aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-11-30 00:51:26 +0000
committerRichard M. Stallman1995-11-30 00:51:26 +0000
commit6cf025703d5f003fb2a3c3d439076823d1e8e347 (patch)
tree844a834e36651517c9dcd850e3a25027de959f24
parent07682ca3c964d8a20a49e14d0a3e85fbc29c0db9 (diff)
downloademacs-6cf025703d5f003fb2a3c3d439076823d1e8e347.tar.gz
emacs-6cf025703d5f003fb2a3c3d439076823d1e8e347.zip
(save-place-limit): New variable.
(load-save-place-alist-from-file): Obey it. Fix "done" message. (save-place-alist-to-file): Fix "done" message.
-rw-r--r--lisp/saveplace.el25
1 files changed, 23 insertions, 2 deletions
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 65f1e18c678..dafe1a707d9 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -69,6 +69,9 @@ value of `version-control'.")
69(defvar save-place-loaded nil 69(defvar save-place-loaded nil
70 "Non-nil means that the `save-place-file' has been loaded.") 70 "Non-nil means that the `save-place-file' has been loaded.")
71 71
72(defvar save-place-limit nil
73 "Maximum number of entries to retain in the list; nil means no limit.")
74
72(defun toggle-save-place (&optional parg) 75(defun toggle-save-place (&optional parg)
73 "Toggle whether to save your place in this file between sessions. 76 "Toggle whether to save your place in this file between sessions.
74If this mode is enabled, point is recorded when you kill the buffer 77If this mode is enabled, point is recorded when you kill the buffer
@@ -133,7 +136,7 @@ To save places automatically in all files, put this in your `.emacs' file:
133 t)))) 136 t))))
134 (write-file file) 137 (write-file file)
135 (kill-buffer (current-buffer)) 138 (kill-buffer (current-buffer))
136 (message (format "Saving places to %s... done." file)))))) 139 (message (format "Saving places to %s...done" file))))))
137 140
138(defun load-save-place-alist-from-file () 141(defun load-save-place-alist-from-file ()
139 (if (not save-place-loaded) 142 (if (not save-place-loaded)
@@ -155,8 +158,26 @@ To save places automatically in all files, put this in your `.emacs' file:
155 (setq save-place-alist 158 (setq save-place-alist
156 (car (read-from-string 159 (car (read-from-string
157 (buffer-substring (point-min) (point-max))))) 160 (buffer-substring (point-min) (point-max)))))
161
162 ;; If there is a limit, and we're over it, then we'll
163 ;; have to truncate the end of the list:
164 (if save-place-limit
165 (if (<= save-place-limit 0)
166 ;; Zero gets special cased. I'm not thrilled
167 ;; with this, but the loop for >= 1 is tight.
168 (setq save-place-alist nil)
169 ;; Else the limit is >= 1, so enforce it by
170 ;; counting and then `setcdr'ing.
171 (let ((s save-place-alist)
172 (count 1))
173 (while s
174 (if (>= count save-place-limit)
175 (setcdr s nil)
176 (setq count (1+ count)))
177 (setq s (cdr s))))))
178
158 (kill-buffer (current-buffer)) 179 (kill-buffer (current-buffer))
159 (message (format "Loading places from %s... done." file)) 180 (message (format "Loading places from %s...done" file))
160 t) 181 t)
161 t) 182 t)
162 nil)))) 183 nil))))