Not sure I understand your question/request.
But:
- Bookmarks need not have any destination at all. They need not go anywhere. They can do anything.
- Bookmarks can have destinations that are unrelated to files or locations in files.
As for destinations are are in files, bookmarks can (and by default do) take you to a particular position in a file. And the position reached isn't necessarily the exact position recorded in the bookmark: the surrounding context (text before and after) is also recorded, and if the recorded position no longer matches the recorded context then the destination searches for the context and takes you to the (moved) position. You can optionally have the recorded position updated to that new location.
What if the destination code is moved to a different file altogether? In that case, the context isn't found in the recorded file, and when you jump to the bookmark Emacs asks to tell it where the new, proper destination is. After you tell it, it takes you there, and optionally updates the recorded file.
All of that is true of even vanilla Emacs, as well as Bookmark+. The automatic relocation is a bit better with Bookmark+, and Bookmark+ also lets you bookmark a region (text selection), not just a position - which means that there are two recorded contexts, one for the region start and one for the region end.
On the other hand, from your example, maybe you're asking whether you can set a bookmark at a given location in file1.el
and have the action of the bookmark take you to a particular location in file2.el
.
The answer to that is yes. You just have to decide what the logic is behind the bookmark behavior. As I said above, a bookmark can do anything.
E.g., you can define a bookmark-setting command that prompts you for the destination location (e.g., a position in file2.el
), and records that in the bookmark's action function. This could be dependent on the starting file (e.g. file1.el
) or independent of it (jumps to the file2.el
location from anywhere else).
Specify the exact behavior you want, then define yourself a command that sets the bookmark you need for that behavior. If you have specific questions about doing that, you can post them here (one question per post, please).
bookmark.el
, notbookmarks.el
?