emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp ChangeLog files.el net/tramp-compat....


From: Michael Albinus
Subject: [Emacs-diffs] emacs/lisp ChangeLog files.el net/tramp-compat....
Date: Thu, 17 Dec 2009 13:18:08 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Michael Albinus <albinus>       09/12/17 13:18:07

Modified files:
        lisp           : ChangeLog files.el 
        lisp/net       : tramp-compat.el tramp.el 

Log message:
        * files.el (file-expand-wildcards): In case of remote files, check
        only local file name part for wildcards.  Provide feature 'files
        and subfeature 'remote-wildcards.  (Bug#5198)
        
        * net/tramp.el (tramp-handle-file-remote-p): Expand file name only
        if there is already an established connection.
        (tramp-advice-file-expand-wildcards): Remove it.
        
        * net/tramp-compat.el (top): Autoload `tramp-handle-file-remote-p'.
        (tramp-advice-file-expand-wildcards): Moved from tramp.el.
        Activate advice for older GNU Emacs versions.  (Bug#5237)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16913&r2=1.16914
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/files.el?cvsroot=emacs&r1=1.1103&r2=1.1104
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/net/tramp-compat.el?cvsroot=emacs&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/net/tramp.el?cvsroot=emacs&r1=1.276&r2=1.277

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16913
retrieving revision 1.16914
diff -u -b -r1.16913 -r1.16914
--- ChangeLog   17 Dec 2009 02:06:31 -0000      1.16913
+++ ChangeLog   17 Dec 2009 13:18:03 -0000      1.16914
@@ -1,3 +1,19 @@
+2009-12-17  Michael Albinus  <address@hidden>
+
+       Make `file-expand-wildcards' work for remote files.
+
+       * files.el (file-expand-wildcards): In case of remote files, check
+       only local file name part for wildcards.  Provide feature 'files
+       and subfeature 'remote-wildcards.  (Bug#5198)
+
+       * net/tramp.el (tramp-handle-file-remote-p): Expand file name only
+       if there is already an established connection.
+       (tramp-advice-file-expand-wildcards): Remove it.
+
+       * net/tramp-compat.el (top): Autoload `tramp-handle-file-remote-p'.
+       (tramp-advice-file-expand-wildcards): Moved from tramp.el.
+       Activate advice for older GNU Emacs versions.  (Bug#5237)
+
 2009-12-17  Juanma Barranquero  <address@hidden>
 
        Some doc fixes (more needed).

Index: files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.1103
retrieving revision 1.1104
diff -u -b -r1.1103 -r1.1104
--- files.el    17 Dec 2009 01:18:17 -0000      1.1103
+++ files.el    17 Dec 2009 13:18:06 -0000      1.1104
@@ -5365,7 +5365,10 @@
           ;; A list of all dirs that DIRPART specifies.
           ;; This can be more than one dir
           ;; if DIRPART contains wildcards.
-          (dirs (if (and dirpart (string-match "[[*?]" dirpart))
+          (dirs (if (and dirpart
+                         (string-match "[[*?]"
+                                       (or (file-remote-p dirpart 'localname)
+                                           dirpart)))
                     (mapcar 'file-name-as-directory
                             (file-expand-wildcards (directory-file-name 
dirpart)))
                   (list dirpart)))
@@ -5392,6 +5395,9 @@
        (setq dirs (cdr dirs)))
       contents)))
 
+;; Let Tramp know that `file-expand-wildcards' does not need an advice.
+(provide 'files '(remote-wildcards))
+
 (defun list-directory (dirname &optional verbose)
   "Display a list of files in or matching DIRNAME, a la `ls'.
 DIRNAME is globbed by the shell if necessary.

Index: net/tramp-compat.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp-compat.el,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- net/tramp-compat.el 7 Nov 2009 23:51:17 -0000       1.18
+++ net/tramp-compat.el 17 Dec 2009 13:18:06 -0000      1.19
@@ -44,6 +44,7 @@
 
   (autoload 'tramp-tramp-file-p "tramp")
   (autoload 'tramp-file-name-handler "tramp")
+  (autoload 'tramp-handle-file-remote-p "tramp")
 
   ;; tramp-util offers integration into other (X)Emacs packages like
   ;; compile.el, gud.el etc.  Not necessary in Emacs 23.
@@ -143,7 +144,35 @@
       (lambda (filename &optional time)
        (when (tramp-tramp-file-p filename)
          (tramp-file-name-handler
-          'set-file-times filename time))))))
+          'set-file-times filename time)))))
+
+  ;; We currently use "[" and "]" in the filename format for IPv6
+  ;; hosts of GNU Emacs.  This means, that Emacs wants to expand
+  ;; wildcards if `find-file-wildcards' is non-nil, and then barfs
+  ;; because no expansion could be found.  We detect this situation
+  ;; and do something really awful: we have `file-expand-wildcards'
+  ;; return the original filename if it can't expand anything.  Let's
+  ;; just hope that this doesn't break anything else.
+  ;; It is not needed anymore since GNU Emacs 23.2.
+  (unless (or (featurep 'xemacs) (featurep 'files 'remote-wildcards))
+    (defadvice file-expand-wildcards
+      (around tramp-advice-file-expand-wildcards activate)
+      (let ((name (ad-get-arg 0)))
+       ;; If it's a Tramp file, look if wildcards need to be expanded
+       ;; at all.
+       (if (and
+            (tramp-tramp-file-p name)
+            (not (string-match
+                  "[[*?]" (tramp-handle-file-remote-p name 'localname))))
+           (setq ad-return-value (list name))
+         ;; Otherwise, just run the original function.
+         ad-do-it)))
+    (add-hook
+     'tramp-unload-hook
+     (lambda ()
+       (ad-remove-advice
+       'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards)
+       (ad-activate 'file-expand-wildcards)))))
 
 (defsubst tramp-compat-line-beginning-position ()
   "Return point at beginning of line (compat function).

Index: net/tramp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp.el,v
retrieving revision 1.276
retrieving revision 1.277
diff -u -b -r1.276 -r1.277
--- net/tramp.el        15 Dec 2009 21:11:42 -0000      1.276
+++ net/tramp.el        17 Dec 2009 13:18:06 -0000      1.277
@@ -4647,16 +4647,19 @@
 (defun tramp-handle-file-remote-p (filename &optional identification connected)
   "Like `file-remote-p' for Tramp files."
   (when (tramp-tramp-file-p filename)
-    (with-parsed-tramp-file-name (expand-file-name filename) nil
-      (and (or (not connected)
-              (let ((p (tramp-get-connection-process v)))
-                (and p (processp p) (memq (process-status p) '(run open)))))
+    (let* ((v (tramp-dissect-file-name filename))
+          (p (tramp-get-connection-process v))
+          (c (and p (processp p) (memq (process-status p) '(run open)))))
+      ;; We expand the file name only, if there is already a connection.
+      (with-parsed-tramp-file-name
+         (if c (expand-file-name filename) filename) nil
+       (and (or (not connected) c)
           (cond
            ((eq identification 'method) method)
            ((eq identification 'user) user)
            ((eq identification 'host) host)
            ((eq identification 'localname) localname)
-           (t (tramp-make-tramp-file-name method user host "")))))))
+             (t (tramp-make-tramp-file-name method user host ""))))))))
 
 (defun tramp-find-file-name-coding-system-alist (filename tmpname)
   "Like `find-operation-coding-system' for Tramp filenames.
@@ -8429,36 +8432,6 @@
                                      t t result)))
        result))))
 
-;; We currently (sometimes) use "[" and "]" in the filename format.
-;; This means that Emacs wants to expand wildcards if
-;; `find-file-wildcards' is non-nil, and then barfs because no
-;; expansion could be found.  We detect this situation and do
-;; something really awful: we have `file-expand-wildcards' return the
-;; original filename if it can't expand anything.  Let's just hope
-;; that this doesn't break anything else.
-;; CCC: This check is now also really awful; we should search all
-;; of the filename format, not just the prefix.
-(when (string-match "\\[" tramp-prefix-format)
-  (defadvice file-expand-wildcards
-    (around tramp-advice-file-expand-wildcards activate)
-    (let ((name (ad-get-arg 0)))
-      ;; If it's a Tramp file, dissect it and look if wildcards need
-      ;; to be expanded at all.
-      (if (and
-          (tramp-tramp-file-p name)
-          (not (string-match
-                "[[*?]"
-                (tramp-file-name-localname (tramp-dissect-file-name name)))))
-         (setq ad-return-value (list name))
-       ;; Otherwise, just run the original function.
-       ad-do-it)))
-  (add-hook
-   'tramp-unload-hook
-   (lambda ()
-     (ad-remove-advice
-      'file-expand-wildcards 'around 'tramp-advice-file-expand-wildcards)
-     (ad-activate 'file-expand-wildcards))))
-
 ;; Checklist for `tramp-unload-hook'
 ;; - Unload all `tramp-*' packages
 ;; - Reset `file-name-handler-alist'




reply via email to

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