I am using org-mode
in Emacs
to document my development activities. One of the tasks which I must continuously do by hand is to describe areas of code. Emacs
has a very nice Bookmark List: create a bookmark with CTRL-x r m, list them with CTRL-x r l. This is very useful, but is not quite what I need.
Org-mode has the concept of link, and the command org-store-link
will record a link to the current position in any file, which can be pasted to the org-file. The problem with this is two-fold:
file/search
, which is not what I want.I need to have the bookmark in textual form, so that I can copy paste it into org-mode, end edit it if needed, with a simple format like this:
absolute-file-path:line
And this must be obtained from the current point position. The workflow would be as simple as:
position-to-kill-ring
(I would bind this to a keyboard shortcut)org-mode
buffer.Unfortunately my lisp
is non-existent, so I do not know how to do this. Is there a simple solution to my problem?
From an Org buffer, the following commands create, navigate or, more generally, act on links. Insert a link30. This prompts for a link to be inserted into the buffer. You can just type a link, using text for an internal link, or one of the link type prefixes mentioned in the examples above.
Emacs has included Org Mode as a major mode by default since 2006.
Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores.
org-capture is a way to take notes in Emacs in an unobstructive way. It allows you to open a buffer to enter a note and it'll store it in the correct place based on the type of note you've selected. I must say that I took the term note from it's documentation, but I think that it's a very loose definition of the word.
(defun position-to-kill-ring ()
"Copy to the kill ring a string in the format \"file-name:line-number\"
for the current buffer's file name, and the line number at point."
(interactive)
(kill-new
(format "%s:%d" (buffer-file-name) (save-restriction
(widen) (line-number-at-pos)))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With