+2014-03-01 Glenn Morris <rgm@gnu.org>
+
+ * minibuffer.el (completion-hilit-commonality):
+ Make `base-size' argument optional. Short-cut if `prefix-len' is 0.
+ * comint.el (comint-dynamic-list-completions): Doc fix.
+ * comint.el (comint-dynamic-list-completions):
+ * filecache.el (file-cache-minibuffer-complete):
+ * tempo.el (tempo-display-completions):
+ * eshell/em-hist.el (eshell-list-history):
+ Replace use of obsolete argument of display-completion-list.
+
2014-03-01 Juanma Barranquero <lekktu@gmail.com>
* icomplete.el (icomplete-completions):
(defun comint-dynamic-list-completions (completions &optional common-substring)
"Display a list of sorted COMPLETIONS.
-The meaning of COMMON-SUBSTRING is the same as in `display-completion-list'.
-Typing SPC flushes the completions buffer."
+Typing SPC flushes the completions buffer.
+
+The optional argument COMMON-SUBSTRING, if non-nil, should be a string
+specifying a common substring for adding the faces
+`completions-first-difference' and `completions-common-part' to
+the completions."
(let ((window (get-buffer-window "*Completions*" 0)))
(setq completions (sort completions 'string-lessp))
(if (and (eq last-command this-command)
(setq comint-dynamic-list-completions-config
(current-window-configuration))
(with-output-to-temp-buffer "*Completions*"
- (display-completion-list completions common-substring))
+ (display-completion-list
+ (completion-hilit-commonality completions (length common-substring))))
(if (window-minibuffer-p)
(minibuffer-message "Type space to flush; repeat completion command to scroll")
(message "Type space to flush; repeat completion command to scroll")))
;; Change "completion" to "history reference"
;; to make the display accurate.
(with-output-to-temp-buffer history-buffer
- (display-completion-list history prefix)
+ (display-completion-list
+ (completion-hilit-commonality history (length prefix)))
(set-buffer history-buffer)
(forward-line 3)
(while (search-backward "completion" nil 'move)
(append completion-setup-hook
(list 'file-cache-completion-setup-function))))
(with-output-to-temp-buffer file-cache-completions-buffer
- (display-completion-list completion-list string))))
+ (display-completion-list
+ (completion-hilit-commonality completion-list
+ (length string))))))
(setq file-cache-string (file-cache-file-name completion-string))
(if (string= file-cache-string (minibuffer-contents))
(minibuffer-message file-cache-sole-match-message)
by contrast.
See also the face `completions-first-difference'.")
-(defun completion-hilit-commonality (completions prefix-len base-size)
+(defun completion-hilit-commonality (completions prefix-len &optional base-size)
"Apply font-lock highlighting to a list of completions, COMPLETIONS.
PREFIX-LEN is an integer. BASE-SIZE is an integer or nil (meaning zero).
It returns a list with font-lock properties applied to each element,
and with BASE-SIZE appended as the last element."
(when completions
- (let ((com-str-len (- prefix-len (or base-size 0))))
- (nconc
- (mapcar
- (lambda (elem)
- (let ((str
- ;; Don't modify the string itself, but a copy, since the
- ;; the string may be read-only or used for other purposes.
- ;; Furthermore, since `completions' may come from
- ;; display-completion-list, `elem' may be a list.
- (if (consp elem)
- (car (setq elem (cons (copy-sequence (car elem))
- (cdr elem))))
- (setq elem (copy-sequence elem)))))
- (font-lock-prepend-text-property
- 0
- ;; If completion-boundaries returns incorrect
- ;; values, all-completions may return strings
- ;; that don't contain the prefix.
- (min com-str-len (length str))
- 'face 'completions-common-part str)
- (if (> (length str) com-str-len)
- (font-lock-prepend-text-property com-str-len (1+ com-str-len)
- 'face
- 'completions-first-difference
- str)))
- elem)
- completions)
- base-size))))
+ (if (zerop prefix-len)
+ completions
+ (let ((com-str-len (- prefix-len (or base-size 0))))
+ (nconc
+ (mapcar
+ (lambda (elem)
+ (let ((str
+ ;; Don't modify the string itself, but a copy, since the
+ ;; the string may be read-only or used for other purposes.
+ ;; Furthermore, since `completions' may come from
+ ;; display-completion-list, `elem' may be a list.
+ (if (consp elem)
+ (car (setq elem (cons (copy-sequence (car elem))
+ (cdr elem))))
+ (setq elem (copy-sequence elem)))))
+ (font-lock-prepend-text-property
+ 0
+ ;; If completion-boundaries returns incorrect
+ ;; values, all-completions may return strings
+ ;; that don't contain the prefix.
+ (min com-str-len (length str))
+ 'face 'completions-common-part str)
+ (if (> (length str) com-str-len)
+ (font-lock-prepend-text-property com-str-len (1+ com-str-len)
+ 'face
+ 'completions-first-difference
+ str)))
+ elem)
+ completions)
+ base-size)))))
(defun display-completion-list (completions &optional common-substring)
"Display the list of completions, COMPLETIONS, using `standard-output'.
;; Copyright (C) 1994-1995, 2001-2014 Free Software Foundation, Inc.
-;; Author: David K}gedal <davidk@lysator.liu.se>
+;; Author: David Kågedal <davidk@lysator.liu.se>
;; Created: 16 Feb 1994
-;; K}gedal's last version number: 1.2.4
+;; Kågedal's last version number: 1.2.4
;; Keywords: extensions, languages, tools
;; This file is part of GNU Emacs.
(if tempo-leave-completion-buffer
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
- (all-completions string tag-list)
- string))
+ (completion-hilit-commonality (all-completions string tag-list)
+ (length string))))
(save-window-excursion
(with-output-to-temp-buffer "*Completions*"
(display-completion-list
- (all-completions string tag-list)
- string))
+ (completion-hilit-commonality (all-completions string tag-list)
+ (length string))))
(sit-for 32767))))
;;;
(provide 'tempo)
;;; tempo.el ends here
+
+;; Local Variables:
+;; coding: utf-8
+;; End: