summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 05:36:55 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 05:36:55 +0000
commit6138158d86aff6a072f2012876ef034bc9e59986 (patch)
treef99145e91324623d8d357238d2b9acaba317d595 /lisp/simple.el
parent62a918cab4c8a0550dc52f7024aaf23581784b1a (diff)
downloademacs-6138158d86aff6a072f2012876ef034bc9e59986.tar.gz
* minibuffer.el (completion-common-substring): Mark obsolete.
(completions-first-difference, completions-common-part): Move from simple.el. (completion-hilit-commonality): New fun. (display-completion-list, completion-emacs21-all-completions) (completion-emacs22-all-completions): Use it. * simple.el (completions-first-difference, completions-common-part): Move to minibuffer.el. (choose-completion-string): Use field functions and minibufferp. (completion-setup-function): Don't set completions faces.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el61
1 files changed, 9 insertions, 52 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 4ef352e1cd5..164862c1423 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5425,11 +5425,15 @@ to decide what to delete."
'choose-completion-string-functions
choice buffer mini-p base-size)
;; Insert the completion into the buffer where it was requested.
+ ;; FIXME:
+ ;; - There may not be a field at point, or there may be a field but
+ ;; it's not a "completion field", in which case we have to
+ ;; call choose-completion-delete-max-match even if base-size is set.
+ ;; - we may need to delete further than (point) to (field-end),
+ ;; depending on the completion-style, and for that we need to
+ ;; extra data `completion-extra-size'.
(if base-size
- (delete-region (+ base-size (if mini-p
- (minibuffer-prompt-end)
- (point-min)))
- (point))
+ (delete-region (+ base-size (field-beginning)) (point))
(choose-completion-delete-max-match choice))
(insert choice)
(remove-text-properties (- (point) (length choice)) (point)
@@ -5439,7 +5443,7 @@ to decide what to delete."
(set-window-point window (point)))
;; If completing for the minibuffer, exit it with this choice.
(and (not completion-no-auto-exit)
- (equal buffer (window-buffer (minibuffer-window)))
+ (minibufferp buffer)
minibuffer-completion-table
;; If this is reading a file name, and the file name chosen
;; is a directory, don't exit the minibuffer.
@@ -5478,34 +5482,12 @@ Called from `temp-buffer-show-hook'."
:version "22.1"
:group 'completion)
-(defface completions-first-difference
- '((t (:inherit bold)))
- "Face put on the first uncommon character in completions in *Completions* buffer."
- :group 'completion)
-
-(defface completions-common-part
- '((t (:inherit default)))
- "Face put on the common prefix substring in completions in *Completions* buffer.
-The idea of `completions-common-part' is that you can use it to
-make the common parts less visible than normal, so that the rest
-of the differing parts is, by contrast, slightly highlighted."
- :group 'completion)
-
;; This is for packages that need to bind it to a non-default regexp
;; in order to make the first-differing character highlight work
;; to their liking
(defvar completion-root-regexp "^/"
"Regexp to use in `completion-setup-function' to find the root directory.")
-(defvar completion-common-substring nil
- "Common prefix substring to use in `completion-setup-function' to put faces.
-The value is set by `display-completion-list' during running `completion-setup-hook'.
-
-To put faces `completions-first-difference' and `completions-common-part'
-in the `*Completions*' buffer, the common prefix substring in completions
-is needed as a hint. (The minibuffer is a special case. The content
-of the minibuffer before point is always the common substring.)")
-
;; This function goes in completion-setup-hook, so that it is called
;; after the text of the completion list buffer is written.
(defun completion-setup-function ()
@@ -5539,31 +5521,6 @@ of the minibuffer before point is always the common substring.)")
(minibuffer-completing-symbol nil)
;; Otherwise, in minibuffer, the base size is 0.
((minibufferp mainbuf) 0))))
- (setq common-string-length
- (cond
- (completion-common-substring
- (length completion-common-substring))
- (completion-base-size
- (- (length mbuf-contents) completion-base-size))))
- ;; Put faces on first uncommon characters and common parts.
- (when (and (integerp common-string-length) (>= common-string-length 0))
- (let ((element-start (point-min))
- (maxp (point-max))
- element-common-end)
- (while (and (setq element-start
- (next-single-property-change
- element-start 'mouse-face))
- (< (setq element-common-end
- (+ element-start common-string-length))
- maxp))
- (when (get-char-property element-start 'mouse-face)
- (if (and (> common-string-length 0)
- (get-char-property (1- element-common-end) 'mouse-face))
- (put-text-property element-start element-common-end
- 'font-lock-face 'completions-common-part))
- (if (get-char-property element-common-end 'mouse-face)
- (put-text-property element-common-end (1+ element-common-end)
- 'font-lock-face 'completions-first-difference))))))
;; Maybe insert help string.
(when completion-show-help
(goto-char (point-min))