emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog minibuffer.el


From: Stefan Monnier
Subject: [Emacs-diffs] emacs/lisp ChangeLog minibuffer.el
Date: Wed, 19 Aug 2009 02:15:22 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/08/19 02:15:22

Modified files:
        lisp           : ChangeLog minibuffer.el 

Log message:
        (minibuffer-hide-completions): New function.
        (completion--do-completion): Use it.
        (completions-annotations): New face.
        (completion--insert-strings): Use it.
        (completion-pcm--delim-wild-regex): Add docstring.
        (completion-pcm--string->pattern): Add support for 0-width delimiters
        in completion-pcm--delim-wild-regex.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.15963&r2=1.15964
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/minibuffer.el?cvsroot=emacs&r1=1.78&r2=1.79

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.15963
retrieving revision 1.15964
diff -u -b -r1.15963 -r1.15964
--- ChangeLog   18 Aug 2009 19:17:22 -0000      1.15963
+++ ChangeLog   19 Aug 2009 02:15:19 -0000      1.15964
@@ -1,3 +1,13 @@
+2009-08-19  Stefan Monnier  <address@hidden>
+
+       * minibuffer.el (minibuffer-hide-completions): New function.
+       (completion--do-completion): Use it.
+       (completions-annotations): New face.
+       (completion--insert-strings): Use it.
+       (completion-pcm--delim-wild-regex): Add docstring.
+       (completion-pcm--string->pattern): Add support for 0-width delimiters
+       in completion-pcm--delim-wild-regex.
+
 2009-08-18  Stefan Monnier  <address@hidden>
 
        * international/ucs-normalize.el 
(ucs-normalize-hfs-nfd-post-read-conversion):

Index: minibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- minibuffer.el       18 Aug 2009 19:11:46 -0000      1.78
+++ minibuffer.el       19 Aug 2009 02:15:21 -0000      1.79
@@ -388,8 +388,10 @@
                        (- (point) beg))))
     (cond
      ((null comp)
+      (minibuffer-hide-completions)
       (ding) (minibuffer-message "No match") (minibuffer--bitset nil nil nil))
      ((eq t comp)
+      (minibuffer-hide-completions)
       (goto-char (field-end))
       (minibuffer--bitset nil nil t)) ;Exact and unique match.
      (t
@@ -422,7 +424,11 @@
           (let ((exact (test-completion completion
                                        minibuffer-completion-table
                                        minibuffer-completion-predicate)))
-            (unless completed
+            (if completed
+                ;; We could also decide to refresh the completions,
+                ;; if they're displayed (and assuming there are
+                ;; completions left).
+                (minibuffer-hide-completions)
               ;; Show the completion table, if requested.
               (cond
                ((not exact)
@@ -431,9 +437,9 @@
                       (t completion-auto-help))
                     (minibuffer-completion-help)
                   (minibuffer-message "Next char not unique")))
-               ;; If the last exact completion and this one were the same,
-               ;; it means we've already given a "Complete but not unique"
-               ;; message and the user's hit TAB again, so now we give him 
help.
+               ;; If the last exact completion and this one were the same, it
+               ;; means we've already given a "Next char not unique" message
+               ;; and the user's hit TAB again, so now we give him help.
                ((eq this-command last-command)
                 (if completion-auto-help (minibuffer-completion-help)))))
 
@@ -701,6 +707,9 @@
            t)
     (t     t)))
 
+(defface completions-annotations '((t :inherit italic))
+  "Face to use for annotations in the *Completions* buffer.")
+
 (defun completion--insert-strings (strings)
   "Insert a list of STRINGS into the current buffer.
 Uses columns to keep the listing readable but compact.
@@ -752,8 +761,9 @@
                                    'mouse-face 'highlight)
               (put-text-property (point) (progn (insert (car str)) (point))
                                  'mouse-face 'highlight)
-              (put-text-property (point) (progn (insert (cadr str)) (point))
-                                 'mouse-face nil))
+              (add-text-properties (point) (progn (insert (cadr str)) (point))
+                                   '(mouse-face nil
+                                     face completions-annotations)))
             ;; Next column to align to.
             (setq column (+ column
                             ;; Round up to a whole number of columns.
@@ -898,6 +908,13 @@
        (if completions "Sole completion" "No completions")))
     nil))
 
+(defun minibuffer-hide-completions ()
+  "Get rid of an out-of-date *Completions* buffer."
+  ;; FIXME: We could/should use minibuffer-scroll-window here, but it
+  ;; can also point to the minibuffer-parent-window, so it's a bit tricky.
+  (let ((win (get-buffer-window "*Completions*" 0)))
+    (if win (with-selected-window win (bury-buffer)))))
+
 (defun exit-minibuffer ()
   "Terminate this minibuffer argument."
   (interactive)
@@ -1351,7 +1368,13 @@
 
 ;;; Partial-completion-mode style completion.
 
-(defvar completion-pcm--delim-wild-regex nil)
+(defvar completion-pcm--delim-wild-regex nil
+  "Regular expression matching delimiters controlling the partial-completion.
+Typically, this regular expression simply matches a delimiter, meaning
+that completion can add something at (match-beginning 0), but if it has
+a submatch 1, then completion can add something at (match-end 1).
+This is used when the delimiter needs to be of size zero (e.g. the transition
+from lowercase to uppercase characters).")
 
 (defun completion-pcm--prepare-delim-re (delims)
   (setq completion-pcm--delim-wild-regex (concat "[" delims "*]")))
@@ -1395,13 +1418,20 @@
           (p 0)
           (p0 0))
 
-      (while (and (setq p (string-match-p completion-pcm--delim-wild-regex
+      (while (and (setq p (string-match completion-pcm--delim-wild-regex
                                           string p))
                   ;; If the char was added by minibuffer-complete-word, then
                   ;; don't treat it as a delimiter, otherwise "M-x SPC"
                   ;; ends up inserting a "-" rather than listing
                   ;; all completions.
                   (not (get-text-property p 'completion-try-word string)))
+        ;; Usually, completion-pcm--delim-wild-regex matches a delimiter,
+        ;; meaning that something can be added *before* it, but it can also
+        ;; match a prefix and postfix, in which case something can be added
+        ;; in-between (e.g. match [[:lower:]][[:upper:]]).
+        ;; This is determined by the presence of a submatch-1 which delimits
+        ;; the prefix.
+        (if (match-end 1) (setq p (match-end 1)))
         (push (substring string p0 p) pattern)
         (if (eq (aref string p) ?*)
             (progn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]