Michael Hoffman
Michael Hoffman

Reputation: 34364

How can I make a singleton bookmark in my org file?

I have an org-mode task list that I keep in version control. I would like to press a key and turn the current position into a bookmark target that I will be able to access anywhere I have the list checked out, regardless of other changes that have been made to the document. This is why (bookmark-set) will not work.

Additionally I would like to ensure that this target only occurs once in the file. If I put the target at a different position I want the original target to go away.

Essentially, I want to combine features of Emacs bookmarks (the singleton aspect), and org-mode links (more robust persistence). What's the best way to do this?

Upvotes: 1

Views: 305

Answers (2)

Michael Hoffman
Michael Hoffman

Reputation: 34364

The best solution I've been able to come up with is to use the text <<<BOOKMARK>>>, and to search for it when necessary. At some point I might write some functions that place this bookmark and delete it from elsewhere.

Upvotes: 0

phils
phils

Reputation: 73344

You want to read up about Markers:

M-: (info "(elisp) Markers") RET

This feature is what allows the mark ring to retain its relative locations regardless of buffer changes, for example.

If you want the marker to be stored within the file itself, then you might want to include it as a local variable in the file itself, and use before-save-hook to update that to the current value.

The local variable may need to be an integer, in which case you would need to translate it on loading and saving.

(This is a little speculative, but I suspect it will do the trick.)

Upvotes: 1

Related Questions