all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Turning comments into hyperlinks
@ 2012-07-18 14:12 Sohail Somani
  2012-07-19  9:45 ` Tom Willemsen
  0 siblings, 1 reply; 7+ messages in thread
From: Sohail Somani @ 2012-07-18 14:12 UTC (permalink / raw)
  To: help-gnu-emacs

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?

Thanks,

Sohail





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
       [not found] <mailman.5073.1342620934.855.help-gnu-emacs@gnu.org>
@ 2012-07-18 14:28 ` Pascal J. Bourguignon
  2012-07-18 14:49   ` Yagnesh Raghava Yakkala
  2012-07-18 15:28   ` Sohail Somani
  0 siblings, 2 replies; 7+ messages in thread
From: Pascal J. Bourguignon @ 2012-07-18 14:28 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
  2012-07-18 14:28 ` Pascal J. Bourguignon
@ 2012-07-18 14:49   ` Yagnesh Raghava Yakkala
  2012-07-19 16:02     ` PJ Weisberg
  2012-07-18 15:28   ` Sohail Somani
  1 sibling, 1 reply; 7+ messages in thread
From: Yagnesh Raghava Yakkala @ 2012-07-18 14:49 UTC (permalink / raw)
  To: Pascal J. Bourguignon; +Cc: help-gnu-emacs


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"

Just a thought.

Thanks.,
-- 
ఎందరో మహానుభావులు అందరికి వందనములు
YYR



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
  2012-07-18 14:28 ` Pascal J. Bourguignon
  2012-07-18 14:49   ` Yagnesh Raghava Yakkala
@ 2012-07-18 15:28   ` Sohail Somani
  1 sibling, 0 replies; 7+ messages in thread
From: Sohail Somani @ 2012-07-18 15:28 UTC (permalink / raw)
  To: help-gnu-emacs

On 18/07/2012 10:28 AM, Pascal J. Bourguignon wrote:
> 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.

Thanks, I'll look into this.






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
  2012-07-18 14:12 Turning comments into hyperlinks Sohail Somani
@ 2012-07-19  9:45 ` Tom Willemsen
  2012-07-19 14:55   ` Sohail Somani
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Willemsen @ 2012-07-19  9:45 UTC (permalink / raw)
  To: Sohail Somani; +Cc: help-gnu-emacs

Hey Sohail,

Sohail Somani <sohail@taggedtype.net> writes:

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

Have you looked at `bug-reference-prog-mode'? From what I read it seems
to fit perfectly with what you're hoping to accomplish, though I haven't
tried using it myself and I think its only available in emacs 24.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
  2012-07-19  9:45 ` Tom Willemsen
@ 2012-07-19 14:55   ` Sohail Somani
  0 siblings, 0 replies; 7+ messages in thread
From: Sohail Somani @ 2012-07-19 14:55 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: help-gnu-emacs

On 19/07/2012 5:45 AM, Tom Willemsen wrote:
> Hey Sohail,
>
> Sohail Somani <sohail@taggedtype.net> writes:
>
>> 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?
>
> Have you looked at `bug-reference-prog-mode'? From what I read it seems
> to fit perfectly with what you're hoping to accomplish, though I haven't
> tried using it myself and I think its only available in emacs 24.

This actually looks exactly like what I need. Thanks! The documentation 
is a little lacking from what I can tell but I think I can make it work :)

Sohail





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Turning comments into hyperlinks
  2012-07-18 14:49   ` Yagnesh Raghava Yakkala
@ 2012-07-19 16:02     ` PJ Weisberg
  0 siblings, 0 replies; 7+ messages in thread
From: PJ Weisberg @ 2012-07-19 16:02 UTC (permalink / raw)
  To: Yagnesh Raghava Yakkala; +Cc: Pascal J. Bourguignon, help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-07-19 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-18 14:12 Turning comments into hyperlinks Sohail Somani
2012-07-19  9:45 ` Tom Willemsen
2012-07-19 14:55   ` Sohail Somani
     [not found] <mailman.5073.1342620934.855.help-gnu-emacs@gnu.org>
2012-07-18 14:28 ` Pascal J. Bourguignon
2012-07-18 14:49   ` Yagnesh Raghava Yakkala
2012-07-19 16:02     ` PJ Weisberg
2012-07-18 15:28   ` Sohail Somani

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.