all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tino Calancha <f92capac@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: Tino Calancha <f92capac@gmail.com>,
	Lars Ingebrigtsen <larsi@gnus.org>,
	22828@debbugs.gnu.org
Subject: bug#22828: 25.1.50; Mark symlinks whose target matches regexp
Date: Sun, 28 Feb 2016 19:38:19 +0900 (JST)	[thread overview]
Message-ID: <alpine.LRH.2.20.1602281925040.4261@calancha-ilc.kek.jp> (raw)
In-Reply-To: <m2wpppqhuc.fsf@linux-m68k.org>

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]



> Use dired-move-to-end-of-filename to find the proper place.
I see, this way we forget about the '@ -> ' or ' -> ' 
(or any other?).

Do you think is ok that fn contains such ' -> ' thing?
I would prefer if fn doesn't contain that.
So, the question is:
do we have a portable way to get the target of one link?
We may introduce something like:
dired-symlink-target (if doesn't exist)

[-- Attachment #2: Type: text/plain, Size: 2580 bytes --]

diff --git a/lisp/dired.el b/lisp/dired.el
index 6c7445c..6e70cd9 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1493,6 +1493,7 @@ dired-mode-map
     (define-key map "%d" 'dired-flag-files-regexp)
     (define-key map "%g" 'dired-mark-files-containing-regexp)
     (define-key map "%m" 'dired-mark-files-regexp)
+    (define-key map "%@" 'dired-mark-symlinks-regexp)
     (define-key map "%r" 'dired-do-rename-regexp)
     (define-key map "%C" 'dired-do-copy-regexp)
     (define-key map "%H" 'dired-do-hardlink-regexp)
@@ -1730,6 +1731,9 @@ dired-mode-map
     (define-key map [menu-bar regexp flag]
       '(menu-item "Flag..." dired-flag-files-regexp
 		  :help "Flag files matching regexp for deletion"))
+    (define-key map [menu-bar regexp mark-sym]
+      '(menu-item "Mark Symlinks Target..." dired-mark-symlinks-regexp
+		  :help "Mark symbolic links whose target matches regexp for future operations"))
     (define-key map [menu-bar regexp mark]
       '(menu-item "Mark..." dired-mark-files-regexp
 		  :help "Mark files matching regexp for future operations"))
@@ -3345,6 +3349,31 @@ dired-mark-files-regexp
 	    (and fn (string-match-p regexp fn))))
      "matching file")))
 
+(defun dired-mark-symlinks-regexp (regexp &optional marker-char)
+  "Mark all symbolic links whose target file matches REGEXP
+for use in later commands.
+A prefix argument means to unmark them instead.
+
+REGEXP is an Emacs regexp, not a shell wildcard.  Thus, use ‘\.o$’ for
+object files--just ‘.o’ will mark more than you might think."
+  (interactive
+   (list (read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
+                              " symlinks target (regexp): ")
+                      nil 'dired-regexp-history)
+         (if current-prefix-arg ?\040)))
+  (let ((dired-marker-char (or marker-char dired-marker-char)))
+    (dired-mark-if
+     (and (looking-at-p dired-re-sym)
+          (not (looking-at-p dired-re-dot))
+          (not (eolp))			; empty line
+          
+          (let* ((eol (line-end-position))
+                 (fn (save-excursion
+                       (and (dired-move-to-end-of-filename 'noerror)
+                            (buffer-substring-no-properties (point) eol)))))
+            (and fn (string-match-p regexp fn))))
+     "matching symbolic link")))
+
 (defun dired-mark-files-containing-regexp (regexp &optional marker-char)
   "Mark all files with contents containing REGEXP for use in later commands.
 A prefix argument means to unmark them instead.

  reply	other threads:[~2016-02-28 10:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-27 14:27 bug#22828: 25.1.50; Mark symlinks whose target matches regexp Tino Calancha
2016-02-28  5:36 ` Lars Ingebrigtsen
2016-02-28  6:48   ` Tino Calancha
2016-02-28  9:55     ` Andreas Schwab
2016-02-28 10:38       ` Tino Calancha [this message]
2016-02-29  2:18         ` Lars Ingebrigtsen
2016-03-01 11:12           ` Constantino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.20.1602281925040.4261@calancha-ilc.kek.jp \
    --to=f92capac@gmail.com \
    --cc=22828@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.