emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r105984: * lisp/pcomplete.el: Require


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105984: * lisp/pcomplete.el: Require comint.
Date: Sun, 02 Oct 2011 00:08:50 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105984
fixes bug(s): http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9616
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2011-10-02 00:08:50 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/comint.el
  lisp/pcomplete.el
  src/ChangeLog
  src/dired.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-10-02 01:00:17 +0000
+++ b/lisp/ChangeLog    2011-10-02 04:08:50 +0000
@@ -1,5 +1,14 @@
 2011-10-02  Stefan Monnier  <address@hidden>
 
+       * 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.
+       * comint.el (comint-unquote-filename): Simplify.
+       (comint-completion-file-name-table): New function (bug#9616).
+       (comint--complete-file-name-data): Use it.
+
        * pcmpl-gnu.el (pcmpl-gnu-with-file-buffer): New macro (bug#9643).
        (pcmpl-gnu-tar-buffer): Remove.
        (pcmpl-gnu-with-file-buffer): Use it to avoid leaving the tar's buffer

=== modified file 'lisp/comint.el'
--- a/lisp/comint.el    2011-06-30 23:11:36 +0000
+++ b/lisp/comint.el    2011-10-02 04:08:50 +0000
@@ -3005,11 +3005,7 @@
   (if (null comint-file-name-quote-list)
       filename
     (save-match-data
-      (let ((i 0))
-       (while (string-match "\\\\\\(.\\)" filename i)
-         (setq filename (replace-match "\\1" nil nil filename))
-         (setq i (+ 1 (match-beginning 0)))))
-      filename)))
+      (replace-regexp-in-string "\\\\\\(.\\)" "\\1" filename t))))
 
 (defun comint-completion-at-point ()
   (run-hook-with-args-until-success 'comint-dynamic-complete-functions))
@@ -3057,6 +3053,7 @@
     (- (match-end 1) (match-beginning 1))))
 
 (defun comint--common-quoted-suffix (s1 s2)
+  ;; FIXME: Copied in pcomplete.el.
   "Find the common suffix between S1 and S2 where S1 is the expanded S2.
 S1 is expected to be the unquoted and expanded version of S1.
 Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
@@ -3117,6 +3114,24 @@
        ;; E.g. action=nil and it's the only completion.
        (res)))))
 
+(defun comint-completion-file-name-table (string pred action)
+  (if (not (file-name-absolute-p string))
+      (completion-file-name-table string pred action)
+    (cond
+     ((memq action '(t lambda))
+      (completion-file-name-table
+       (concat comint-file-name-prefix string) pred action))
+     ((null action)
+      (let ((res (completion-file-name-table
+                  (concat comint-file-name-prefix string) pred action)))
+        (if (and (stringp res)
+                 (string-match
+                  (concat "\\`" (regexp-quote comint-file-name-prefix))
+                  res))
+            (substring res (match-end 0))
+          res)))
+     (t (completion-file-name-table string pred action)))))
+
 (defun comint--complete-file-name-data ()
   "Return the completion data for file name at point."
   (let* ((filesuffix (cond ((not comint-completion-addsuffix) "")
@@ -3133,7 +3148,7 @@
                            unquoted filename)))
             (apply-partially
              #'comint--table-subvert
-             #'completion-file-name-table
+             #'comint-completion-file-name-table
              (cdr prefixes) (car prefixes)))))
     (nconc
      (list

=== modified file 'lisp/pcomplete.el'
--- a/lisp/pcomplete.el 2011-09-20 01:06:29 +0000
+++ b/lisp/pcomplete.el 2011-10-02 04:08:50 +0000
@@ -119,6 +119,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(require 'comint)
 
 (defgroup pcomplete nil
   "Programmable completion."
@@ -383,22 +384,14 @@
    (t
     (replace-regexp-in-string "\\\\\\(.\\)" "\\1" s t))))
 
-(defun pcomplete--common-suffix (s1 s2)
-  (assert (not (or (string-match "\n" s1) (string-match "\n" s2))))
-  ;; Since S2 is expected to be the "unquoted/expanded" version of S1,
-  ;; there shouldn't be any case difference, even if the completion is
-  ;; case-insensitive.
-  (let ((case-fold-search nil)) ;; pcomplete-ignore-case
-    (string-match ".*?\\(.*\\)\n.*\\1\\'" (concat s1 "\n" s2))
-    (- (match-end 1) (match-beginning 1))))
-
 (defun pcomplete--common-quoted-suffix (s1 s2)
+  ;; FIXME: Copied in comint.el.
   "Find the common suffix between S1 and S2 where S1 is the expanded S2.
 S1 is expected to be the unquoted and expanded version of S1.
 Returns (PS1 . PS2), i.e. the shortest prefixes of S1 and S2, such that
 S1 = (concat PS1 SS1) and S2 = (concat PS2 SS2) and
 SS1 = (unquote SS2)."
-  (let* ((cs (pcomplete--common-suffix s1 s2))
+  (let* ((cs (comint--common-suffix s1 s2))
          (ss1 (substring s1 (- (length s1) cs)))
          (qss1 (pcomplete-quote-argument ss1))
          qc)
@@ -416,6 +409,7 @@
             (substring s2 0 (- (length s2) cs))))))
 
 (defun pcomplete--table-subvert (table s1 s2 string pred action)
+  ;; FIXME: Copied in comint.el.
   "Completion table that replaces the prefix S1 with S2 in STRING.
 When TABLE, S1 and S2 are provided by `apply-partially', the result
 is a completion table which completes strings of the form (concat S1 S)
@@ -449,7 +443,9 @@
                     (mapcar (lambda (c)
                               (if (string-match re c)
                                   (substring c (match-end 0))))
-                            res))))))))))
+                            res))))))
+       ;; E.g. action=nil and it's the only completion.
+       (res)))))
 
 ;; I don't think such commands are usable before first setting up buffer-local
 ;; variables to parse args, so there's no point autoloading it.
@@ -928,7 +924,7 @@
                      ,@(cdr (completion-file-name-table s p a)))
         (let ((completion-ignored-extensions nil))
           (completion-table-with-predicate
-           'completion-file-name-table pred 'strict s p a))))))
+           #'comint-completion-file-name-table pred 'strict s p a))))))
 
 (defconst pcomplete--env-regexp
   
"\\(?:\\`\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(\\$\\(?:{\\([^}]+\\)}\\|\\(?2:[[:alnum:]_]+\\)\\)\\)")

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-10-02 00:25:27 +0000
+++ b/src/ChangeLog     2011-10-02 04:08:50 +0000
@@ -1,5 +1,9 @@
 2011-10-02  Stefan Monnier  <address@hidden>
 
+       * 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.
+
        * minibuf.c (Finternal_complete_buffer): Only show internal buffers if
        they've been requested explicitly (bug#9591).
 
@@ -86,8 +90,8 @@
        * xdisp.c (handle_invisible_prop): If invisible text ends on a
        newline, reseat the iterator instead of bidi-iterating there one
        character at a time.  (Bug#9610)
-       (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail out when
-       past TO_CHARPOS if the bidi iterator is at base embedding level.
+       (BUFFER_POS_REACHED_P, move_it_in_display_line_to): Bail when past
+       TO_CHARPOS if the bidi iterator is at base embedding level.
 
 2011-09-27  Andreas Schwab  <address@hidden>
 
@@ -124,9 +128,9 @@
        value is now t.  Doc fix.
 
        * indent.c (Fvertical_motion): Compute and apply the overshoot
-       logic also when moving up, not only when moving down.  Fix the
+       logic when moving up, not only when moving down.  Fix the
        confusing name and values of the it_overshoot_expected variable;
-       logic changed accordingly.  (Bug#9254) (Bug#9549)
+       logic changes accordingly.  (Bug#9254) (Bug#9549)
 
        * xdisp.c (pos_visible_p): Produce correct pixel coordinates when
        CHARPOS is covered by a display string which includes newlines.
@@ -142,7 +146,7 @@
 
 2011-09-24  Jim Meyering  <address@hidden>
 
-       Do not ignore write error for any output size.
+       do not ignore write error for any output size
        The previous change was incomplete.
        While it makes emacs --batch detect the vast majority of stdout
        write failures, errors were still ignored whenever the output size is

=== modified file 'src/dired.c'
--- a/src/dired.c       2011-09-09 01:06:52 +0000
+++ b/src/dired.c       2011-10-02 04:08:50 +0000
@@ -401,6 +401,7 @@
   (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate)
 {
   Lisp_Object handler;
+  directory = Fexpand_file_name (directory, Qnil);
 
   /* If the directory name has special constructs in it,
      call the corresponding file handler.  */
@@ -424,6 +425,7 @@
   (Lisp_Object file, Lisp_Object directory)
 {
   Lisp_Object handler;
+  directory = Fexpand_file_name (directory, Qnil);
 
   /* If the directory name has special constructs in it,
      call the corresponding file handler.  */
@@ -474,7 +476,6 @@
   bestmatch = Qnil;
   encoded_file = encoded_dir = Qnil;
   GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir);
-  dirname = Fexpand_file_name (dirname, Qnil);
   specbind (Qdefault_directory, dirname);
 
   /* Do completion on the encoded file name


reply via email to

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