diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-03 18:04:55 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-01-03 18:04:55 +0100 |
commit | ff3d23e64e4f61a3b928d50bc2f10ac4b90c38c5 (patch) | |
tree | a415253711542f2d4fa56b2f20488585f4641d14 | |
parent | c0ea20aab70a74136110417bae459abd8efabeaf (diff) | |
download | org-mode-ff3d23e64e4f61a3b928d50bc2f10ac4b90c38c5.tar.gz |
Do not use `called-interactively-p' in `org-store-link'
* lisp/org.el (org-store-link): Do not use `called-interactively-p'.
Fixes: 19915
-rw-r--r-- | lisp/org.el | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lisp/org.el b/lisp/org.el index 3b36ead..930c789 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9064,7 +9064,7 @@ and then used in capture templates." (defvar org-id-link-to-org-use-id) ; Defined in org-id.el ;;;###autoload -(defun org-store-link (arg) +(defun org-store-link (arg &optional interactive?) "Store an org-link to the current location. \\<org-mode-map> This link is added to `org-stored-links' and can later be inserted @@ -9081,8 +9081,11 @@ part of Org core. A `\\[universal-argument] \\[universal-argument] \\[universal-argument]' \ prefix ARG forces storing a link for each line in the -active region." - (interactive "P") +active region. + +Assume the function is called interactively if INTERACTIVE? is +non-nil." + (interactive "P\np") (org-load-modules-maybe) (if (and (equal arg '(64)) (org-region-active-p)) (save-excursion @@ -9131,11 +9134,9 @@ active region." ;; Store a link from a source code buffer. ((org-src-edit-buffer-p) (let ((coderef-format (org-src-coderef-format))) - (cond ((save-excursion - (beginning-of-line) - (looking-at (org-src-coderef-regexp coderef-format))) + (cond ((org-match-line (org-src-coderef-regexp coderef-format)) (setq link (format "(%s)" (match-string-no-properties 3)))) - ((called-interactively-p 'any) + (interactive? (let ((label (read-string "Code line label: "))) (end-of-line) (setq link (format coderef-format label)) @@ -9154,10 +9155,7 @@ active region." (get-text-property (point) 'org-marker)))) (when m (org-with-point-at m - (setq agenda-link - (if (called-interactively-p 'any) - (call-interactively 'org-store-link) - (org-store-link nil))))))) + (setq agenda-link (org-store-link nil interactive?)))))) ((eq major-mode 'calendar-mode) (let ((cd (calendar-cursor-to-date))) @@ -9221,7 +9219,7 @@ active region." link cpltxt)) ((and (featurep 'org-id) (or (eq org-id-link-to-org-use-id t) - (and (called-interactively-p 'any) + (and interactive? (or (eq org-id-link-to-org-use-id 'create-if-interactive) (and (eq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id) @@ -9284,7 +9282,7 @@ active region." desc "NONE"))) (setq link cpltxt)) - ((called-interactively-p 'interactive) + (interactive? (user-error "No method for storing a link from this buffer")) (t (setq link nil))) @@ -9301,9 +9299,7 @@ active region." (lambda (m) (or (match-string 5 m) (match-string 3 m))) desc)))) ;; Return the link - (if (not (and (or (called-interactively-p 'any) - executing-kbd-macro) - link)) + (if (not (and interactive? link)) (or agenda-link (and link (org-make-link-string link desc))) (push (list link desc) org-stored-links) (message "Stored: %s" (or desc link)) |