[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposal for a closed-buffer tracker
From: |
Eli Zaretskii |
Subject: |
Re: Proposal for a closed-buffer tracker |
Date: |
Sun, 22 Feb 2015 17:53:25 +0200 |
> From: Kelly Dean <address@hidden>
> Date: Sun, 22 Feb 2015 04:11:54 +0000
>
> Below is code for a closed-buffer tracker. It lets you reopen closed buffers,
> and restores the major mode, minor modes, point, mark, mark ring, and other
> buffer-local variables returned by the function desktop-buffer-info.
> Currently,
> it's implemented only for file-visiting buffers. It's comparable to the
> «closed
> tabs» feature of modern web browsers, and useful for the same reasons.
Thanks.
> Note that although it uses functions in desktop.el, it doesn't require
> desktop-save-mode to be enabled; the two operate independently.
If by "independently" you mean that desktop saving does not have to be
enabled, then fine. But this functionality should IMO be able to do
everything desktop.el is able to do wrt restoring buffers. In
particular, desktop.el is able to restore buffers whose
buffer-file-name is nil, at least for Info buffers. I'd presume that
buffers visiting URLs via eww should also be restorable (I don't know
if desktop.el can do that already, but if not, it should be taught to
do so, and this feature should then be able to reuse that).
> Stefan suggested I submit this feature as a patch. If other people might find
> it useful, should it go into desktop.el? Or perhaps GNU Elpa? Currently it's
> just part of a larger convenience package at:
> http://prtime.org/emacs/usablizer.html
IMO, it should definitely go to desktop.el, as it uses its
infrastructure.
> (defvar closed-buffer-history-max-saved-items 1000
This should be a defcustom, of course.
> "Max items to save on `closed-buffer-history' list.
> Use -1 for unlimited, or zero to disable tracking closed files.
I think we tend to use nil for "unlimited", not -1.
Please use 2 spaces between sentences in doc strings, we use the US
English style.
> To clear the list, set it to nil.
The list is an internal variable, so telling users to set it is a
minor annoyance, I think. How about an explicit function to do that,
a-la "Clear Recent History"?
> (defvar closed-buffer-history-max-full-items 100
> "Max full items to save on `closed-buffer-history' list.
Should be a defcustom.
> Use -1 for unlimited, or zero to disable tracking of full items.
Again, nil for unlimited is better, IMO.
> (interactive
> (list (ido-completing-read "Last closed: "
Why ido-completing-read, rather than completing-read? I think it6's
up to the users to customize their completion.
> ;;Load from info list, using base filename as new buffer name.
> (let ((buf
> ;; Set variables needed by desktop-create-buffer.
> ;; Need dlet because they're not globally special, but only locally
> ;; special in desktop.el, which according to Stefan, is not weird.
> (dlet ((desktop-buffer-ok-count 0)
> (desktop-buffer-fail-count 0)
> desktop-first-buffer)
> (silently ; Silence desktop-restore-file-buffer if file
> can't be found
> (apply 'desktop-create-buffer (string-to-number
> desktop-file-version)
> name (file-name-nondirectory name) (cddr
> bufinfo))))))
What happens if there is already a buffer by the same name? Also,
should we somehow draw user's attention to the fact that another
buffer visits the same file?
> (add-hook 'kill-buffer-hook #'track-closed-buffer)
Why the hash?
> (global-set-key [S-XF86Close] #'reopen-buffer)
Why this strange binding?
Also, if we are targeting newbies who are accustomed to Web browsers,
this functionality should be easily reachable from the menu bar, IMO.
Thanks again for working on this.
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, (continued)
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Daniel Colascione, 2015/02/15
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Kelly Dean, 2015/02/16
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Stefan Monnier, 2015/02/16
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Kelly Dean, 2015/02/17
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Stefan Monnier, 2015/02/18
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Kelly Dean, 2015/02/19
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Stefan Monnier, 2015/02/19
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Kelly Dean, 2015/02/19
- Re: Why is Elisp's defvar weird? And is eval_sub broken?, Stefan Monnier, 2015/02/19
- Proposal for a closed-buffer tracker, Kelly Dean, 2015/02/21
- Re: Proposal for a closed-buffer tracker,
Eli Zaretskii <=
- Re: Proposal for a closed-buffer tracker, Stefan Monnier, 2015/02/22
- Re: Proposal for a closed-buffer tracker, Dmitry Gutov, 2015/02/22
- Re: Proposal for a closed-buffer tracker, Artur Malabarba, 2015/02/23
- Re: Proposal for a closed-buffer tracker, Eli Zaretskii, 2015/02/23
- Re: Proposal for a closed-buffer tracker, Stefan Monnier, 2015/02/22
- Re: Proposal for a closed-buffer tracker, Artur Malabarba, 2015/02/28