فهرست منبع

org-protocol.el: minor documentation and formatting clean up.

Bastien Guerry 14 سال پیش
والد
کامیت
fab2788864
1فایلهای تغییر یافته به همراه27 افزوده شده و 33 حذف شده
  1. 27 33
      lisp/org-protocol.el

+ 27 - 33
lisp/org-protocol.el

@@ -164,7 +164,6 @@ for `org-protocol-the-protocol' and sub-procols defined in
   "Default protocols to use.
   "Default protocols to use.
 See `org-protocol-protocol-alist' for a description of this variable.")
 See `org-protocol-protocol-alist' for a description of this variable.")
 
 
-
 (defconst org-protocol-the-protocol "org-protocol"
 (defconst org-protocol-the-protocol "org-protocol"
   "This is the protocol to detect if org-protocol.el is loaded.
   "This is the protocol to detect if org-protocol.el is loaded.
 `org-protocol-protocol-alist-default' and `org-protocol-protocol-alist' hold
 `org-protocol-protocol-alist-default' and `org-protocol-protocol-alist' hold
@@ -172,11 +171,10 @@ 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).
 just one protocol handler OS-wide (MS-Windows) or per application (Linux).
 That protocol handler should call emacsclient.")
 That protocol handler should call emacsclient.")
 
 
-
 ;;; User variables:
 ;;; User variables:
 
 
 (defcustom org-protocol-reverse-list-of-files t
 (defcustom org-protocol-reverse-list-of-files t
-  "* Non-nil means re-reverse the list of filenames passed on the command line.
+  "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
 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
 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
 sequence on the command line.  If nil, the sequence of the filenames is
@@ -184,9 +182,8 @@ unchanged."
   :group 'org-protocol
   :group 'org-protocol
   :type 'boolean)
   :type 'boolean)
 
 
-
 (defcustom org-protocol-project-alist nil
 (defcustom org-protocol-project-alist nil
-  "* Map URLs to local filenames for `org-protocol-open-source' (open-source).
+  "Map URLs to local filenames for `org-protocol-open-source' (open-source).
 
 
 Each element of this list must be of the form:
 Each element of this list must be of the form:
 
 
@@ -229,7 +226,6 @@ Consider using the interactive functions `org-protocol-create' and
   :group 'org-protocol
   :group 'org-protocol
   :type 'alist)
   :type 'alist)
 
 
-
 (defcustom org-protocol-protocol-alist nil
 (defcustom org-protocol-protocol-alist nil
   "* Register custom handlers for org-protocol.
   "* Register custom handlers for org-protocol.
 
 
@@ -287,14 +283,13 @@ Slashes are sanitized to double slashes here."
       (setq uri (concat (car splitparts) "//" (mapconcat 'identity (cdr splitparts) "/")))))
       (setq uri (concat (car splitparts) "//" (mapconcat 'identity (cdr splitparts) "/")))))
   uri)
   uri)
 
 
-
-(defun org-protocol-split-data(data &optional unhexify separator)
-  "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
+(defun org-protocol-split-data (data &optional unhexify separator)
+  "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
 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
+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."
 part."
   (let* ((sep (or separator "/+"))
   (let* ((sep (or separator "/+"))
          (split-parts (split-string data sep)))
          (split-parts (split-string data sep)))
@@ -348,7 +343,6 @@ returned list."
        ret)
        ret)
     l)))
     l)))
 
 
-
 (defun org-protocol-flatten (l)
 (defun org-protocol-flatten (l)
   "Greedy handlers might receive a list like this from emacsclient:
   "Greedy handlers might receive a list like this from emacsclient:
  '( (\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")
  '( (\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\")
@@ -359,6 +353,7 @@ This function transforms it into a flat list."
        (append (org-protocol-flatten (car l)) (org-protocol-flatten (cdr l)))
        (append (org-protocol-flatten (car l)) (org-protocol-flatten (cdr l)))
       (list l))))
       (list l))))
 
 
+
 ;;; Standard protocol handlers:
 ;;; Standard protocol handlers:
 
 
 (defun org-protocol-store-link (fname)
 (defun org-protocol-store-link (fname)
@@ -390,7 +385,7 @@ The sub-protocol used to reach this function is set in
              uri))
              uri))
   nil)
   nil)
 
 
-(defun org-protocol-remember  (info)
+(defun org-protocol-remember (info)
   "Process an org-protocol://remember:// style url.
   "Process an org-protocol://remember:// style url.
 
 
 The location for a browser's bookmark has to look like this:
 The location for a browser's bookmark has to look like this:
@@ -408,7 +403,7 @@ See the docs for `org-protocol-capture' for more information."
       (message "Org-mode not loaded."))
       (message "Org-mode not loaded."))
   nil)
   nil)
 
 
-(defun org-protocol-capture  (info)
+(defun org-protocol-capture (info)
   "Process an org-protocol://capture:// style url.
   "Process an org-protocol://capture:// style url.
 
 
 The sub-protocol used to reach this function is set in
 The sub-protocol used to reach this function is set in
@@ -444,7 +439,7 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
 	 (url (org-protocol-sanitize-uri (car parts)))
 	 (url (org-protocol-sanitize-uri (car parts)))
 	 (type (if (string-match "^\\([a-z]+\\):" url)
 	 (type (if (string-match "^\\([a-z]+\\):" url)
 		   (match-string 1 url)))
 		   (match-string 1 url)))
-	 (title(or (cadr parts) ""))
+	 (title (or (cadr parts) ""))
 	 (region (or (caddr parts) ""))
 	 (region (or (caddr parts) ""))
 	 (orglink (org-make-link-string
 	 (orglink (org-make-link-string
 		   url (if (string-match "[^[:space:]]" title) title url)))
 		   url (if (string-match "[^[:space:]]" title) title url)))
@@ -461,7 +456,6 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
     (raise-frame)
     (raise-frame)
     (funcall capture-func nil template)))
     (funcall capture-func nil template)))
 
 
-
 (defun org-protocol-open-source (fname)
 (defun org-protocol-open-source (fname)
   "Process an org-protocol://open-source:// style url.
   "Process an org-protocol://open-source:// style url.
 
 
@@ -472,7 +466,6 @@ The location for a browser's bookmark should look like this:
 
 
   javascript:location.href='org-protocol://open-source://'+ \\
   javascript:location.href='org-protocol://open-source://'+ \\
         encodeURIComponent(location.href)"
         encodeURIComponent(location.href)"
-
   ;; As we enter this function for a match on our protocol, the return value
   ;; As we enter this function for a match on our protocol, the return value
   ;; defaults to nil.
   ;; defaults to nil.
   (let ((result nil)
   (let ((result nil)
@@ -541,12 +534,14 @@ function returns nil, the filename is removed from the list of filenames
 passed from emacsclient to the server.
 passed from emacsclient to the server.
 If the function returns a non nil value, that value is passed to the server
 If the function returns a non nil value, that value is passed to the server
 as filename."
 as filename."
-  (let ((sub-protocols (append org-protocol-protocol-alist org-protocol-protocol-alist-default)))
+  (let ((sub-protocols (append org-protocol-protocol-alist
+			       org-protocol-protocol-alist-default)))
     (catch 'fname
     (catch 'fname
       (let ((the-protocol (concat (regexp-quote org-protocol-the-protocol) ":/+")))
       (let ((the-protocol (concat (regexp-quote org-protocol-the-protocol) ":/+")))
         (when (string-match the-protocol fname)
         (when (string-match the-protocol fname)
           (dolist (prolist sub-protocols)
           (dolist (prolist sub-protocols)
-            (let ((proto (concat the-protocol (regexp-quote (plist-get (cdr prolist) :protocol)) ":/+")))
+            (let ((proto (concat the-protocol
+				 (regexp-quote (plist-get (cdr prolist) :protocol)) ":/+")))
               (when (string-match proto fname)
               (when (string-match proto fname)
                 (let* ((func (plist-get (cdr prolist) :function))
                 (let* ((func (plist-get (cdr prolist) :function))
                        (greedy (plist-get (cdr prolist) :greedy))
                        (greedy (plist-get (cdr prolist) :greedy))
@@ -563,7 +558,6 @@ as filename."
       ;; (message "fname: %s" fname)
       ;; (message "fname: %s" fname)
       fname)))
       fname)))
 
 
-
 (defadvice server-visit-files (before org-protocol-detect-protocol-server activate)
 (defadvice server-visit-files (before org-protocol-detect-protocol-server activate)
   "Advice server-visit-flist to call `org-protocol-modify-filename-for-protocol'."
   "Advice server-visit-flist to call `org-protocol-modify-filename-for-protocol'."
   (let ((flist (if org-protocol-reverse-list-of-files
   (let ((flist (if org-protocol-reverse-list-of-files
@@ -572,16 +566,17 @@ as filename."
         (client (ad-get-arg 1)))
         (client (ad-get-arg 1)))
     (catch 'greedy
     (catch 'greedy
       (dolist (var flist)
       (dolist (var flist)
-        (let ((fname  (expand-file-name (car var)))) ;; `\' to `/' on windows. FIXME: could this be done any better?
-          (setq fname (org-protocol-check-filename-for-protocol fname (member var flist)  client))
+	;; `\' to `/' on windows. FIXME: could this be done any better?
+        (let ((fname  (expand-file-name (car var))))
+          (setq fname (org-protocol-check-filename-for-protocol
+		       fname (member var flist)  client))
           (if (eq fname t) ;; greedy? We need the `t' return value.
           (if (eq fname t) ;; greedy? We need the `t' return value.
               (progn
               (progn
                 (ad-set-arg 0 nil)
                 (ad-set-arg 0 nil)
                 (throw 'greedy t))
                 (throw 'greedy t))
             (if (stringp fname) ;; probably filename
             (if (stringp fname) ;; probably filename
                 (setcar var fname)
                 (setcar var fname)
-              (ad-set-arg 0 (delq var (ad-get-arg 0))))))
-        ))))
+              (ad-set-arg 0 (delq var (ad-get-arg 0))))))))))
 
 
 ;;; Org specific functions:
 ;;; Org specific functions:
 
 
@@ -597,8 +592,7 @@ most of the work."
       (message "Not in an org-project. Did mean %s?"
       (message "Not in an org-project. Did mean %s?"
                (substitute-command-keys"\\[org-protocol-create]")))))
                (substitute-command-keys"\\[org-protocol-create]")))))
 
 
-
-(defun org-protocol-create(&optional project-plist)
+(defun org-protocol-create (&optional project-plist)
   "Create a new org-protocol project interactively.
   "Create a new org-protocol project interactively.
 An org-protocol project is an entry in `org-protocol-project-alist'
 An org-protocol project is an entry in `org-protocol-project-alist'
 which is used by `org-protocol-open-source'.
 which is used by `org-protocol-open-source'.
@@ -606,15 +600,15 @@ 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
 project-plist is the CDR of an element in `org-publish-project-alist', reuse
 :base-directory, :html-extension and :base-extension."
 :base-directory, :html-extension and :base-extension."
   (interactive)
   (interactive)
-  (let ((working-dir (expand-file-name(or (plist-get project-plist :base-directory) default-directory)))
+  (let ((working-dir (expand-file-name
+		      (or (plist-get project-plist :base-directory)
+			  default-directory)))
         (base-url "http://orgmode.org/worg/")
         (base-url "http://orgmode.org/worg/")
         (strip-suffix (or (plist-get project-plist :html-extension) ".html"))
         (strip-suffix (or (plist-get project-plist :html-extension) ".html"))
         (working-suffix (if (plist-get project-plist :base-extension)
         (working-suffix (if (plist-get project-plist :base-extension)
                             (concat "." (plist-get project-plist :base-extension))
                             (concat "." (plist-get project-plist :base-extension))
                           ".org"))
                           ".org"))
-
         (worglet-buffer nil)
         (worglet-buffer nil)
-
         (insert-default-directory t)
         (insert-default-directory t)
         (minibuffer-allow-text-properties nil))
         (minibuffer-allow-text-properties nil))
 
 
@@ -630,12 +624,12 @@ project-plist is the CDR of an element in `org-publish-project-alist', reuse
 
 
     (setq strip-suffix
     (setq strip-suffix
           (read-string
           (read-string
-           (concat "Extension to strip from published URLs ("strip-suffix"): ")
+           (concat "Extension to strip from published URLs (" strip-suffix "): ")
                    strip-suffix nil strip-suffix t))
                    strip-suffix nil strip-suffix t))
 
 
     (setq working-suffix
     (setq working-suffix
           (read-string
           (read-string
-           (concat "Extension of editable files ("working-suffix"): ")
+           (concat "Extension of editable files (" working-suffix "): ")
                    working-suffix nil working-suffix t))
                    working-suffix nil working-suffix t))
 
 
     (when (yes-or-no-p "Save the new org-protocol-project to your init file? ")
     (when (yes-or-no-p "Save the new org-protocol-project to your init file? ")