diff options
| author | Stefan Monnier | 2011-05-27 23:10:32 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-05-27 23:10:32 -0300 |
| commit | 0ff8e1ba6b4819aca0c95e15e2255908e3d276d3 (patch) | |
| tree | b62dc69878bddd314c98a718d81edbb9c29cc05d | |
| parent | 423428a80c423a32727ad1e01442b020835fb92b (diff) | |
| download | emacs-0ff8e1ba6b4819aca0c95e15e2255908e3d276d3.tar.gz emacs-0ff8e1ba6b4819aca0c95e15e2255908e3d276d3.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/erc/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/erc/erc-pcomplete.el | 9 | ||||
| -rw-r--r-- | lisp/info-look.el | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 31 | ||||
| -rw-r--r-- | lisp/progmodes/etags.el | 2 |
6 files changed, 50 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d2b495ae669..0b55fb4bba2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2011-05-28 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2011-05-28 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * minibuffer.el (completion--capf-wrapper): Check applicability before | ||
| 4 | retuning non-nil for non-exclusive completion data. | ||
| 5 | * progmodes/etags.el (tags-completion-at-point-function): | ||
| 6 | * info-look.el (info-lookup-completions-at-point): Mark as | ||
| 7 | non-exclusive. | ||
| 8 | (info-complete): Adjust accordingly. | ||
| 9 | |||
| 3 | * info-look.el: Convert to lexical-binding and completion-at-point. | 10 | * info-look.el: Convert to lexical-binding and completion-at-point. |
| 4 | (info-lookup-completions-at-point): New function. | 11 | (info-lookup-completions-at-point): New function. |
| 5 | (info-complete): Use it and completion-in-region. | 12 | (info-complete): Use it and completion-in-region. |
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 187d338c1bc..f1c0b2d1c65 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-05-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * erc-pcomplete.el (erc-pcompletions-at-point): Mark the completion | ||
| 4 | data as non-exclusive if it's using the default-completion-function. | ||
| 5 | (pcomplete-erc-parse-arguments): Rename pcomplete-parse-erc-arguments. | ||
| 6 | (pcomplete-erc-setup): Use new name. | ||
| 7 | |||
| 1 | 2011-05-03 Debarshi Ray <rishi@gnu.org> (tiny change) | 8 | 2011-05-03 Debarshi Ray <rishi@gnu.org> (tiny change) |
| 2 | 9 | ||
| 3 | * erc-backend.el (671): New response handler. | 10 | * erc-backend.el (671): New response handler. |
diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el index eb1398d5b05..a390fcfe84d 100644 --- a/lisp/erc/erc-pcomplete.el +++ b/lisp/erc/erc-pcomplete.el | |||
| @@ -73,7 +73,10 @@ the most recent speakers are listed first." | |||
| 73 | "ERC completion data from pcomplete. | 73 | "ERC completion data from pcomplete. |
| 74 | for use on `completion-at-point-function'." | 74 | for use on `completion-at-point-function'." |
| 75 | (when (> (point) (erc-beg-of-input-line)) | 75 | (when (> (point) (erc-beg-of-input-line)) |
| 76 | (pcomplete-completions-at-point))) | 76 | (or (let ((pcomplete-default-completion-function #'ignore)) |
| 77 | (pcomplete-completions-at-point)) | ||
| 78 | (let ((c (pcomplete-completions-at-point))) | ||
| 79 | (if c (nconc c '(:exclusive no))))))) | ||
| 77 | 80 | ||
| 78 | (defun erc-pcomplete () | 81 | (defun erc-pcomplete () |
| 79 | "Complete the nick before point." | 82 | "Complete the nick before point." |
| @@ -94,7 +97,7 @@ for use on `completion-at-point-function'." | |||
| 94 | (set (make-local-variable 'pcomplete-use-paring) | 97 | (set (make-local-variable 'pcomplete-use-paring) |
| 95 | nil) | 98 | nil) |
| 96 | (set (make-local-variable 'pcomplete-parse-arguments-function) | 99 | (set (make-local-variable 'pcomplete-parse-arguments-function) |
| 97 | 'pcomplete-parse-erc-arguments) | 100 | 'pcomplete-erc-parse-arguments) |
| 98 | (set (make-local-variable 'pcomplete-command-completion-function) | 101 | (set (make-local-variable 'pcomplete-command-completion-function) |
| 99 | 'pcomplete/erc-mode/complete-command) | 102 | 'pcomplete/erc-mode/complete-command) |
| 100 | (set (make-local-variable 'pcomplete-command-name-function) | 103 | (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." | |||
| 254 | (upcase (substring (pcomplete-arg 'first) 1)) | 257 | (upcase (substring (pcomplete-arg 'first) 1)) |
| 255 | "SAY")) | 258 | "SAY")) |
| 256 | 259 | ||
| 257 | (defun pcomplete-parse-erc-arguments () | 260 | (defun pcomplete-erc-parse-arguments () |
| 258 | "Returns a list of parsed whitespace-separated arguments. | 261 | "Returns a list of parsed whitespace-separated arguments. |
| 259 | These are the words from the beginning of the line after the prompt | 262 | These are the words from the beginning of the line after the prompt |
| 260 | up to where point is right now." | 263 | up to where point is right now." |
diff --git a/lisp/info-look.el b/lisp/info-look.el index 26a89ca956e..2cfaa81d4c7 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el | |||
| @@ -667,7 +667,8 @@ Return nil if there is nothing appropriate in the buffer near point." | |||
| 667 | (end-of-line) | 667 | (end-of-line) |
| 668 | (while (and (search-backward try nil t) | 668 | (while (and (search-backward try nil t) |
| 669 | (< start (point)))) | 669 | (< start (point)))) |
| 670 | (list (match-beginning 0) (match-end 0) completions)))))))) | 670 | (list (match-beginning 0) (match-end 0) completions |
| 671 | :exclusive 'no)))))))) | ||
| 671 | 672 | ||
| 672 | (defun info-complete (topic mode) | 673 | (defun info-complete (topic mode) |
| 673 | "Try to complete a help item." | 674 | "Try to complete a help item." |
| @@ -675,7 +676,7 @@ Return nil if there is nothing appropriate in the buffer near point." | |||
| 675 | (let ((data (info-lookup-completions-at-point topic mode))) | 676 | (let ((data (info-lookup-completions-at-point topic mode))) |
| 676 | (if (null data) | 677 | (if (null data) |
| 677 | (error "No %s completion available for `%s' at point" topic mode) | 678 | (error "No %s completion available for `%s' at point" topic mode) |
| 678 | (apply #'completion-in-region data)))) | 679 | (completion-in-region (nth 0 data) (nth 1 data) (nth 2 data))))) |
| 679 | 680 | ||
| 680 | 681 | ||
| 681 | ;;; Initialize some common modes. | 682 | ;;; Initialize some common modes. |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f3d92b18722..7af602c629b 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -1433,12 +1433,19 @@ or a list of the form (START END COLLECTION &rest PROPS) where | |||
| 1433 | PROPS is a property list for additional information. | 1433 | PROPS is a property list for additional information. |
| 1434 | Currently supported properties are all the properties that can appear in | 1434 | Currently supported properties are all the properties that can appear in |
| 1435 | `completion-extra-properties' plus: | 1435 | `completion-extra-properties' plus: |
| 1436 | `:predicate' a predicate that completion candidates need to satisfy.") | 1436 | `:predicate' a predicate that completion candidates need to satisfy. |
| 1437 | `:exclusive' If `no', means that if the completion data does not match the | ||
| 1438 | text at point failure, then instead of reporting a completion failure, | ||
| 1439 | the completion should try the next completion function.") | ||
| 1437 | 1440 | ||
| 1438 | (defvar completion--capf-misbehave-funs nil | 1441 | (defvar completion--capf-misbehave-funs nil |
| 1439 | "List of functions found on `completion-at-point-functions' that misbehave.") | 1442 | "List of functions found on `completion-at-point-functions' that misbehave. |
| 1443 | These are functions that neither return completion data nor a completion | ||
| 1444 | function but instead perform completion right away.") | ||
| 1440 | (defvar completion--capf-safe-funs nil | 1445 | (defvar completion--capf-safe-funs nil |
| 1441 | "List of well-behaved functions found on `completion-at-point-functions'.") | 1446 | "List of well-behaved functions found on `completion-at-point-functions'. |
| 1447 | These are functions which return proper completion data rather than | ||
| 1448 | a completion function or god knows what else.") | ||
| 1442 | 1449 | ||
| 1443 | (defun completion--capf-wrapper (fun which) | 1450 | (defun completion--capf-wrapper (fun which) |
| 1444 | ;; FIXME: The safe/misbehave handling assumes that a given function will | 1451 | ;; 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 | |||
| 1451 | (optimist (not (member fun completion--capf-misbehave-funs)))) | 1458 | (optimist (not (member fun completion--capf-misbehave-funs)))) |
| 1452 | (let ((res (funcall fun))) | 1459 | (let ((res (funcall fun))) |
| 1453 | (cond | 1460 | (cond |
| 1454 | ((consp res) | 1461 | ((and (consp res) (not (functionp res))) |
| 1455 | (unless (member fun completion--capf-safe-funs) | 1462 | (unless (member fun completion--capf-safe-funs) |
| 1456 | (push fun completion--capf-safe-funs))) | 1463 | (push fun completion--capf-safe-funs)) |
| 1464 | (and (eq 'no (plist-get (nthcdr 3 res) :exclusive)) | ||
| 1465 | ;; FIXME: Here we'd need to decide whether there are | ||
| 1466 | ;; valid completions against the current text. But this depends | ||
| 1467 | ;; on the actual completion UI (e.g. with the default completion | ||
| 1468 | ;; it depends on completion-style) ;-( | ||
| 1469 | ;; We approximate this result by checking whether prefix | ||
| 1470 | ;; completion might work, which means that non-prefix completion | ||
| 1471 | ;; will not work (or not right) for completion functions that | ||
| 1472 | ;; are non-exclusive. | ||
| 1473 | (null (try-completion (buffer-substring-no-properties | ||
| 1474 | (car res) (point)) | ||
| 1475 | (nth 2 res) | ||
| 1476 | (plist-get (nthcdr 3 res) :predicate))) | ||
| 1477 | (setq res nil))) | ||
| 1457 | ((not (or (listp res) (functionp res))) | 1478 | ((not (or (listp res) (functionp res))) |
| 1458 | (unless (member fun completion--capf-misbehave-funs) | 1479 | (unless (member fun completion--capf-misbehave-funs) |
| 1459 | (message | 1480 | (message |
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 6bd2de992cb..8abf298bb76 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el | |||
| @@ -812,7 +812,7 @@ If no tags table is loaded, do nothing and return nil." | |||
| 812 | (search-backward pattern) ;FIXME: will fail if we're inside pattern. | 812 | (search-backward pattern) ;FIXME: will fail if we're inside pattern. |
| 813 | (setq beg (point)) | 813 | (setq beg (point)) |
| 814 | (forward-char (length pattern)) | 814 | (forward-char (length pattern)) |
| 815 | (list beg (point) (tags-lazy-completion-table))))))) | 815 | (list beg (point) (tags-lazy-completion-table) :exclusive 'no)))))) |
| 816 | 816 | ||
| 817 | (defun find-tag-tag (string) | 817 | (defun find-tag-tag (string) |
| 818 | "Read a tag name, with defaulting and completion." | 818 | "Read a tag name, with defaulting and completion." |