Subject: bug#43028: 28.0.50; Add dired commands to navigate symbolic links

From: Tino Calancha <[email-masked]>
Date: Mon, 24 Aug 2020 21:12:25 +0200

X-Debbugs-Cc: [email-masked], [email-masked],
[email-masked], [email-masked], [email-masked]
Severity: wishlist

How do you feel about adding these new navigators and bind them to
'{' '}' ?

--8<-----------------------------cut here---------------start------------->8---
commit 98e474b5b3be644d6cdff8aaf3b2d917ca4cea56
Author: Tino Calancha <[email-masked]>
Date:   Mon Aug 24 20:56:27 2020 +0200

    New dired commands to navigate symbolic links
    
    Like dired-prev-dirline and dired-next-dirline
    but for symbolic links.
    
    * lisp/dired.el (dired-prev-symlinkline, dired-next-symlinkline):
    New commands.
    (dired-mode-map): Bind them to '{' and '}'.  Add menu entries for them.
    
    * doc/emacs/dired.texi (Dired Navigation): Document them.
    
    * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1):
    Announce them.

diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 19aaca962d..92c1214cb4 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -177,6 +177,16 @@ Dired Navigation
 minibuffer, and moves point to the line in the Dired buffer describing
 that file.
 
+@findex dired-prev-symlinkline
+@kindex @{ @r{(Dired)}
+  @kbd{@{} (@code{dired-prev-symlinkline}) jumps to the previous
+  symbolic link in the Dired buffer.
+
+@findex dired-next-symlinkline
+@kindex @} @r{(Dired)}
+  @kbd{@}} (@code{dired-next-symlinkline}) jumps to the next
+  symbolic link in the Dired buffer.
+
 @cindex searching Dired buffers
 @findex dired-isearch-filenames
 @vindex dired-isearch-filenames
diff --git a/etc/NEWS b/etc/NEWS
index a65852fcd0..5785cdc1e5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -235,6 +235,10 @@ time zones will use a form like "+0100" instead of "CET".
 
 ** Dired
 
++++
+*** New commands 'dired-prev-symlinkline', 'dired-next-symlinkline' to visit
+symbolic links in the current dired buffer, bound respectively to '{' '}'.
+
 +++
 *** New user option 'dired-maybe-use-globstar'.
 If set, enables globstar (recursive globbing) in shells that support
diff --git a/lisp/dired.el b/lisp/dired.el
index 94d3befda8..273e787af0 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1898,6 +1898,8 @@ dired-mode-map
     ;; moving
     (define-key map "<" 'dired-prev-dirline)
     (define-key map ">" 'dired-next-dirline)
+    (define-key map "}" 'dired-next-symlinkline)
+    (define-key map "{" 'dired-prev-symlinkline)
     (define-key map "^" 'dired-up-directory)
     (define-key map " " 'dired-next-line)
     (define-key map [?\S-\ ] 'dired-previous-line)
@@ -2039,6 +2041,12 @@ dired-mode-map
     (define-key map [menu-bar immediate find-file]
       '(menu-item "Find This File" dired-find-file
 		  :help "Edit file at cursor"))
+    (define-key map [menu-bar immediate prev-symlink]
+      '(menu-item "Prev Symlink" dired-prev-symlinkline
+		  :help "Move to next symbolic link line"))
+    (define-key map [menu-bar immediate next-symlink]
+      '(menu-item "Next Symlink" dired-next-symlinkline
+		  :help "Move to previous symbolic link line"))
     (define-key map [menu-bar immediate create-directory]
       '(menu-item "Create Directory..." dired-create-directory
 		  :help "Create a directory"))
@@ -2431,6 +2439,23 @@ dired-prev-dirline
   (interactive "p")
   (dired-next-dirline (- arg)))
 
+(defun dired-next-symlinkline (arg &optional opoint)
+  "Goto ARGth next symbolic link file line."
+  (interactive "p")
+  (or opoint (setq opoint (point)))
+  (if (if (> arg 0)
+	  (re-search-forward dired-re-sym nil t arg)
+	(beginning-of-line)
+	(re-search-backward dired-re-sym nil t (- arg)))
+      (dired-move-to-filename)		; user may type `i' or `f'
+    (goto-char opoint)
+    (error "No more symlinks")))
+
+(defun dired-prev-symlinkline (arg)
+  "Goto ARGth previous symbolic link file line."
+  (interactive "p")
+  (dired-next-symlinkline (- arg)))
+
 (defun dired-up-directory (&optional other-window)
   "Run Dired on parent directory of current directory.
 Find the parent directory either in this buffer or another buffer.

--8<-----------------------------cut here---------------end--------------->8---

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2020-08-19 built on localhost.example.com
Repository revision: 88795c52ff13203dda5940ed5defc26ce2c20e5e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: openSUSE Tumbleweed