unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14377: 24.3.50; patch: run a hook after `bookmark-write'
@ 2013-05-09 20:22 Eduard Wiebe
  2013-05-10 21:09 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Eduard Wiebe @ 2013-05-09 20:22 UTC (permalink / raw)
  To: 14377

[-- Attachment #1: Type: text/plain, Size: 107 bytes --]

 
   Hello,

i want always to export my bookmarks when bookmark file is saved.
Consider this simple patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bookmark.after.save.hook.patch --]
[-- Type: text/x-diff, Size: 786 bytes --]

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 482cdf9..ee561db 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1311,6 +1311,9 @@ Don't use this in Lisp programs; use `bookmark-save' instead."
   (bookmark-save t))


+(defvar bookmark-after-save-hook nil
+  "Hook run after bookmark file was saved.")
+
 ;;;###autoload
 (defun bookmark-save (&optional parg file)
   "Save currently defined bookmarks.
@@ -1380,5 +1383,6 @@ for a file, defaulting to the file defined by variable
             (write-region (point-min) (point-max) file)
           (file-error (message "Can't write %s" file)))
         (kill-buffer (current-buffer))
+        (run-hooks 'bookmark-after-save-hook)
         (bookmark-maybe-message
          "Saving bookmarks to file %s...done" file)))))

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#14377: 24.3.50; patch: run a hook after `bookmark-write'
  2013-05-09 20:22 bug#14377: 24.3.50; patch: run a hook after `bookmark-write' Eduard Wiebe
@ 2013-05-10 21:09 ` Stefan Monnier
  2013-05-11 19:30   ` Eduard Wiebe
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-05-10 21:09 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 14377

> I want always to export my bookmarks when bookmark file is saved.
> Consider this simple patch.

You could use

  (defadvice bookmark-write-file (after export activate)
    (do what I want))

Of course, we could also install something like your patch, but the hook
functions will probably need access to the file name (which might turn into
a lexically scoped var any time).


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14377: 24.3.50; patch: run a hook after `bookmark-write'
  2013-05-10 21:09 ` Stefan Monnier
@ 2013-05-11 19:30   ` Eduard Wiebe
  2013-05-12  1:42     ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: Eduard Wiebe @ 2013-05-11 19:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eduard Wiebe, 14377

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> I want always to export my bookmarks when bookmark file is saved.
>> Consider this simple patch.
>
> You could use
>
>   (defadvice bookmark-write-file (after export activate)
>     (do what I want))

Sure.

> Of course, we could also install something like your patch, but the hook
> functions will probably need access to the file name (which might turn into
> a lexically scoped var any time).

Ahh.., that was not clear to me. Thanks for the hint.
Please close this report.

--
Eduard Wiebe





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14377: 24.3.50; patch: run a hook after `bookmark-write'
  2013-05-11 19:30   ` Eduard Wiebe
@ 2013-05-12  1:42     ` Glenn Morris
  2013-05-12 18:01       ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2013-05-12  1:42 UTC (permalink / raw)
  To: 14377


>> Of course, we could also install something like your patch, but the hook
>> functions will probably need access to the file name (which might turn into
>> a lexically scoped var any time).

Aren't matters of extensibility like this one reason why

http://www.gnu.org/software/emacs/emacs-paper.html#SEC15

favours dynamic binding?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14377: 24.3.50; patch: run a hook after `bookmark-write'
  2013-05-12  1:42     ` Glenn Morris
@ 2013-05-12 18:01       ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2013-05-12 18:01 UTC (permalink / raw)
  To: 'Glenn Morris', 14377; +Cc: 'Eduard Wiebe'

> >> Of course, we could also install something like your 
> >> patch, but the hook functions will probably need access
> >> to the file name (which might turn into a lexically
> >> scoped var any time).
> 
> Aren't matters of extensibility like this one reason why
> http://www.gnu.org/software/emacs/emacs-paper.html#SEC15
> favours dynamic binding?

;-)

FWIW, Bookmark+ has such a hook: `bmkp-write-bookmark-file-hook'.  (And it
passes the file name to the hook functions.)






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-12 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 20:22 bug#14377: 24.3.50; patch: run a hook after `bookmark-write' Eduard Wiebe
2013-05-10 21:09 ` Stefan Monnier
2013-05-11 19:30   ` Eduard Wiebe
2013-05-12  1:42     ` Glenn Morris
2013-05-12 18:01       ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).