4 |
|
|
5 |
;; Author: Hrvoje Niksic <hniksic@xemacs.org> |
;; Author: Hrvoje Niksic <hniksic@xemacs.org> |
6 |
;; Keywords: minibuffer |
;; Keywords: minibuffer |
7 |
;; Version: 19 |
;; Version: 23 |
8 |
|
|
9 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
10 |
|
|
64 |
Set this by calling the `savehist-mode' function or using the customize |
Set this by calling the `savehist-mode' function or using the customize |
65 |
interface." |
interface." |
66 |
:type 'boolean |
:type 'boolean |
67 |
:set (if (fboundp 'custom-set-minor-mode) |
:set (lambda (symbol value) (savehist-mode (or value 0))) |
|
'custom-set-minor-mode |
|
|
(lambda (symbol value) (funcall symbol (or value 0)))) |
|
68 |
:initialize 'custom-initialize-default |
:initialize 'custom-initialize-default |
69 |
:require 'savehist |
:require 'savehist |
70 |
:group 'savehist) |
:group 'savehist) |
133 |
save." |
save." |
134 |
:type 'hook) |
:type 'hook) |
135 |
|
|
136 |
(defvar savehist-coding-system |
;; This should be capable of representing characters used by Emacs. |
137 |
;; UTF-8 is usually preferable to ISO-2022-8 when available, but under |
;; We prefer UTF-8 over ISO 2022 because it is well-known outside |
138 |
;; XEmacs, UTF-8 is provided by external packages, and may not always be |
;; Mule. XEmacs prir to 21.5 had UTF-8 provided by an external |
139 |
;; available, so even if it currently is available, we prefer not to |
;; package which may not be loaded, which is why we check for version. |
140 |
;; use is. |
(defvar savehist-coding-system (if (and (featurep 'xemacs) |
141 |
(if (featurep 'xemacs) 'iso-2022-8 'utf-8) |
(<= emacs-major-version 21) |
142 |
|
(< emacs-minor-version 5)) |
143 |
|
'iso-2022-8 'utf-8) |
144 |
"The coding system savehist uses for saving the minibuffer history. |
"The coding system savehist uses for saving the minibuffer history. |
145 |
Changing this value while Emacs is running is supported, but considered |
Changing this value while Emacs is running is supported, but considered |
146 |
unwise, unless you know what you are doing.") |
unwise, unless you know what you are doing.") |
157 |
along with minibuffer history. You can change its value off |
along with minibuffer history. You can change its value off |
158 |
`savehist-save-hook' to influence which variables are saved.") |
`savehist-save-hook' to influence which variables are saved.") |
159 |
|
|
160 |
(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion) |
;; Coding system without any conversion, used for calculating an |
161 |
"Coding system without conversion, used for calculating internal checksums. |
;; internal checksum. Should be as fast as possible, ideally simply |
162 |
Should be as fast as possible, ideally simply exposing the internal |
;; exposing the internal representation of buffer text. |
163 |
representation of buffer text.") |
(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion)) |
164 |
|
|
165 |
(defvar savehist-loaded nil |
;; Whether the history has already been loaded. This prevents |
166 |
"Whether the history has already been loaded. |
;; toggling savehist-mode from destroying existing minibuffer history. |
167 |
This prevents toggling `savehist-mode' from destroying existing |
(defvar savehist-loaded nil) |
168 |
minibuffer history.") |
|
169 |
|
(when (featurep 'xemacs) |
170 |
(eval-when-compile |
;; Must declare this under XEmacs, which doesn't have built-in |
171 |
(when (featurep 'xemacs) |
;; minibuffer history truncation. |
172 |
;; Must declare this under XEmacs, which doesn't have built-in |
(defvar history-length 100)) |
|
;; minibuffer history truncation. |
|
|
(defvar history-length 100))) |
|
173 |
|
|
174 |
;; Functions. |
;; Functions. |
175 |
|
|
208 |
(savehist-uninstall) |
(savehist-uninstall) |
209 |
(signal (car errvar) (cdr errvar))))) |
(signal (car errvar) (cdr errvar))))) |
210 |
(savehist-install)) |
(savehist-install)) |
|
|
|
|
;; End with the usual minor-mode conventions normally provided |
|
|
;; transparently by define-minor-mode. |
|
|
(run-hooks 'savehist-mode-hook) |
|
|
(if (interactive-p) |
|
|
(progn |
|
|
(customize-mark-as-set 'savehist-mode) |
|
|
(unless (current-message) |
|
|
(message "Savehist mode %sabled" (if savehist-mode "en" "dis"))))) |
|
211 |
;; Return the new setting. |
;; Return the new setting. |
212 |
savehist-mode) |
savehist-mode) |
213 |
(add-minor-mode 'savehist-mode "") |
(add-minor-mode 'savehist-mode "") |
362 |
(error nil)))))) |
(error nil)))))) |
363 |
|
|
364 |
(defun savehist-minibuffer-hook () |
(defun savehist-minibuffer-hook () |
365 |
(add-to-list 'savehist-minibuffer-history-variables |
;; XEmacs sets minibuffer-history-variable to t to mean "no history |
366 |
minibuffer-history-variable)) |
;; is being recorded". |
367 |
|
(unless (eq minibuffer-history-variable t) |
368 |
|
(add-to-list 'savehist-minibuffer-history-variables |
369 |
|
minibuffer-history-variable))) |
370 |
|
|
371 |
(provide 'savehist) |
(provide 'savehist) |
372 |
|
|