From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [dev] Implement "ref" link types Date: Sun, 19 Feb 2012 21:10:59 +0100 Message-ID: References: <87vcn2vgq7.fsf@gmail.com> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:49049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzD69-0001XL-St for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 15:11:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzD68-0000BC-Mj for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 15:11:05 -0500 Received: from mail-ey0-f169.google.com ([209.85.215.169]:65169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzD68-0000B8-I3 for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 15:11:04 -0500 Received: by eaag11 with SMTP id g11so2112009eaa.0 for ; Sun, 19 Feb 2012 12:11:03 -0800 (PST) In-Reply-To: <87vcn2vgq7.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Org Mode List On 19.2.2012, at 19:08, Nicolas Goaziou wrote: > Hello, >=20 > I'd like to introduce a new type of internal links, namely "ref" = links. >=20 > 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. >=20 > 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]]. >=20 > 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: >=20 > #+begin_src org > #+name: tab:letters > #+caption: Letters > | a | b | > | c | d | >=20 > #+name: tab:numbers > #+caption: Numbers > | 1 | > | 2 | >=20 >=20 > In tableau [[ref:tab:numbers]] we can see... Yet, in > [[ref:tab:numbers][the same table]], ... > #+end_src >=20 > the last sentence, in ascii, becomes: >=20 > In tableau 2 we can see... Yet, in the same table, ... >=20 >=20 > 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. >=20 > 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 >=20 >=20 > Regards, >=20 > --=20 > Nicolas Goaziou > =46rom f92e12a9482613d4b1d27090fac8d2667b094fdb Mon Sep 17 00:00:00 = 2001 > From: Nicolas Goaziou > Date: Sun, 19 Feb 2012 18:48:41 +0100 > Subject: [PATCH] Implement "ref" internal link type in Org buffers >=20 > * lisp/org.el (org-link-search): Handle "ref" internal link types. >=20 > 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(-) >=20 > 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 > --=20 > 1.7.9.1 >=20