aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-08-30 03:45:30 +0000
committerStefan Monnier2009-08-30 03:45:30 +0000
commitab22be48bdbaab243f708566cb38b8f2a1c3cd32 (patch)
treeda5348a2746143c03004a14d1ed6b63f4cf4fded
parent744256cf1b1113a67f0c176adbbcf7d1839d6762 (diff)
downloademacs-ab22be48bdbaab243f708566cb38b8f2a1c3cd32.tar.gz
emacs-ab22be48bdbaab243f708566cb38b8f2a1c3cd32.zip
(minibuffer-message): If the current buffer is not
a minibuffer, insert the message in the echo area rather than at the end of the buffer. (completion-annotate-function): New variable. (minibuffer-completion-help): Use it. (completion--embedded-envvar-table): Environment vars are always case-sensitive.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/minibuffer.el124
2 files changed, 96 insertions, 38 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 840111dadfd..d3eb3e405be 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12009-08-30 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * minibuffer.el (minibuffer-message): If the current buffer is not
4 a minibuffer, insert the message in the echo area rather than at the
5 end of the buffer.
6 (completion-annotate-function): New variable.
7 (minibuffer-completion-help): Use it.
8 (completion--embedded-envvar-table): Environment vars are
9 always case-sensitive.
10
12009-08-30 Glenn Morris <rgm@gnu.org> 112009-08-30 Glenn Morris <rgm@gnu.org>
2 12
3 * progmodes/fortran.el (fortran-start-prog-re): New constant, extracted 13 * progmodes/fortran.el (fortran-start-prog-re): New constant, extracted
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index e8862eba6d1..5ab3e412232 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -30,7 +30,6 @@
30;; (boundaries START . END). See `completion-boundaries'. 30;; (boundaries START . END). See `completion-boundaries'.
31;; Any other return value should be ignored (so we ignore values returned 31;; Any other return value should be ignored (so we ignore values returned
32;; from completion tables that don't know about this new `action' form). 32;; from completion tables that don't know about this new `action' form).
33;; See `completion-boundaries'.
34 33
35;;; Bugs: 34;;; Bugs:
36 35
@@ -40,10 +39,23 @@
40;; - choose-completion can't automatically figure out the boundaries 39;; - choose-completion can't automatically figure out the boundaries
41;; corresponding to the displayed completions. `base-size' gives the left 40;; corresponding to the displayed completions. `base-size' gives the left
42;; boundary, but not the righthand one. So we need to add 41;; boundary, but not the righthand one. So we need to add
43;; completion-extra-size (and also completion-no-auto-exit). 42;; completion-extra-size.
44 43
45;;; Todo: 44;;; Todo:
46 45
46;; - make partial-complete-mode obsolete:
47;; - make M-x lch TAB expand to list-command-history.
48;; (not sure how/where it's implemented in complete.el)
49;; - (?) <foo.h> style completion for file names.
50
51;; - case-sensitivity is currently confuses two issues:
52;; - whether or not a particular completion table should be case-sensitive
53;; (i.e. whether strings that different only by case are semantically
54;; equivalent)
55;; - whether the user wants completion to pay attention to case.
56;; e.g. we may want to make it possible for the user to say "first try
57;; completion case-sensitively, and if that fails, try to ignore case".
58
47;; - make lisp-complete-symbol and sym-comp use it. 59;; - make lisp-complete-symbol and sym-comp use it.
48;; - add support for ** to pcm. 60;; - add support for ** to pcm.
49;; - Make read-file-name-predicate obsolete. 61;; - Make read-file-name-predicate obsolete.
@@ -248,31 +260,38 @@ The text is displayed for `minibuffer-message-timeout' seconds,
248or until the next input event arrives, whichever comes first. 260or until the next input event arrives, whichever comes first.
249Enclose MESSAGE in [...] if this is not yet the case. 261Enclose MESSAGE in [...] if this is not yet the case.
250If ARGS are provided, then pass MESSAGE through `format'." 262If ARGS are provided, then pass MESSAGE through `format'."
251 ;; Clear out any old echo-area message to make way for our new thing. 263 (if (not (minibufferp (current-buffer)))
252 (message nil) 264 (progn
253 (setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message)) 265 (if args
254 ;; Make sure we can put-text-property. 266 (apply 'message message args)
255 (copy-sequence message) 267 (message "%s" message))
256 (concat " [" message "]"))) 268 (prog1 (sit-for (or minibuffer-message-timeout 1000000))
257 (when args (setq message (apply 'format message args))) 269 (message nil)))
258 (let ((ol (make-overlay (point-max) (point-max) nil t t)) 270 ;; Clear out any old echo-area message to make way for our new thing.
259 ;; A quit during sit-for normally only interrupts the sit-for, 271 (message nil)
260 ;; but since minibuffer-message is used at the end of a command, 272 (setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message))
261 ;; at a time when the command has virtually finished already, a C-g 273 ;; Make sure we can put-text-property.
262 ;; should really cause an abort-recursive-edit instead (i.e. as if 274 (copy-sequence message)
263 ;; the C-g had been typed at top-level). Binding inhibit-quit here 275 (concat " [" message "]")))
264 ;; is an attempt to get that behavior. 276 (when args (setq message (apply 'format message args)))
265 (inhibit-quit t)) 277 (let ((ol (make-overlay (point-max) (point-max) nil t t))
266 (unwind-protect 278 ;; A quit during sit-for normally only interrupts the sit-for,
267 (progn 279 ;; but since minibuffer-message is used at the end of a command,
268 (unless (zerop (length message)) 280 ;; at a time when the command has virtually finished already, a C-g
269 ;; The current C cursor code doesn't know to use the overlay's 281 ;; should really cause an abort-recursive-edit instead (i.e. as if
270 ;; marker's stickiness to figure out whether to place the cursor 282 ;; the C-g had been typed at top-level). Binding inhibit-quit here
271 ;; before or after the string, so let's spoon-feed it the pos. 283 ;; is an attempt to get that behavior.
272 (put-text-property 0 1 'cursor t message)) 284 (inhibit-quit t))
273 (overlay-put ol 'after-string message) 285 (unwind-protect
274 (sit-for (or minibuffer-message-timeout 1000000))) 286 (progn
275 (delete-overlay ol)))) 287 (unless (zerop (length message))
288 ;; The current C cursor code doesn't know to use the overlay's
289 ;; marker's stickiness to figure out whether to place the cursor
290 ;; before or after the string, so let's spoon-feed it the pos.
291 (put-text-property 0 1 'cursor t message))
292 (overlay-put ol 'after-string message)
293 (sit-for (or minibuffer-message-timeout 1000000)))
294 (delete-overlay ol)))))
276 295
277(defun minibuffer-completion-contents () 296(defun minibuffer-completion-contents ()
278 "Return the user input in a minibuffer before point as a string. 297 "Return the user input in a minibuffer before point as a string.
@@ -343,6 +362,8 @@ Only the elements of table that satisfy predicate PRED are considered.
343POINT is the position of point within STRING. 362POINT is the position of point within STRING.
344The return value is a list of completions and may contain the base-size 363The return value is a list of completions and may contain the base-size
345in the last `cdr'." 364in the last `cdr'."
365 ;; FIXME: We need to additionally return completion-extra-size (similar
366 ;; to completion-base-size but for the text after point).
346 ;; The property `completion-styles' indicates that this functional 367 ;; The property `completion-styles' indicates that this functional
347 ;; completion-table claims to take care of completion styles itself. 368 ;; completion-table claims to take care of completion styles itself.
348 ;; [I.e. It will most likely call us back at some point. ] 369 ;; [I.e. It will most likely call us back at some point. ]
@@ -872,6 +893,23 @@ the completions buffer."
872 (run-hooks 'completion-setup-hook))) 893 (run-hooks 'completion-setup-hook)))
873 nil) 894 nil)
874 895
896(defvar completion-annotate-function
897 nil
898 ;; Note: there's a lot of scope as for when to add annotations and
899 ;; what annotations to add. E.g. completing-help.el allowed adding
900 ;; the first line of docstrings to M-x completion. But there's
901 ;; a tension, since such annotations, while useful at times, can
902 ;; actually drown the useful information.
903 ;; So completion-annotate-function should be used parsimoniously, or
904 ;; else only used upon a user's request (e.g. we could add a command
905 ;; to completion-list-mode to add annotations to the current
906 ;; completions).
907 "Function to add annotations in the *Completions* buffer.
908The function takes a completion and should either return nil, or a string that
909will be displayed next to the completion. The function can access the
910completion table and predicates via `minibuffer-completion-table' and related
911variables.")
912
875(defun minibuffer-completion-help () 913(defun minibuffer-completion-help ()
876 "Display a list of possible completions of the current minibuffer contents." 914 "Display a list of possible completions of the current minibuffer contents."
877 (interactive) 915 (interactive)
@@ -892,8 +930,15 @@ the completions buffer."
892 ;; Remove the base-size tail because `sort' requires a properly 930 ;; Remove the base-size tail because `sort' requires a properly
893 ;; nil-terminated list. 931 ;; nil-terminated list.
894 (when last (setcdr last nil)) 932 (when last (setcdr last nil))
895 (display-completion-list (nconc (sort completions 'string-lessp) 933 (setq completions (sort completions 'string-lessp))
896 base-size)))) 934 (when completion-annotate-function
935 (setq completions
936 (mapcar (lambda (s)
937 (let ((ann
938 (funcall completion-annotate-function s)))
939 (if ann (list s ann) s)))
940 completions)))
941 (display-completion-list (nconc completions base-size))))
897 942
898 ;; If there are no completions, or if the current input is already the 943 ;; If there are no completions, or if the current input is already the
899 ;; only possible completion, then hide (previous&stale) completions. 944 ;; only possible completion, then hide (previous&stale) completions.
@@ -998,8 +1043,11 @@ the completions buffer."
998 (if (eq (aref string (1- beg)) ?{) 1043 (if (eq (aref string (1- beg)) ?{)
999 (setq table (apply-partially 'completion-table-with-terminator 1044 (setq table (apply-partially 'completion-table-with-terminator
1000 "}" table))) 1045 "}" table)))
1001 (completion-table-with-context 1046 ;; Even if file-name completion is case-insensitive, we want
1002 prefix table (substring string beg) pred action))))) 1047 ;; envvar completion to be case-sensitive.
1048 (let ((completion-ignore-case nil))
1049 (completion-table-with-context
1050 prefix table (substring string beg) pred action))))))
1003 1051
1004(defun completion--file-name-table (string pred action) 1052(defun completion--file-name-table (string pred action)
1005 "Internal subroutine for `read-file-name'. Do not call this." 1053 "Internal subroutine for `read-file-name'. Do not call this."
@@ -1447,15 +1495,15 @@ or a symbol chosen among `any', `star', `point'."
1447 1495
1448(defun completion-pcm--pattern->regex (pattern &optional group) 1496(defun completion-pcm--pattern->regex (pattern &optional group)
1449 (let ((re 1497 (let ((re
1450 (concat "\\`" 1498 (concat "\\`"
1451 (mapconcat 1499 (mapconcat
1452 (lambda (x) 1500 (lambda (x)
1453 (case x 1501 (case x
1454 ((star any point) 1502 ((star any point)
1455 (if (if (consp group) (memq x group) group) 1503 (if (if (consp group) (memq x group) group)
1456 "\\(.*?\\)" ".*?")) 1504 "\\(.*?\\)" ".*?"))
1457 (t (regexp-quote x)))) 1505 (t (regexp-quote x))))
1458 pattern 1506 pattern
1459 "")))) 1507 ""))))
1460 ;; Avoid pathological backtracking. 1508 ;; Avoid pathological backtracking.
1461 (while (string-match "\\.\\*\\?\\(?:\\\\[()]\\)*\\(\\.\\*\\?\\)" re) 1509 (while (string-match "\\.\\*\\?\\(?:\\\\[()]\\)*\\(\\.\\*\\?\\)" re)