(define-abbrev): Don't use `iff' in doc-strings.
[emacs.git] / lisp / minibuffer.el
blob1e9def104a30eeae0e43d4cd56d293a621a3a4de
1 ;;; minibuffer.el --- Minibuffer completion functions
3 ;; Copyright (C) 2008 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 ;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; Names starting with "minibuffer--" are for functions and variables that
25 ;; are meant to be for internal use only.
27 ;;; Todo:
29 ;; - Make read-file-name-predicate obsolete.
30 ;; - New command minibuffer-force-complete that chooses one of all-completions.
31 ;; - Add vc-file-name-completion-table to read-file-name-internal.
32 ;; - A feature like completing-help.el.
33 ;; - Make the `hide-spaces' arg of all-completions obsolete?
35 ;;; Code:
37 (eval-when-compile (require 'cl))
39 (defvar completion-all-completions-with-base-size nil
40 "If non-nil, `all-completions' may return the base-size in the last cdr.
41 The base-size is the length of the prefix that is elided from each
42 element in the returned list of completions. See `completion-base-size'.")
44 ;;; Completion table manipulation
46 (defun completion--some (fun xs)
47 "Apply FUN to each element of XS in turn.
48 Return the first non-nil returned value.
49 Like CL's `some'."
50 (let (res)
51 (while (and (not res) xs)
52 (setq res (funcall fun (pop xs))))
53 res))
55 (defun apply-partially (fun &rest args)
56 "Do a \"curried\" partial application of FUN to ARGS.
57 ARGS is a list of the first N arguments to pass to FUN.
58 The result is a new function that takes the remaining arguments,
59 and calls FUN."
60 (lexical-let ((fun fun) (args1 args))
61 (lambda (&rest args2) (apply fun (append args1 args2)))))
63 (defun complete-with-action (action table string pred)
64 "Perform completion ACTION.
65 STRING is the string to complete.
66 TABLE is the completion table, which should not be a function.
67 PRED is a completion predicate.
68 ACTION can be one of nil, t or `lambda'."
69 ;; (assert (not (functionp table)))
70 (funcall
71 (cond
72 ((null action) 'try-completion)
73 ((eq action t) 'all-completions)
74 (t 'test-completion))
75 string table pred))
77 (defun completion-table-dynamic (fun)
78 "Use function FUN as a dynamic completion table.
79 FUN is called with one argument, the string for which completion is required,
80 and it should return an alist containing all the intended possible completions.
81 This alist may be a full list of possible completions so that FUN can ignore
82 the value of its argument. If completion is performed in the minibuffer,
83 FUN will be called in the buffer from which the minibuffer was entered.
85 The result of the `dynamic-completion-table' form is a function
86 that can be used as the ALIST argument to `try-completion' and
87 `all-completions'. See Info node `(elisp)Programmed Completion'."
88 (lexical-let ((fun fun))
89 (lambda (string pred action)
90 (with-current-buffer (let ((win (minibuffer-selected-window)))
91 (if (window-live-p win) (window-buffer win)
92 (current-buffer)))
93 (complete-with-action action (funcall fun string) string pred)))))
95 (defmacro lazy-completion-table (var fun)
96 "Initialize variable VAR as a lazy completion table.
97 If the completion table VAR is used for the first time (e.g., by passing VAR
98 as an argument to `try-completion'), the function FUN is called with no
99 arguments. FUN must return the completion table that will be stored in VAR.
100 If completion is requested in the minibuffer, FUN will be called in the buffer
101 from which the minibuffer was entered. The return value of
102 `lazy-completion-table' must be used to initialize the value of VAR.
104 You should give VAR a non-nil `risky-local-variable' property."
105 (declare (debug (symbolp lambda-expr)))
106 (let ((str (make-symbol "string")))
107 `(completion-table-dynamic
108 (lambda (,str)
109 (when (functionp ,var)
110 (setq ,var (,fun)))
111 ,var))))
113 (defun completion-table-with-context (prefix table string pred action)
114 ;; TODO: add `suffix' maybe?
115 ;; Notice that `pred' is not a predicate when called from read-file-name
116 ;; or Info-read-node-name-2.
117 (when (functionp pred)
118 (setq pred
119 (lexical-let ((pred pred))
120 ;; Predicates are called differently depending on the nature of
121 ;; the completion table :-(
122 (cond
123 ((vectorp table) ;Obarray.
124 (lambda (sym) (funcall pred (concat prefix (symbol-name sym)))))
125 ((hash-table-p table)
126 (lambda (s v) (funcall pred (concat prefix s))))
127 ((functionp table)
128 (lambda (s) (funcall pred (concat prefix s))))
129 (t ;Lists and alists.
130 (lambda (s)
131 (funcall pred (concat prefix (if (consp s) (car s) s)))))))))
132 (let ((comp (complete-with-action action table string pred)))
133 (cond
134 ;; In case of try-completion, add the prefix.
135 ((stringp comp) (concat prefix comp))
136 ;; In case of non-empty all-completions,
137 ;; add the prefix size to the base-size.
138 ((consp comp)
139 (let ((last (last comp)))
140 (when completion-all-completions-with-base-size
141 (setcdr last (+ (or (cdr last) 0) (length prefix))))
142 comp))
143 (t comp))))
145 (defun completion-table-with-terminator (terminator table string pred action)
146 (cond
147 ((eq action nil)
148 (let ((comp (try-completion string table pred)))
149 (if (eq comp t)
150 (concat string terminator)
151 (if (and (stringp comp)
152 (eq (try-completion comp table pred) t))
153 (concat comp terminator)
154 comp))))
155 ((eq action t) (all-completions string table pred))
156 ;; completion-table-with-terminator is always used for
157 ;; "sub-completions" so it's only called if the terminator is missing,
158 ;; in which case `test-completion' should return nil.
159 ((eq action 'lambda) nil)))
161 (defun completion-table-with-predicate (table pred1 strict string pred2 action)
162 "Make a completion table equivalent to TABLE but filtered through PRED1.
163 PRED1 is a function of one argument which returns non-nil iff the
164 argument is an element of TABLE which should be considered for completion.
165 STRING, PRED2, and ACTION are the usual arguments to completion tables,
166 as described in `try-completion', `all-completions', and `test-completion'.
167 If STRICT is t, the predicate always applies; if nil it only applies if
168 it does not reduce the set of possible completions to nothing.
169 Note: TABLE needs to be a proper completion table which obeys predicates."
170 (cond
171 ((and (not strict) (eq action 'lambda))
172 ;; Ignore pred1 since it doesn't really have to apply anyway.
173 (test-completion string table pred2))
175 (or (complete-with-action action table string
176 (if (null pred2) pred1
177 (lexical-let ((pred1 pred2) (pred2 pred2))
178 (lambda (x)
179 ;; Call `pred1' first, so that `pred2'
180 ;; really can't tell that `x' is in table.
181 (if (funcall pred1 x) (funcall pred2 x))))))
182 ;; If completion failed and we're not applying pred1 strictly, try
183 ;; again without pred1.
184 (and (not strict)
185 (complete-with-action action table string pred2))))))
187 (defun completion-table-in-turn (&rest tables)
188 "Create a completion table that tries each table in TABLES in turn."
189 (lexical-let ((tables tables))
190 (lambda (string pred action)
191 (completion--some (lambda (table)
192 (complete-with-action action table string pred))
193 tables))))
195 ;; (defmacro complete-in-turn (a b) `(completion-table-in-turn ,a ,b))
196 ;; (defmacro dynamic-completion-table (fun) `(completion-table-dynamic ,fun))
197 (define-obsolete-function-alias
198 'complete-in-turn 'completion-table-in-turn "23.1")
199 (define-obsolete-function-alias
200 'dynamic-completion-table 'completion-table-dynamic "23.1")
202 ;;; Minibuffer completion
204 (defgroup minibuffer nil
205 "Controlling the behavior of the minibuffer."
206 :link '(custom-manual "(emacs)Minibuffer")
207 :group 'environment)
209 (defun minibuffer-message (message &rest args)
210 "Temporarily display MESSAGE at the end of the minibuffer.
211 The text is displayed for `minibuffer-message-timeout' seconds,
212 or until the next input event arrives, whichever comes first.
213 Enclose MESSAGE in [...] if this is not yet the case.
214 If ARGS are provided, then pass MESSAGE through `format'."
215 ;; Clear out any old echo-area message to make way for our new thing.
216 (message nil)
217 (setq message (if (and (null args) (string-match "\\[.+\\]" message))
218 ;; Make sure we can put-text-property.
219 (copy-sequence message)
220 (concat " [" message "]")))
221 (when args (setq message (apply 'format message args)))
222 (let ((ol (make-overlay (point-max) (point-max) nil t t)))
223 (unwind-protect
224 (progn
225 (unless (zerop (length message))
226 ;; The current C cursor code doesn't know to use the overlay's
227 ;; marker's stickiness to figure out whether to place the cursor
228 ;; before or after the string, so let's spoon-feed it the pos.
229 (put-text-property 0 1 'cursor t message))
230 (overlay-put ol 'after-string message)
231 (sit-for (or minibuffer-message-timeout 1000000)))
232 (delete-overlay ol))))
234 (defun minibuffer-completion-contents ()
235 "Return the user input in a minibuffer before point as a string.
236 That is what completion commands operate on."
237 (buffer-substring (field-beginning) (point)))
239 (defun delete-minibuffer-contents ()
240 "Delete all user input in a minibuffer.
241 If the current buffer is not a minibuffer, erase its entire contents."
242 (delete-field))
244 (defcustom completion-auto-help t
245 "Non-nil means automatically provide help for invalid completion input.
246 If the value is t the *Completion* buffer is displayed whenever completion
247 is requested but cannot be done.
248 If the value is `lazy', the *Completions* buffer is only displayed after
249 the second failed attempt to complete."
250 :type '(choice (const nil) (const t) (const lazy))
251 :group 'minibuffer)
253 (defvar completion-styles-alist
254 '((basic completion-basic-try-completion completion-basic-all-completions)
255 (emacs22 completion-emacs22-try-completion completion-emacs22-all-completions)
256 (emacs21 completion-emacs21-try-completion completion-emacs21-all-completions)
257 (partial-completion
258 completion-pcm-try-completion completion-pcm-all-completions))
259 "List of available completion styles.
260 Each element has the form (NAME TRY-COMPLETION ALL-COMPLETIONS)
261 where NAME is the name that should be used in `completion-styles'
262 TRY-COMPLETION is the function that does the completion, and
263 ALL-COMPLETIONS is the function that lists the completions.")
265 (defcustom completion-styles '(basic partial-completion)
266 "List of completion styles to use."
267 :type `(repeat (choice ,@(mapcar (lambda (x) (list 'const (car x)))
268 completion-styles-alist)))
269 :group 'minibuffer
270 :version "23.1")
272 (defun completion-try-completion (string table pred point)
273 "Try to complete STRING using completion table TABLE.
274 Only the elements of table that satisfy predicate PRED are considered.
275 POINT is the position of point within STRING.
276 The return value can be either nil to indicate that there is no completion,
277 t to indicate that STRING is the only possible completion,
278 or a pair (STRING . NEWPOINT) of the completed result string together with
279 a new position for point."
280 ;; The property `completion-styles' indicates that this functional
281 ;; completion-table claims to take care of completion styles itself.
282 ;; [I.e. It will most likely call us back at some point. ]
283 (if (and (symbolp table) (get table 'completion-styles))
284 ;; Extended semantics for functional completion-tables:
285 ;; They accept a 4th argument `point' and when called with action=nil
286 ;; and this 4th argument (a position inside `string'), they should
287 ;; return instead of a string a pair (STRING . NEWPOINT).
288 (funcall table string pred nil point)
289 (completion--some (lambda (style)
290 (funcall (nth 1 (assq style completion-styles-alist))
291 string table pred point))
292 completion-styles)))
294 (defun completion-all-completions (string table pred point)
295 "List the possible completions of STRING in completion table TABLE.
296 Only the elements of table that satisfy predicate PRED are considered.
297 POINT is the position of point within STRING.
298 The return value is a list of completions and may contain the BASE-SIZE
299 in the last `cdr'."
300 ;; The property `completion-styles' indicates that this functional
301 ;; completion-table claims to take care of completion styles itself.
302 ;; [I.e. It will most likely call us back at some point. ]
303 (let ((completion-all-completions-with-base-size t))
304 (if (and (symbolp table) (get table 'completion-styles))
305 ;; Extended semantics for functional completion-tables:
306 ;; They accept a 4th argument `point' and when called with action=t
307 ;; and this 4th argument (a position inside `string'), they may
308 ;; return BASE-SIZE in the last `cdr'.
309 (funcall table string pred t point)
310 (completion--some (lambda (style)
311 (funcall (nth 2 (assq style completion-styles-alist))
312 string table pred point))
313 completion-styles))))
315 (defun minibuffer--bitset (modified completions exact)
316 (logior (if modified 4 0)
317 (if completions 2 0)
318 (if exact 1 0)))
320 (defun completion--do-completion (&optional try-completion-function)
321 "Do the completion and return a summary of what happened.
322 M = completion was performed, the text was Modified.
323 C = there were available Completions.
324 E = after completion we now have an Exact match.
327 000 0 no possible completion
328 001 1 was already an exact and unique completion
329 010 2 no completion happened
330 011 3 was already an exact completion
331 100 4 ??? impossible
332 101 5 ??? impossible
333 110 6 some completion happened
334 111 7 completed to an exact completion"
335 (let* ((beg (field-beginning))
336 (end (field-end))
337 (string (buffer-substring beg end))
338 (comp (funcall (or try-completion-function
339 'completion-try-completion)
340 string
341 minibuffer-completion-table
342 minibuffer-completion-predicate
343 (- (point) beg))))
344 (cond
345 ((null comp)
346 (ding) (minibuffer-message "No match") (minibuffer--bitset nil nil nil))
347 ((eq t comp) (minibuffer--bitset nil nil t)) ;Exact and unique match.
349 ;; `completed' should be t if some completion was done, which doesn't
350 ;; include simply changing the case of the entered string. However,
351 ;; for appearance, the string is rewritten if the case changes.
352 (let* ((comp-pos (cdr comp))
353 (completion (car comp))
354 (completed (not (eq t (compare-strings completion nil nil
355 string nil nil t))))
356 (unchanged (eq t (compare-strings completion nil nil
357 string nil nil nil))))
358 (unless unchanged
360 ;; Insert in minibuffer the chars we got.
361 (goto-char end)
362 (insert completion)
363 (delete-region beg end)
364 (goto-char (+ beg comp-pos)))
366 (if (not (or unchanged completed))
367 ;; The case of the string changed, but that's all. We're not sure
368 ;; whether this is a unique completion or not, so try again using
369 ;; the real case (this shouldn't recurse again, because the next
370 ;; time try-completion will return either t or the exact string).
371 (completion--do-completion try-completion-function)
373 ;; It did find a match. Do we match some possibility exactly now?
374 (let ((exact (test-completion completion
375 minibuffer-completion-table
376 minibuffer-completion-predicate)))
377 (unless completed
378 ;; Show the completion table, if requested.
379 (cond
380 ((not exact)
381 (if (case completion-auto-help
382 (lazy (eq this-command last-command))
383 (t completion-auto-help))
384 (minibuffer-completion-help)
385 (minibuffer-message "Next char not unique")))
386 ;; If the last exact completion and this one were the same,
387 ;; it means we've already given a "Complete but not unique"
388 ;; message and the user's hit TAB again, so now we give him help.
389 ((eq this-command last-command)
390 (if completion-auto-help (minibuffer-completion-help)))))
392 (minibuffer--bitset completed t exact))))))))
394 (defun minibuffer-complete ()
395 "Complete the minibuffer contents as far as possible.
396 Return nil if there is no valid completion, else t.
397 If no characters can be completed, display a list of possible completions.
398 If you repeat this command after it displayed such a list,
399 scroll the window of possible completions."
400 (interactive)
401 ;; If the previous command was not this,
402 ;; mark the completion buffer obsolete.
403 (unless (eq this-command last-command)
404 (setq minibuffer-scroll-window nil))
406 (let ((window minibuffer-scroll-window))
407 ;; If there's a fresh completion window with a live buffer,
408 ;; and this command is repeated, scroll that window.
409 (if (window-live-p window)
410 (with-current-buffer (window-buffer window)
411 (if (pos-visible-in-window-p (point-max) window)
412 ;; If end is in view, scroll up to the beginning.
413 (set-window-start window (point-min) nil)
414 ;; Else scroll down one screen.
415 (scroll-other-window))
416 nil)
418 (case (completion--do-completion)
419 (0 nil)
420 (1 (goto-char (field-end))
421 (minibuffer-message "Sole completion")
423 (3 (goto-char (field-end))
424 (minibuffer-message "Complete, but not unique")
426 (t t)))))
428 (defun minibuffer-complete-and-exit ()
429 "If the minibuffer contents is a valid completion then exit.
430 Otherwise try to complete it. If completion leads to a valid completion,
431 a repetition of this command will exit."
432 (interactive)
433 (let ((beg (field-beginning))
434 (end (field-end)))
435 (cond
436 ;; Allow user to specify null string
437 ((= beg end) (exit-minibuffer))
438 ((test-completion (buffer-substring beg end)
439 minibuffer-completion-table
440 minibuffer-completion-predicate)
441 (when completion-ignore-case
442 ;; Fixup case of the field, if necessary.
443 (let* ((string (buffer-substring beg end))
444 (compl (try-completion
445 string
446 minibuffer-completion-table
447 minibuffer-completion-predicate)))
448 (when (and (stringp compl)
449 ;; If it weren't for this piece of paranoia, I'd replace
450 ;; the whole thing with a call to do-completion.
451 (= (length string) (length compl)))
452 (goto-char end)
453 (insert compl)
454 (delete-region beg end))))
455 (exit-minibuffer))
457 ((eq minibuffer-completion-confirm 'confirm-only)
458 ;; The user is permitted to exit with an input that's rejected
459 ;; by test-completion, but at the condition to confirm her choice.
460 (if (eq last-command this-command)
461 (exit-minibuffer)
462 (minibuffer-message "Confirm")
463 nil))
466 ;; Call do-completion, but ignore errors.
467 (case (condition-case nil
468 (completion--do-completion)
469 (error 1))
470 ((1 3) (exit-minibuffer))
471 (7 (if (not minibuffer-completion-confirm)
472 (exit-minibuffer)
473 (minibuffer-message "Confirm")
474 nil))
475 (t nil))))))
477 (defun completion--try-word-completion (string table predicate point)
478 (let ((comp (completion-try-completion string table predicate point)))
479 (if (not (consp comp))
480 comp
482 ;; If completion finds next char not unique,
483 ;; consider adding a space or a hyphen.
484 (when (= (length string) (length (car comp)))
485 (let ((exts '(" " "-"))
486 (before (substring string 0 point))
487 (after (substring string point))
488 tem)
489 (while (and exts (not (consp tem)))
490 (setq tem (completion-try-completion
491 (concat before (pop exts) after)
492 table predicate (1+ point))))
493 (if (consp tem) (setq comp tem))))
495 ;; Completing a single word is actually more difficult than completing
496 ;; as much as possible, because we first have to find the "current
497 ;; position" in `completion' in order to find the end of the word
498 ;; we're completing. Normally, `string' is a prefix of `completion',
499 ;; which makes it trivial to find the position, but with fancier
500 ;; completion (plus env-var expansion, ...) `completion' might not
501 ;; look anything like `string' at all.
502 (let* ((comppoint (cdr comp))
503 (completion (car comp))
504 (before (substring string 0 point))
505 (combined (concat before "\n" completion)))
506 ;; Find in completion the longest text that was right before point.
507 (when (string-match "\\(.+\\)\n.*?\\1" combined)
508 (let* ((prefix (match-string 1 before))
509 ;; We used non-greedy match to make `rem' as long as possible.
510 (rem (substring combined (match-end 0)))
511 ;; Find in the remainder of completion the longest text
512 ;; that was right after point.
513 (after (substring string point))
514 (suffix (if (string-match "\\`\\(.+\\).*\n.*\\1"
515 (concat after "\n" rem))
516 (match-string 1 after))))
517 ;; The general idea is to try and guess what text was inserted
518 ;; at point by the completion. Problem is: if we guess wrong,
519 ;; we may end up treating as "added by completion" text that was
520 ;; actually painfully typed by the user. So if we then cut
521 ;; after the first word, we may throw away things the
522 ;; user wrote. So let's try to be as conservative as possible:
523 ;; only cut after the first word, if we're reasonably sure that
524 ;; our guess is correct.
525 ;; Note: a quick survey on emacs-devel seemed to indicate that
526 ;; nobody actually cares about the "word-at-a-time" feature of
527 ;; minibuffer-complete-word, whose real raison-d'être is that it
528 ;; tries to add "-" or " ". One more reason to only cut after
529 ;; the first word, if we're really sure we're right.
530 (when (and (or suffix (zerop (length after)))
531 (string-match (concat
532 ;; Make submatch 1 as small as possible
533 ;; to reduce the risk of cutting
534 ;; valuable text.
535 ".*" (regexp-quote prefix) "\\(.*?\\)"
536 (if suffix (regexp-quote suffix) "\\'"))
537 completion)
538 ;; The new point in `completion' should also be just
539 ;; before the suffix, otherwise something more complex
540 ;; is going on, and we're not sure where we are.
541 (eq (match-end 1) comppoint)
542 ;; (match-beginning 1)..comppoint is now the stretch
543 ;; of text in `completion' that was completed at point.
544 (string-match "\\W" completion (match-beginning 1))
545 ;; Is there really something to cut?
546 (> comppoint (match-end 0)))
547 ;; Cut after the first word.
548 (let ((cutpos (match-end 0)))
549 (setq completion (concat (substring completion 0 cutpos)
550 (substring completion comppoint)))
551 (setq comppoint cutpos)))))
553 (cons completion comppoint)))))
556 (defun minibuffer-complete-word ()
557 "Complete the minibuffer contents at most a single word.
558 After one word is completed as much as possible, a space or hyphen
559 is added, provided that matches some possible completion.
560 Return nil if there is no valid completion, else t."
561 (interactive)
562 (case (completion--do-completion 'completion--try-word-completion)
563 (0 nil)
564 (1 (goto-char (field-end))
565 (minibuffer-message "Sole completion")
567 (3 (goto-char (field-end))
568 (minibuffer-message "Complete, but not unique")
570 (t t)))
572 (defun completion--insert-strings (strings)
573 "Insert a list of STRINGS into the current buffer.
574 Uses columns to keep the listing readable but compact.
575 It also eliminates runs of equal strings."
576 (when (consp strings)
577 (let* ((length (apply 'max
578 (mapcar (lambda (s)
579 (if (consp s)
580 (+ (length (car s)) (length (cadr s)))
581 (length s)))
582 strings)))
583 (window (get-buffer-window (current-buffer) 0))
584 (wwidth (if window (1- (window-width window)) 79))
585 (columns (min
586 ;; At least 2 columns; at least 2 spaces between columns.
587 (max 2 (/ wwidth (+ 2 length)))
588 ;; Don't allocate more columns than we can fill.
589 ;; Windows can't show less than 3 lines anyway.
590 (max 1 (/ (length strings) 2))))
591 (colwidth (/ wwidth columns))
592 (column 0)
593 (laststring nil))
594 ;; The insertion should be "sensible" no matter what choices were made
595 ;; for the parameters above.
596 (dolist (str strings)
597 (unless (equal laststring str) ; Remove (consecutive) duplicates.
598 (setq laststring str)
599 (unless (bolp)
600 (insert " \t")
601 (setq column (+ column colwidth))
602 ;; Leave the space unpropertized so that in the case we're
603 ;; already past the goal column, there is still
604 ;; a space displayed.
605 (set-text-properties (- (point) 1) (point)
606 ;; We can't just set tab-width, because
607 ;; completion-setup-function will kill all
608 ;; local variables :-(
609 `(display (space :align-to ,column))))
610 (when (< wwidth (+ (max colwidth
611 (if (consp str)
612 (+ (length (car str)) (length (cadr str)))
613 (length str)))
614 column))
615 (delete-char -2) (insert "\n") (setq column 0))
616 (if (not (consp str))
617 (put-text-property (point) (progn (insert str) (point))
618 'mouse-face 'highlight)
619 (put-text-property (point) (progn (insert (car str)) (point))
620 'mouse-face 'highlight)
621 (put-text-property (point) (progn (insert (cadr str)) (point))
622 'mouse-face nil)))))))
624 (defvar completion-common-substring)
626 (defvar completion-setup-hook nil
627 "Normal hook run at the end of setting up a completion list buffer.
628 When this hook is run, the current buffer is the one in which the
629 command to display the completion list buffer was run.
630 The completion list buffer is available as the value of `standard-output'.
631 The common prefix substring for completion may be available as the value
632 of `completion-common-substring'. See also `display-completion-list'.")
634 (defun display-completion-list (completions &optional common-substring)
635 "Display the list of completions, COMPLETIONS, using `standard-output'.
636 Each element may be just a symbol or string
637 or may be a list of two strings to be printed as if concatenated.
638 If it is a list of two strings, the first is the actual completion
639 alternative, the second serves as annotation.
640 `standard-output' must be a buffer.
641 The actual completion alternatives, as inserted, are given `mouse-face'
642 properties of `highlight'.
643 At the end, this runs the normal hook `completion-setup-hook'.
644 It can find the completion buffer in `standard-output'.
645 The optional second arg COMMON-SUBSTRING is a string.
646 It is used to put faces, `completions-first-difference' and
647 `completions-common-part' on the completion buffer. The
648 `completions-common-part' face is put on the common substring
649 specified by COMMON-SUBSTRING. If COMMON-SUBSTRING is nil
650 and the current buffer is not the minibuffer, the faces are not put.
651 Internally, COMMON-SUBSTRING is bound to `completion-common-substring'
652 during running `completion-setup-hook'."
653 (if (not (bufferp standard-output))
654 ;; This *never* (ever) happens, so there's no point trying to be clever.
655 (with-temp-buffer
656 (let ((standard-output (current-buffer))
657 (completion-setup-hook nil))
658 (display-completion-list completions))
659 (princ (buffer-string)))
661 (with-current-buffer standard-output
662 (goto-char (point-max))
663 (if (null completions)
664 (insert "There are no possible completions of what you have typed.")
666 (insert "Possible completions are:\n")
667 (let ((last (last completions)))
668 ;; Get the base-size from the tail of the list.
669 (set (make-local-variable 'completion-base-size) (or (cdr last) 0))
670 (setcdr last nil)) ;Make completions a properly nil-terminated list.
671 (completion--insert-strings completions))))
673 (let ((completion-common-substring common-substring))
674 (run-hooks 'completion-setup-hook))
675 nil)
677 (defun minibuffer-completion-help ()
678 "Display a list of possible completions of the current minibuffer contents."
679 (interactive)
680 (message "Making completion list...")
681 (let* ((string (field-string))
682 (completions (completion-all-completions
683 string
684 minibuffer-completion-table
685 minibuffer-completion-predicate
686 (- (point) (field-beginning)))))
687 (message nil)
688 (if (and completions
689 (or (consp (cdr completions))
690 (not (equal (car completions) string))))
691 (with-output-to-temp-buffer "*Completions*"
692 (let* ((last (last completions))
693 (base-size (cdr last)))
694 ;; Remove the base-size tail because `sort' requires a properly
695 ;; nil-terminated list.
696 (when last (setcdr last nil))
697 (display-completion-list (nconc (sort completions 'string-lessp)
698 base-size))))
700 ;; If there are no completions, or if the current input is already the
701 ;; only possible completion, then hide (previous&stale) completions.
702 (let ((window (and (get-buffer "*Completions*")
703 (get-buffer-window "*Completions*" 0))))
704 (when (and (window-live-p window) (window-dedicated-p window))
705 (condition-case ()
706 (delete-window window)
707 (error (iconify-frame (window-frame window))))))
708 (ding)
709 (minibuffer-message
710 (if completions "Sole completion" "No completions")))
711 nil))
713 (defun exit-minibuffer ()
714 "Terminate this minibuffer argument."
715 (interactive)
716 ;; If the command that uses this has made modifications in the minibuffer,
717 ;; we don't want them to cause deactivation of the mark in the original
718 ;; buffer.
719 ;; A better solution would be to make deactivate-mark buffer-local
720 ;; (or to turn it into a list of buffers, ...), but in the mean time,
721 ;; this should do the trick in most cases.
722 (setq deactivate-mark nil)
723 (throw 'exit nil))
725 (defun self-insert-and-exit ()
726 "Terminate minibuffer input."
727 (interactive)
728 (if (characterp last-command-char)
729 (call-interactively 'self-insert-command)
730 (ding))
731 (exit-minibuffer))
733 (defun minibuffer--double-dollars (str)
734 (replace-regexp-in-string "\\$" "$$" str))
736 (defun completion--make-envvar-table ()
737 (mapcar (lambda (enventry)
738 (substring enventry 0 (string-match "=" enventry)))
739 process-environment))
741 (defun completion--embedded-envvar-table (string pred action)
742 (when (string-match (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)"
743 "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'")
744 string)
745 (let* ((beg (or (match-beginning 2) (match-beginning 1)))
746 (table (completion--make-envvar-table))
747 (prefix (substring string 0 beg)))
748 (if (eq (aref string (1- beg)) ?{)
749 (setq table (apply-partially 'completion-table-with-terminator
750 "}" table)))
751 (completion-table-with-context prefix table
752 (substring string beg)
753 pred action))))
755 (defun completion--file-name-table (string pred action)
756 "Internal subroutine for `read-file-name'. Do not call this."
757 (if (and (zerop (length string)) (eq 'lambda action))
758 nil ; FIXME: why?
759 (let* ((dir (if (stringp pred)
760 ;; It used to be that `pred' was abused to pass `dir'
761 ;; as an argument.
762 (prog1 (expand-file-name pred) (setq pred nil))
763 default-directory))
764 (str (condition-case nil
765 (substitute-in-file-name string)
766 (error string)))
767 (name (file-name-nondirectory str))
768 (specdir (file-name-directory str))
769 (realdir (if specdir (expand-file-name specdir dir)
770 (file-name-as-directory dir))))
772 (cond
773 ((null action)
774 (let ((comp (file-name-completion name realdir
775 read-file-name-predicate)))
776 (if (stringp comp)
777 ;; Requote the $s before returning the completion.
778 (minibuffer--double-dollars (concat specdir comp))
779 ;; Requote the $s before checking for changes.
780 (setq str (minibuffer--double-dollars str))
781 (if (string-equal string str)
782 comp
783 ;; If there's no real completion, but substitute-in-file-name
784 ;; changed the string, then return the new string.
785 str))))
787 ((eq action t)
788 (let ((all (file-name-all-completions name realdir))
789 ;; Actually, this is not always right in the presence of
790 ;; envvars, but there's not much we can do, I think.
791 (base-size (length (file-name-directory string))))
793 ;; Check the predicate, if necessary.
794 (unless (memq read-file-name-predicate '(nil file-exists-p))
795 (let ((comp ())
796 (pred
797 (if (eq read-file-name-predicate 'file-directory-p)
798 ;; Brute-force speed up for directory checking:
799 ;; Discard strings which don't end in a slash.
800 (lambda (s)
801 (let ((len (length s)))
802 (and (> len 0) (eq (aref s (1- len)) ?/))))
803 ;; Must do it the hard (and slow) way.
804 read-file-name-predicate)))
805 (let ((default-directory realdir))
806 (dolist (tem all)
807 (if (funcall pred tem) (push tem comp))))
808 (setq all (nreverse comp))))
810 (if (and completion-all-completions-with-base-size (consp all))
811 ;; Add base-size, but only if the list is non-empty.
812 (nconc all base-size))
814 all))
817 ;; Only other case actually used is ACTION = lambda.
818 (let ((default-directory dir))
819 (funcall (or read-file-name-predicate 'file-exists-p) str)))))))
821 (defalias 'read-file-name-internal
822 (completion-table-in-turn 'completion--embedded-envvar-table
823 'completion--file-name-table)
824 "Internal subroutine for `read-file-name'. Do not call this.")
826 (defvar read-file-name-function nil
827 "If this is non-nil, `read-file-name' does its work by calling this function.")
829 (defvar read-file-name-predicate nil
830 "Current predicate used by `read-file-name-internal'.")
832 (defcustom read-file-name-completion-ignore-case
833 (if (memq system-type '(ms-dos windows-nt darwin macos vax-vms axp-vms))
834 t nil)
835 "Non-nil means when reading a file name completion ignores case."
836 :group 'minibuffer
837 :type 'boolean
838 :version "22.1")
840 (defcustom insert-default-directory t
841 "Non-nil means when reading a filename start with default dir in minibuffer.
843 When the initial minibuffer contents show a name of a file or a directory,
844 typing RETURN without editing the initial contents is equivalent to typing
845 the default file name.
847 If this variable is non-nil, the minibuffer contents are always
848 initially non-empty, and typing RETURN without editing will fetch the
849 default name, if one is provided. Note however that this default name
850 is not necessarily the same as initial contents inserted in the minibuffer,
851 if the initial contents is just the default directory.
853 If this variable is nil, the minibuffer often starts out empty. In
854 that case you may have to explicitly fetch the next history element to
855 request the default name; typing RETURN without editing will leave
856 the minibuffer empty.
858 For some commands, exiting with an empty minibuffer has a special meaning,
859 such as making the current buffer visit no file in the case of
860 `set-visited-file-name'."
861 :group 'minibuffer
862 :type 'boolean)
864 ;; Not always defined, but only called if next-read-file-uses-dialog-p says so.
865 (declare-function x-file-dialog "xfns.c"
866 (prompt dir &optional default-filename mustmatch only-dir-p))
868 (defun read-file-name (prompt &optional dir default-filename mustmatch initial predicate)
869 "Read file name, prompting with PROMPT and completing in directory DIR.
870 Value is not expanded---you must call `expand-file-name' yourself.
871 Default name to DEFAULT-FILENAME if user exits the minibuffer with
872 the same non-empty string that was inserted by this function.
873 (If DEFAULT-FILENAME is omitted, the visited file name is used,
874 except that if INITIAL is specified, that combined with DIR is used.)
875 If the user exits with an empty minibuffer, this function returns
876 an empty string. (This can only happen if the user erased the
877 pre-inserted contents or if `insert-default-directory' is nil.)
878 Fourth arg MUSTMATCH non-nil means require existing file's name.
879 Non-nil and non-t means also require confirmation after completion.
880 Fifth arg INITIAL specifies text to start with.
881 If optional sixth arg PREDICATE is non-nil, possible completions and
882 the resulting file name must satisfy (funcall PREDICATE NAME).
883 DIR should be an absolute directory name. It defaults to the value of
884 `default-directory'.
886 If this command was invoked with the mouse, use a file dialog box if
887 `use-dialog-box' is non-nil, and the window system or X toolkit in use
888 provides a file dialog box.
890 See also `read-file-name-completion-ignore-case'
891 and `read-file-name-function'."
892 (unless dir (setq dir default-directory))
893 (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir)))
894 (unless default-filename
895 (setq default-filename (if initial (expand-file-name initial dir)
896 buffer-file-name)))
897 ;; If dir starts with user's homedir, change that to ~.
898 (setq dir (abbreviate-file-name dir))
899 ;; Likewise for default-filename.
900 (if default-filename
901 (setq default-filename (abbreviate-file-name default-filename)))
902 (let ((insdef (cond
903 ((and insert-default-directory (stringp dir))
904 (if initial
905 (cons (minibuffer--double-dollars (concat dir initial))
906 (length (minibuffer--double-dollars dir)))
907 (minibuffer--double-dollars dir)))
908 (initial (cons (minibuffer--double-dollars initial) 0)))))
910 (if read-file-name-function
911 (funcall read-file-name-function
912 prompt dir default-filename mustmatch initial predicate)
913 (let ((completion-ignore-case read-file-name-completion-ignore-case)
914 (minibuffer-completing-file-name t)
915 (read-file-name-predicate (or predicate 'file-exists-p))
916 (add-to-history nil))
918 (let* ((val
919 (if (not (next-read-file-uses-dialog-p))
920 ;; We used to pass `dir' to `read-file-name-internal' by
921 ;; abusing the `predicate' argument. It's better to
922 ;; just use `default-directory', but in order to avoid
923 ;; changing `default-directory' in the current buffer,
924 ;; we don't let-bind it.
925 (lexical-let ((dir (file-name-as-directory
926 (expand-file-name dir))))
927 (minibuffer-with-setup-hook
928 (lambda () (setq default-directory dir))
929 (completing-read prompt 'read-file-name-internal
930 nil mustmatch insdef 'file-name-history
931 default-filename)))
932 ;; If DIR contains a file name, split it.
933 (let ((file (file-name-nondirectory dir)))
934 (when (and default-filename (not (zerop (length file))))
935 (setq default-filename file)
936 (setq dir (file-name-directory dir)))
937 (if default-filename
938 (setq default-filename
939 (expand-file-name default-filename dir)))
940 (setq add-to-history t)
941 (x-file-dialog prompt dir default-filename mustmatch
942 (eq predicate 'file-directory-p)))))
944 (replace-in-history (eq (car-safe file-name-history) val)))
945 ;; If completing-read returned the inserted default string itself
946 ;; (rather than a new string with the same contents),
947 ;; it has to mean that the user typed RET with the minibuffer empty.
948 ;; In that case, we really want to return ""
949 ;; so that commands such as set-visited-file-name can distinguish.
950 (when (eq val default-filename)
951 ;; In this case, completing-read has not added an element
952 ;; to the history. Maybe we should.
953 (if (not replace-in-history)
954 (setq add-to-history t))
955 (setq val ""))
956 (unless val (error "No file name specified"))
958 (if (and default-filename
959 (string-equal val (if (consp insdef) (car insdef) insdef)))
960 (setq val default-filename))
961 (setq val (substitute-in-file-name val))
963 (if replace-in-history
964 ;; Replace what Fcompleting_read added to the history
965 ;; with what we will actually return.
966 (let ((val1 (minibuffer--double-dollars val)))
967 (if history-delete-duplicates
968 (setcdr file-name-history
969 (delete val1 (cdr file-name-history))))
970 (setcar file-name-history val1))
971 (if add-to-history
972 ;; Add the value to the history--but not if it matches
973 ;; the last value already there.
974 (let ((val1 (minibuffer--double-dollars val)))
975 (unless (and (consp file-name-history)
976 (equal (car file-name-history) val1))
977 (setq file-name-history
978 (cons val1
979 (if history-delete-duplicates
980 (delete val1 file-name-history)
981 file-name-history)))))))
982 val)))))
984 (defun internal-complete-buffer-except (&optional buffer)
985 "Perform completion on all buffers excluding BUFFER.
986 Like `internal-complete-buffer', but removes BUFFER from the completion list."
987 (lexical-let ((except (if (stringp buffer) buffer (buffer-name buffer))))
988 (apply-partially 'completion-table-with-predicate
989 'internal-complete-buffer
990 (lambda (name)
991 (not (equal (if (consp name) (car name) name) except)))
992 nil)))
994 ;;; Old-style completion, used in Emacs-21.
996 (defun completion-emacs21-try-completion (string table pred point)
997 (let ((completion (try-completion string table pred)))
998 (if (stringp completion)
999 (cons completion (length completion))
1000 completion)))
1002 (defun completion-emacs21-all-completions (string table pred point)
1003 (all-completions string table pred t))
1005 ;;; Basic completion, used in Emacs-22.
1007 (defun completion-emacs22-try-completion (string table pred point)
1008 (let ((suffix (substring string point))
1009 (completion (try-completion (substring string 0 point) table pred)))
1010 (if (not (stringp completion))
1011 completion
1012 ;; Merge a trailing / in completion with a / after point.
1013 ;; We used to only do it for word completion, but it seems to make
1014 ;; sense for all completions.
1015 ;; Actually, claiming this feature was part of Emacs-22 completion
1016 ;; is pushing it a bit: it was only done in minibuffer-completion-word,
1017 ;; which was (by default) not bound during file completion, where such
1018 ;; slashes are most likely to occur.
1019 (if (and (not (zerop (length completion)))
1020 (eq ?/ (aref completion (1- (length completion))))
1021 (not (zerop (length suffix)))
1022 (eq ?/ (aref suffix 0)))
1023 ;; This leaves point after the / .
1024 (setq suffix (substring suffix 1)))
1025 (cons (concat completion suffix) (length completion)))))
1027 (defun completion-emacs22-all-completions (string table pred point)
1028 (all-completions (substring string 0 point) table pred t))
1030 (defun completion-basic-try-completion (string table pred point)
1031 (let ((suffix (substring string point))
1032 (completion (try-completion (substring string 0 point) table pred)))
1033 (if (not (stringp completion))
1034 completion
1035 ;; Merge end of completion with beginning of suffix.
1036 ;; Simple generalization of the "merge trailing /" done in Emacs-22.
1037 (when (and (not (zerop (length suffix)))
1038 (string-match "\\(.+\\)\n\\1" (concat completion "\n" suffix)
1039 ;; Make sure we don't compress things to less
1040 ;; than we started with.
1041 point)
1042 ;; Just make sure we didn't match some other \n.
1043 (eq (match-end 1) (length completion)))
1044 (setq suffix (substring suffix (- (match-end 1) (match-beginning 1)))))
1046 (cons (concat completion suffix) (length completion)))))
1048 (defalias 'completion-basic-all-completions 'completion-emacs22-all-completions)
1050 ;;; Partial-completion-mode style completion.
1052 ;; BUGS:
1054 ;; - "minibuffer-s- TAB" with minibuffer-selected-window ends up with
1055 ;; "minibuffer--s-" which matches other options.
1057 (defvar completion-pcm--delim-wild-regex nil)
1059 (defun completion-pcm--prepare-delim-re (delims)
1060 (setq completion-pcm--delim-wild-regex (concat "[" delims "*]")))
1062 (defcustom completion-pcm-word-delimiters "-_. "
1063 "A string of characters treated as word delimiters for completion.
1064 Some arcane rules:
1065 If `]' is in this string, it must come first.
1066 If `^' is in this string, it must not come first.
1067 If `-' is in this string, it must come first or right after `]'.
1068 In other words, if S is this string, then `[S]' must be a valid Emacs regular
1069 expression (not containing character ranges like `a-z')."
1070 :set (lambda (symbol value)
1071 (set-default symbol value)
1072 ;; Refresh other vars.
1073 (completion-pcm--prepare-delim-re value))
1074 :initialize 'custom-initialize-reset
1075 :type 'string)
1077 (defun completion-pcm--pattern-trivial-p (pattern)
1078 (and (stringp (car pattern)) (null (cdr pattern))))
1080 (defun completion-pcm--string->pattern (basestr &optional point)
1081 "Split BASESTR into a pattern.
1082 A pattern is a list where each element is either a string
1083 or a symbol chosen among `any', `star', `point'."
1084 (if (and point (< point (length basestr)))
1085 (let ((prefix (substring basestr 0 point))
1086 (suffix (substring basestr point)))
1087 (append (completion-pcm--string->pattern prefix)
1088 '(point)
1089 (completion-pcm--string->pattern suffix)))
1090 (let ((pattern nil)
1091 (p 0)
1092 (p0 0))
1094 (while (setq p (string-match completion-pcm--delim-wild-regex basestr p))
1095 (push (substring basestr p0 p) pattern)
1096 (if (eq (aref basestr p) ?*)
1097 (progn
1098 (push 'star pattern)
1099 (setq p0 (1+ p)))
1100 (push 'any pattern)
1101 (setq p0 p))
1102 (incf p))
1104 ;; An empty string might be erroneously added at the beginning.
1105 ;; It should be avoided properly, but it's so easy to remove it here.
1106 (delete "" (nreverse (cons (substring basestr p0) pattern))))))
1108 (defun completion-pcm--pattern->regex (pattern &optional group)
1109 (concat "\\`"
1110 (mapconcat
1111 (lambda (x)
1112 (case x
1113 ((star any point) (if group "\\(.*?\\)" ".*?"))
1114 (t (regexp-quote x))))
1115 pattern
1116 "")))
1118 (defun completion-pcm--all-completions (pattern table pred)
1119 "Find all completions for PATTERN in TABLE obeying PRED.
1120 PATTERN is as returned by `complete-string->pattern'."
1121 ;; Find an initial list of possible completions.
1122 (if (completion-pcm--pattern-trivial-p pattern)
1124 ;; Minibuffer contains no delimiters -- simple case!
1125 (all-completions (car pattern) table pred)
1127 ;; Use all-completions to do an initial cull. This is a big win,
1128 ;; since all-completions is written in C!
1129 (let* (;; Convert search pattern to a standard regular expression.
1130 (regex (completion-pcm--pattern->regex pattern))
1131 (completion-regexp-list (cons regex completion-regexp-list))
1132 (compl (all-completions
1133 (if (stringp (car pattern)) (car pattern))
1134 table pred))
1135 (last (last compl)))
1136 ;; FIXME: If `base-size' is not 0, we have a problem :-(
1137 (if last (setcdr last nil))
1138 (if (not (functionp table))
1139 ;; The internal functions already obeyed completion-regexp-list.
1140 compl
1141 (let ((case-fold-search completion-ignore-case)
1142 (poss ()))
1143 (dolist (c compl)
1144 (when (string-match regex c) (push c poss)))
1145 poss)))))
1147 (defun completion-pcm-all-completions (string table pred point)
1148 (let ((pattern (completion-pcm--string->pattern string point)))
1149 (completion-pcm--all-completions pattern table pred)))
1151 (defun completion-pcm--merge-completions (strs pattern)
1152 "Extract the commonality in STRS, with the help of PATTERN."
1153 (cond
1154 ((null (cdr strs)) (list (car strs)))
1156 (let ((re (completion-pcm--pattern->regex pattern 'group))
1157 (ccs ())) ;Chopped completions.
1159 ;; First chop each string into the parts corresponding to each
1160 ;; non-constant element of `pattern', using regexp-matching.
1161 (let ((case-fold-search completion-ignore-case))
1162 (dolist (str strs)
1163 (unless (string-match re str)
1164 (error "Internal error: %s doesn't match %s" str re))
1165 (let ((chopped ())
1166 (i 1))
1167 (while (match-beginning i)
1168 (push (match-string i str) chopped)
1169 (setq i (1+ i)))
1170 ;; Add the text corresponding to the implicit trailing `any'.
1171 (push (substring str (match-end 0)) chopped)
1172 (push (nreverse chopped) ccs))))
1174 ;; Then for each of those non-constant elements, extract the
1175 ;; commonality between them.
1176 (let ((res ()))
1177 ;; Make the implicit `any' explicit. We could make it explicit
1178 ;; everywhere, but it would slow down regexp-matching a little bit.
1179 (dolist (elem (append pattern '(any)))
1180 (if (stringp elem)
1181 (push elem res)
1182 (let ((comps ()))
1183 (dolist (cc (prog1 ccs (setq ccs nil)))
1184 (push (car cc) comps)
1185 (push (cdr cc) ccs))
1186 (let* ((prefix (try-completion "" comps))
1187 (unique (or (and (eq prefix t) (setq prefix ""))
1188 (eq t (try-completion prefix comps)))))
1189 (unless (equal prefix "") (push prefix res))
1190 ;; If there's only one completion, `elem' is not useful
1191 ;; any more: it can only match the empty string.
1192 ;; FIXME: in some cases, it may be necessary to turn an
1193 ;; `any' into a `star' because the surrounding context has
1194 ;; changed such that string->pattern wouldn't add an `any'
1195 ;; here any more.
1196 (unless unique (push elem res))))))
1197 ;; We return it in reverse order.
1198 res)))))
1200 (defun completion-pcm--pattern->string (pattern)
1201 (mapconcat (lambda (x) (cond
1202 ((stringp x) x)
1203 ((eq x 'star) "*")
1204 ((eq x 'any) "")
1205 ((eq x 'point) "")))
1206 pattern
1207 ""))
1209 (defun completion-pcm-try-completion (string table pred point)
1210 (let* ((pattern (completion-pcm--string->pattern string point))
1211 (all (completion-pcm--all-completions pattern table pred)))
1212 (when all
1213 (let* ((mergedpat (completion-pcm--merge-completions all pattern))
1214 ;; `mergedpat' is in reverse order.
1215 (pointpat (or (memq 'point mergedpat) (memq 'any mergedpat)))
1216 ;; New pos from the end.
1217 (newpos (length (completion-pcm--pattern->string pointpat)))
1218 ;; Do it afterwards because it changes `pointpat' by sideeffect.
1219 (merged (completion-pcm--pattern->string (nreverse mergedpat))))
1220 (cons merged (- (length merged) newpos))))))
1225 (provide 'minibuffer)
1227 ;; arch-tag: ef8a0a15-1080-4790-a754-04017c02f08f
1228 ;;; minibuffer.el ends here