Mercurial > emacs
comparison lisp/bookmark.el @ 34529:8e38e93616a7
* bookmark.el: Provide a generic exit hook, as suggested by Ovidiu
Predescu <ovidiu@cup.hp.com>:
(bookmark-exit-hook): new var.
(bookmark-exit-hook-internal): new func, replaces old raw lambda form
in `kill-emacs-hook', and runs new `bookmark-exit-hooks'. No longer
tests for the bookmark feature, as logically that feature must have
been provided if this function is running.
Removed ;;;###autoload before the `add-hook' call.
author | Karl Fogel <kfogel@red-bean.com> |
---|---|
date | Wed, 13 Dec 2000 22:56:38 +0000 |
parents | 0797cad76554 |
children | ac715b4413f7 |
comparison
equal
deleted
inserted
replaced
34528:add308ec5e6e | 34529:8e38e93616a7 |
---|---|
297 `info-node' is optional, by the way.") | 297 `info-node' is optional, by the way.") |
298 | 298 |
299 | 299 |
300 (defvar bookmarks-already-loaded nil) | 300 (defvar bookmarks-already-loaded nil) |
301 | 301 |
302 | |
303 ;; just add the hook to make sure that people don't lose bookmarks | |
304 ;; when they kill Emacs, unless they don't want to save them. | |
305 ;;;###autoload | |
306 (add-hook 'kill-emacs-hook | |
307 (function | |
308 (lambda () (and (featurep 'bookmark) | |
309 bookmark-alist | |
310 (bookmark-time-to-save-p t) | |
311 (bookmark-save))))) | |
312 | 302 |
313 ;; more stuff added by db. | 303 ;; more stuff added by db. |
314 | 304 |
315 (defvar bookmark-current-bookmark nil | 305 (defvar bookmark-current-bookmark nil |
316 "Name of bookmark most recently used in the current file. | 306 "Name of bookmark most recently used in the current file. |
2267 | 2257 |
2268 ;;; Load Hook | 2258 ;;; Load Hook |
2269 (defvar bookmark-load-hook nil | 2259 (defvar bookmark-load-hook nil |
2270 "Hook to run at the end of loading bookmark.") | 2260 "Hook to run at the end of loading bookmark.") |
2271 | 2261 |
2262 ;;; Exit Hook, called from kill-emacs-hook | |
2263 (defvar bookmark-exit-hook nil | |
2264 "Hook to run when emacs exits") | |
2265 | |
2266 (defun bookmark-exit-hook-internal () | |
2267 "Save bookmark state, if necessary, at Emacs exit time. | |
2268 This also runs `bookmark-exit-hooks'." | |
2269 (and | |
2270 (progn (run-hooks 'bookmark-exit-hooks) t) | |
2271 bookmark-alist | |
2272 (bookmark-time-to-save-p t) | |
2273 (bookmark-save))) | |
2274 | |
2275 (add-hook 'kill-emacs-hook 'bookmark-exit-hook-internal) | |
2276 | |
2277 | |
2272 (run-hooks 'bookmark-load-hook) | 2278 (run-hooks 'bookmark-load-hook) |
2273 | 2279 |
2274 (provide 'bookmark) | 2280 (provide 'bookmark) |
2275 | 2281 |
2276 ;;; bookmark.el ends here | 2282 ;;; bookmark.el ends here |