* Final bookmark exporting
@ 2009-11-02 22:55 andrea Crotti
0 siblings, 0 replies; only message in thread
From: andrea Crotti @ 2009-11-02 22:55 UTC (permalink / raw
To: emacs-orgmode
Given that I finally have my nice org-agenda-files
defined I would also like to have an automatic bookmark exporting.
I was thinking to something like
hook on write-file that
- checks if file is org-mode and in the org-directories
- if it is and not in agenda files add it (and not do the whole scan again)
- otherwise start the bookmark exportation for that file
(and also ICS export)
I don't know if it's possible to do them incrementally though.
It would be nice to add only new bookmarks, but that could be complicated...
And in plus I need a way to tell the programs to reload it.
For ICS files I could just put them in a webdav directory but I
don't know about bookmarks, any idea?
Isn't there a format for bookmarks that work for every browser maybe?
I tried this ugly code
(defun org-to-bookmarks ()
(interactive)
(dolist (org-file org-agenda-files)
(find-file org-file)
(org-export-html-bookmarks)
(let ((fbook (concat (file-name-sans-extension org-file) "-bookmarks.html")))
(rename-file fbook
(concat bookmark-dir (file-name-nondirectory fbook))))))
Which uses a function that I "stole" from here
;; TODO: add parameters for source and destination
(defun org-export-html-bookmarks (&optional source-file dest-dir)
"Extract bookmarks from the current org file and create an html file that
can be imported into a web browser."
(interactive)
(unless (eq major-mode 'org-mode)
(error "Not in an org buffer"))
(let ((file (file-name-nondirectory (buffer-file-name)))
bookmarks)
(save-excursion
(goto-char (point-min))
(while (re-search-forward org-bracket-link-analytic-regexp nil t)
(when (equal (match-string 2) "http")
(let ((url (concat (match-string 1)
(match-string 3)))
(desc (match-string 5)))
(push (concat "<DT><A HREF=\"" url "\">" desc "</A>\n") bookmarks))))
(with-temp-buffer
(insert
"<!DOCTYPE NETSCAPE-Bookmark-file-1>\n"
"<HTML>\n"
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n"
"<Title>Bookmarks</Title>\n"
"<H1>Bookmarks</H1>\n"
"<DT><H3 FOLDED>" file " (" (format-time-string "%Y-%m-%d") ")</H3>\n"
"<DL><p>\n")
(apply 'insert (nreverse bookmarks))
(insert
"</DL><p>\n"
"</HTML>")
(write-file (concat (file-name-sans-extension file) "-bookmarks.html"))))))
It works but I need it more flexible..
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-02 22:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-02 22:55 Final bookmark exporting andrea Crotti
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.