Closed akirak closed 3 years ago
Hi Akira,
Thanks, this looks useful. Would you mind giving me an example of what format you want to use in your config? Maybe we should provide a few choices in addition to a custom function.
I'll post a few comments in a review.
Thank you for the code review. I have resolved the issues in your comments.
Would you mind giving me an example of what format you want to use in your config?
I have this experimental configuration now:
(use-package org-bookmark-heading
:after org
:custom
(org-bookmark-heading-filename-fn
(defun akirak/org-bookmark-heading-filename (path)
(let* ((path (expand-file-name path))
(project (project-current))
(dir (abbreviate-file-name (file-name-directory path)))
(filename (file-name-nondirectory path))
(root (car-safe (project-roots project))))
(if root
(f-relative path (f-parent root))
path))))
(org-bookmark-heading-name-fn
(defun akirak/org-bookmark-heading (path heading)
(let ((ancestors (org-get-outline-path)))
(format "\"%s\" in %s%s"
(substring-no-properties
(org-link-display-format heading))
(akirak/org-bookmark-heading-filename path)
(if ancestors
(substring-no-properties
(concat ":" (org-format-outline-path
(mapcar #'org-link-display-format ancestors)
nil nil "/")))
""))))))
It consists of the heading of the entry, the file path of the file (which actually starts from the project root), and the outline path to the entry in the file, in that order. An example bookmark name produced by this function is as follows:
"Emacs packages" in notes/aux.org:Open source projects
I made this because some of my files contains multiple entries on the same subjects in different contexts, e.g. trying out Emacs packages and contributing to them. Apparently, bookmark names should contain outline paths, but since they tend to be long, I want to put them at the end, after the file name. I'm pretty sure I tend to complicate things and mess up, but I think it's useful in seeking out opportunities for pushing the limits.
Hi Akira,
Sorry for overlooking this PR (I'm going through a list of old ones in chronological order). Are you still interested in pursuing this change?
Thanks.
Are you still interested in pursuing this change?
Maybe no. I rely more on Org links than on Org bookmarks. This package is still sometimes useful, and it should be a built-in feature, but I don't care much about the default bookmark name.
Ok, since I'm satisfied with the existing behavior, I'll leave this PR closed. If you or anyone else is interested in it in the future, feel free to comment and we can reopen it.
Hi, I wanted to customize the entire default name format, so I have added a new customizable variable.