Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Bookmarking end-of-file in an org document #22

Open
jmay opened this issue Dec 9, 2022 · 9 comments · May be fixed by #23
Open

Feature Request: Bookmarking end-of-file in an org document #22

jmay opened this issue Dec 9, 2022 · 9 comments · May be fixed by #23
Assignees
Milestone

Comments

@jmay
Copy link

jmay commented Dec 9, 2022

I would like to be able to save a bookmark to an org file that points to the end of the file, not to any heading in it. This isn't really org-specific, but I only have use cases that involve org files. Since org-bookmark-heading remaps the the bookmark-make-record-function in any org-mode buffer, this feature should either be in this package or there should be a fallback-to-default-bookmark handler (and therefore a way to decide whether to fallback, and have the feature in the built-in bookmark function, which adds complexity in both places).

Since this might not be of interest to everyone, there would need to be a switch to toggle this feature.

My proposal is to recognize that point is at end of buffer and record a specific type of org bookmark in that case. Could overload the existing id or outline-path fields for this or have a different attribute. org-bookmark-heading-jump would then recognize the EOB marker and jump directly to (end-of-buffer).

Would this be useful to other people?

@alphapapa
Copy link
Owner

Hi Jason,

Sure, this seems like it could be useful. I'd suggest that such a record record an additional end-of-buffer alist key, and the jumping function should do what's necessary when it's there. I doubt that additional configuration is needed; just documenting the behavior and attempting to DWIM/DTRT should be enough.

Note as well that this probably needs to be handled in indirect, narrowed buffers too.

What do you think? Thanks.

@jmay
Copy link
Author

jmay commented Dec 10, 2022

I haven't experimented with indirect or narrowed buffers. How would those work differently from a regular org buffer? My idea was to evaluate (eq (point) (point-max)) to decide whether the bookmark is for EOB. Maybe that check should be disabled for indirect/narrowed.

@jmay
Copy link
Author

jmay commented Dec 10, 2022

I can't think of a reason for recording start-of-buffer or any other special positions, but maybe using a position alist key with a value that could potentially refer to something other than eob.

@akirak
Copy link
Contributor

akirak commented Dec 10, 2022

This isn't really org-specific

@jmay If it's not specific to Org, I think the feature should not be confined to this package. I think you can define a new bookmark backend and use its bookmark-store function explicitly to create a bookmark that jumps to the end of your file. Is there anything I am missing?

jmay added a commit to jmay/org-bookmark-heading that referenced this issue Dec 11, 2022
@jmay
Copy link
Author

jmay commented Dec 12, 2022

@akirak As far as I can tell, there's only one "slot" for injecting a new bookmark backend. I'd like to be able to inject an alternative flow that only operates when point is at EOB but does not disturb any other backend, mode-specific or otherwise.

I made changes in the commit above that enhances org-bookmark-heading with EOB-specific behavior. Feedback appreciated. Is this worth submitting as a PR? Probably there should be a switch to make this optional.

@akirak
Copy link
Contributor

akirak commented Dec 13, 2022

@jmay I have never had a situation where I want to bookmark the end of a file. That's not my current workflow. I may mistakenly bookmark the end of a file when I just want to bookmark a heading. Thus I want the functionality to be opt-in.

Otherwise, I don't have any opinion on how it should be implemented. I think it's a trade-off between usefulness vs. additional complexity. It would be possible to implement your idea as a function advice without tweaking this package.

@jmay
Copy link
Author

jmay commented Dec 13, 2022

@akirak Thanks for the input. I've added a configuration setting (defaulting to OFF) for the proposed EOB marking. Latest revision is jmay@4ee2240

@akirak
Copy link
Contributor

akirak commented Dec 14, 2022

@jmay This is not my project, so @alphapapa may review your PR, if he is interested in it.

@alphapapa
Copy link
Owner

Actually, I can imagine wanting to bookmark the end of an Org file, e.g. if one always appends to the end of a file, and so the last heading won't be the same one each time one visits (like with a datetree).

So I think we could add a special case for when point is at end-of-buffer, and maybe prompt the user whether to bookmark EOB or that heading.

@alphapapa alphapapa self-assigned this Dec 16, 2023
@alphapapa alphapapa added this to the 1.4 milestone Dec 16, 2023
@alphapapa alphapapa linked a pull request Dec 16, 2023 that will close this issue
jmay added a commit to jmay/org-bookmark-heading that referenced this issue Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants