added navigation standard hydra and tested on elpy
This commit is contained in:
parent
22cfdd28c6
commit
1304fd71b7
97
conf.org
97
conf.org
|
@ -3053,6 +3053,9 @@ Everyone forgets keybindings. When typing a key chord, this will display a windo
|
|||
(:send-group "g")
|
||||
(:send-group-step "G" :exit nil)
|
||||
(:send-group-follow "C-g")
|
||||
(:send-region "r")
|
||||
(:send-region-step "R" :exit nil)
|
||||
(:send-region-follow "C-r")
|
||||
(:send-buffer "b")
|
||||
(:send-buffer-follow "C-b")
|
||||
(:shell-start "z")
|
||||
|
@ -3061,8 +3064,23 @@ Everyone forgets keybindings. When typing a key chord, this will display a windo
|
|||
(:shell-kill-all "K"))
|
||||
"Standard hydra keymap for interactive REPL workflow.")
|
||||
|
||||
(defvar nd/hydra-standard-navigation-map
|
||||
'(("M-n" :exit t)
|
||||
(:def-at "M-n")
|
||||
(:def-at-new-win "N")
|
||||
(:asgn-at "a")
|
||||
(:asgn-at-new-win "A")
|
||||
(:ref-at "r")
|
||||
(:ref-at-new-win "R")
|
||||
(:pop-marker-stack "b")
|
||||
(:doc-at "d")
|
||||
(:doc-at-new-win "D")
|
||||
(:type-at "t")
|
||||
(:type-at-new-win "T"))
|
||||
"Standard hydra keymap for navigation and information workflow.")
|
||||
|
||||
(defmacro nd/hydra-standard (hydra-map suffix keymap &rest cmds)
|
||||
"Docstring"
|
||||
"Create a standardized hydra keymap."
|
||||
(unless (s-match "-mode-map" (symbol-name keymap))
|
||||
(error "Not a valid keymap: %s" keymap))
|
||||
(let* ((hydra-name (--> keymap
|
||||
|
@ -3084,37 +3102,28 @@ Everyone forgets keybindings. When typing a key chord, this will display a windo
|
|||
`(defhydra ,hydra-name ,body ,docstring ,@heads)))
|
||||
|
||||
(defmacro nd/hydra-standard-int (keymap &rest cmds)
|
||||
"Docstring"
|
||||
"Create a standardized interactive REPL hydra keymap.
|
||||
|
||||
KEYMAP is the keymap to which the hydra should be added and CMDS are
|
||||
cons cells like (':kw' . 'command') where 'command is an interactive
|
||||
command that corresponds to ':kw'.
|
||||
|
||||
See `nd/hydra-standard-interactive-map' which keywords are valid along
|
||||
with their corresponding body/head hydra keys."
|
||||
`(nd/hydra-standard ,nd/hydra-standard-interactive-map "int"
|
||||
,keymap ,@cmds))
|
||||
|
||||
;; ;; TODO this can be generalized
|
||||
;; (defmacro nd/hydra-standard-int (name map docstring &rest keys)
|
||||
;; "Create a standardized hydra map for process interaction."
|
||||
;; ;; TODO this should be outside with a docstring so it is easy to look up
|
||||
;; (let* ((nav-key-alist
|
||||
;; '((:send-line "M-i")
|
||||
;; (:send-line-step "I" :exit nil)
|
||||
;; (:send-line-follow "C-i")
|
||||
;; (:send-group "g")
|
||||
;; (:send-group-step "G" :exit nil)
|
||||
;; (:send-group-follow "C-g")
|
||||
;; (:send-buffer "b")
|
||||
;; (:send-buffer-follow "C-b")
|
||||
;; (:shell-start "z")
|
||||
;; (:shell-start-follow "C-z")
|
||||
;; (:shell-kill "k")
|
||||
;; (:shell-kill-all "K")))
|
||||
;; ;; TODO warning if a keyword is wrong
|
||||
;; (set-keys
|
||||
;; (--map (-when-let (key (alist-get (car it) nav-key-alist))
|
||||
;; (append (list (car key)) (cdr it) (cdr key)))
|
||||
;; keys)))
|
||||
;; ;; TODO get the previous binding for the command and unset it
|
||||
;; ;; (--> set-keys
|
||||
;; ;; (-map #'car it)
|
||||
;; ;; (--each it (define-key (eval map) (kbd it) nil)))
|
||||
;; `(defhydra ,name (,map "M-i" :exit t) ,docstring ,@set-keys)))
|
||||
(defmacro nd/hydra-standard-nav (keymap &rest cmds)
|
||||
"Create a standardized navigation hydra keymap.
|
||||
|
||||
KEYMAP is the keymap to which the hydra should be added and CMDS are
|
||||
cons cells like (':kw' . 'command') where 'command is an interactive
|
||||
command that corresponds to ':kw'.
|
||||
|
||||
See `nd/hydra-standard-navigation-map' which keywords are valid along
|
||||
with their corresponding body/head hydra keys."
|
||||
`(nd/hydra-standard ,nd/hydra-standard-navigation-map "nav"
|
||||
,keymap ,@cmds))
|
||||
#+END_SRC
|
||||
** evil
|
||||
I like being evil. All package and custom bindings go here.
|
||||
|
@ -3572,19 +3581,29 @@ The only thing I like about elpy is the interactive shell
|
|||
(:shell-kill elpy-shell-kill)
|
||||
(:shell-kill-all elpy-shell-kill-all))
|
||||
|
||||
(defhydra hydra-nav (python-mode-map "M-n" :exit t)
|
||||
"python query commands"
|
||||
("M-n" anaconda-mode-find-definitions)
|
||||
("N" anaconda-mode-find-definitions-other-window)
|
||||
(nd/hydra-standard-nav python-mode-map
|
||||
(:def-at . anaconda-mode-find-definitions)
|
||||
(:def-at-new-win . anaconda-mode-find-definitions-other-window)
|
||||
(:asgn-at . anaconda-mode-find-assignments)
|
||||
(:asgn-at-new-win . anaconda-mode-find-assignments-other-window)
|
||||
(:ref-at . anaconda-mode-find-references)
|
||||
(:ref-at-new-win . anaconda-mode-find-references-other-window)
|
||||
(:pop-marker-stack . xref-pop-marker-stack)
|
||||
(:doc-at . anaconda-mode-show-doc))
|
||||
|
||||
("a" anaconda-mode-find-assignments)
|
||||
("A" anaconda-mode-find-assignments-other-window)
|
||||
;; (defhydra hydra-nav (python-mode-map "M-n" :exit t)
|
||||
;; "python query commands"
|
||||
;; ("M-n" anaconda-mode-find-definitions)
|
||||
;; ("N" anaconda-mode-find-definitions-other-window)
|
||||
|
||||
("r" anaconda-mode-find-references)
|
||||
("R" anaconda-mode-find-references-other-window)
|
||||
;; ("a" anaconda-mode-find-assignments)
|
||||
;; ("A" anaconda-mode-find-assignments-other-window)
|
||||
|
||||
("b" xref-pop-marker-stack)
|
||||
("?" anaconda-mode-show-doc))
|
||||
;; ("r" anaconda-mode-find-references)
|
||||
;; ("R" anaconda-mode-find-references-other-window)
|
||||
|
||||
;; ("b" xref-pop-marker-stack)
|
||||
;; ("?" anaconda-mode-show-doc))
|
||||
#+END_SRC
|
||||
*** haskell
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
|
Loading…
Reference in New Issue