comparison lisp/saveplace.el @ 15190:dc5aa17e7910

Merged cosmetic differences between FSF version and local copy. In the future, diffmon will make this unnecessary. (save-place-version): new var; init to 1.4. (save-place-limit): init to nil.
author Karl Fogel <kfogel@red-bean.com>
date Wed, 08 May 1996 20:02:29 +0000
parents ba3525471dae
children f2aaee52dfe1
comparison
equal deleted inserted replaced
15189:dd74ff8dad0b 15190:dc5aa17e7910
3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. 3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4 4
5 ;; Author: Karl Fogel <kfogel@cs.oberlin.edu> 5 ;; Author: Karl Fogel <kfogel@cs.oberlin.edu>
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Created: July, 1993 7 ;; Created: July, 1993
8 ;; Version: 1.2 8 ;; Version: See variable `save-place-version'.
9 ;; Keywords: bookmarks, placeholders 9 ;; Keywords: bookmarks, placeholders
10 10
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify 13 ;; GNU Emacs is free software; you can redistribute it and/or modify
22 22
23 ;; You should have received a copy of the GNU General Public License 23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA. 26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29 27
30 ;; Automatically save place in files, so that visiting them later 28 ;; Automatically save place in files, so that visiting them later
31 ;; (even during a different Emacs session) automatically moves point 29 ;; (even during a different Emacs session) automatically moves point
32 ;; to the saved position, when the file is first found. Uses the 30 ;; to the saved position, when the file is first found. Uses the
33 ;; value of buffer-local variable save-place to determine whether to 31 ;; value of buffer-local variable save-place to determine whether to
34 ;; save position or not. 32 ;; save position or not.
35 ;; 33 ;;
36 ;; Thanks to Stefan Schoef, who sent a patch with the 34 ;; Thanks to Stefan Schoef, who sent a patch with the
37 ;; `save-place-version-control' stuff in it. 35 ;; `save-place-version-control' stuff in it.
38 36
39 ;;; Code:
40
41 ;; this is what I was using during testing: 37 ;; this is what I was using during testing:
42 ;; (define-key ctl-x-map "p" 'toggle-save-place) 38 ;; (define-key ctl-x-map "p" 'toggle-save-place)
39
40 (defconst save-place-version "1.4"
41 "The version number of this release of saveplace. This is unrelated
42 to the version of Emacs itself, except that they change colinearly.")
43 43
44 (defvar save-place-alist nil 44 (defvar save-place-alist nil
45 "Alist of saved places to go back to when revisiting files. 45 "Alist of saved places to go back to when revisiting files.
46 Each element looks like (FILENAME . POSITION); 46 Each element looks like (FILENAME . POSITION);
47 visiting file FILENAME goes automatically to position POSITION 47 visiting file FILENAME goes automatically to position POSITION
112 (let ((cell (assoc buffer-file-name save-place-alist))) 112 (let ((cell (assoc buffer-file-name save-place-alist)))
113 (if cell 113 (if cell
114 (setq save-place-alist (delq cell save-place-alist)))) 114 (setq save-place-alist (delq cell save-place-alist))))
115 (if save-place 115 (if save-place
116 (setq save-place-alist 116 (setq save-place-alist
117 (cons (cons buffer-file-name 117 (cons (cons buffer-file-name
118 (if (not (eq major-mode 'hexl-mode)) 118 (if (not (eq major-mode 'hexl-mode))
119 (point) 119 (point)
120 (1+ (hexl-current-address)))) 120 (1+ (hexl-current-address))))
121 save-place-alist)))))) 121 save-place-alist))))))
122 122
123 (defun save-place-alist-to-file () 123 (defun save-place-alist-to-file ()
203 (defun save-place-find-file-hook () 203 (defun save-place-find-file-hook ()
204 (or save-place-loaded (load-save-place-alist-from-file)) 204 (or save-place-loaded (load-save-place-alist-from-file))
205 (let ((cell (assoc buffer-file-name save-place-alist))) 205 (let ((cell (assoc buffer-file-name save-place-alist)))
206 (if cell 206 (if cell
207 (progn 207 (progn
208 (or after-find-file-from-revert-buffer 208 (or after-find-file-from-revert-buffer
209 (goto-char (cdr cell))) 209 (goto-char (cdr cell)))
210 ;; and make sure it will be saved again for later 210 ;; and make sure it will be saved again for later
211 (setq save-place t))))) 211 (setq save-place t)))))
212 212
213 (defun save-place-kill-emacs-hook () 213 (defun save-place-kill-emacs-hook ()
214 ;; First update the alist. This loads the old save-place-file if nec. 214 ;; First update the alist. This loads the old save-place-file if nec.