Hello, I'd like to introduce a new type of internal links, namely "ref" links.
Since any element can now have a "#+name: something" affiliated keyword, it would be practical to have a way to go straight to that name, from anywhere in the buffer. The following patch implements a [[ref:something]] syntax, or even [[ref:something][text]] to do so. The problem that I see here is that is breaks a bit syntax for internal links ("protocol:path" is usually for external links). Another solution would be to make them more hermetic: [[!something]]. On the export side, a "ref" link should be replaced by its description, if it has any, or by the sequence number of the matching element among elements of the same type. With the new exporter and the following buffer: #+begin_src org #+name: tab:letters #+caption: Letters | a | b | | c | d | #+name: tab:numbers #+caption: Numbers | 1 | | 2 | In tableau [[ref:tab:numbers]] we can see... Yet, in [[ref:tab:numbers][the same table]], ... #+end_src the last sentence, in ascii, becomes: In tableau 2 we can see... Yet, in the same table, ... Even if it's not a perfect replacement for "\ref{something}" commands, it should be sufficient for all major back-ends to provide an approximate functionality. And we gain interactivity in the Org buffer. What do you think? Regards, -- Nicolas Goaziou
>From f92e12a9482613d4b1d27090fac8d2667b094fdb Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaz...@gmail.com> Date: Sun, 19 Feb 2012 18:48:41 +0100 Subject: [PATCH] Implement "ref" internal link type in Org buffers * lisp/org.el (org-link-search): Handle "ref" internal link types. A [[ref:some-name]] link points to a "#+name: some-name" in the same buffer. --- lisp/org.el | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a81f7fc..ea06863 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9875,6 +9875,16 @@ visibility around point, thus ignoring ;; First check if there are any special search functions ((run-hook-with-args-until-success 'org-execute-file-search-functions s)) ;; Now try the builtin stuff + ;; Ref internal link. + ((and (string-match "^ref:\\(.*\\)" s0) + (let ((name (org-trim (match-string 1 s0)))) + (save-excursion + (goto-char (point-min)) + (and (re-search-forward + (format "^[ \t]*#\\+name: %s" name) nil t) + (setq type 'dedicated pos (match-beginning 0)))))) + (goto-char pos)) + ;; Custom-id ((and (equal (string-to-char s0) ?#) (> (length s0) 1) (save-excursion -- 1.7.9.1