* anyway to create link to a line number in a file @ 2012-02-17 16:54 Not To Miss 2012-02-18 14:03 ` Sean O'Halpin 0 siblings, 1 reply; 11+ messages in thread From: Not To Miss @ 2012-02-17 16:54 UTC (permalink / raw) To: emacs-orgmode Hi all, I am reading a long text file and want to write down my notes with org-mode. I extremely would like to put the line numbers down along with my notes. Although there is a way to store a link for text search for the current line, I haven't found a way to create a link to a line number in the current buffer. Is there anyway to do that? Thanks -- Best, Zane ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-17 16:54 anyway to create link to a line number in a file Not To Miss @ 2012-02-18 14:03 ` Sean O'Halpin 2012-02-18 16:31 ` Not To Miss 0 siblings, 1 reply; 11+ messages in thread From: Sean O'Halpin @ 2012-02-18 14:03 UTC (permalink / raw) To: Not To Miss; +Cc: emacs-orgmode On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: > Hi all, > > I am reading a long text file and want to write down my notes with > org-mode. I extremely would like to put the line numbers down along > with my notes. Although there is a way to store a link for text search > for the current line, I haven't found a way to create a link to a line > number in the current buffer. Is there anyway to do that? Thanks Take a look at org-capture: http://orgmode.org/manual/Capture.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 14:03 ` Sean O'Halpin @ 2012-02-18 16:31 ` Not To Miss 2012-02-18 17:11 ` Eric Schulte 2012-02-18 17:31 ` Nick Dokos 0 siblings, 2 replies; 11+ messages in thread From: Not To Miss @ 2012-02-18 16:31 UTC (permalink / raw) To: Sean O'Halpin; +Cc: emacs-orgmode I looked that section carefully and the whole manual briefly. I haven't found anything yet. That's why I am asking on the mailing list to see if anyone has some workaround. On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: >> Hi all, >> >> I am reading a long text file and want to write down my notes with >> org-mode. I extremely would like to put the line numbers down along >> with my notes. Although there is a way to store a link for text search >> for the current line, I haven't found a way to create a link to a line >> number in the current buffer. Is there anyway to do that? Thanks > > Take a look at org-capture: http://orgmode.org/manual/Capture.html -- Best, Zhenjiang ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 16:31 ` Not To Miss @ 2012-02-18 17:11 ` Eric Schulte 2012-02-18 17:30 ` Not To Miss 2012-02-18 17:31 ` Nick Dokos 1 sibling, 1 reply; 11+ messages in thread From: Eric Schulte @ 2012-02-18 17:11 UTC (permalink / raw) To: Not To Miss; +Cc: emacs-orgmode Not To Miss <not.to.miss@gmail.com> writes: > I looked that section carefully and the whole manual briefly. I > haven't found anything yet. That's why I am asking on the mailing list > to see if anyone has some workaround. > [[file:filename.txt::6]] jumps to line 6 of filename.txt for me. I don't know if this is documented... if not a documentation patch would be appreciated. Best, > > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: >> On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: >>> Hi all, >>> >>> I am reading a long text file and want to write down my notes with >>> org-mode. I extremely would like to put the line numbers down along >>> with my notes. Although there is a way to store a link for text search >>> for the current line, I haven't found a way to create a link to a line >>> number in the current buffer. Is there anyway to do that? Thanks >> >> Take a look at org-capture: http://orgmode.org/manual/Capture.html -- Eric Schulte http://cs.unm.edu/~eschulte/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 17:11 ` Eric Schulte @ 2012-02-18 17:30 ` Not To Miss 0 siblings, 0 replies; 11+ messages in thread From: Not To Miss @ 2012-02-18 17:30 UTC (permalink / raw) To: Eric Schulte; +Cc: emacs-orgmode Sorry, I didn't make it more clear. I want to create a link to a specific line automatically, just as the command "C-c l" (org-store-link) to automatically create a link to the text of current line. Sometimes line number is more important for me to record. On Sat, Feb 18, 2012 at 12:11 PM, Eric Schulte <eric.schulte@gmx.com> wrote: > Not To Miss <not.to.miss@gmail.com> writes: > >> I looked that section carefully and the whole manual briefly. I >> haven't found anything yet. That's why I am asking on the mailing list >> to see if anyone has some workaround. >> > > [[file:filename.txt::6]] jumps to line 6 of filename.txt for me. I > don't know if this is documented... if not a documentation patch would > be appreciated. > > Best, > >> >> On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: >>> On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: >>>> Hi all, >>>> >>>> I am reading a long text file and want to write down my notes with >>>> org-mode. I extremely would like to put the line numbers down along >>>> with my notes. Although there is a way to store a link for text search >>>> for the current line, I haven't found a way to create a link to a line >>>> number in the current buffer. Is there anyway to do that? Thanks >>> >>> Take a look at org-capture: http://orgmode.org/manual/Capture.html > > -- > Eric Schulte > http://cs.unm.edu/~eschulte/ -- Best, Zhenjiang ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 16:31 ` Not To Miss 2012-02-18 17:11 ` Eric Schulte @ 2012-02-18 17:31 ` Nick Dokos 2012-02-18 21:58 ` Nick Dokos 1 sibling, 1 reply; 11+ messages in thread From: Nick Dokos @ 2012-02-18 17:31 UTC (permalink / raw) To: Not To Miss; +Cc: nicholas.dokos, emacs-orgmode Not To Miss <not.to.miss@gmail.com> wrote: > I looked that section carefully and the whole manual briefly. I > haven't found anything yet. That's why I am asking on the mailing list > to see if anyone has some workaround. > > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: > > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: > >> Hi all, > >> > >> I am reading a long text file and want to write down my notes with > >> org-mode. I extremely would like to put the line numbers down along > >> with my notes. Although there is a way to store a link for text search > >> for the current line, I haven't found a way to create a link to a line > >> number in the current buffer. Is there anyway to do that? Thanks > > > > Take a look at org-capture: http://orgmode.org/manual/Capture.html *Following* a link with a line number is no problem: org does that out of the box with a link like [[file:foo.txt::NNN][desc]] That is actually documented: (info "(org) External links") The problem is to make sure org-store-link will actually store the line number (along with everything else) so that then org-insert-link can insert the link in the proper format. I don't think there is a function to do that out of the box for line numbers, but you can easily (for some value of "easily") write your own. Look in (info "(org)Adding hyperlink types") for some hints. Briefly, you write a function that checks whether it wants to deal with the link or not, and you add it to org-store-link-functions. I don't have the time to try it out right now, but I believe this should work for what you want. Nick ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 17:31 ` Nick Dokos @ 2012-02-18 21:58 ` Nick Dokos 2012-02-20 4:43 ` Not To Miss 0 siblings, 1 reply; 11+ messages in thread From: Nick Dokos @ 2012-02-18 21:58 UTC (permalink / raw) To: Not To Miss; +Cc: nicholas.dokos, emacs-orgmode Nick Dokos <nicholas.dokos@hp.com> wrote: > Not To Miss <not.to.miss@gmail.com> wrote: > > > I looked that section carefully and the whole manual briefly. I > > haven't found anything yet. That's why I am asking on the mailing list > > to see if anyone has some workaround. > > > > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: > > > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: > > >> Hi all, > > >> > > >> I am reading a long text file and want to write down my notes with > > >> org-mode. I extremely would like to put the line numbers down along > > >> with my notes. Although there is a way to store a link for text search > > >> for the current line, I haven't found a way to create a link to a line > > >> number in the current buffer. Is there anyway to do that? Thanks > > > > > > Take a look at org-capture: http://orgmode.org/manual/Capture.html > > The problem is to make sure org-store-link will actually store the line > number (along with everything else) so that then org-insert-link can > insert the link in the proper format. I don't think there is a function > to do that out of the box for line numbers, but you can easily (for some > value of "easily") write your own. Look in > > (info "(org)Adding hyperlink types") > > for some hints. Briefly, you write a function that checks whether it > wants to deal with the link or not, and you add it to > org-store-link-functions. I don't have the time to try it out right now, > but I believe this should work for what you want. > Following up on this, the following seems to work, although you probably want to tweak the criterion of when you want *this* function to take care of links - this particular implementation only applies the line number treatment to links generated in the file named "/path/to/the.file.txt" and only that file: --8<---------------cut here---------------start------------->8--- (defun org-file-lineno-store-link() (when (string-equal (buffer-file-name) "/path/to/the.file.txt") (let* ((link (format "file:%s::%d" (buffer-file-name) (line-number-at-pos)))) (org-store-link-props :type "file" :link link)))) (add-hook 'org-store-link-functions 'org-file-lineno-store-link) --8<---------------cut here---------------end--------------->8--- Nick ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-18 21:58 ` Nick Dokos @ 2012-02-20 4:43 ` Not To Miss 2012-02-20 5:58 ` Nick Dokos 0 siblings, 1 reply; 11+ messages in thread From: Not To Miss @ 2012-02-20 4:43 UTC (permalink / raw) To: nicholas.dokos; +Cc: emacs-orgmode Thanks, Nick! It works, though it works only to the specified file(s) by overruling the original org-store-link-functions. Ideally, it would be great if in the normal stored org link, line number could be included in the link and would be ripped off from the text to search the linked file. On Sat, Feb 18, 2012 at 4:58 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: > Nick Dokos <nicholas.dokos@hp.com> wrote: > >> Not To Miss <not.to.miss@gmail.com> wrote: >> >> > I looked that section carefully and the whole manual briefly. I >> > haven't found anything yet. That's why I am asking on the mailing list >> > to see if anyone has some workaround. >> > >> > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: >> > > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: >> > >> Hi all, >> > >> >> > >> I am reading a long text file and want to write down my notes with >> > >> org-mode. I extremely would like to put the line numbers down along >> > >> with my notes. Although there is a way to store a link for text search >> > >> for the current line, I haven't found a way to create a link to a line >> > >> number in the current buffer. Is there anyway to do that? Thanks >> > > >> > > Take a look at org-capture: http://orgmode.org/manual/Capture.html >> > >> The problem is to make sure org-store-link will actually store the line >> number (along with everything else) so that then org-insert-link can >> insert the link in the proper format. I don't think there is a function >> to do that out of the box for line numbers, but you can easily (for some >> value of "easily") write your own. Look in >> >> (info "(org)Adding hyperlink types") >> >> for some hints. Briefly, you write a function that checks whether it >> wants to deal with the link or not, and you add it to >> org-store-link-functions. I don't have the time to try it out right now, >> but I believe this should work for what you want. >> > > Following up on this, the following seems to work, although you probably > want to tweak the criterion of when you want *this* function to take > care of links - this particular implementation only applies the line > number treatment to links generated in the file named > "/path/to/the.file.txt" and only that file: > > --8<---------------cut here---------------start------------->8--- > (defun org-file-lineno-store-link() > (when (string-equal (buffer-file-name) "/path/to/the.file.txt") > (let* ((link (format "file:%s::%d" (buffer-file-name) (line-number-at-pos)))) > (org-store-link-props > :type "file" > :link link)))) > > (add-hook 'org-store-link-functions 'org-file-lineno-store-link) > --8<---------------cut here---------------end--------------->8--- > > Nick > -- Best, Zhenjiang ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-20 4:43 ` Not To Miss @ 2012-02-20 5:58 ` Nick Dokos 2012-02-21 17:16 ` Not To Miss 0 siblings, 1 reply; 11+ messages in thread From: Nick Dokos @ 2012-02-20 5:58 UTC (permalink / raw) To: Not To Miss; +Cc: nicholas.dokos, emacs-orgmode Not To Miss <not.to.miss@gmail.com> wrote: > Thanks, Nick! It works, though it works only to the specified file(s) > by overruling the original org-store-link-functions. Yes, org marches down the link handlers and takes the first positive response as the answer. You can make the function arbitrarily complicated of course, if you don't like the behavior, but in any case, it will have to say "yes" (and provide the link in some format) or "no" - in the latter case, org will continue on with the rest of the functions in the list (and fall back to its default if *no* function says "yes"). > Ideally, it would > be great if in the normal stored org link, line number could be > included in the link and would be ripped off from the text to search > the linked file. > I'm confused - what exactly are you asking for here? If you don't use the line number for searching, why would you want to store it? Nick > On Sat, Feb 18, 2012 at 4:58 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: > > Nick Dokos <nicholas.dokos@hp.com> wrote: > > > >> Not To Miss <not.to.miss@gmail.com> wrote: > >> > >> > I looked that section carefully and the whole manual briefly. I > >> > haven't found anything yet. That's why I am asking on the mailing list > >> > to see if anyone has some workaround. > >> > > >> > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin <sean.ohalpin@gmail.com> wrote: > >> > > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss <not.to.miss@gmail.com> wrote: > >> > >> Hi all, > >> > >> > >> > >> I am reading a long text file and want to write down my notes with > >> > >> org-mode. I extremely would like to put the line numbers down along > >> > >> with my notes. Although there is a way to store a link for text search > >> > >> for the current line, I haven't found a way to create a link to a line > >> > >> number in the current buffer. Is there anyway to do that? Thanks > >> > > > >> > > Take a look at org-capture: http://orgmode.org/manual/Capture.html > >> > > > >> The problem is to make sure org-store-link will actually store the line > >> number (along with everything else) so that then org-insert-link can > >> insert the link in the proper format. I don't think there is a function > >> to do that out of the box for line numbers, but you can easily (for some > >> value of "easily") write your own. Look in > >> > >> (info "(org)Adding hyperlink types") > >> > >> for some hints. Briefly, you write a function that checks whether it > >> wants to deal with the link or not, and you add it to > >> org-store-link-functions. I don't have the time to try it out right now, > >> but I believe this should work for what you want. > >> > > > > Following up on this, the following seems to work, although you probably > > want to tweak the criterion of when you want *this* function to take > > care of links - this particular implementation only applies the line > > number treatment to links generated in the file named > > "/path/to/the.file.txt" and only that file: > > > > --8<---------------cut here---------------start------------->8--- > > (defun org-file-lineno-store-link() > > (when (string-equal (buffer-file-name) "/path/to/the.file.txt") > > (let* ((link (format "file:%s::%d" (buffer-file-name) (line-number-at-pos)))) > > (org-store-link-props > > :type "file" > > :link link)))) > > > > (add-hook 'org-store-link-functions 'org-file-lineno-store-link) > > --8<---------------cut here---------------end--------------->8--- > > > > Nick > > > > > > -- > Best, > Zhenjiang > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-20 5:58 ` Nick Dokos @ 2012-02-21 17:16 ` Not To Miss 2012-02-21 17:29 ` Nick Dokos 0 siblings, 1 reply; 11+ messages in thread From: Not To Miss @ 2012-02-21 17:16 UTC (permalink / raw) To: nicholas.dokos; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 4367 bytes --] On Mon, Feb 20, 2012 at 12:58 AM, Nick Dokos <nicholas.dokos@hp.com> wrote: > Not To Miss <not.to.miss@gmail.com> wrote: > > > Thanks, Nick! It works, though it works only to the specified file(s) > > by overruling the original org-store-link-functions. > > Yes, org marches down the link handlers and takes the first positive > response as the answer. You can make the function arbitrarily complicated > of course, if you don't like the behavior, but in any case, it will have > to say "yes" (and provide the link in some format) or "no" - in the latter > case, org will continue on with the rest of the functions in the list (and > fall back to its default if *no* function says "yes"). > > > Ideally, it would > > be great if in the normal stored org link, line number could be > > included in the link and would be ripped off from the text to search > > the linked file. > > > > I'm confused - what exactly are you asking for here? If you don't use > the line number for searching, why would you want to store it? > Because I think sometimes the line number gives valuable information in addition to the text. I meant to create a link like [[file:foo.txt::123 whatever_text]], when users open the link, org-mode searches "whatever_text"; if it doesn't find anything, jump to the line 123. The idea behind that is that it is possible the line is changed and is unsearchable but still remains in the same line number. This, however, is probably an issue of built-in org-mode design, beyond the scope of user customization. Anyway, thanks for your help. > > Nick > > > On Sat, Feb 18, 2012 at 4:58 PM, Nick Dokos <nicholas.dokos@hp.com> > wrote: > > > Nick Dokos <nicholas.dokos@hp.com> wrote: > > > > > >> Not To Miss <not.to.miss@gmail.com> wrote: > > >> > > >> > I looked that section carefully and the whole manual briefly. I > > >> > haven't found anything yet. That's why I am asking on the mailing > list > > >> > to see if anyone has some workaround. > > >> > > > >> > On Sat, Feb 18, 2012 at 9:03 AM, Sean O'Halpin < > sean.ohalpin@gmail.com> wrote: > > >> > > On Fri, Feb 17, 2012 at 4:54 PM, Not To Miss < > not.to.miss@gmail.com> wrote: > > >> > >> Hi all, > > >> > >> > > >> > >> I am reading a long text file and want to write down my notes > with > > >> > >> org-mode. I extremely would like to put the line numbers down > along > > >> > >> with my notes. Although there is a way to store a link for text > search > > >> > >> for the current line, I haven't found a way to create a link to > a line > > >> > >> number in the current buffer. Is there anyway to do that? Thanks > > >> > > > > >> > > Take a look at org-capture: > http://orgmode.org/manual/Capture.html > > >> > > > > > >> The problem is to make sure org-store-link will actually store the > line > > >> number (along with everything else) so that then org-insert-link can > > >> insert the link in the proper format. I don't think there is a > function > > >> to do that out of the box for line numbers, but you can easily (for > some > > >> value of "easily") write your own. Look in > > >> > > >> (info "(org)Adding hyperlink types") > > >> > > >> for some hints. Briefly, you write a function that checks whether it > > >> wants to deal with the link or not, and you add it to > > >> org-store-link-functions. I don't have the time to try it out right > now, > > >> but I believe this should work for what you want. > > >> > > > > > > Following up on this, the following seems to work, although you > probably > > > want to tweak the criterion of when you want *this* function to take > > > care of links - this particular implementation only applies the line > > > number treatment to links generated in the file named > > > "/path/to/the.file.txt" and only that file: > > > > > > --8<---------------cut here---------------start------------->8--- > > > (defun org-file-lineno-store-link() > > > (when (string-equal (buffer-file-name) "/path/to/the.file.txt") > > > (let* ((link (format "file:%s::%d" (buffer-file-name) > (line-number-at-pos)))) > > > (org-store-link-props > > > :type "file" > > > :link link)))) > > > > > > (add-hook 'org-store-link-functions 'org-file-lineno-store-link) > > > --8<---------------cut here---------------end--------------->8--- > > > > > > Nick > > > > > > > > > > > -- > > Best, > > Zhenjiang > > > -- Best, Zhenjiang [-- Attachment #2: Type: text/html, Size: 6326 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: anyway to create link to a line number in a file 2012-02-21 17:16 ` Not To Miss @ 2012-02-21 17:29 ` Nick Dokos 0 siblings, 0 replies; 11+ messages in thread From: Nick Dokos @ 2012-02-21 17:29 UTC (permalink / raw) To: Not To Miss; +Cc: nicholas.dokos, emacs-orgmode Not To Miss <not.to.miss@gmail.com> wrote: > > Ideally, it would > > be great if in the normal stored org link, line number could be > > included in the link and would be ripped off from the text to search > > the linked file. > > > > I'm confused - what exactly are you asking for here? If you don't use > the line number for searching, why would you want to store it? > > Because I think sometimes the line number gives valuable information > in addition to the text. I meant to create a link like > [[file:foo.txt::123 whatever_text]], when users open the link, > org-mode searches "whatever_text"; if it doesn't find anything, jump > to the line 123. The idea behind that is that it is possible the line > is changed and is unsearchable but still remains in the same line > number. I guess the main idea is that it is more likely for the text around the link to remain the same: the line number can change (e.g. if you add stuff at the beginning of the file), but the surrounding text will probably remain the same, so a context search is more likely to find you what you want. But you are right in that a line number can sometimes disambiguate things, e.g. the etags functionality in emacs works (worked? not sure if the implementation is still the same) by using a position to go to and then searching in ever-widening circles around that position in order to find the appropriate context. That way, identical contexts could be used (a necessity for etags) and still be distinguished from each other. > This, however, is probably an issue of built-in org-mode > design, beyond the scope of user customization. > Yup. Nick ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-02-21 17:30 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-02-17 16:54 anyway to create link to a line number in a file Not To Miss 2012-02-18 14:03 ` Sean O'Halpin 2012-02-18 16:31 ` Not To Miss 2012-02-18 17:11 ` Eric Schulte 2012-02-18 17:30 ` Not To Miss 2012-02-18 17:31 ` Nick Dokos 2012-02-18 21:58 ` Nick Dokos 2012-02-20 4:43 ` Not To Miss 2012-02-20 5:58 ` Nick Dokos 2012-02-21 17:16 ` Not To Miss 2012-02-21 17:29 ` Nick Dokos
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).