aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-10-02 00:08:50 -0400
committerStefan Monnier2011-10-02 00:08:50 -0400
commit32c1fffd728cfed8427d144bf7c622257aad859f (patch)
treed732c10ec70d78c49fdebc23b32c2ccf0a35ce66
parentb0e2675c7f28f729354abc1d471af9934899852d (diff)
downloademacs-32c1fffd728cfed8427d144bf7c622257aad859f.tar.gz
emacs-32c1fffd728cfed8427d144bf7c622257aad859f.zip
* lisp/pcomplete.el: Require comint.
(pcomplete--common-suffix): Remove. (pcomplete--common-quoted-suffix): Use comint--common-suffix instead. (pcomplete--table-subvert): Sync with comint--table-subvert. (pcomplete--entries): Use comint-completion-file-name-table. * lisp/comint.el (comint-unquote-filename): Simplify. (comint-completion-file-name-table): New function. (comint--complete-file-name-data): Use it. * src/dired.c (file_name_completion): Don't expand file name. (Ffile_name_completion, Ffile_name_all_completions): Expand file name before checking file name handler. Fixes: debbugs:9616
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/comint.el27
-rw-r--r--lisp/pcomplete.el20
-rw-r--r--src/ChangeLog14
-rw-r--r--src/dired.c3
5 files changed, 49 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f170cbd37c5..efe1d4b4a42 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,14 @@
12011-10-02 Stefan Monnier <monnier@iro.umontreal.ca> 12011-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * pcomplete.el: Require comint.
4 (pcomplete--common-suffix): Remove.
5 (pcomplete--common-quoted-suffix): Use comint--common-suffix instead.
6 (pcomplete--table-subvert): Sync with comint--table-subvert.
7 (pcomplete--entries): Use comint-completion-file-name-table.
8 * comint.el (comint-unquote-filename): Simplify.
9 (comint-completion-file-name-table): New function (bug#9616).
10 (comint--complete-file-name-data): Use it.
11
3 * pcmpl-gnu.el (pcmpl-gnu-with-file-buffer): New macro (bug#9643). 12 * pcmpl-gnu.el (pcmpl-gnu-with-file-buffer): New macro (bug#9643).
4 (pcmpl-gnu-tar-buffer): Remove. 13 (pcmpl-gnu-tar-buffer): Remove.
5 (pcmpl-gnu-with-file-buffer): Use it to avoid leaving the tar's buffer 14 (pcmpl-gnu-with-file-buffer): Use it to avoid leaving the tar's buffer
diff --git a/lisp/comint.el b/lisp/comint.el
index 2349fc0edd9..59feab82e44 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -3005,11 +3005,7 @@ Magic characters are those in `comint-file-name-quote-list'."
3005 (if (null comint-file-name-quote-list) 3005 (if (null comint-file-name-quote-list)
3006 filename 3006 filename
3007 (save-match-data 3007 (save-match-data
3008 (let ((i 0)) 3008 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t))))
3009 (while (string-match "\\\\\\(.\\)" filename i)
3010 (setq filename (replace-match "\\1" nil nil filename))
3011 (setq i (+ 1 (match-beginning 0)))))
3012 filename)))
3013 3009
3014(defun comint-completion-at-point () 3010(defun comint-completion-at-point ()
3015 (run-hook-with-args-until-success 'comint-dynamic-complete-functions)) 3011 (run-hook-with-args-until-success 'comint-dynamic-complete-functions))
@@ -3057,6 +3053,7 @@ Returns t if successful."
3057 (- (match-end 1) (match-beginning 1)))) 3053 (- (match-end 1) (match-beginning 1))))
3058 3054
3059(defun comint--common-quoted-suffix (s1 s2) 3055(defun comint--common-quoted-suffix (s1 s2)
3056 ;; FIXME: Copied in pcomplete.el.
3060 "Find the common suffix between S1 and S2 where S1 is the expanded S2. 3057 "Find the common suffix between S1 and S2 where S1 is the expanded S2.
3061S1 is expected to be the unquoted and expanded version of S1. 3058S1 is expected to be the unquoted and expanded version of S1.
3062Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that 3059Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
@@ -3117,6 +3114,24 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
3117 ;; E.g. action=nil and it's the only completion. 3114 ;; E.g. action=nil and it's the only completion.
3118 (res))))) 3115 (res)))))
3119 3116
3117(defun comint-completion-file-name-table (string pred action)
3118 (if (not (file-name-absolute-p string))
3119 (completion-file-name-table string pred action)
3120 (cond
3121 ((memq action '(t lambda))
3122 (completion-file-name-table
3123 (concat comint-file-name-prefix string) pred action))
3124 ((null action)
3125 (let ((res (completion-file-name-table
3126 (concat comint-file-name-prefix string) pred action)))
3127 (if (and (stringp res)
3128 (string-match
3129 (concat "\\`" (regexp-quote comint-file-name-prefix))
3130 res))
3131 (substring res (match-end 0))
3132 res)))
3133 (t (completion-file-name-table string pred action)))))
3134
3120(defun comint--complete-file-name-data () 3135(defun comint--complete-file-name-data ()
3121 "Return the completion data for file name at point." 3136 "Return the completion data for file name at point."
3122 (let* ((filesuffix (cond ((not comint-completion-addsuffix) "") 3137 (let* ((filesuffix (cond ((not comint-completion-addsuffix) "")
@@ -3133,7 +3148,7 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
3133 unquoted filename))) 3148 unquoted filename)))
3134 (apply-partially 3149 (apply-partially
3135 #'comint--table-subvert 3150 #'comint--table-subvert
3136 #'completion-file-name-table 3151 #'comint-completion-file-name-table
3137 (cdr prefixes) (car prefixes))))) 3152 (cdr prefixes) (car prefixes)))))
3138 (nconc 3153 (nconc
3139 (list 3154 (list
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 1a95fb28206..4ac69df8e3a 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -119,6 +119,7 @@
119;;; Code: 119;;; Code:
120 120
121(eval-when-compile (require 'cl)) 121(eval-when-compile (require 'cl))
122(require 'comint)
122 123
123(defgroup pcomplete nil 124(defgroup pcomplete nil
124 "Programmable completion." 125 "Programmable completion."
@@ -383,22 +384,14 @@ modified to be an empty string, or the desired separation string."
383 (t 384 (t
384 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" s t)))) 385 (replace-regexp-in-string "\\\\\\(.\\)" "\\1" s t))))
385 386
386(defun pcomplete--common-suffix (s1 s2)
387 (assert (not (or (string-match "\n" s1) (string-match "\n" s2))))
388 ;; Since S2 is expected to be the "unquoted/expanded" version of S1,
389 ;; there shouldn't be any case difference, even if the completion is
390 ;; case-insensitive.
391 (let ((case-fold-search nil)) ;; pcomplete-ignore-case
392 (string-match ".*?\\(.*\\)\n.*\\1\\'" (concat s1 "\n" s2))
393 (- (match-end 1) (match-beginning 1))))
394
395(defun pcomplete--common-quoted-suffix (s1 s2) 387(defun pcomplete--common-quoted-suffix (s1 s2)
388 ;; FIXME: Copied in comint.el.
396 "Find the common suffix between S1 and S2 where S1 is the expanded S2. 389 "Find the common suffix between S1 and S2 where S1 is the expanded S2.
397S1 is expected to be the unquoted and expanded version of S1. 390S1 is expected to be the unquoted and expanded version of S1.
398Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that 391Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
399S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and 392S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and
400SS1 = (unquote SS2)." 393SS1 = (unquote SS2)."
401 (let* ((cs (pcomplete--common-suffix s1 s2)) 394 (let* ((cs (comint--common-suffix s1 s2))
402 (ss1 (substring s1 (- (length s1) cs))) 395 (ss1 (substring s1 (- (length s1) cs)))
403 (qss1 (pcomplete-quote-argument ss1)) 396 (qss1 (pcomplete-quote-argument ss1))
404 qc) 397 qc)
@@ -416,6 +409,7 @@ SS1 = (unquote SS2)."
416 (substring s2 0 (- (length s2) cs)))))) 409 (substring s2 0 (- (length s2) cs))))))
417 410
418(defun pcomplete--table-subvert (table s1 s2 string pred action) 411(defun pcomplete--table-subvert (table s1 s2 string pred action)
412 ;; FIXME: Copied in comint.el.
419 "Completion table that replaces the prefix S1 with S2 in STRING. 413 "Completion table that replaces the prefix S1 with S2 in STRING.
420When TABLE, S1 and S2 are provided by `apply-partially', the result 414When TABLE, S1 and S2 are provided by `apply-partially', the result
421is a completion table which completes strings of the form (concat S1 S) 415is a completion table which completes strings of the form (concat S1 S)
@@ -449,7 +443,9 @@ in the same way as TABLE completes strings of the form (concat S2 S)."
449 (mapcar (lambda (c) 443 (mapcar (lambda (c)
450 (if (string-match re c) 444 (if (string-match re c)
451 (substring c (match-end 0)))) 445 (substring c (match-end 0))))
452 res)))))))))) 446 res))))))
447 ;; E.g. action=nil and it's the only completion.
448 (res)))))
453 449
454;; I don't think such commands are usable before first setting up buffer-local 450;; I don't think such commands are usable before first setting up buffer-local
455;; variables to parse args, so there's no point autoloading it. 451;; variables to parse args, so there's no point autoloading it.
@@ -928,7 +924,7 @@ Magic characters are those in `pcomplete-arg-quote-list'."
928 ,@(cdr (completion-file-name-table s p a))) 924 ,@(cdr (completion-file-name-table s p a)))
929 (let ((completion-ignored-extensions nil)) 925 (let ((completion-ignored-extensions nil))
930 (completion-table-with-predicate 926 (completion-table-with-predicate
931 'completion-file-name-table pred 'strict s p a)))))) 927 #'comint-completion-file-name-table pred 'strict s p a))))))
932 928
933(defconst pcomplete--env-regexp 929(defconst pcomplete--env-regexp
934 "\\(?:\\`\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(\\$\\(?:{\\([^}]+\\)}\\|\\(?2:[[:alnum:]_]+\\)\\)\\)") 930 "\\(?:\\`\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(\\$\\(?:{\\([^}]+\\)}\\|\\(?2:[[:alnum:]_]+\\)\\)\\)")
diff --git a/src/ChangeLog b/src/ChangeLog
index fc9a839a25b..bc9ffc8f3fe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12011-10-02 Stefan Monnier <monnier@iro.umontreal.ca> 12011-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * dired.c (file_name_completion): Don't expand file name.
4 (Ffile_name_completion, Ffile_name_all_completions): Expand file name
5 before checking file name handler.
6
3 * minibuf.c (Finternal_complete_buffer): Only show internal buffers if 7 * minibuf.c (Finternal_complete_buffer): Only show internal buffers if
4 they've been requested explicitly (bug#9591). 8 they've been requested explicitly (bug#9591).
5 9
@@ -86,8 +90,8 @@
86 * xdisp.c (handle_invisible_prop): If invisible text ends on a 90 * xdisp.c (handle_invisible_prop): If invisible text ends on a
87 newline, reseat the iterator instead of bidi-iterating there one 91 newline, reseat the iterator instead of bidi-iterating there one
88 character at a time. (Bug#9610) 92 character at a time. (Bug#9610)
89 (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail out when 93 (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail when past
90 past TO_CHARPOS if the bidi iterator is at base embedding level. 94 TO_CHARPOS if the bidi iterator is at base embedding level.
91 95
922011-09-27 Andreas Schwab <schwab@linux-m68k.org> 962011-09-27 Andreas Schwab <schwab@linux-m68k.org>
93 97
@@ -124,9 +128,9 @@
124 value is now t. Doc fix. 128 value is now t. Doc fix.
125 129
126 * indent.c (Fvertical_motion): Compute and apply the overshoot 130 * indent.c (Fvertical_motion): Compute and apply the overshoot
127 logic also when moving up, not only when moving down. Fix the 131 logic when moving up, not only when moving down. Fix the
128 confusing name and values of the it_overshoot_expected variable; 132 confusing name and values of the it_overshoot_expected variable;
129 logic changed accordingly. (Bug#9254) (Bug#9549) 133 logic changes accordingly. (Bug#9254) (Bug#9549)
130 134
131 * xdisp.c (pos_visible_p): Produce correct pixel coordinates when 135 * xdisp.c (pos_visible_p): Produce correct pixel coordinates when
132 CHARPOS is covered by a display string which includes newlines. 136 CHARPOS is covered by a display string which includes newlines.
@@ -142,7 +146,7 @@
142 146
1432011-09-24 Jim Meyering <meyering@redhat.com> 1472011-09-24 Jim Meyering <meyering@redhat.com>
144 148
145 Do not ignore write error for any output size. 149 do not ignore write error for any output size
146 The previous change was incomplete. 150 The previous change was incomplete.
147 While it makes emacs --batch detect the vast majority of stdout 151 While it makes emacs --batch detect the vast majority of stdout
148 write failures, errors were still ignored whenever the output size is 152 write failures, errors were still ignored whenever the output size is
diff --git a/src/dired.c b/src/dired.c
index be94b16cf75..fac3a34ab9b 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -401,6 +401,7 @@ determined by the variable `completion-ignored-extensions', which see. */)
401 (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate) 401 (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate)
402{ 402{
403 Lisp_Object handler; 403 Lisp_Object handler;
404 directory = Fexpand_file_name (directory, Qnil);
404 405
405 /* If the directory name has special constructs in it, 406 /* If the directory name has special constructs in it,
406 call the corresponding file handler. */ 407 call the corresponding file handler. */
@@ -424,6 +425,7 @@ These are all file names in directory DIRECTORY which begin with FILE. */)
424 (Lisp_Object file, Lisp_Object directory) 425 (Lisp_Object file, Lisp_Object directory)
425{ 426{
426 Lisp_Object handler; 427 Lisp_Object handler;
428 directory = Fexpand_file_name (directory, Qnil);
427 429
428 /* If the directory name has special constructs in it, 430 /* If the directory name has special constructs in it,
429 call the corresponding file handler. */ 431 call the corresponding file handler. */
@@ -474,7 +476,6 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
474 bestmatch = Qnil; 476 bestmatch = Qnil;
475 encoded_file = encoded_dir = Qnil; 477 encoded_file = encoded_dir = Qnil;
476 GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir); 478 GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir);
477 dirname = Fexpand_file_name (dirname, Qnil);
478 specbind (Qdefault_directory, dirname); 479 specbind (Qdefault_directory, dirname);
479 480
480 /* Do completion on the encoded file name 481 /* Do completion on the encoded file name