aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2012-02-17 21:19:30 +0100
committerTassilo Horn2012-02-17 21:19:30 +0100
commit0311a3fc3d16d3dd7b34036a0b1ae063afadafa5 (patch)
tree23ee5c68e49f8cbe8e10bcc521577e69fb272096
parenteb864a71bd9a3ecf02dc994dcefd561aca0fdd4d (diff)
downloademacs-0311a3fc3d16d3dd7b34036a0b1ae063afadafa5.tar.gz
emacs-0311a3fc3d16d3dd7b34036a0b1ae063afadafa5.zip
2012-02-17 Tassilo Horn <tassilo@member.fsf.org>
* saveplace.el (save-place-ignore-files-regexp): New variable allowing for excluding files from saving their location. The default value matches the temporary commit message editing files from Git, SVN, Bazaar, and Mercurial. (save-place-to-alist): Use it.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/saveplace.el36
2 files changed, 30 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3d15010e16d..cbb9265a35e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-02-17 Tassilo Horn <tassilo@member.fsf.org>
2
3 * saveplace.el (save-place-ignore-files-regexp): New variable
4 allowing for excluding files from saving their location of point.
5 The default value matches the temporary commit message editing
6 files from Git, SVN, Bazaar, and Mercurial.
7 (save-place-to-alist): Use it.
8
12012-02-17 Lawrence Mitchell <wence@gmx.li> 92012-02-17 Lawrence Mitchell <wence@gmx.li>
2 Stefan Monnier <monnier@iro.umontreal.ca> 10 Stefan Monnier <monnier@iro.umontreal.ca>
3 11
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 0588bf258a7..5850d2b8d33 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -130,6 +130,13 @@ Files for which such a check may be inconvenient include those on
130removable and network volumes." 130removable and network volumes."
131 :type 'regexp :group 'save-place) 131 :type 'regexp :group 'save-place)
132 132
133(defcustom save-place-ignore-files-regexp
134 "\\(?:COMMIT_EDITMSG\\|hg-editor-[[:alnum:]]+\\.txt\\|svn-commit\\.tmp\\|bzr_log\\.[[:alnum:]]+\\)$"
135 "Regexp matching files for which no location should be recorded.
136Useful for temporary file such as commit message files that are
137automatically created by the VCS."
138 :type 'regexp :group 'save-place)
139
133(defun toggle-save-place (&optional parg) 140(defun toggle-save-place (&optional parg)
134 "Toggle whether to save your place in this file between sessions. 141 "Toggle whether to save your place in this file between sessions.
135If this mode is enabled, point is recorded when you kill the buffer 142If this mode is enabled, point is recorded when you kill the buffer
@@ -160,20 +167,21 @@ To save places automatically in all files, put this in your `.emacs' file:
160 ;; file. If not, do so, then feel free to modify the alist. It 167 ;; file. If not, do so, then feel free to modify the alist. It
161 ;; will be saved again when Emacs is killed. 168 ;; will be saved again when Emacs is killed.
162 (or save-place-loaded (load-save-place-alist-from-file)) 169 (or save-place-loaded (load-save-place-alist-from-file))
163 (if buffer-file-name 170 (when (and buffer-file-name
164 (progn 171 (not (string-match save-place-ignore-files-regexp
165 (let ((cell (assoc buffer-file-name save-place-alist)) 172 buffer-file-name)))
166 (position (if (not (eq major-mode 'hexl-mode)) 173 (let ((cell (assoc buffer-file-name save-place-alist))
167 (point) 174 (position (if (not (eq major-mode 'hexl-mode))
168 (with-no-warnings 175 (point)
169 (1+ (hexl-current-address)))))) 176 (with-no-warnings
170 (if cell 177 (1+ (hexl-current-address))))))
171 (setq save-place-alist (delq cell save-place-alist))) 178 (if cell
172 (if (and save-place 179 (setq save-place-alist (delq cell save-place-alist)))
173 (not (= position 1))) ;; Optimize out the degenerate case. 180 (if (and save-place
174 (setq save-place-alist 181 (not (= position 1))) ;; Optimize out the degenerate case.
175 (cons (cons buffer-file-name position) 182 (setq save-place-alist
176 save-place-alist))))))) 183 (cons (cons buffer-file-name position)
184 save-place-alist))))))
177 185
178(defun save-place-forget-unreadable-files () 186(defun save-place-forget-unreadable-files ()
179 "Remove unreadable files from `save-place-alist'. 187 "Remove unreadable files from `save-place-alist'.