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

Using xdg-open on a note #714

Closed
iago-pssjd opened this issue Apr 5, 2024 · 8 comments
Closed

Using xdg-open on a note #714

iago-pssjd opened this issue Apr 5, 2024 · 8 comments

Comments

@iago-pssjd
Copy link

iago-pssjd commented Apr 5, 2024

Is it possible to use xdg-open on a note after M-x consult-notes through embark? I am trying:

  1. M-x consult-notes
  2. Select note of interest
  3. C-.
  4. M-&
  5. xdg-open
    As in 'Run a shell command on a minibuffer candidate file without losing your session' (https://karthinks.com/software/fifteen-ways-to-use-embark/)
    Not success because it is applied to something it is not the file name.

or
4. E (embark-export)
5. Select note of interest again and
6. M-x embark-select
7. a (embark-act)
8. ! (like in dired-mode to apply shell commands)
but ! is unefined

Related:

@oantolin
Copy link
Owner

oantolin commented Apr 6, 2024

I'm sorry, but I'm not familiar with consult-notes. I'm guessing its completion candidates are not files, if the procedure you described doesn't work. You might be able to write an embark candidate transformer that converts the candidates to files but doing so will probably require some knowledge of how consult-notes is implemented.

@iago-pssjd
Copy link
Author

Thanks for the answer!

@hmelman
Copy link

hmelman commented Apr 6, 2024

It's a nice package based on some code I put in the consult wiki. I still run my version and this is how I support embark:

(defun hrm-notes-grep (cand)
  "Run consult-ripgrep in directory of notes file CAND."
  (interactive "fNote: ")
  (consult-ripgrep (file-name-directory cand)))

(defvar-keymap hrm-notes-map
  :doc "Keymap for Embark notes actions."
  :parent embark-file-map
  "g" #'hrm-notes-grep)

(with-eval-after-load 'embark
  (add-to-list 'embark-keymap-alist `(,hrm-notes-category hrm-notes-map))
  ;; make embark-export use dired for notes
  (setf (alist-get hrm-notes-category embark-exporters-alist) #'embark-export-dired))

It's the last few lines you need to tell embark about the notes category, you'll want to change hrm-notes-category to consult-notes-category. Note that the keymap sets the embark-file-map to be the parent.

I suppose an alternative would be to set consult-notes-category to be file though I didn't test it.

@oantolin
Copy link
Owner

oantolin commented Apr 6, 2024

Thanks, @hmelman!

@iago-pssjd
Copy link
Author

Thanks for the help @hmelman

If I include that code in my .init I switch hrm-notes-category with consult-notes-category and I open emacs I get Symbol's value as variable is void: embark-file-map.

@oantolin
Copy link
Owner

oantolin commented Apr 6, 2024

Right, because Embark hasn't been loaded yet. You should move the code that uses embark-file-map into the(with-eval-after-load 'embark ...) form.

@iago-pssjd
Copy link
Author

iago-pssjd commented Apr 6, 2024

Thanks @oantolin too. Previous issue solved. Now, @hmelman , if I try

  1. M-x consult-notes
  2. Select note of interest
  3. C-.
    It appears an option which is
    x embark-open-externally Open file or URL using system's default applitacion
    I try it then:
  4. x
    But I get
embark PCH: (wrong-type-argument window-valid-p #<window 25>

Similar end if I try instead
! shell-command Execute string COMMAND in inferior shell

@oantolin
Copy link
Owner

oantolin commented Apr 6, 2024

Try reproducing that problem starting from emacs -Q and loading only embark, consult-notes and the above configuration. If the problem occurs then, maybe you can give me instructions to reproduce it and I might be able to install consult-notes and investigate.

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

3 participants