aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2012-04-25 15:00:18 -0400
committerStefan Monnier2012-04-25 15:00:18 -0400
commitdd2ac746d4867e3f2f3ed730a096d310d6ca98e9 (patch)
treea216e1580bfcca316ec16156db20525b42ef539f
parent784e7d6eebb4ac47d1f7b4e724b7aa843bc02f81 (diff)
parentcc356a5d470c0b9b0cb7034c8b25a729a38d58a1 (diff)
downloademacs-dd2ac746d4867e3f2f3ed730a096d310d6ca98e9.tar.gz
emacs-dd2ac746d4867e3f2f3ed730a096d310d6ca98e9.zip
Add support for completion of quoted/escaped data.
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/ChangeLog94
-rw-r--r--lisp/comint.el160
-rw-r--r--lisp/ffap.el14
-rw-r--r--lisp/mh-e/ChangeLog240
-rw-r--r--lisp/mh-e/mh-utils.el3
-rw-r--r--lisp/minibuffer.el367
-rw-r--r--lisp/pcmpl-unix.el4
-rw-r--r--lisp/pcomplete.el145
9 files changed, 595 insertions, 440 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 3e296702065..254e774a65e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -169,6 +169,14 @@ still be supported for Emacs 24.x.
169 169
170 170
171* Lisp changes in Emacs 24.2 171* Lisp changes in Emacs 24.2
172
173** Completion
174
175*** New function `completion-table-with-quoting' to handle completion
176in the presence of quoting, such as file completion in shell buffers.
177
178*** New function `completion-table-subvert' to use an existing completion
179table, but with a different prefix.
172 180
173* Changes in Emacs 24.2 on non-free operating systems 181* Changes in Emacs 24.2 on non-free operating systems
174 182
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 55df33b4d30..eb09afc0b55 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,7 +1,44 @@
12012-04-25 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * ffap.el: Remove old code for obsolete package.
4 (ffap-complete-as-file-p): Remove.
5
6 Use completion-table-with-quoting for comint and pcomplete.
7 * comint.el (comint--unquote&requote-argument)
8 (comint--unquote-argument, comint--requote-argument): New functions.
9 (comint--unquote&expand-filename, comint-unquote-filename): Obsolete.
10 (comint-quote-filename): Use regexp-opt-charset.
11 (comint--common-suffix, comint--common-quoted-suffix)
12 (comint--table-subvert): Remove.
13 (comint-unquote-function, comint-requote-function): New vars.
14 (comint--complete-file-name-data): Use them with
15 completion-table-with-quoting.
16 * pcmpl-unix.el (pcomplete/scp): Use completion-table-subvert.
17 * pcomplete.el (pcomplete-arg-quote-list)
18 (pcomplete-quote-arg-hook, pcomplete-quote-argument): Obsolete.
19 (pcomplete-unquote-argument-function): Default to non-nil.
20 (pcomplete-unquote-argument): Simplify.
21 (pcomplete--common-quoted-suffix): Remove.
22 (pcomplete-requote-argument-function): New var.
23 (pcomplete--common-suffix): New function.
24 (pcomplete-completions-at-point): Use completion-table-with-quoting
25 and completion-table-subvert.
26
27 * minibuffer.el: Use completion-table-with-quoting for read-file-name.
28 (minibuffer--double-dollars): Preserve properties.
29 (completion--sifn-requote): New function.
30 (completion--file-name-table): Rewrite using it and c-t-with-quoting.
31
32 * minibuffer.el: Add support for completion of quoted/escaped data.
33 (completion-table-with-quoting, completion-table-subvert): New funs.
34 (completion--twq-try, completion--twq-all): New functions.
35 (completion--nth-completion): New function.
36 (completion-try-completion, completion-all-completions): Use it.
37
12012-04-25 Leo Liu <sdl.web@gmail.com> 382012-04-25 Leo Liu <sdl.web@gmail.com>
2 39
3 * progmodes/python.el (python-pdbtrack-get-source-buffer): Use 40 * progmodes/python.el (python-pdbtrack-get-source-buffer):
4 compilation-message if available to find real filename. 41 Use compilation-message if available to find real filename.
5 42
62012-04-25 Chong Yidong <cyd@gnu.org> 432012-04-25 Chong Yidong <cyd@gnu.org>
7 44
@@ -21,32 +58,31 @@
21 58
222012-04-25 Alex Harsanyi <AlexHarsanyi@gmail.com> 592012-04-25 Alex Harsanyi <AlexHarsanyi@gmail.com>
23 60
24 Sync with soap-client repository. Support SOAP simpleType. (Bug#10331) 61 Sync with soap-client repository. Support SOAP simpleType (Bug#10331).
25 62
26 * soap-client.el (soap-resolve-references-for-sequence-type) 63 * soap-client.el (soap-resolve-references-for-sequence-type)
27 (soap-resolve-references-for-array-type): hack to prevent self 64 (soap-resolve-references-for-array-type): Hack to prevent self
28 references, see Bug#9. 65 references, see Bug#9.
29 (soap-parse-envelope): report the contents of the 'detail' node 66 (soap-parse-envelope): Report the contents of the 'detail' node
30 when receiving a fault reply. 67 when receiving a fault reply.
31 (soap-parse-envelope): report the contents of the entire 'detail' 68 (soap-parse-envelope): Report the contents of the entire 'detail' node.
32 node.
33 69
34 * soap-inspect.el (soap-sample-value-for-simple-type) 70 * soap-inspect.el (soap-sample-value-for-simple-type)
35 (soap-inspect-simple-type): new function 71 (soap-inspect-simple-type): New function.
36 72
37 * soap-client.el (soap-simple-type): new struct 73 * soap-client.el (soap-simple-type): New struct.
38 (soap-default-xsd-types, soap-default-soapenc-types) 74 (soap-default-xsd-types, soap-default-soapenc-types)
39 (soap-decode-basic-type, soap-encode-basic-type): support 75 (soap-decode-basic-type, soap-encode-basic-type):
40 unsignedInt and double basic types 76 support unsignedInt and double basic types.
41 (soap-resolve-references-for-simple-type) 77 (soap-resolve-references-for-simple-type)
42 (soap-parse-simple-type, soap-encode-simple-type): new function 78 (soap-parse-simple-type, soap-encode-simple-type): New function.
43 (soap-parse-schema): parse xsd:simpleType declarations 79 (soap-parse-schema): Parse xsd:simpleType declarations.
44 80
45 * soap-client.el (soap-default-xsd-types) 81 * soap-client.el (soap-default-xsd-types)
46 (soap-default-soapenc-types): add integer, byte and anyURI types 82 (soap-default-soapenc-types): Add integer, byte and anyURI types.
47 (soap-parse-complex-type-complex-content): use `soap-wk2l' to find 83 (soap-parse-complex-type-complex-content): Use `soap-wk2l' to find
48 the local name of "soapenc:Array" 84 the local name of "soapenc:Array".
49 (soap-decode-basic-type, soap-encode-basic-type): support encoding 85 (soap-decode-basic-type, soap-encode-basic-type): Support encoding
50 decoding integer, byte and anyURI xsd types. 86 decoding integer, byte and anyURI xsd types.
51 87
522012-04-25 Chong Yidong <cyd@gnu.org> 882012-04-25 Chong Yidong <cyd@gnu.org>
@@ -166,8 +202,8 @@
166 202
167 * ispell.el (ispell-insert-word) Remove unneeded function using 203 * ispell.el (ispell-insert-word) Remove unneeded function using
168 obsolete `translation-table-for-input'. 204 obsolete `translation-table-for-input'.
169 (ispell-word, ispell-process-line, ispell-complete-word): Use 205 (ispell-word, ispell-process-line, ispell-complete-word):
170 plain `insert' instead of removed `ispell-insert-word'. 206 Use plain `insert' instead of removed `ispell-insert-word'.
171 207
1722012-04-22 Chong Yidong <cyd@gnu.org> 2082012-04-22 Chong Yidong <cyd@gnu.org>
173 209
@@ -185,8 +221,8 @@
185 Move functions from C to Lisp. Make non-blocking method calls 221 Move functions from C to Lisp. Make non-blocking method calls
186 the default. Implement further D-Bus standard interfaces. 222 the default. Implement further D-Bus standard interfaces.
187 223
188 * net/dbus.el (dbus-message-internal): Declare function. Remove 224 * net/dbus.el (dbus-message-internal): Declare function.
189 unneeded function declarations. 225 Remove unneeded function declarations.
190 (defvar dbus-message-type-invalid, dbus-message-type-method-call) 226 (defvar dbus-message-type-invalid, dbus-message-type-method-call)
191 (dbus-message-type-method-return, dbus-message-type-error) 227 (dbus-message-type-method-return, dbus-message-type-error)
192 (dbus-message-type-signal): Declare variables. Remove local 228 (dbus-message-type-signal): Declare variables. Remove local
@@ -202,8 +238,8 @@
202 (dbus-register-signal, dbus-register-method): New defuns, moved 238 (dbus-register-signal, dbus-register-method): New defuns, moved
203 from dbusbind.c 239 from dbusbind.c
204 (dbus-call-method-handler, dbus-setenv) 240 (dbus-call-method-handler, dbus-setenv)
205 (dbus-get-all-managed-objects, dbus-managed-objects-handler): New 241 (dbus-get-all-managed-objects, dbus-managed-objects-handler):
206 defuns. 242 New defuns.
207 (dbus-call-method-non-blocking): Make it an obsolete function. 243 (dbus-call-method-non-blocking): Make it an obsolete function.
208 (dbus-unregister-object, dbus-unregister-service) 244 (dbus-unregister-object, dbus-unregister-service)
209 (dbus-handle-event, dbus-register-property) 245 (dbus-handle-event, dbus-register-property)
@@ -328,8 +364,8 @@
328 364
3292012-04-20 Chong Yidong <cyd@gnu.org> 3652012-04-20 Chong Yidong <cyd@gnu.org>
330 366
331 * progmodes/gdb-mi.el (gdb-inferior-io--maybe-delete-pty): New 367 * progmodes/gdb-mi.el (gdb-inferior-io--maybe-delete-pty):
332 function to call delete-process on the gdb-inferior buffer's pty. 368 New function to call delete-process on the gdb-inferior buffer's pty.
333 (gdb-reset): Use it, instead of relying on kill-buffer to kill the 369 (gdb-reset): Use it, instead of relying on kill-buffer to kill the
334 pty process (Bug#11273). 370 pty process (Bug#11273).
335 (gdb-update): New arg to suppress talking to the gdb process. 371 (gdb-update): New arg to suppress talking to the gdb process.
@@ -360,8 +396,8 @@
360 (c-comment-indent, c-scan-conditionals, c-indent-defun) 396 (c-comment-indent, c-scan-conditionals, c-indent-defun)
361 (c-context-line-break): Bind case-fold-search to nil. 397 (c-context-line-break): Bind case-fold-search to nil.
362 398
363 * progmodes/cc-mode.el (c-font-lock-fontify-region): Bind 399 * progmodes/cc-mode.el (c-font-lock-fontify-region):
364 case-fold-search to nil. 400 Bind case-fold-search to nil.
365 401
3662012-04-20 Chong Yidong <cyd@gnu.org> 4022012-04-20 Chong Yidong <cyd@gnu.org>
367 403
@@ -1112,8 +1148,8 @@
1112 1148
11132012-03-30 Agustín Martín Domingo <agustin.martin@hispalinux.es> 11492012-03-30 Agustín Martín Domingo <agustin.martin@hispalinux.es>
1114 1150
1115 * ispell.el (ispell-get-extended-character-mode): Disable 1151 * ispell.el (ispell-get-extended-character-mode):
1116 extended-char-mode for hunspell. hunspell does not support it 1152 Disable extended-char-mode for hunspell. hunspell does not support it
1117 and treats ~word as ordinary words in pipe mode. 1153 and treats ~word as ordinary words in pipe mode.
1118 1154
11192012-03-30 Glenn Morris <rgm@gnu.org> 11552012-03-30 Glenn Morris <rgm@gnu.org>
diff --git a/lisp/comint.el b/lisp/comint.el
index 10981675971..2f8d7bd850c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -104,6 +104,7 @@
104(eval-when-compile (require 'cl)) 104(eval-when-compile (require 'cl))
105(require 'ring) 105(require 'ring)
106(require 'ansi-color) 106(require 'ansi-color)
107(require 'regexp-opt) ;For regexp-opt-charset.
107 108
108;; Buffer Local Variables: 109;; Buffer Local Variables:
109;;============================================================================ 110;;============================================================================
@@ -3000,26 +3001,62 @@ interpreter (e.g., the percent notation of cmd.exe on Windows)."
3000See `comint-word'." 3001See `comint-word'."
3001 (comint-word comint-file-name-chars)) 3002 (comint-word comint-file-name-chars))
3002 3003
3003(defun comint--unquote&expand-filename (filename) 3004(defun comint--unquote&requote-argument (qstr &optional upos)
3004 ;; FIXME: The code below does unquote-then-expand which means that "\\$HOME" 3005 (unless upos (setq upos 0))
3005 ;; gets expanded to the same as "$HOME" 3006 (let* ((qpos 0)
3006 (comint-substitute-in-file-name 3007 (dquotes nil)
3007 (comint-unquote-filename filename))) 3008 (ustrs '())
3009 (re (concat
3010 "[\"']\\|\\\\\\(.\\)"
3011 "\\|\\$\\(?:\\([[:alpha:]][[:alnum:]]*\\)"
3012 "\\|{\\(?2:[^{}]+\\)}\\)"
3013 (when (memq system-type '(ms-dos windows-nt))
3014 "\\|%\\(?2:[^\\\\/]*\\)%")))
3015 (qupos nil)
3016 (push (lambda (str end)
3017 (push str ustrs)
3018 (setq upos (- upos (length str)))
3019 (unless (or qupos (> upos 0))
3020 (setq qupos (if (< end 0) (- end) (+ upos end))))))
3021 match)
3022 (while (setq match (string-match re qstr qpos))
3023 (funcall push (substring qstr qpos match) match)
3024 (cond
3025 ((match-beginning 1) (funcall push (match-string 1 qstr) (match-end 0)))
3026 ((match-beginning 2) (funcall push (getenv (match-string 2 qstr))
3027 (- (match-end 0))))
3028 ((eq (aref qstr match) ?\") (setq dquotes (not dquotes)))
3029 ((eq (aref qstr match) ?\')
3030 (cond
3031 (dquotes (funcall push "'" (match-end 0)))
3032 ((< match (1+ (length qstr)))
3033 (let ((end (string-match "'" qstr (1+ match))))
3034 (funcall push (substring qstr (1+ match) end)
3035 (or end (length qstr)))))
3036 (t nil)))
3037 (t (error "Unexpected case in comint--unquote&requote-argument!")))
3038 (setq qpos (match-end 0)))
3039 (funcall push (substring qstr qpos) (length qstr))
3040 (list (mapconcat #'identity (nreverse ustrs) "")
3041 qupos #'comint-quote-filename)))
3042
3043(defun comint--unquote-argument (str)
3044 (car (comint--unquote&requote-argument str)))
3045(define-obsolete-function-alias 'comint--unquote&expand-filename
3046 #'comint--unquote-argument "24.2")
3008 3047
3009(defun comint-match-partial-filename () 3048(defun comint-match-partial-filename ()
3010 "Return the unquoted&expanded filename at point, or nil if none is found. 3049 "Return the unquoted&expanded filename at point, or nil if none is found.
3011Environment variables are substituted. See `comint-word'." 3050Environment variables are substituted. See `comint-word'."
3012 (let ((filename (comint--match-partial-filename))) 3051 (let ((filename (comint--match-partial-filename)))
3013 (and filename (comint--unquote&expand-filename filename)))) 3052 (and filename (comint--unquote-argument filename))))
3014 3053
3015(defun comint-quote-filename (filename) 3054(defun comint-quote-filename (filename)
3016 "Return FILENAME with magic characters quoted. 3055 "Return FILENAME with magic characters quoted.
3017Magic characters are those in `comint-file-name-quote-list'." 3056Magic characters are those in `comint-file-name-quote-list'."
3018 (if (null comint-file-name-quote-list) 3057 (if (null comint-file-name-quote-list)
3019 filename 3058 filename
3020 (let ((regexp 3059 (let ((regexp (regexp-opt-charset comint-file-name-quote-list)))
3021 (format "[%s]"
3022 (mapconcat 'char-to-string comint-file-name-quote-list ""))))
3023 (save-match-data 3060 (save-match-data
3024 (let ((i 0)) 3061 (let ((i 0))
3025 (while (string-match regexp filename i) 3062 (while (string-match regexp filename i)
@@ -3033,6 +3070,12 @@ Magic characters are those in `comint-file-name-quote-list'."
3033 filename 3070 filename
3034 (save-match-data 3071 (save-match-data
3035 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t)))) 3072 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t))))
3073(make-obsolete 'comint-unquote-filename nil "24.2")
3074
3075(defun comint--requote-argument (upos qstr)
3076 ;; See `completion-table-with-quoting'.
3077 (let ((res (comint--unquote&requote-argument qstr upos)))
3078 (cons (nth 1 res) (nth 2 res))))
3036 3079
3037(defun comint-completion-at-point () 3080(defun comint-completion-at-point ()
3038 (run-hook-with-args-until-success 'comint-dynamic-complete-functions)) 3081 (run-hook-with-args-until-success 'comint-dynamic-complete-functions))
@@ -3066,87 +3109,6 @@ Returns t if successful."
3066 (when (comint--match-partial-filename) 3109 (when (comint--match-partial-filename)
3067 (comint--complete-file-name-data))) 3110 (comint--complete-file-name-data)))
3068 3111
3069;; FIXME: comint--common-suffix, comint--common-quoted-suffix, and
3070;; comint--table-subvert don't fully solve the problem, since
3071;; selecting a file from *Completions* won't quote it, among several
3072;; other problems.
3073
3074(defun comint--common-suffix (s1 s2)
3075 (assert (not (or (string-match "\n" s1) (string-match "\n" s2))))
3076 ;; Since S2 is expected to be the "unquoted/expanded" version of S1,
3077 ;; there shouldn't be any case difference, even if the completion is
3078 ;; case-insensitive.
3079 (let ((case-fold-search nil))
3080 (string-match ".*?\\(.*\\)\n.*\\1\\'" (concat s1 "\n" s2))
3081 (- (match-end 1) (match-beginning 1))))
3082
3083(defun comint--common-quoted-suffix (s1 s2)
3084 ;; FIXME: Copied in pcomplete.el.
3085 "Find the common suffix between S1 and S2 where S1 is the expanded S2.
3086S1 is expected to be the unquoted and expanded version of S2.
3087Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
3088S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and
3089SS1 = (unquote SS2)."
3090 (let* ((cs (comint--common-suffix s1 s2))
3091 (ss1 (substring s1 (- (length s1) cs)))
3092 (qss1 (comint-quote-filename ss1))
3093 qc s2b)
3094 (if (and (not (equal ss1 qss1))
3095 (setq qc (comint-quote-filename (substring ss1 0 1)))
3096 (setq s2b (- (length s2) cs (length qc) -1))
3097 (>= s2b 0) ;bug#11158.
3098 (eq t (compare-strings s2 s2b (- (length s2) cs -1)
3099 qc nil nil)))
3100 ;; The difference found is just that one char is quoted in S2
3101 ;; but not in S1, keep looking before this difference.
3102 (comint--common-quoted-suffix
3103 (substring s1 0 (- (length s1) cs))
3104 (substring s2 0 s2b))
3105 (cons (substring s1 0 (- (length s1) cs))
3106 (substring s2 0 (- (length s2) cs))))))
3107
3108(defun comint--table-subvert (table s1 s2 &optional quote-fun unquote-fun)
3109 "Completion table that replaces the prefix S1 with S2 in STRING.
3110The result is a completion table which completes strings of the
3111form (concat S1 S) in the same way as TABLE completes strings of
3112the form (concat S2 S)."
3113 (lambda (string pred action)
3114 (let* ((str (if (eq t (compare-strings string 0 (length s1) s1 nil nil
3115 completion-ignore-case))
3116 (let ((rest (substring string (length s1))))
3117 (concat s2 (if unquote-fun
3118 (funcall unquote-fun rest) rest)))))
3119 (res (if str (complete-with-action action table str pred))))
3120 (when res
3121 (cond
3122 ((and (eq (car-safe action) 'boundaries))
3123 (let ((beg (or (and (eq (car-safe res) 'boundaries) (cadr res)) 0)))
3124 (list* 'boundaries
3125 (max (length s1)
3126 ;; FIXME: Adjust because of quoting/unquoting.
3127 (+ beg (- (length s1) (length s2))))
3128 (and (eq (car-safe res) 'boundaries) (cddr res)))))
3129 ((stringp res)
3130 (if (eq t (compare-strings res 0 (length s2) s2 nil nil
3131 completion-ignore-case))
3132 (let ((rest (substring res (length s2))))
3133 (concat s1 (if quote-fun (funcall quote-fun rest) rest)))))
3134 ((eq action t)
3135 (let ((bounds (completion-boundaries str table pred "")))
3136 (if (>= (car bounds) (length s2))
3137 (if quote-fun (mapcar quote-fun res) res)
3138 (let ((re (concat "\\`"
3139 (regexp-quote (substring s2 (car bounds))))))
3140 (delq nil
3141 (mapcar (lambda (c)
3142 (if (string-match re c)
3143 (let ((str (substring c (match-end 0))))
3144 (if quote-fun
3145 (funcall quote-fun str) str))))
3146 res))))))
3147 ;; E.g. action=nil and it's the only completion.
3148 (res))))))
3149
3150(defun comint-completion-file-name-table (string pred action) 3112(defun comint-completion-file-name-table (string pred action)
3151 (if (not (file-name-absolute-p string)) 3113 (if (not (file-name-absolute-p string))
3152 (completion-file-name-table string pred action) 3114 (completion-file-name-table string pred action)
@@ -3165,6 +3127,13 @@ the form (concat S2 S)."
3165 res))) 3127 res)))
3166 (t (completion-file-name-table string pred action))))) 3128 (t (completion-file-name-table string pred action)))))
3167 3129
3130(defvar comint-unquote-function #'comint--unquote-argument
3131 "Function to use for completion of quoted data.
3132See `completion-table-with-quoting' and `comint-requote-function'.")
3133(defvar comint-requote-function #'comint--requote-argument
3134 "Function to use for completion of quoted data.
3135See `completion-table-with-quoting' and `comint-requote-function'.")
3136
3168(defun comint--complete-file-name-data () 3137(defun comint--complete-file-name-data ()
3169 "Return the completion data for file name at point." 3138 "Return the completion data for file name at point."
3170 (let* ((filesuffix (cond ((not comint-completion-addsuffix) "") 3139 (let* ((filesuffix (cond ((not comint-completion-addsuffix) "")
@@ -3175,14 +3144,11 @@ the form (concat S2 S)."
3175 (filename (comint--match-partial-filename)) 3144 (filename (comint--match-partial-filename))
3176 (filename-beg (if filename (match-beginning 0) (point))) 3145 (filename-beg (if filename (match-beginning 0) (point)))
3177 (filename-end (if filename (match-end 0) (point))) 3146 (filename-end (if filename (match-end 0) (point)))
3178 (unquoted (if filename (comint--unquote&expand-filename filename) ""))
3179 (table 3147 (table
3180 (let ((prefixes (comint--common-quoted-suffix 3148 (completion-table-with-quoting
3181 unquoted filename))) 3149 #'comint-completion-file-name-table
3182 (comint--table-subvert 3150 comint-unquote-function
3183 #'comint-completion-file-name-table 3151 comint-requote-function)))
3184 (cdr prefixes) (car prefixes)
3185 #'comint-quote-filename #'comint-unquote-filename))))
3186 (nconc 3152 (nconc
3187 (list 3153 (list
3188 filename-beg filename-end 3154 filename-beg filename-end
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 52ffc9905ed..7ab6a75406d 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1340,20 +1340,6 @@ which may actually result in an URL rather than a filename."
1340;; We must inform complete about whether our completion function 1340;; We must inform complete about whether our completion function
1341;; will do filename style completion. 1341;; will do filename style completion.
1342 1342
1343(defun ffap-complete-as-file-p ()
1344 ;; Will `minibuffer-completion-table' complete the minibuffer
1345 ;; contents as a filename? Assumes the minibuffer is current.
1346 ;; Note: t and non-nil mean somewhat different reasons.
1347 (if (eq minibuffer-completion-table 'ffap-read-file-or-url-internal)
1348 (not (ffap-url-p (buffer-string))) ; t
1349 (and minibuffer-completing-file-name '(t)))) ;list
1350
1351(and
1352 (featurep 'complete)
1353 (if (boundp 'PC-completion-as-file-name-predicate)
1354 ;; modern version of complete.el, just set the variable:
1355 (setq PC-completion-as-file-name-predicate 'ffap-complete-as-file-p)))
1356
1357 1343
1358;;; Highlighting (`ffap-highlight'): 1344;;; Highlighting (`ffap-highlight'):
1359;; 1345;;
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog
index f98b4a7490e..6eedef1980e 100644
--- a/lisp/mh-e/ChangeLog
+++ b/lisp/mh-e/ChangeLog
@@ -1,3 +1,7 @@
12012-04-25 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * mh-utils.el (minibuffer-completing-file-name): Don't declare, unused.
4
12012-04-21 Juanma Barranquero <lekktu@gmail.com> 52012-04-21 Juanma Barranquero <lekktu@gmail.com>
2 6
3 * mh-folder.el (top): Check whether which-func-modes is t before 7 * mh-folder.el (top): Check whether which-func-modes is t before
@@ -179,8 +183,8 @@
179 183
180 * mh-mime.el (mh-decode-message-subject): New function to decode 184 * mh-mime.el (mh-decode-message-subject): New function to decode
181 RFC2047 encoded Subject lines. Used for reply drafts. 185 RFC2047 encoded Subject lines. Used for reply drafts.
182 * mh-comp.el (mh-compose-and-send-mail): Call 186 * mh-comp.el (mh-compose-and-send-mail):
183 `mh-decode-message-subject' on (reply or forward) message drafts. 187 Call `mh-decode-message-subject' on (reply or forward) message drafts.
184 188
1852010-05-07 Chong Yidong <cyd@stupidchicken.com> 1892010-05-07 Chong Yidong <cyd@stupidchicken.com>
186 190
@@ -353,8 +357,8 @@
353 * mh-show.el (mh-show-preferred-alternative) 357 * mh-show.el (mh-show-preferred-alternative)
354 * mh-e.el (mh-annotate-msg-hook): Sync docstring with manual. 358 * mh-e.el (mh-annotate-msg-hook): Sync docstring with manual.
355 359
356 * mh-comp.el (mh-send-letter, mh-redistribute): Mention 360 * mh-comp.el (mh-send-letter, mh-redistribute):
357 mh-annotate-msg-hook in docstring. 361 Mention mh-annotate-msg-hook in docstring.
358 362
3592008-06-29 Jeffrey C Honig <jch@honig.net> 3632008-06-29 Jeffrey C Honig <jch@honig.net>
360 364
@@ -404,8 +408,8 @@
404 408
4052008-05-23 Bill Wohler <wohler@newt.com> 4092008-05-23 Bill Wohler <wohler@newt.com>
406 410
407 * mh-e.el (mh-invisible-header-fields-internal): Remove 411 * mh-e.el (mh-invisible-header-fields-internal):
408 DKIM-Signature as it is covered by DKIM-. Fully qualify X-EID. 412 Remove DKIM-Signature as it is covered by DKIM-. Fully qualify X-EID.
409 413
4102008-05-19 Sergey Poznyakoff <gray@gnu.org.ua> 4142008-05-19 Sergey Poznyakoff <gray@gnu.org.ua>
411 415
@@ -488,8 +492,8 @@
488 492
4892007-08-21 Jeffrey C Honig <jch@honig.net> 4932007-08-21 Jeffrey C Honig <jch@honig.net>
490 494
491 * mh-folder.el (mh-folder-message-menu, mh-folder-mode-map): Add 495 * mh-folder.el (mh-folder-message-menu, mh-folder-mode-map):
492 folder mode support for mh-show-preferred-alternative (closes SF 496 Add folder mode support for mh-show-preferred-alternative (closes SF
493 #1777321). 497 #1777321).
494 498
495 * mh-show.el (mh-show-preferred-alternative) 499 * mh-show.el (mh-show-preferred-alternative)
@@ -500,8 +504,8 @@
500 HTML when text content is lacking (closes SF #1777321). 504 HTML when text content is lacking (closes SF #1777321).
501 505
502 * mh-e.el: 506 * mh-e.el:
503 (mh-invisible-header-fields-internal): Exclude Fax and Phone. Put 507 (mh-invisible-header-fields-internal): Exclude Fax and Phone.
504 known exclusions as comments before the list and move parens to 508 Put known exclusions as comments before the list and move parens to
505 separate lines to aid in sorting (closes SF #1701231). 509 separate lines to aid in sorting (closes SF #1701231).
506 510
507 * mh-mime.el (mm-decode-body): Remove explicit autoload of 511 * mh-mime.el (mm-decode-body): Remove explicit autoload of
@@ -750,16 +754,16 @@
750 (mh-tool-bar-folder-buttons-set, mh-tool-bar-letter-buttons-set): 754 (mh-tool-bar-folder-buttons-set, mh-tool-bar-letter-buttons-set):
751 Call it (closes SF #1452718). 755 Call it (closes SF #1452718).
752 756
753 * mh-folder.el (mh-folder-buttons-init-flag): Delete. Use 757 * mh-folder.el (mh-folder-buttons-init-flag): Delete.
754 mh-folder-tool-bar-map instead. 758 Use mh-folder-tool-bar-map instead.
755 (image-load-path): Delete. No longer used. 759 (image-load-path): Delete. No longer used.
756 (mh-folder-mode): Moved setting of image-load-path into 760 (mh-folder-mode): Move setting of image-load-path into
757 mh-tool-bar-folder-buttons-init. 761 mh-tool-bar-folder-buttons-init.
758 762
759 * mh-letter.el (mh-letter-buttons-init-flag): Delete. Use 763 * mh-letter.el (mh-letter-buttons-init-flag): Delete.
760 mh-letter-tool-bar-map instead. 764 Use mh-letter-tool-bar-map instead.
761 (image-load-path): Delete. No longer used. 765 (image-load-path): Delete. No longer used.
762 (mh-letter-mode): Moved setting of image-load-path into 766 (mh-letter-mode): Move setting of image-load-path into
763 mh-tool-bar-letter-buttons-init. 767 mh-tool-bar-letter-buttons-init.
764 768
765 * mh-seq.el (mh-narrow-to-seq, mh-widen): Use with-current-buffer 769 * mh-seq.el (mh-narrow-to-seq, mh-widen): Use with-current-buffer
@@ -1007,8 +1011,8 @@
1007 (mh-print-background-flag, mh-show-maximum-size) 1011 (mh-print-background-flag, mh-show-maximum-size)
1008 (mh-show-use-xface-flag, mh-store-default-directory) 1012 (mh-show-use-xface-flag, mh-store-default-directory)
1009 (mh-summary-height, mh-speed-update-interval) 1013 (mh-summary-height, mh-speed-update-interval)
1010 (mh-show-threads-flag, mh-tool-bar-search-function): Add 1014 (mh-show-threads-flag, mh-tool-bar-search-function):
1011 :package-version keyword to these options (closes SF #1452724). 1015 Add :package-version keyword to these options (closes SF #1452724).
1012 (mh-after-commands-processed-hook) 1016 (mh-after-commands-processed-hook)
1013 (mh-alias-reloaded-hook, mh-before-commands-processed-hook) 1017 (mh-alias-reloaded-hook, mh-before-commands-processed-hook)
1014 (mh-before-quit-hook, mh-before-send-letter-hook) 1018 (mh-before-quit-hook, mh-before-send-letter-hook)
@@ -1035,15 +1039,15 @@
1035 (mh-speedbar-selected-folder-with-unseen-messages): : Add 1039 (mh-speedbar-selected-folder-with-unseen-messages): : Add
1036 :package-version keyword to these faces (closes SF #1452724). 1040 :package-version keyword to these faces (closes SF #1452724).
1037 1041
1038 * mh-tool-bar.el (mh-tool-bar-define): Added commented-out 1042 * mh-tool-bar.el (mh-tool-bar-define): Add commented-out
1039 :package-version keywords (closes SF #1452724). 1043 :package-version keywords (closes SF #1452724).
1040 1044
10412006-03-28 Bill Wohler <wohler@newt.com> 10452006-03-28 Bill Wohler <wohler@newt.com>
1042 1046
1043 * mh-tool-bar.el: Use clipboard-kill-region, 1047 * mh-tool-bar.el: Use clipboard-kill-region,
1044 clipboard-kill-ring-save, and clipboard-yank instead of undo, 1048 clipboard-kill-ring-save, and clipboard-yank instead of undo,
1045 kill-region, and menu-bar-kill-ring-save respectively. In 1049 kill-region, and menu-bar-kill-ring-save respectively.
1046 MH-Letter mode, move save-buffer and mh-fully-kill-draft icons in 1050 In MH-Letter mode, move save-buffer and mh-fully-kill-draft icons in
1047 front of mh-compose-insertion to be consistent with other mailers, 1051 front of mh-compose-insertion to be consistent with other mailers,
1048 such as Evolution. In MH-Folder mode, move vanilla reply icon to 1052 such as Evolution. In MH-Folder mode, move vanilla reply icon to
1049 the left of the other reply icons. Use mail/inbox icon instead of 1053 the left of the other reply icons. Use mail/inbox icon instead of
@@ -1099,8 +1103,8 @@
1099 1103
11002006-03-14 Bill Wohler <wohler@newt.com> 11042006-03-14 Bill Wohler <wohler@newt.com>
1101 1105
1102 * mh-compat.el (mh-image-load-path-for-library): Incorporate 1106 * mh-compat.el (mh-image-load-path-for-library):
1103 changes from image-load-path-for-library, which are: 1107 Incorporate changes from image-load-path-for-library, which are:
1104 (image-load-path-for-library): Pass value of path rather than 1108 (image-load-path-for-library): Pass value of path rather than
1105 symbol. Always return list of directories. Guarantee that image 1109 symbol. Always return list of directories. Guarantee that image
1106 directory comes first. 1110 directory comes first.
@@ -1126,8 +1130,8 @@
1126 flag to replace-in-string. This was badly needed by 1130 flag to replace-in-string. This was badly needed by
1127 mh-quote-pick-expr in order to properly quote subjects when using 1131 mh-quote-pick-expr in order to properly quote subjects when using
1128 / s on XEmacs (closes SF #1447598). 1132 / s on XEmacs (closes SF #1447598).
1129 (mh-image-load-path-for-library): Merged changes from Reiner. Add 1133 (mh-image-load-path-for-library): Merged changes from Reiner.
1130 no-error argument. If path t, just return directory. 1134 Add no-error argument. If path t, just return directory.
1131 1135
1132 * mh-e.el (mh-profile-component): Drop `s' from mhparam 1136 * mh-e.el (mh-profile-component): Drop `s' from mhparam
1133 -components for Mailutils compatibility (closes SF #1446985). 1137 -components for Mailutils compatibility (closes SF #1446985).
@@ -1185,8 +1189,8 @@
1185 local variable mh-image-directory to image-directory. Move error 1189 local variable mh-image-directory to image-directory. Move error
1186 checks to default case in cond and simplify. 1190 checks to default case in cond and simplify.
1187 1191
1188 * mh-comp.el (mh-send-letter, mh-insert-auto-fields): Sync 1192 * mh-comp.el (mh-send-letter, mh-insert-auto-fields):
1189 docstrings with manual. 1193 Sync docstrings with manual.
1190 1194
11912006-03-02 Bill Wohler <wohler@newt.com> 11952006-03-02 Bill Wohler <wohler@newt.com>
1192 1196
@@ -1212,8 +1216,8 @@
1212 1216
1213 * mh-utils.el (mh-image-directory) 1217 * mh-utils.el (mh-image-directory)
1214 (mh-image-load-path-called-flag): Delete. 1218 (mh-image-load-path-called-flag): Delete.
1215 (mh-image-load-path): Incorporate changes from Gnus team. Biggest 1219 (mh-image-load-path): Incorporate changes from Gnus team.
1216 changes are that it no longer uses/sets mh-image-directory or 1220 Biggest changes are that it no longer uses/sets mh-image-directory or
1217 mh-image-load-path-called-flag, and returns the updated path 1221 mh-image-load-path-called-flag, and returns the updated path
1218 rather than change it. 1222 rather than change it.
1219 (mh-logo-display): Change usage of mh-image-load-path. 1223 (mh-logo-display): Change usage of mh-image-load-path.
@@ -1278,8 +1282,8 @@
1278 goto-addr.el. 1282 goto-addr.el.
1279 (mh-alias-suggest-alias): Use goto-address-mail-regexp instead of 1283 (mh-alias-suggest-alias): Use goto-address-mail-regexp instead of
1280 mh-address-mail-regexp. 1284 mh-address-mail-regexp.
1281 (mh-alias-add-address-under-point): Use 1285 (mh-alias-add-address-under-point):
1282 goto-address-find-address-at-point instead of 1286 Use goto-address-find-address-at-point instead of
1283 mh-goto-address-find-address-at-point. 1287 mh-goto-address-find-address-at-point.
1284 1288
1285 * mh-e.el (mh-show-use-goto-addr-flag): Delete. 1289 * mh-e.el (mh-show-use-goto-addr-flag): Delete.
@@ -1360,7 +1364,7 @@
1360 1364
13612006-02-08 Peter S Galbraith <psg@debian.org> 13652006-02-08 Peter S Galbraith <psg@debian.org>
1362 1366
1363 * mh-e.el (mh-invisible-header-fields-internal): Added entries 1367 * mh-e.el (mh-invisible-header-fields-internal): Add entries
1364 "X-BrightmailFiltered:", "X-Brightmail-Tracker:" and "X-Hashcash". 1368 "X-BrightmailFiltered:", "X-Brightmail-Tracker:" and "X-Hashcash".
1365 1369
13662006-02-04 Bill Wohler <wohler@newt.com> 13702006-02-04 Bill Wohler <wohler@newt.com>
@@ -1429,17 +1433,17 @@
1429 1433
1430 * mh-search.el (which-func-mode): Shush compiler on Emacs 21 too. 1434 * mh-search.el (which-func-mode): Shush compiler on Emacs 21 too.
1431 1435
1432 * mh-alias.el (mh-alias-gecos-name): Use 1436 * mh-alias.el (mh-alias-gecos-name):
1433 mh-replace-regexp-in-string instead of replace-regexp-in-string. 1437 Use mh-replace-regexp-in-string instead of replace-regexp-in-string.
1434 (crm, multi-prompt): Use mh-require instead of require. 1438 (crm, multi-prompt): Use mh-require instead of require.
1435 (mh-goto-address-find-address-at-point): Use 1439 (mh-goto-address-find-address-at-point):
1436 mh-line-beginning-position and mh-line-end-position instead of 1440 Use mh-line-beginning-position and mh-line-end-position instead of
1437 line-beginning-position and line-end-position. Use 1441 line-beginning-position and line-end-position.
1438 mh-match-string-no-properties instead of 1442 Use mh-match-string-no-properties instead of
1439 match-string-no-properties. 1443 match-string-no-properties.
1440 1444
1441 * mh-comp.el (mh-modify-header-field): Use 1445 * mh-comp.el (mh-modify-header-field):
1442 mh-line-beginning-position and mh-line-end-position instead of 1446 Use mh-line-beginning-position and mh-line-end-position instead of
1443 line-beginning-position and line-end-position. 1447 line-beginning-position and line-end-position.
1444 1448
1445 * mh-compat.el (mailabbrev): Use mh-require instead of require. 1449 * mh-compat.el (mailabbrev): Use mh-require instead of require.
@@ -1474,16 +1478,16 @@
1474 mh-line-end-position instead of line-beginning-position and 1478 mh-line-end-position instead of line-beginning-position and
1475 line-end-position. 1479 line-end-position.
1476 1480
1477 * mh-limit.el (mh-subject-to-sequence-unthreaded): Use 1481 * mh-limit.el (mh-subject-to-sequence-unthreaded):
1478 mh-match-string-no-properties instead of 1482 Use mh-match-string-no-properties instead of
1479 match-string-no-properties. 1483 match-string-no-properties.
1480 (mh-narrow-to-header-field): Use mh-line-beginning-position and 1484 (mh-narrow-to-header-field): Use mh-line-beginning-position and
1481 mh-line-end-position instead of line-beginning-position and 1485 mh-line-end-position instead of line-beginning-position and
1482 line-end-position. 1486 line-end-position.
1483 1487
1484 * mh-mime.el (mh-mime-inline-part, mh-mm-display-part) 1488 * mh-mime.el (mh-mime-inline-part, mh-mm-display-part)
1485 (mh-mh-quote-unescaped-sharp, mh-mh-directive-present-p): Use 1489 (mh-mh-quote-unescaped-sharp, mh-mh-directive-present-p):
1486 mh-line-beginning-position and mh-line-end-position instead of 1490 Use mh-line-beginning-position and mh-line-end-position instead of
1487 line-beginning-position and line-end-position. 1491 line-beginning-position and line-end-position.
1488 1492
1489 * mh-search.el (which-func): Use mh-require instead of require. 1493 * mh-search.el (which-func): Use mh-require instead of require.
@@ -1492,8 +1496,8 @@
1492 (mh-mairix-next-result, mh-namazu-next-result) 1496 (mh-mairix-next-result, mh-namazu-next-result)
1493 (mh-pick-next-result, mh-grep-next-result) 1497 (mh-pick-next-result, mh-grep-next-result)
1494 (mh-index-create-imenu-index, mh-index-match-checksum) 1498 (mh-index-create-imenu-index, mh-index-match-checksum)
1495 (mh-md5sum-parser, mh-openssl-parser, mh-index-update-maps): Use 1499 (mh-md5sum-parser, mh-openssl-parser, mh-index-update-maps):
1496 mh-line-beginning-position and mh-line-end-position instead of 1500 Use mh-line-beginning-position and mh-line-end-position instead of
1497 line-beginning-position and line-end-position. 1501 line-beginning-position and line-end-position.
1498 1502
1499 * mh-seq.el (mh-list-sequences): Use mh-view-mode-enter instead of 1503 * mh-seq.el (mh-list-sequences): Use mh-view-mode-enter instead of
@@ -1516,8 +1520,8 @@
1516 (mh-speed-flists): Use mh-cancel-timer instead of cancel-timer. 1520 (mh-speed-flists): Use mh-cancel-timer instead of cancel-timer.
1517 1521
1518 * mh-thread.el (mh-thread-find-children) 1522 * mh-thread.el (mh-thread-find-children)
1519 (mh-thread-parse-scan-line, mh-thread-generate): Use 1523 (mh-thread-parse-scan-line, mh-thread-generate):
1520 mh-line-beginning-position and mh-line-end-position instead of 1524 Use mh-line-beginning-position and mh-line-end-position instead of
1521 line-beginning-position and line-end-position. 1525 line-beginning-position and line-end-position.
1522 1526
1523 * mh-utils.el (mh-colors-available-p): Use mh-display-color-cells 1527 * mh-utils.el (mh-colors-available-p): Use mh-display-color-cells
@@ -1738,8 +1742,8 @@
1738 (mh-letter-header-field-regexp, mh-pgp-support-flag) 1742 (mh-letter-header-field-regexp, mh-pgp-support-flag)
1739 (mh-x-mailer-string): Move here from mh-comp.el. 1743 (mh-x-mailer-string): Move here from mh-comp.el.
1740 (mh-folder-line-matches-show-buffer-p): Move to mh-alias.el. 1744 (mh-folder-line-matches-show-buffer-p): Move to mh-alias.el.
1741 (mh-thread-scan-line-map, mh-thread-scan-line-map-stack): Move 1745 (mh-thread-scan-line-map, mh-thread-scan-line-map-stack):
1742 here from mh-seq.el. 1746 Move here from mh-seq.el.
1743 (mh-draft-folder, mh-inbox, mh-user-path, mh-current-folder) 1747 (mh-draft-folder, mh-inbox, mh-user-path, mh-current-folder)
1744 (mh-previous-window-config, mh-seen-list, mh-seq-list) 1748 (mh-previous-window-config, mh-seen-list, mh-seq-list)
1745 (mh-show-buffer, mh-showing-mode, mh-globals-hash) 1749 (mh-show-buffer, mh-showing-mode, mh-globals-hash)
@@ -2042,10 +2046,10 @@
2042 (mh-show-mouse, mh-modify, mh-goto-msg, mh-set-folder-modified-p): 2046 (mh-show-mouse, mh-modify, mh-goto-msg, mh-set-folder-modified-p):
2043 Move to new file mh-folder.el. 2047 Move to new file mh-folder.el.
2044 (with-mh-folder-updating, mh-in-show-buffer) 2048 (with-mh-folder-updating, mh-in-show-buffer)
2045 (mh-do-at-event-location, mh-seq-msgs): Moved to mh-acros.el. 2049 (mh-do-at-event-location, mh-seq-msgs): Move to mh-acros.el.
2046 (mh-make-seq, mh-seq-name, mh-notate, mh-find-seq) 2050 (mh-make-seq, mh-seq-name, mh-notate, mh-find-seq)
2047 (mh-seq-to-msgs, mh-add-msgs-to-seq, mh-canonicalize-sequence): 2051 (mh-seq-to-msgs, mh-add-msgs-to-seq, mh-canonicalize-sequence):
2048 Moved to mh-seq.el. 2052 Move to mh-seq.el.
2049 (mh-show-xface-function, mh-uncompface-executable, mh-face-to-png) 2053 (mh-show-xface-function, mh-uncompface-executable, mh-face-to-png)
2050 (mh-uncompface, mh-icontopbm, mh-face-foreground-compat) 2054 (mh-uncompface, mh-icontopbm, mh-face-foreground-compat)
2051 (mh-face-background-compat, mh-face-display-function) 2055 (mh-face-background-compat, mh-face-display-function)
@@ -2070,8 +2074,8 @@
2070 mh-init.el. 2074 mh-init.el.
2071 (mh-help-messages): Now an alist of modes to an alist of messages. 2075 (mh-help-messages): Now an alist of modes to an alist of messages.
2072 (mh-set-help): New function used to set mh-help-messages. 2076 (mh-set-help): New function used to set mh-help-messages.
2073 (mh-help): Adjust for new format of mh-help-messages. Add 2077 (mh-help): Adjust for new format of mh-help-messages.
2074 help-messages argument. 2078 Add help-messages argument.
2075 (mh-prefix-help): Refactor to use mh-help. 2079 (mh-prefix-help): Refactor to use mh-help.
2076 (mh-coalesce-msg-list, mh-greaterp, mh-lessp): Move here from 2080 (mh-coalesce-msg-list, mh-greaterp, mh-lessp): Move here from
2077 mh-e.el. 2081 mh-e.el.
@@ -2202,8 +2206,8 @@
2202 (mh-search-mode-map): Autoload so that keys are shown in help even 2206 (mh-search-mode-map): Autoload so that keys are shown in help even
2203 before mh-search is loaded. 2207 before mh-search is loaded.
2204 (mh-search-mode): Sync docstring with manual. 2208 (mh-search-mode): Sync docstring with manual.
2205 (mh-index-do-search): Rename argument indexer to searcher. Sync 2209 (mh-index-do-search): Rename argument indexer to searcher.
2206 docstring with manual. 2210 Sync docstring with manual.
2207 (mh-pick-do-search): Sync docstring with manual. 2211 (mh-pick-do-search): Sync docstring with manual.
2208 (mh-index-p): Rename to mh-search-p. 2212 (mh-index-p): Rename to mh-search-p.
2209 (mh-indexer-choices): Rename to mh-search-choices. 2213 (mh-indexer-choices): Rename to mh-search-choices.
@@ -2220,7 +2224,7 @@
2220 2224
22212006-01-13 Bill Wohler <wohler@newt.com> 22252006-01-13 Bill Wohler <wohler@newt.com>
2222 2226
2223 * mh-acros.el (require): Added Satyaki's comment regarding what 2227 * mh-acros.el (require): Add Satyaki's comment regarding what
2224 needs to happen to remove this defadvice which caused a little 2228 needs to happen to remove this defadvice which caused a little
2225 discussion on emacs-devel today (see Subject: mh-e/mh-acros.el 2229 discussion on emacs-devel today (see Subject: mh-e/mh-acros.el
2226 advices `require' incorrectly). 2230 advices `require' incorrectly).
@@ -2292,8 +2296,8 @@
2292 * mh-gnus.el: Require mh-acros. 2296 * mh-gnus.el: Require mh-acros.
2293 (mh-defmacro-compat, mh-defun-compat): Move to mh-acros.el. 2297 (mh-defmacro-compat, mh-defun-compat): Move to mh-acros.el.
2294 2298
2295 * mh-utils.el (mh-x-image-url-cache-canonicalize): Use 2299 * mh-utils.el (mh-x-image-url-cache-canonicalize):
2296 url-hexify-string to remove special characters from filenames 2300 Use url-hexify-string to remove special characters from filenames
2297 (closes SF #1396499). Note that this invalidates the existing 2301 (closes SF #1396499). Note that this invalidates the existing
2298 names in your cache so you might as well remove 2302 names in your cache so you might as well remove
2299 ~/Mail/.mhe-x-image-cache/* now. 2303 ~/Mail/.mhe-x-image-cache/* now.
@@ -2352,16 +2356,16 @@
2352 than file-executable-p which returns t for directories. 2356 than file-executable-p which returns t for directories.
2353 (mh-file-command-p): Move here from mh-utils, since 2357 (mh-file-command-p): Move here from mh-utils, since
2354 mh-variant-*-info are the only functions to use it. 2358 mh-variant-*-info are the only functions to use it.
2355 (mh-variant-set, mh-variant-set-variant, mh-variant-p): Use 2359 (mh-variant-set, mh-variant-set-variant, mh-variant-p):
2356 function mh-variants instead of variable. More robust. 2360 Use function mh-variants instead of variable. More robust.
2357 (mh-find-path-run): Move here from mh-utils.el. Mention that 2361 (mh-find-path-run): Move here from mh-utils.el. Mention that
2358 checking this variable is unnecessary. 2362 checking this variable is unnecessary.
2359 (mh-find-path): Move here from mh-utils.el. With the advent of MH 2363 (mh-find-path): Move here from mh-utils.el. With the advent of MH
2360 variants and an mhparam command that doesn't work if there isn't 2364 variants and an mhparam command that doesn't work if there isn't
2361 an MH profile, we can't get libdir for running install-mh. So 2365 an MH profile, we can't get libdir for running install-mh.
2362 don't bother. If there's an issue with the environment, direct the 2366 So don't bother. If there's an issue with the environment, direct the
2363 user to install MH and run install-mh (closes SF #835192). Don't 2367 user to install MH and run install-mh (closes SF #835192).
2364 read ~/.mh_profile directly. Use mh-profile-component which uses 2368 Don't read ~/.mh_profile directly. Use mh-profile-component which uses
2365 mhparam (closes SF #1016027). 2369 mhparam (closes SF #1016027).
2366 2370
2367 * mh-utils.el (mh-get-profile-field): Rename to 2371 * mh-utils.el (mh-get-profile-field): Rename to
@@ -2376,12 +2380,12 @@
2376 (mh-no-install, mh-install): Delete. 2380 (mh-no-install, mh-install): Delete.
2377 2381
2378 * mh-customize.el (mh-folder-msg-number): 2382 * mh-customize.el (mh-folder-msg-number):
2379 * mh-mime.el (mh-file-mime-type): Removed trailing whitespace. 2383 * mh-mime.el (mh-file-mime-type): Remove trailing whitespace.
2380 2384
23812006-01-09 Bill Wohler <wohler@newt.com> 23852006-01-09 Bill Wohler <wohler@newt.com>
2382 2386
2383 * mh-init.el (mh-variant-mu-mh-info, mh-variant-nmh-info): Applied 2387 * mh-init.el (mh-variant-mu-mh-info, mh-variant-nmh-info):
2384 patch from Satyaki from SF #1016027. 2388 Applied patch from Satyaki from SF #1016027.
2385 2389
2386 * mh-e.el (mh-rescan-folder): Try to keep cursor at current 2390 * mh-e.el (mh-rescan-folder): Try to keep cursor at current
2387 message, even if cur sequence is no longer present (closes SF 2391 message, even if cur sequence is no longer present (closes SF
@@ -2429,7 +2433,7 @@
2429 2433
2430 * mh-comp.el: Require cleanup, wrap compiler-shushing defvars with 2434 * mh-comp.el: Require cleanup, wrap compiler-shushing defvars with
2431 eval-when-compile. 2435 eval-when-compile.
2432 (mh-file-is-vcard-p): Removed redundant test. 2436 (mh-file-is-vcard-p): Remove redundant test.
2433 2437
2434 * mh-customize.el: Require cleanup, wrap compiler-shushing defvars 2438 * mh-customize.el: Require cleanup, wrap compiler-shushing defvars
2435 with eval-when-compile. 2439 with eval-when-compile.
@@ -2455,8 +2459,8 @@
2455 2459
2456 * mh-mime.el: Wrap compiler-shushing defvars with 2460 * mh-mime.el: Wrap compiler-shushing defvars with
2457 eval-when-compile. 2461 eval-when-compile.
2458 (mh-have-file-command): Initialize variable to 'undefined. Add 2462 (mh-have-file-command): Initialize variable to 'undefined.
2459 docstring. Update function of same name accordingly. Also don't 2463 Add docstring. Update function of same name accordingly. Also don't
2460 need to load executable any more. 2464 need to load executable any more.
2461 (mh-mime-content-types): Delete. 2465 (mh-mime-content-types): Delete.
2462 (mh-minibuffer-read-type): Prompt user for type if 2466 (mh-minibuffer-read-type): Prompt user for type if
@@ -2695,11 +2699,11 @@
2695 with manual. 2699 with manual.
2696 (mh-yank-cur-msg): Mention that mh-ins-buf-prefix isn't used if 2700 (mh-yank-cur-msg): Mention that mh-ins-buf-prefix isn't used if
2697 you have added a mail-citation-hook and neither are used if you 2701 you have added a mail-citation-hook and neither are used if you
2698 use one of the supercite flavors of mh-yank-behavior. Sync 2702 use one of the supercite flavors of mh-yank-behavior.
2699 docstrings with manual. 2703 Sync docstrings with manual.
2700 2704
2701 * mh-customize.el (mh-kill-folder-suppress-prompt-hooks): Rename 2705 * mh-customize.el (mh-kill-folder-suppress-prompt-hooks):
2702 from mh-kill-folder-suppress-prompt-hook since it is an abnormal 2706 Rename from mh-kill-folder-suppress-prompt-hook since it is an abnormal
2703 hook. Use "Hook run by `function'..." instead of "Invoked...". 2707 hook. Use "Hook run by `function'..." instead of "Invoked...".
2704 Sync docstrings with manual. 2708 Sync docstrings with manual.
2705 (mh-ins-buf-prefix, mh-yank-behavior): Mention that 2709 (mh-ins-buf-prefix, mh-yank-behavior): Mention that
@@ -2824,13 +2828,13 @@
2824 2828
2825 * mh-customize.el (mh-speed-flists-interval): Rename to 2829 * mh-customize.el (mh-speed-flists-interval): Rename to
2826 mh-speed-update-interval. 2830 mh-speed-update-interval.
2827 (mh-speed-run-flists-flag): Delete. Setting 2831 (mh-speed-run-flists-flag): Delete.
2828 mh-speed-flists-interval to 0 accomplishes the same thing. 2832 Setting mh-speed-flists-interval to 0 accomplishes the same thing.
2829 2833
2830 * mh-speed.el (mh-folder-speedbar-buttons, mh-speed-flists): Use 2834 * mh-speed.el (mh-folder-speedbar-buttons, mh-speed-flists):
2831 mh-speed-update-interval instead of mh-speed-run-flists-flag. 2835 Use mh-speed-update-interval instead of mh-speed-run-flists-flag.
2832 (mh-speed-toggle, mh-speed-view, mh-speed-refresh): Sync 2836 (mh-speed-toggle, mh-speed-view, mh-speed-refresh):
2833 docstrings with manual. 2837 Sync docstrings with manual.
2834 2838
28352005-12-09 Bill Wohler <wohler@newt.com> 28392005-12-09 Bill Wohler <wohler@newt.com>
2836 2840
@@ -2847,8 +2851,8 @@
2847 (mh-invisible-header-fields-internal): Add X-Bugzilla-* and 2851 (mh-invisible-header-fields-internal): Add X-Bugzilla-* and
2848 X-Virus-Scanned. 2852 X-Virus-Scanned.
2849 2853
2850 * mh-customize.el (mh-insert-signature-hook): Rename 2854 * mh-customize.el (mh-insert-signature-hook):
2851 mh-letter-insert-signature-hook to mh-insert-signature-hook. 2855 Rename mh-letter-insert-signature-hook to mh-insert-signature-hook.
2852 2856
2853 * mh-comp.el (mh-insert-signature): Ditto. 2857 * mh-comp.el (mh-insert-signature): Ditto.
2854 2858
@@ -2950,10 +2954,10 @@
2950 (mh-next-undeleted-msg, mh-previous-undeleted-msg): Rename arg to 2954 (mh-next-undeleted-msg, mh-previous-undeleted-msg): Rename arg to
2951 count. Sync docstrings with manual. 2955 count. Sync docstrings with manual.
2952 (mh-refile-or-write-again): Use output from mh-write-msg-to-file 2956 (mh-refile-or-write-again): Use output from mh-write-msg-to-file
2953 so that message doesn't change when using this command. Sync 2957 so that message doesn't change when using this command.
2954 docstrings with manual. 2958 Sync docstrings with manual.
2955 (mh-page-msg, mh-previous-page): Rename arg to lines. Sync 2959 (mh-page-msg, mh-previous-page): Rename arg to lines.
2956 docstrings with manual. 2960 Sync docstrings with manual.
2957 (mh-write-msg-to-file): Rename msg to message. Rename no-headers 2961 (mh-write-msg-to-file): Rename msg to message. Rename no-headers
2958 to no-header. Sync docstrings with manual. 2962 to no-header. Sync docstrings with manual.
2959 (mh-ps-print-map): Delete keybindings for deleted commands 2963 (mh-ps-print-map): Delete keybindings for deleted commands
@@ -2977,8 +2981,8 @@
2977 Sync docstrings with manual. 2981 Sync docstrings with manual.
2978 (mh-toggle-mh-decode-mime-flag): Use English in message, not Lisp. 2982 (mh-toggle-mh-decode-mime-flag): Use English in message, not Lisp.
2979 Sync docstrings with manual. 2983 Sync docstrings with manual.
2980 (mh-mm-display-part, mh-mm-inline-message): Use 2984 (mh-mm-display-part, mh-mm-inline-message):
2981 mh-highlight-citation-style instead of mh-highlight-citation-p. 2985 Use mh-highlight-citation-style instead of mh-highlight-citation-p.
2982 (mh-press-button): Sync docstrings with manual. 2986 (mh-press-button): Sync docstrings with manual.
2983 (mh-display-with-external-viewer): Fix default output in 2987 (mh-display-with-external-viewer): Fix default output in
2984 minibuffer. Sync docstrings with manual. 2988 minibuffer. Sync docstrings with manual.
@@ -3069,8 +3073,8 @@
3069 (mh-smail, mh-extract-rejected-mail, mh-forward, mh-redistribute) 3073 (mh-smail, mh-extract-rejected-mail, mh-forward, mh-redistribute)
3070 (mh-reply, mh-send, mh-send-other-window) 3074 (mh-reply, mh-send, mh-send-other-window)
3071 (mh-fill-paragraph-function): Sync docstrings with manual. 3075 (mh-fill-paragraph-function): Sync docstrings with manual.
3072 (mh-edit-again, mh-extract-rejected-mail, mh-redistribute): Rename 3076 (mh-edit-again, mh-extract-rejected-mail, mh-redistribute):
3073 msg argument to message (to make for a better docstring). 3077 Rename msg argument to message (to make for a better docstring).
3074 3078
3075 * mh-customize.el (mh-redist-full-contents-flag): Convert defvar 3079 * mh-customize.el (mh-redist-full-contents-flag): Convert defvar
3076 to defcustom. Rename by adding -flag. 3080 to defcustom. Rename by adding -flag.
@@ -3095,8 +3099,8 @@
3095 * mh-customize.el (mh-compose-space-does-completion-flag) 3099 * mh-customize.el (mh-compose-space-does-completion-flag)
3096 (mh-signature-separator-flag, mh-interpret-number-as-range-flag) 3100 (mh-signature-separator-flag, mh-interpret-number-as-range-flag)
3097 (mh-adaptive-cmd-note-flag): Use "Non-nil means" instead of "On 3101 (mh-adaptive-cmd-note-flag): Use "Non-nil means" instead of "On
3098 means" to remain checkdoc clean and consistent with Emacs. I 3102 means" to remain checkdoc clean and consistent with Emacs.
3099 raised this issue with the Emacs developers and Stallman agrees 3103 I raised this issue with the Emacs developers and Stallman agrees
3100 that "On means" should be allowed in custom docstrings but that 3104 that "On means" should be allowed in custom docstrings but that
3101 this change requires thought and should wait until after the Emacs 3105 this change requires thought and should wait until after the Emacs
3102 22 release. 3106 22 release.
@@ -3108,14 +3112,14 @@
3108 3112
3109 * mh-customize.el (mh-interpret-number-as-range-flag): Add * to 3113 * mh-customize.el (mh-interpret-number-as-range-flag): Add * to
3110 docstring. 3114 docstring.
3111 (mh-adaptive-cmd-note-flag-check, mh-scan-format-file-check): New 3115 (mh-adaptive-cmd-note-flag-check, mh-scan-format-file-check):
3112 functions to check input for mh-adaptive-cmd-note-flag and 3116 New functions to check input for mh-adaptive-cmd-note-flag and
3113 mh-scan-format-file respectively. 3117 mh-scan-format-file respectively.
3114 (mh-adaptive-cmd-note-flag, mh-scan-format-file): Docstring fixes, 3118 (mh-adaptive-cmd-note-flag, mh-scan-format-file): Docstring fixes,
3115 add :set. 3119 add :set.
3116 3120
3117 * mh-e.el (mh-scan-field-destination-offset): New variable. The 3121 * mh-e.el (mh-scan-field-destination-offset): New variable.
3118 destination is the -, t, b, c, or n character for Replied, To, cc, 3122 The destination is the -, t, b, c, or n character for Replied, To, cc,
3119 Bcc, or Newsgroups respectively. 3123 Bcc, or Newsgroups respectively.
3120 (mh-make-folder, mh-regenerate-headers, mh-generate-new-cmd-note): 3124 (mh-make-folder, mh-regenerate-headers, mh-generate-new-cmd-note):
3121 Call new function mh-msg-num-width-to-column to make leap between 3125 Call new function mh-msg-num-width-to-column to make leap between
@@ -3235,10 +3239,10 @@
3235 3239
32362005-10-23 Bill Wohler <wohler@newt.com> 32402005-10-23 Bill Wohler <wohler@newt.com>
3237 3241
3238 * mh-comp.el (mh-letter-menu): Rename 3242 * mh-comp.el (mh-letter-menu):
3239 mh-mhn-compose-external-compressed-tar to 3243 Rename mh-mhn-compose-external-compressed-tar to
3240 mh-mh-compose-external-compressed-tar. Rename 3244 mh-mh-compose-external-compressed-tar.
3241 mh-mhn-compose-anon-ftp to mh-mh-compose-anon-ftp. Rename 3245 Rename mh-mhn-compose-anon-ftp to mh-mh-compose-anon-ftp. Rename
3242 mh-edit-mhn to mh-mh-to-mime. Rename mh-mhn-directive-present-p to 3246 mh-edit-mhn to mh-mh-to-mime. Rename mh-mhn-directive-present-p to
3243 mh-mh-directive-present-p. Rename mh-revert-mhn-edit to 3247 mh-mh-directive-present-p. Rename mh-revert-mhn-edit to
3244 mh-mh-to-mime-undo. Rename mh-gnus-pgp-support-flag to 3248 mh-mh-to-mime-undo. Rename mh-gnus-pgp-support-flag to
@@ -3248,21 +3252,21 @@
3248 mh-mh-directive-present-p. 3252 mh-mh-directive-present-p.
3249 (mh-send-letter): Rename mh-mhn-directive-present-p to 3253 (mh-send-letter): Rename mh-mhn-directive-present-p to
3250 mh-mh-directive-present-p. Rename mh-edit-mhn to mh-mh-to-mime. 3254 mh-mh-directive-present-p. Rename mh-edit-mhn to mh-mh-to-mime.
3251 (mh-letter-mode-map): Rename mh-edit-mhn to mh-mh-to-mime. Rename 3255 (mh-letter-mode-map): Rename mh-edit-mhn to mh-mh-to-mime.
3252 mh-mhn-compose-anon-ftp to mh-mh-compose-anon-ftp. Rename 3256 Rename mh-mhn-compose-anon-ftp to mh-mh-compose-anon-ftp.
3253 mh-mhn-compose-external-compressed-tar to 3257 Rename mh-mhn-compose-external-compressed-tar to
3254 mh-mh-compose-external-compressed-tar. Rename mh-revert-mhn-edit 3258 mh-mh-compose-external-compressed-tar. Rename mh-revert-mhn-edit
3255 to mh-mh-to-mime-undo. Rename mh-mhn-compose-external-type to 3259 to mh-mh-to-mime-undo. Rename mh-mhn-compose-external-type to
3256 mh-mh-compose-external-type. Rename mh-mhn-compose-anon-ftp to 3260 mh-mh-compose-external-type. Rename mh-mhn-compose-anon-ftp to
3257 mh-mh-compose-anon-ftp. Rename 3261 mh-mh-compose-anon-ftp.
3258 mh-mhn-compose-external-compressed-tar to 3262 Rename mh-mhn-compose-external-compressed-tar to
3259 mh-mh-compose-external-compressed-tar. Rename mh-revert-mhn-edit 3263 mh-mh-compose-external-compressed-tar. Rename mh-revert-mhn-edit
3260 to mh-mh-to-mime-undo. Rename mh-mhn-compose-external-type to 3264 to mh-mh-to-mime-undo. Rename mh-mhn-compose-external-type to
3261 mh-mh-compose-external-type. 3265 mh-mh-compose-external-type.
3262 (mh-send-letter, mh-letter-mode-map): Rename mh-edit-mhn to 3266 (mh-send-letter, mh-letter-mode-map): Rename mh-edit-mhn to
3263 mh-mh-to-mime, mh-revert-mhn-edit to mh-mh-to-mime-undo. 3267 mh-mh-to-mime, mh-revert-mhn-edit to mh-mh-to-mime-undo.
3264 (mh-reply, mh-yank-cur-msg, mh-insert-prefix-string): Rename 3268 (mh-reply, mh-yank-cur-msg, mh-insert-prefix-string):
3265 mh-yank-from-start-of-msg to mh-yank-behavior. 3269 Rename mh-yank-from-start-of-msg to mh-yank-behavior.
3266 (mh-letter-mode, mh-to-field, mh-to-fcc, mh-insert-signature) 3270 (mh-letter-mode, mh-to-field, mh-to-fcc, mh-insert-signature)
3267 (mh-check-whom, mh-insert-auto-fields, mh-send-letter) 3271 (mh-check-whom, mh-insert-auto-fields, mh-send-letter)
3268 (mh-insert-letter, mh-yank-cur-msg, mh-insert-prefix-string) 3272 (mh-insert-letter, mh-yank-cur-msg, mh-insert-prefix-string)
@@ -3305,8 +3309,8 @@
3305 (mh-mhn-compose-anon-ftp): Rename to mh-mh-compose-anon-ftp. 3309 (mh-mhn-compose-anon-ftp): Rename to mh-mh-compose-anon-ftp.
3306 Rename mh-mhn-compose-external-type to mh-mh-compose-external-type. 3310 Rename mh-mhn-compose-external-type to mh-mh-compose-external-type.
3307 (mh-mhn-compose-external-compressed-tar): Rename to 3311 (mh-mhn-compose-external-compressed-tar): Rename to
3308 mh-mh-compose-external-compressed-tar. Rename 3312 mh-mh-compose-external-compressed-tar.
3309 mh-mhn-compose-external-type to mh-mh-compose-external-type. 3313 Rename mh-mhn-compose-external-type to mh-mh-compose-external-type.
3310 (mh-mhn-compose-external-type): Rename to mh-mh-compose-external-type. 3314 (mh-mhn-compose-external-type): Rename to mh-mh-compose-external-type.
3311 (mh-edit-mhn): Rename to mh-mh-to-mime. Rename mh-mhn-args to 3315 (mh-edit-mhn): Rename to mh-mh-to-mime. Rename mh-mhn-args to
3312 mh-mh-to-mime-args. Rename mh-edit-mhn-hook to mh-mh-to-mime-hook. 3316 mh-mh-to-mime-args. Rename mh-edit-mhn-hook to mh-mh-to-mime-hook.
@@ -3323,8 +3327,8 @@
3323 (mh-mh-compose-external-type): Rename extra-param argument to 3327 (mh-mh-compose-external-type): Rename extra-param argument to
3324 parameters. 3328 parameters.
3325 (mh-mml-to-mime, mh-secure-message, mh-mml-unsecure-message) 3329 (mh-mml-to-mime, mh-secure-message, mh-mml-unsecure-message)
3326 (mh-mime-display-part, mh-mime-display-single): Rename 3330 (mh-mime-display-part, mh-mime-display-single):
3327 mh-gnus-pgp-support-flag to mh-pgp-support-flag. 3331 Rename mh-gnus-pgp-support-flag to mh-pgp-support-flag.
3328 (mh-compose-insertion): Rename mh-mhn-compose-insertion to 3332 (mh-compose-insertion): Rename mh-mhn-compose-insertion to
3329 mh-mh-attach-file. 3333 mh-mh-attach-file.
3330 (mh-compose-forward): Rename mh-mhn-compose-forw to 3334 (mh-compose-forward): Rename mh-mhn-compose-forw to
@@ -3389,8 +3393,8 @@
3389 3393
3390 * mh-init.el (mh-image-load-path-called-flag): New variable which 3394 * mh-init.el (mh-image-load-path-called-flag): New variable which
3391 is used by mh-image-load-path so that it runs only once. 3395 is used by mh-image-load-path so that it runs only once.
3392 (mh-image-load-path): Modify so that it gets run only once. Also 3396 (mh-image-load-path): Modify so that it gets run only once.
3393 flatten out heavily nested if statements to make it clearer. 3397 Also flatten out heavily nested if statements to make it clearer.
3394 3398
3395 * mh-e.el (mh-folder-mode): Call mh-image-load-path to allow Emacs 3399 * mh-e.el (mh-folder-mode): Call mh-image-load-path to allow Emacs
3396 to find images used in the toolbar. 3400 to find images used in the toolbar.
@@ -3414,11 +3418,11 @@
3414 need to be indented. 3418 need to be indented.
3415 3419
3416 * mh-e.el: mh-folder-tick-face had been renamed to mh-folder-tick 3420 * mh-e.el: mh-folder-tick-face had been renamed to mh-folder-tick
3417 but the code that invoked the face had not been updated. Tick 3421 but the code that invoked the face had not been updated.
3418 highlighting working again. 3422 Tick highlighting working again.
3419 3423
3420 * mh-seq.el (mh-non-seq-mode-line-annotation): Move 3424 * mh-seq.el (mh-non-seq-mode-line-annotation):
3421 make-variable-buffer-local call to top level to avoid warnings in 3425 Move make-variable-buffer-local call to top level to avoid warnings in
3422 CVS Emacs. 3426 CVS Emacs.
3423 3427
3424 * mh-comp.el (mh-insert-letter): Replace deprecated read-input 3428 * mh-comp.el (mh-insert-letter): Replace deprecated read-input
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el
index 1944a4cd08f..2b5e51cfb34 100644
--- a/lisp/mh-e/mh-utils.el
+++ b/lisp/mh-e/mh-utils.el
@@ -732,8 +732,7 @@ See Info node `(elisp) Programmed Completion' for details."
732 732
733;; Shush compiler. 733;; Shush compiler.
734(mh-do-in-xemacs 734(mh-do-in-xemacs
735 (defvar completion-root-regexp) 735 (defvar completion-root-regexp))
736 (defvar minibuffer-completing-file-name))
737 736
738(defun mh-folder-completing-read (prompt default allow-root-folder-flag) 737(defun mh-folder-completing-read (prompt default allow-root-folder-flag)
739 "Read folder name with PROMPT and default result DEFAULT. 738 "Read folder name with PROMPT and default result DEFAULT.
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5a990f6ab35..733a132bb1c 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -45,17 +45,6 @@
45;; corresponding to the displayed completions because we only 45;; corresponding to the displayed completions because we only
46;; provide the start info but not the end info in 46;; provide the start info but not the end info in
47;; completion-base-position. 47;; completion-base-position.
48;; - quoting is problematic. E.g. the double-dollar quoting used in
49;; substitute-in-file-name (and hence read-file-name-internal) bumps
50;; into various bugs:
51;; - choose-completion doesn't know how to quote the text it inserts.
52;; E.g. it fails to double the dollars in file-name completion, or
53;; to backslash-escape spaces and other chars in comint completion.
54;; - when completing ~/tmp/fo$$o, the highlighting in *Completions*
55;; is off by one position.
56;; - all code like PCM which relies on all-completions to match
57;; its argument gets confused because all-completions returns unquoted
58;; texts (as desired for *Completions* output).
59;; - C-x C-f ~/*/sr ? should not list "~/./src". 48;; - C-x C-f ~/*/sr ? should not list "~/./src".
60;; - minibuffer-force-complete completes ~/src/emacs/t<!>/lisp/minibuffer.el 49;; - minibuffer-force-complete completes ~/src/emacs/t<!>/lisp/minibuffer.el
61;; to ~/src/emacs/trunk/ and throws away lisp/minibuffer.el. 50;; to ~/src/emacs/trunk/ and throws away lisp/minibuffer.el.
@@ -66,12 +55,9 @@
66;; - Make things like icomplete-mode or lightning-completion work with 55;; - Make things like icomplete-mode or lightning-completion work with
67;; completion-in-region-mode. 56;; completion-in-region-mode.
68;; - extend `metadata': 57;; - extend `metadata':
69;; - quoting/unquoting (so we can complete files names with envvars
70;; and backslashes, and all-completion can list names without
71;; quoting backslashes and dollars).
72;; - indicate how to turn all-completion's output into 58;; - indicate how to turn all-completion's output into
73;; try-completion's output: e.g. completion-ignored-extensions. 59;; try-completion's output: e.g. completion-ignored-extensions.
74;; maybe that could be merged with the "quote" operation above. 60;; maybe that could be merged with the "quote" operation.
75;; - indicate that `all-completions' doesn't do prefix-completion 61;; - indicate that `all-completions' doesn't do prefix-completion
76;; but just returns some list that relates in some other way to 62;; but just returns some list that relates in some other way to
77;; the provided string (as is the case in filecache.el), in which 63;; the provided string (as is the case in filecache.el), in which
@@ -224,6 +210,42 @@ case sensitive instead."
224 (let ((completion-ignore-case (not dont-fold))) 210 (let ((completion-ignore-case (not dont-fold)))
225 (complete-with-action action table string pred)))) 211 (complete-with-action action table string pred))))
226 212
213(defun completion-table-subvert (table s1 s2)
214 "Completion table that replaces the prefix S1 with S2 in STRING.
215The result is a completion table which completes strings of the
216form (concat S1 S) in the same way as TABLE completes strings of
217the form (concat S2 S)."
218 (lambda (string pred action)
219 (let* ((str (if (eq t (compare-strings string 0 (length s1) s1 nil nil
220 completion-ignore-case))
221 (concat s2 (substring string (length s1)))))
222 (res (if str (complete-with-action action table str pred))))
223 (when res
224 (cond
225 ((eq (car-safe action) 'boundaries)
226 (let ((beg (or (and (eq (car-safe res) 'boundaries) (cadr res)) 0)))
227 (list* 'boundaries
228 (max (length s1)
229 (+ beg (- (length s1) (length s2))))
230 (and (eq (car-safe res) 'boundaries) (cddr res)))))
231 ((stringp res)
232 (if (eq t (compare-strings res 0 (length s2) s2 nil nil
233 completion-ignore-case))
234 (concat s1 (substring res (length s2)))))
235 ((eq action t)
236 (let ((bounds (completion-boundaries str table pred "")))
237 (if (>= (car bounds) (length s2))
238 res
239 (let ((re (concat "\\`"
240 (regexp-quote (substring s2 (car bounds))))))
241 (delq nil
242 (mapcar (lambda (c)
243 (if (string-match re c)
244 (substring c (match-end 0))))
245 res))))))
246 ;; E.g. action=nil and it's the only completion.
247 (res))))))
248
227(defun completion-table-with-context (prefix table string pred action) 249(defun completion-table-with-context (prefix table string pred action)
228 ;; TODO: add `suffix' maybe? 250 ;; TODO: add `suffix' maybe?
229 (let ((pred 251 (let ((pred
@@ -347,6 +369,186 @@ Note: TABLE needs to be a proper completion table which obeys predicates."
347 (complete-with-action action table string pred)) 369 (complete-with-action action table string pred))
348 tables))) 370 tables)))
349 371
372(defun completion-table-with-quoting (table unquote requote)
373 ;; A difficult part of completion-with-quoting is to map positions in the
374 ;; quoted string to equivalent positions in the unquoted string and
375 ;; vice-versa. There is no efficient and reliable algorithm that works for
376 ;; arbitrary quote and unquote functions.
377 ;; So to map from quoted positions to unquoted positions, we simply assume
378 ;; that `concat' and `unquote' commute (which tends to be the case).
379 ;; And we ask `requote' to do the work of mapping from unquoted positions
380 ;; back to quoted positions.
381 "Return a new completion table operating on quoted text.
382TABLE operates on the unquoted text.
383UNQUOTE is a function that takes a string and returns a new unquoted string.
384REQUOTE is a function of 2 args (UPOS QSTR) where
385 QSTR is a string entered by the user (and hence indicating
386 the user's preferred form of quoting); and
387 UPOS is a position within the unquoted form of QSTR.
388REQUOTE should return a pair (QPOS . QFUN) such that QPOS is the
389position corresponding to UPOS but in QSTR, and QFUN is a function
390of one argument (a string) which returns that argument appropriately quoted
391for use at QPOS."
392 ;; FIXME: One problem with the current setup is that `qfun' doesn't know if
393 ;; its argument is "the end of the completion", so if the quoting used double
394 ;; quotes (for example), we end up completing "fo" to "foobar and throwing
395 ;; away the closing double quote.
396 (lambda (string pred action)
397 (cond
398 ((eq action 'metadata)
399 (append (completion-metadata string table pred)
400 '((completion--unquote-requote . t))))
401
402 ((eq action 'lambda) ;;test-completion
403 (let ((ustring (funcall unquote string)))
404 (test-completion ustring table pred)))
405
406 ((eq (car-safe action) 'boundaries)
407 (let* ((ustring (funcall unquote string))
408 (qsuffix (cdr action))
409 (ufull (if (zerop (length qsuffix)) ustring
410 (funcall unquote (concat string qsuffix))))
411 (_ (assert (string-prefix-p ustring ufull)))
412 (usuffix (substring ufull (length ustring)))
413 (boundaries (completion-boundaries ustring table pred usuffix))
414 (qlboundary (car (funcall requote (car boundaries) string)))
415 (qrboundary (if (zerop (cdr boundaries)) 0 ;Common case.
416 (let* ((urfullboundary
417 (+ (cdr boundaries) (length ustring))))
418 (- (car (funcall requote urfullboundary
419 (concat string qsuffix)))
420 (length string))))))
421 (list* 'boundaries qlboundary qrboundary)))
422
423 ((eq action nil) ;;try-completion
424 (let* ((ustring (funcall unquote string))
425 (completion (try-completion ustring table pred)))
426 ;; Most forms of quoting allow several ways to quote the same string.
427 ;; So here we could simply requote `completion' in a kind of
428 ;; "canonical" quoted form without paying attention to the way
429 ;; `string' was quoted. But since we have to solve the more complex
430 ;; problems of "pay attention to the original quoting" for
431 ;; all-completions, we may as well use it here, since it provides
432 ;; a nicer behavior.
433 (if (not (stringp completion)) completion
434 (car (completion--twq-try
435 string ustring completion 0 unquote requote)))))
436
437 ((eq action t) ;;all-completions
438 ;; When all-completions is used for completion-try/all-completions
439 ;; (e.g. for `pcm' style), we can't do the job properly here because
440 ;; the caller will match our output against some pattern derived from
441 ;; the user's (quoted) input, and we don't have access to that
442 ;; pattern, so we can't know how to requote our output so that it
443 ;; matches the quoting used in the pattern. It is to fix this
444 ;; fundamental problem that we have to introduce the new
445 ;; unquote-requote method so that completion-try/all-completions can
446 ;; pass the unquoted string to the style functions.
447 (pcase-let*
448 ((ustring (funcall unquote string))
449 (completions (all-completions ustring table pred))
450 (boundary (car (completion-boundaries ustring table pred ""))))
451 (completion--twq-all
452 string ustring completions boundary unquote requote)))
453
454 ((eq action 'completion--unquote)
455 (let ((ustring (funcall unquote string))
456 (uprefix (funcall unquote (substring string 0 pred))))
457 ;; We presume (more or less) that `concat' and `unquote' commute.
458 (assert (string-prefix-p uprefix ustring))
459 (list ustring table (length uprefix)
460 (lambda (unquoted-result op)
461 (pcase op
462 (`1 ;;try
463 (if (not (stringp (car-safe unquoted-result)))
464 unquoted-result
465 (completion--twq-try
466 string ustring
467 (car unquoted-result) (cdr unquoted-result)
468 unquote requote)))
469 (`2 ;;all
470 (let* ((last (last unquoted-result))
471 (base (or (cdr last) 0)))
472 (when last
473 (setcdr last nil)
474 (completion--twq-all string ustring
475 unquoted-result base
476 unquote requote))))))))))))
477
478(defun completion--twq-try (string ustring completion point
479 unquote requote)
480 ;; Basically two case: either the new result is
481 ;; - commonprefix1 <point> morecommonprefix <qpos> suffix
482 ;; - commonprefix <qpos> newprefix <point> suffix
483 (pcase-let*
484 ((prefix (fill-common-string-prefix ustring completion))
485 (suffix (substring completion (max point (length prefix))))
486 (`(,qpos . ,qfun) (funcall requote (length prefix) string))
487 (qstr1 (if (> point (length prefix))
488 (funcall qfun (substring completion (length prefix) point))))
489 (qsuffix (funcall qfun suffix))
490 (qstring (concat (substring string 0 qpos) qstr1 qsuffix))
491 (qpoint
492 (cond
493 ((zerop point) 0)
494 ((> point (length prefix)) (+ qpos (length qstr1)))
495 (t (car (funcall requote point string))))))
496 ;; Make sure `requote' worked.
497 (assert (equal (funcall unquote qstring) completion))
498 (cons qstring qpoint)))
499
500(defun completion--twq-all (string ustring completions boundary
501 unquote requote)
502 (when completions
503 (pcase-let*
504 ((prefix
505 (let ((completion-regexp-list nil))
506 (try-completion "" (cons (substring ustring boundary)
507 completions))))
508 (`(,qfullpos . ,qfun)
509 (funcall requote (+ boundary (length prefix)) string))
510 (qfullprefix (substring string 0 qfullpos))
511 (_ (assert (let ((uboundarystr (substring ustring 0 boundary)))
512 (equal (funcall unquote qfullprefix)
513 (concat uboundarystr prefix)))))
514 (qboundary (car (funcall requote boundary string)))
515 (_ (assert (<= qboundary qfullpos)))
516 ;; FIXME: this split/quote/concat business messes up the carefully
517 ;; placed completions-common-part and completions-first-difference
518 ;; faces. We could try within the mapcar loop to search for the
519 ;; boundaries of those faces, pass them to `requote' to find their
520 ;; equivalent positions in the quoted output and re-add the faces:
521 ;; this might actually lead to correct results but would be
522 ;; pretty expensive.
523 ;; The better solution is to not quote the *Completions* display,
524 ;; which nicely circumvents the problem. The solution I used here
525 ;; instead is to hope that `qfun' preserves the text-properties and
526 ;; presume that the `first-difference' is not within the `prefix';
527 ;; this presumption is not always true, but at least in practice it is
528 ;; true in most cases.
529 (qprefix (propertize (substring qfullprefix qboundary)
530 'face 'completions-common-part)))
531
532 ;; Here we choose to quote all elements returned, but a better option
533 ;; would be to return unquoted elements together with a function to
534 ;; requote them, so that *Completions* can show nicer unquoted values
535 ;; which only get quoted when needed by choose-completion.
536 (nconc
537 (mapcar (lambda (completion)
538 (assert (string-prefix-p prefix completion))
539 (let* ((new (substring completion (length prefix)))
540 (qnew (funcall qfun new))
541 (qcompletion (concat qprefix qnew)))
542 (assert
543 (equal (funcall unquote
544 (concat (substring string 0 qboundary)
545 qcompletion))
546 (concat (substring ustring 0 boundary)
547 completion)))
548 qcompletion))
549 completions)
550 qboundary))))
551
350;; (defmacro complete-in-turn (a b) `(completion-table-in-turn ,a ,b)) 552;; (defmacro complete-in-turn (a b) `(completion-table-in-turn ,a ,b))
351;; (defmacro dynamic-completion-table (fun) `(completion-table-dynamic ,fun)) 553;; (defmacro dynamic-completion-table (fun) `(completion-table-dynamic ,fun))
352(define-obsolete-function-alias 554(define-obsolete-function-alias
@@ -535,21 +737,47 @@ completing buffer and file names, respectively."
535 (delete-dups (append (cdr over) (copy-sequence completion-styles))) 737 (delete-dups (append (cdr over) (copy-sequence completion-styles)))
536 completion-styles))) 738 completion-styles)))
537 739
740(defun completion--nth-completion (n string table pred point metadata)
741 "Call the Nth method of completion styles."
742 (unless metadata
743 (setq metadata
744 (completion-metadata (substring string 0 point) table pred)))
745 ;; We provide special support for quoting/unquoting here because it cannot
746 ;; reliably be done within the normal completion-table routines: Completion
747 ;; styles such as `substring' or `partial-completion' need to match the
748 ;; output of all-completions with the user's input, and since most/all
749 ;; quoting mechanisms allow several equivalent quoted forms, the
750 ;; completion-style can't do this matching (e.g. `substring' doesn't know
751 ;; that "\a\b\e" is a valid (quoted) substring of "label").
752 ;; The quote/unquote function needs to come from the completion table (rather
753 ;; than from completion-extra-properties) because it may apply only to some
754 ;; part of the string (e.g. substitute-in-file-name).
755 (let ((requote
756 (when (completion-metadata-get metadata 'completion--unquote-requote)
757 (let ((new (funcall table string point 'completion--unquote)))
758 (setq string (pop new))
759 (setq table (pop new))
760 (setq point (pop new))
761 (pop new))))
762 (result
763 (completion--some (lambda (style)
764 (funcall (nth n (assq style
765 completion-styles-alist))
766 string table pred point))
767 (completion--styles metadata))))
768 (if requote
769 (funcall requote result n)
770 result)))
771
538(defun completion-try-completion (string table pred point &optional metadata) 772(defun completion-try-completion (string table pred point &optional metadata)
539 "Try to complete STRING using completion table TABLE. 773 "Try to complete STRING using completion table TABLE.
540Only the elements of table that satisfy predicate PRED are considered. 774Only the elements of table that satisfy predicate PRED are considered.
541POINT is the position of point within STRING. 775POINT is the position of point within STRING.
542The return value can be either nil to indicate that there is no completion, 776The return value can be either nil to indicate that there is no completion,
543t to indicate that STRING is the only possible completion, 777t to indicate that STRING is the only possible completion,
544or a pair (STRING . NEWPOINT) of the completed result string together with 778or a pair (NEWSTRING . NEWPOINT) of the completed result string together with
545a new position for point." 779a new position for point."
546 (completion--some (lambda (style) 780 (completion--nth-completion 1 string table pred point metadata))
547 (funcall (nth 1 (assq style completion-styles-alist))
548 string table pred point))
549 (completion--styles (or metadata
550 (completion-metadata
551 (substring string 0 point)
552 table pred)))))
553 781
554(defun completion-all-completions (string table pred point &optional metadata) 782(defun completion-all-completions (string table pred point &optional metadata)
555 "List the possible completions of STRING in completion table TABLE. 783 "List the possible completions of STRING in completion table TABLE.
@@ -559,13 +787,7 @@ The return value is a list of completions and may contain the base-size
559in the last `cdr'." 787in the last `cdr'."
560 ;; FIXME: We need to additionally return the info needed for the 788 ;; FIXME: We need to additionally return the info needed for the
561 ;; second part of completion-base-position. 789 ;; second part of completion-base-position.
562 (completion--some (lambda (style) 790 (completion--nth-completion 2 string table pred point metadata))
563 (funcall (nth 2 (assq style completion-styles-alist))
564 string table pred point))
565 (completion--styles (or metadata
566 (completion-metadata
567 (substring string 0 point)
568 table pred)))))
569 791
570(defun minibuffer--bitset (modified completions exact) 792(defun minibuffer--bitset (modified completions exact)
571 (logior (if modified 4 0) 793 (logior (if modified 4 0)
@@ -1754,7 +1976,10 @@ This is only used when the minibuffer area has no active minibuffer.")
1754;;; Completion tables. 1976;;; Completion tables.
1755 1977
1756(defun minibuffer--double-dollars (str) 1978(defun minibuffer--double-dollars (str)
1757 (replace-regexp-in-string "\\$" "$$" str)) 1979 ;; Reuse the actual "$" from the string to preserve any text-property it
1980 ;; might have, such as `face'.
1981 (replace-regexp-in-string "\\$" (lambda (dollar) (concat dollar dollar))
1982 str))
1758 1983
1759(defun completion--make-envvar-table () 1984(defun completion--make-envvar-table ()
1760 (mapcar (lambda (enventry) 1985 (mapcar (lambda (enventry)
@@ -1880,58 +2105,40 @@ same as `substitute-in-file-name'."
1880(make-obsolete-variable 'read-file-name-predicate 2105(make-obsolete-variable 'read-file-name-predicate
1881 "use the regular PRED argument" "23.2") 2106 "use the regular PRED argument" "23.2")
1882 2107
1883(defun completion--file-name-table (string pred action) 2108(defun completion--sifn-requote (upos qstr)
2109 (let ((qpos 0))
2110 (while (and (> upos 0)
2111 (string-match "\\$\\(\\$\\|\\([[:alnum:]_]+\\|{[^}]*}\\)\\)?"
2112 qstr qpos))
2113 (cond
2114 ((>= (- (match-beginning 0) qpos) upos) ; UPOS is before current match.
2115 (setq qpos (+ qpos upos))
2116 (setq upos 0))
2117 ((not (match-end 1)) ;A sole $: probably an error.
2118 (setq upos (- upos (- (match-end 0) qpos)))
2119 (setq qpos (match-end 0)))
2120 (t
2121 (setq upos (- upos (- (match-beginning 0) qpos)))
2122 (setq qpos (match-end 0))
2123 (setq upos (- upos (length (substitute-in-file-name
2124 (match-string 0 qstr))))))))
2125 ;; If `upos' is negative, it's because it's within the expansion of an
2126 ;; envvar, i.e. there is no exactly matching qpos, so we just use the next
2127 ;; available qpos right after the envvar.
2128 (cons (if (>= upos 0) (+ qpos upos) qpos)
2129 #'minibuffer--double-dollars)))
2130
2131(defalias 'completion--file-name-table
2132 (completion-table-with-quoting #'completion-file-name-table
2133 #'substitute-in-file-name
2134 #'completion--sifn-requote)
1884 "Internal subroutine for `read-file-name'. Do not call this. 2135 "Internal subroutine for `read-file-name'. Do not call this.
1885This is a completion table for file names, like `completion-file-name-table' 2136This is a completion table for file names, like `completion-file-name-table'
1886except that it passes the file name through `substitute-in-file-name'." 2137except that it passes the file name through `substitute-in-file-name'.")
1887 (cond
1888 ((eq (car-safe action) 'boundaries)
1889 ;; For the boundaries, we can't really delegate to
1890 ;; substitute-in-file-name+completion-file-name-table and then fix
1891 ;; them up (as we do for the other actions), because it would
1892 ;; require us to track the relationship between `str' and
1893 ;; `string', which is difficult. And in any case, if
1894 ;; substitute-in-file-name turns "fo-$TO-ba" into "fo-o/b-ba",
1895 ;; there's no way for us to return proper boundaries info, because
1896 ;; the boundary is not (yet) in `string'.
1897 ;;
1898 ;; FIXME: Actually there is a way to return correct boundaries
1899 ;; info, at the condition of modifying the all-completions
1900 ;; return accordingly. But for now, let's not bother.
1901 (completion-file-name-table string pred action))
1902
1903 (t
1904 (let* ((default-directory
1905 (if (stringp pred)
1906 ;; It used to be that `pred' was abused to pass `dir'
1907 ;; as an argument.
1908 (prog1 (file-name-as-directory (expand-file-name pred))
1909 (setq pred nil))
1910 default-directory))
1911 (str (condition-case nil
1912 (substitute-in-file-name string)
1913 (error string)))
1914 (comp (completion-file-name-table
1915 str
1916 (with-no-warnings (or pred read-file-name-predicate))
1917 action)))
1918
1919 (cond
1920 ((stringp comp)
1921 ;; Requote the $s before returning the completion.
1922 (minibuffer--double-dollars comp))
1923 ((and (null action) comp
1924 ;; Requote the $s before checking for changes.
1925 (setq str (minibuffer--double-dollars str))
1926 (not (string-equal string str)))
1927 ;; If there's no real completion, but substitute-in-file-name
1928 ;; changed the string, then return the new string.
1929 str)
1930 (t comp))))))
1931 2138
1932(defalias 'read-file-name-internal 2139(defalias 'read-file-name-internal
1933 (completion-table-in-turn 'completion--embedded-envvar-table 2140 (completion-table-in-turn #'completion--embedded-envvar-table
1934 'completion--file-name-table) 2141 #'completion--file-name-table)
1935 "Internal subroutine for `read-file-name'. Do not call this.") 2142 "Internal subroutine for `read-file-name'. Do not call this.")
1936 2143
1937(defvar read-file-name-function 'read-file-name-default 2144(defvar read-file-name-function 'read-file-name-default
@@ -2073,7 +2280,7 @@ and `read-file-name-function'."
2073;; use (eq minibuffer-completion-table #'read-file-name-internal), which is 2280;; use (eq minibuffer-completion-table #'read-file-name-internal), which is
2074;; probably even worse. Maybe We should add some read-file-name-setup-hook 2281;; probably even worse. Maybe We should add some read-file-name-setup-hook
2075;; instead, but for now, let's keep this non-obsolete. 2282;; instead, but for now, let's keep this non-obsolete.
2076;;(make-obsolete-variable 'minibuffer-completing-file-name nil "24.1" 'get) 2283;;(make-obsolete-variable 'minibuffer-completing-file-name nil "future" 'get)
2077 2284
2078(defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate) 2285(defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate)
2079 "Default method for reading file names. 2286 "Default method for reading file names.
diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index 3af22c82dfb..ae4bd270b09 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -205,8 +205,8 @@ Includes files as well as host names followed by a colon."
205 ;; Avoid connecting to the remote host when we're 205 ;; Avoid connecting to the remote host when we're
206 ;; only completing the host name. 206 ;; only completing the host name.
207 (list string) 207 (list string)
208 (comint--table-subvert (pcomplete-all-entries) 208 (completion-table-subvert (pcomplete-all-entries)
209 "" "/ssh:"))) 209 "" "/ssh:")))
210 ((string-match "/" string) ; Local file name. 210 ((string-match "/" string) ; Local file name.
211 (pcomplete-all-entries)) 211 (pcomplete-all-entries))
212 (t ;Host name or local file name. 212 (t ;Host name or local file name.
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index cad2ffb2a2c..c9961a67f3d 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -165,22 +165,8 @@ A non-nil value is useful if `pcomplete-autolist' is non-nil too."
165 :type 'boolean 165 :type 'boolean
166 :group 'pcomplete) 166 :group 'pcomplete)
167 167
168(defcustom pcomplete-arg-quote-list nil 168(define-obsolete-variable-alias
169 "List of characters to quote when completing an argument." 169 'pcomplete-arg-quote-list 'comint-file-name-quote-list "24.2")
170 :type '(choice (repeat character)
171 (const :tag "Don't quote" nil))
172 :group 'pcomplete)
173
174(defcustom pcomplete-quote-arg-hook nil
175 "A hook which is run to quote a character within a filename.
176Each function is passed both the filename to be quoted, and the index
177to be considered. If the function wishes to provide an alternate
178quoted form, it need only return the replacement string. If no
179function provides a replacement, quoting shall proceed as normal,
180using a backslash to quote any character which is a member of
181`pcomplete-arg-quote-list'."
182 :type 'hook
183 :group 'pcomplete)
184 170
185(defcustom pcomplete-man-function 'man 171(defcustom pcomplete-man-function 'man
186 "A function to that will be called to display a manual page. 172 "A function to that will be called to display a manual page.
@@ -370,48 +356,28 @@ modified to be an empty string, or the desired separation string."
370;; it pretty much impossible to have completion other than 356;; it pretty much impossible to have completion other than
371;; prefix-completion. 357;; prefix-completion.
372;; 358;;
373;; pcomplete--common-quoted-suffix and comint--table-subvert try to 359;; pcomplete--common-suffix and completion-table-subvert try to work around
374;; work around this difficulty with heuristics, but it's 360;; this difficulty with heuristics, but it's really a hack.
375;; really a hack. 361
376 362(defvar pcomplete-unquote-argument-function #'comint--unquote-argument)
377(defvar pcomplete-unquote-argument-function nil) 363
378 364(defsubst pcomplete-unquote-argument (s)
379(defun pcomplete-unquote-argument (s) 365 (funcall pcomplete-unquote-argument-function s))
380 (cond 366
381 (pcomplete-unquote-argument-function 367(defvar pcomplete-requote-argument-function #'comint--requote-argument)
382 (funcall pcomplete-unquote-argument-function s)) 368
383 ((null pcomplete-arg-quote-list) s) 369(defun pcomplete--common-suffix (s1 s2)
384 (t 370 ;; Since S2 is expected to be the "unquoted/expanded" version of S1,
385 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" s t)))) 371 ;; there shouldn't be any case difference, even if the completion is
386 372 ;; case-insensitive.
387(defun pcomplete--common-quoted-suffix (s1 s2) 373 (let ((case-fold-search nil))
388 ;; FIXME: Copied in comint.el. 374 (string-match
389 "Find the common suffix between S1 and S2 where S1 is the expanded S2. 375 ;; \x3FFF7F is just an arbitrary char among the ones Emacs accepts
390S1 is expected to be the unquoted and expanded version of S2. 376 ;; that hopefully will never appear in normal text.
391Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that 377 "\\(?:.\\|\n\\)*?\\(\\(?:.\\|\n\\)*\\)\x3FFF7F\\(?:.\\|\n\\)*\\1\\'"
392S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and 378 (concat s1 "\x3FFF7F" s2))
393SS1 = (unquote SS2)." 379 (- (match-end 1) (match-beginning 1))))
394 (let* ((cs (comint--common-suffix s1 s2)) 380
395 (ss1 (substring s1 (- (length s1) cs)))
396 (qss1 (pcomplete-quote-argument ss1))
397 qc s2b)
398 (if (and (not (equal ss1 qss1))
399 (setq qc (pcomplete-quote-argument (substring ss1 0 1)))
400 (setq s2b (- (length s2) cs (length qc) -1))
401 (>= s2b 0) ;bug#11158.
402 (eq t (compare-strings s2 s2b (- (length s2) cs -1)
403 qc nil nil)))
404 ;; The difference found is just that one char is quoted in S2
405 ;; but not in S1, keep looking before this difference.
406 (pcomplete--common-quoted-suffix
407 (substring s1 0 (- (length s1) cs))
408 (substring s2 0 s2b))
409 (cons (substring s1 0 (- (length s1) cs))
410 (substring s2 0 (- (length s2) cs))))))
411
412;; I don't think such commands are usable before first setting up buffer-local
413;; variables to parse args, so there's no point autoloading it.
414;; ;;;###autoload
415(defun pcomplete-completions-at-point () 381(defun pcomplete-completions-at-point ()
416 "Provide standard completion using pcomplete's completion tables. 382 "Provide standard completion using pcomplete's completion tables.
417Same as `pcomplete' but using the standard completion UI." 383Same as `pcomplete' but using the standard completion UI."
@@ -442,34 +408,31 @@ Same as `pcomplete' but using the standard completion UI."
442 ;; pcomplete-stub and works from the buffer's text instead, 408 ;; pcomplete-stub and works from the buffer's text instead,
443 ;; we need to trick minibuffer-complete, into using 409 ;; we need to trick minibuffer-complete, into using
444 ;; pcomplete-stub without its knowledge. To that end, we 410 ;; pcomplete-stub without its knowledge. To that end, we
445 ;; use comint--table-subvert to construct a completion 411 ;; use completion-table-subvert to construct a completion
446 ;; table which expects strings using a prefix from the 412 ;; table which expects strings using a prefix from the
447 ;; buffer's text but internally uses the corresponding 413 ;; buffer's text but internally uses the corresponding
448 ;; prefix from pcomplete-stub. 414 ;; prefix from pcomplete-stub.
449 (beg (max (- (point) (length pcomplete-stub)) 415 (beg (max (- (point) (length pcomplete-stub))
450 (pcomplete-begin))) 416 (pcomplete-begin)))
451 (buftext (buffer-substring beg (point)))) 417 (buftext (pcomplete-unquote-argument
418 (buffer-substring beg (point)))))
452 (when completions 419 (when completions
453 (let ((table 420 (let ((table
454 (cond 421 (completion-table-with-quoting
455 ((not (equal pcomplete-stub buftext)) 422 (if (equal pcomplete-stub buftext)
456 ;; This isn't always strictly right (e.g. if 423 completions
457 ;; FOO="toto/$FOO", then completion of /$FOO/bar may 424 ;; This may not always be strictly right, but given the lack
458 ;; result in something incorrect), but given the lack of 425 ;; of any other info, it's about as good as it gets, and in
459 ;; any other info, it's about as good as it gets, and in 426 ;; practice it should work just fine (fingers crossed).
460 ;; practice it should work just fine (fingers crossed). 427 (let ((suf-len (pcomplete--common-suffix
461 (let ((prefixes (pcomplete--common-quoted-suffix
462 pcomplete-stub buftext))) 428 pcomplete-stub buftext)))
463 (comint--table-subvert 429 (completion-table-subvert
464 completions (cdr prefixes) (car prefixes) 430 completions
465 #'pcomplete-quote-argument #'pcomplete-unquote-argument))) 431 (substring buftext 0 (- (length buftext) suf-len))
466 (t 432 (substring pcomplete-stub 0
467 (lambda (string pred action) 433 (- (length pcomplete-stub) suf-len)))))
468 (let ((res (complete-with-action 434 pcomplete-unquote-argument-function
469 action completions string pred))) 435 pcomplete-requote-argument-function))
470 (if (stringp res)
471 (pcomplete-quote-argument res)
472 res))))))
473 (pred 436 (pred
474 ;; Pare it down, if applicable. 437 ;; Pare it down, if applicable.
475 (when (and pcomplete-use-paring pcomplete-seen) 438 (when (and pcomplete-use-paring pcomplete-seen)
@@ -828,22 +791,8 @@ this is `comint-dynamic-complete-functions'."
828 (throw 'pcompleted t) 791 (throw 'pcompleted t)
829 pcomplete-args)))))) 792 pcomplete-args))))))
830 793
831(defun pcomplete-quote-argument (filename) 794(define-obsolete-function-alias
832 "Return FILENAME with magic characters quoted. 795 'pcomplete-quote-argument #'comint-quote-filename "24.2")
833Magic characters are those in `pcomplete-arg-quote-list'."
834 (if (null pcomplete-arg-quote-list)
835 filename
836 (let ((index 0))
837 (mapconcat (lambda (c)
838 (prog1
839 (or (run-hook-with-args-until-success
840 'pcomplete-quote-arg-hook filename index)
841 (when (memq c pcomplete-arg-quote-list)
842 (string ?\\ c))
843 (char-to-string c))
844 (setq index (1+ index))))
845 filename
846 ""))))
847 796
848;; file-system completion lists 797;; file-system completion lists
849 798
@@ -1179,14 +1128,14 @@ Returns non-nil if a space was appended at the end."
1179 (if (not pcomplete-ignore-case) 1128 (if (not pcomplete-ignore-case)
1180 (insert-and-inherit (if raw-p 1129 (insert-and-inherit (if raw-p
1181 (substring entry (length stub)) 1130 (substring entry (length stub))
1182 (pcomplete-quote-argument 1131 (comint-quote-filename
1183 (substring entry (length stub))))) 1132 (substring entry (length stub)))))
1184 ;; the stub is not quoted at this time, so to determine the 1133 ;; the stub is not quoted at this time, so to determine the
1185 ;; length of what should be in the buffer, we must quote it 1134 ;; length of what should be in the buffer, we must quote it
1186 ;; FIXME: Here we presume that quoting `stub' gives us the exact 1135 ;; FIXME: Here we presume that quoting `stub' gives us the exact
1187 ;; text in the buffer before point, which is not guaranteed; 1136 ;; text in the buffer before point, which is not guaranteed;
1188 ;; e.g. it is not the case in eshell when completing ${FOO}tm[TAB]. 1137 ;; e.g. it is not the case in eshell when completing ${FOO}tm[TAB].
1189 (delete-char (- (length (pcomplete-quote-argument stub)))) 1138 (delete-char (- (length (comint-quote-filename stub))))
1190 ;; if there is already a backslash present to handle the first 1139 ;; if there is already a backslash present to handle the first
1191 ;; character, don't bother quoting it 1140 ;; character, don't bother quoting it
1192 (when (eq (char-before) ?\\) 1141 (when (eq (char-before) ?\\)
@@ -1194,7 +1143,7 @@ Returns non-nil if a space was appended at the end."
1194 (setq entry (substring entry 1))) 1143 (setq entry (substring entry 1)))
1195 (insert-and-inherit (if raw-p 1144 (insert-and-inherit (if raw-p
1196 entry 1145 entry
1197 (pcomplete-quote-argument entry)))) 1146 (comint-quote-filename entry))))
1198 (let (space-added) 1147 (let (space-added)
1199 (when (and (not (memq (char-before) pcomplete-suffix-list)) 1148 (when (and (not (memq (char-before) pcomplete-suffix-list))
1200 addsuffix) 1149 addsuffix)
@@ -1204,7 +1153,7 @@ Returns non-nil if a space was appended at the end."
1204 pcomplete-last-completion-stub stub) 1153 pcomplete-last-completion-stub stub)
1205 space-added))) 1154 space-added)))
1206 1155
1207;; selection of completions 1156;; Selection of completions.
1208 1157
1209(defun pcomplete-do-complete (stub completions) 1158(defun pcomplete-do-complete (stub completions)
1210 "Dynamically complete at point using STUB and COMPLETIONS. 1159 "Dynamically complete at point using STUB and COMPLETIONS.