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: Saving minibuffer history Date: Sun, 16 Oct 2005 11:39:19 -0400 Message-ID: <87zmp9sd0o.fsf-monnier+emacs@gnu.org> References: <87u0fkfc8c.fsf@xemacs.org> <873bn2s9cz.fsf@xemacs.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1129477228 17988 80.91.229.2 (16 Oct 2005 15:40:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 Oct 2005 15:40:28 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 16 17:40:22 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ERAbo-00041n-HD for ged-emacs-devel@m.gmane.org; Sun, 16 Oct 2005 17:39:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERAbn-0001e7-Hi for ged-emacs-devel@m.gmane.org; Sun, 16 Oct 2005 11:39:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ERAba-0001cF-NM for emacs-devel@gnu.org; Sun, 16 Oct 2005 11:39:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ERAbZ-0001bY-Uk for emacs-devel@gnu.org; Sun, 16 Oct 2005 11:39:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERAbZ-0001bV-QD for emacs-devel@gnu.org; Sun, 16 Oct 2005 11:39:21 -0400 Original-Received: from [209.226.175.110] (helo=tomts43-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ERAbZ-00071o-57; Sun, 16 Oct 2005 11:39:21 -0400 Original-Received: from alfajor ([70.48.83.21]) by tomts43-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20051016153919.SDH2981.tomts43-srv.bellnexxia.net@alfajor>; Sun, 16 Oct 2005 11:39:19 -0400 Original-Received: by alfajor (Postfix, from userid 1000) id 55945D7810; Sun, 16 Oct 2005 11:39:19 -0400 (EDT) Original-To: Hrvoje Niksic In-Reply-To: <873bn2s9cz.fsf@xemacs.org> (Hrvoje Niksic's message of "16 Oct 2005 00:28:44 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:44130 Archived-At: >> I installed it. Thanks. > Thank you. An improved version is now available at > . Thank you. Installed. Along with a few minor changes, mostly to remove run-time dependency on CL and to get rid of most checks for XEmacs, replaced by checks for features. I have one question: what's the point of savehist-no-conversion? Also see attached a proposed patch (100% guaranteed untested). If nobody objects, I'll install it. I could also get rid of savehist-history-variables altogether. Stefan 2005-10-16 Stefan Monnier * savehist.el (savehist-file): Use the ~/.emacs.d directory. (savehist-all-history-variables): New var. (savehist-minibuffer-hook): New fun to populate it. (savehist-save): Use and save it. (savehist-history-variables): Default to nil, meaning "all". Index: savehist.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/savehist.el,v retrieving revision 1.3 diff -u -u -b -r1.3 savehist.el --- savehist.el 16 Oct 2005 15:22:37 -0000 1.3 +++ savehist.el 16 Oct 2005 15:33:46 -0000 @@ -52,64 +52,20 @@ "Save minibuffer history." :group 'minibuffer) -(defcustom savehist-history-variables - '( - ;; Catch-all minibuffer history - minibuffer-history - ;; File-oriented commands - file-name-history - ;; Regexp-related reads - regexp-history - ;; Searches in minibuffer (via `M-r' and such) - minibuffer-history-search-history - ;; Query replace - query-replace-history - ;; eval-expression (`M-:') - read-expression-history - ;; shell-command (`M-!') - shell-command-history - ;; compile - compile-history - ;; find-tag (`M-.') - find-tag-history - ;; grep - grep-history - ;; Viper stuff - vip-ex-history vip-search-history - vip-replace1-history vip-replace2-history - vip-shell-history vip-search-history - - ;; XEmacs-specific: - ;; Buffer-related commands - buffer-history - ;; Reads of variables and functions - variable-history function-history - ;; Extended commands - read-command-history - - ;; Info, lookup, and bookmark historys - Info-minibuffer-history - Info-search-history - Manual-page-minibuffer-history - - ;; Emacs-specific: - ;; Extended commands - extended-command-history) +(defvar savehist-all-history-variables nil) + +(defcustom savehist-history-variables nil "*List of symbols to be saved. Every symbol should refer to a variable. The variable will be saved only if it is bound and has a non-nil value. Thus it is safe to specify a superset of the variables a user is expected to want to save. -Default value contains minibuffer history variables used by Emacs, XEmacs, -and Viper (uh-oh). Note that, if you customize this variable, you -can lose the benefit of future versions of Emacs adding new values to -the list. Because of that it might be more useful to add values using -`add-to-list'." +If nil, all history variables will be saved." :type '(repeat (symbol :tag "Variable")) :group 'savehist) -(defcustom savehist-file "~/.emacs-history" +(defcustom savehist-file "~/.emacs.d/history" "*File name to save minibuffer history to. The minibuffer history is a series of Lisp expressions, which should be loaded using `savehist-load' from your .emacs. See `savehist-load' for @@ -201,7 +157,11 @@ (print-level nil) (print-readably t) (print-quoted t)) - (dolist (sym savehist-history-variables) + (prin1 + `(setq savehist-all-history-variables ',savehist-all-history-variables) + (current-buffer)) + (dolist (sym (or savehist-history-variables + savehist-all-history-variables)) (when (boundp sym) (let ((value (savehist-process-for-saving (symbol-value sym)))) (prin1 `(setq ,sym ',value) (current-buffer)) @@ -261,6 +221,11 @@ t) ;; The attempt failed: the object is not printable. (error nil))))) + +(defun savehist-minibuffer-hook () + (add-to-list 'savehist-all-history-variables minibuffer-history-variable)) + +(add-hook 'minibuffer-setup-hook 'savehist-minibuffer-hook) (provide 'savehist)