diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 261004c3c..3c8fb8eda 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,11 @@ +2008-12-08 Carsten Dominik + + * lisp/org-browser-url.el: New file. + + * lisp/org-registry.el (org-registry-before-first-heading-p): + Function renamed to `org-before-first-heading-p', and moved to + org.el. + 2008-09-20 James TD Smith * lisp/org-checklist.el: New file. diff --git a/contrib/README b/contrib/README index d7838641b..27d0f2ca7 100644 --- a/contrib/README +++ b/contrib/README @@ -13,6 +13,7 @@ LISP (emacs-lisp code) org-annotate-file.el --- Annotate a file with org syntax org-annotation-helper.el --- Call remember directly from Firefox/Opera org-bookmark.el --- Links to bookmarks +org-browser-url.el --- Store links to webpages directly from Firefox/Opera org-depend.el --- TODO dependencies for Org-mode org-elisp-symbol.el --- Org links to emacs-lisp symbols org-eval.el --- The tag, adapted from Muse diff --git a/contrib/lisp/org-browser-url.el b/contrib/lisp/org-browser-url.el new file mode 100644 index 000000000..478f3731e --- /dev/null +++ b/contrib/lisp/org-browser-url.el @@ -0,0 +1,89 @@ +;;; org-browser-url.el --- Bookmark from a browser into org links + +;; Author: Ross Patterson +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: + +;; Once a bookmarklet and a app handler are setup in your browser, +;; the functions here support using the bookmarklet to add links to +;; the org links ring. +;; +;; Much of this is taken from or modeled after +;; org-annotation-helper.el +;; +;; Installation and Activation +;; --------------------------- +;; +;; Step 1: Install this library on your path and enable it in your +;; $HOME/.emacs: +;; +;; (require 'org-browser-url) +;; +;; Step 2: Install the handler script +;; +;; * Save the following script to an appropriate place and make sure +;; it is executable: +;; +;; #!/bin/sh +;; # org-browser-url-store - Store URLs in the org links ring +;; emacsclient --eval "(let ((org-browser-url-args \"$*\"))\ +;; (call-interactively 'org-store-link))" +;; +;; * Make sure emacs is running with server mode started: +;; +;; (server-start) +;; +;; * Test the script from the command line +;; +;; $ org-browser-url-store \ +;; 'org-browser-url-store:///Link%20Description/http://foo.com' +;; +;; * Insert the link in an org-mode buffer with C-c C-l +;; +;; Step 3: Add the handler to your browser +;; +;; * For Firefox: +;; - type in "about:config" in the location bar +;; - right click, select "New", then "String" +;; - enter the name: +;; "network.protocol-handler.app.org-browser-url-store" +;; - leave the value blank +;; +;; See http://kb.mozillazine.org/Register_protocol for more details. +;; +;; * For Opera add the protocol in the +;; Preferences->Advanced->Programs dialog. +;; +;; Step 4: Add bookmarklet +;; +;; * Create a new bookmark with the following location: +;; +;; javascript:location.href='org-browser-url-store:///'+\ +;; escape(document.title)+'/'+location.href +;; +;; When you first use the bookmarklet, Firefox will prompt you for +;; the script. Point it to the full path of the script. + +;;; Code: + +(require 'org) +(require 'url) + +(defun org-browser-url-store-link () + "Store a browser URL as an org link from the bookmarklet" + (if (boundp 'org-browser-url-args) + (let* ((stored (url-generic-parse-url org-browser-url-args)) + (path (split-string (aref stored 6) "/")) + (parsed (url-generic-parse-url + (mapconcat 'identity (cddr path) "/"))) + (type (aref parsed 1)) + (link (aset parsed 7 (aref stored 7))) + (link (url-recreate-url parsed)) + (description (url-unhex-string (nth 1 path)))) + (org-store-link-props + :type type :link link :description description)))) + +(add-hook 'org-store-link-functions 'org-browser-url-store-link) + +(provide 'org-browser-url) \ No newline at end of file