From 9233c47071d4e65cd767572a9761dbe868e8f4f2 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sun, 10 Apr 2022 13:08:50 +0800 Subject: bookmark-conf: use `file-remote-p' to get host and user * bookmark-conf.el ("ilist-automatic-group-durand"): Instead of using a hand-made regular expression for determining the user and the host of the remote file name, use the function `file-remote-p'. This is quite necessary since the Tramp syntax might vary according to the style used. It is best to use an official function. --- bookmark-conf.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/bookmark-conf.el b/bookmark-conf.el index 32a102d..4e3aa5a 100644 --- a/bookmark-conf.el +++ b/bookmark-conf.el @@ -116,19 +116,20 @@ (cond ((and (stringp location) (not (string= location "")) - (string-match (rx bos "/ssh:" - (group (1+ (not ":"))) - (zero-or-more - (and "|" - (1+ (not ":")) - ":" - (1+ (not ":")))) - ":" - (1+ (not ":")) - eos) - location)) + (file-remote-p location)) (setq handler-name - (concat "Tramp - " (match-string 1 location))) + (concat "Tramp - " + (format + "%s%s" + (cond + ((file-remote-p location 'user) + (concat + (file-remote-p location 'user) + "@")) + ("")) + (cond + ((file-remote-p location 'host)) + (""))))) (setq capitalize-p nil))) ;; take case of file extensions (cond -- cgit v1.2.3-18-g5258