all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: andrea Crotti <andrea.crotti.0@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Final bookmark exporting
Date: Mon, 2 Nov 2009 22:55:06 +0000 (UTC)	[thread overview]
Message-ID: <loom.20091102T234908-856@post.gmane.org> (raw)

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	other threads:[~2009-11-02 22:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20091102T234908-856@post.gmane.org \
    --to=andrea.crotti.0@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.