Commit ab22be48 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(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.
parent 744256cf
2009-08-30 Stefan Monnier <>
* minibuffer.el (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.
2009-08-30 Glenn Morris <>
* progmodes/fortran.el (fortran-start-prog-re): New constant, extracted
......@@ -30,7 +30,6 @@
;; (boundaries START . END). See `completion-boundaries'.
;; Any other return value should be ignored (so we ignore values returned
;; from completion tables that don't know about this new `action' form).
;; See `completion-boundaries'.
;;; Bugs:
......@@ -40,10 +39,23 @@
;; - choose-completion can't automatically figure out the boundaries
;; corresponding to the displayed completions. `base-size' gives the left
;; boundary, but not the righthand one. So we need to add
;; completion-extra-size (and also completion-no-auto-exit).
;; completion-extra-size.
;;; Todo:
;; - make partial-complete-mode obsolete:
;; - make M-x lch TAB expand to list-command-history.
;; (not sure how/where it's implemented in complete.el)
;; - (?) <foo.h> style completion for file names.
;; - case-sensitivity is currently confuses two issues:
;; - whether or not a particular completion table should be case-sensitive
;; (i.e. whether strings that different only by case are semantically
;; equivalent)
;; - whether the user wants completion to pay attention to case.
;; e.g. we may want to make it possible for the user to say "first try
;; completion case-sensitively, and if that fails, try to ignore case".
;; - make lisp-complete-symbol and sym-comp use it.
;; - add support for ** to pcm.
;; - Make read-file-name-predicate obsolete.
......@@ -248,6 +260,13 @@ The text is displayed for `minibuffer-message-timeout' seconds,
or until the next input event arrives, whichever comes first.
Enclose MESSAGE in [...] if this is not yet the case.
If ARGS are provided, then pass MESSAGE through `format'."
(if (not (minibufferp (current-buffer)))
(if args
(apply 'message message args)
(message "%s" message))
(prog1 (sit-for (or minibuffer-message-timeout 1000000))
(message nil)))
;; Clear out any old echo-area message to make way for our new thing.
(message nil)
(setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message))
......@@ -272,7 +291,7 @@ If ARGS are provided, then pass MESSAGE through `format'."
(put-text-property 0 1 'cursor t message))
(overlay-put ol 'after-string message)
(sit-for (or minibuffer-message-timeout 1000000)))
(delete-overlay ol))))
(delete-overlay ol)))))
(defun minibuffer-completion-contents ()
"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.
POINT is the position of point within STRING.
The return value is a list of completions and may contain the base-size
in the last `cdr'."
;; FIXME: We need to additionally return completion-extra-size (similar
;; to completion-base-size but for the text after point).
;; The property `completion-styles' indicates that this functional
;; completion-table claims to take care of completion styles itself.
;; [I.e. It will most likely call us back at some point. ]
......@@ -872,6 +893,23 @@ the completions buffer."
(run-hooks 'completion-setup-hook)))
(defvar completion-annotate-function
;; Note: there's a lot of scope as for when to add annotations and
;; what annotations to add. E.g. completing-help.el allowed adding
;; the first line of docstrings to M-x completion. But there's
;; a tension, since such annotations, while useful at times, can
;; actually drown the useful information.
;; So completion-annotate-function should be used parsimoniously, or
;; else only used upon a user's request (e.g. we could add a command
;; to completion-list-mode to add annotations to the current
;; completions).
"Function to add annotations in the *Completions* buffer.
The function takes a completion and should either return nil, or a string that
will be displayed next to the completion. The function can access the
completion table and predicates via `minibuffer-completion-table' and related
(defun minibuffer-completion-help ()
"Display a list of possible completions of the current minibuffer contents."
......@@ -892,8 +930,15 @@ the completions buffer."
;; Remove the base-size tail because `sort' requires a properly
;; nil-terminated list.
(when last (setcdr last nil))
(display-completion-list (nconc (sort completions 'string-lessp)
(setq completions (sort completions 'string-lessp))
(when completion-annotate-function
(setq completions
(mapcar (lambda (s)
(let ((ann
(funcall completion-annotate-function s)))
(if ann (list s ann) s)))
(display-completion-list (nconc completions base-size))))
;; If there are no completions, or if the current input is already the
;; only possible completion, then hide (previous&stale) completions.
......@@ -998,8 +1043,11 @@ the completions buffer."
(if (eq (aref string (1- beg)) ?{)
(setq table (apply-partially 'completion-table-with-terminator
"}" table)))
;; Even if file-name completion is case-insensitive, we want
;; envvar completion to be case-sensitive.
(let ((completion-ignore-case nil))
prefix table (substring string beg) pred action)))))
prefix table (substring string beg) pred action))))))
(defun completion--file-name-table (string pred action)
"Internal subroutine for `read-file-name'. Do not call this."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment