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

embark integration with consult-notes-org-headings-mode #48

Open
fhansen42 opened this issue Sep 21, 2023 · 9 comments
Open

embark integration with consult-notes-org-headings-mode #48

fhansen42 opened this issue Sep 21, 2023 · 9 comments

Comments

@fhansen42
Copy link

consult-notes-org-headings-mode is great. It's allowed me to replace consult-org-agenda with consult-notes and get a combined interface for selecting org headings and file names. One items that is missing, however, is identification of the org heading as an org-heading target within embark. Currently it is identified as a consult-note target after calling embark-act.

FYI to @oantolin and @minad in case either of them would like to offer any ideas on how to fix this.

@oantolin
Copy link
Contributor

oantolin commented Sep 21, 2023

The text properrty with the marker should be called org-marker (rather than consult--candidate as it is currently) and the completion category should be org-heading (rather than consult-notes-category as it is currently). So it's a simple two-symbol change.

Also users can do this on their own without any changes to this library:

(defun refine-consult-notes (_type target)
  (when-let ((marker (get-text-property 0 'consult--candidate target))
             ((markerp marker)))
    (cons 'org-heading (propertize target 'org-marker marker))))

(add-to-list 'embark-transformer-alist '(consult-notes-category . refine-consult-notes))

@oantolin
Copy link
Contributor

Currently it is identified as a consult-note target after calling embark-act.

Isn't it identified as a consult-notes-category target? (This is why I wouldn't end a category name in the word category.)

@minad
Copy link

minad commented Sep 22, 2023

@oantolin There seems to be a consult-notes-category defcustom with a value consult-note.

@oantolin
Copy link
Contributor

Oh, I read very quickly and thought that symbol was quoted, @minad. Thanks for the correction.

@mclearc
Copy link
Contributor

mclearc commented Sep 22, 2023

@fhansen42 is the solution offered by @oantolin enough? I could just put that in the readme.

@fhansen42
Copy link
Author

fhansen42 commented Sep 22, 2023

@fhansen42 is the solution offered by @oantolin enough? I could just put that in the readme.

I've added the code provided by @oantolin to my .init file. I don't see any change in the behavior of embark-act called on a heading in consult-notes. I've just appended to the bottom of my .init. I'm not sure if it makes a difference where it is placed?

@mclearc
Copy link
Contributor

mclearc commented Sep 22, 2023

Yeah I'm not seeing a difference either. I'll look into this soon, when I have some more time.

@oantolin
Copy link
Contributor

Oh, I'm sorry, that code won't work. consult-notes uses consult--multi internally, right? The embark support for consult--multi already uses embark-transformer-alist and Embark only does one round of transformation.

@oantolin
Copy link
Contributor

It's funny but if you use (setq consult-notes-category 'org-heading) then Embark actions work because of a coincidence: the marker is still in the text property consult--candidate so embark-org doesn't find it (it expects the marker to be stored in the text property org-marker), and thus embark-org doesn't jump to the heading before running the action, but thanks to consult-notes's preview point is already at the heading and the lack of a jump doesn't matter!

Now, if you collected some consult-notes candidates, then Embark actions wouldn't work from the embark collect buffer.

So I stand by my original recommendation: store the marker in org-marker rather than consult--candidate (or in both places if you need to) and set consult-notes-category to org-heading (maybe that should only be set in consult-notes-org-heading-mode; I'm not familiar with what this package does in any other mode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants