From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sriram Thaiyar Subject: Dynamic links Date: Fri, 8 Jul 2016 15:00:59 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1148b6ee1bff04053726f04e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLdpZ-0001qJ-KJ for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 18:01:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLdpV-0000Yc-BF for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 18:01:05 -0400 Received: from mail-yw0-x229.google.com ([2607:f8b0:4002:c05::229]:36729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLdpV-0000YX-6y for emacs-orgmode@gnu.org; Fri, 08 Jul 2016 18:01:01 -0400 Received: by mail-yw0-x229.google.com with SMTP id b72so48070670ywa.3 for ; Fri, 08 Jul 2016 15:01:00 -0700 (PDT) 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" To: emacs-orgmode@gnu.org --001a1148b6ee1bff04053726f04e Content-Type: text/plain; charset=UTF-8 Hi- I've implemented "dynamic links" which are like plain links but for arbitrary regular expressions. I was wondering if there was a better way to do this? You can see the implementation here: https://github.com/sri/dotfiles/commit/cd3429ce0c8e637c803835299c2ed4653d19a5fb (This works with Org-mode version: 8.3.4 - 8.3.4-88-g792bb9-elpa.) With this config: (add-to-list 'my-org-dynamic-links-matcher '("\\([[:alpha:]]\\{2,5\\}-[[:digit:]]+\\)" "https://some-ticketing-system.org/%s")) a string like `TEST-122' is turned into a link, as you type it in. And when you click on that link, it'll visit this URL: https://some-ticketing-system.org/TEST-122 There are some things that gave me problems: - I can't hit and have it follow the link. For this, it seems like I would need to advice the `org-return' function. - Despite the fact that the `TEST-123' has a `htmlize-link' text property, it errors out with "No link found". To fix that, I needed to add a hook to `org-open-at-point-functions'. - I had to copy a bunch of code from `org-activate-plain-links' to get this to work. Thanks, -Sriram --001a1148b6ee1bff04053726f04e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi-

I've implemente= d "dynamic links" which are like plain links but for
ar= bitrary regular expressions.

I was wondering if th= ere was a better way to do this?

You can see the i= mplementation here:

(This works with Org-mode version: 8.3.4 - 8.3.4-88-g792bb9-elpa.)

With this config:

=C2= =A0 =C2=A0 (add-to-list 'my-org-dynamic-links-matcher
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'("\\([[:al= pha:]]\\{2,5\\}-[[:digit:]]+\\)"
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"https://some-ticketing-system.org/%s"))

a string like `TEST-122' is turned into a link, as= you type it in.
And when you click on that link, it'll visit= this URL:

Th= ere are some things that gave me problems:

- I can= 't hit <return> and have it follow the link. For this, it seems
=C2=A0 like I would need to advice the `org-return' function.<= /div>

- Despite the fact that the `TEST-123' has a `= htmlize-link' text property,=C2=A0
=C2=A0 it errors out with = "No link found". To fix that, I needed to add a hook to
=C2=A0 `org-open-at-point-functions'.

- I had= to copy a bunch of code from `org-activate-plain-links' to get
=C2=A0 this to work.

Thanks,
-Sriram<= /div>

--001a1148b6ee1bff04053726f04e--