all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: daniel.c.mccarthy@gmail.com, Eli Zaretskii <eliz@gnu.org>,
	68235@debbugs.gnu.org
Subject: bug#68235: 29.1.90; Switching tabs stops following process output in selected window
Date: Tue, 16 Jan 2024 18:30:22 +0200	[thread overview]
Message-ID: <86a5p5qv61.fsf@mail.linkov.net> (raw)
In-Reply-To: <c8355ce7-14b2-4cf7-8948-a36bc2d3ce52@gmx.at> (martin rudalics's message of "Tue, 16 Jan 2024 11:19:28 +0100")

>> Maybe then at least would be possible to display a message
>> that will list the names of dead buffers.  That might help
>> the users to restore the buffers killed accidentally.
>
> The name of a killed buffer is nil as long as the buffer object has not
> been collected.  But would buffer names be of great use anyway? Isn't it
> the name of the file, the info node, or the directory name the buffer
> was visiting that counts?

The buffer name often has a hint about the file/directory name.

>> OTOH, this is not needed in case of using the tab-bar
>> because before switching to the tab with the killed buffer,
>> the name of the killed buffer is visible as the tab name.
>
> Does the tab-bar code store the buffer name separately?  But again -
> that name won't help you much anyway once the buffer was killed.

By default the buffer name is stored as a tab name.  And it helps
to know the purpose of why that tab was created.  When the buffer
was killed in another tab, it helps to decide whether the tab
that displayed the killed buffer should be closed as well.

> Incidentally, the name of the file a killed buffer was visiting will be
> available as long as the buffer object exists.  Do you mean that?

What would be more useful to keep for the killed buffer
is the value of its revert-buffer-function.  Often calling
this function can reconstruct the buffer contents.

>> Or maybe instead of 'post-set-window-configuration-hook' it's easy
>> to call a post-processing function after 'set-window-configuration'.
>
> 'post-set-window-configuration-functions' that's what I meant earlier -
> with the frame as argument.  But if a buffer is dead now, this won't
> help in neither regard.  First and foremost, 'set-window-configuration'
> must be able to deal with dead buffers in a safe fashion.  We could,
> optionally, display *scratch* in all windows that have a dead buffer now.

Instead of *scratch*, is it possible to display some special buffer
that will display the name of the killed buffer, and a button
that runs its revert-buffer-function?

> Still 'post-set-window-configuration-functions' (and also the
> desktop routines) would have to know enough about how to restore the
> earlier state.  This is something only a buffer's major mode itself may
> know.

Or revert-buffer-function.

>> BTW, there is another problem when the same buffer is displayed
>> in two tabs/window-configurations. For example, in the first tab
>> point is near the top of the buffer, and in the second tab point
>> is near the bottom of the same buffer.  The user edits the top
>> of the buffer in the first tab and saves writable window states
>> to the desktop.
>>
>> At this point, all positions saved in the second tab are wrong
>> because writable window states save point instead of the marker.
>
> But 'window--state-get-1' does
>
> 		(let ((point (window-point window))
>
> which should reliable give the value of point in window and then
>
> 		     (point . ,(if writable
>                                    point
>                                  (with-current-buffer buffer
>                                    (copy-marker point
>                                                 (buffer-local-value
>                                                  'window-point-insertion-type
>                                                  buffer)))))
>
> 'window--state-put-2' OTOH does
>
> 		  (set-window-point window (cdr (assq 'point state))))
>
> Do you see the problem here?

The problem is that for writable window states 'window--state-get-1'
saves point as a number from the marker.

>> One workaround is before saving the desktop to revisit all tabs
>> that will update points from markers in writable window states.
>>
>> But this won't help too much because there is still the same
>> problem after restoring the desktop.  When the desktop is
>> restored with right positions of all points, and the user
>> edits the top of the buffer in the first tab before visiting
>> the second tab, then after switching to the second tab
>> point will be at wrong position, because the tab is
>> restored from window states.
>
> So IIUC you mean that restoring the desktop (writable) does things
> differently than restoring tabs (non-writable)?  Can you tell me more
> precisely the order of desktop/tab-bar operations involved in that
> scenario?

The desktop saves writable window states with point as a number.
Switching tabs uses window configurations with point as a marker.

>> Here the same workaround is possible: to revisit all tabs after
>> restoring the desktop, that will create window configurations
>> from window states.
>
> I'd still have to understand: A non-writable state should behave like a
> window configuration.  A writable state should do the same but for using
> numbers instead of markers for positions.

Indeed.  Only writable window states saved to the desktop.

>> But automatically revisiting all tabs is too harmful
>> because some tabs might lost their names: when a buffer
>> was killed, then the tab will be renamed to the name
>> of the buffer that replaces the killed buffer,
>> and the user loses the hint what buffer was displayed
>> in the tab originally.
>
> Again I'm not sure how you would retrieve the name of a killed buffer.
> What am I missing?

Currently there is no solution to this problem.

>> To solve the problem of outdated points/markers in window states
>> maybe in addition to point, window states could also store
>> context strings like bookmark.el does?
>> I don't know how reliable these bookmark contexts are.
>
> It would help when the file a buffer is visiting was modified outside
> Emacs.  In all other cases, the stored point should suffice.

The stored point is not sufficient when saved as a number to the desktop file.





  reply	other threads:[~2024-01-16 16:30 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 20:48 bug#68235: 29.1.90; Switching tabs stops following process output in selected window Dan McCarthy
2024-01-04  6:09 ` Eli Zaretskii
2024-01-04 10:23   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-04 10:42     ` Eli Zaretskii
2024-01-04 17:07     ` Juri Linkov
2024-01-04 17:48       ` Eli Zaretskii
2024-01-05  9:24         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-06 17:36           ` Juri Linkov
2024-01-07 14:54             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-07 16:45               ` Juri Linkov
2024-01-08  8:55                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-09 17:23                   ` Juri Linkov
2024-01-07 16:49               ` Juri Linkov
2024-01-09 17:25                 ` Juri Linkov
2024-01-10  8:37                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10 17:08                     ` Juri Linkov
2024-01-11  9:14                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-12  7:37                         ` Juri Linkov
2024-01-13 10:38                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-13 15:02                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-13 18:20                               ` Juri Linkov
2024-01-14  8:13                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-14 18:53                                   ` Juri Linkov
2024-01-15 10:24                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-15 17:53                                       ` Juri Linkov
2024-01-16 10:19                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-16 16:30                                           ` Juri Linkov [this message]
2024-01-17 11:42                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-17 16:36                                               ` Juri Linkov
2024-01-18 10:47                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-18 16:50                                                   ` Juri Linkov
2024-01-20  9:44                                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-22  7:43                                                       ` Juri Linkov
2024-01-23  9:30                                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-24  7:54                                                           ` Juri Linkov
2024-01-25  9:39                                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-25 17:46                                                               ` Juri Linkov
2024-01-26  9:56                                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-27 17:58                                                                   ` Juri Linkov
2024-01-28 10:06                                                                     ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-05  7:17                                                       ` Juri Linkov
2024-02-06 10:34                                                         ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-06 18:03                                                           ` Juri Linkov
2024-02-15  7:34                                                           ` Juri Linkov
2024-02-16  9:40                                                             ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18  7:35                                                               ` Juri Linkov
2024-02-19  9:42                                                                 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-20 17:44                                                                   ` Juri Linkov
2024-03-04  9:40                                                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-05 17:27                                                                     ` Juri Linkov
2024-03-05 17:45                                                                       ` Eli Zaretskii
2024-03-06 18:03                                                                         ` Juri Linkov
2024-03-09  8:35                                                                           ` Eli Zaretskii
2024-03-17 17:57                                                                             ` Juri Linkov
2024-03-05 17:37                                                                     ` Juri Linkov
2024-03-06 10:19                                                                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-06 17:57                                                                         ` Juri Linkov
2024-03-08  9:21                                                                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-10 17:23                                                                             ` Juri Linkov
2024-03-11  9:13                                                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-09  6:53                                                                                 ` Juri Linkov
2024-04-09  7:36                                                                                   ` Eli Zaretskii
2024-04-09  9:22                                                                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-09 16:40                                                                                     ` Juri Linkov
2024-04-10  8:47                                                                                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-10 17:35                                                                                         ` Juri Linkov
2024-04-11  9:16                                                                                           ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-12  6:30                                                                                             ` Juri Linkov
2024-04-12  8:18                                                                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-12 16:20                                                                                                 ` Juri Linkov
2024-04-15  9:21                                                                                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-21  6:59                                                                                                     ` Juri Linkov
2024-04-21  8:56                                                                                                       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-22  6:46                                                                                                         ` Juri Linkov
2024-04-21  9:27                                                                                                       ` Eli Zaretskii
2024-04-22  6:40                                                                                                         ` Juri Linkov
2024-04-22  7:00                                                                                                           ` Eli Zaretskii
2024-04-22 16:36                                                                                                             ` Juri Linkov
2024-04-22 19:22                                                                                                               ` Eli Zaretskii
2024-03-15  9:38                                                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-17 17:47                                                                                 ` Juri Linkov
2024-03-18 10:13                                                                                   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-15 10:11                                                                             ` Andreas Schwab
2024-03-15 10:56                                                                               ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-04 17:27                       ` Juri Linkov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86a5p5qv61.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=68235@debbugs.gnu.org \
    --cc=daniel.c.mccarthy@gmail.com \
    --cc=eliz@gnu.org \
    --cc=rudalics@gmx.at \
    /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 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.