emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Line numbers with org-store-link?


From: Carsten Dominik
Subject: Re: [Orgmode] Line numbers with org-store-link?
Date: Tue, 6 May 2008 09:20:57 +0200

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.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


reply via email to

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