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

Make helm-org-insert-link-to-heading-at-marker insert id when the selected heading has one #25

Open
rodrigomorales1 opened this issue Jul 5, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rodrigomorales1
Copy link

Given that org-id.el is a native package and some users use this feature for creating a permanent link to a heading, I think it would be useful that helm-org-insert-link-to-heading-at-marker consider the ID property for referencing a selected heading. The current behavior is to use the heading title.

@rodrigomorales1
Copy link
Author

I guess it would be better if there were a defcustom that would allow the user to define whether helm-org-insert-link-to-headint-at-marker use ids or not, so that helm would create the ID in the scenario that the selected heading doesn't have one.

@alphapapa
Copy link
Member

alphapapa commented Jul 5, 2021

I haven't looked at the code in question, but we should probably be using Org's built-in link-creating functions (i.e. org-store-link), which should take the existing option org-id-link-to-org-use-id into account. We probably shouldn't be doing this manually and adding a Helm-specific option.

@rodrigomorales1
Copy link
Author

@alphapapa I agree with you, using org-store-link (your idea) would be better than creating a defcustom (my idea) for this.

For those interested, here's the relevant part of the source code:

The function helm-org-headings-actions contains helm-org-insert-link-to-heading-at-marker.

helm-org/helm-org.el

Lines 98 to 105 in d67186d

(defcustom helm-org-headings-actions
'(("Go to heading" . helm-org-goto-marker)
("Open in indirect buffer `C-c i'" . helm-org--open-heading-in-indirect-buffer)
("Refile heading(s) (marked-to-selected|current-to-selected) `C-c w`" . helm-org--refile-heading-to)
("Insert link to this heading `C-c l`" . helm-org-insert-link-to-heading-at-marker))
"Default actions alist for `helm-source-org-headings-for-files'."
:group 'helm-org
:type '(alist :key-type string :value-type function))

The function helm-org-insert-link-to-heading-at-marker uses org-insert-link.

helm-org/helm-org.el

Lines 376 to 384 in d67186d

(defun helm-org-insert-link-to-heading-at-marker (marker)
"Insert link to heading at MARKER position."
(with-current-buffer (marker-buffer marker)
(let ((heading-name (save-excursion (goto-char (marker-position marker))
(nth 4 (org-heading-components))))
(file-name (buffer-file-name)))
(with-helm-current-buffer
(org-insert-link
file-name (concat "file:" file-name "::*" heading-name))))))

@alphapapa alphapapa added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 5, 2021
@alphapapa
Copy link
Member

Thanks. I don't use this feature, myself, so I'll let someone else propose a patch. Please feel free to tag my username to get my attention on this again; notifications on repos I don't own tend to get lost.

@rodrigomorales1
Copy link
Author

@alphapapa I've created a pull request: #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants