mirror of https://github.com/Chizi123/.emacs.d.git

Chizi123
2018-11-18 76bbd07de7add0f9d13c6914f158d19630fe2f62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
;ELC
;;; Compiled
;;; in Emacs version 26.1
;;; with all optimizations.
 
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
 
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
(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 scan the list of filenames\nfor `org-protocol-the-protocol' and sub-protocols 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-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)) (#$ . 849))
#@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" (#$ . 1250))
(byte-code "\300\301\302\303\304DD\305\306\307\310\311&\210\300\312\302\303\313DD\314\306\307\310\315&\210\300\316\302\303\317DD\320\306\307\310\321&\210\300\322\302\303\323DD\324\306\307\310\325&\210\300\326\302\303\327DD\330\306\307\331\332\333\334\310\335& \207" [custom-declare-variable org-protocol-reverse-list-of-files funcall function #[0 "\300\207" [t] 1] "Non-nil means re-reverse the list of filenames passed on the command line.\nThe filenames passed on the command line are passed to the emacs-server in\nreverse order.  Set to t (default) to re-reverse the list, i.e. use the\nsequence on the command line.  If nil, the sequence of the filenames is\nunchanged." :group org-protocol :type boolean org-protocol-project-alist #[0 "\300\207" [nil] 1] "Map URLs to local filenames for `org-protocol-open-source' (open-source).\n\nEach element of this list must be of the form:\n\n  (module-name :property value property: value ...)\n\nwhere module-name is an arbitrary name.  All the values are strings.\n\nPossible properties are:\n\n  :online-suffix     - the suffix to strip from the published URLs\n  :working-suffix    - the replacement for online-suffix\n  :base-url          - the base URL, e.g. http://www.example.com/project/\n                       Last slash required.\n  :working-directory - the local working directory.  This is, what base-url will\n                       be replaced with.\n  :redirects         - A list of cons cells, each of which maps a regular\n                       expression to match to a path relative to :working-directory.\n\nExample:\n\n   (setq org-protocol-project-alist\n       \\='((\"https://orgmode.org/worg/\"\n          :online-suffix \".php\"\n          :working-suffix \".org\"\n          :base-url \"https://orgmode.org/worg/\"\n          :working-directory \"/home/user/org/Worg/\")\n         (\"http://localhost/org-notes/\"\n          :online-suffix \".html\"\n          :working-suffix \".org\"\n          :base-url \"http://localhost/org/\"\n          :working-directory \"/home/user/org/\"\n          :rewrites ((\"org/?$\" . \"index.php\")))\n         (\"Hugo based blog\"\n          :base-url \"https://www.site.com/\"\n          :working-directory \"~/site/content/post/\"\n          :online-suffix \".html\"\n          :working-suffix \".md\"\n          :rewrites ((\"\\(https://site.com/[0-9]+/[0-9]+/[0-9]+/\\)\" . \".md\")))))\n\n\n   The last line tells `org-protocol-open-source' to open\n   /home/user/org/index.php, if the URL cannot be mapped to an existing\n   file, and ends with either \"org\" or \"org/\".\n\nConsider using the interactive functions `org-protocol-create' and\n`org-protocol-create-for-org' to help you filling this variable with valid contents." alist org-protocol-protocol-alist #[0 "\300\207" [nil] 1] "Register custom handlers for org-protocol.\n\nEach element of this list must be of the form:\n\n  (module-name :protocol protocol :function func :kill-client nil)\n\nprotocol - protocol to detect in a filename without trailing\n           colon and slashes.  See rfc1738 section 2.1 for more\n           on this.  If you define a protocol \"my-protocol\",\n           `org-protocol-check-filename-for-protocol' will search\n           filenames for \"org-protocol:/my-protocol\" and\n           trigger your action for every match.  `org-protocol'\n           is defined in `org-protocol-the-protocol'.  Double and\n           triple slashes are compressed to one by emacsclient.\n\nfunction - function that handles requests with protocol and takes\n           one argument.  If a new-style link (key=val&key2=val2)\n           is given, the argument will be a property list with\n           the values from the link.  If an old-style link is\n           given (val1/val2), the argument will be the filename\n           with all protocols stripped.\n\n           If the function returns nil, emacsclient and -server\n           do nothing.  Any non-nil return value is considered a\n           valid filename and thus passed to the server.\n\n           `org-protocol.el' provides some support for handling\n           old-style filenames, if you follow the conventions\n           used for the standard handlers in\n           `org-protocol-protocol-alist-default'.  See\n           `org-protocol-parse-parameters'.\n\nkill-client - If t, kill the client immediately, once the sub-protocol is\n           detected.  This is necessary for actions that can be interrupted by\n           `C-g' to avoid dangling emacsclients.  Note that all other command\n           line arguments but the this one will be discarded.  Greedy handlers\n           still receive the whole list of arguments though.\n\nHere is an example:\n\n  (setq org-protocol-protocol-alist\n      \\='((\"my-protocol\"\n         :protocol \"my-protocol\"\n         :function my-protocol-handler-function)\n        (\"your-protocol\"\n         :protocol \"your-protocol\"\n         :function your-protocol-handler-function)))" (alist) org-protocol-default-template-key #[0 "\300\207" [nil] 1] "The default template key to use.\nThis is usually a single character string but can also be a\nstring with two characters." (choice (const nil) (string)) org-protocol-data-separator #[0 "\300\207" [#1="/+\\|\\?"] 1 #1#] "The default data separator to use.\nThis should be a single regexp string." :version "24.4" :package-version (Org . "8.0") string] 12)
#@104 Sanitize slashes to double-slashes in URI.
Emacsclient compresses double and triple slashes.
 
(fn URI)
(defalias 'org-protocol-sanitize-uri #[257 "\300\301\"\203\302\303\"\211@\304\305\306A\307#Q\266\202\207" [string-match "^\\([a-z]+\\):/" split-string "/+" "//" mapconcat identity "/"] 8 (#$ . 7085)])
#@410 Split the DATA argument for an org-protocol handler function.
If UNHEXIFY is non-nil, hex-decode each split part.  If UNHEXIFY
is a function, use that function to decode each split part.  The
string 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.
 
(fn DATA &optional UNHEXIFY SEPARATOR)
(defalias 'org-protocol-split-data #[769 "\211\206\300\301\"\203!\302!\203\303\"\202\"\303\304\"\202\"\211\207" ["/+\\|\\?" split-string fboundp mapcar org-link-unescape] 8 (#$ . 7401)])
#@939 Transform PARAM-LIST into a flat list for greedy handlers.
 
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 emacsclient's working directory.  This
function transforms it into a flat list using `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.  emacsclient's first parameter will be the first one in the
returned list.
 
(fn PARAM-LIST &optional STRIP-PATH REPLACEMENT)
(defalias 'org-protocol-flatten-greedy #[769 "\301\203    \202\f\302!!\211@\303\304\211\305\306\"\203-\307\310\"\262G\262\307\311\"P\240\210\203p\211\203k\211@\312;\203_    ;\203T    \304OP\211\262\202`\304O\211\262\202`C\"\262A\266\202\2023\210\211\202q\207" [org-protocol-reverse-list-of-files org-protocol-flatten reverse 0 nil string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" match-string 1 3 append] 16 (#$ . 8018)])
#@293 Transform LIST into a flat list.
 
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.
 
(fn LIST)
(defalias 'org-protocol-flatten #[257 "\211\205\211<\203\300\301@!\301A!\"\207\211C\207" [append org-protocol-flatten] 5 (#$ . 9451)])
#@418 Return a property list of parameters from INFO.
If NEW-STYLE is non-nil, treat INFO as a query string (ex:
url=URL&title=TITLE).  If old-style links are used (ex:
org-protocol://store-link/url/title), assign them to attributes
following DEFAULT-ORDER.
 
If no DEFAULT-ORDER is specified, return the list of values.
 
If INFO is already a property list, return it unchanged.
 
(fn INFO &optional NEW-STYLE DEFAULT-ORDER)
(defalias 'org-protocol-parse-parameters #[769 "<\203\207\203+\301!\302\203*\303\211A\262\242\304\211A\262\242!D\"\262\202\207\305\306#\203;\307\"\202<\211\207" [org-protocol-data-separator org-protocol-convert-query-to-plist nil append org-link-unescape org-protocol-split-data t org-protocol-assign-parameters] 11 (#$ . 9891)])
#@271 Return a property list of parameters from DATA.
Key names are taken from DEFAULT-ORDER, which should be a list of
symbols.  If DEFAULT-ORDER is shorter than the number of values
specified, the rest of the values are treated as :key value pairs.
 
(fn DATA DEFAULT-ORDER)
(defalias 'org-protocol-assign-parameters #[514 "\300\203\301\211A\262\242\211A\262\242D\"\262\202\2038\301\302\303\211A\262\242P!\211A\262\242D\"\262\202\211\207" [nil append intern ":"] 9 (#$ . 10669)])
#@864 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'.
 
Parameters: url, title (optional), body (optional)
 
Old-style links such as org-protocol://store-link://URL/TITLE are
also recognized.
 
The location for a browser's bookmark has to look like this:
 
  javascript:location.href = \
      \='org-protocol://store-link?url=\=' + \
      encodeURIComponent(location.href) + \='&title=\=' + \
      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'.
 
FNAME should be a property list.  If not, an old-style link of the
form URL/TITLE can also be used.
 
(fn FNAME)
(defalias 'org-protocol-store-link #[257 "\301\302\303#\304\305\306\"!\305\307\"\310\300!\203DB\311!\210\312\313\314\315!\314\316!$\266\302\207" [org-stored-links org-protocol-parse-parameters nil (:url :title) org-protocol-sanitize-uri plist-get :url :title boundp kill-new message "`%s' to insert new org-link, `%s' to insert `%s'" substitute-command-keys "`\\[org-insert-link]'" "`\\[yank]'"] 9 (#$ . 11173)])
#@846 Process an org-protocol://capture style url with INFO.
 
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 looks like this:
 
  javascript:location.href = \='org-protocol://capture?url=\='+ \
        encodeURIComponent(location.href) + \='&title=\=' \
        encodeURIComponent(document.title) + \='&body=\=' + \
        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'.
You may specify the template with a template= query parameter, like this:
 
  javascript:location.href = \='org-protocol://capture?template=b\='+ ...
 
Now template ?b will be used.
 
(fn INFO)
(defalias 'org-protocol-capture #[257 "\300\301!\203\302!\203\303\304!\210\305\207" [boundp org-stored-links org-protocol-do-capture message "Item captured." nil] 3 (#$ . 12468)])
#@74 Convert QUERY key=value pairs in the URL to a property list.
 
(fn QUERY)
(defalias 'org-protocol-convert-query-to-plist #[257 "\211\205\300\301\302\303\304\305\"\"\"\207" [apply append mapcar #[257 "\300\301\"\302\303@P!A@D\207" [split-string "=" intern ":"] 5 "\n\n(fn X)"] split-string "&"] 8 (#$ . 13504)])
#@54 Perform the actual capture based on INFO.
 
(fn INFO)
(defalias 'org-protocol-do-capture #[257 "\303!<\203@9\203\202%\211@G\304U\203!\305\306\"\202%\305\307\"\310\311\"\206-\310\312\"\205:\313\310\312\"!\211\205I\314\315\"\205I\316\304\"\310\317\"\206Q\320\310\321\"\206Y\320\203o\322\314\323\"\203j\202k\"\202p\324D\nB\325\326\327\330\331\332 \333&\f\210\334 \210\335\336\")\207" [org-protocol-default-template-key org-capture-link-is-already-stored org-stored-links org-protocol-parse-parameters 1 org-protocol-assign-parameters (:template :url :title :body) (:url :title :body) plist-get :template :url org-protocol-sanitize-uri string-match "^\\([a-z]+\\):" match-string :title "" :body org-make-link-string "[^[:space:]]" t org-store-link-props :type :link :description :annotation :initial :query raise-frame org-capture nil] 22 (#$ . 13826)])
#@348 Process an org-protocol://open-source?url= style URL with FNAME.
 
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?url=\=' + \
        encodeURIComponent(location.href)
 
(fn FNAME)
(defalias 'org-protocol-open-source #[257 "\301\302\303\304\301\305#\306\"!\3072\312\211\203\307\211@\303A\310\"\311!\312\"\203\276\303A\313\"\303A\314\"\303A\315\"\316\312\317 \"O\312\"G\\\312\311!\"OP\211P\320!\204\236\321\322\"\210\303 A\323\"\211\203\235\321\324\"\210\211\211\203\234\211@\312@    \"\203\225\325\326\327\301\211\f\330%!AP\331\307 P\"\266A\266\202\202p\210\210\332!\203\251\331\307\"\210\320!\203\267\321\333\"\210\202\274\321\334\"\210\266\266A\266\202\202\2100\207" [org-protocol-project-alist nil org-protocol-sanitize-uri plist-get org-protocol-parse-parameters (:url) :url result :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" directory-file-name replace-match "" 1 throw file-readable-p "%s: permission denied!" "%s: no such file or directory."] 25 (#$ . 14735)])
#@1027 Check if `org-protocol-the-protocol' and a valid protocol are 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.
 
Old-style links such as "protocol://sub-protocol://param1/param2" are
also recognized.
 
If a matching protocol is found, the protocol is stripped from
fname and the result is passed to the protocol function as the
first parameter.  The second parameter will be non-nil if FNAME
uses key=val&key2=val2-type arguments, or nil if FNAME uses
val/val2-type arguments.  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.
 
If the handler function is greedy, RESTOFFILES will also be passed to it.
 
CLIENT is ignored.
 
(fn FNAME RESTOFFILES CLIENT)
(defalias 'org-protocol-check-filename-for-protocol #[771 "\303    \"\3042\233\305\n!\306P\307\"\203\230\211\203\227\211@\305\310A\311\"!\312Q\307    \"\203\217\310A\313\"\310A\314\"\315\n\"\203F    \202I\211A@\316\317 \"\320\230\310A\321\"\203`\322\323!\210\324 \210\325!\203\215\204\204\326\304\203z\327\"!\202\202\330\331!\210!\"\210!\210\326\304\332\"\210\266\210A\266\202\202\210\2100\207" [org-protocol-protocol-alist org-protocol-protocol-alist-default org-protocol-the-protocol append fname regexp-quote ":/+" string-match plist-get :protocol "\\(:/+\\|\\?\\)" :function :greedy split-string match-string 1 "?" :kill-client message "Greedy org-protocol handler.  Killing client." server-edit fboundp throw org-protocol-parse-parameters warn "Please update your Org Protocol handler to deal with new-style links." t] 19 (#$ . 16103)])
(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)
#@238 Create an Org protocol project for the current file's project.
The visited file needs to be part of a publishing project in
`org-publish-project-alist' for this to work.  The function
delegates most of the work to `org-protocol-create'.
(defalias 'org-protocol-create-for-org #[0 "\301\302!\210\303!\211\203\304A!\202\305\306\307\310!\"\207" [buffer-file-name require ox-publish org-publish-get-project-from-filename org-protocol-create message "%s" substitute-command-keys "Not in an Org project.  Did you mean `\\[org-protocol-create]'?"] 5 (#$ . 18712) nil])
#@403 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.
 
(fn &optional PROJECT-PLIST)
(defalias 'org-protocol-create #[256 "\304\305\306\"\206    !\307\305\310\"\206\311\305\312\"\203#\313\305\312\"P\202$\314\315\316\317\320\316\315%\262\321\322\"\204>\322P\262\304\323\324\211\315$!\262\321\322\"\204U\322P\262\317\325\326Q\316\315%\262\317\327\326Q\316\315%\262\330\331!\205\210\332\333\334\335\257     B\336\303 \"*\207" [default-directory minibuffer-allow-text-properties insert-default-directory org-protocol-project-alist expand-file-name plist-get :base-directory "https://orgmode.org/worg/" :html-extension ".html" :base-extension "." ".org" t nil read-string "Base URL of published content: " string-suffix-p "/" 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] 14 (#$ . 19287) nil])
(provide 'org-protocol)