From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: Turning comments into hyperlinks Date: Thu, 19 Jul 2012 09:02:13 -0700 Message-ID: References: <87txx5gn3n.fsf@kuiper.lan.informatimago.com> <878veh2kfv.fsf@yagnesh.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1342713756 26210 80.91.229.3 (19 Jul 2012 16:02:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 19 Jul 2012 16:02:36 +0000 (UTC) Cc: "Pascal J. Bourguignon" , help-gnu-emacs@gnu.org To: Yagnesh Raghava Yakkala Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 19 18:02:35 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SrtBR-0001VV-UH for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 18:02:34 +0200 Original-Received: from localhost ([::1]:57918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrtBR-0006ur-9o for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jul 2012 12:02:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrtBG-0006u9-LH for help-gnu-emacs@gnu.org; Thu, 19 Jul 2012 12:02:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrtB9-0001vd-FA for help-gnu-emacs@gnu.org; Thu, 19 Jul 2012 12:02:22 -0400 Original-Received: from mail-lb0-f169.google.com ([209.85.217.169]:48976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrtB9-0001vM-7a for help-gnu-emacs@gnu.org; Thu, 19 Jul 2012 12:02:15 -0400 Original-Received: by lbjn8 with SMTP id n8so4675964lbj.0 for ; Thu, 19 Jul 2012 09:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=xoksGyb1Rz748Vi1XeZGd7tAGWHi0Dc9qcEW6iecxXc=; b=N95chOYt/nwSP5DdxKo5Y8Z4mP31EkjBiE2Av22Fj2BXesFyLOsIMAGClz2onnmay3 YT++b24YaY75cXafgmuXYxSpM+tm2fJ3yyPDV8T6D6/QBusvkJA+7cPq3ggecuegRwAu wdmXgzzHWxdS6qmEZm4gAYMO+H9oLo6QaoLg1QY1Nzv9/jylG8KIZjMgXcObOeuAvHU6 tVeA7mh1sXNsNicH9R4uK+Y8UFdRJdrNxU3QoXabNEQto72dIkPXJtp8EpiCLF6hyI4j 9LEjMFTSEFuEIAch99lJczeHCnGyUVtmTrJ8i2LFGmdp3vtfCRe4cyiAVeHmswA7YA2/ pdEg== Original-Received: by 10.152.132.233 with SMTP id ox9mr2796551lab.25.1342713733526; Thu, 19 Jul 2012 09:02:13 -0700 (PDT) Original-Received: by 10.112.5.102 with HTTP; Thu, 19 Jul 2012 09:02:13 -0700 (PDT) In-Reply-To: <878veh2kfv.fsf@yagnesh.org> X-Google-Sender-Auth: KF9WxFeZJqUtIbbmWv4vpJycc14 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.217.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85940 Archived-At: On Wed, Jul 18, 2012 at 7:49 AM, Yagnesh Raghava Yakkala wrote: > > Hello Pascal, > > "Pascal J. Bourguignon" writes: > >> Sohail Somani 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.