Coderefs: Supporting functionality
This patch adds support functionality for the new code references. It makes sure that `C-c C-o' will follow a code reference correctly. It also extends the command org-store-link to actually create a new code reference cookie when used in a source code temporary buffer created with "C-c '". The new link will be stored, so that it can be inserted with `C-c C-l'. When inserting such a link, no description will be prompted for, because these coderef links should best not have a description part.
This commit is contained in:
parent
49f0a8d8b7
commit
c80b4a6c24
50
lisp/org.el
50
lisp/org.el
|
@ -6228,6 +6228,23 @@ For file links, arg negates `org-context-in-file-links'."
|
||||||
(setq link (plist-get org-store-link-plist :link)
|
(setq link (plist-get org-store-link-plist :link)
|
||||||
desc (or (plist-get org-store-link-plist :description) link)))
|
desc (or (plist-get org-store-link-plist :description) link)))
|
||||||
|
|
||||||
|
((equal (buffer-name) "*Org Edit Src Example*")
|
||||||
|
(let (label gc)
|
||||||
|
(while (or (not label)
|
||||||
|
(save-excursion
|
||||||
|
(save-restriction
|
||||||
|
(widen)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(re-search-forward (concat "((" label "))") nil t))))
|
||||||
|
(when label (message "Label exists already") (sit-for 2))
|
||||||
|
(setq label (read-string "Code line label: " label)))
|
||||||
|
(end-of-line 1)
|
||||||
|
(setq link (format "((%s))" label))
|
||||||
|
(setq gc (- 79 (length link)))
|
||||||
|
(if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
|
||||||
|
(insert link)
|
||||||
|
(setq desc nil)))
|
||||||
|
|
||||||
((eq major-mode 'calendar-mode)
|
((eq major-mode 'calendar-mode)
|
||||||
(let ((cd (calendar-cursor-to-date)))
|
(let ((cd (calendar-cursor-to-date)))
|
||||||
(setq link
|
(setq link
|
||||||
|
@ -6640,23 +6657,25 @@ used as the link location instead of reading one interactively."
|
||||||
(reverse org-stored-links) "\n"))))
|
(reverse org-stored-links) "\n"))))
|
||||||
(let ((cw (selected-window)))
|
(let ((cw (selected-window)))
|
||||||
(select-window (get-buffer-window "*Org Links*"))
|
(select-window (get-buffer-window "*Org Links*"))
|
||||||
(org-fit-window-to-buffer)
|
|
||||||
(setq truncate-lines t)
|
(setq truncate-lines t)
|
||||||
|
(org-fit-window-to-buffer)
|
||||||
(select-window cw))
|
(select-window cw))
|
||||||
;; Fake a link history, containing the stored links.
|
;; Fake a link history, containing the stored links.
|
||||||
(setq tmphist (append (mapcar 'car org-stored-links)
|
(setq tmphist (append (mapcar 'car org-stored-links)
|
||||||
org-insert-link-history))
|
org-insert-link-history))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(setq link (org-completing-read
|
(setq link
|
||||||
"Link: "
|
(let ((org-completion-use-ido nil))
|
||||||
(append
|
(org-completing-read
|
||||||
(mapcar (lambda (x) (list (concat (car x) ":")))
|
"Link: "
|
||||||
(append org-link-abbrev-alist-local org-link-abbrev-alist))
|
(append
|
||||||
(mapcar (lambda (x) (list (concat x ":")))
|
(mapcar (lambda (x) (list (concat (car x) ":")))
|
||||||
org-link-types))
|
(append org-link-abbrev-alist-local org-link-abbrev-alist))
|
||||||
nil nil nil
|
(mapcar (lambda (x) (list (concat x ":")))
|
||||||
'tmphist
|
org-link-types))
|
||||||
(or (car (car org-stored-links)))))
|
nil nil nil
|
||||||
|
'tmphist
|
||||||
|
(or (car (car org-stored-links))))))
|
||||||
(set-window-configuration wcf)
|
(set-window-configuration wcf)
|
||||||
(kill-buffer "*Org Links*"))
|
(kill-buffer "*Org Links*"))
|
||||||
(setq entry (assoc link org-stored-links))
|
(setq entry (assoc link org-stored-links))
|
||||||
|
@ -7118,6 +7137,15 @@ in all files. If AVOID-POS is given, ignore matches near that position."
|
||||||
pos (match-beginning 0))))
|
pos (match-beginning 0))))
|
||||||
;; There is an exact target for this
|
;; There is an exact target for this
|
||||||
(goto-char pos))
|
(goto-char pos))
|
||||||
|
((and (string-match "^((.*))$" s0)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(and
|
||||||
|
(re-search-forward (concat "[^[]" (regexp-quote s0)) nil t)
|
||||||
|
(setq type 'dedicated
|
||||||
|
pos (1+ (match-beginning 0))))))
|
||||||
|
;; There is a coderef target for this
|
||||||
|
(goto-char pos))
|
||||||
((string-match "^/\\(.*\\)/$" s)
|
((string-match "^/\\(.*\\)/$" s)
|
||||||
;; A regular expression
|
;; A regular expression
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Reference in New Issue