From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 32672@debbugs.gnu.org
Subject: bug#32672: 27.0.50; image resize on window resizing
Date: Wed, 27 Nov 2019 23:53:46 +0200 [thread overview]
Message-ID: <87a78iyz8l.fsf@mail.linkov.net> (raw)
In-Reply-To: <878sqbfaqo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 26 Sep 2019 15:27:59 +0200")
[-- Attachment #1: Type: text/plain, Size: 762 bytes --]
tags 32672 fixed
close 32672 27.0.50
quit
>> Using new hooks I noticed only one problem that when the same image buffer is
>> displayed in several windows then using `other-window' to switch between them,
>> the selection-change hook is not always called.
>
> [...]
>
>> + (add-hook 'window-size-change-functions (debounce #'image-window-change 1) nil t)
>> + (add-hook 'window-state-change-functions (debounce #'image-window-change 1) nil t)
>> + (add-hook 'window-selection-change-functions (debounce #'image-window-change 1) nil t)
>> +
>
> I think this sounds like a nice addition for image-mode... but were the
> remaining edge cases ever resolved? I see that the patch hasn't been
> applied.
This is installed now with the following patch and closed.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: image--window-change.patch --]
[-- Type: text/x-diff, Size: 1866 bytes --]
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index db6864649d..09d7828047 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -599,6 +599,10 @@ image-mode--setup-mode
(add-hook 'change-major-mode-hook #'image-toggle-display-text nil t)
(add-hook 'after-revert-hook #'image-after-revert-hook nil t)
+ (add-hook 'window-size-change-functions #'image--window-change nil t)
+ (add-hook 'window-state-change-functions #'image--window-change nil t)
+ (add-hook 'window-selection-change-functions #'image--window-change nil t)
+
(run-mode-hooks 'image-mode-hook)
(let ((image (image-get-display-property))
(msg1 (substitute-command-keys
@@ -856,6 +860,27 @@ image-after-revert-hook
(get-buffer-window-list (current-buffer) 'nomini 'visible))
(image-toggle-display-image)))
+(defvar image--window-change-function
+ (debounce 1.0
+ (lambda (window)
+ (when (window-live-p window)
+ (with-current-buffer (window-buffer)
+ (when (derived-mode-p 'image-mode)
+ (let ((spec (image-get-display-property)))
+ (when (eq (car-safe spec) 'image)
+ (let* ((image-width (plist-get (cdr spec) :max-width))
+ (image-height (plist-get (cdr spec) :max-height))
+ (edges (window-inside-pixel-edges window))
+ (window-width (- (nth 2 edges) (nth 0 edges)))
+ (window-height (- (nth 3 edges) (nth 1 edges))))
+ (when (and image-width image-height
+ (or (not (= image-width window-width))
+ (not (= image-height window-height))))
+ (image-toggle-display-image)))))))))))
+
+(defun image--window-change (window)
+ (funcall image--window-change-function window))
+
\f
;;; Animated images
next prev parent reply other threads:[~2019-11-27 21:53 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 15:54 bug#32672: 27.0.50; image resize on window resizing Juri Linkov
2018-09-11 23:53 ` Juri Linkov
2018-09-12 6:33 ` martin rudalics
2018-09-12 23:18 ` Juri Linkov
2018-09-13 7:46 ` martin rudalics
2018-09-13 23:20 ` Juri Linkov
2018-09-14 8:33 ` martin rudalics
2018-09-15 23:35 ` Juri Linkov
2018-09-16 9:10 ` martin rudalics
2018-09-16 23:49 ` Juri Linkov
2018-09-17 6:46 ` martin rudalics
2018-09-17 22:35 ` Juri Linkov
2018-09-19 8:22 ` martin rudalics
2018-09-19 23:15 ` Juri Linkov
2018-09-20 7:34 ` martin rudalics
2018-09-20 23:15 ` Juri Linkov
2018-09-21 6:34 ` martin rudalics
2018-09-22 22:15 ` Juri Linkov
2018-09-23 8:26 ` martin rudalics
2018-09-23 20:39 ` Juri Linkov
2018-09-24 8:22 ` martin rudalics
2018-09-24 8:35 ` Eli Zaretskii
2018-09-24 12:25 ` martin rudalics
2018-09-24 12:46 ` Eli Zaretskii
2018-09-24 17:37 ` martin rudalics
2018-09-24 17:53 ` Eli Zaretskii
2018-09-25 7:26 ` martin rudalics
2018-09-25 9:19 ` Eli Zaretskii
2018-09-25 17:56 ` martin rudalics
2018-09-25 18:31 ` Eli Zaretskii
2018-09-24 18:38 ` Juri Linkov
2018-09-24 19:31 ` Eli Zaretskii
2018-09-25 7:27 ` martin rudalics
2018-09-25 19:24 ` Juri Linkov
2018-09-26 8:51 ` martin rudalics
2018-10-27 19:38 ` Juri Linkov
2018-10-28 8:59 ` martin rudalics
2018-09-24 18:31 ` Juri Linkov
2018-09-25 7:27 ` martin rudalics
2018-12-26 23:42 ` Juri Linkov
2018-12-27 9:36 ` martin rudalics
2018-12-27 21:41 ` Juri Linkov
2018-12-28 8:34 ` martin rudalics
2018-12-27 15:48 ` Eli Zaretskii
2018-12-27 20:58 ` Juri Linkov
2018-12-28 4:51 ` Eli Zaretskii
2019-09-26 13:27 ` Lars Ingebrigtsen
2019-11-27 21:53 ` Juri Linkov [this message]
2019-11-28 9:20 ` martin rudalics
2019-11-28 22:50 ` Juri Linkov
2019-11-29 9:24 ` martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a78iyz8l.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=32672@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).