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 "g")
|
||||||
(:send-group-step "G" :exit nil)
|
(:send-group-step "G" :exit nil)
|
||||||
(:send-group-follow "C-g")
|
(:send-group-follow "C-g")
|
||||||
|
(:send-region "r")
|
||||||
|
(:send-region-step "R" :exit nil)
|
||||||
|
(:send-region-follow "C-r")
|
||||||
(:send-buffer "b")
|
(:send-buffer "b")
|
||||||
(:send-buffer-follow "C-b")
|
(:send-buffer-follow "C-b")
|
||||||
(:shell-start "z")
|
(:shell-start "z")
|
||||||
|
@ -3061,8 +3064,23 @@ Everyone forgets keybindings. When typing a key chord, this will display a windo
|
||||||
(:shell-kill-all "K"))
|
(:shell-kill-all "K"))
|
||||||
"Standard hydra keymap for interactive REPL workflow.")
|
"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)
|
(defmacro nd/hydra-standard (hydra-map suffix keymap &rest cmds)
|
||||||
"Docstring"
|
"Create a standardized hydra keymap."
|
||||||
(unless (s-match "-mode-map" (symbol-name keymap))
|
(unless (s-match "-mode-map" (symbol-name keymap))
|
||||||
(error "Not a valid keymap: %s" keymap))
|
(error "Not a valid keymap: %s" keymap))
|
||||||
(let* ((hydra-name (--> 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)))
|
`(defhydra ,hydra-name ,body ,docstring ,@heads)))
|
||||||
|
|
||||||
(defmacro nd/hydra-standard-int (keymap &rest cmds)
|
(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"
|
`(nd/hydra-standard ,nd/hydra-standard-interactive-map "int"
|
||||||
,keymap ,@cmds))
|
,keymap ,@cmds))
|
||||||
|
|
||||||
;; ;; TODO this can be generalized
|
(defmacro nd/hydra-standard-nav (keymap &rest cmds)
|
||||||
;; (defmacro nd/hydra-standard-int (name map docstring &rest keys)
|
"Create a standardized navigation hydra keymap.
|
||||||
;; "Create a standardized hydra map for process interaction."
|
|
||||||
;; ;; TODO this should be outside with a docstring so it is easy to look up
|
KEYMAP is the keymap to which the hydra should be added and CMDS are
|
||||||
;; (let* ((nav-key-alist
|
cons cells like (':kw' . 'command') where 'command is an interactive
|
||||||
;; '((:send-line "M-i")
|
command that corresponds to ':kw'.
|
||||||
;; (:send-line-step "I" :exit nil)
|
|
||||||
;; (:send-line-follow "C-i")
|
See `nd/hydra-standard-navigation-map' which keywords are valid along
|
||||||
;; (:send-group "g")
|
with their corresponding body/head hydra keys."
|
||||||
;; (:send-group-step "G" :exit nil)
|
`(nd/hydra-standard ,nd/hydra-standard-navigation-map "nav"
|
||||||
;; (:send-group-follow "C-g")
|
,keymap ,@cmds))
|
||||||
;; (: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)))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** evil
|
** evil
|
||||||
I like being evil. All package and custom bindings go here.
|
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 elpy-shell-kill)
|
||||||
(:shell-kill-all elpy-shell-kill-all))
|
(:shell-kill-all elpy-shell-kill-all))
|
||||||
|
|
||||||
(defhydra hydra-nav (python-mode-map "M-n" :exit t)
|
(nd/hydra-standard-nav python-mode-map
|
||||||
"python query commands"
|
(:def-at . anaconda-mode-find-definitions)
|
||||||
("M-n" anaconda-mode-find-definitions)
|
(:def-at-new-win . anaconda-mode-find-definitions-other-window)
|
||||||
("N" 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)
|
;; (defhydra hydra-nav (python-mode-map "M-n" :exit t)
|
||||||
("A" anaconda-mode-find-assignments-other-window)
|
;; "python query commands"
|
||||||
|
;; ("M-n" anaconda-mode-find-definitions)
|
||||||
|
;; ("N" anaconda-mode-find-definitions-other-window)
|
||||||
|
|
||||||
("r" anaconda-mode-find-references)
|
;; ("a" anaconda-mode-find-assignments)
|
||||||
("R" anaconda-mode-find-references-other-window)
|
;; ("A" anaconda-mode-find-assignments-other-window)
|
||||||
|
|
||||||
("b" xref-pop-marker-stack)
|
;; ("r" anaconda-mode-find-references)
|
||||||
("?" anaconda-mode-show-doc))
|
;; ("R" anaconda-mode-find-references-other-window)
|
||||||
|
|
||||||
|
;; ("b" xref-pop-marker-stack)
|
||||||
|
;; ("?" anaconda-mode-show-doc))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** haskell
|
*** haskell
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
|
Loading…
Reference in New Issue