[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xref and leaving "temporary" buffers open

From: Dmitry Gutov
Subject: Re: xref and leaving "temporary" buffers open
Date: Sat, 25 Jul 2015 23:12:45 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0

On 07/25/2015 06:53 PM, martin rudalics wrote:

All file visiting functions must be aware of it and take it out.  As far
as implementation is concerned we have the usual two choices: Pass an
extra argument (clean but costly) or bind some variable around the calls
that visit the file in the background which is probably the way to go.

How about this:

(defvar-local buffer-hidden nil
  "When non-nil, this buffer is not returned by `buffer-list',
unless passed a non-nil INCLUDE-HIDDEN argument.")

(defvar-local buffer-hidden-last-access nil
"The time when this buffer was last accessed.")

(defun buffer-list (&optional frame include-hidden)

(defvar find-file-hidden nil
  "When non-nil, new file buffers are marked as hidden.
`find-file-noselect', when creating a new buffer, will set
`buffer-hidden' to t, and `buffer-hidden-last-access' to the
current time.
When it's nil, `find-file-noselect' will set `buffer-hidden' and
`buffer-hidden-last-accessed' to nil in the buffer it returns.")

`find-file-noselect' might also become a problem with large amounts of hidden buffers, because `find-buffer-visiting' iterates through all buffers (and thus is O(N)). Although we should see whether it's an actual problem in practice.

The "*every* reasonable way" solution applies only where such
customizations are cheap to implement and the behavior is not easily
predictable.  As fas as querying the user for whether to revert buffers
I see no problem in doing that.  Personally, I'd never opt for a
solution where I'm asked for each file individually.  But the options
"never auto-revert", "always auto-revert without asking" and "if at
least one file is stale ask whether to auto-revert all" seem all pretty
reasonable to me and I would probably try them out.

"never auto-revert" sounds like "always ask", but without the option "yes", because xref should abort in this case rather than return wrong results, and the user would have to be notified of that anyway. So that makes for two reasonable values, I think: "always revert" and "ask before reverting".

As long as a vague "Some buffers are out of date. Revert?" will suffice, that won't be a problem. Naming the first out-of-date buffer should also be always possible, but whether we'll be able to name them all, depends on the implementation of a given command.

The least recently accessed ones, I suppose.  So somewhere we might want
to maintain a timestamp of the least recently background access of these

The time when `find-file-noselect' was last called seems like a good approximation of the most recent access time.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]