all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
@ 2022-02-17  9:18 Visuwesh
  2022-02-17 18:12 ` Juri Linkov
  0 siblings, 1 reply; 16+ messages in thread
From: Visuwesh @ 2022-02-17  9:18 UTC (permalink / raw)
  To: 54038

Pretty much the subject.

1. emacs -Q.
2. Open a pdf file.
3. Clone the tab using C-x t n.
4. Move to the next page (n).
5. Switch back to the original tab C-x t o.
6. The page is changed here too.

Expected: The original and the cloned tabs should show different pages,
just like how you can show different pages in different windows/frames.

[ FWIW, the same problem also exists with pdf-tools.  ]

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
Repository revision: 58bb9eb4005599155a8fce8d5c5beb531a72c534
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: NixOS 21.11 (Porcupine)

Configured using:
 'configure
 --prefix=/nix/store/0m0yw7b3zly74ljs3qmkblb780xg03id-emacs-git-20220130.0
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $EMACSLOADPATH:
  value of $EMACSNATIVELOADPATH: /nix/store/07cbjwzil3jfhyifj15h60k7yvixzqxs-emacs-packages-deps/share/emacs/native-lisp::
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  recentf-mode: t
  eros-mode: t
  pdf-occur-global-minor-mode: t
  minibuffer-depth-indicate-mode: t
  repeat-mode: t
  display-time-mode: t
  display-battery-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/viz/.nix-profile/share/emacs/site-lisp/site-start hides /nix/store/07cbjwzil3jfhyifj15h60k7yvixzqxs-emacs-packages-deps/share/emacs/site-lisp/site-start
/home/viz/lib/emacs/straight/build/map/map hides /nix/store/0m0yw7b3zly74ljs3qmkblb780xg03id-emacs-git-20220130.0/share/emacs/29.0.50/lisp/emacs-lisp/map
/home/viz/lib/emacs/straight/build/let-alist/let-alist hides /nix/store/0m0yw7b3zly74ljs3qmkblb780xg03id-emacs-git-20220130.0/share/emacs/29.0.50/lisp/emacs-lisp/let-alist

Features:
(vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc calc-rewr
cl-print completion misc expand-region subword-mode-expansions
text-mode-expansions cc-mode-expansions the-org-mode-expansions
er-basic-expansions expand-region-core expand-region-custom
flymake-shellcheck sh-script calc-prog calc-incom calc-undo calc-stuff
calcalg2 calccomp calc-misc calc-arith calc-math calc-alg latexenc
ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn
nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar
ox-html table ox-ascii ox-publish ox cdlatex math-delimiters cus-start
texmathp cal-iso image-file image-converter org-colview shadow emacsbug
ind-util man cap-words superword subword nix-mode ffap smie nix-repl
nix-shell nix-store magit-section nix-instantiate nix-shebang nix-format
nix shell-command+ epa-file org-datetree thai-util thai-word tabify
org-capture doct descr-text timezone dabbrev wdired siege-mode
cursor-sensor valign comp comp-cstr hippie-exp calc-map calc-stat
calc-vec calc-ext calc-menu calc-aent calc calc-loaddefs rect calc-macs
writegood-mode org-agenda cal-islam holidays hol-loaddefs mule-util
cal-move dictionary dictionary-connection lacarte dired-aux nndoc crm
bug-reference xref pdf-sync pdf-outline pdf-links pdf-history icomplete
pulse elec-pair org-pdftools pdf-annot facemenu org-noter org-refile
org-indent org-element avl-tree generator ob-C cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ob-shell
ob-racket async ob-async tempo ol-eww ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe
ol-docview doc-view ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src
ob-comint org-pcomplete org-list org-faces org-entities org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex ol org-keys oc
org-compat org-macs org-loaddefs ement-room-list ement ement-notify
notifications ement-room ewoc ement-api ement-structs ement-macros plz
dns ts s dash face-remap view time-stamp shortdoc help-fns radix-tree
misearch multi-isearch reveal noutline outline recentf tree-widget
url-http url-gw url-cache url-auth eww xdg url-queue mm-url binhex
smerge-mode diff gnus-fun flow-fill gnutls network-stream nsm shr-color
color mm-archive nnfolder sendmail qp flyspell ispell goto-addr
ecomplete gnus-cite mail-extr textsec uni-scripts idna-mapping
ucs-normalize uni-confusable textsec-check gnus-async gnus-bcklg sort
gnus-ml nndraft nnmh nnmaildir nnagent nnml executable vc-git diff-mode
vc-dispatcher nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig nntp
gnus-cache gnus-sum shr pixel-fill kinsoku svg dom gnus-group gnus-undo
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo parse-time iso8601 gnus-spec gnus-int gnus-range message yank-media
rmc puny rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode
mm-bodies mm-encode mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util mail-utils range shell pcomplete server paredit
edmacro kmacro eros time-date checkdoc lisp-mnt mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr flymake-proc flymake
project warnings thingatpt hl-todo writegood-mode-autoloads
wordel-autoloads sokoban-autoloads ement-autoloads ts-autoloads
map-autoloads plz-autoloads nov-autoloads esxml-autoloads kv-autoloads
transmission-autoloads lua-mode-autoloads nix-mode-autoloads
magit-section-autoloads dash-autoloads racket-mode-autoloads
eros-autoloads flymake-shellcheck-autoloads avy avy-autoloads
siege-mode-autoloads paredit-autoloads puni-autoloads
expand-region-autoloads filladapt-autoloads compose quail
scroll-other-window org-pdftools-autoloads org-noter-autoloads
math-delimiters-autoloads doct-autoloads ob-async-autoloads
async-autoloads emacs-ob-racket-autoloads valign-autoloads
org-starless-autoloads cdlatex-autoloads auctex-autoloads tex-site
easy-mmode pdf-occur ibuf-ext ibuffer ibuffer-loaddefs tablist advice
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local find-func cedet
pdf-isearch let-alist pdf-misc imenu pdf-tools package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source eieio
eieio-core eieio-loaddefs json map url-vars compile comint ansi-color
ring cus-edit wid-edit pdf-view password-cache jka-compr pdf-cache
pdf-info tq pdf-util pdf-macs image-mode dired-x dired dired-loaddefs
exif pdf-tools-autoloads let-alist-autoloads tablist-autoloads derived
mb-depth cus-load repeat visual-fill-autoloads olivetti-autoloads
hl-todo-autoloads time format-spec battery dbus filenotify xml
disp-table lacarte-autoloads shell-command-plus-autoloads rx icalendar
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs
flymake-grammarly-autoloads grammarly-autoloads websocket-autoloads
finder-inf request-autoloads s-autoloads chemtable-autoloads
molar-mass-autoloads saveplace-pdf-view saveplace bookmark
text-property-search pp saveplace-pdf-view-autoloads pcase
straight-autoloads info cl-seq cl-extra help-mode straight cl-macs
cl-loaddefs cl-lib vz-nh-theme seq gv subr-x byte-opt bytecomp
byte-compile cconv iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 2173612 796860)
 (symbols 48 62322 87)
 (strings 32 384571 53459)
 (string-bytes 1 164733736)
 (vectors 16 150975)
 (vector-slots 8 3649338 697381)
 (floats 8 120674 3482)
 (intervals 56 140293 16903)
 (buffers 992 113))





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-17  9:18 bug#54038: 29.0.50; doc-view cannot show different pages in different tabs Visuwesh
@ 2022-02-17 18:12 ` Juri Linkov
  2022-02-18  1:06   ` Visuwesh
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-17 18:12 UTC (permalink / raw)
  To: Visuwesh; +Cc: 54038

> Pretty much the subject.
>
> 1. emacs -Q.
> 2. Open a pdf file.
> 3. Clone the tab using C-x t n.
> 4. Move to the next page (n).
> 5. Switch back to the original tab C-x t o.
> 6. The page is changed here too.
>
> Expected: The original and the cloned tabs should show different pages,
> just like how you can show different pages in different windows/frames.
>
> [ FWIW, the same problem also exists with pdf-tools.  ]

This is expected behavior when you use 'C-x t n' that clones
the current tab.  A new clone has exactly the same window.
You can confirm this by evaluating in each tab: 'M-: (selected-window)'.
It will show the same window number.  But doc-view can show different pages
only in different windows.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-17 18:12 ` Juri Linkov
@ 2022-02-18  1:06   ` Visuwesh
  2022-02-18  7:46     ` Juri Linkov
  2022-02-18  8:11     ` Juri Linkov
  0 siblings, 2 replies; 16+ messages in thread
From: Visuwesh @ 2022-02-18  1:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

[வியாழன், பிப்ரவரி 17 2022] Juri Linkov wrote:

>> Pretty much the subject.
>>
>> 1. emacs -Q.
>> 2. Open a pdf file.
>> 3. Clone the tab using C-x t n.
>> 4. Move to the next page (n).
>> 5. Switch back to the original tab C-x t o.
>> 6. The page is changed here too.
>>
>> Expected: The original and the cloned tabs should show different pages,
>> just like how you can show different pages in different windows/frames.
>>
>> [ FWIW, the same problem also exists with pdf-tools.  ]
>
> This is expected behavior when you use 'C-x t n' that clones
> the current tab.  A new clone has exactly the same window.
> You can confirm this by evaluating in each tab: 'M-:
> (selected-window)'.
> It will show the same window number.  But doc-view can show different pages
> only in different windows.

I see, thanks.  I didn't know that.  If that is the case, the current
behaviour makes sense.  I was confused primarily because tabs created
this showing regular buffers were allowed to have different points.

But, how can I get my desired behaviour tho?  If I create a new tab
using C-x t 2, it breaks doc-view in a different way.  I am finding it
hard to describe it in text, so I would appreciate it if you can try it
out for yourself: essentially, C-x t 2, and then try changing pages.
Doc-view doesn't show the correct image but the page number in the
modeline changes.






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  1:06   ` Visuwesh
@ 2022-02-18  7:46     ` Juri Linkov
  2022-02-19 17:31       ` Juri Linkov
  2022-02-18  8:11     ` Juri Linkov
  1 sibling, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-18  7:46 UTC (permalink / raw)
  To: Visuwesh; +Cc: 54038

>>> 2. Open a pdf file.
>>> 3. Clone the tab using C-x t n.
>>> 4. Move to the next page (n).
>>> 5. Switch back to the original tab C-x t o.
>>> 6. The page is changed here too.
>>>
>>> Expected: The original and the cloned tabs should show different pages,
>>> just like how you can show different pages in different windows/frames.
>>
>> This is expected behavior when you use 'C-x t n' that clones
>> the current tab.  A new clone has exactly the same window.
>> You can confirm this by evaluating in each tab: 'M-:
>> (selected-window)'.
>> It will show the same window number.  But doc-view can show different pages
>> only in different windows.
>
> I see, thanks.  I didn't know that.  If that is the case, the current
> behaviour makes sense.  I was confused primarily because tabs created
> this showing regular buffers were allowed to have different points.

Hmm, maybe 'C-x t n' should not reuse the same window,
but should create a new window with exactly the same state.
This will avoid such problems.  Ok, I'll try to use
window-state-put/get while cloning tabs.

> But, how can I get my desired behaviour tho?  If I create a new tab
> using C-x t 2, it breaks doc-view in a different way.  I am finding it
> hard to describe it in text, so I would appreciate it if you can try it
> out for yourself: essentially, C-x t 2, and then try changing pages.
> Doc-view doesn't show the correct image but the page number in the
> modeline changes.

You are right, it fails with 'C-x t 2' too, so there is a problem
in interaction between doc-view and tab switching.  The current
handling of different windows in doc-view is quite hackish,
so it should be rewritten.  This comment in doc-view.el
proposes a good idea how this should be properly implemented:

      ;; FIXME: This should be done for all windows restored that show
      ;; this buffer.  Basically, the page/slice should be saved as
      ;; window-parameters in the window-state(s) and then restoring this
      ;; window-state should call us back (to interpret/use those parameters).





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  1:06   ` Visuwesh
  2022-02-18  7:46     ` Juri Linkov
@ 2022-02-18  8:11     ` Juri Linkov
  2022-02-18 12:19       ` Visuwesh
                         ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Juri Linkov @ 2022-02-18  8:11 UTC (permalink / raw)
  To: Visuwesh; +Cc: 54038

> But, how can I get my desired behaviour tho?  If I create a new tab
> using C-x t 2, it breaks doc-view in a different way.  I am finding it
> hard to describe it in text, so I would appreciate it if you can try it
> out for yourself: essentially, C-x t 2, and then try changing pages.
> Doc-view doesn't show the correct image but the page number in the
> modeline changes.

Please try this patch with 'C-x t 2' (whereas 'C-x t n' will be fixed later).
The problem is that when 'image-mode-winprops' does window cleanup,
it doesn't take into account windows saved in tabs.

diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 5bee155460..c127df12ae 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -179,7 +179,7 @@ image-mode-reapply-winprops
     ;; Beware: this call to image-mode-winprops can't be optimized away,
     ;; because it not only gets the winprops data but sets it up if needed
     ;; (e.g. it's used by doc-view to display the image in a new window).
-    (let* ((winprops (image-mode-winprops nil t))
+    (let* ((winprops (image-mode-winprops nil nil))
            (hscroll (image-mode-window-get 'hscroll winprops))
            (vscroll (image-mode-window-get 'vscroll winprops)))
       (when (image-get-display-property) ;Only do it if we display an image!





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  8:11     ` Juri Linkov
@ 2022-02-18 12:19       ` Visuwesh
  2022-02-19 17:35       ` Juri Linkov
  2024-07-29 18:12       ` Juri Linkov
  2 siblings, 0 replies; 16+ messages in thread
From: Visuwesh @ 2022-02-18 12:19 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

[வெள்ளி, பிப்ரவரி 18 2022] Juri Linkov wrote:

>> But, how can I get my desired behaviour tho?  If I create a new tab
>> using C-x t 2, it breaks doc-view in a different way.  I am finding it
>> hard to describe it in text, so I would appreciate it if you can try it
>> out for yourself: essentially, C-x t 2, and then try changing pages.
>> Doc-view doesn't show the correct image but the page number in the
>> modeline changes.
>
> Please try this patch with 'C-x t 2' (whereas 'C-x t n' will be fixed later).
> The problem is that when 'image-mode-winprops' does window cleanup,
> it doesn't take into account windows saved in tabs.
>

Doc-view is still broken here.  But now the tabs at least show different
pages but they break in a similar way as before.

Also, unfortunately, this completely breaks pdf-tools (one tab shows the
image, the other shows the raw PDF file).  Considering that it is in
NonGNU ELPA, it would be nice to ensure that it isn't broken.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  7:46     ` Juri Linkov
@ 2022-02-19 17:31       ` Juri Linkov
  2022-02-20  9:17         ` martin rudalics
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-19 17:31 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54038

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]

> Hmm, maybe 'C-x t n' should not reuse the same window,
> but should create a new window with exactly the same state.
> This will avoid such problems.  Ok, I'll try to use
> window-state-put/get while cloning tabs.

Here is attempt to create new windows with 'C-x t n'.
It works fine with (window-state-put (window-state-get))
to clone all windows in the tab (from the frame window).

But 'tab-bar-move-window-to-tab' still doesn't work
when it binds 'tab-bar-new-tab-choice' to 'window'.

The problem is that this doesn't create a new window
from the selected window:

  (window-state-put (window-state-get (selected-window)) (selected-window))

Maybe Martin could help.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tab-bar-new-tab-choice-clone.patch --]
[-- Type: text/x-diff, Size: 2721 bytes --]

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index e88bcac0da..7185cd52e8 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -481,7 +481,7 @@ tab-bar-new-tab-choice
 if such buffer exists, or switch to a buffer visiting the file or
 directory that the string specifies.  If the value is a function,
 call it with no arguments and switch to the buffer that it returns.
-If nil, duplicate the contents of the tab that was active
+If `clone', duplicate the contents of the tab that was active
 before calling the command that adds a new tab."
   :type '(choice (const     :tag "Current buffer" t)
                  (const     :tag "Current window" window)
@@ -489,7 +489,7 @@ tab-bar-new-tab-choice
                  (directory :tag "Directory" :value "~/")
                  (file      :tag "File" :value "~/.emacs")
                  (function  :tag "Function")
-                 (const     :tag "Duplicate tab" nil))
+                 (const     :tag "Duplicate tab" clone))
   :group 'tab-bar
   :version "27.1")
 
@@ -1367,14 +1367,19 @@ tab-bar-new-tab-to
         (select-window (minibuffer-selected-window)))
       ;; Remove window parameters that can cause problems
       ;; with `delete-other-windows' and `split-window'.
-      (set-window-parameter nil 'window-atom nil)
-      (set-window-parameter nil 'window-side nil)
+      (unless (eq tab-bar-new-tab-choice 'clone)
+        (set-window-parameter nil 'window-atom nil)
+        (set-window-parameter nil 'window-side nil))
       (let ((ignore-window-parameters t))
-        (delete-other-windows)
-        (unless (eq tab-bar-new-tab-choice 'window)
-          ;; Create a new window to get rid of old window parameters
-          ;; (e.g. prev/next buffers) of old window.
-          (split-window) (delete-window)))
+        (if (eq tab-bar-new-tab-choice 'clone)
+            (window-state-put (window-state-get))
+          (delete-other-windows)
+          (if (eq tab-bar-new-tab-choice 'window)
+              ;; TODO: this doesn't create a new window
+              (window-state-put (window-state-get (selected-window)) (selected-window))
+            ;; Create a new window to get rid of old window parameters
+            ;; (e.g. prev/next buffers) of old window.
+            (split-window) (delete-window))))
 
       (let ((buffer
              (if (functionp tab-bar-new-tab-choice)
@@ -1453,7 +1458,7 @@ tab-bar-duplicate-tab
   "Clone the current tab to ARG positions to the right.
 ARG and FROM-NUMBER have the same meaning as in `tab-bar-new-tab'."
   (interactive "P")
-  (let ((tab-bar-new-tab-choice nil)
+  (let ((tab-bar-new-tab-choice 'clone)
         (tab-bar-new-tab-group t))
     (tab-bar-new-tab arg from-number)))
 

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  8:11     ` Juri Linkov
  2022-02-18 12:19       ` Visuwesh
@ 2022-02-19 17:35       ` Juri Linkov
  2022-02-20  9:17         ` martin rudalics
  2024-07-29 18:12       ` Juri Linkov
  2 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-19 17:35 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54038

> The problem is that when 'image-mode-winprops' does window cleanup,
> it doesn't take into account windows saved in tabs.

The current implementation:

  (when cleanup
    (setq image-mode-winprops-alist
  	  (delq nil (mapcar (lambda (winprop)
			      (let ((w (car-safe winprop)))
				(if (or (not (windowp w)) (window-live-p w))
				    winprop)))
  			    image-mode-winprops-alist))))


'window-live-p' doesn't check windows saved in window-configurations in tabs.

Maybe it should check tab window-configurations on all frames
by a new function 'window-configuration-windows'
(something like used in 'tab-bar-get-buffer-tab').

But then what about windows saved by 'window-configuration-to-register'?
Should they be checked by 'window-live-p' too?

Or maybe better to change 'image-mode-winprops-alist' to the hash
'image-mode-winprops-hash' where window keys are garbage-collected?
So when a window is deleted from all window-configurations,
it will be garbage-collected?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-19 17:31       ` Juri Linkov
@ 2022-02-20  9:17         ` martin rudalics
  2022-02-23 17:59           ` Juri Linkov
  0 siblings, 1 reply; 16+ messages in thread
From: martin rudalics @ 2022-02-20  9:17 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

 > The problem is that this doesn't create a new window
 > from the selected window:
 >
 >    (window-state-put (window-state-get (selected-window)) (selected-window))

This should put the contents of the selected window into itself - a NOOP
WOW.  What else did you expect?

martin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-19 17:35       ` Juri Linkov
@ 2022-02-20  9:17         ` martin rudalics
  2022-02-20 18:51           ` Juri Linkov
  0 siblings, 1 reply; 16+ messages in thread
From: martin rudalics @ 2022-02-20  9:17 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

 > 'window-live-p' doesn't check windows saved in window-configurations in tabs.
 >
 > Maybe it should check tab window-configurations on all frames
 > by a new function 'window-configuration-windows'
 > (something like used in 'tab-bar-get-buffer-tab').
 >
 > But then what about windows saved by 'window-configuration-to-register'?
 > Should they be checked by 'window-live-p' too?
 >
 > Or maybe better to change 'image-mode-winprops-alist' to the hash
 > 'image-mode-winprops-hash' where window keys are garbage-collected?
 > So when a window is deleted from all window-configurations,
 > it will be garbage-collected?

GC tries to remove dead buffers window configurations stored in their
list of previous or next buffers.  But checking for whether a dead
window has disappeared from all stored configurations is more demanding
- maybe we could reserve a bit in each window the collector resets for
all dead windows at the beginning of each cycle and at the end reclaim
the space of all windows that did not have that bit set when the window
was found in a stored window configuration.

martin





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-20  9:17         ` martin rudalics
@ 2022-02-20 18:51           ` Juri Linkov
  2022-02-21  9:08             ` martin rudalics
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-20 18:51 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54038

>> 'window-live-p' doesn't check windows saved in window-configurations in tabs.
>>
>> Maybe it should check tab window-configurations on all frames
>> by a new function 'window-configuration-windows'
>> (something like used in 'tab-bar-get-buffer-tab').
>>
>> But then what about windows saved by 'window-configuration-to-register'?
>> Should they be checked by 'window-live-p' too?
>>
>> Or maybe better to change 'image-mode-winprops-alist' to the hash
>> 'image-mode-winprops-hash' where window keys are garbage-collected?
>> So when a window is deleted from all window-configurations,
>> it will be garbage-collected?
>
> GC tries to remove dead buffers window configurations stored in their
> list of previous or next buffers.  But checking for whether a dead
> window has disappeared from all stored configurations is more demanding
> - maybe we could reserve a bit in each window the collector resets for
> all dead windows at the beginning of each cycle and at the end reclaim
> the space of all windows that did not have that bit set when the window
> was found in a stored window configuration.

Maybe a more immediate solution would be simply to iterate all tabs
on all frames, and to check whether they contain a window.  But still
I can't find a function to check whether a window is in a window configuration.
Does such a function exist?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-20 18:51           ` Juri Linkov
@ 2022-02-21  9:08             ` martin rudalics
  2022-02-23 17:46               ` Juri Linkov
  0 siblings, 1 reply; 16+ messages in thread
From: martin rudalics @ 2022-02-21  9:08 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

 > Maybe a more immediate solution would be simply to iterate all tabs
 > on all frames, and to check whether they contain a window.  But still
 > I can't find a function to check whether a window is in a window configuration.
 > Does such a function exist?

No.  The only agent that has access to all window configurations is the
garbage collector.  Do you want to collect garbage each time you want to
know whether a window is part of a window configuration?

martin






^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-21  9:08             ` martin rudalics
@ 2022-02-23 17:46               ` Juri Linkov
  2022-02-24  9:18                 ` martin rudalics
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2022-02-23 17:46 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54038

>> Maybe a more immediate solution would be simply to iterate all tabs
>> on all frames, and to check whether they contain a window.  But still
>> I can't find a function to check whether a window is in a window configuration.
>> Does such a function exist?
>
> No.  The only agent that has access to all window configurations is the
> garbage collector.  Do you want to collect garbage each time you want to
> know whether a window is part of a window configuration?
>
>> Like in bug#54038 (about having access to windows in window configurations),
>> the problem is that there is no way to update and even peek inside
>> a window configuration.  In bug#54038 the cleanup function can't tell
>> if a window is still live in a window configuration.
>
> We might be able to provide such a function but can you tell me why you
> would need it and how you would use it?

It could be used in 'image-mode-winprops':

  (when cleanup
    (setq image-mode-winprops-alist
  	  (delq nil (mapcar (lambda (winprop)
			      (let ((w (car-safe winprop)))
				(if (or (not (windowp w))
                                        (window-live-p w)
           new function =>              (window-live-in-all-window-configurations w))
				    winprop)))
  			    image-mode-winprops-alist))))





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-20  9:17         ` martin rudalics
@ 2022-02-23 17:59           ` Juri Linkov
  0 siblings, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2022-02-23 17:59 UTC (permalink / raw)
  To: martin rudalics; +Cc: 54038

>> The problem is that this doesn't create a new window
>> from the selected window:
>>
>>    (window-state-put (window-state-get (selected-window)) (selected-window))
>
> This should put the contents of the selected window into itself - a NOOP
> WOW.  What else did you expect?

Thanks, now this is simplified in master.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-23 17:46               ` Juri Linkov
@ 2022-02-24  9:18                 ` martin rudalics
  0 siblings, 0 replies; 16+ messages in thread
From: martin rudalics @ 2022-02-24  9:18 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 54038

 >> We might be able to provide such a function but can you tell me why you
 >> would need it and how you would use it?
 >
 > It could be used in 'image-mode-winprops':
 >
 >    (when cleanup
 >      (setq image-mode-winprops-alist
 >    	  (delq nil (mapcar (lambda (winprop)
 > 			      (let ((w (car-safe winprop)))
 > 				(if (or (not (windowp w))
 >                                          (window-live-p w)
 >             new function =>              (window-live-in-all-window-configurations w))
 > 				    winprop)))
 >    			    image-mode-winprops-alist))))

I can't tell from here what 'window-live-in-all-window-configurations'
is supposed to return.  Its name appears misleading - do we care if 'w'
is live in a configuration of another frame but w's?  So please tell me
the doc-string of ‘window-live-in-all-window-configurations’ first.

And please always keep in mind: The only agent that has access to _all_
window configurations is the garbage collector.  If we wanted to change
that, we'd have to make window configurations explicitly deletable like
buffers or windows with functions like 'make-window-configuration',
'delete-window-configuration' and 'window-configurations-list'.  While
this might not pose great problems for read_minibuf, it certainly will
for configurations in plain Lisp code which all of a sudden would become
noncollectable after the last reference to them has gone ...

martin

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#54038: 29.0.50; doc-view cannot show different pages in different tabs
  2022-02-18  8:11     ` Juri Linkov
  2022-02-18 12:19       ` Visuwesh
  2022-02-19 17:35       ` Juri Linkov
@ 2024-07-29 18:12       ` Juri Linkov
  2 siblings, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2024-07-29 18:12 UTC (permalink / raw)
  To: Visuwesh; +Cc: 54038

> The problem is that when 'image-mode-winprops' does window cleanup,
> it doesn't take into account windows saved in tabs.
>
> diff --git a/lisp/image-mode.el b/lisp/image-mode.el
> index 5bee155460..c127df12ae 100644
> --- a/lisp/image-mode.el
> +++ b/lisp/image-mode.el
> @@ -179,7 +179,7 @@ image-mode-reapply-winprops
>      ;; Beware: this call to image-mode-winprops can't be optimized away,
>      ;; because it not only gets the winprops data but sets it up if needed
>      ;; (e.g. it's used by doc-view to display the image in a new window).
> -    (let* ((winprops (image-mode-winprops nil t))
> +    (let* ((winprops (image-mode-winprops nil nil))
>             (hscroll (image-mode-window-get 'hscroll winprops))
>             (vscroll (image-mode-window-get 'vscroll winprops)))
>        (when (image-get-display-property) ;Only do it if we display an image!

I see that Po Lu corrected display of Doc View documents after tab switching
in the commit a475360af98.  I tried the original report, but it still doesn't
work without the patch above.





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-07-29 18:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-17  9:18 bug#54038: 29.0.50; doc-view cannot show different pages in different tabs Visuwesh
2022-02-17 18:12 ` Juri Linkov
2022-02-18  1:06   ` Visuwesh
2022-02-18  7:46     ` Juri Linkov
2022-02-19 17:31       ` Juri Linkov
2022-02-20  9:17         ` martin rudalics
2022-02-23 17:59           ` Juri Linkov
2022-02-18  8:11     ` Juri Linkov
2022-02-18 12:19       ` Visuwesh
2022-02-19 17:35       ` Juri Linkov
2022-02-20  9:17         ` martin rudalics
2022-02-20 18:51           ` Juri Linkov
2022-02-21  9:08             ` martin rudalics
2022-02-23 17:46               ` Juri Linkov
2022-02-24  9:18                 ` martin rudalics
2024-07-29 18:12       ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.