emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <dominik@science.uva.nl>
To: Bart Parliman <parliman@lanl.gov>
Cc: emacs-orgmode@gnu.org
Subject: Re: Line numbers with org-store-link?
Date: Tue, 6 May 2008 09:20:57 +0200	[thread overview]
Message-ID: <1965C49B-BDF1-451C-A84B-1E48AE5C5488@science.uva.nl> (raw)
In-Reply-To: <alpine.OSX.1.10.0805051515190.302@kezar.lanl.gov>


[-- Attachment #1.1: Type: text/plain, Size: 1907 bytes --]

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


[-- Attachment #1.2: Type: text/html, Size: 2575 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

  reply	other threads:[~2008-05-06  7:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05 21:40 Line numbers with org-store-link? Bart Parliman
2008-05-06  7:20 ` Carsten Dominik [this message]
2008-05-06 15:28   ` Bart Parliman

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=1965C49B-BDF1-451C-A84B-1E48AE5C5488@science.uva.nl \
    --to=dominik@science.uva.nl \
    --cc=emacs-orgmode@gnu.org \
    --cc=parliman@lanl.gov \
    /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).