mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-22 07:09:47 +00:00
New file org-browser-url.el.
This commit is contained in:
parent
0216c9a27c
commit
0b9b7d7b58
@ -1,3 +1,11 @@
|
||||
2008-12-08 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* 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 <ahktenzero@mohorovi.cc>
|
||||
|
||||
* lisp/org-checklist.el: New file.
|
||||
|
@ -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 <lisp> tag, adapted from Muse
|
||||
|
89
contrib/lisp/org-browser-url.el
Normal file
89
contrib/lisp/org-browser-url.el
Normal file
@ -0,0 +1,89 @@
|
||||
;;; org-browser-url.el --- Bookmark from a browser into org links
|
||||
|
||||
;; Author: Ross Patterson <me@rpatterson.net>
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; 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)
|
Loading…
Reference in New Issue
Block a user