diff options
| author | Chong Yidong | 2010-10-03 15:50:14 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-10-03 15:50:14 -0400 |
| commit | 397ae2261860609d3f320b9c4255ca8f92353c50 (patch) | |
| tree | f6386c1afb534e2570a3019fbbbe1d90a67e63c6 | |
| parent | 8686a5eafc46055d39c30104ebe209a100940f1c (diff) | |
| download | emacs-397ae2261860609d3f320b9c4255ca8f92353c50.tar.gz emacs-397ae2261860609d3f320b9c4255ca8f92353c50.zip | |
Use lexical-let to avoid false matches in var completion (Bug#7056).
* lisp/minibuffer.el (completion--some, completion--do-completion)
(minibuffer-complete-and-exit, minibuffer-completion-help)
(completion-basic-try-completion)
(completion-basic-all-completions)
(completion-pcm--find-all-completions): Use lexical-let to
avoid some false matches in variable completion (Bug#7056)
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 112 |
2 files changed, 68 insertions, 53 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 84162ef502d..85d108356cc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2010-10-03 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * minibuffer.el (completion--some, completion--do-completion) | ||
| 4 | (minibuffer-complete-and-exit, minibuffer-completion-help) | ||
| 5 | (completion-basic-try-completion) | ||
| 6 | (completion-basic-all-completions) | ||
| 7 | (completion-pcm--find-all-completions): Use lexical-let to | ||
| 8 | avoid some false matches in variable completion (Bug#7056) | ||
| 9 | |||
| 1 | 2010-10-03 Olof Ohlsson Sax <olof.ohlsson.sax@gmail.com> (tiny change) | 10 | 2010-10-03 Olof Ohlsson Sax <olof.ohlsson.sax@gmail.com> (tiny change) |
| 2 | 11 | ||
| 3 | * vc-svn.el (vc-svn-merge-news): Use --non-interactive. (Bug#7152) | 12 | * vc-svn.el (vc-svn-merge-news): Use --non-interactive. (Bug#7152) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 9a477020421..a4ab5261f7c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -129,8 +129,8 @@ the closest directory separators." | |||
| 129 | "Apply FUN to each element of XS in turn. | 129 | "Apply FUN to each element of XS in turn. |
| 130 | Return the first non-nil returned value. | 130 | Return the first non-nil returned value. |
| 131 | Like CL's `some'." | 131 | Like CL's `some'." |
| 132 | (let ((firsterror nil) | 132 | (lexical-let ((firsterror nil) |
| 133 | res) | 133 | res) |
| 134 | (while (and (not res) xs) | 134 | (while (and (not res) xs) |
| 135 | (condition-case err | 135 | (condition-case err |
| 136 | (setq res (funcall fun (pop xs))) | 136 | (setq res (funcall fun (pop xs))) |
| @@ -518,15 +518,16 @@ E = after completion we now have an Exact match. | |||
| 518 | 101 5 ??? impossible | 518 | 101 5 ??? impossible |
| 519 | 110 6 some completion happened | 519 | 110 6 some completion happened |
| 520 | 111 7 completed to an exact completion" | 520 | 111 7 completed to an exact completion" |
| 521 | (let* ((beg (field-beginning)) | 521 | (lexical-let* |
| 522 | (end (field-end)) | 522 | ((beg (field-beginning)) |
| 523 | (string (buffer-substring beg end)) | 523 | (end (field-end)) |
| 524 | (comp (funcall (or try-completion-function | 524 | (string (buffer-substring beg end)) |
| 525 | 'completion-try-completion) | 525 | (comp (funcall (or try-completion-function |
| 526 | string | 526 | 'completion-try-completion) |
| 527 | minibuffer-completion-table | 527 | string |
| 528 | minibuffer-completion-predicate | 528 | minibuffer-completion-table |
| 529 | (- (point) beg)))) | 529 | minibuffer-completion-predicate |
| 530 | (- (point) beg)))) | ||
| 530 | (cond | 531 | (cond |
| 531 | ((null comp) | 532 | ((null comp) |
| 532 | (minibuffer-hide-completions) | 533 | (minibuffer-hide-completions) |
| @@ -539,14 +540,15 @@ E = after completion we now have an Exact match. | |||
| 539 | ;; `completed' should be t if some completion was done, which doesn't | 540 | ;; `completed' should be t if some completion was done, which doesn't |
| 540 | ;; include simply changing the case of the entered string. However, | 541 | ;; include simply changing the case of the entered string. However, |
| 541 | ;; for appearance, the string is rewritten if the case changes. | 542 | ;; for appearance, the string is rewritten if the case changes. |
| 542 | (let* ((comp-pos (cdr comp)) | 543 | (lexical-let* |
| 543 | (completion (car comp)) | 544 | ((comp-pos (cdr comp)) |
| 544 | (completed (not (eq t (compare-strings completion nil nil | 545 | (completion (car comp)) |
| 545 | string nil nil t)))) | 546 | (completed (not (eq t (compare-strings completion nil nil |
| 546 | (unchanged (eq t (compare-strings completion nil nil | 547 | string nil nil t)))) |
| 547 | string nil nil nil)))) | 548 | (unchanged (eq t (compare-strings completion nil nil |
| 549 | string nil nil nil)))) | ||
| 548 | (if unchanged | 550 | (if unchanged |
| 549 | (goto-char end) | 551 | (goto-char end) |
| 550 | ;; Insert in minibuffer the chars we got. | 552 | ;; Insert in minibuffer the chars we got. |
| 551 | (completion--replace beg end completion)) | 553 | (completion--replace beg end completion)) |
| 552 | ;; Move point to its completion-mandated destination. | 554 | ;; Move point to its completion-mandated destination. |
| @@ -693,8 +695,8 @@ If `minibuffer-completion-confirm' is `confirm-after-completion', | |||
| 693 | `minibuffer-confirm-exit-commands', and accept the input | 695 | `minibuffer-confirm-exit-commands', and accept the input |
| 694 | otherwise." | 696 | otherwise." |
| 695 | (interactive) | 697 | (interactive) |
| 696 | (let ((beg (field-beginning)) | 698 | (lexical-let ((beg (field-beginning)) |
| 697 | (end (field-end))) | 699 | (end (field-end))) |
| 698 | (cond | 700 | (cond |
| 699 | ;; Allow user to specify null string | 701 | ;; Allow user to specify null string |
| 700 | ((= beg end) (exit-minibuffer)) | 702 | ((= beg end) (exit-minibuffer)) |
| @@ -1071,13 +1073,13 @@ variables.") | |||
| 1071 | "Display a list of possible completions of the current minibuffer contents." | 1073 | "Display a list of possible completions of the current minibuffer contents." |
| 1072 | (interactive) | 1074 | (interactive) |
| 1073 | (message "Making completion list...") | 1075 | (message "Making completion list...") |
| 1074 | (let* ((start (field-beginning)) | 1076 | (lexical-let* ((start (field-beginning)) |
| 1075 | (string (field-string)) | 1077 | (string (field-string)) |
| 1076 | (completions (completion-all-completions | 1078 | (completions (completion-all-completions |
| 1077 | string | 1079 | string |
| 1078 | minibuffer-completion-table | 1080 | minibuffer-completion-table |
| 1079 | minibuffer-completion-predicate | 1081 | minibuffer-completion-predicate |
| 1080 | (- (point) (field-beginning))))) | 1082 | (- (point) (field-beginning))))) |
| 1081 | (message nil) | 1083 | (message nil) |
| 1082 | (if (and completions | 1084 | (if (and completions |
| 1083 | (or (consp (cdr completions)) | 1085 | (or (consp (cdr completions)) |
| @@ -1707,9 +1709,10 @@ Return the new suffix." | |||
| 1707 | suffix)) | 1709 | suffix)) |
| 1708 | 1710 | ||
| 1709 | (defun completion-basic-try-completion (string table pred point) | 1711 | (defun completion-basic-try-completion (string table pred point) |
| 1710 | (let* ((beforepoint (substring string 0 point)) | 1712 | (lexical-let* |
| 1711 | (afterpoint (substring string point)) | 1713 | ((beforepoint (substring string 0 point)) |
| 1712 | (bounds (completion-boundaries beforepoint table pred afterpoint))) | 1714 | (afterpoint (substring string point)) |
| 1715 | (bounds (completion-boundaries beforepoint table pred afterpoint))) | ||
| 1713 | (if (zerop (cdr bounds)) | 1716 | (if (zerop (cdr bounds)) |
| 1714 | ;; `try-completion' may return a subtly different result | 1717 | ;; `try-completion' may return a subtly different result |
| 1715 | ;; than `all+merge', so try to use it whenever possible. | 1718 | ;; than `all+merge', so try to use it whenever possible. |
| @@ -1720,28 +1723,30 @@ Return the new suffix." | |||
| 1720 | (concat completion | 1723 | (concat completion |
| 1721 | (completion--merge-suffix completion point afterpoint)) | 1724 | (completion--merge-suffix completion point afterpoint)) |
| 1722 | (length completion)))) | 1725 | (length completion)))) |
| 1723 | (let* ((suffix (substring afterpoint (cdr bounds))) | 1726 | (lexical-let* |
| 1724 | (prefix (substring beforepoint 0 (car bounds))) | 1727 | ((suffix (substring afterpoint (cdr bounds))) |
| 1725 | (pattern (delete | 1728 | (prefix (substring beforepoint 0 (car bounds))) |
| 1726 | "" (list (substring beforepoint (car bounds)) | 1729 | (pattern (delete |
| 1727 | 'point | 1730 | "" (list (substring beforepoint (car bounds)) |
| 1728 | (substring afterpoint 0 (cdr bounds))))) | 1731 | 'point |
| 1729 | (all (completion-pcm--all-completions prefix pattern table pred))) | 1732 | (substring afterpoint 0 (cdr bounds))))) |
| 1733 | (all (completion-pcm--all-completions prefix pattern table pred))) | ||
| 1730 | (if minibuffer-completing-file-name | 1734 | (if minibuffer-completing-file-name |
| 1731 | (setq all (completion-pcm--filename-try-filter all))) | 1735 | (setq all (completion-pcm--filename-try-filter all))) |
| 1732 | (completion-pcm--merge-try pattern all prefix suffix))))) | 1736 | (completion-pcm--merge-try pattern all prefix suffix))))) |
| 1733 | 1737 | ||
| 1734 | (defun completion-basic-all-completions (string table pred point) | 1738 | (defun completion-basic-all-completions (string table pred point) |
| 1735 | (let* ((beforepoint (substring string 0 point)) | 1739 | (lexical-let* |
| 1736 | (afterpoint (substring string point)) | 1740 | ((beforepoint (substring string 0 point)) |
| 1737 | (bounds (completion-boundaries beforepoint table pred afterpoint)) | 1741 | (afterpoint (substring string point)) |
| 1738 | (suffix (substring afterpoint (cdr bounds))) | 1742 | (bounds (completion-boundaries beforepoint table pred afterpoint)) |
| 1739 | (prefix (substring beforepoint 0 (car bounds))) | 1743 | (suffix (substring afterpoint (cdr bounds))) |
| 1740 | (pattern (delete | 1744 | (prefix (substring beforepoint 0 (car bounds))) |
| 1741 | "" (list (substring beforepoint (car bounds)) | 1745 | (pattern (delete |
| 1742 | 'point | 1746 | "" (list (substring beforepoint (car bounds)) |
| 1743 | (substring afterpoint 0 (cdr bounds))))) | 1747 | 'point |
| 1744 | (all (completion-pcm--all-completions prefix pattern table pred))) | 1748 | (substring afterpoint 0 (cdr bounds))))) |
| 1749 | (all (completion-pcm--all-completions prefix pattern table pred))) | ||
| 1745 | (completion-hilit-commonality all point (car bounds)))) | 1750 | (completion-hilit-commonality all point (car bounds)))) |
| 1746 | 1751 | ||
| 1747 | ;;; Partial-completion-mode style completion. | 1752 | ;;; Partial-completion-mode style completion. |
| @@ -1896,12 +1901,13 @@ POINT is a position inside STRING. | |||
| 1896 | FILTER is a function applied to the return value, that can be used, e.g. to | 1901 | FILTER is a function applied to the return value, that can be used, e.g. to |
| 1897 | filter out additional entries (because TABLE migth not obey PRED)." | 1902 | filter out additional entries (because TABLE migth not obey PRED)." |
| 1898 | (unless filter (setq filter 'identity)) | 1903 | (unless filter (setq filter 'identity)) |
| 1899 | (let* ((beforepoint (substring string 0 point)) | 1904 | (lexical-let* |
| 1900 | (afterpoint (substring string point)) | 1905 | ((beforepoint (substring string 0 point)) |
| 1901 | (bounds (completion-boundaries beforepoint table pred afterpoint)) | 1906 | (afterpoint (substring string point)) |
| 1902 | (prefix (substring beforepoint 0 (car bounds))) | 1907 | (bounds (completion-boundaries beforepoint table pred afterpoint)) |
| 1903 | (suffix (substring afterpoint (cdr bounds))) | 1908 | (prefix (substring beforepoint 0 (car bounds))) |
| 1904 | firsterror) | 1909 | (suffix (substring afterpoint (cdr bounds))) |
| 1910 | firsterror) | ||
| 1905 | (setq string (substring string (car bounds) (+ point (cdr bounds)))) | 1911 | (setq string (substring string (car bounds) (+ point (cdr bounds)))) |
| 1906 | (let* ((relpoint (- point (car bounds))) | 1912 | (let* ((relpoint (- point (car bounds))) |
| 1907 | (pattern (completion-pcm--string->pattern string relpoint)) | 1913 | (pattern (completion-pcm--string->pattern string relpoint)) |