aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2017-11-07 12:17:34 -0500
committerStefan Monnier2017-11-07 12:17:34 -0500
commit325ef57b0e3977f9509f1049c826999e8b7c226d (patch)
tree937cdfc4005f324170966cbc0fdffc20cf9ee786
parent12c39211b38f641a72eb15c8f046df24d8acc4c3 (diff)
downloademacs-325ef57b0e3977f9509f1049c826999e8b7c226d.tar.gz
emacs-325ef57b0e3977f9509f1049c826999e8b7c226d.zip
* lisp/minibuffer.el: Put completions-common-part on all common parts
(completion-pcm--pattern-point-idx): New function. (completion-pcm--hilit-commonality): Use it. Put completions-common-part on all the common parts.
-rw-r--r--lisp/minibuffer.el28
1 files changed, 24 insertions, 4 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index f13f1fa7984..c3f77afae60 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1312,7 +1312,7 @@ Repeated uses step through the possible completions."
1312(defvar minibuffer-confirm-exit-commands 1312(defvar minibuffer-confirm-exit-commands
1313 '(completion-at-point minibuffer-complete 1313 '(completion-at-point minibuffer-complete
1314 minibuffer-complete-word PC-complete PC-complete-word) 1314 minibuffer-complete-word PC-complete PC-complete-word)
1315 "A list of commands which cause an immediately following 1315 "List of commands which cause an immediately following
1316`minibuffer-complete-and-exit' to ask for extra confirmation.") 1316`minibuffer-complete-and-exit' to ask for extra confirmation.")
1317 1317
1318(defun minibuffer-complete-and-exit () 1318(defun minibuffer-complete-and-exit ()
@@ -2979,6 +2979,17 @@ or a symbol, see `completion-pcm--merge-completions'."
2979 (setq re (replace-match "" t t re 1))) 2979 (setq re (replace-match "" t t re 1)))
2980 re)) 2980 re))
2981 2981
2982(defun completion-pcm--pattern-point-idx (pattern)
2983 "Return index of subgroup corresponding to `point' element of PATTERN.
2984Return nil if there's no such element."
2985 (let ((idx nil)
2986 (i 0))
2987 (dolist (x pattern)
2988 (unless (stringp x)
2989 (cl-incf i)
2990 (if (eq x 'point) (setq idx i))))
2991 idx))
2992
2982(defun completion-pcm--all-completions (prefix pattern table pred) 2993(defun completion-pcm--all-completions (prefix pattern table pred)
2983 "Find all completions for PATTERN in TABLE obeying PRED. 2994 "Find all completions for PATTERN in TABLE obeying PRED.
2984PATTERN is as returned by `completion-pcm--string->pattern'." 2995PATTERN is as returned by `completion-pcm--string->pattern'."
@@ -3010,7 +3021,8 @@ PATTERN is as returned by `completion-pcm--string->pattern'."
3010 3021
3011(defun completion-pcm--hilit-commonality (pattern completions) 3022(defun completion-pcm--hilit-commonality (pattern completions)
3012 (when completions 3023 (when completions
3013 (let* ((re (completion-pcm--pattern->regex pattern '(point))) 3024 (let* ((re (completion-pcm--pattern->regex pattern 'group))
3025 (point-idx (completion-pcm--pattern-point-idx pattern))
3014 (case-fold-search completion-ignore-case)) 3026 (case-fold-search completion-ignore-case))
3015 (mapcar 3027 (mapcar
3016 (lambda (str) 3028 (lambda (str)
@@ -3018,8 +3030,16 @@ PATTERN is as returned by `completion-pcm--string->pattern'."
3018 (setq str (copy-sequence str)) 3030 (setq str (copy-sequence str))
3019 (unless (string-match re str) 3031 (unless (string-match re str)
3020 (error "Internal error: %s does not match %s" re str)) 3032 (error "Internal error: %s does not match %s" re str))
3021 (let ((pos (or (match-beginning 1) (match-end 0)))) 3033 (let* ((pos (if point-idx (match-beginning point-idx) (match-end 0)))
3022 (put-text-property 0 pos 3034 (md (match-data))
3035 (start (pop md))
3036 (end (pop md)))
3037 (while md
3038 (put-text-property start (pop md)
3039 'font-lock-face 'completions-common-part
3040 str)
3041 (setq start (pop md)))
3042 (put-text-property start end
3023 'font-lock-face 'completions-common-part 3043 'font-lock-face 'completions-common-part
3024 str) 3044 str)
3025 (if (> (length str) pos) 3045 (if (> (length str) pos)