emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sriram Thaiyar <sriram.thaiyar@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Dynamic links
Date: Fri, 8 Jul 2016 15:00:59 -0700	[thread overview]
Message-ID: <CAOBv0PdH+MVr+_6w9iWYBzz1ENkHYdivZwBS2U6BpzRGYJWD_w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1945 bytes --]

             reply	other threads:[~2016-07-08 22:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08 22:00 Sriram Thaiyar [this message]
2016-07-10 21:19 ` Dynamic links John Kitchin
2016-07-11  7:42   ` Sriram Thaiyar

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=CAOBv0PdH+MVr+_6w9iWYBzz1ENkHYdivZwBS2U6BpzRGYJWD_w@mail.gmail.com \
    --to=sriram.thaiyar@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).