help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turning comments into hyperlinks


From: PJ Weisberg
Subject: Re: Turning comments into hyperlinks
Date: Thu, 19 Jul 2012 09:02:13 -0700

On Wed, Jul 18, 2012 at 7:49 AM, Yagnesh Raghava Yakkala <hi@yagnesh.org> wrote:
>
> Hello Pascal,
>
> "Pascal J. Bourguignon" <pjb@informatimago.com> writes:
>
>> Sohail Somani <sohail@taggedtype.net> writes:
>>
>>> Greetings Earthlings!
>>>
>>> I have come across an inconvenience which I would like to resolve. I
>>> am working on a codebase which has the following patterns throughout
>>> the code:
>>>
>>> // JIRA 12312
>>> // ISSUE 12312
>>> // KEY-12312
>>>
>>> What I would like to do is match these patterns and turn them into
>>> hyperlinks that open in the browser. So for example, I might turn
>>> KEY-12312 into a hyperlink to http://jira.myhomies.com/KEY-12312 but
>>> continue to display the original text.
>>>
>>> How would I accomplish this with cc-mode or emacs in general?
>>
>>
>> Since those patterns seem to be safely recognizable with regular
>> expressions, you can use font-locking to identify them and substitute
>> with with an hyperlink button. The font-lock keyword definition would
>> use compose-region to overlay the text with a button which action would
>> browse the url you want.
>
> I think It would have been good, if `ffap' functions(or some other generic 
> library)
> are more user customizable to allow such a use cases.
>
> An alist with "regex-pattern . action-func"

find-file-at-point *is* flexible enough to handle it, if you write
functions to turn those strings into URLs.  See `ffap-alist'.  It
would be a bit ugly in the first two cases, though, because the
function gets passed the word at point, so if you got "12312" you
would have to look back to see if "JIRA" or "ISSUE" came before it.

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]