From 2163c4c3894272d2022e5fb78d2c0be1310d9da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20M=C3=BCnster?= Date: Wed, 18 Aug 2021 02:02:02 +0200 Subject: [PATCH 5/6] Avoid problems when one tag/file is a substring of another * lisp/image-dired.el (image-dired-remove-tag): End of filename is bound by ";" and end of tag is bound by ";" or end of line. --- lisp/image-dired.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 428b20d6eb..5ee66b0e90 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -1110,11 +1110,12 @@ image-dired-remove-tag (error "Files must be a string or a list of strings!"))) (dolist (file files) (goto-char (point-min)) - (when (search-forward-regexp (format "^%s" file) nil t) + (when (search-forward-regexp (format "^%s;" file) nil t) (end-of-line) (setq end (point)) (beginning-of-line) - (when (search-forward-regexp (format "\\(;%s\\)" tag) end t) + (when (search-forward-regexp + (format "\\(;%s\\)\\($\\|;\\)" tag) end t) (delete-region (match-beginning 1) (match-end 1)) ;; Check if file should still be in the database. If ;; it has no tags or comments, it will be removed. -- 2.26.2