diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-05-12 02:51:53 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-05-12 02:51:53 +0200 |
commit | a9d226dea4d0cc190ab6d9dcc430e94b41115fc4 (patch) | |
tree | 25b4b0d02061bcb884b3248b2f0f2da93285a319 /lisp/image-dired.el | |
parent | dcbe8267834dca80e94d4f96d61e76517e8c0022 (diff) | |
download | emacs-a9d226dea4d0cc190ab6d9dcc430e94b41115fc4.tar.gz |
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).
Diffstat (limited to 'lisp/image-dired.el')
-rw-r--r-- | lisp/image-dired.el | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index d8bd2937db8..30bf5ee1086 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 |