From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Parliman Subject: Re: Line numbers with org-store-link? Date: Tue, 6 May 2008 09:28:24 -0600 Message-ID: References: <1965C49B-BDF1-451C-A84B-1E48AE5C5488@science.uva.nl> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JtP5q-0005p7-Bs for emacs-orgmode@gnu.org; Tue, 06 May 2008 11:28:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JtP5p-0005od-L5 for emacs-orgmode@gnu.org; Tue, 06 May 2008 11:28:37 -0400 Received: from [199.232.76.173] (port=43740 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JtP5p-0005oZ-Bu for emacs-orgmode@gnu.org; Tue, 06 May 2008 11:28:37 -0400 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JtP5o-0006vP-UD for emacs-orgmode@gnu.org; Tue, 06 May 2008 11:28:37 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JtP5m-0004Dm-H2 for emacs-orgmode@gnu.org; Tue, 06 May 2008 15:28:34 +0000 Received: from kezar.lanl.gov ([128.165.248.134]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 06 May 2008 15:28:34 +0000 Received: from parliman by kezar.lanl.gov with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 06 May 2008 15:28:34 +0000 In-Reply-To: <1965C49B-BDF1-451C-A84B-1E48AE5C5488@science.uva.nl> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Cc: Bart Parliman , emacs-orgmode@gnu.org Carsten, This is exactly what I need. Thanks. Bart On Tue, 6 May 2008, Carsten Dominik wrote: > Hi Bart, > > No, this does not exist, because normally line numbers are moving around and > therefore are not very useful as long-term search targets. > > You can pretty easily hack this, though: > > Lets say you want to have line numbers for links to any files in c-mode > (because this is the programming language you are talking about). Limiting > it to some special files makes sure that in other file types you will still > get links based on (somewhat) more reliable text snippets. > > Then you can write a small function and add it to the hook > org-create-file-search-functions: > > (defun my-link-to-line-number-in-c-mode () > "When in c-mode, use line number as search item." > (when (eq major-mode 'c-mode) > (number-to-string (org-current-line)))) > > (add-hook 'org-create-file-search-functions > 'my-link-to-line-number-in-c-mode) > > Normally you would also have to write a function to search for the custom > link search text and add that function to > `org-execute-file-search-functions'. But you are lucky: if the search item > is an integer number, Org already interprets it as a line number. > > Hope this helps. > > - Carsten > > On May 5, 2008, at 11:40 PM, Bart Parliman wrote: >> Is there a way to force org-store-link to store the current line number >> rather than a string to locate? >> >> When preparing for code reviews I like to create notes with links to the >> exact source line. FWIW, in these cases, I keep a static copy of the code >> so I know it isn't going to change. >> >> Obviously none of those reviews involve lisp, since my first feeble attempt >> to add a hyperlink type never even came close to running. :-) >> >> Thanks for any help, >> Bart >> >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Remember: use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >