From d4c144f64b69e466a78ee2d195467d1efb35c57a Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 9 Apr 2022 22:45:50 +0800 Subject: bookmark-conf: automatic grouping of Tramp bookmarks * bookmark-conf.el ("ilist-automatic-group-durand"): Now this automatic grouping function understands the syntax of Tramp buffers (for ssh only, though) and will group Tramp bookmarks according to the remote server name, like root@jsdurand.xyz, or git@jsdurand.xyz. I start to think that Tramp is the best invention since the slice of bread now. --- bookmark-conf.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bookmark-conf.el') diff --git a/bookmark-conf.el b/bookmark-conf.el index 7faa7c5..1b880f7 100644 --- a/bookmark-conf.el +++ b/bookmark-conf.el @@ -100,7 +100,8 @@ (save-match-data (let* ((handler (bookmark-get-handler element)) (handler-name (and handler (format "%S" handler))) - (location (bookmark-location element))) + (location (bookmark-location element)) + (capitalize-p t)) ;; replace repeating parts (cond ((and handler-name @@ -111,6 +112,14 @@ "^durand-" "" (replace-regexp-in-string "-bookmark$" "" (match-string 1 handler-name)))))) + ;; Tramp bookmarks + (cond + ((and (stringp location) + (not (string= location "")) + (string-match (rx bos "/ssh:" (group (1+ (not ":"))) ":" (1+ (not ":")) eos) location)) + (setq handler-name + (concat "Tramp - " (match-string 1 location))) + (setq capitalize-p nil))) ;; take case of file extensions (cond ((and (null handler-name) location @@ -120,7 +129,8 @@ (handler-name (cond ((<= (length handler-name) 3) (upcase handler-name)) - ((capitalize handler-name)))))))) + (capitalize-p (capitalize handler-name)) + (handler-name))))))) (setq blist-automatic-filter-groups #'ilist-automatic-group-durand) -- cgit v1.2.3-18-g5258