* lisp/minibuffer.el (completion--capf-wrapper): Check applicability before

retuning non-nil for non-exclusive completion data.
* lisp/progmodes/etags.el (tags-completion-at-point-function):
* lisp/info-look.el (info-lookup-completions-at-point): Mark as non-exclusive.
(info-complete): Adjust accordingly.
* lisp/erc/erc-pcomplete.el (erc-pcompletions-at-point): Mark the completion
data as non-exclusive if it's using the default-completion-function.
(pcomplete-erc-parse-arguments): Rename pcomplete-parse-erc-arguments.
(pcomplete-erc-setup): Use new name.
This commit is contained in:
Stefan Monnier 2011-05-27 23:10:32 -03:00
parent 423428a80c
commit 0ff8e1ba6b
6 changed files with 50 additions and 11 deletions

View file

@ -1,5 +1,12 @@
2011-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
* minibuffer.el (completion--capf-wrapper): Check applicability before
retuning non-nil for non-exclusive completion data.
* progmodes/etags.el (tags-completion-at-point-function):
* info-look.el (info-lookup-completions-at-point): Mark as
non-exclusive.
(info-complete): Adjust accordingly.
* info-look.el: Convert to lexical-binding and completion-at-point.
(info-lookup-completions-at-point): New function.
(info-complete): Use it and completion-in-region.

View file

@ -1,3 +1,10 @@
2011-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
* erc-pcomplete.el (erc-pcompletions-at-point): Mark the completion
data as non-exclusive if it's using the default-completion-function.
(pcomplete-erc-parse-arguments): Rename pcomplete-parse-erc-arguments.
(pcomplete-erc-setup): Use new name.
2011-05-03 Debarshi Ray <rishi@gnu.org> (tiny change)
* erc-backend.el (671): New response handler.

View file

@ -73,7 +73,10 @@ the most recent speakers are listed first."
"ERC completion data from pcomplete.
for use on `completion-at-point-function'."
(when (> (point) (erc-beg-of-input-line))
(pcomplete-completions-at-point)))
(or (let ((pcomplete-default-completion-function #'ignore))
(pcomplete-completions-at-point))
(let ((c (pcomplete-completions-at-point)))
(if c (nconc c '(:exclusive no)))))))
(defun erc-pcomplete ()
"Complete the nick before point."
@ -94,7 +97,7 @@ for use on `completion-at-point-function'."
(set (make-local-variable 'pcomplete-use-paring)
nil)
(set (make-local-variable 'pcomplete-parse-arguments-function)
'pcomplete-parse-erc-arguments)
'pcomplete-erc-parse-arguments)
(set (make-local-variable 'pcomplete-command-completion-function)
'pcomplete/erc-mode/complete-command)
(set (make-local-variable 'pcomplete-command-name-function)
@ -254,7 +257,7 @@ If optional argument IGNORE-SELF is non-nil, don't return the current nick."
(upcase (substring (pcomplete-arg 'first) 1))
"SAY"))
(defun pcomplete-parse-erc-arguments ()
(defun pcomplete-erc-parse-arguments ()
"Returns a list of parsed whitespace-separated arguments.
These are the words from the beginning of the line after the prompt
up to where point is right now."

View file

@ -667,7 +667,8 @@ Return nil if there is nothing appropriate in the buffer near point."
(end-of-line)
(while (and (search-backward try nil t)
(< start (point))))
(list (match-beginning 0) (match-end 0) completions))))))))
(list (match-beginning 0) (match-end 0) completions
:exclusive 'no))))))))
(defun info-complete (topic mode)
"Try to complete a help item."
@ -675,7 +676,7 @@ Return nil if there is nothing appropriate in the buffer near point."
(let ((data (info-lookup-completions-at-point topic mode)))
(if (null data)
(error "No %s completion available for `%s' at point" topic mode)
(apply #'completion-in-region data))))
(completion-in-region (nth 0 data) (nth 1 data) (nth 2 data)))))
;;; Initialize some common modes.

View file

@ -1433,12 +1433,19 @@ or a list of the form (START END COLLECTION &rest PROPS) where
PROPS is a property list for additional information.
Currently supported properties are all the properties that can appear in
`completion-extra-properties' plus:
`:predicate' a predicate that completion candidates need to satisfy.")
`:predicate' a predicate that completion candidates need to satisfy.
`:exclusive' If `no', means that if the completion data does not match the
text at point failure, then instead of reporting a completion failure,
the completion should try the next completion function.")
(defvar completion--capf-misbehave-funs nil
"List of functions found on `completion-at-point-functions' that misbehave.")
"List of functions found on `completion-at-point-functions' that misbehave.
These are functions that neither return completion data nor a completion
function but instead perform completion right away.")
(defvar completion--capf-safe-funs nil
"List of well-behaved functions found on `completion-at-point-functions'.")
"List of well-behaved functions found on `completion-at-point-functions'.
These are functions which return proper completion data rather than
a completion function or god knows what else.")
(defun completion--capf-wrapper (fun which)
;; FIXME: The safe/misbehave handling assumes that a given function will
@ -1451,9 +1458,23 @@ Currently supported properties are all the properties that can appear in
(optimist (not (member fun completion--capf-misbehave-funs))))
(let ((res (funcall fun)))
(cond
((consp res)
((and (consp res) (not (functionp res)))
(unless (member fun completion--capf-safe-funs)
(push fun completion--capf-safe-funs)))
(push fun completion--capf-safe-funs))
(and (eq 'no (plist-get (nthcdr 3 res) :exclusive))
;; FIXME: Here we'd need to decide whether there are
;; valid completions against the current text. But this depends
;; on the actual completion UI (e.g. with the default completion
;; it depends on completion-style) ;-(
;; We approximate this result by checking whether prefix
;; completion might work, which means that non-prefix completion
;; will not work (or not right) for completion functions that
;; are non-exclusive.
(null (try-completion (buffer-substring-no-properties
(car res) (point))
(nth 2 res)
(plist-get (nthcdr 3 res) :predicate)))
(setq res nil)))
((not (or (listp res) (functionp res)))
(unless (member fun completion--capf-misbehave-funs)
(message

View file

@ -812,7 +812,7 @@ If no tags table is loaded, do nothing and return nil."
(search-backward pattern) ;FIXME: will fail if we're inside pattern.
(setq beg (point))
(forward-char (length pattern))
(list beg (point) (tags-lazy-completion-table)))))))
(list beg (point) (tags-lazy-completion-table) :exclusive 'no))))))
(defun find-tag-tag (string)
"Read a tag name, with defaulting and completion."