emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Final bookmark exporting


From: andrea Crotti
Subject: [Orgmode] Final bookmark exporting
Date: Mon, 2 Nov 2009 22:55:06 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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..





reply via email to

[Prev in Thread] Current Thread [Next in Thread]