;ELC
;;; Compiled by LTX@Xue-LingTaos-MacBook-Pro.local on Wed Mar 16 23:17:53 2011
;;; from file /Users/LTX/Projects/Emacs/emacs/lisp/org/org-protocol.el
;;; in Emacs version 24.0.50.1
;;; with all optimizations.

;;; This file contains utf-8 non-ASCII characters,
;;; and so cannot be loaded into Emacs 22 or earlier.
(and (boundp 'emacs-version)
     (< (aref emacs-version (1- (length emacs-version))) ?A)
     (string-lessp emacs-version "23")
     (error "`org-protocol.el' was compiled for Emacs 23 or later"))

;;;;;;;;;;;;;;;;;;;


(byte-code "\300\301!\210\302\303\304\305\306\307\310\311\310\301&	\207" [require org custom-declare-group org-protocol nil "Intercept calls from emacsclient to trigger custom actions.\n\nThis is done by advising `server-visit-files' to scann the list of filenames\nfor `org-protocol-the-protocol' and sub-procols defined in\n`org-protocol-protocol-alist' and `org-protocol-protocol-alist-default'." :version "22.1" :group convenience] 10)
#@97 Default protocols to use.
See `org-protocol-protocol-alist' for a description of this variable.
(defconst org-protocol-protocol-alist-default '(("org-remember" :protocol "remember" :function org-protocol-remember :kill-client t) ("org-capture" :protocol "capture" :function org-protocol-capture :kill-client t) ("org-store-link" :protocol "store-link" :function org-protocol-store-link) ("org-open-source" :protocol "open-source" :function org-protocol-open-source)) (#$ . 990))
#@338 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.
(defconst org-protocol-the-protocol "org-protocol" (#$ . 1476))
#@308 * 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.
(custom-declare-variable 'org-protocol-reverse-list-of-files 't '(#$ . -1884) :group 'org-protocol :type 'boolean)
#@1623 * Map URLs to local filenames for `org-protocol-open-source' (open-source).

Each element of this list must be of the form:

  (module-name :property value property: value ...)

where module-name is an arbitrary name. All the values are strings.

Possible properties are:

  :online-suffix     - the suffix to strip from the published URLs
  :working-suffix    - the replacement for online-suffix
  :base-url          - the base URL, e.g. http://www.example.com/project/
                       Last slash required.
  :working-directory - the local working directory. This is, what base-url will
                       be replaced with.
  :redirects         - A list of cons cells, each of which maps a regular
                       expression to match to a path relative to :working-directory.

Example:

   (setq org-protocol-project-alist
       '(("http://orgmode.org/worg/"
          :online-suffix ".php"
          :working-suffix ".org"
          :base-url "http://orgmode.org/worg/"
          :working-directory "/home/user/org/Worg/")
         ("http://localhost/org-notes/"
          :online-suffix ".html"
          :working-suffix ".org"
          :base-url "http://localhost/org/"
          :working-directory "/home/user/org/"
          :rewrites (("org/?$" . "index.php")))))

   The last line tells `org-protocol-open-source' to open
   /home/user/org/index.php, if the URL cannot be mapped to an existing
   file, and ends with either "org" or "org/".

Consider using the interactive functions `org-protocol-create' and
`org-protocol-create-for-org' to help you filling this variable with valid contents.
(custom-declare-variable 'org-protocol-project-alist 'nil '(#$ . -2314) :group 'org-protocol :type 'alist)
#@1855 * Register custom handlers for org-protocol.

Each element of this list must be of the form:

  (module-name :protocol protocol :function func :kill-client nil)

protocol - protocol to detect in a filename without trailing colon and slashes.
           See rfc1738 section 2.1 for more on this.
           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 triple slashes are compressed
           to one by emacsclient.

function - function that handles requests with protocol and takes exactly one
           argument: the filename with all protocols stripped. If the function
           returns nil, emacsclient and -server do nothing. Any non-nil return
           value is considered a valid filename and thus passed to the server.

           `org-protocol.el provides some support for handling those filenames,
           if you stay with the conventions used for the standard handlers in
           `org-protocol-protocol-alist-default'. See `org-protocol-split-data'.

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

Here is an example:

  (setq org-protocol-protocol-alist
      '(("my-protocol"
         :protocol "my-protocol"
         :function my-protocol-handler-function)
        ("your-protocol"
         :protocol "your-protocol"
         :function your-protocol-handler-function)))
(custom-declare-variable 'org-protocol-protocol-alist 'nil '(#$ . -4051) :group 'org-protocol :type '(alist))
#@48 The default org-remember-templates key to use.
(custom-declare-variable 'org-protocol-default-template-key 'nil '(#$ . 6021) :group 'org-protocol :type 'string)
#@97 emacsclient compresses double and triple slashes.
Slashes are sanitized to double slashes here.
(defalias 'org-protocol-sanitize-uri #[(uri) "\302\303\"\203\304\305\"\211@\306\307\310	A\311#Q)\207" [uri splitparts string-match "^\\([a-z]+\\):/" split-string "/+" "//" mapconcat identity "/"] 7 (#$ . 6188)])
#@394 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.
(defalias 'org-protocol-split-data #[(data &optional unhexify separator) "\206\305\306\n	\"\f\203#\307\f!\203\310\f\"\202$\310\311\"\202$*\207" [separator sep data split-parts unhexify "/+" split-string fboundp mapcar org-protocol-unhex-string] 3 (#$ . 6510)])
#@134 Unhex hexified unicode strings as returned from the JavaScript function
encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `Ã¼'.
(defalias 'org-protocol-unhex-string #[(str) "\206\306\306\307\310\311\"\2034\312\224\312\225\313\312\"\314
\226!\n\312OQ\f\315O,\202\n\nP\211*\207" [str case-fold-search tmp start end hex "" t string-match "\\(%[0-9a-f][0-9a-f]\\)+" 0 match-string org-protocol-unhex-compound nil replacement] 5 (#$ . 7184)])
#@70 Unhexify unicode hex-chars. E.g. `%C3%B6' is the German Umlaut `Ã¼'.
(defalias 'org-protocol-unhex-compound #[(hex) "\306\307\310\311\"\"\307\312\211	\203	\211A@\211\312\234
\313\234\314V\2031\315\316Z\\\2025\317Z
\314V\203E\315
\316Z\\\202H
\317Z \320\321\" \\!\312U\203\225!\322Y\203e\323\202\226!\324Y\203p\325\202\226!\326Y\203{\321\202\226!\327Y\203\206\330\202\226!\331Y\203\221\332\202\226\312\202\226\323\"\312U\203\331!\322Y\203\251\322\202\332!\324Y\203\264\324\202\332!\326Y\203\277\326\202\332!\327Y\203\312\327\202\332!\331Y\203\325\331\202\332\312\202\332\333#!\331Y\203\346\"\334!#\"!\320\f\"\"!\\\312V\203S\312U\203\n\f$\335$!)P\312.\202\n,\207" [hex bytes ret eat sum b remove "" split-string "%" 0 1 57 10 65 48 lsh 4 252 6 248 5 240 224 3 192 2 128 logxor char-to-string a c1 c2 val shift xor c] 6 (#$ . 7657)])
#@837 Greedy handlers might receive a list like this from emacsclient:
 '( ("/dir/org-protocol:/greedy:/~/path1" (23 . 12)) ("/dir/param")
where "/dir/" is the absolute path to emacsclients working directory.  This
function transforms it into a flat list utilizing `org-protocol-flatten' and
transforms the elements of that list as follows:

If strip-path is non-nil, remove the "/dir/" prefix from all members of
param-list.

If replacement is string, replace the "/dir/" prefix with it.

The first parameter, the one that contains the protocols, is always changed.
Everything up to the end of the protocols is stripped.

Note, that this function will always behave as if
`org-protocol-reverse-list-of-files' was set to t and the returned list will
reflect that. I.e. emacsclients first parameter will be the first one in the
returned list.
(defalias 'org-protocol-flatten-greedy #[(param-list &optional strip-path replacement) "\306\203		\202\f\307	!!\211@\310\311\211\312\313\"\2030\314\315\"\211G\n
\314\316\"P\240\210\203\207\n\311\211\203{@\317;\203l;\203a\f\311OP\211\202n\f\311O\211\202nC\"A\211\204?\311*\210\202\210\n-\207" [org-protocol-reverse-list-of-files param-list l trigger len dir org-protocol-flatten reverse 0 nil string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" match-string 1 3 append ret strip-path e #1=#:--cl-dolist-temp-- replacement] 8 (#$ . 8587)])
#@250 Greedy handlers might receive a list like this from emacsclient:
 '( ("/dir/org-protocol:/greedy:/~/path1" (23 . 12)) ("/dir/param")
where "/dir/" is the absolute path to emacsclients working directory.
This function transforms it into a flat list.
(defalias 'org-protocol-flatten #[(l) "\205<\203\301\302@!\302A!\"\207C\207" [l append org-protocol-flatten] 4 (#$ . 10061)])
#@588 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:

  javascript:location.href='org-protocol://store-link://'+ \
        encodeURIComponent(location.href)
        encodeURIComponent(document.title)+'/'+ \

Don't use `escape()'! Use `encodeURIComponent()' instead. The title of the page
could contain slashes and the location definitely will.

The sub-protocol used to reach this function is set in
`org-protocol-protocol-alist'.
(defalias 'org-protocol-store-link #[(fname) "\306\307\"\310	@!	\211A@)\311\312\313!\203!\n\fDB\314\n!\210\315\316\317\320!\317\321!\n$\210,\311\207" [fname splitparts uri x title orglink org-protocol-split-data t org-protocol-sanitize-uri nil boundp org-stored-links kill-new message "`%s' to insert new org-link, `%s' to insert `%s'" substitute-command-keys "\\[org-insert-link]" "\\[yank]"] 6 (#$ . 10452)])
#@383 Process an org-protocol://remember:// style url.

The location for a browser's bookmark has to look like this:

  javascript:location.href='org-protocol://remember://'+ \
        encodeURIComponent(location.href)+'/' \
        encodeURIComponent(document.title)+'/'+ \
        encodeURIComponent(window.getSelection())

See the docs for `org-protocol-capture' for more information.
(defalias 'org-protocol-remember #[(info) "\301\302!\203\303\304!\203\305\306\"\203\307\310!\210\311\207" [info boundp org-stored-links fboundp org-capture org-protocol-do-capture org-remember message "Org-mode not loaded." nil] 3 (#$ . 11468)])
#@788 Process an org-protocol://capture:// style url.

The sub-protocol used to reach this function is set in
`org-protocol-protocol-alist'.

This function detects an URL, title and optional text, separated by '/'
The location for a browser's bookmark has to look like this:

  javascript:location.href='org-protocol://capture://'+ \
        encodeURIComponent(location.href)+'/' \
        encodeURIComponent(document.title)+'/'+ \
        encodeURIComponent(window.getSelection())

By default, it uses the character `org-protocol-default-template-key',
which should be associated with a template in `org-capture-templates'.
But you may prepend the encoded URL with a character and a slash like so:

  javascript:location.href='org-protocol://capture://b/'+ ...

Now template ?b will be used.
(defalias 'org-protocol-capture #[(info) "\301\302!\203\303\304!\203\305\304\"\203\306\307!\210\310\207" [info boundp org-stored-links fboundp org-capture org-protocol-do-capture message "Org-mode not loaded." nil] 3 (#$ . 12110)])
#@116 Support `org-capture' and `org-remember' alike.
CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'.
(defalias 'org-protocol-do-capture #[(info capture-func) "\306\307\"\211@G\310U\203	\211A@\206\n\311	@!\312\313\f\"\205'\314\310\f\"	\211A@)\2063\315	\211AA)@\206A\315\316\f\312\317\"\203R\202S\f\"\307\320\fDB\321!\210\322\323
\324\f\325\326\327&\n\210\330 \210 \320\".	\207" [info parts org-protocol-default-template-key template url type org-protocol-split-data t 1 org-protocol-sanitize-uri string-match "^\\([a-z]+\\):" match-string "" org-make-link-string "[^[:space:]]" nil kill-new org-store-link-props :type :link :description :annotation :initial raise-frame x title region orglink org-capture-link-is-already-stored remember-annotation-functions org-stored-links capture-func] 12 (#$ . 13143)])
#@314 Process an org-protocol://open-source:// style url.

Change a filename by mapping URLs to local filenames as set
in `org-protocol-project-alist'.

The location for a browser's bookmark should look like this:

  javascript:location.href='org-protocol://open-source://'+ \
        encodeURIComponent(location.href)
(defalias 'org-protocol-open-source #[(fname) "\303\304!\302\305\215*\207" [fname f result nil org-protocol-unhex-string (byte-code "\306\211\203\262\n@\307	A\310\"\311!\312\f
\"\203\252\307	A\313\"\307	A\314\"\307	A\315\"
\316\312\317
\"O\312\f\"G\\ \312\311!\"! !OP\211\"P#\320#!\204\205\321\322#\"\210\307	A\323\"\211$\203\204\321\324$\"\210\325\326$\"\210)\327#!\203\222\330\331#\"\210\320#!\203\242\321\332#\"\210\202\250\321\333#\"\210.*\nA\211\204*\207" [org-protocol-project-alist prolist #1=#:--cl-dolist-temp-- base-url wsearch f nil plist-get :base-url regexp-quote string-match :working-directory :online-suffix :working-suffix 0 "\\([\\?#].*\\)?$" file-exists-p message "File %s does not exist.\nTesting for rewritten URLs." :rewrites "Rewrites found: %S" mapc #[(rewrite) "\303@	\"\205\304\305\nAP\"\207" [rewrite f2 wdir string-match throw result] 4 "Try to match a rewritten URL and map it to a real file."] file-readable-p throw result "%s: permission denied!" "%s: no such file or directory." wdir strip-suffix add-suffix f1 start-pos end-pos f2 the-file rewrites] 6)] 3 (#$ . 14019)])
#@671 Detect if `org-protocol-the-protocol' and a known sub-protocol is used in fname.
Sub-protocols are registered in `org-protocol-protocol-alist' and
`org-protocol-protocol-alist-default'.
This is, how the matching is done:

  (string-match "protocol:/+sub-protocol:/+" ...)

protocol and sub-protocol are regexp-quoted.

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.
If the function returns a non nil value, that value is passed to the server
as filename.
(defalias 'org-protocol-check-filename-for-protocol #[(fname restoffiles client) "\303	\"\304\305\215)\207" [org-protocol-protocol-alist org-protocol-protocol-alist-default sub-protocols append fname (byte-code "\306!\307P\310	\n\"\203\216\311\211\203\215
@	\306\312\fA\313\"!\307Q\310\n\"\203\205\312\fA\314\"\312\fA\315\"\316\n\"\203K\202S\211A@)\312\fA\317\"\203d\320\321!\210\322 \210\323!\203\204\204y\324\302!\"\210!\210\324\302\325\"\210,)
A\211\204*)\n\207" [org-protocol-the-protocol the-protocol fname sub-protocols prolist #1=#:--cl-dolist-temp-- regexp-quote ":/+" string-match nil plist-get :protocol :function :greedy split-string :kill-client message "Greedy org-protocol handler. Killing client." server-edit fboundp throw t proto func greedy splitted restoffiles x result] 6)] 3 (#$ . 15507)])
(byte-code "\300\301\302\303\304$\210\305\301\304\"\207" [ad-add-advice server-visit-files (org-protocol-detect-protocol-server nil t (advice lambda nil "Advice server-visit-flist to call `org-protocol-modify-filename-for-protocol'." (let ((flist (if org-protocol-reverse-list-of-files (reverse (ad-get-arg 0)) (ad-get-arg 0))) (client (ad-get-arg 1))) (catch 'greedy (dolist (var flist) (let ((fname (expand-file-name (car var)))) (setq fname (org-protocol-check-filename-for-protocol fname (member var flist) client)) (if (eq fname t) (progn (ad-set-arg 0 nil) (throw 'greedy t)) (if (stringp fname) (setcar var fname) (ad-set-arg 0 (delq var (ad-get-arg 0))))))))))) before nil ad-activate] 5)
#@235 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 function calls `org-protocol-create' to do
most of the work.
(defalias 'org-protocol-create-for-org #[nil "\302\303!\210\304!\211\203\305	A!\202\306\307\310\311!\")\207" [buffer-file-name all require org-publish org-publish-get-project-from-filename org-protocol-create message "Not in an org-project. Did mean %s?" substitute-command-keys "\\[org-protocol-create]"] 5 (#$ . 17745) nil])
#@371 Create a new org-protocol project interactively.
An org-protocol project is an entry in `org-protocol-project-alist'
which is used by `org-protocol-open-source'.
Optionally use project-plist to initialize the defaults for this project. If
project-plist is the CDR of an element in `org-publish-project-alist', reuse
:base-directory, :html-extension and :base-extension.
(defalias 'org-protocol-create #[(&optional project-plist) "\306\307\310\"\206		!\311\307\312\"\206\313\307\314\"\203#\315\307\314\"P\202$\316\317\320\317#$%\321\322$\317$\320%$\323\324$\"\204J$\325P$\306\326\327%\211\320$!%\323\324%\"\204c%\325P%\321\330#\331Q#\317#\320%#\321\332
\331Q
\317
\320%\333\334!\205\234$\335$\336%\337#\340
\257	\"B\"\341\342\"\".\207" [project-plist default-directory minibuffer-allow-text-properties insert-default-directory worglet-buffer working-suffix expand-file-name plist-get :base-directory "http://orgmode.org/worg/" :html-extension ".html" :base-extension "." ".org" nil t read-string "Base URL of published content: " string-match "\\/$" "/" read-directory-name "Local working directory: " "Extension to strip from published URLs (" "): " "Extension of editable files (" yes-or-no-p "Save the new org-protocol-project to your init file? " :base-url :working-directory :online-suffix :working-suffix customize-save-variable org-protocol-project-alist strip-suffix base-url working-dir] 9 (#$ . 18319) nil])
(provide 'org-protocol)
