emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100205: * minibuffer.el (completion-


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100205: * minibuffer.el (completion-pcm-complete-word-inserts-delimiters):
Date: Sun, 09 May 2010 18:39:36 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100205
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2010-05-09 18:39:36 -0400
message:
  * minibuffer.el (completion-pcm-complete-word-inserts-delimiters):
  New custom variable.
  (completion-pcm--string->pattern): Use it.
  (completion-pcm--pattern->regex, completion-pcm--pattern->string):
  Make it handle any symbol as `any'.
  (completion-pcm--merge-completions): Extract common suffix for the new
  `prefix' symbol as well.
  (completion-substring--all-completions): Use the new `prefix' symbol.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/minibuffer.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2010-05-07 17:04:15 +0000
+++ b/etc/NEWS  2010-05-09 22:39:36 +0000
@@ -123,8 +123,9 @@
 The reason is that this interferes with cua-mode.
 
 ** partial-completion-mode is now obsolete.
-You can get the same behavior with
-(setq completion-styles '(partial-completion initials)).
+You can get a comparable behavior with:
+(setq completion-styles '(partial-completion initials))
+(setq completion-pcm-complete-word-inserts-delimiters t)
 
 ** mpc.el: Can use pseudo tags of the form tag1|tag2 as a union of two tags.
 ** Customize

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-05-09 19:57:55 +0000
+++ b/lisp/ChangeLog    2010-05-09 22:39:36 +0000
@@ -1,3 +1,14 @@
+2010-05-09  Stefan Monnier  <address@hidden>
+
+       * minibuffer.el (completion-pcm-complete-word-inserts-delimiters):
+       New custom variable.
+       (completion-pcm--string->pattern): Use it.
+       (completion-pcm--pattern->regex, completion-pcm--pattern->string):
+       Make it handle any symbol as `any'.
+       (completion-pcm--merge-completions): Extract common suffix for the new
+       `prefix' symbol as well.
+       (completion-substring--all-completions): Use the new `prefix' symbol.
+
 2010-05-09  Michael Albinus  <address@hidden>
 
        * net/tramp-compat.el (byte-compile-not-obsolete-vars): Define if

=== modified file 'lisp/minibuffer.el'
--- a/lisp/minibuffer.el        2010-05-08 18:47:07 +0000
+++ b/lisp/minibuffer.el        2010-05-09 22:39:36 +0000
@@ -1769,6 +1769,14 @@
   :group 'minibuffer
   :type 'string)
 
+(defcustom completion-pcm-complete-word-inserts-delimiters nil
+  "Treat the SPC or - inserted by `minibuffer-complete-word' as delimiters.
+Those chars are treated as delimiters iff this variable is non-nil.
+I.e. if non-nil, M-x SPC will just insert a \"-\" in the minibuffer, whereas
+if nil, it will list all possible commands in *Completions* because none of
+the commands start with a \"-\" or a SPC."
+  :type 'boolean)
+
 (defun completion-pcm--pattern-trivial-p (pattern)
   (and (stringp (car pattern))
        ;; It can be followed by `point' and "" and still be trivial.
@@ -1781,7 +1789,7 @@
 (defun completion-pcm--string->pattern (string &optional point)
   "Split STRING into a pattern.
 A pattern is a list where each element is either a string
-or a symbol chosen among `any', `star', `point'."
+or a symbol chosen among `any', `star', `point', `prefix'."
   (if (and point (< point (length string)))
       (let ((prefix (substring string 0 point))
             (suffix (substring string point)))
@@ -1794,11 +1802,12 @@
 
       (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)))
+                  (or completion-pcm-complete-word-inserts-delimiters
+                      ;; 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
@@ -1824,11 +1833,10 @@
          (concat "\\`"
                  (mapconcat
                   (lambda (x)
-                    (case x
-                      ((star any point)
-                       (if (if (consp group) (memq x group) group)
-                           "\\(.*?\\)" ".*?"))
-                      (t (regexp-quote x))))
+                    (cond
+                     ((stringp x) (regexp-quote x))
+                     ((if (consp group) (memq x group) group)
+                      "\\(.*?\\)" ".*?")))
                   pattern
                   ""))))
     ;; Avoid pathological backtracking.
@@ -2057,9 +2065,9 @@
                 ;; here any more.
                 (unless unique
                   (push elem res)
-                  (when (memq elem '(star point))
+                  (when (memq elem '(star point prefix))
                     ;; Extract common suffix additionally to common prefix.
-                    ;; Only do it for `point' and `star' since for
+                    ;; Only do it for `point', `star', and `prefix' since for
                     ;; `any' it could lead to a merged completion that
                     ;; doesn't itself match the candidates.
                     (let ((suffix (completion--common-suffix comps)))
@@ -2074,8 +2082,7 @@
   (mapconcat (lambda (x) (cond
                      ((stringp x) x)
                      ((eq x 'star) "*")
-                     ((eq x 'any) "")
-                     ((eq x 'point) "")))
+                     (t "")))           ;any, point, prefix.
              pattern
              ""))
 
@@ -2117,6 +2124,7 @@
              (pointpat (or (memq 'point mergedpat)
                            (memq 'any   mergedpat)
                            (memq 'star  mergedpat)
+                           ;; Not `prefix'.
                           mergedpat))
              ;; New pos from the start.
              (newpos (length (completion-pcm--pattern->string pointpat)))
@@ -2147,7 +2155,7 @@
                          beforepoint afterpoint bounds))
          (pattern (if (not (stringp (car basic-pattern)))
                       basic-pattern
-                    (cons 'any basic-pattern)))
+                    (cons 'prefix basic-pattern)))
          (all (completion-pcm--all-completions prefix pattern table pred)))
     (list all pattern prefix suffix (car bounds))))
 


reply via email to

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