emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104396: * lisp/minibuffer.el (comple


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104396: * lisp/minibuffer.el (completion--capf-wrapper): Check applicability before
Date: Fri, 27 May 2011 23:10:32 -0300
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104396
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2011-05-27 23:10:32 -0300
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/erc/ChangeLog
  lisp/erc/erc-pcomplete.el
  lisp/info-look.el
  lisp/minibuffer.el
  lisp/progmodes/etags.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-28 01:33:10 +0000
+++ b/lisp/ChangeLog    2011-05-28 02:10:32 +0000
@@ -1,5 +1,12 @@
 2011-05-28  Stefan Monnier  <address@hidden>
 
+       * 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.

=== modified file 'lisp/erc/ChangeLog'
--- a/lisp/erc/ChangeLog        2011-05-03 15:51:14 +0000
+++ b/lisp/erc/ChangeLog        2011-05-28 02:10:32 +0000
@@ -1,3 +1,10 @@
+2011-05-28  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>  (tiny change)
 
        * erc-backend.el (671): New response handler.

=== modified file 'lisp/erc/erc-pcomplete.el'
--- a/lisp/erc/erc-pcomplete.el 2011-04-29 15:23:59 +0000
+++ b/lisp/erc/erc-pcomplete.el 2011-05-28 02:10:32 +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))
+        (let ((c (pcomplete-completions-at-point)))
+          (if c (nconc c '(:exclusive no)))))))
 
 (defun erc-pcomplete ()
   "Complete the nick before point."
@@ -94,7 +97,7 @@
   (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 @@
       (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."

=== modified file 'lisp/info-look.el'
--- a/lisp/info-look.el 2011-05-28 01:33:10 +0000
+++ b/lisp/info-look.el 2011-05-28 02:10:32 +0000
@@ -667,7 +667,8 @@
               (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 @@
   (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.

=== modified file 'lisp/minibuffer.el'
--- a/lisp/minibuffer.el        2011-05-24 02:45:50 +0000
+++ b/lisp/minibuffer.el        2011-05-28 02:10:32 +0000
@@ -1433,12 +1433,19 @@
  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 @@
         (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

=== modified file 'lisp/progmodes/etags.el'
--- a/lisp/progmodes/etags.el   2011-04-24 18:47:17 +0000
+++ b/lisp/progmodes/etags.el   2011-05-28 02:10:32 +0000
@@ -812,7 +812,7 @@
          (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."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]