]> code.delx.au - gnu-emacs/blobdiff - lisp/saveplace.el
Fix previous rmail-output-read-file-name change
[gnu-emacs] / lisp / saveplace.el
index 0588bf258a765a60c80c0cda2daf47be8df4a087..43dad63a14055411a1b9b2f3cf08984567d9a5f6 100644 (file)
@@ -130,6 +130,15 @@ Files for which such a check may be inconvenient include those on
 removable and network volumes."
   :type 'regexp :group 'save-place)
 
+(defcustom save-place-ignore-files-regexp
+  "\\(?:COMMIT_EDITMSG\\|hg-editor-[[:alnum:]]+\\.txt\\|svn-commit\\.tmp\\|bzr_log\\.[[:alnum:]]+\\)$"
+  "Regexp matching files for which no position should be recorded.
+Useful for temporary file such as commit message files that are
+automatically created by the VCS.  If set to nil, this feature is
+disabled, i.e., the position is recorded for all files."
+  :version "24.1"
+  :type 'regexp :group 'save-place)
+
 (defun toggle-save-place (&optional parg)
   "Toggle whether to save your place in this file between sessions.
 If this mode is enabled, point is recorded when you kill the buffer
@@ -160,20 +169,22 @@ To save places automatically in all files, put this in your `.emacs' file:
   ;; file.  If not, do so, then feel free to modify the alist.  It
   ;; will be saved again when Emacs is killed.
   (or save-place-loaded (load-save-place-alist-from-file))
-  (if buffer-file-name
-      (progn
-        (let ((cell (assoc buffer-file-name save-place-alist))
-             (position (if (not (eq major-mode 'hexl-mode))
-                           (point)
-                         (with-no-warnings
-                           (1+ (hexl-current-address))))))
-          (if cell
-              (setq save-place-alist (delq cell save-place-alist)))
-         (if (and save-place
-                  (not (= position 1)))  ;; Optimize out the degenerate case.
-             (setq save-place-alist
-                   (cons (cons buffer-file-name position)
-                         save-place-alist)))))))
+  (when (and buffer-file-name
+            (or (not save-place-ignore-files-regexp)
+                (not (string-match save-place-ignore-files-regexp
+                                   buffer-file-name))))
+    (let ((cell (assoc buffer-file-name save-place-alist))
+         (position (if (not (eq major-mode 'hexl-mode))
+                       (point)
+                     (with-no-warnings
+                       (1+ (hexl-current-address))))))
+      (if cell
+         (setq save-place-alist (delq cell save-place-alist)))
+      (if (and save-place
+              (not (= position 1)))  ;; Optimize out the degenerate case.
+         (setq save-place-alist
+               (cons (cons buffer-file-name position)
+                     save-place-alist))))))
 
 (defun save-place-forget-unreadable-files ()
   "Remove unreadable files from `save-place-alist'.