From 364beec6d1470712415a36f5810e4f7d320c6b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20M=C3=BCnster?= Date: Wed, 18 Aug 2021 11:21:51 +0200 Subject: [PATCH 6/6] Add support for history of image tags and completion in the minibuffer * lisp/image-dired.el (image-dired-tag-history): New variable holding the tag history. (image-dired-tag-files, image-dired-tag-thumbnail, image-dired-delete-tag) (image-dired-tag-thumbnail-remove): Use it for the user input. --- lisp/image-dired.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 5ee66b0e90..5a332964d5 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -652,6 +652,8 @@ image-dired-queue-active-limit "Maximum number of concurrent jobs permitted for generating images. Increase at own risk.") +(defvar image-dired-tag-history nil "Variable holding the tag history.") + (defun image-dired-pngnq-thumb (spec) "Quantize thumbnail described by format SPEC with pngnq(1)." (let ((process @@ -1146,7 +1148,9 @@ image-dired-list-tags (defun image-dired-tag-files (arg) "Tag marked file(s) in dired. With prefix ARG, tag file at point." (interactive "P") - (let ((tag (read-string "Tags to add (separate tags with a semicolon): ")) + (let ((tag (completing-read + "Tags to add (separate tags with a semicolon): " + image-dired-tag-history nil nil nil 'image-dired-tag-history)) files) (if arg (setq files (list (dired-get-filename))) @@ -1160,7 +1164,9 @@ image-dired-tag-files (defun image-dired-tag-thumbnail () "Tag current or marked thumbnails." (interactive) - (let ((tag (read-string "Tags to add (separate tags with a semicolon): "))) + (let ((tag (completing-read + "Tags to add (separate tags with a semicolon): " + image-dired-tag-history nil nil nil 'image-dired-tag-history))) (image-dired--with-marked (image-dired-write-tags (list (cons (image-dired-original-file-name) tag))) @@ -1172,7 +1178,8 @@ image-dired-delete-tag "Remove tag for selected file(s). With prefix argument ARG, remove tag from file at point." (interactive "P") - (let ((tag (read-string "Tag to remove: ")) + (let ((tag (completing-read "Tag to remove: " image-dired-tag-history + nil nil nil 'image-dired-tag-history)) files) (if arg (setq files (list (dired-get-filename))) @@ -1182,7 +1189,8 @@ image-dired-delete-tag (defun image-dired-tag-thumbnail-remove () "Remove tag from current or marked thumbnails." (interactive) - (let ((tag (read-string "Tag to remove: "))) + (let ((tag (completing-read "Tag to remove: " image-dired-tag-history + nil nil nil 'image-dired-tag-history))) (image-dired--with-marked (image-dired-remove-tag (image-dired-original-file-name) tag) (image-dired-update-property -- 2.26.2