|
@@ -31,8 +31,8 @@
|
|
|
;;
|
|
|
;; Intercept calls from emacsclient to trigger custom actions.
|
|
|
;;
|
|
|
-;; This is done by advising `server-visit-files' to scann the list of filenames
|
|
|
-;; for `org-protocol-the-protocol' and sub-procols defined in
|
|
|
+;; This is done by advising `server-visit-files' to scan the list of filenames
|
|
|
+;; for `org-protocol-the-protocol' and sub-protocols defined in
|
|
|
;; `org-protocol-protocol-alist' and `org-protocol-protocol-alist-default'.
|
|
|
;;
|
|
|
;; Any application that supports calling external programs with an URL
|
|
@@ -58,7 +58,7 @@
|
|
|
;; (setq org-protocol-protocol-alist
|
|
|
;; '(("my-protocol"
|
|
|
;; :protocol "my-protocol"
|
|
|
-;; :function my-protocol-handler-fuction)))
|
|
|
+;; :function my-protocol-handler-function)))
|
|
|
;;
|
|
|
;; A "sub-protocol" will be found in URLs like this:
|
|
|
;;
|
|
@@ -84,13 +84,13 @@
|
|
|
;; URLs to local filenames defined in `org-protocol-project-alist'.
|
|
|
;;
|
|
|
;; * `org-protocol-store-link' stores an Org-link (if Org-mode is present) and
|
|
|
-;; pushes the browsers URL to the `kill-ring' for yanking. This handler is
|
|
|
+;; pushes the browsers URL to the `kill-ring' for yanking. This handler is
|
|
|
;; triggered through the sub-protocol \"store-link\".
|
|
|
;;
|
|
|
;; * Call `org-protocol-capture' by using the sub-protocol \"capture\". If
|
|
|
-;; Org-mode is loaded, emacs will pop-up a capture buffer and fill the
|
|
|
-;; template with the data provided. I.e. the browser's URL is inserted as an
|
|
|
-;; Org-link of which the page title will be the description part. If text
|
|
|
+;; Org-mode is loaded, Emacs will pop-up a capture buffer and fill the
|
|
|
+;; template with the data provided. I.e. the browser's URL is inserted as an
|
|
|
+;; Org-link of which the page title will be the description part. If text
|
|
|
;; was select in the browser, that text will be the body of the entry.
|
|
|
;;
|
|
|
;; * Call `org-protocol-remember' by using the sub-protocol \"remember\".
|
|
@@ -155,18 +155,19 @@ See `org-protocol-protocol-alist' for a description of this variable.")
|
|
|
|
|
|
(defconst org-protocol-the-protocol "org-protocol"
|
|
|
"This is the protocol to detect if org-protocol.el is loaded.
|
|
|
-`org-protocol-protocol-alist-default' and `org-protocol-protocol-alist' hold the
|
|
|
-sub-protocols that trigger the required action. You will have to define just one
|
|
|
-protocol handler OS-wide (MS-Windows) or per application (Linux). That protocol
|
|
|
-handler should call emacsclient.")
|
|
|
+`org-protocol-protocol-alist-default' and `org-protocol-protocol-alist' hold
|
|
|
+the sub-protocols that trigger the required action. You will have to define
|
|
|
+just one protocol handler OS-wide (MS-Windows) or per application (Linux).
|
|
|
+That protocol handler should call emacsclient.")
|
|
|
|
|
|
|
|
|
;;; User variables:
|
|
|
|
|
|
(defcustom org-protocol-reverse-list-of-files t
|
|
|
- "* The filenames passed on the commandline are passed to the emacs-server in
|
|
|
-reversed order. Set to `t' (default) to re-reverse the list, i.e. use the
|
|
|
-sequence on the command line. If nil, the sequence of the filenames is
|
|
|
+ "* Non-nil means re-reverse the list of filenames passed on the command line.
|
|
|
+The filenames passed on the command line are passed to the emacs-server in
|
|
|
+reverse order. Set to t (default) to re-reverse the list, i.e. use the
|
|
|
+sequence on the command line. If nil, the sequence of the filenames is
|
|
|
unchanged."
|
|
|
:group 'org-protocol
|
|
|
:type 'boolean)
|
|
@@ -229,7 +230,7 @@ protocol - protocol to detect in a filename without trailing colon and slashes.
|
|
|
If you define a protocol \"my-protocol\", `org-protocol-check-filename-for-protocol'
|
|
|
will search filenames for \"org-protocol:/my-protocol:/\"
|
|
|
and trigger your action for every match. `org-protocol' is defined in
|
|
|
- `org-protocol-the-protocol'. Double and tripple slashes are compressed
|
|
|
+ `org-protocol-the-protocol'. Double and triple slashes are compressed
|
|
|
to one by emacsclient.
|
|
|
|
|
|
function - function that handles requests with protocol and takes exactly one
|
|
@@ -243,7 +244,7 @@ function - function that handles requests with protocol and takes exactly one
|
|
|
|
|
|
kill-client - If t, kill the client immediately, once the sub-protocol is
|
|
|
detected. This is necessary for actions that can be interrupted by
|
|
|
- `C-g' to avoid dangeling emacsclients. Note, that all other command
|
|
|
+ `C-g' to avoid dangling emacsclients. Note, that all other command
|
|
|
line arguments but the this one will be discarded, greedy handlers
|
|
|
still receive the whole list of arguments though.
|
|
|
|
|
@@ -252,10 +253,10 @@ Here is an example:
|
|
|
(setq org-protocol-protocol-alist
|
|
|
'((\"my-protocol\"
|
|
|
:protocol \"my-protocol\"
|
|
|
- :function my-protocol-handler-fuction)
|
|
|
+ :function my-protocol-handler-function)
|
|
|
(\"your-protocol\"
|
|
|
:protocol \"your-protocol\"
|
|
|
- :function your-protocol-handler-fuction)))"
|
|
|
+ :function your-protocol-handler-function)))"
|
|
|
:group 'org-protocol
|
|
|
:type '(alist))
|
|
|
|
|
@@ -267,7 +268,7 @@ Here is an example:
|
|
|
;;; Helper functions:
|
|
|
|
|
|
(defun org-protocol-sanitize-uri (uri)
|
|
|
- "emacsclient compresses double and tripple slashes.
|
|
|
+ "emacsclient compresses double and triple slashes.
|
|
|
Slashes are sanitized to double slashes here."
|
|
|
(when (string-match "^\\([a-z]+\\):/" uri)
|
|
|
(let* ((splitparts (split-string uri "/+")))
|
|
@@ -276,12 +277,13 @@ Slashes are sanitized to double slashes here."
|
|
|
|
|
|
|
|
|
(defun org-protocol-split-data(data &optional unhexify separator)
|
|
|
- "Split, what a org-protocol handler function gets as only argument.
|
|
|
-data is that one argument. Data is splitted at each occurrence of separator
|
|
|
- (regexp). If no separator is specified or separator is nil, assume \"/+\".
|
|
|
-The results of that splitting are return as a list. If unhexify is non-nil,
|
|
|
-hex-decode each split part. If unhexify is a function, use that function to
|
|
|
-decode each split part."
|
|
|
+ "Split, what an org-protocol handler function gets as only argument.
|
|
|
+DATA is that one argument. DATA is split at each occurrence of
|
|
|
+SEPARATOR (regexp). If no SEPARATOR is specified or SEPARATOR is
|
|
|
+nil, assume \"/+\". The results of that splitting are returned
|
|
|
+as a list. If UNHEXIFY is non-nil, hex-decode each split part. If
|
|
|
+UNHEXIFY is a function, use that function to decode each split
|
|
|
+part."
|
|
|
(let* ((sep (or separator "/+"))
|
|
|
(split-parts (split-string data sep)))
|
|
|
(if unhexify
|
|
@@ -319,7 +321,7 @@ encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'."
|
|
|
|
|
|
|
|
|
(defun org-protocol-unhex-compound (hex)
|
|
|
- "Unhexify unicode hex-chars. E.g. `%C3%B6' is the german Umlaut `ü'."
|
|
|
+ "Unhexify unicode hex-chars. E.g. `%C3%B6' is the German Umlaut `ü'."
|
|
|
(let* ((bytes (remove "" (split-string hex "%")))
|
|
|
(ret "")
|
|
|
(eat 0)
|
|
@@ -415,9 +417,9 @@ This function transforms it into a flat list."
|
|
|
;;; Standard protocol handlers:
|
|
|
|
|
|
(defun org-protocol-store-link (fname)
|
|
|
- "Process an org-protocol://store-link:// style url
|
|
|
-and store a browser URL as an org link. Also pushes the links URL to the
|
|
|
-`kill-ring'.
|
|
|
+ "Process an org-protocol://store-link:// style url.
|
|
|
+Additionally store a browser URL as an org link. Also pushes the
|
|
|
+link's URL to the `kill-ring'.
|
|
|
|
|
|
The location for a browser's bookmark has to look like this:
|
|
|
|
|
@@ -588,7 +590,7 @@ This is, how the matching is done:
|
|
|
|
|
|
protocol and sub-protocol are regexp-quoted.
|
|
|
|
|
|
-If a matching protcol is found, the protcol is stripped from fname and the
|
|
|
+If a matching protocol is found, the protocol is stripped from fname and the
|
|
|
result is passed to the protocols function as the only parameter. If the
|
|
|
function returns nil, the filename is removed from the list of filenames
|
|
|
passed from emacsclient to the server.
|
|
@@ -641,7 +643,7 @@ as filename."
|
|
|
(defun org-protocol-create-for-org ()
|
|
|
"Create a org-protocol project for the current file's Org-mode project.
|
|
|
This works, if the file visited is part of a publishing project in
|
|
|
-`org-publish-project-alist'. This functions calls `org-protocol-create' to do
|
|
|
+`org-publish-project-alist'. This function calls `org-protocol-create' to do
|
|
|
most of the work."
|
|
|
(interactive)
|
|
|
(require 'org-publish)
|