changeset 106702:d4fd57e5eafd

* lisp/bookmark.el (bookmark-bmenu-any-marks): New function (bookmark-bmenu-save): Clear buffer modification if no marks.
author Karl Fogel <kfogel@red-bean.com>
date Sat, 02 Jan 2010 02:08:02 -0500
parents a3eff1130b76
children 0ea26a56f9de
files lisp/ChangeLog lisp/bookmark.el
diffstat 2 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Jan 02 00:00:55 2010 -0500
+++ b/lisp/ChangeLog	Sat Jan 02 02:08:02 2010 -0500
@@ -1,6 +1,11 @@
 2010-01-02  Karl Fogel  <kfogel@red-bean.com>
 
-	* lisp/bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
+	* bookmark.el (bookmark-bmenu-any-marks): New function
+	(bookmark-bmenu-save): Clear buffer modification if no marks.
+
+2010-01-02  Karl Fogel  <kfogel@red-bean.com>
+
+	* bookmark.el (bookmark-bmenu-marks-width): Define to 1, not 2.
 	(bookmark-bmenu-list, bookmark-bmenu-bookmark): Calculate property
 	positions by using `bookmark-bmenu-marks-width', instead of hardcoding.
 	This fixes the `bookmark-bmenu-execute-deletions' bug reported here:
--- a/lisp/bookmark.el	Sat Jan 02 00:00:55 2010 -0500
+++ b/lisp/bookmark.el	Sat Jan 02 02:08:02 2010 -0500
@@ -1836,13 +1836,40 @@
       (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 ()