emacs-diffs
[Top][All Lists]
Advanced

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

master a9d226dea4 2/2: Make anchored regexps work in image-dired-mark-ta


From: Lars Ingebrigtsen
Subject: master a9d226dea4 2/2: Make anchored regexps work in image-dired-mark-tagged-files
Date: Wed, 11 May 2022 20:52:07 -0400 (EDT)

branch: master
commit a9d226dea4d0cc190ab6d9dcc430e94b41115fc4
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make anchored regexps work in image-dired-mark-tagged-files
    
    * lisp/image-dired.el (image-dired-mark-tagged-files): Make
    anchored regexps work (bug#55375).
---
 lisp/image-dired.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index d8bd2937db..30bf5ee108 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -2261,23 +2261,26 @@ Optionally use old comment from FILE as initial value."
      comment)))
 
 ;;;###autoload
-(defun image-dired-mark-tagged-files ()
-  "Use regexp to mark files with matching tag.
+(defun image-dired-mark-tagged-files (regexp)
+  "Use REGEXP to mark files with matching tag.
 A `tag' is a keyword, a piece of meta data, associated with an
 image file and stored in image-dired's database file.  This command
 lets you input a regexp and this will be matched against all tags
 on all image files in the database file.  The files that have a
 matching tag will be marked in the Dired buffer."
-  (interactive)
+  (interactive "sMark tagged files (regexp): ")
   (image-dired-sane-db-file)
-  (let ((tag (read-string "Mark tagged files (regexp): "))
-        (hits 0)
+  (let ((hits 0)
         files)
     (image-dired--with-db-file
-     ;; Collect matches
-     (while (search-forward-regexp
-            (concat "\\(^[^;\n]+\\);.*" tag ".*$") nil t)
-       (push (match-string 1) files)))
+      ;; Collect matches
+      (while (search-forward-regexp "\\(^[^;\n]+\\);\\(.*\\)" nil t)
+        (let ((file (match-string 1))
+              (tags (split-string (match-string 2) ";")))
+          (when (seq-find (lambda (tag)
+                            (string-match-p regexp tag))
+                          tags)
+            (push file files)))))
     ;; Mark files
     (dolist (curr-file files)
       ;; I tried using `dired-mark-files-regexp' but it was waaaay to



reply via email to

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