summaryrefslogtreecommitdiff
path: root/lisp/bookmark.el
diff options
context:
space:
mode:
authorKarl Fogel <kfogel@red-bean.com>2010-01-02 02:08:02 -0500
committerKarl Fogel <kfogel@red-bean.com>2010-01-02 02:08:02 -0500
commit479899451b22eae5db2109c97862652309128a81 (patch)
treefcd619703a4c2740a669e5265c61ac4482d58111 /lisp/bookmark.el
parent5ae329f4c86fa4eff1d30d80f82e4d80ff3da81d (diff)
downloademacs-479899451b22eae5db2109c97862652309128a81.tar.gz
* lisp/bookmark.el (bookmark-bmenu-any-marks): New function
(bookmark-bmenu-save): Clear buffer modification if no marks.
Diffstat (limited to 'lisp/bookmark.el')
-rw-r--r--lisp/bookmark.el29
1 files changed, 28 insertions, 1 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 190ce58689f..eb841921b3e 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1836,13 +1836,40 @@ You can mark bookmarks with the \\<bookmark-bmenu-mode-map>\\[bookmark-bmenu-mar
(other-window 1))))
+(defun bookmark-bmenu-any-marks ()
+ "Return non-nil if any bookmarks are marked in the marks column."
+ (save-excursion
+ (goto-char (point-min))
+ (bookmark-bmenu-ensure-position)
+ (catch 'found-mark
+ (while (not (eobp))
+ (beginning-of-line)
+ (if (looking-at "^\\S-")
+ (throw 'found-mark t)
+ (forward-line 1)))
+ nil)))
+
+
(defun bookmark-bmenu-save (parg)
"Save the current list into a bookmark file.
With a prefix arg, prompts for a file to save them in."
(interactive "P")
(save-excursion
(save-window-excursion
- (bookmark-save parg))))
+ (bookmark-save parg)))
+ ;; Show the buffer as unmodified after saving, but only if there are
+ ;; no marks: marks are not saved with the bookmarks, therefore from
+ ;; the user's point of view they are a "modification" in the buffer
+ ;;
+ ;; FIXME: Ideally, if the buffer were unmodified when there are no
+ ;; marks, and then some marks are made and removed without being
+ ;; executed, then the buffer would be restored to unmodified state.
+ ;; But that would require bookmark-specific logic to track buffer
+ ;; modification. It might be worth it, but it's fine not to have it
+ ;; too -- the worst outcome is that the user might be tempted to
+ ;; save the bookmark list when it technically doesn't need saving.
+ (if (not (bookmark-bmenu-any-marks))
+ (set-buffer-modified-p nil)))
(defun bookmark-bmenu-load ()