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: Artur Malabarba
Subject: Re: Proposal for a closed-buffer tracker
Date: Sat, 28 Feb 2015 10:15:59 +0000

I'm refrain from repeating some of the things Eli or Stefan already pointed out:

> should it go into desktop.el? Or perhaps GNU Elpa?

If it can be made into its own package, then yes, it should go on Gelpa as well. But that doesn't mean it can't be built-in. I think this is the type of feature that needs to be turned on by default.

> (defmacro dlet (binders &rest body)

If this remains, it needs to go somewhere else (like subr-x), or be given a prefix.

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

I understand this comes from somewhere else, but even in a general context this macro looks like overkill to me. Just define `silently' (and other similar macros) as a regular macro.

> ;; Copied from assq-delete-all in subr.el, but «eq» replaced by «equal»
> (defun assoc-delete-all (key alist)
>   "Delete from ALIST all elements whose car is `equal' to KEY.
> Return the modified alist.
> Elements of ALIST that are not conses are ignored."
>   (while (and (consp (car alist))
>               (equal (car (car alist)) key))
>     (setq alist (cdr alist)))
>   (let ((tail alist) tail-cdr)
>     (while (setq tail-cdr (cdr tail))
>       (if (and (consp (car tail-cdr))
>                (equal (car (car tail-cdr)) key))
>           (setcdr tail (cdr tail-cdr))
>         (setq tail tail-cdr))))
>   alist)

I also find this a little corner-case to warrant so much code. I would just use
    (cl-remove-if (lambda (x) (equal (car-safe x) key)) alist)
Or even
    (cl-remove key alist :filter #'car-safe)

> (defun untrack-closed-buffer (name)
>   ;; Could be just name, or info list; delete in either case

This comment might as well be a docstring.

> (defun track-closed-buffer ()
>   (when (and buffer-file-name (not (= closed-buffer-history-max-saved-items 0)))
>     ;; Remove from not-head of list
>     (untrack-closed-buffer buffer-file-name)
>     ;; Add to head of list
>     (pushnew (if (desktop-save-buffer-p buffer-file-name (buffer-name) major-mode)

Use cl-pushnew (also [1] for reference below).

>         (letrec ((demote (lambda (x) (when (and (consp x) (consp (car x)))
>                                        (setcar x (caar x)) (funcall demote (cdr x))))))

This will stop demoting if it runs into a non-full entry. Is it guaranteed that a non-full entry can only be followed by non-full entries?
Line [1] above makes it seem like non-full entries might get inserted at the head, which means you can have non full entries in front of full entries.

> (defun reopen-buffer (name &optional remove-missing select)
> If called interactively, or SELECT is non-nil, then switch to the buffer."

Would be nice if prefix argument did something. How about setting SELECT to nil?


reply via email to

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