Function: org-link--try-link-store-functions

org-link--try-link-store-functions is a byte-compiled function defined in ol.el.gz.

Signature

(org-link--try-link-store-functions INTERACTIVE?)

Documentation

Try storing external links, prompting if more than one is possible.

Each function returned by org-store-link-functions is called in turn. If multiple functions return non-nil, prompt for which link should be stored.

Argument INTERACTIVE? indicates whether org-store-link was called interactively and is passed to the link store functions.

Return t when a link has been stored in org-link-store-props.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ol.el.gz
(defun org-link--try-link-store-functions (interactive?)
  "Try storing external links, prompting if more than one is possible.

Each function returned by `org-store-link-functions' is called in
turn.  If multiple functions return non-nil, prompt for which
link should be stored.

Argument INTERACTIVE? indicates whether `org-store-link' was
called interactively and is passed to the link store functions.

Return t when a link has been stored in `org-link-store-props'."
  (let ((results-alist nil))
    (dolist (f (org-store-link-functions))
      (when (condition-case nil
                (funcall f interactive?)
              ;; FIXME: The store function used (< Org 9.7) to accept
              ;; no arguments; provide backward compatibility support
              ;; for them.
              (wrong-number-of-arguments
               (funcall f)))
        ;; FIXME: return value is not link's plist, so we store the
        ;; new value before it is modified.  It would be cleaner to
        ;; ask store link functions to return the plist instead.
        (push (cons f (copy-sequence org-store-link-plist))
              results-alist)))
    (pcase results-alist
      (`nil nil)
      (`((,_ . ,_)) t)	;single choice: nothing to do
      (`((,name . ,_) . ,_)
       ;; Reinstate link plist associated to the chosen
       ;; function.
       (apply #'org-link-store-props
              (cdr (assoc-string
                    (completing-read
                     (format "Store link with (default %s): " name)
                     (mapcar #'car results-alist)
                     nil t nil nil (symbol-name name))
                    results-alist)))
       t))))