aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-19 22:37:33 +0200
committerLars Ingebrigtsen2019-06-19 22:37:33 +0200
commita97ba6eb305c9db8641c0e65748907cd53dbfa5e (patch)
treeaab26f16379eabe23dde242dfefba8243ecd3dbd
parent8064f64eb14882f68851cc8f91b86fb287589499 (diff)
downloademacs-a97ba6eb305c9db8641c0e65748907cd53dbfa5e.tar.gz
emacs-a97ba6eb305c9db8641c0e65748907cd53dbfa5e.zip
Remove XEmacs compat code from savehist.el
* lisp/savehist.el: (savehist-install, savehist-uninstall, savehist-save) (savehist-trim-history, savehist-printable) (savehist-minibuffer-hook): Remove XEmacs compat code.
-rw-r--r--lisp/savehist.el65
1 files changed, 15 insertions, 50 deletions
diff --git a/lisp/savehist.el b/lisp/savehist.el
index 79ab8483868..6f79369f0c5 100644
--- a/lisp/savehist.el
+++ b/lisp/savehist.el
@@ -48,8 +48,6 @@
48;;; Code: 48;;; Code:
49 49
50(require 'custom) 50(require 'custom)
51(eval-when-compile
52 (if (featurep 'xemacs) (require 'cl)))
53 51
54;; User variables 52;; User variables
55 53
@@ -120,12 +118,8 @@ to save."
120 118
121;; This should be capable of representing characters used by Emacs. 119;; This should be capable of representing characters used by Emacs.
122;; We prefer UTF-8 over ISO 2022 because it is well-known outside 120;; We prefer UTF-8 over ISO 2022 because it is well-known outside
123;; Mule. XEmacs prior to 21.5 had UTF-8 provided by an external 121;; Mule.
124;; package which may not be loaded, which is why we check for version. 122(defvar savehist-coding-system 'utf-8-unix
125(defvar savehist-coding-system (if (and (featurep 'xemacs)
126 (<= emacs-major-version 21)
127 (< emacs-minor-version 5))
128 'iso-2022-8 'utf-8-unix)
129 "The coding system Savehist uses for saving the minibuffer history. 123 "The coding system Savehist uses for saving the minibuffer history.
130Changing this value while Emacs is running is supported, but considered 124Changing this value while Emacs is running is supported, but considered
131unwise, unless you know what you are doing.") 125unwise, unless you know what you are doing.")
@@ -147,10 +141,6 @@ along with minibuffer history. You can change its value off
147This prevents toggling Savehist mode from destroying existing 141This prevents toggling Savehist mode from destroying existing
148minibuffer history.") 142minibuffer history.")
149 143
150(when (featurep 'xemacs)
151 ;; Must declare this under XEmacs, which doesn't have built-in
152 ;; minibuffer history truncation.
153 (defvar history-length 100))
154 144
155;; Functions. 145;; Functions.
156 146
@@ -217,12 +207,8 @@ To undo this, call `savehist-uninstall'."
217 (when (and savehist-autosave-interval 207 (when (and savehist-autosave-interval
218 (null savehist-timer)) 208 (null savehist-timer))
219 (setq savehist-timer 209 (setq savehist-timer
220 (if (featurep 'xemacs) 210 (run-with-timer savehist-autosave-interval
221 (start-itimer 211 savehist-autosave-interval #'savehist-autosave))))
222 "savehist" #'savehist-autosave savehist-autosave-interval
223 savehist-autosave-interval)
224 (run-with-timer savehist-autosave-interval
225 savehist-autosave-interval #'savehist-autosave)))))
226 212
227(defun savehist-uninstall () 213(defun savehist-uninstall ()
228 "Undo installing savehist. 214 "Undo installing savehist.
@@ -230,15 +216,9 @@ Normally invoked by calling `savehist-mode' to unset the minor mode."
230 (remove-hook 'minibuffer-setup-hook #'savehist-minibuffer-hook) 216 (remove-hook 'minibuffer-setup-hook #'savehist-minibuffer-hook)
231 (remove-hook 'kill-emacs-hook #'savehist-autosave) 217 (remove-hook 'kill-emacs-hook #'savehist-autosave)
232 (when savehist-timer 218 (when savehist-timer
233 (if (featurep 'xemacs) 219 (cancel-timer savehist-timer)
234 (delete-itimer savehist-timer)
235 (cancel-timer savehist-timer))
236 (setq savehist-timer nil))) 220 (setq savehist-timer nil)))
237 221
238;; From XEmacs?
239(defvar print-readably)
240(defvar print-string-length)
241
242(defun savehist-save (&optional auto-save) 222(defun savehist-save (&optional auto-save)
243 "Save the values of minibuffer history variables. 223 "Save the values of minibuffer history variables.
244Unbound symbols referenced in `savehist-additional-variables' are ignored. 224Unbound symbols referenced in `savehist-additional-variables' are ignored.
@@ -255,9 +235,7 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved,
255 savehist-coding-system)) 235 savehist-coding-system))
256 (run-hooks 'savehist-save-hook) 236 (run-hooks 'savehist-save-hook)
257 (let ((print-length nil) 237 (let ((print-length nil)
258 (print-string-length nil)
259 (print-level nil) 238 (print-level nil)
260 (print-readably t)
261 (print-quoted t)) 239 (print-quoted t))
262 ;; Save the minibuffer histories, along with the value of 240 ;; Save the minibuffer histories, along with the value of
263 ;; savehist-minibuffer-history-variables itself. 241 ;; savehist-minibuffer-history-variables itself.
@@ -269,7 +247,7 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved,
269 (dolist (symbol savehist-minibuffer-history-variables) 247 (dolist (symbol savehist-minibuffer-history-variables)
270 (when (and (boundp symbol) 248 (when (and (boundp symbol)
271 (not (memq symbol savehist-ignored-variables))) 249 (not (memq symbol savehist-ignored-variables)))
272 (let ((value (savehist-trim-history (symbol-value symbol))) 250 (let ((value (symbol-value symbol))
273 excess-space) 251 excess-space)
274 (when value ; Don't save empty histories. 252 (when value ; Don't save empty histories.
275 (insert "(setq ") 253 (insert "(setq ")
@@ -334,17 +312,7 @@ Does nothing if Savehist mode is off."
334 (when savehist-mode 312 (when savehist-mode
335 (savehist-save t))) 313 (savehist-save t)))
336 314
337(defun savehist-trim-history (value) 315(define-obsolete-function-alias 'savehist-trim-history #'identity "27.1")
338 "Retain only the first `history-length' items in VALUE.
339Only used under XEmacs, which doesn't (yet) implement automatic
340trimming of history lists to `history-length' items."
341 (if (and (featurep 'xemacs)
342 (natnump history-length)
343 (> (length value) history-length))
344 ;; Equivalent to `(subseq value 0 history-length)', but doesn't
345 ;; need cl-extra at run-time.
346 (loop repeat history-length collect (pop value))
347 value))
348 316
349(defun savehist-printable (value) 317(defun savehist-printable (value)
350 "Return non-nil if VALUE is printable." 318 "Return non-nil if VALUE is printable."
@@ -359,21 +327,18 @@ trimming of history lists to `history-length' items."
359 ;; For others, check explicitly. 327 ;; For others, check explicitly.
360 (with-temp-buffer 328 (with-temp-buffer
361 (condition-case nil 329 (condition-case nil
362 (let ((print-readably t) (print-level nil)) 330 (let ((print-level nil))
363 ;; Print the value into a buffer... 331 ;; Print the value into a buffer...
364 (prin1 value (current-buffer)) 332 (prin1 value (current-buffer))
365 ;; ...and attempt to read it. 333 ;; ...and attempt to read it.
366 (read (point-min-marker)) 334 (read (point-min-marker))
367 ;; The attempt worked: the object is printable. 335 ;; The attempt worked: the object is printable.
368 t) 336 t)
369 ;; The attempt failed: the object is not printable. 337 ;; The attempt failed: the object is not printable.
370 (error nil)))))) 338 (error nil))))))
371 339
372(defun savehist-minibuffer-hook () 340(defun savehist-minibuffer-hook ()
373 (unless (or (eq minibuffer-history-variable t) 341 (unless (memq minibuffer-history-variable savehist-ignored-variables)
374 ;; XEmacs sets minibuffer-history-variable to t to mean "no
375 ;; history is being recorded".
376 (memq minibuffer-history-variable savehist-ignored-variables))
377 (add-to-list 'savehist-minibuffer-history-variables 342 (add-to-list 'savehist-minibuffer-history-variables
378 minibuffer-history-variable))) 343 minibuffer-history-variable)))
379 344