emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [dev] Implement "ref" link types
Date: Sun, 19 Feb 2012 21:10:59 +0100	[thread overview]
Message-ID: <E2A59F3A-458B-44D7-B794-C2429FD18F9D@gmail.com> (raw)
In-Reply-To: <87vcn2vgq7.fsf@gmail.com>


On 19.2.2012, at 19:08, Nicolas Goaziou wrote:

> 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?

Love it!  Why are you saying it is not a full replacement for \ref{something}?
It is better than that because it will work in more backends....

- Carsten

> 
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> From f92e12a9482613d4b1d27090fac8d2667b094fdb Mon Sep 17 00:00:00 2001
> From: Nicolas Goaziou <n.goaziou@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
> 

  parent reply	other threads:[~2012-02-19 20:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-19 18:08 [dev] Implement "ref" link types Nicolas Goaziou
2012-02-19 19:28 ` Christian Moe
2012-02-19 19:41   ` Nicolas Goaziou
2012-02-19 20:11     ` Toby Cubitt
2012-02-19 20:20     ` Christian Moe
2012-02-19 19:41 ` Samuel Wales
2012-02-19 20:02   ` Nicolas Goaziou
2012-02-19 20:48     ` Samuel Wales
2012-02-19 20:10 ` Carsten Dominik [this message]
2012-02-20  0:51   ` Nicolas Goaziou
2012-02-20  7:09     ` Carsten Dominik
2012-02-20 10:59       ` Nicolas Goaziou
2012-02-20 22:06         ` Nicolas Goaziou
2012-02-21  1:26           ` Thomas S. Dye
2012-02-21  5:14           ` David Maus
2012-02-21  9:18             ` Nicolas Goaziou
2012-02-27 19:38               ` Nicolas Goaziou
2012-02-27 20:38               ` David Maus
2012-03-05  9:37         ` Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E2A59F3A-458B-44D7-B794-C2429FD18F9D@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).