emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] scratch/hyperbole-merge-7.0.2b 450489e 13/23: Adjust tramp-file-n


From: Stefan Monnier
Subject: [elpa] scratch/hyperbole-merge-7.0.2b 450489e 13/23: Adjust tramp-file-name-regexp to work with looking-at
Date: Tue, 5 Feb 2019 16:11:20 -0500 (EST)

branch: scratch/hyperbole-merge-7.0.2b
commit 450489ed67a192bde6504370f2fdf850c54ea7e4
Author: Mats Lidell <address@hidden>
Commit: Mats Lidell <address@hidden>

    Adjust tramp-file-name-regexp to work with looking-at
    
    Recent updates to tramp have introduced an ending match of empty
    string that does not work together with looking-at as used in
    hpath.
    
    A promising alternative to this change would be to use file-remote-p
    in combination with a regexp that finds a possible filename after
    point. This would remove the dependency on the internal regexp in
    tramp.
---
 hpath.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/hpath.el b/hpath.el
index d26678d..9e076e9 100644
--- a/hpath.el
+++ b/hpath.el
@@ -4,7 +4,7 @@
 ;;
 ;; Orig-Date:     1-Nov-91 at 00:44:23
 ;;
-;; Copyright (C) 1991-2016  Free Software Foundation, Inc.
+;; Copyright (C) 1991-2016, 2018  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -372,6 +372,15 @@ directories.  The first one in which PATH is found is 
used."
          (or (file-exists-p rtn) (setq rtn nil)))
        (or rtn path)))))
 
+(defun hpath:tramp-file-name-regexp ()
+  "Returns a modified tramp-file-name-regexp used for checking if
+point is at the beginning of a remote file name.  Removes match
+to bol and remove match to empty string if present."
+  (let ((tramp-regexp (car (if (fboundp 'tramp-file-name-structure)
+                              (tramp-file-name-structure)
+                            tramp-file-name-structure))))
+    (substring-no-properties (replace-regexp-in-string "\\\\'" "" 
tramp-regexp) 1)))
+
 (defun hpath:remote-at-p ()
   "Returns a remote pathname that point is within or nil.
 See the `(emacs)Remote Files' info documentation for pathname format details.
@@ -385,10 +394,7 @@ Always returns nil if (hpath:remote-available-p) returns 
nil."
              (skip-chars-backward "^[ \t\n\r\f\"`'|\(\{<")
              (cond
               ((and (eq remote-package 'tramp)
-                    ;; Remove match to bol in this regexp before testing.
-                    (looking-at (substring-no-properties (car (if (fboundp 
'tramp-file-name-structure)
-                                                                  
(tramp-file-name-structure)
-                                                                
tramp-file-name-structure)) 1)))
+                    (looking-at (hpath:tramp-file-name-regexp)))
                (match-string-no-properties 0))
               ((looking-at hpath:url-regexp)
                (if (string-equal (match-string-no-properties 
hpath:protocol-grpn) "ftp")



reply via email to

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