From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: Proposal for a closed-buffer tracker Date: Sat, 28 Feb 2015 10:15:59 +0000 Message-ID: References: Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c21ff07c4faa0510234594 X-Trace: ger.gmane.org 1425118580 8601 80.91.229.3 (28 Feb 2015 10:16:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Feb 2015 10:16:20 +0000 (UTC) Cc: emacs-devel To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 28 11:16:20 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YReRX-0005H4-MT for ged-emacs-devel@m.gmane.org; Sat, 28 Feb 2015 11:16:19 +0100 Original-Received: from localhost ([::1]:40675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YReRW-0003yv-Eq for ged-emacs-devel@m.gmane.org; Sat, 28 Feb 2015 05:16:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YReRG-0003vp-Lw for emacs-devel@gnu.org; Sat, 28 Feb 2015 05:16:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YReRF-0001dN-5F for emacs-devel@gnu.org; Sat, 28 Feb 2015 05:16:02 -0500 Original-Received: from mail-ob0-x236.google.com ([2607:f8b0:4003:c01::236]:48846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YReRE-0001dA-UW for emacs-devel@gnu.org; Sat, 28 Feb 2015 05:16:01 -0500 Original-Received: by mail-ob0-f182.google.com with SMTP id nt9so22789804obb.13 for ; Sat, 28 Feb 2015 02:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=9e3DAD7TZXsp3LDydD8GA/aRqYXMOQK6qSpsgz3JCZQ=; b=Epp16w/BvIMkUlPaxewLN74mFojg4VCYbqEdcxtxlY/m9T2kQ+j82hzDThb11OZ38f K50W6TghmDr5UpFR3Rn7oxxnhI/l+Noc8x/+8V5H5gmQoIrA0Y8sT5Y9DO3y7uz0RvcR 074bFE9YtZ2NmXiU6/N9HXVFNlkxH8rxgA3nziGRBqy1wzarncNqxIKbzONPgfinR4f3 FQxUDDPRukJ1ZQP0GKSNZJ7AYxrcUUta5gUT2kALogGeYdHjcgm8I8NYaUnBs6Rprd7X nPCRN/NUcZbP2Fh1xTk4ZuEcmqWZO/Tp6+PPrf8yhKTsjsnS/W1mH8/h5+IpO4eRtOg+ dqEw== X-Received: by 10.60.63.39 with SMTP id d7mr12999161oes.4.1425118559225; Sat, 28 Feb 2015 02:15:59 -0800 (PST) Original-Received: by 10.76.130.17 with HTTP; Sat, 28 Feb 2015 02:15:59 -0800 (PST) Original-Received: by 10.76.130.17 with HTTP; Sat, 28 Feb 2015 02:15:59 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: 1HwCsSsCiy03PgmkeWUqqT7sOlE X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183533 Archived-At: --001a11c21ff07c4faa0510234594 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =C2=ABeq=C2=BB replaced by= =C2=ABequal=C2=BB > (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 (=3D 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? --001a11c21ff07c4faa0510234594 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I'm refrain from repeating some of the things Eli or Ste= fan 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 do= cstring)

I understand this comes from somewhere else, but even in a g= eneral context this macro looks like overkill to me. Just define `silently&= #39; (and other similar macros) as a regular macro.

> ;; Copied from assq-delete-all in subr.el, but =C2=ABeq= =C2=BB replaced by =C2=ABequal=C2=BB
> (defun assoc-delete-all (key alist)
> =C2=A0 "Delete from ALIST all elements whose car is `equal' t= o KEY.
> Return the modified alist.
> Elements of ALIST that are not conses are ignored."
> =C2=A0 (while (and (consp (car alist))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (equal (car (car alis= t)) key))
> =C2=A0 =C2=A0 (setq alist (cdr alist)))
> =C2=A0 (let ((tail alist) tail-cdr)
> =C2=A0 =C2=A0 (while (setq tail-cdr (cdr tail))
> =C2=A0 =C2=A0 =C2=A0 (if (and (consp (car tail-cdr))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(equal (car (ca= r tail-cdr)) key))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setcdr tail (cdr tail-cdr))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq tail tail-cdr))))
> =C2=A0 alist)

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

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

This comment might as well be a docstring.

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

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

> =C2=A0 =C2=A0 =C2=A0 =C2=A0 (letrec ((demote (lambda (x= ) (when (and (consp x) (consp (car x)))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setca= r 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 entri= es?
Line [1] above makes it seem like non-full entries might get inserted at th= e 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 buff= er."

Would be nice if prefix argument did something. How about se= tting SELECT to nil?

--001a11c21ff07c4faa0510234594--