GNU bug report logs - #14548
24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays

Previous Next

Package: emacs;

Reported by: E Sabof <esabof <at> gmail.com>

Date: Mon, 3 Jun 2013 13:31:01 UTC

Severity: normal

Tags: patch

Found in version 24.3.1

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14548 in the body.
You can then email your comments to 14548 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Mon, 03 Jun 2013 13:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to E Sabof <esabof <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 03 Jun 2013 13:31:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: E Sabof <esabof <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with
	other modes using overlays
Date: Mon, 3 Jun 2013 14:28:28 +0100
[Message part 1 (text/plain, inline)]
One such mode is stripe-buffer, which can be fonud here:

https://github.com/sabof/stripe-buffer

the definition below fixes the problem.

Evgeni

(ad-unadvise 'image-dired-dired-toggle-marked-thumbs) ; stripe-buffer
monkey-patches the function.

 (defun image-dired-dired-toggle-marked-thumbs (&optional arg)
    "Toggle thumbnails in front of file names in the dired buffer.
If no marked file could be found, insert or hide thumbnails on the
current line.  ARG, if non-nil, specifies the files to use instead
of the marked files.  If ARG is an integer, use the next ARG (or
previous -ARG, if ARG<0) files."
    (interactive "P")
    (dired-map-over-marks
     (let* ((image-pos  (dired-move-to-filename))
            (image-file (dired-get-filename nil t))
            thumb-file
            overlay)
       (when (and image-file
                  (string-match-p (image-file-name-regexp) image-file))
         (setq thumb-file (image-dired-get-thumbnail-image image-file))
         ;; If image is not already added, then add it.
         (let* (( cur-ovs (overlays-in (point) (1+ (point))))
                ( thumb-ov (car (cl-remove-if-not
                                 (lambda (ov) (overlay-get ov 'thumb-file))
                                 cur-ovs))))
           (if thumb-ov
               (delete-overlay thumb-ov)
               (progn
                 (put-image thumb-file image-pos)
                 (setq overlay
                       (cl-loop for o in (overlays-in (point) (1+ (point)))
                                when (overlay-get o 'put-image) collect o
into ov
                                finally return (car ov)))
                 (overlay-put overlay 'image-file image-file)
                 (overlay-put overlay 'thumb-file thumb-file))))))
     arg             ; Show or hide image on ARG next files.
     'show-progress) ; Update dired display after each image is updated.
    (add-hook 'dired-after-readin-hook
              'image-dired-dired-after-readin-hook nil t))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Tue, 11 Jun 2013 19:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: E Sabof <esabof <at> gmail.com>
Cc: 14548 <at> debbugs.gnu.org
Subject: Re: bug#14548: 24.3.1;
 [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other
 modes using overlays
Date: Tue, 11 Jun 2013 15:08:46 -0400
E Sabof wrote:

> One such mode is stripe-buffer, which can be fonud here:
>
> https://github.com/sabof/stripe-buffer
>
> the definition below fixes the problem.

Things are much, much more likely to be applied if they come as diffs
with an explanation of what the change is going, rather than "here's a
new version of the function with no explanation".

IIUC, the issue is that image-dired-dired-toggle-marked-thumbs can
remove overlays from other packages, and you suggest a fix like the
following?

The idea seems fine, but as written it won't work without requiring
cl-lib at run-time.


*** lisp/image-dired.el	2013-02-17 00:45:53 +0000
--- lisp/image-dired.el	2013-06-11 19:00:18 +0000
***************
*** 657,665 ****
                  (string-match-p (image-file-name-regexp) image-file))
         (setq thumb-file (image-dired-get-thumbnail-image image-file))
         ;; If image is not already added, then add it.
!        (let ((cur-ov (overlays-in (point) (1+ (point)))))
!          (if cur-ov
!              (delete-overlay (car cur-ov))
  	   (put-image thumb-file image-pos)
  	   (setq overlay
                   (cl-loop for o in (overlays-in (point) (1+ (point)))
--- 657,668 ----
                  (string-match-p (image-file-name-regexp) image-file))
         (setq thumb-file (image-dired-get-thumbnail-image image-file))
         ;; If image is not already added, then add it.
!        (let* ((cur-ovs (overlays-in (point) (1+ (point))))
!               (thumb-ov (car (cl-remove-if-not
!                               (lambda (ov) (overlay-get ov 'thumb-file))
!                               cur-ovs))))
!          (if thumb-ov
!              (delete-overlay thumb-ov)
  	   (put-image thumb-file image-pos)
  	   (setq overlay
                   (cl-loop for o in (overlays-in (point) (1+ (point)))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Tue, 11 Jun 2013 21:57:02 GMT) Full text and rfc822 format available.

Message #11 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14548 <at> debbugs.gnu.org, E Sabof <esabof <at> gmail.com>
Subject: Re: bug#14548: 24.3.1;
 [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other
 modes using overlays
Date: Tue, 11 Jun 2013 17:56:19 -0400
> The idea seems fine, but as written it won't work without requiring
> cl-lib at run-time.

That's fine for non-preloaded packages.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Tue, 11 Jun 2013 22:13:02 GMT) Full text and rfc822 format available.

Message #14 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 14548 <at> debbugs.gnu.org, E Sabof <esabof <at> gmail.com>
Subject: Re: bug#14548: 24.3.1;
 [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other
 modes using overlays
Date: Tue, 11 Jun 2013 18:12:16 -0400
Stefan Monnier wrote:

>> The idea seems fine, but as written it won't work without requiring
>> cl-lib at run-time.
>
> That's fine for non-preloaded packages.

I meant that image-dired does not presently require cl-lib at runtime,
so to be a complete solution the patch should have included that change
too.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Tue, 11 Jun 2013 23:02:02 GMT) Full text and rfc822 format available.

Message #17 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: E Sabof <esabof <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14548 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs
 conflicts with other modes using overlays
Date: Wed, 12 Jun 2013 00:00:52 +0100
[Message part 1 (text/plain, inline)]
On Tue, Jun 11, 2013 at 11:12 PM, Glenn Morris <rgm <at> gnu.org> wrote:

> Stefan Monnier wrote:
>
> >> The idea seems fine, but as written it won't work without requiring
> >> cl-lib at run-time.
> >
> > That's fine for non-preloaded packages.
>
> I meant that image-dired does not presently require cl-lib at runtime,
> so to be a complete solution the patch should have included that change
> too.
>

Basically, whenever a line contains an overlay and this function is evoked,
it thinks it already has a thumbnail, and won't put a new one there.

I can rewrite the function so it doesn't use cl-remove-if-not, although I
assumed that avoidance of the execution/expansion distinction was one of
the reasons cl-lib was created.

Evgeni
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Wed, 12 Jun 2013 12:02:02 GMT) Full text and rfc822 format available.

Message #20 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: E Sabof <esabof <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14548 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs
 conflicts with other modes using overlays
Date: Wed, 12 Jun 2013 13:01:09 +0100
[Message part 1 (text/plain, inline)]
Bellow is the patch for the trunk version, without cl-remove-if-not

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index bbb41d4..2e169ed 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -657,16 +657,24 @@ previous -ARG, if ARG<0) files."
                 (string-match-p (image-file-name-regexp) image-file))
        (setq thumb-file (image-dired-get-thumbnail-image image-file))
        ;; If image is not already added, then add it.
-       (let ((cur-ov (overlays-in (point) (1+ (point)))))
-         (if cur-ov
-             (delete-overlay (car cur-ov))
-   (put-image thumb-file image-pos)
-   (setq overlay
-                 (cl-loop for o in (overlays-in (point) (1+ (point)))
-                          when (overlay-get o 'put-image) collect o into ov
-                          finally return (car ov)))
-   (overlay-put overlay 'image-file image-file)
-   (overlay-put overlay 'thumb-file thumb-file)))))
+       (let (( cur-ovs (overlays-in (point) (1+ (point))))
+             thumb-ov)
+         (while (and cur-ovs
+                     (if (overlay-get (car cur-ovs) 'thumb-file)
+                         (progn
+                           (setq thumb-ov (car cur-ovs))
+                           nil)
+                         (pop cur-ovs))))
+         (if thumb-ov
+             (delete-overlay thumb-ov)
+             (progn
+               (put-image thumb-file image-pos)
+               (setq overlay
+                     (cl-loop for o in (overlays-in (point) (1+ (point)))
+                              when (overlay-get o 'put-image) collect o
into ov
+                              finally return (car ov)))
+               (overlay-put overlay 'image-file image-file)
+               (overlay-put overlay 'thumb-file thumb-file))))))
    arg             ; Show or hide image on ARG next files.
    'show-progress) ; Update dired display after each image is updated.
   (add-hook 'dired-after-readin-hook
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Wed, 12 Jun 2013 19:26:02 GMT) Full text and rfc822 format available.

Message #23 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: E Sabof <esabof <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, 14548 <at> debbugs.gnu.org
Subject: Re: bug#14548: 24.3.1;
 [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other
 modes using overlays
Date: Wed, 12 Jun 2013 15:25:46 -0400
> Bellow is the patch for the trunk version, without cl-remove-if-not

cl-remove-if-not is perfectly acceptable.  But it needs a (require
'cl-lib) at the top of the file (and not within eval-when-compile).


        Stefan




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Thu, 13 Jun 2013 05:12:02 GMT) Full text and rfc822 format available.

Notification sent to E Sabof <esabof <at> gmail.com>:
bug acknowledged by developer. (Thu, 13 Jun 2013 05:12:04 GMT) Full text and rfc822 format available.

Message #28 received at 14548-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 14548-done <at> debbugs.gnu.org
Subject: Re: bug#14548: 24.3.1;
 [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other
 modes using overlays
Date: Thu, 13 Jun 2013 01:11:10 -0400
Version: 24.4

Applied in this form.

> *** lisp/image-dired.el	2013-02-17 00:45:53 +0000
> --- lisp/image-dired.el	2013-06-11 19:00:18 +0000
> ***************
> *** 657,665 ****
>                   (string-match-p (image-file-name-regexp) image-file))
>          (setq thumb-file (image-dired-get-thumbnail-image image-file))
>          ;; If image is not already added, then add it.
> !        (let ((cur-ov (overlays-in (point) (1+ (point)))))
> !          (if cur-ov
> !              (delete-overlay (car cur-ov))
>   	   (put-image thumb-file image-pos)
>   	   (setq overlay
>                    (cl-loop for o in (overlays-in (point) (1+ (point)))
> --- 657,668 ----
>                   (string-match-p (image-file-name-regexp) image-file))
>          (setq thumb-file (image-dired-get-thumbnail-image image-file))
>          ;; If image is not already added, then add it.
> !        (let* ((cur-ovs (overlays-in (point) (1+ (point))))
> !               (thumb-ov (car (cl-remove-if-not
> !                               (lambda (ov) (overlay-get ov 'thumb-file))
> !                               cur-ovs))))
> !          (if thumb-ov
> !              (delete-overlay thumb-ov)
>   	   (put-image thumb-file image-pos)
>   	   (setq overlay
>                    (cl-loop for o in (overlays-in (point) (1+ (point)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Thu, 13 Jun 2013 14:19:01 GMT) Full text and rfc822 format available.

Message #31 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 14548 <at> debbugs.gnu.org
Cc: rgm <at> gnu.org, esabof <at> gmail.com
Subject: Re: bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs
 conflicts with other modes using overlays
Date: Thu, 13 Jun 2013 10:18:12 -0400
>> !        (let* ((cur-ovs (overlays-in (point) (1+ (point))))
>> !               (thumb-ov (car (cl-remove-if-not
>> !                               (lambda (ov) (overlay-get ov 'thumb-file))
>> !                               cur-ovs))))
>> !          (if thumb-ov
>> !              (delete-overlay thumb-ov)

BTW, now that I actually look at the code, I twonder why it doesn't use
remove-overlays.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14548; Package emacs. (Thu, 13 Jun 2013 14:40:04 GMT) Full text and rfc822 format available.

Message #34 received at 14548 <at> debbugs.gnu.org (full text, mbox):

From: E Sabof <esabof <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 14548 <at> debbugs.gnu.org
Subject: Re: bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs
 conflicts with other modes using overlays
Date: Thu, 13 Jun 2013 15:39:49 +0100
[Message part 1 (text/plain, inline)]
On Thu, Jun 13, 2013 at 3:18 PM, Stefan Monnier <monnier <at> iro.umontreal.ca>wrote:

> >> !        (let* ((cur-ovs (overlays-in (point) (1+ (point))))
> >> !               (thumb-ov (car (cl-remove-if-not
> >> !                               (lambda (ov) (overlay-get ov
> 'thumb-file))
> >> !                               cur-ovs))))
> >> !          (if thumb-ov
> >> !              (delete-overlay thumb-ov)
>
> BTW, now that I actually look at the code, I twonder why it doesn't use
> remove-overlays.
>
>
>         Stefan
>

It's a toggler. It will remove the overlay if present, or create one. And
remove-overlays always returns nil.

Evgeni
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Jul 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 316 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.