diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-08-17 23:45:38 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-08-17 23:45:38 +0200 |
commit | fea6dd167a37237ca58190f6f248c90e01ba75ec (patch) | |
tree | 0750d2ca697f37ebdad332f62aba2706ee747ee8 | |
parent | 48af4166fde469aaced46d70f01c39d460bd0f86 (diff) | |
download | org-mode-fea6dd167a37237ca58190f6f248c90e01ba75ec.tar.gz |
Fix `org-store-link' in edit buffers
* lisp/org.el (org-store-link): Properly handle coderef insertion in an
edit buffer.
This patch also removes check for duplicate coderef labels, so as to be
on par with other link types.
-rw-r--r-- | lisp/org.el | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/lisp/org.el b/lisp/org.el index 9d837fa..39c37f5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9920,30 +9920,23 @@ active region." ;; Store a link from a source code buffer. ((org-src-edit-buffer-p) - (cond - ((save-excursion - (beginning-of-line) - (looking-at (concat (format org-coderef-label-format "\\(.*?\\)") - "[ \t]*$"))) - (setq link (format "(%s)" (match-string-no-properties 1)))) - ((called-interactively-p 'any) - (let (label) - (while (or (not label) - (org-with-wide-buffer - (goto-char (point-min)) - (re-search-forward - (regexp-quote (format org-coderef-label-format label)) - nil t))) - (when label (message "Label exists already") (sit-for 2)) - (setq label (read-string "Code line label: " label))) - (end-of-line) - (setq link (format org-coderef-label-format label)) - (let ((gc (- 79 (length link)))) - (if (< (current-column) gc) (org-move-to-column gc t) - (insert " "))) - (insert link) - (setq link (concat "(" label ")") desc nil))) - (t (setq link nil)))) + (let ((coderef-format (org-src-coderef-format))) + (cond ((save-excursion + (beginning-of-line) + (looking-at (org-src-coderef-regexp coderef-format))) + (setq link (format "(%s)" (match-string-no-properties 3)))) + ((called-interactively-p 'any) + (let ((label (read-string "Code line label: "))) + (end-of-line) + (setq link (format coderef-format label)) + (let ((gc (- 79 (length link)))) + (if (< (current-column) gc) + (org-move-to-column gc t) + (insert " "))) + (insert link) + (setq link (concat "(" label ")")) + (setq desc nil))) + (t (setq link nil))))) ;; We are in the agenda, link to referenced location ((equal (bound-and-true-p org-agenda-buffer-name) (buffer-name)) |