0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 22:07:49 +00:00

Fix storing coderef link on when a code ref already exists

* lisp/org.el (org-store-link): Fix storing coderef link on when
  a code ref already exists.
This commit is contained in:
Nicolas Goaziou 2018-11-03 16:38:28 +01:00
parent 6382a6bbb3
commit eb8041ef82

View file

@ -9242,22 +9242,30 @@ non-nil."
(setq desc (or (plist-get org-store-link-plist :description)
link)))
;; Store a link from a source code buffer.
;; Store a link from a remote editing buffer.
((org-src-edit-buffer-p)
(let ((coderef-format (org-src-coderef-format)))
(cond ((org-match-line (org-src-coderef-regexp coderef-format))
(cond
;; A code reference exists. Use it.
((save-excursion
(beginning-of-line)
(re-search-forward (org-src-coderef-regexp coderef-format)
(line-end-position)
t))
(setq link (format "(%s)" (match-string-no-properties 3))))
;; No code reference. Create a new one then store the link
;; to it, but only in the function is called interactively.
(interactive?
(let ((label (read-string "Code line label: ")))
(end-of-line)
(setq link (format coderef-format label))
(let ((gc (- 79 (length link))))
(let* ((label (read-string "Code line label: "))
(reference (format coderef-format label))
(gc (- 79 (length link))))
(if (< (current-column) gc)
(org-move-to-column gc t)
(insert " ")))
(insert link)
(setq link (concat "(" label ")"))
(setq desc nil)))
(insert " "))
(insert reference))
(setq link (format "(%s)" label))
(setq desc nil))
(t (setq link nil)))))
;; We are in the agenda, link to referenced location