]> code.delx.au - gnu-emacs/blobdiff - lisp/savehist.el
Rename `MS-DOG' into `MS-DOS'.
[gnu-emacs] / lisp / savehist.el
index f8c39a31cb57e41ff18734711a08214c44070dd9..3a5c0ae034782e9c42867d21defab01ddc3a95bc 100644 (file)
@@ -1,6 +1,6 @@
 ;;; savehist.el --- Save minibuffer history.
 
-;; Copyright (C) 1997,2005 Free Software Foundation
+;; Copyright (C) 1997, 2005, 2006 Free Software Foundation
 
 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
 ;; Keywords: minibuffer
@@ -56,6 +56,7 @@
 
 (defgroup savehist nil
   "Save minibuffer history."
+  :version "22.1"
   :group 'minibuffer)
 
 ;;;###autoload
@@ -91,6 +92,11 @@ minibuffer histories, such as `compile-command' or `kill-ring'."
   :type '(repeat variable)
   :group 'savehist)
 
+(defcustom savehist-ignored-variables nil ;; '(command-history)
+  "*List of additional variables not to save."
+  :type '(repeat variable)
+  :group 'savehist)
+
 (defcustom savehist-file
   (cond
    ;; Backward compatibility with previous versions of savehist.
@@ -129,13 +135,15 @@ If set to nil, disables timer-based autosaving."
 
 (defcustom savehist-mode-hook nil
   "Hook called when `savehist-mode' is turned on."
-  :type 'hook)
+  :type 'hook
+  :group 'savehist)
 
 (defcustom savehist-save-hook nil
   "Hook called by `savehist-save' before saving the variables.
 You can use this hook to influence choice and content of variables to
 save."
-  :type 'hook)
+  :type 'hook
+  :group 'savehist)
 
 ;; This should be capable of representing characters used by Emacs.
 ;; We prefer UTF-8 over ISO 2022 because it is well-known outside
@@ -169,7 +177,7 @@ buffer text.")
 
 (defvar savehist-loaded nil
   "Whether the history has already been loaded.
-This prevents toggling savehist-mode from destroying existing
+This prevents toggling `savehist-mode' from destroying existing
 minibuffer history.")
 
 (when (featurep 'xemacs)
@@ -224,9 +232,9 @@ which is probably undesirable."
 Don't call this from new code, use (savehist-mode 1) instead.
 
 This function loads the variables stored in `savehist-file' and turns on
-savehist-mode.  If savehist-file is in the old format that doesn't record
-the value of `savehist-minibuffer-history-variables', that value is
-deducted from the contents of the file."
+`savehist-mode'.  If `savehist-file' is in the old format that doesn't
+record the value of `savehist-minibuffer-history-variables', that value
+is deducted from the contents of the file."
   (savehist-mode 1)
   ;; Old versions of savehist distributed with XEmacs didn't save
   ;; savehist-minibuffer-history-variables.  If that variable is nil
@@ -248,8 +256,8 @@ deducted from the contents of the file."
 (defun savehist-install ()
   "Hook savehist into Emacs.
 Normally invoked by calling `savehist-mode' to set the minor mode.
-Installs `savehist-autosave' in `kill-emacs-hook' and on a timer.   To
-undo this, call `savehist-uninstall'."
+Installs `savehist-autosave' in `kill-emacs-hook' and on a timer.
+To undo this, call `savehist-uninstall'."
   (add-hook 'minibuffer-setup-hook 'savehist-minibuffer-hook)
   (add-hook 'kill-emacs-hook 'savehist-autosave)
   ;; Install an invocation of savehist-autosave on a timer.  This
@@ -331,14 +339,14 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved,
 
 (defun savehist-autosave ()
   "Save the minibuffer history if it has been modified since the last save.
-Does nothing if savehist-mode is off."
+Does nothing if `savehist-mode' is off."
   (when savehist-mode
     (savehist-save t)))
 
 (defun savehist-trim-history (value)
-  "Retain only the first history-length items in VALUE.
+  "Retain only the first `history-length' items in VALUE.
 Only used under XEmacs, which doesn't (yet) implement automatic
-trimming of history lists to history-length items."
+trimming of history lists to `history-length' items."
   (if (and (featurep 'xemacs)
           (natnump history-length)
           (> (length value) history-length))
@@ -369,9 +377,10 @@ trimming of history lists to history-length items."
        (error nil))))))
 
 (defun savehist-minibuffer-hook ()
-  ;; XEmacs sets minibuffer-history-variable to t to mean "no history
-  ;; is being recorded".
-  (unless (eq minibuffer-history-variable t)
+  (unless (or (eq minibuffer-history-variable t)
+             ;; XEmacs sets minibuffer-history-variable to t to mean "no
+             ;; history is being recorded".
+             (memq minibuffer-history-variable savehist-ignored-variables))
     (add-to-list 'savehist-minibuffer-history-variables
                 minibuffer-history-variable)))