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

Transient menu for EKG #99

Closed
garyo opened this issue Sep 25, 2023 · 2 comments
Closed

Transient menu for EKG #99

garyo opened this issue Sep 25, 2023 · 2 comments

Comments

@garyo
Copy link

garyo commented Sep 25, 2023

Here's a transient menu I created for EKG. I'm still very new to it so not sure about any of the commands or bindings, but for the basics it seems to work for me.

(defun setup-ekg-transients () "Set up Transient menus for EKG"
       (transient-define-prefix ekg-dispatch ()
         "Top level Transient menu for EKG (Emacs Knowledge Graph)"
         [["Show"
           ("st" "Today" ekg-show-notes-for-today)
           ("slc" "Latest Captured" ekg-show-notes-latest-captured)
           ("slm" "Latest Mod" ekg-show-notes-latest-modified)
           ("sx" "Trash" ekg-show-notes-in-trash)
           ("sd" "Drafts" ekg-show-notes-in-drafts)
           "Find Tags"
           ("tt" "Tag" ekg-show-notes-with-tag)
           ("taa" "All Tags" ekg-show-notes-with-all-tags)
           ("ta?" "Any Tag" ekg-show-notes-with-any-tags)
           ]
          ["Capture"
           ("cc" "New Note" ekg-capture)
           ("cu" "...from URL" ekg-capture-url)
           ("cb" "...from current buffer" ekg-capture-file)
           ("ct" "...with tags from buffer" ekg-notes-create)
           ]
          ["Query"
           ("qt" "for terms" ekg-embedding-search)
           ("qs" "similar to current note" ekg-embedding-show-similar)
           ("qb" "similar to current buffer" ekg-embedding-show-similar-to-current-buffer)
           ("qR" "Regenerate embeddings" ekg-embedding-generate-all)
           "AI"
           ("aa" "AI send & append" ekg-llm-send-and-append-note)
           ("ar" "AI send & replace" ekg-llm-send-and-replace-note)
           ("aq" "AI query, all notes" ekg-llm-query-with-notes)
           ]
          ["Misc"
           "Browse"
           ("bb" "Browse to topic" ekg-notes-browse)
           ("bu" "Browse to URL" ekg-browse-url)
           ("bs" "Select & browse to URL" ekg-notes-select-and-browse-url)
           "Other"
           ("gr" "Global rename tag" ekg-global-rename-tag)
           ("cm" "Change mode of current note" ekg-change-mode)
           ("e" "This note ..." ekg-notes-dispatch :if-mode ekg-notes-mode)
           ("q" "Quit this menu" transient-quit-one)
           ]
          ])

       (global-set-key (kbd "<f6>") 'ekg-dispatch)
       (global-set-key (kbd "C-c e") 'ekg-dispatch)

       (transient-define-prefix ekg-notes-dispatch ()
         "Notes buffer Transient menu for EKG (Emacs Knowledge Graph)"
         [["Show Notes"
           ("a" "with any of this note's tags" ekg-notes-any-note-tags)
           ("A" "with any of these notes' tags" ekg-notes-any-tags)
           ("t" "select tag" ekg-notes-tag)
           ("s" "search for similar" ekg-embedding-show-similar)
           ]
          ["Manage"
           ("c" "create" ekg-notes-create)
           ("d" "delete" ekg-notes-delete)
           ("g" "refresh" ekg-notes-refresh)
           ("k" "kill (hide) note" ekg-notes-kill)
           ("Q" "quit EKG" kill-buffer-and-window)
           ("o" "open/edit" ekg-notes-open)
           ("q" "quit this menu" transient-quit-one)
           ]
          ["Browse"
           ("b" "browse resource" ekg-notes-browse)
           ("B" "select & browse" ekg-notes-select-and-browse-url)
           ]
          ])
       (define-key ekg-notes-mode-map (kbd "e") 'ekg-notes-dispatch)
       (define-key ekg-notes-mode-map (kbd "?") 'ekg-notes-dispatch) ; help when I'm confused
       (define-key ekg-notes-mode-map (kbd "q") 'kill-buffer-and-window) ; I prefer this
       )

Invoke this after ekg is loaded (e.g. in the :config section of use-package). You can see I set up ? in the notes mode to bring up a notes-related transient menu, and the main one (which I bind to C-c e and <f6>) has what I took to be the main global ekg commands.

Here's what the main one looks like for me:
image

Feel free to include this in ekg; I put this code in the public domain.

@ahyatt
Copy link
Owner

ahyatt commented Sep 25, 2023

That's super nice, I'll have to try it out! Be aware that you are mixing commands which are done on notes only, with global commands.

Package like ekg generally don't try to integrate out of the box with packages like transient, but rely on users hook these things together. In that spirit, thank you for sharing your code so that people can put it in their own configs!

@ahyatt
Copy link
Owner

ahyatt commented Sep 25, 2023

I just realized this is an issue, so I'm going to close it - but I'd recommend you add your code to the discussion or Wiki (which I think has been unused so far).

@ahyatt ahyatt closed this as completed Sep 25, 2023
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

2 participants