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.
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.
+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.
"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."
(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)
(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."
(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."
(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)))))
\f
;;; Initialize some common modes.
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
(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
(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))))))
\f
(defun find-tag-tag (string)
"Read a tag name, with defaulting and completion."