From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Monnier Subject: Re: Completing with anything Date: Wed, 25 May 2011 23:23:38 -0300 Message-ID: References: <87r5bhysp6.fsf@keller.adm.naquadah.org> <87vd0qfhu3.fsf@member.fsf.org> <87y63jpii5.fsf@keller.adm.naquadah.org> <871v0ecwe4.fsf@keller.adm.naquadah.org> <87aaecihl2.fsf@gmail.com> <87lixwkzi4.fsf@gmail.com> <87d3j8vtn5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <87d3j8vtn5.fsf@gmail.com> (Antoine Levitt's message of "Tue, 24 May 2011 20:30:06 +0200") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org To: Antoine Levitt Cc: emacs-orgmode@gnu.org, emacs-devel@gnu.org List-Id: emacs-orgmode.gnu.org >> Another is to do it more selectively, flag some of >> completion-at-point-functions as "not-exclusive", meaning that if >> completion fails with those we should keep trying with subsequent >> functions. E.g. the nick completion in rcirc could be flagged as >> non-exclusive since it applies everywhere, which in turn would let >> your dabbrev-expand kick in when nick-completion fails. > This seems to be the most flexible, while still keeping all the > completions in the same UI. I'd make the non-exclusive behaviour the > default though: let the functions that want to "take over" the > completion state it explicitely. I actually much prefer the it the other way around. Most completion-at-point-functions should be pretty specific, checking the context to decide whether they should be used at point, so they can be exclusive. Can you try the patch below to see if it gives you back the old behavior in ERC? Stefan === modified file 'lisp/erc/erc-pcomplete.el' --- lisp/erc/erc-pcomplete.el 2011-04-29 15:23:59 +0000 +++ lisp/erc/erc-pcomplete.el 2011-05-26 02:12:19 +0000 @@ -73,7 +73,10 @@ "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)) + (nconc (pcomplete-completions-at-point) + '(:exclusivity 'non-exclusive))))) (defun erc-pcomplete () "Complete the nick before point." === modified file 'lisp/minibuffer.el' --- lisp/minibuffer.el 2011-05-24 02:45:50 +0000 +++ lisp/minibuffer.el 2011-05-26 02:16:05 +0000 @@ -1436,9 +1436,13 @@ `:predicate' a predicate that completion candidates need to satisfy.") (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 +1455,23 @@ (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 'non-exclusive (plist-get (nthcdr 3 res) :exclusivity)) + ;; 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