* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
@ 2013-06-03 13:28 E Sabof
2013-06-11 19:08 ` Glenn Morris
0 siblings, 1 reply; 10+ messages in thread
From: E Sabof @ 2013-06-03 13:28 UTC (permalink / raw)
To: 14548
[-- Attachment #1: Type: text/plain, Size: 2010 bytes --]
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))
[-- Attachment #2: Type: text/html, Size: 2633 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-03 13:28 bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays E Sabof
@ 2013-06-11 19:08 ` Glenn Morris
2013-06-11 21:56 ` Stefan Monnier
2013-06-13 5:11 ` Glenn Morris
0 siblings, 2 replies; 10+ messages in thread
From: Glenn Morris @ 2013-06-11 19:08 UTC (permalink / raw)
To: E Sabof; +Cc: 14548
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)))
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-11 19:08 ` Glenn Morris
@ 2013-06-11 21:56 ` Stefan Monnier
2013-06-11 22:12 ` Glenn Morris
2013-06-13 5:11 ` Glenn Morris
1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-06-11 21:56 UTC (permalink / raw)
To: Glenn Morris; +Cc: 14548, E Sabof
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-11 21:56 ` Stefan Monnier
@ 2013-06-11 22:12 ` Glenn Morris
2013-06-11 23:00 ` E Sabof
0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2013-06-11 22:12 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 14548, E Sabof
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-11 22:12 ` Glenn Morris
@ 2013-06-11 23:00 ` E Sabof
2013-06-12 12:01 ` E Sabof
0 siblings, 1 reply; 10+ messages in thread
From: E Sabof @ 2013-06-11 23:00 UTC (permalink / raw)
To: Glenn Morris; +Cc: 14548
[-- Attachment #1: Type: text/plain, Size: 733 bytes --]
On Tue, Jun 11, 2013 at 11:12 PM, Glenn Morris <rgm@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
[-- Attachment #2: Type: text/html, Size: 1302 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-11 23:00 ` E Sabof
@ 2013-06-12 12:01 ` E Sabof
2013-06-12 19:25 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: E Sabof @ 2013-06-12 12:01 UTC (permalink / raw)
To: Glenn Morris; +Cc: 14548
[-- Attachment #1: Type: text/plain, Size: 1960 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 2664 bytes --]
^ permalink raw reply related [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-11 19:08 ` Glenn Morris
2013-06-11 21:56 ` Stefan Monnier
@ 2013-06-13 5:11 ` Glenn Morris
2013-06-13 14:18 ` Stefan Monnier
1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2013-06-13 5:11 UTC (permalink / raw)
To: 14548-done
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)))
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays
2013-06-13 5:11 ` Glenn Morris
@ 2013-06-13 14:18 ` Stefan Monnier
2013-06-13 14:39 ` E Sabof
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2013-06-13 14:18 UTC (permalink / raw)
To: 14548; +Cc: esabof
>> ! (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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-06-13 14:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 13:28 bug#14548: 24.3.1; [PATCH] image-dired-dired-toggle-marked-thumbs conflicts with other modes using overlays E Sabof
2013-06-11 19:08 ` Glenn Morris
2013-06-11 21:56 ` Stefan Monnier
2013-06-11 22:12 ` Glenn Morris
2013-06-11 23:00 ` E Sabof
2013-06-12 12:01 ` E Sabof
2013-06-12 19:25 ` Stefan Monnier
2013-06-13 5:11 ` Glenn Morris
2013-06-13 14:18 ` Stefan Monnier
2013-06-13 14:39 ` E Sabof
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).