bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#49999: 27.2; save-mark-and-excursion does not save mark-active


From: Peter Münster
Subject: bug#49999: 27.2; save-mark-and-excursion does not save mark-active
Date: Fri, 13 Aug 2021 11:19:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

On Wed, Aug 11 2021, Lars Ingebrigtsen wrote:

> So `save-mark-and-excursion' works exactly as it should.  But if you
> don't want transient-mark-mode to switch itself off, you have to say
> something like:

Thanks for your explanation. Please find attached a patch, that uses
your solution.

-- 
           Peter
From 8e0d6c4e787ecb56ef8eede83ea5c5d8ed0db5e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Peter=20M=C3=BCnster?= <pm@a16n.net>
Date: Fri, 13 Aug 2021 11:13:43 +0200
Subject: [PATCH] Minor enhancements for image-dired.el

* lisp/image-dired.el (image-dired-thumb-visible-marks): Add the group.
(image-dired-thumb-update-marks): Keep the mark state when changing faces.
---
 lisp/image-dired.el | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 76c7ae91f0..34bf1d02a9 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -465,6 +465,7 @@ This is where you see the cursor."
 If non-nil, apply the `image-dired-thumb-mark' face to marked
 images."
   :type 'boolean
+  :group 'image-dired
   :version "28.1")
 
 (defface image-dired-thumb-mark
@@ -2360,20 +2361,18 @@ non-nil."
 
 (defun image-dired-thumb-update-marks ()
   "Update the marks in the thumbnail buffer."
-  ;; TODO: only called by image-dired-mouse-toggle-mark but there are
-  ;; certainly other places, where it should be called too.
   (when image-dired-thumb-visible-marks
     (with-current-buffer image-dired-thumbnail-buffer
-      (save-excursion
+      (save-mark-and-excursion
         (goto-char (point-min))
         (let ((inhibit-read-only t))
           (while (not (eobp))
-            (if (image-dired-thumb-file-marked-p)
-                (add-face-text-property
-                 (point) (1+ (point))
-                 'image-dired-thumb-mark)
-              (remove-text-properties (point) (1+ (point))
-                                      '(face image-dired-thumb-mark)))
+            (with-silent-modifications
+              (if (image-dired-thumb-file-marked-p)
+                  (add-face-text-property (point) (1+ (point))
+                                          'image-dired-thumb-mark)
+                (remove-text-properties (point) (1+ (point))
+                                        '(face image-dired-thumb-mark))))
             (forward-char)))))))
 
 (defun image-dired-mouse-toggle-mark-1 ()
-- 
2.26.2

Attachment: signature.asc
Description: PGP signature


reply via email to

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