comparison lisp/bookmark.el @ 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
comparison
equal deleted inserted replaced
106701:a3eff1130b76 106702:d4fd57e5eafd
1834 (bookmark-jump (car others)) 1834 (bookmark-jump (car others))
1835 (setq others (cdr others))) 1835 (setq others (cdr others)))
1836 (other-window 1)))) 1836 (other-window 1))))
1837 1837
1838 1838
1839 (defun bookmark-bmenu-any-marks ()
1840 "Return non-nil if any bookmarks are marked in the marks column."
1841 (save-excursion
1842 (goto-char (point-min))
1843 (bookmark-bmenu-ensure-position)
1844 (catch 'found-mark
1845 (while (not (eobp))
1846 (beginning-of-line)
1847 (if (looking-at "^\\S-")
1848 (throw 'found-mark t)
1849 (forward-line 1)))
1850 nil)))
1851
1852
1839 (defun bookmark-bmenu-save (parg) 1853 (defun bookmark-bmenu-save (parg)
1840 "Save the current list into a bookmark file. 1854 "Save the current list into a bookmark file.
1841 With a prefix arg, prompts for a file to save them in." 1855 With a prefix arg, prompts for a file to save them in."
1842 (interactive "P") 1856 (interactive "P")
1843 (save-excursion 1857 (save-excursion
1844 (save-window-excursion 1858 (save-window-excursion
1845 (bookmark-save parg)))) 1859 (bookmark-save parg)))
1860 ;; Show the buffer as unmodified after saving, but only if there are
1861 ;; no marks: marks are not saved with the bookmarks, therefore from
1862 ;; the user's point of view they are a "modification" in the buffer
1863 ;;
1864 ;; FIXME: Ideally, if the buffer were unmodified when there are no
1865 ;; marks, and then some marks are made and removed without being
1866 ;; executed, then the buffer would be restored to unmodified state.
1867 ;; But that would require bookmark-specific logic to track buffer
1868 ;; modification. It might be worth it, but it's fine not to have it
1869 ;; too -- the worst outcome is that the user might be tempted to
1870 ;; save the bookmark list when it technically doesn't need saving.
1871 (if (not (bookmark-bmenu-any-marks))
1872 (set-buffer-modified-p nil)))
1846 1873
1847 1874
1848 (defun bookmark-bmenu-load () 1875 (defun bookmark-bmenu-load ()
1849 "Load the bookmark file and rebuild the bookmark menu-buffer." 1876 "Load the bookmark file and rebuild the bookmark menu-buffer."
1850 (interactive) 1877 (interactive)