Function: org--protocol-detect-protocol-server

org--protocol-detect-protocol-server is a byte-compiled function defined in org-protocol.el.gz.

Signature

(org--protocol-detect-protocol-server ORIG-FUN FILES CLIENT &rest ARGS)

Documentation

Advice server-visit-files to call org-protocol-check-filename-for-protocol.

This function is indented to be used as :around advice for server-visit-files.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-protocol.el.gz
(defun org--protocol-detect-protocol-server (orig-fun files client &rest args)
  "Advice `server-visit-files' to call `org-protocol-check-filename-for-protocol'.
This function is indented to be used as :around advice for `server-visit-files'."
  (let ((flist (if org-protocol-reverse-list-of-files
                   (reverse files)
                 files)))
    (catch 'greedy
      (dolist (var flist)
	;; `\' 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.
              (progn
                ;; FIXME: Doesn't this just ignore all the files before
                ;; this one (the remaining ones have been passed to
                ;; `org-protocol-check-filename-for-protocol' but not
                ;; the ones before).
                (setq files nil)
                (throw 'greedy t))
            (if (stringp fname) ;; probably filename
                (setcar var fname)
              (setq files (delq var files)))))))
    (apply orig-fun files client args)))