delve icon indicating copy to clipboard operation
delve copied to clipboard

Integrate keybindings for delve v2 with evil or doom

Open publicimageltd opened this issue 5 years ago • 9 comments

This is an issue thread to add evil keybindings to delve. There has been one proposal yet; if there are any other suggestions or improvements, feel free to post them here. Eventually, I will include the most approved and affirmed solution into the source code. I don't use evil, and I am not really willing to install it and to learn to use it, so please help me to do this "blindly"!

publicimageltd avatar Nov 14 '20 09:11 publicimageltd

Here's a doom-specific solution posted by @oatmealm:

(use-package! delve
  :bind (("<f12>" . delve-open-or-select))
  :config
  (set-evil-initial-state! 'delve-mode 'insert)
  (map! :map delve-mode-map
        :n "gr"      #'delve-refresh-buffer
        :n "<right>" #'delve-expand-insert-tolinks
        :n "<left>"  #'devle-expand-insert-backlinks
        :localleader
        "RET"  #'lister-key-action
        "TAB"  #'delve-expand-toggle-sublist)
  (use-package! delve-minor-mode
    :hook (org-roam-mode . delve-minor-mode-maybe-activate)))

publicimageltd avatar Nov 14 '20 09:11 publicimageltd

Mind you this is a doom specific code. I think the right way to go would be to add a snippet via the evil-collection package, which is more generic and also supported in doom via the evil-everywhere flag. I've looked at evil-collection once to get an idea, and it seems straight forward enough. I'll see if I can find the time to create a snippet and send them pull request.

oatmealm avatar Nov 14 '20 20:11 oatmealm

I don't even know the difference between evil and doom that's all greek to me :-) So yes, a more generic solution would be preferable, of course, take your time!

publicimageltd avatar Nov 15 '20 10:11 publicimageltd

more generic until evil-collection.

(evil-define-key* '(normal insert) delve-mode-map
  (kbd "<return>") #'lister-key-action
  (kbd "<tab>") #'delve-expand-toggle-sublist
  (kbd "gr") #'delve-revert
  (kbd "sm") #'delve-sort-buffer-by-mtime
  (kbd "sa") #'delve-sort-buffer-by-atime
  (kbd "sc") #'delve-sort-buffer-by-ctime
  (kbd "<right>") #'delve-expand-insert-tolinks
  (kbd "<left>")  #'delve-expand-insert-backlinks
  (kbd "c") #'delve-collect
  (kbd "q") #'delve-kill-buffer)

natask avatar Mar 10 '21 00:03 natask

@natask thanks for the snippet! Out of curiosity, you seem to have added a function to sort the buffer contents by {m/a/c}-time. Would you mind sharing it or even add a PR? Seems like a useful extension, didn't think of it.

publicimageltd avatar Mar 10 '21 06:03 publicimageltd

@publicimageltd sure. A couple points, ctime isn't supported officially. I have changed the ui to display all three times which clutters the ui but I don't mind. Also sorting doesn't preserve sublists. It maybe possible by using lister-get-all-tree and -treemap but I haven't gotten around to doing that. Feel free to only take stuff you think will be useful for this repo.

(defun delve-sort-buffer-function (buf function)
  "sort all items in BUF by FUNCTION."
  (when-let* ((all-data (lister-get-all-data buf))
              (head (car all-data))
              (tail (cdr all-data)))
    (lister-with-locked-cursor buf
      (with-temp-message "Updating the whole buffer, that might take some time...."
	(lister-set-list buf (cons head (funcall function  tail)))))))

natask avatar Mar 10 '21 09:03 natask

Closed since this discussion refers to an outdated version

publicimageltd avatar Nov 03 '21 07:11 publicimageltd

I would also really like some more doom/evil specific integration, as currently I need to set this up myself (haven't taken the time do so, atm just using M-x delve--key--insert-node like a caveman haha).

I will try to find a decent set of keybindings and make PR!

tefkah avatar Nov 14 '21 18:11 tefkah

I would love to find an abstract way to do this. Maybe the doom map could just remap the original bindings?

publicimageltd avatar Nov 14 '21 19:11 publicimageltd