From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Proposal for a closed-buffer tracker Date: Sun, 22 Feb 2015 16:59:37 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1424642441 23671 80.91.229.3 (22 Feb 2015 22:00:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Feb 2015 22:00:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kelly Dean Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 22 23:00:33 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 1YPeZk-00072z-O8 for ged-emacs-devel@m.gmane.org; Sun, 22 Feb 2015 23:00:32 +0100 Original-Received: from localhost ([::1]:41385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPeZk-0006Pw-4I for ged-emacs-devel@m.gmane.org; Sun, 22 Feb 2015 17:00:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPeZT-0006Pr-7v for emacs-devel@gnu.org; Sun, 22 Feb 2015 17:00:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPeZQ-00026P-1E for emacs-devel@gnu.org; Sun, 22 Feb 2015 17:00:15 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:45140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPeZP-00026K-TH for emacs-devel@gnu.org; Sun, 22 Feb 2015 17:00:11 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArsTAPOG1lTO+LI//2dsb2JhbABbgwaDX4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCzQSFBgNJIg4CM4jAQEBBwIBH494B4QqBYongxGcOoFFIoQMIIJzAQEB X-IPAS-Result: ArsTAPOG1lTO+LI//2dsb2JhbABbgwaDX4VTwGUEAgKBDUQBAQEBAQF8hA0BBAFWIwULCzQSFBgNJIg4CM4jAQEBBwIBH494B4QqBYongxGcOoFFIoQMIIJzAQEB X-IronPort-AV: E=Sophos;i="5.09,536,1418101200"; d="scan'208";a="111178215" Original-Received: from 206-248-178-63.dsl.teksavvy.com (HELO pastel.home) ([206.248.178.63]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Feb 2015 17:00:10 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id D7D731028; Sun, 22 Feb 2015 16:59:37 -0500 (EST) In-Reply-To: (Kelly Dean's message of "Sun, 22 Feb 2015 04:11:54 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 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:183402 Archived-At: > 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 =ABclosed tabs=BB 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