(apropos-symbols-internal): Handle (obsolete) face aliases.
[emacs.git] / lisp / minibuffer.el
blob5ab3e4122329d86a75836a77ad39aefdb1cc4e3b
1 ;;; minibuffer.el --- Minibuffer completion functions
3 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; Names with "--" are for functions and variables that are meant to be for
25 ;; internal use only.
27 ;; Functional completion tables have an extended calling conventions:
28 ;; - The `action' can be (additionally to nil, t, and lambda) of the form
29 ;; (boundaries . SUFFIX) in which case it should return
30 ;; (boundaries START . END). See `completion-boundaries'.
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).
34 ;;; Bugs:
36 ;; - completion-all-sorted-completions list all the completions, whereas
37 ;; it should only lists the ones that `try-completion' would consider.
38 ;; E.g. it should honor completion-ignored-extensions.
39 ;; - choose-completion can't automatically figure out the boundaries
40 ;; corresponding to the displayed completions. `base-size' gives the left
41 ;; boundary, but not the righthand one. So we need to add
42 ;; completion-extra-size.
44 ;;; Todo:
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.
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".
59 ;; - make lisp-complete-symbol and sym-comp use it.
60 ;; - add support for ** to pcm.
61 ;; - Make read-file-name-predicate obsolete.
62 ;; - Add vc-file-name-completion-table to read-file-name-internal.
63 ;; - A feature like completing-help.el.
64 ;; - make lisp/complete.el obsolete.
65 ;; - Make the `hide-spaces' arg of all-completions obsolete?
67 ;;; Code:
69 (eval-when-compile (require 'cl))
71 ;;; Completion table manipulation
73 ;; New completion-table operation.
74 (defun completion-boundaries (string table pred suffix)
75 "Return the boundaries of the completions returned by TABLE for STRING.
76 STRING is the string on which completion will be performed.
77 SUFFIX is the string after point.
78 The result is of the form (START . END) where START is the position
79 in STRING of the beginning of the completion field and END is the position
80 in SUFFIX of the end of the completion field.
81 E.g. for simple completion tables, the result is always (0 . (length SUFFIX))
82 and for file names the result is the positions delimited by
83 the closest directory separators."
84 (let ((boundaries (if (functionp table)
85 (funcall table string pred (cons 'boundaries suffix)))))
86 (if (not (eq (car-safe boundaries) 'boundaries))
87 (setq boundaries nil))
88 (cons (or (cadr boundaries) 0)
89 (or (cddr boundaries) (length suffix)))))
91 (defun completion--some (fun xs)
92 "Apply FUN to each element of XS in turn.
93 Return the first non-nil returned value.
94 Like CL's `some'."
95 (let ((firsterror nil)
96 res)
97 (while (and (not res) xs)
98 (condition-case err
99 (setq res (funcall fun (pop xs)))
100 (error (unless firsterror (setq firsterror err)) nil)))
101 (or res
102 (if firsterror (signal (car firsterror) (cdr firsterror))))))
104 (defun complete-with-action (action table string pred)
105 "Perform completion ACTION.
106 STRING is the string to complete.
107 TABLE is the completion table, which should not be a function.
108 PRED is a completion predicate.
109 ACTION can be one of nil, t or `lambda'."
110 (cond
111 ((functionp table) (funcall table string pred action))
112 ((eq (car-safe action) 'boundaries)
113 (cons 'boundaries (completion-boundaries string table pred (cdr action))))
115 (funcall
116 (cond
117 ((null action) 'try-completion)
118 ((eq action t) 'all-completions)
119 (t 'test-completion))
120 string table pred))))
122 (defun completion-table-dynamic (fun)
123 "Use function FUN as a dynamic completion table.
124 FUN is called with one argument, the string for which completion is required,
125 and it should return an alist containing all the intended possible completions.
126 This alist may be a full list of possible completions so that FUN can ignore
127 the value of its argument. If completion is performed in the minibuffer,
128 FUN will be called in the buffer from which the minibuffer was entered.
130 The result of the `completion-table-dynamic' form is a function
131 that can be used as the COLLECTION argument to `try-completion' and
132 `all-completions'. See Info node `(elisp)Programmed Completion'."
133 (lexical-let ((fun fun))
134 (lambda (string pred action)
135 (with-current-buffer (let ((win (minibuffer-selected-window)))
136 (if (window-live-p win) (window-buffer win)
137 (current-buffer)))
138 (complete-with-action action (funcall fun string) string pred)))))
140 (defmacro lazy-completion-table (var fun)
141 "Initialize variable VAR as a lazy completion table.
142 If the completion table VAR is used for the first time (e.g., by passing VAR
143 as an argument to `try-completion'), the function FUN is called with no
144 arguments. FUN must return the completion table that will be stored in VAR.
145 If completion is requested in the minibuffer, FUN will be called in the buffer
146 from which the minibuffer was entered. The return value of
147 `lazy-completion-table' must be used to initialize the value of VAR.
149 You should give VAR a non-nil `risky-local-variable' property."
150 (declare (debug (symbolp lambda-expr)))
151 (let ((str (make-symbol "string")))
152 `(completion-table-dynamic
153 (lambda (,str)
154 (when (functionp ,var)
155 (setq ,var (,fun)))
156 ,var))))
158 (defun completion-table-with-context (prefix table string pred action)
159 ;; TODO: add `suffix' maybe?
160 ;; Notice that `pred' may not be a function in some abusive cases.
161 (when (functionp pred)
162 (setq pred
163 (lexical-let ((pred pred))
164 ;; Predicates are called differently depending on the nature of
165 ;; the completion table :-(
166 (cond
167 ((vectorp table) ;Obarray.
168 (lambda (sym) (funcall pred (concat prefix (symbol-name sym)))))
169 ((hash-table-p table)
170 (lambda (s v) (funcall pred (concat prefix s))))
171 ((functionp table)
172 (lambda (s) (funcall pred (concat prefix s))))
173 (t ;Lists and alists.
174 (lambda (s)
175 (funcall pred (concat prefix (if (consp s) (car s) s)))))))))
176 (if (eq (car-safe action) 'boundaries)
177 (let* ((len (length prefix))
178 (bound (completion-boundaries string table pred (cdr action))))
179 (list* 'boundaries (+ (car bound) len) (cdr bound)))
180 (let ((comp (complete-with-action action table string pred)))
181 (cond
182 ;; In case of try-completion, add the prefix.
183 ((stringp comp) (concat prefix comp))
184 (t comp)))))
186 (defun completion-table-with-terminator (terminator table string pred action)
187 (cond
188 ((eq action nil)
189 (let ((comp (try-completion string table pred)))
190 (if (eq comp t)
191 (concat string terminator)
192 (if (and (stringp comp)
193 (eq (try-completion comp table pred) t))
194 (concat comp terminator)
195 comp))))
196 ((eq action t)
197 ;; FIXME: We generally want the `try' and `all' behaviors to be
198 ;; consistent so pcm can merge the `all' output to get the `try' output,
199 ;; but that sometimes clashes with the need for `all' output to look
200 ;; good in *Completions*.
201 ;; (mapcar (lambda (s) (concat s terminator))
202 ;; (all-completions string table pred))))
203 (all-completions string table pred))
204 ;; completion-table-with-terminator is always used for
205 ;; "sub-completions" so it's only called if the terminator is missing,
206 ;; in which case `test-completion' should return nil.
207 ((eq action 'lambda) nil)))
209 (defun completion-table-with-predicate (table pred1 strict string pred2 action)
210 "Make a completion table equivalent to TABLE but filtered through PRED1.
211 PRED1 is a function of one argument which returns non-nil if and only if the
212 argument is an element of TABLE which should be considered for completion.
213 STRING, PRED2, and ACTION are the usual arguments to completion tables,
214 as described in `try-completion', `all-completions', and `test-completion'.
215 If STRICT is t, the predicate always applies; if nil it only applies if
216 it does not reduce the set of possible completions to nothing.
217 Note: TABLE needs to be a proper completion table which obeys predicates."
218 (cond
219 ((and (not strict) (eq action 'lambda))
220 ;; Ignore pred1 since it doesn't really have to apply anyway.
221 (test-completion string table pred2))
223 (or (complete-with-action action table string
224 (if (null pred2) pred1
225 (lexical-let ((pred1 pred2) (pred2 pred2))
226 (lambda (x)
227 ;; Call `pred1' first, so that `pred2'
228 ;; really can't tell that `x' is in table.
229 (if (funcall pred1 x) (funcall pred2 x))))))
230 ;; If completion failed and we're not applying pred1 strictly, try
231 ;; again without pred1.
232 (and (not strict)
233 (complete-with-action action table string pred2))))))
235 (defun completion-table-in-turn (&rest tables)
236 "Create a completion table that tries each table in TABLES in turn."
237 (lexical-let ((tables tables))
238 (lambda (string pred action)
239 (completion--some (lambda (table)
240 (complete-with-action action table string pred))
241 tables))))
243 ;; (defmacro complete-in-turn (a b) `(completion-table-in-turn ,a ,b))
244 ;; (defmacro dynamic-completion-table (fun) `(completion-table-dynamic ,fun))
245 (define-obsolete-function-alias
246 'complete-in-turn 'completion-table-in-turn "23.1")
247 (define-obsolete-function-alias
248 'dynamic-completion-table 'completion-table-dynamic "23.1")
250 ;;; Minibuffer completion
252 (defgroup minibuffer nil
253 "Controlling the behavior of the minibuffer."
254 :link '(custom-manual "(emacs)Minibuffer")
255 :group 'environment)
257 (defun minibuffer-message (message &rest args)
258 "Temporarily display MESSAGE at the end of the minibuffer.
259 The text is displayed for `minibuffer-message-timeout' seconds,
260 or until the next input event arrives, whichever comes first.
261 Enclose MESSAGE in [...] if this is not yet the case.
262 If ARGS are provided, then pass MESSAGE through `format'."
263 (if (not (minibufferp (current-buffer)))
264 (progn
265 (if args
266 (apply 'message message args)
267 (message "%s" message))
268 (prog1 (sit-for (or minibuffer-message-timeout 1000000))
269 (message nil)))
270 ;; Clear out any old echo-area message to make way for our new thing.
271 (message nil)
272 (setq message (if (and (null args) (string-match-p "\\` *\\[.+\\]\\'" message))
273 ;; Make sure we can put-text-property.
274 (copy-sequence message)
275 (concat " [" message "]")))
276 (when args (setq message (apply 'format message args)))
277 (let ((ol (make-overlay (point-max) (point-max) nil t t))
278 ;; A quit during sit-for normally only interrupts the sit-for,
279 ;; but since minibuffer-message is used at the end of a command,
280 ;; at a time when the command has virtually finished already, a C-g
281 ;; should really cause an abort-recursive-edit instead (i.e. as if
282 ;; the C-g had been typed at top-level). Binding inhibit-quit here
283 ;; is an attempt to get that behavior.
284 (inhibit-quit t))
285 (unwind-protect
286 (progn
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)))))
296 (defun minibuffer-completion-contents ()
297 "Return the user input in a minibuffer before point as a string.
298 That is what completion commands operate on."
299 (buffer-substring (field-beginning) (point)))
301 (defun delete-minibuffer-contents ()
302 "Delete all user input in a minibuffer.
303 If the current buffer is not a minibuffer, erase its entire contents."
304 ;; We used to do `delete-field' here, but when file name shadowing
305 ;; is on, the field doesn't cover the entire minibuffer contents.
306 (delete-region (minibuffer-prompt-end) (point-max)))
308 (defcustom completion-auto-help t
309 "Non-nil means automatically provide help for invalid completion input.
310 If the value is t the *Completion* buffer is displayed whenever completion
311 is requested but cannot be done.
312 If the value is `lazy', the *Completions* buffer is only displayed after
313 the second failed attempt to complete."
314 :type '(choice (const nil) (const t) (const lazy))
315 :group 'minibuffer)
317 (defvar completion-styles-alist
318 '((basic completion-basic-try-completion completion-basic-all-completions)
319 (emacs22 completion-emacs22-try-completion completion-emacs22-all-completions)
320 (emacs21 completion-emacs21-try-completion completion-emacs21-all-completions)
321 (partial-completion
322 completion-pcm-try-completion completion-pcm-all-completions))
323 "List of available completion styles.
324 Each element has the form (NAME TRY-COMPLETION ALL-COMPLETIONS)
325 where NAME is the name that should be used in `completion-styles',
326 TRY-COMPLETION is the function that does the completion, and
327 ALL-COMPLETIONS is the function that lists the completions.")
329 (defcustom completion-styles '(basic partial-completion emacs22)
330 "List of completion styles to use.
331 The available styles are listed in `completion-styles-alist'."
332 :type `(repeat (choice ,@(mapcar (lambda (x) (list 'const (car x)))
333 completion-styles-alist)))
334 :group 'minibuffer
335 :version "23.1")
337 (defun completion-try-completion (string table pred point)
338 "Try to complete STRING using completion table TABLE.
339 Only the elements of table that satisfy predicate PRED are considered.
340 POINT is the position of point within STRING.
341 The return value can be either nil to indicate that there is no completion,
342 t to indicate that STRING is the only possible completion,
343 or a pair (STRING . NEWPOINT) of the completed result string together with
344 a new position for point."
345 ;; The property `completion-styles' indicates that this functional
346 ;; completion-table claims to take care of completion styles itself.
347 ;; [I.e. It will most likely call us back at some point. ]
348 (if (and (symbolp table) (get table 'completion-styles))
349 ;; Extended semantics for functional completion-tables:
350 ;; They accept a 4th argument `point' and when called with action=nil
351 ;; and this 4th argument (a position inside `string'), they should
352 ;; return instead of a string a pair (STRING . NEWPOINT).
353 (funcall table string pred nil point)
354 (completion--some (lambda (style)
355 (funcall (nth 1 (assq style completion-styles-alist))
356 string table pred point))
357 completion-styles)))
359 (defun completion-all-completions (string table pred point)
360 "List the possible completions of STRING in completion table TABLE.
361 Only the elements of table that satisfy predicate PRED are considered.
362 POINT is the position of point within STRING.
363 The return value is a list of completions and may contain the base-size
364 in 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).
367 ;; The property `completion-styles' indicates that this functional
368 ;; completion-table claims to take care of completion styles itself.
369 ;; [I.e. It will most likely call us back at some point. ]
370 (if (and (symbolp table) (get table 'completion-styles))
371 ;; Extended semantics for functional completion-tables:
372 ;; They accept a 4th argument `point' and when called with action=t
373 ;; and this 4th argument (a position inside `string'), they may
374 ;; return BASE-SIZE in the last `cdr'.
375 (funcall table string pred t point)
376 (completion--some (lambda (style)
377 (funcall (nth 2 (assq style completion-styles-alist))
378 string table pred point))
379 completion-styles)))
381 (defun minibuffer--bitset (modified completions exact)
382 (logior (if modified 4 0)
383 (if completions 2 0)
384 (if exact 1 0)))
386 (defun completion--do-completion (&optional try-completion-function)
387 "Do the completion and return a summary of what happened.
388 M = completion was performed, the text was Modified.
389 C = there were available Completions.
390 E = after completion we now have an Exact match.
393 000 0 no possible completion
394 001 1 was already an exact and unique completion
395 010 2 no completion happened
396 011 3 was already an exact completion
397 100 4 ??? impossible
398 101 5 ??? impossible
399 110 6 some completion happened
400 111 7 completed to an exact completion"
401 (let* ((beg (field-beginning))
402 (end (field-end))
403 (string (buffer-substring beg end))
404 (comp (funcall (or try-completion-function
405 'completion-try-completion)
406 string
407 minibuffer-completion-table
408 minibuffer-completion-predicate
409 (- (point) beg))))
410 (cond
411 ((null comp)
412 (minibuffer-hide-completions)
413 (ding) (minibuffer-message "No match") (minibuffer--bitset nil nil nil))
414 ((eq t comp)
415 (minibuffer-hide-completions)
416 (goto-char (field-end))
417 (minibuffer--bitset nil nil t)) ;Exact and unique match.
419 ;; `completed' should be t if some completion was done, which doesn't
420 ;; include simply changing the case of the entered string. However,
421 ;; for appearance, the string is rewritten if the case changes.
422 (let* ((comp-pos (cdr comp))
423 (completion (car comp))
424 (completed (not (eq t (compare-strings completion nil nil
425 string nil nil t))))
426 (unchanged (eq t (compare-strings completion nil nil
427 string nil nil nil))))
428 (unless unchanged
430 ;; Insert in minibuffer the chars we got.
431 (goto-char end)
432 (insert completion)
433 (delete-region beg end))
434 ;; Move point.
435 (goto-char (+ beg comp-pos))
437 (if (not (or unchanged completed))
438 ;; The case of the string changed, but that's all. We're not sure
439 ;; whether this is a unique completion or not, so try again using
440 ;; the real case (this shouldn't recurse again, because the next
441 ;; time try-completion will return either t or the exact string).
442 (completion--do-completion try-completion-function)
444 ;; It did find a match. Do we match some possibility exactly now?
445 (let ((exact (test-completion completion
446 minibuffer-completion-table
447 minibuffer-completion-predicate)))
448 (if completed
449 ;; We could also decide to refresh the completions,
450 ;; if they're displayed (and assuming there are
451 ;; completions left).
452 (minibuffer-hide-completions)
453 ;; Show the completion table, if requested.
454 (cond
455 ((not exact)
456 (if (case completion-auto-help
457 (lazy (eq this-command last-command))
458 (t completion-auto-help))
459 (minibuffer-completion-help)
460 (minibuffer-message "Next char not unique")))
461 ;; If the last exact completion and this one were the same, it
462 ;; means we've already given a "Next char not unique" message
463 ;; and the user's hit TAB again, so now we give him help.
464 ((eq this-command last-command)
465 (if completion-auto-help (minibuffer-completion-help)))))
467 (minibuffer--bitset completed t exact))))))))
469 (defun minibuffer-complete ()
470 "Complete the minibuffer contents as far as possible.
471 Return nil if there is no valid completion, else t.
472 If no characters can be completed, display a list of possible completions.
473 If you repeat this command after it displayed such a list,
474 scroll the window of possible completions."
475 (interactive)
476 ;; If the previous command was not this,
477 ;; mark the completion buffer obsolete.
478 (unless (eq this-command last-command)
479 (setq minibuffer-scroll-window nil))
481 (let ((window minibuffer-scroll-window))
482 ;; If there's a fresh completion window with a live buffer,
483 ;; and this command is repeated, scroll that window.
484 (if (window-live-p window)
485 (with-current-buffer (window-buffer window)
486 (if (pos-visible-in-window-p (point-max) window)
487 ;; If end is in view, scroll up to the beginning.
488 (set-window-start window (point-min) nil)
489 ;; Else scroll down one screen.
490 (scroll-other-window))
491 nil)
493 (case (completion--do-completion)
494 (#b000 nil)
495 (#b001 (minibuffer-message "Sole completion")
497 (#b011 (minibuffer-message "Complete, but not unique")
499 (t t)))))
501 (defvar completion-all-sorted-completions nil)
502 (make-variable-buffer-local 'completion-all-sorted-completions)
504 (defun completion--flush-all-sorted-completions (&rest ignore)
505 (setq completion-all-sorted-completions nil))
507 (defun completion-all-sorted-completions ()
508 (or completion-all-sorted-completions
509 (let* ((start (field-beginning))
510 (end (field-end))
511 (all (completion-all-completions (buffer-substring start end)
512 minibuffer-completion-table
513 minibuffer-completion-predicate
514 (- (point) start)))
515 (last (last all))
516 (base-size (or (cdr last) 0)))
517 (when last
518 (setcdr last nil)
519 ;; Prefer shorter completions.
520 (setq all (sort all (lambda (c1 c2) (< (length c1) (length c2)))))
521 ;; Prefer recently used completions.
522 (let ((hist (symbol-value minibuffer-history-variable)))
523 (setq all (sort all (lambda (c1 c2)
524 (> (length (member c1 hist))
525 (length (member c2 hist)))))))
526 ;; Cache the result. This is not just for speed, but also so that
527 ;; repeated calls to minibuffer-force-complete can cycle through
528 ;; all possibilities.
529 (add-hook 'after-change-functions
530 'completion--flush-all-sorted-completions nil t)
531 (setq completion-all-sorted-completions
532 (nconc all base-size))))))
534 (defun minibuffer-force-complete ()
535 "Complete the minibuffer to an exact match.
536 Repeated uses step through the possible completions."
537 (interactive)
538 ;; FIXME: Need to deal with the extra-size issue here as well.
539 (let* ((start (field-beginning))
540 (end (field-end))
541 (all (completion-all-sorted-completions)))
542 (if (not (consp all))
543 (minibuffer-message (if all "No more completions" "No completions"))
544 (goto-char end)
545 (insert (car all))
546 (delete-region (+ start (cdr (last all))) end)
547 ;; If completing file names, (car all) may be a directory, so we'd now
548 ;; have a new set of possible completions and might want to reset
549 ;; completion-all-sorted-completions to nil, but we prefer not to,
550 ;; so that repeated calls minibuffer-force-complete still cycle
551 ;; through the previous possible completions.
552 (setq completion-all-sorted-completions (cdr all)))))
554 (defvar minibuffer-confirm-exit-commands
555 '(minibuffer-complete minibuffer-complete-word PC-complete PC-complete-word)
556 "A list of commands which cause an immediately following
557 `minibuffer-complete-and-exit' to ask for extra confirmation.")
559 (defun minibuffer-complete-and-exit ()
560 "Exit if the minibuffer contains a valid completion.
561 Otherwise, try to complete the minibuffer contents. If
562 completion leads to a valid completion, a repetition of this
563 command will exit.
565 If `minibuffer-completion-confirm' is `confirm', do not try to
566 complete; instead, ask for confirmation and accept any input if
567 confirmed.
568 If `minibuffer-completion-confirm' is `confirm-after-completion',
569 do not try to complete; instead, ask for confirmation if the
570 preceding minibuffer command was a member of
571 `minibuffer-confirm-exit-commands', and accept the input
572 otherwise."
573 (interactive)
574 (let ((beg (field-beginning))
575 (end (field-end)))
576 (cond
577 ;; Allow user to specify null string
578 ((= beg end) (exit-minibuffer))
579 ((test-completion (buffer-substring beg end)
580 minibuffer-completion-table
581 minibuffer-completion-predicate)
582 (when completion-ignore-case
583 ;; Fixup case of the field, if necessary.
584 (let* ((string (buffer-substring beg end))
585 (compl (try-completion
586 string
587 minibuffer-completion-table
588 minibuffer-completion-predicate)))
589 (when (and (stringp compl)
590 ;; If it weren't for this piece of paranoia, I'd replace
591 ;; the whole thing with a call to do-completion.
592 ;; This is important, e.g. when the current minibuffer's
593 ;; content is a directory which only contains a single
594 ;; file, so `try-completion' actually completes to
595 ;; that file.
596 (= (length string) (length compl)))
597 (goto-char end)
598 (insert compl)
599 (delete-region beg end))))
600 (exit-minibuffer))
602 ((eq minibuffer-completion-confirm 'confirm)
603 ;; The user is permitted to exit with an input that's rejected
604 ;; by test-completion, after confirming her choice.
605 (if (eq last-command this-command)
606 (exit-minibuffer)
607 (minibuffer-message "Confirm")
608 nil))
610 ((eq minibuffer-completion-confirm 'confirm-after-completion)
611 ;; Similar to the above, but only if trying to exit immediately
612 ;; after typing TAB (this catches most minibuffer typos).
613 (if (memq last-command minibuffer-confirm-exit-commands)
614 (progn (minibuffer-message "Confirm")
615 nil)
616 (exit-minibuffer)))
619 ;; Call do-completion, but ignore errors.
620 (case (condition-case nil
621 (completion--do-completion)
622 (error 1))
623 ((#b001 #b011) (exit-minibuffer))
624 (#b111 (if (not minibuffer-completion-confirm)
625 (exit-minibuffer)
626 (minibuffer-message "Confirm")
627 nil))
628 (t nil))))))
630 (defun completion--try-word-completion (string table predicate point)
631 (let ((comp (completion-try-completion string table predicate point)))
632 (if (not (consp comp))
633 comp
635 ;; If completion finds next char not unique,
636 ;; consider adding a space or a hyphen.
637 (when (= (length string) (length (car comp)))
638 ;; Mark the added char with the `completion-word' property, so it
639 ;; can be handled specially by completion styles such as
640 ;; partial-completion.
641 ;; We used to remove `partial-completion' from completion-styles
642 ;; instead, but it was too blunt, leading to situations where SPC
643 ;; was the only insertable char at point but minibuffer-complete-word
644 ;; refused inserting it.
645 (let ((exts (mapcar (lambda (str) (propertize str 'completion-try-word t))
646 '(" " "-")))
647 (before (substring string 0 point))
648 (after (substring string point))
649 tem)
650 (while (and exts (not (consp tem)))
651 (setq tem (completion-try-completion
652 (concat before (pop exts) after)
653 table predicate (1+ point))))
654 (if (consp tem) (setq comp tem))))
656 ;; Completing a single word is actually more difficult than completing
657 ;; as much as possible, because we first have to find the "current
658 ;; position" in `completion' in order to find the end of the word
659 ;; we're completing. Normally, `string' is a prefix of `completion',
660 ;; which makes it trivial to find the position, but with fancier
661 ;; completion (plus env-var expansion, ...) `completion' might not
662 ;; look anything like `string' at all.
663 (let* ((comppoint (cdr comp))
664 (completion (car comp))
665 (before (substring string 0 point))
666 (combined (concat before "\n" completion)))
667 ;; Find in completion the longest text that was right before point.
668 (when (string-match "\\(.+\\)\n.*?\\1" combined)
669 (let* ((prefix (match-string 1 before))
670 ;; We used non-greedy match to make `rem' as long as possible.
671 (rem (substring combined (match-end 0)))
672 ;; Find in the remainder of completion the longest text
673 ;; that was right after point.
674 (after (substring string point))
675 (suffix (if (string-match "\\`\\(.+\\).*\n.*\\1"
676 (concat after "\n" rem))
677 (match-string 1 after))))
678 ;; The general idea is to try and guess what text was inserted
679 ;; at point by the completion. Problem is: if we guess wrong,
680 ;; we may end up treating as "added by completion" text that was
681 ;; actually painfully typed by the user. So if we then cut
682 ;; after the first word, we may throw away things the
683 ;; user wrote. So let's try to be as conservative as possible:
684 ;; only cut after the first word, if we're reasonably sure that
685 ;; our guess is correct.
686 ;; Note: a quick survey on emacs-devel seemed to indicate that
687 ;; nobody actually cares about the "word-at-a-time" feature of
688 ;; minibuffer-complete-word, whose real raison-d'être is that it
689 ;; tries to add "-" or " ". One more reason to only cut after
690 ;; the first word, if we're really sure we're right.
691 (when (and (or suffix (zerop (length after)))
692 (string-match (concat
693 ;; Make submatch 1 as small as possible
694 ;; to reduce the risk of cutting
695 ;; valuable text.
696 ".*" (regexp-quote prefix) "\\(.*?\\)"
697 (if suffix (regexp-quote suffix) "\\'"))
698 completion)
699 ;; The new point in `completion' should also be just
700 ;; before the suffix, otherwise something more complex
701 ;; is going on, and we're not sure where we are.
702 (eq (match-end 1) comppoint)
703 ;; (match-beginning 1)..comppoint is now the stretch
704 ;; of text in `completion' that was completed at point.
705 (string-match "\\W" completion (match-beginning 1))
706 ;; Is there really something to cut?
707 (> comppoint (match-end 0)))
708 ;; Cut after the first word.
709 (let ((cutpos (match-end 0)))
710 (setq completion (concat (substring completion 0 cutpos)
711 (substring completion comppoint)))
712 (setq comppoint cutpos)))))
714 (cons completion comppoint)))))
717 (defun minibuffer-complete-word ()
718 "Complete the minibuffer contents at most a single word.
719 After one word is completed as much as possible, a space or hyphen
720 is added, provided that matches some possible completion.
721 Return nil if there is no valid completion, else t."
722 (interactive)
723 (case (completion--do-completion 'completion--try-word-completion)
724 (#b000 nil)
725 (#b001 (minibuffer-message "Sole completion")
727 (#b011 (minibuffer-message "Complete, but not unique")
729 (t t)))
731 (defface completions-annotations '((t :inherit italic))
732 "Face to use for annotations in the *Completions* buffer.")
734 (defun completion--insert-strings (strings)
735 "Insert a list of STRINGS into the current buffer.
736 Uses columns to keep the listing readable but compact.
737 It also eliminates runs of equal strings."
738 (when (consp strings)
739 (let* ((length (apply 'max
740 (mapcar (lambda (s)
741 (if (consp s)
742 (+ (string-width (car s))
743 (string-width (cadr s)))
744 (string-width s)))
745 strings)))
746 (window (get-buffer-window (current-buffer) 0))
747 (wwidth (if window (1- (window-width window)) 79))
748 (columns (min
749 ;; At least 2 columns; at least 2 spaces between columns.
750 (max 2 (/ wwidth (+ 2 length)))
751 ;; Don't allocate more columns than we can fill.
752 ;; Windows can't show less than 3 lines anyway.
753 (max 1 (/ (length strings) 2))))
754 (colwidth (/ wwidth columns))
755 (column 0)
756 (laststring nil))
757 ;; The insertion should be "sensible" no matter what choices were made
758 ;; for the parameters above.
759 (dolist (str strings)
760 (unless (equal laststring str) ; Remove (consecutive) duplicates.
761 (setq laststring str)
762 (let ((length (if (consp str)
763 (+ (string-width (car str))
764 (string-width (cadr str)))
765 (string-width str))))
766 (unless (bolp)
767 (if (< wwidth (+ (max colwidth length) column))
768 ;; No space for `str' at point, move to next line.
769 (progn (insert "\n") (setq column 0))
770 (insert " \t")
771 ;; Leave the space unpropertized so that in the case we're
772 ;; already past the goal column, there is still
773 ;; a space displayed.
774 (set-text-properties (- (point) 1) (point)
775 ;; We can't just set tab-width, because
776 ;; completion-setup-function will kill all
777 ;; local variables :-(
778 `(display (space :align-to ,column)))
779 nil))
780 (if (not (consp str))
781 (put-text-property (point) (progn (insert str) (point))
782 'mouse-face 'highlight)
783 (put-text-property (point) (progn (insert (car str)) (point))
784 'mouse-face 'highlight)
785 (add-text-properties (point) (progn (insert (cadr str)) (point))
786 '(mouse-face nil
787 face completions-annotations)))
788 ;; Next column to align to.
789 (setq column (+ column
790 ;; Round up to a whole number of columns.
791 (* colwidth (ceiling length colwidth))))))))))
793 (defvar completion-common-substring nil)
794 (make-obsolete-variable 'completion-common-substring nil "23.1")
796 (defvar completion-setup-hook nil
797 "Normal hook run at the end of setting up a completion list buffer.
798 When this hook is run, the current buffer is the one in which the
799 command to display the completion list buffer was run.
800 The completion list buffer is available as the value of `standard-output'.
801 See also `display-completion-list'.")
803 (defface completions-first-difference
804 '((t (:inherit bold)))
805 "Face put on the first uncommon character in completions in *Completions* buffer."
806 :group 'completion)
808 (defface completions-common-part
809 '((t (:inherit default)))
810 "Face put on the common prefix substring in completions in *Completions* buffer.
811 The idea of `completions-common-part' is that you can use it to
812 make the common parts less visible than normal, so that the rest
813 of the differing parts is, by contrast, slightly highlighted."
814 :group 'completion)
816 (defun completion-hilit-commonality (completions prefix-len base-size)
817 (when completions
818 (let ((com-str-len (- prefix-len (or base-size 0))))
819 (nconc
820 (mapcar
821 (lambda (elem)
822 (let ((str
823 ;; Don't modify the string itself, but a copy, since the
824 ;; the string may be read-only or used for other purposes.
825 ;; Furthermore, since `completions' may come from
826 ;; display-completion-list, `elem' may be a list.
827 (if (consp elem)
828 (car (setq elem (cons (copy-sequence (car elem))
829 (cdr elem))))
830 (setq elem (copy-sequence elem)))))
831 (put-text-property 0
832 ;; If completion-boundaries returns incorrect
833 ;; values, all-completions may return strings
834 ;; that don't contain the prefix.
835 (min com-str-len (length str))
836 'font-lock-face 'completions-common-part
837 str)
838 (if (> (length str) com-str-len)
839 (put-text-property com-str-len (1+ com-str-len)
840 'font-lock-face 'completions-first-difference
841 str)))
842 elem)
843 completions)
844 base-size))))
846 (defun display-completion-list (completions &optional common-substring)
847 "Display the list of completions, COMPLETIONS, using `standard-output'.
848 Each element may be just a symbol or string
849 or may be a list of two strings to be printed as if concatenated.
850 If it is a list of two strings, the first is the actual completion
851 alternative, the second serves as annotation.
852 `standard-output' must be a buffer.
853 The actual completion alternatives, as inserted, are given `mouse-face'
854 properties of `highlight'.
855 At the end, this runs the normal hook `completion-setup-hook'.
856 It can find the completion buffer in `standard-output'.
858 The obsolete optional arg COMMON-SUBSTRING, if non-nil, should be a string
859 specifying a common substring for adding the faces
860 `completions-first-difference' and `completions-common-part' to
861 the completions buffer."
862 (if common-substring
863 (setq completions (completion-hilit-commonality
864 completions (length common-substring)
865 ;; We don't know the base-size.
866 nil)))
867 (if (not (bufferp standard-output))
868 ;; This *never* (ever) happens, so there's no point trying to be clever.
869 (with-temp-buffer
870 (let ((standard-output (current-buffer))
871 (completion-setup-hook nil))
872 (display-completion-list completions common-substring))
873 (princ (buffer-string)))
875 (let ((mainbuf (current-buffer)))
876 (with-current-buffer standard-output
877 (goto-char (point-max))
878 (if (null completions)
879 (insert "There are no possible completions of what you have typed.")
880 (insert "Possible completions are:\n")
881 (let ((last (last completions)))
882 ;; Set base-size from the tail of the list.
883 (set (make-local-variable 'completion-base-size)
884 (or (cdr last)
885 (and (minibufferp mainbuf) 0)))
886 (setcdr last nil)) ; Make completions a properly nil-terminated list.
887 (completion--insert-strings completions)))))
889 ;; The hilit used to be applied via completion-setup-hook, so there
890 ;; may still be some code that uses completion-common-substring.
891 (with-no-warnings
892 (let ((completion-common-substring common-substring))
893 (run-hooks 'completion-setup-hook)))
894 nil)
896 (defvar completion-annotate-function
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.
908 The function takes a completion and should either return nil, or a string that
909 will be displayed next to the completion. The function can access the
910 completion table and predicates via `minibuffer-completion-table' and related
911 variables.")
913 (defun minibuffer-completion-help ()
914 "Display a list of possible completions of the current minibuffer contents."
915 (interactive)
916 (message "Making completion list...")
917 (let* ((string (field-string))
918 (completions (completion-all-completions
919 string
920 minibuffer-completion-table
921 minibuffer-completion-predicate
922 (- (point) (field-beginning)))))
923 (message nil)
924 (if (and completions
925 (or (consp (cdr completions))
926 (not (equal (car completions) string))))
927 (with-output-to-temp-buffer "*Completions*"
928 (let* ((last (last completions))
929 (base-size (cdr last)))
930 ;; Remove the base-size tail because `sort' requires a properly
931 ;; nil-terminated list.
932 (when last (setcdr last nil))
933 (setq completions (sort completions 'string-lessp))
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))))
943 ;; If there are no completions, or if the current input is already the
944 ;; only possible completion, then hide (previous&stale) completions.
945 (let ((window (and (get-buffer "*Completions*")
946 (get-buffer-window "*Completions*" 0))))
947 (when (and (window-live-p window) (window-dedicated-p window))
948 (condition-case ()
949 (delete-window window)
950 (error (iconify-frame (window-frame window))))))
951 (ding)
952 (minibuffer-message
953 (if completions "Sole completion" "No completions")))
954 nil))
956 (defun minibuffer-hide-completions ()
957 "Get rid of an out-of-date *Completions* buffer."
958 ;; FIXME: We could/should use minibuffer-scroll-window here, but it
959 ;; can also point to the minibuffer-parent-window, so it's a bit tricky.
960 (let ((win (get-buffer-window "*Completions*" 0)))
961 (if win (with-selected-window win (bury-buffer)))))
963 (defun exit-minibuffer ()
964 "Terminate this minibuffer argument."
965 (interactive)
966 ;; If the command that uses this has made modifications in the minibuffer,
967 ;; we don't want them to cause deactivation of the mark in the original
968 ;; buffer.
969 ;; A better solution would be to make deactivate-mark buffer-local
970 ;; (or to turn it into a list of buffers, ...), but in the mean time,
971 ;; this should do the trick in most cases.
972 (setq deactivate-mark nil)
973 (throw 'exit nil))
975 (defun self-insert-and-exit ()
976 "Terminate minibuffer input."
977 (interactive)
978 (if (characterp last-command-event)
979 (call-interactively 'self-insert-command)
980 (ding))
981 (exit-minibuffer))
983 ;;; Key bindings.
985 (define-obsolete-variable-alias 'minibuffer-local-must-match-filename-map
986 'minibuffer-local-filename-must-match-map "23.1")
988 (let ((map minibuffer-local-map))
989 (define-key map "\C-g" 'abort-recursive-edit)
990 (define-key map "\r" 'exit-minibuffer)
991 (define-key map "\n" 'exit-minibuffer))
993 (let ((map minibuffer-local-completion-map))
994 (define-key map "\t" 'minibuffer-complete)
995 ;; M-TAB is already abused for many other purposes, so we should find
996 ;; another binding for it.
997 ;; (define-key map "\e\t" 'minibuffer-force-complete)
998 (define-key map " " 'minibuffer-complete-word)
999 (define-key map "?" 'minibuffer-completion-help))
1001 (let ((map minibuffer-local-must-match-map))
1002 (define-key map "\r" 'minibuffer-complete-and-exit)
1003 (define-key map "\n" 'minibuffer-complete-and-exit))
1005 (let ((map minibuffer-local-filename-completion-map))
1006 (define-key map " " nil))
1007 (let ((map minibuffer-local-filename-must-match-map))
1008 (define-key map " " nil))
1010 (let ((map minibuffer-local-ns-map))
1011 (define-key map " " 'exit-minibuffer)
1012 (define-key map "\t" 'exit-minibuffer)
1013 (define-key map "?" 'self-insert-and-exit))
1015 ;;; Completion tables.
1017 (defun minibuffer--double-dollars (str)
1018 (replace-regexp-in-string "\\$" "$$" str))
1020 (defun completion--make-envvar-table ()
1021 (mapcar (lambda (enventry)
1022 (substring enventry 0 (string-match-p "=" enventry)))
1023 process-environment))
1025 (defconst completion--embedded-envvar-re
1026 (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)"
1027 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
1029 (defun completion--embedded-envvar-table (string pred action)
1030 (if (eq (car-safe action) 'boundaries)
1031 ;; Compute the boundaries of the subfield to which this
1032 ;; completion applies.
1033 (let ((suffix (cdr action)))
1034 (if (string-match completion--embedded-envvar-re string)
1035 (list* 'boundaries
1036 (or (match-beginning 2) (match-beginning 1))
1037 (when (string-match "[^[:alnum:]_]" suffix)
1038 (match-beginning 0)))))
1039 (when (string-match completion--embedded-envvar-re string)
1040 (let* ((beg (or (match-beginning 2) (match-beginning 1)))
1041 (table (completion--make-envvar-table))
1042 (prefix (substring string 0 beg)))
1043 (if (eq (aref string (1- beg)) ?{)
1044 (setq table (apply-partially 'completion-table-with-terminator
1045 "}" table)))
1046 ;; Even if file-name completion is case-insensitive, we want
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))))))
1052 (defun completion--file-name-table (string pred action)
1053 "Internal subroutine for `read-file-name'. Do not call this."
1054 (cond
1055 ((and (zerop (length string)) (eq 'lambda action))
1056 nil) ; FIXME: why?
1057 ((eq (car-safe action) 'boundaries)
1058 ;; FIXME: Actually, this is not always right in the presence of
1059 ;; envvars, but there's not much we can do, I think.
1060 (let ((start (length (file-name-directory string)))
1061 (end (string-match-p "/" (cdr action))))
1062 (list* 'boundaries start end)))
1065 (let* ((dir (if (stringp pred)
1066 ;; It used to be that `pred' was abused to pass `dir'
1067 ;; as an argument.
1068 (prog1 (expand-file-name pred) (setq pred nil))
1069 default-directory))
1070 (str (condition-case nil
1071 (substitute-in-file-name string)
1072 (error string)))
1073 (name (file-name-nondirectory str))
1074 (specdir (file-name-directory str))
1075 (realdir (if specdir (expand-file-name specdir dir)
1076 (file-name-as-directory dir))))
1078 (cond
1079 ((null action)
1080 (let ((comp (file-name-completion name realdir
1081 read-file-name-predicate)))
1082 (if (stringp comp)
1083 ;; Requote the $s before returning the completion.
1084 (minibuffer--double-dollars (concat specdir comp))
1085 ;; Requote the $s before checking for changes.
1086 (setq str (minibuffer--double-dollars str))
1087 (if (string-equal string str)
1088 comp
1089 ;; If there's no real completion, but substitute-in-file-name
1090 ;; changed the string, then return the new string.
1091 str))))
1093 ((eq action t)
1094 (let ((all (file-name-all-completions name realdir)))
1096 ;; Check the predicate, if necessary.
1097 (unless (memq read-file-name-predicate '(nil file-exists-p))
1098 (let ((comp ())
1099 (pred
1100 (if (eq read-file-name-predicate 'file-directory-p)
1101 ;; Brute-force speed up for directory checking:
1102 ;; Discard strings which don't end in a slash.
1103 (lambda (s)
1104 (let ((len (length s)))
1105 (and (> len 0) (eq (aref s (1- len)) ?/))))
1106 ;; Must do it the hard (and slow) way.
1107 read-file-name-predicate)))
1108 (let ((default-directory realdir))
1109 (dolist (tem all)
1110 (if (funcall pred tem) (push tem comp))))
1111 (setq all (nreverse comp))))
1113 all))
1116 ;; Only other case actually used is ACTION = lambda.
1117 (let ((default-directory dir))
1118 (funcall (or read-file-name-predicate 'file-exists-p) str))))))))
1120 (defalias 'read-file-name-internal
1121 (completion-table-in-turn 'completion--embedded-envvar-table
1122 'completion--file-name-table)
1123 "Internal subroutine for `read-file-name'. Do not call this.")
1125 (defvar read-file-name-function nil
1126 "If this is non-nil, `read-file-name' does its work by calling this function.")
1128 (defvar read-file-name-predicate nil
1129 "Current predicate used by `read-file-name-internal'.")
1131 (defcustom read-file-name-completion-ignore-case
1132 (if (memq system-type '(ms-dos windows-nt darwin cygwin))
1133 t nil)
1134 "Non-nil means when reading a file name completion ignores case."
1135 :group 'minibuffer
1136 :type 'boolean
1137 :version "22.1")
1139 (defcustom insert-default-directory t
1140 "Non-nil means when reading a filename start with default dir in minibuffer.
1142 When the initial minibuffer contents show a name of a file or a directory,
1143 typing RETURN without editing the initial contents is equivalent to typing
1144 the default file name.
1146 If this variable is non-nil, the minibuffer contents are always
1147 initially non-empty, and typing RETURN without editing will fetch the
1148 default name, if one is provided. Note however that this default name
1149 is not necessarily the same as initial contents inserted in the minibuffer,
1150 if the initial contents is just the default directory.
1152 If this variable is nil, the minibuffer often starts out empty. In
1153 that case you may have to explicitly fetch the next history element to
1154 request the default name; typing RETURN without editing will leave
1155 the minibuffer empty.
1157 For some commands, exiting with an empty minibuffer has a special meaning,
1158 such as making the current buffer visit no file in the case of
1159 `set-visited-file-name'."
1160 :group 'minibuffer
1161 :type 'boolean)
1163 ;; Not always defined, but only called if next-read-file-uses-dialog-p says so.
1164 (declare-function x-file-dialog "xfns.c"
1165 (prompt dir &optional default-filename mustmatch only-dir-p))
1167 (defun read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
1168 "Read file name, prompting with PROMPT and completing in directory DIR.
1169 Value is not expanded---you must call `expand-file-name' yourself.
1170 Default name to DEFAULT-FILENAME if user exits the minibuffer with
1171 the same non-empty string that was inserted by this function.
1172 (If DEFAULT-FILENAME is omitted, the visited file name is used,
1173 except that if INITIAL is specified, that combined with DIR is used.)
1174 If the user exits with an empty minibuffer, this function returns
1175 an empty string. (This can only happen if the user erased the
1176 pre-inserted contents or if `insert-default-directory' is nil.)
1178 Fourth arg MUSTMATCH can take the following values:
1179 - nil means that the user can exit with any input.
1180 - t means that the user is not allowed to exit unless
1181 the input is (or completes to) an existing file.
1182 - `confirm' means that the user can exit with any input, but she needs
1183 to confirm her choice if the input is not an existing file.
1184 - `confirm-after-completion' means that the user can exit with any
1185 input, but she needs to confirm her choice if she called
1186 `minibuffer-complete' right before `minibuffer-complete-and-exit'
1187 and the input is not an existing file.
1188 - anything else behaves like t except that typing RET does not exit if it
1189 does non-null completion.
1191 Fifth arg INITIAL specifies text to start with.
1193 If optional sixth arg PREDICATE is non-nil, possible completions and
1194 the resulting file name must satisfy (funcall PREDICATE NAME).
1195 DIR should be an absolute directory name. It defaults to the value of
1196 `default-directory'.
1198 If this command was invoked with the mouse, use a graphical file
1199 dialog if `use-dialog-box' is non-nil, and the window system or X
1200 toolkit in use provides a file dialog box. For graphical file
1201 dialogs, any the special values of MUSTMATCH; `confirm' and
1202 `confirm-after-completion' are treated as equivalent to nil.
1204 See also `read-file-name-completion-ignore-case'
1205 and `read-file-name-function'."
1206 (unless dir (setq dir default-directory))
1207 (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir)))
1208 (unless default-filename
1209 (setq default-filename (if initial (expand-file-name initial dir)
1210 buffer-file-name)))
1211 ;; If dir starts with user's homedir, change that to ~.
1212 (setq dir (abbreviate-file-name dir))
1213 ;; Likewise for default-filename.
1214 (if default-filename
1215 (setq default-filename (abbreviate-file-name default-filename)))
1216 (let ((insdef (cond
1217 ((and insert-default-directory (stringp dir))
1218 (if initial
1219 (cons (minibuffer--double-dollars (concat dir initial))
1220 (length (minibuffer--double-dollars dir)))
1221 (minibuffer--double-dollars dir)))
1222 (initial (cons (minibuffer--double-dollars initial) 0)))))
1224 (if read-file-name-function
1225 (funcall read-file-name-function
1226 prompt dir default-filename mustmatch initial predicate)
1227 (let ((completion-ignore-case read-file-name-completion-ignore-case)
1228 (minibuffer-completing-file-name t)
1229 (read-file-name-predicate (or predicate 'file-exists-p))
1230 (add-to-history nil))
1232 (let* ((val
1233 (if (not (next-read-file-uses-dialog-p))
1234 ;; We used to pass `dir' to `read-file-name-internal' by
1235 ;; abusing the `predicate' argument. It's better to
1236 ;; just use `default-directory', but in order to avoid
1237 ;; changing `default-directory' in the current buffer,
1238 ;; we don't let-bind it.
1239 (lexical-let ((dir (file-name-as-directory
1240 (expand-file-name dir))))
1241 (minibuffer-with-setup-hook
1242 (lambda () (setq default-directory dir))
1243 (completing-read prompt 'read-file-name-internal
1244 nil mustmatch insdef 'file-name-history
1245 default-filename)))
1246 ;; If DEFAULT-FILENAME not supplied and DIR contains
1247 ;; a file name, split it.
1248 (let ((file (file-name-nondirectory dir))
1249 ;; When using a dialog, revert to nil and non-nil
1250 ;; interpretation of mustmatch. confirm options
1251 ;; need to be interpreted as nil, otherwise
1252 ;; it is impossible to create new files using
1253 ;; dialogs with the default settings.
1254 (dialog-mustmatch
1255 (and (not (eq mustmatch 'confirm))
1256 (not (eq mustmatch 'confirm-after-completion))
1257 mustmatch)))
1258 (when (and (not default-filename)
1259 (not (zerop (length file))))
1260 (setq default-filename file)
1261 (setq dir (file-name-directory dir)))
1262 (if default-filename
1263 (setq default-filename
1264 (expand-file-name default-filename dir)))
1265 (setq add-to-history t)
1266 (x-file-dialog prompt dir default-filename
1267 dialog-mustmatch
1268 (eq predicate 'file-directory-p)))))
1270 (replace-in-history (eq (car-safe file-name-history) val)))
1271 ;; If completing-read returned the inserted default string itself
1272 ;; (rather than a new string with the same contents),
1273 ;; it has to mean that the user typed RET with the minibuffer empty.
1274 ;; In that case, we really want to return ""
1275 ;; so that commands such as set-visited-file-name can distinguish.
1276 (when (eq val default-filename)
1277 ;; In this case, completing-read has not added an element
1278 ;; to the history. Maybe we should.
1279 (if (not replace-in-history)
1280 (setq add-to-history t))
1281 (setq val ""))
1282 (unless val (error "No file name specified"))
1284 (if (and default-filename
1285 (string-equal val (if (consp insdef) (car insdef) insdef)))
1286 (setq val default-filename))
1287 (setq val (substitute-in-file-name val))
1289 (if replace-in-history
1290 ;; Replace what Fcompleting_read added to the history
1291 ;; with what we will actually return.
1292 (let ((val1 (minibuffer--double-dollars val)))
1293 (if history-delete-duplicates
1294 (setcdr file-name-history
1295 (delete val1 (cdr file-name-history))))
1296 (setcar file-name-history val1))
1297 (if add-to-history
1298 ;; Add the value to the history--but not if it matches
1299 ;; the last value already there.
1300 (let ((val1 (minibuffer--double-dollars val)))
1301 (unless (and (consp file-name-history)
1302 (equal (car file-name-history) val1))
1303 (setq file-name-history
1304 (cons val1
1305 (if history-delete-duplicates
1306 (delete val1 file-name-history)
1307 file-name-history)))))))
1308 val)))))
1310 (defun internal-complete-buffer-except (&optional buffer)
1311 "Perform completion on all buffers excluding BUFFER.
1312 BUFFER nil or omitted means use the current buffer.
1313 Like `internal-complete-buffer', but removes BUFFER from the completion list."
1314 (lexical-let ((except (if (stringp buffer) buffer (buffer-name buffer))))
1315 (apply-partially 'completion-table-with-predicate
1316 'internal-complete-buffer
1317 (lambda (name)
1318 (not (equal (if (consp name) (car name) name) except)))
1319 nil)))
1321 ;;; Old-style completion, used in Emacs-21 and Emacs-22.
1323 (defun completion-emacs21-try-completion (string table pred point)
1324 (let ((completion (try-completion string table pred)))
1325 (if (stringp completion)
1326 (cons completion (length completion))
1327 completion)))
1329 (defun completion-emacs21-all-completions (string table pred point)
1330 (completion-hilit-commonality
1331 (all-completions string table pred)
1332 (length string)
1333 (car (completion-boundaries string table pred ""))))
1335 (defun completion-emacs22-try-completion (string table pred point)
1336 (let ((suffix (substring string point))
1337 (completion (try-completion (substring string 0 point) table pred)))
1338 (if (not (stringp completion))
1339 completion
1340 ;; Merge a trailing / in completion with a / after point.
1341 ;; We used to only do it for word completion, but it seems to make
1342 ;; sense for all completions.
1343 ;; Actually, claiming this feature was part of Emacs-22 completion
1344 ;; is pushing it a bit: it was only done in minibuffer-completion-word,
1345 ;; which was (by default) not bound during file completion, where such
1346 ;; slashes are most likely to occur.
1347 (if (and (not (zerop (length completion)))
1348 (eq ?/ (aref completion (1- (length completion))))
1349 (not (zerop (length suffix)))
1350 (eq ?/ (aref suffix 0)))
1351 ;; This leaves point after the / .
1352 (setq suffix (substring suffix 1)))
1353 (cons (concat completion suffix) (length completion)))))
1355 (defun completion-emacs22-all-completions (string table pred point)
1356 (let ((beforepoint (substring string 0 point)))
1357 (completion-hilit-commonality
1358 (all-completions beforepoint table pred)
1359 point
1360 (car (completion-boundaries beforepoint table pred "")))))
1362 ;;; Basic completion.
1364 (defun completion--merge-suffix (completion point suffix)
1365 "Merge end of COMPLETION with beginning of SUFFIX.
1366 Simple generalization of the \"merge trailing /\" done in Emacs-22.
1367 Return the new suffix."
1368 (if (and (not (zerop (length suffix)))
1369 (string-match "\\(.+\\)\n\\1" (concat completion "\n" suffix)
1370 ;; Make sure we don't compress things to less
1371 ;; than we started with.
1372 point)
1373 ;; Just make sure we didn't match some other \n.
1374 (eq (match-end 1) (length completion)))
1375 (substring suffix (- (match-end 1) (match-beginning 1)))
1376 ;; Nothing to merge.
1377 suffix))
1379 (defun completion-basic-try-completion (string table pred point)
1380 (let* ((beforepoint (substring string 0 point))
1381 (afterpoint (substring string point))
1382 (bounds (completion-boundaries beforepoint table pred afterpoint)))
1383 (if (zerop (cdr bounds))
1384 ;; `try-completion' may return a subtly different result
1385 ;; than `all+merge', so try to use it whenever possible.
1386 (let ((completion (try-completion beforepoint table pred)))
1387 (if (not (stringp completion))
1388 completion
1389 (cons
1390 (concat completion
1391 (completion--merge-suffix completion point afterpoint))
1392 (length completion))))
1393 (let* ((suffix (substring afterpoint (cdr bounds)))
1394 (prefix (substring beforepoint 0 (car bounds)))
1395 (pattern (delete
1396 "" (list (substring beforepoint (car bounds))
1397 'point
1398 (substring afterpoint 0 (cdr bounds)))))
1399 (all (completion-pcm--all-completions prefix pattern table pred)))
1400 (if minibuffer-completing-file-name
1401 (setq all (completion-pcm--filename-try-filter all)))
1402 (completion-pcm--merge-try pattern all prefix suffix)))))
1404 (defun completion-basic-all-completions (string table pred point)
1405 (let* ((beforepoint (substring string 0 point))
1406 (afterpoint (substring string point))
1407 (bounds (completion-boundaries beforepoint table pred afterpoint))
1408 (suffix (substring afterpoint (cdr bounds)))
1409 (prefix (substring beforepoint 0 (car bounds)))
1410 (pattern (delete
1411 "" (list (substring beforepoint (car bounds))
1412 'point
1413 (substring afterpoint 0 (cdr bounds)))))
1414 (all (completion-pcm--all-completions prefix pattern table pred)))
1415 (completion-hilit-commonality all point (car bounds))))
1417 ;;; Partial-completion-mode style completion.
1419 (defvar completion-pcm--delim-wild-regex nil
1420 "Regular expression matching delimiters controlling the partial-completion.
1421 Typically, this regular expression simply matches a delimiter, meaning
1422 that completion can add something at (match-beginning 0), but if it has
1423 a submatch 1, then completion can add something at (match-end 1).
1424 This is used when the delimiter needs to be of size zero (e.g. the transition
1425 from lowercase to uppercase characters).")
1427 (defun completion-pcm--prepare-delim-re (delims)
1428 (setq completion-pcm--delim-wild-regex (concat "[" delims "*]")))
1430 (defcustom completion-pcm-word-delimiters "-_. "
1431 "A string of characters treated as word delimiters for completion.
1432 Some arcane rules:
1433 If `]' is in this string, it must come first.
1434 If `^' is in this string, it must not come first.
1435 If `-' is in this string, it must come first or right after `]'.
1436 In other words, if S is this string, then `[S]' must be a valid Emacs regular
1437 expression (not containing character ranges like `a-z')."
1438 :set (lambda (symbol value)
1439 (set-default symbol value)
1440 ;; Refresh other vars.
1441 (completion-pcm--prepare-delim-re value))
1442 :initialize 'custom-initialize-reset
1443 :group 'minibuffer
1444 :type 'string)
1446 (defun completion-pcm--pattern-trivial-p (pattern)
1447 (and (stringp (car pattern))
1448 ;; It can be followed by `point' and "" and still be trivial.
1449 (let ((trivial t))
1450 (dolist (elem (cdr pattern))
1451 (unless (member elem '(point ""))
1452 (setq trivial nil)))
1453 trivial)))
1455 (defun completion-pcm--string->pattern (string &optional point)
1456 "Split STRING into a pattern.
1457 A pattern is a list where each element is either a string
1458 or a symbol chosen among `any', `star', `point'."
1459 (if (and point (< point (length string)))
1460 (let ((prefix (substring string 0 point))
1461 (suffix (substring string point)))
1462 (append (completion-pcm--string->pattern prefix)
1463 '(point)
1464 (completion-pcm--string->pattern suffix)))
1465 (let ((pattern nil)
1466 (p 0)
1467 (p0 0))
1469 (while (and (setq p (string-match completion-pcm--delim-wild-regex
1470 string p))
1471 ;; If the char was added by minibuffer-complete-word, then
1472 ;; don't treat it as a delimiter, otherwise "M-x SPC"
1473 ;; ends up inserting a "-" rather than listing
1474 ;; all completions.
1475 (not (get-text-property p 'completion-try-word string)))
1476 ;; Usually, completion-pcm--delim-wild-regex matches a delimiter,
1477 ;; meaning that something can be added *before* it, but it can also
1478 ;; match a prefix and postfix, in which case something can be added
1479 ;; in-between (e.g. match [[:lower:]][[:upper:]]).
1480 ;; This is determined by the presence of a submatch-1 which delimits
1481 ;; the prefix.
1482 (if (match-end 1) (setq p (match-end 1)))
1483 (push (substring string p0 p) pattern)
1484 (if (eq (aref string p) ?*)
1485 (progn
1486 (push 'star pattern)
1487 (setq p0 (1+ p)))
1488 (push 'any pattern)
1489 (setq p0 p))
1490 (incf p))
1492 ;; An empty string might be erroneously added at the beginning.
1493 ;; It should be avoided properly, but it's so easy to remove it here.
1494 (delete "" (nreverse (cons (substring string p0) pattern))))))
1496 (defun completion-pcm--pattern->regex (pattern &optional group)
1497 (let ((re
1498 (concat "\\`"
1499 (mapconcat
1500 (lambda (x)
1501 (case x
1502 ((star any point)
1503 (if (if (consp group) (memq x group) group)
1504 "\\(.*?\\)" ".*?"))
1505 (t (regexp-quote x))))
1506 pattern
1507 ""))))
1508 ;; Avoid pathological backtracking.
1509 (while (string-match "\\.\\*\\?\\(?:\\\\[()]\\)*\\(\\.\\*\\?\\)" re)
1510 (setq re (replace-match "" t t re 1)))
1511 re))
1513 (defun completion-pcm--all-completions (prefix pattern table pred)
1514 "Find all completions for PATTERN in TABLE obeying PRED.
1515 PATTERN is as returned by `completion-pcm--string->pattern'."
1516 ;; (assert (= (car (completion-boundaries prefix table pred ""))
1517 ;; (length prefix)))
1518 ;; Find an initial list of possible completions.
1519 (if (completion-pcm--pattern-trivial-p pattern)
1521 ;; Minibuffer contains no delimiters -- simple case!
1522 (all-completions (concat prefix (car pattern)) table pred)
1524 ;; Use all-completions to do an initial cull. This is a big win,
1525 ;; since all-completions is written in C!
1526 (let* (;; Convert search pattern to a standard regular expression.
1527 (regex (completion-pcm--pattern->regex pattern))
1528 (case-fold-search completion-ignore-case)
1529 (completion-regexp-list (cons regex completion-regexp-list))
1530 (compl (all-completions
1531 (concat prefix (if (stringp (car pattern)) (car pattern) ""))
1532 table pred)))
1533 (if (not (functionp table))
1534 ;; The internal functions already obeyed completion-regexp-list.
1535 compl
1536 (let ((poss ()))
1537 (dolist (c compl)
1538 (when (string-match-p regex c) (push c poss)))
1539 poss)))))
1541 (defun completion-pcm--hilit-commonality (pattern completions)
1542 (when completions
1543 (let* ((re (completion-pcm--pattern->regex pattern '(point)))
1544 (case-fold-search completion-ignore-case))
1545 ;; Remove base-size during mapcar, and add it back later.
1546 (mapcar
1547 (lambda (str)
1548 ;; Don't modify the string itself.
1549 (setq str (copy-sequence str))
1550 (unless (string-match re str)
1551 (error "Internal error: %s does not match %s" re str))
1552 (let ((pos (or (match-beginning 1) (match-end 0))))
1553 (put-text-property 0 pos
1554 'font-lock-face 'completions-common-part
1555 str)
1556 (if (> (length str) pos)
1557 (put-text-property pos (1+ pos)
1558 'font-lock-face 'completions-first-difference
1559 str)))
1560 str)
1561 completions))))
1563 (defun completion-pcm--find-all-completions (string table pred point
1564 &optional filter)
1565 "Find all completions for STRING at POINT in TABLE, satisfying PRED.
1566 POINT is a position inside STRING.
1567 FILTER is a function applied to the return value, that can be used, e.g. to
1568 filter out additional entries (because TABLE migth not obey PRED)."
1569 (unless filter (setq filter 'identity))
1570 (let* ((beforepoint (substring string 0 point))
1571 (afterpoint (substring string point))
1572 (bounds (completion-boundaries beforepoint table pred afterpoint))
1573 (prefix (substring beforepoint 0 (car bounds)))
1574 (suffix (substring afterpoint (cdr bounds)))
1575 firsterror)
1576 (setq string (substring string (car bounds) (+ point (cdr bounds))))
1577 (let* ((relpoint (- point (car bounds)))
1578 (pattern (completion-pcm--string->pattern string relpoint))
1579 (all (condition-case err
1580 (funcall filter
1581 (completion-pcm--all-completions
1582 prefix pattern table pred))
1583 (error (unless firsterror (setq firsterror err)) nil))))
1584 (when (and (null all)
1585 (> (car bounds) 0)
1586 (null (ignore-errors (try-completion prefix table pred))))
1587 ;; The prefix has no completions at all, so we should try and fix
1588 ;; that first.
1589 (let ((substring (substring prefix 0 -1)))
1590 (destructuring-bind (subpat suball subprefix subsuffix)
1591 (completion-pcm--find-all-completions
1592 substring table pred (length substring) filter)
1593 (let ((sep (aref prefix (1- (length prefix))))
1594 ;; Text that goes between the new submatches and the
1595 ;; completion substring.
1596 (between nil))
1597 ;; Eliminate submatches that don't end with the separator.
1598 (dolist (submatch (prog1 suball (setq suball ())))
1599 (when (eq sep (aref submatch (1- (length submatch))))
1600 (push submatch suball)))
1601 (when suball
1602 ;; Update the boundaries and corresponding pattern.
1603 ;; We assume that all submatches result in the same boundaries
1604 ;; since we wouldn't know how to merge them otherwise anyway.
1605 ;; FIXME: COMPLETE REWRITE!!!
1606 (let* ((newbeforepoint
1607 (concat subprefix (car suball)
1608 (substring string 0 relpoint)))
1609 (leftbound (+ (length subprefix) (length (car suball))))
1610 (newbounds (completion-boundaries
1611 newbeforepoint table pred afterpoint)))
1612 (unless (or (and (eq (cdr bounds) (cdr newbounds))
1613 (eq (car newbounds) leftbound))
1614 ;; Refuse new boundaries if they step over
1615 ;; the submatch.
1616 (< (car newbounds) leftbound))
1617 ;; The new completed prefix does change the boundaries
1618 ;; of the completed substring.
1619 (setq suffix (substring afterpoint (cdr newbounds)))
1620 (setq string
1621 (concat (substring newbeforepoint (car newbounds))
1622 (substring afterpoint 0 (cdr newbounds))))
1623 (setq between (substring newbeforepoint leftbound
1624 (car newbounds)))
1625 (setq pattern (completion-pcm--string->pattern
1626 string
1627 (- (length newbeforepoint)
1628 (car newbounds)))))
1629 (dolist (submatch suball)
1630 (setq all (nconc (mapcar
1631 (lambda (s) (concat submatch between s))
1632 (funcall filter
1633 (completion-pcm--all-completions
1634 (concat subprefix submatch between)
1635 pattern table pred)))
1636 all)))
1637 ;; FIXME: This can come in handy for try-completion,
1638 ;; but isn't right for all-completions, since it lists
1639 ;; invalid completions.
1640 ;; (unless all
1641 ;; ;; Even though we found expansions in the prefix, none
1642 ;; ;; leads to a valid completion.
1643 ;; ;; Let's keep the expansions, tho.
1644 ;; (dolist (submatch suball)
1645 ;; (push (concat submatch between newsubstring) all)))
1647 (setq pattern (append subpat (list 'any (string sep))
1648 (if between (list between)) pattern))
1649 (setq prefix subprefix)))))
1650 (if (and (null all) firsterror)
1651 (signal (car firsterror) (cdr firsterror))
1652 (list pattern all prefix suffix)))))
1654 (defun completion-pcm-all-completions (string table pred point)
1655 (destructuring-bind (pattern all &optional prefix suffix)
1656 (completion-pcm--find-all-completions string table pred point)
1657 (when all
1658 (nconc (completion-pcm--hilit-commonality pattern all)
1659 (length prefix)))))
1661 (defun completion-pcm--merge-completions (strs pattern)
1662 "Extract the commonality in STRS, with the help of PATTERN."
1663 (cond
1664 ((null (cdr strs)) (list (car strs)))
1666 (let ((re (completion-pcm--pattern->regex pattern 'group))
1667 (ccs ())) ;Chopped completions.
1669 ;; First chop each string into the parts corresponding to each
1670 ;; non-constant element of `pattern', using regexp-matching.
1671 (let ((case-fold-search completion-ignore-case))
1672 (dolist (str strs)
1673 (unless (string-match re str)
1674 (error "Internal error: %s doesn't match %s" str re))
1675 (let ((chopped ())
1676 (i 1))
1677 (while (match-beginning i)
1678 (push (match-string i str) chopped)
1679 (setq i (1+ i)))
1680 ;; Add the text corresponding to the implicit trailing `any'.
1681 (push (substring str (match-end 0)) chopped)
1682 (push (nreverse chopped) ccs))))
1684 ;; Then for each of those non-constant elements, extract the
1685 ;; commonality between them.
1686 (let ((res ()))
1687 ;; Make the implicit `any' explicit. We could make it explicit
1688 ;; everywhere, but it would slow down regexp-matching a little bit.
1689 (dolist (elem (append pattern '(any)))
1690 (if (stringp elem)
1691 (push elem res)
1692 (let ((comps ()))
1693 (dolist (cc (prog1 ccs (setq ccs nil)))
1694 (push (car cc) comps)
1695 (push (cdr cc) ccs))
1696 (let* ((prefix (try-completion "" comps))
1697 (unique (or (and (eq prefix t) (setq prefix ""))
1698 (eq t (try-completion prefix comps)))))
1699 (unless (equal prefix "") (push prefix res))
1700 ;; If there's only one completion, `elem' is not useful
1701 ;; any more: it can only match the empty string.
1702 ;; FIXME: in some cases, it may be necessary to turn an
1703 ;; `any' into a `star' because the surrounding context has
1704 ;; changed such that string->pattern wouldn't add an `any'
1705 ;; here any more.
1706 (unless unique (push elem res))))))
1707 ;; We return it in reverse order.
1708 res)))))
1710 (defun completion-pcm--pattern->string (pattern)
1711 (mapconcat (lambda (x) (cond
1712 ((stringp x) x)
1713 ((eq x 'star) "*")
1714 ((eq x 'any) "")
1715 ((eq x 'point) "")))
1716 pattern
1717 ""))
1719 ;; We want to provide the functionality of `try', but we use `all'
1720 ;; and then merge it. In most cases, this works perfectly, but
1721 ;; if the completion table doesn't consider the same completions in
1722 ;; `try' as in `all', then we have a problem. The most common such
1723 ;; case is for filename completion where completion-ignored-extensions
1724 ;; is only obeyed by the `try' code. We paper over the difference
1725 ;; here. Note that it is not quite right either: if the completion
1726 ;; table uses completion-table-in-turn, this filtering may take place
1727 ;; too late to correctly fallback from the first to the
1728 ;; second alternative.
1729 (defun completion-pcm--filename-try-filter (all)
1730 "Filter to adjust `all' file completion to the behavior of `try'."
1731 (when all
1732 (let ((try ())
1733 (re (concat "\\(?:\\`\\.\\.?/\\|"
1734 (regexp-opt completion-ignored-extensions)
1735 "\\)\\'")))
1736 (dolist (f all)
1737 (unless (string-match-p re f) (push f try)))
1738 (or try all))))
1741 (defun completion-pcm--merge-try (pattern all prefix suffix)
1742 (cond
1743 ((not (consp all)) all)
1744 ((and (not (consp (cdr all))) ;Only one completion.
1745 ;; Ignore completion-ignore-case here.
1746 (equal (completion-pcm--pattern->string pattern) (car all)))
1749 (let* ((mergedpat (completion-pcm--merge-completions all pattern))
1750 ;; `mergedpat' is in reverse order. Place new point (by
1751 ;; order of preference) either at the old point, or at
1752 ;; the last place where there's something to choose, or
1753 ;; at the very end.
1754 (pointpat (or (memq 'point mergedpat) (memq 'any mergedpat)
1755 mergedpat))
1756 ;; New pos from the start.
1757 (newpos (length (completion-pcm--pattern->string pointpat)))
1758 ;; Do it afterwards because it changes `pointpat' by sideeffect.
1759 (merged (completion-pcm--pattern->string (nreverse mergedpat))))
1761 (setq suffix (completion--merge-suffix merged newpos suffix))
1762 (cons (concat prefix merged suffix) (+ newpos (length prefix)))))))
1764 (defun completion-pcm-try-completion (string table pred point)
1765 (destructuring-bind (pattern all prefix suffix)
1766 (completion-pcm--find-all-completions
1767 string table pred point
1768 (if minibuffer-completing-file-name
1769 'completion-pcm--filename-try-filter))
1770 (completion-pcm--merge-try pattern all prefix suffix)))
1773 (provide 'minibuffer)
1775 ;; arch-tag: ef8a0a15-1080-4790-a754-04017c02f08f
1776 ;;; minibuffer.el ends here