emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal for a closed-buffer tracker


From: Stefan Monnier
Subject: Re: Proposal for a closed-buffer tracker
Date: Sun, 22 Feb 2015 16:59:37 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> 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.

[ FWIW: I'd be really happy if someone were to design some clean
  "buffer-info" system, which can then be used for desktop,
  for bookmark, for special-mode's revert-buffed, and for help-xref
  (and now for closed-buffer).  ]

Sounds nice.

> Stefan suggested I submit this feature as a patch. If other people
> might find it useful, should it go into desktop.el?

In light of my view that the "buffer-info" you currently get from
desktop-buffer-info should really not be part of desktop, you can
probably guess that I think closed-buffer should be in a package of
its own.
Of course, it should use names with a proper package prefix.

> Or perhaps GNU ELPA?

Sounds good, yes.

>   (unless (listp binders) (error "%S is not a list" binders))
[...]
>        (dolist (binder binders (nreverse vardefs))

The `listp' test above is not really needed since dolist should signal an
equivalent error anyway.

>          (cond ((symbolp binder)
>                 (push `(defvar ,binder) vardefs))
>                ((and (listp binder)
>                      (symbolp (car binder)))
>                 (push `(defvar ,(car binder)) vardefs))
>                (t (error "%S is not a symbol or list" binder)))))

BTW, you can do:

           (push `(defvar ,(cond ((symbolp binder) binder)
                                 ((and (listp binder)
                                       (symbolp (car binder)))
                                  (car binder))
                                 (t (error "%S is not a symbol or list" 
binder))))
                 vardefs)

And you can skip the explicit `listp' test again which `car' will do for
you as well as the `symbolp' test which `defvar' will do for you:

           (push `(defvar ,(if (symbolp binder) binder (car binder)))
                 vardefs)

Other than that, looks very similar to what I have in cconv.el:

;; (defmacro dlet (binders &rest body)
;;   ;; Works in both lexical and non-lexical mode.
;;   (declare (indent 1) (debug let))
;;   `(progn
;;      ,@(mapcar (lambda (binder)
;;                  `(defvar ,(if (consp binder) (car binder) binder)))
;;                binders)
;;      (let ,binders ,@body)))

> (defmacro define-function-suppressor (wrapper victim docstring)

I don't much like this kind of hacking, although I know it can be
very useful.  IOW: when you need it, go right ahead, but don't forget to
report that need as a bug.


        Stefan



reply via email to

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