Fix/Cleanup many of the keybindings
Creating multiple general leader keys per mode, doesn't work. Instead, I need to re-use the _local leader_ but add the keymap during the definition.
This commit is contained in:
parent
e1eb3b85e3
commit
882cf0dba7
14 changed files with 70 additions and 174 deletions
|
@ -44,10 +44,7 @@ Glad to see the 2FA feature is working on the [[https://codeberg.org/martianh/ma
|
|||
:straight (:host codeberg :repo "martianh/mastodon.el")
|
||||
:init
|
||||
(setq mastodon-instance-url "https://emacs.ch"
|
||||
mastodon-active-user "howard")
|
||||
:bind
|
||||
(:map mastodon-mode-map
|
||||
("g" . mastodon-tl--update)))
|
||||
mastodon-active-user "howard"))
|
||||
#+end_src
|
||||
|
||||
I would like a dedicate perspective to Mastodon, and I would like a leader key sequence that /expands/ will all options, once Mastodon is running in its own perspective:
|
||||
|
@ -60,17 +57,20 @@ I would like a dedicate perspective to Mastodon, and I would like a leader key s
|
|||
(persp-names) "mastodon" 'equal)))
|
||||
(persp-switch "mastodon")
|
||||
(unless already-tooted?
|
||||
(ha-leader
|
||||
"a m t" '("toot" . mastodon-toot)
|
||||
"a m u" '("update" . mastodon-tl--update)
|
||||
"a m f" '("favorite" . mastodon-toot--toggle-favourite)
|
||||
"a m b" '("boost" . mastodon-toot--toggle-boost)
|
||||
"a m d" '("discover" . mastodon-discover))
|
||||
(ha-local-leader :keymaps 'mastodon-mode-map
|
||||
;; "," '("thread" . mastodon-tl--thread)
|
||||
"t" '("toot" . mastodon-toot)
|
||||
"u" '("update" . mastodon-tl--update)
|
||||
"f" '("favorite" . mastodon-toot--toggle-favourite)
|
||||
"b" '("boost" . mastodon-toot--toggle-boost)
|
||||
"r" '("reply" . mastodon-toot--reply)
|
||||
"s" '("share" . mastodon-toot--copy-toot-url)
|
||||
"y" '("copy text" . mastodon-toot--copy-toot-text)
|
||||
"d" '("discover" . mastodon-discover))
|
||||
(my-mastodon-start))))
|
||||
|
||||
(ha-leader
|
||||
"a m" '(:ignore t :which-key "mastodon")
|
||||
"a m m" '("perspective" . mastodon-perspective)))
|
||||
"a m" '("mastodon" . mastodon-perspective)))
|
||||
#+end_src
|
||||
|
||||
Starting the =mastodon= perspective, I set some initial windows:
|
||||
|
|
|
@ -669,7 +669,7 @@ Here is the script I tangle to =~/bin/en=:
|
|||
Along with kicking off the org-capture, I want to be able to clock-in and out:
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'ha-org
|
||||
(ha-org-leader
|
||||
(ha-local-leader :keymaps 'org-mode-map
|
||||
"X" '("org capture" . org-capture)
|
||||
"c" '(:ignore t :which-key "clocks")
|
||||
"c i" '("clock in" . org-clock-in)
|
||||
|
|
|
@ -1077,7 +1077,7 @@ Note we bind the key ~M-R~ to the [[help:rg-menu][rg-menu]], which is a Magit-li
|
|||
I don’t understand the bug associated with the =:general= extension to =use-package=, but it /works/, but stops everything else from working, so pulling it out into its own =use-package= section addresses that issue:
|
||||
#+begin_src emacs-lisp
|
||||
(use-package rg
|
||||
:general (:states 'normal "gr" 'rg-dwim))
|
||||
:general (:states 'normal "gS" 'rg-dwim))
|
||||
#+end_src
|
||||
**** wgrep
|
||||
The [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep package]] integrates with =ripgrep=. Typically, you hit ~i~ to automatically go into =wgrep-mode= and edit away, but since I typically want to edit everything at the same time, I have a toggle that should work as well:
|
||||
|
@ -1312,7 +1312,7 @@ Notice that you can swap:
|
|||
- ~gx i w~ :: words, ~W~ words with dashes, or ~o~ for programming symbols (like variables)
|
||||
- ~gx i s~ :: sentences
|
||||
- ~gx i p~ :: paragraphs
|
||||
- ~gx i g~ :: programming s-expressions between parens, braces, etc.
|
||||
- ~gx i x~ :: programming s-expressions between parens, braces, etc.
|
||||
- ~gx i l~ :: lines, with the [[Evil Text Object Line][line-based text object]] project installed
|
||||
*** Evil Commentary
|
||||
The [[https://github.com/linktohack/evil-commentary][evil-commentary]] is a VI-like way of commenting text. Yeah, I typically type ~M-;~ to call Emacs’ originally functionality, but in this case, ~g c c~ comments out a line(s), and ~g c~ takes text objects and whatnot. For instance, ~g c $~ comments to the end of the line.
|
||||
|
@ -1516,7 +1516,7 @@ I appreciated the [[https://github.com/benma/visual-regexp.el][visual-regexp pac
|
|||
(use-package visual-regexp
|
||||
:bind (("C-c r" . vr/replace)
|
||||
("C-c q" . vr/query-replace))
|
||||
:general (:states 'normal "gR" '("replace" . vr/replace))
|
||||
:general (:states 'normal "g r" '("replace" . vr/replace))
|
||||
:config (ha-leader
|
||||
"r" '("replace" . vr/replace)
|
||||
"R" '("query replace" . vr/query-replace)))
|
||||
|
@ -1584,20 +1584,12 @@ Magnar Sveen's [[https://github.com/magnars/expand-region.el][expand-region]] pr
|
|||
(use-package expand-region
|
||||
:bind ("C-=" . er/expand-region)
|
||||
|
||||
:config
|
||||
(defun ha-start-region ()
|
||||
"Increase the region when on special characters."
|
||||
(interactive)
|
||||
(if (looking-at (rx (any "{}()[]")))
|
||||
(call-interactively 'er/expand-region)
|
||||
(evil-visual-state)))
|
||||
|
||||
:general
|
||||
(:states 'normal "v" 'ha-start-region)
|
||||
;; Use escape to get out of visual mode, but hitting v again expands the selection.
|
||||
(:states 'visual
|
||||
"v" 'er/expand-region
|
||||
"V" 'er/contract-region))
|
||||
"V" 'er/contract-region
|
||||
"-" 'er/contract-region))
|
||||
#+end_src
|
||||
* Working Layout
|
||||
While editing any file on disk is easy enough, I like the mental context switch associated with a full-screen window frame showing all the buffers of a /project task/ (often a direct link to a repository project, but not always).
|
||||
|
|
|
@ -184,7 +184,7 @@ Lots of things to learn and keep straight. Let’s try the [[https://github.com/
|
|||
'(:key "g c" :description "comment line")
|
||||
'(:key "g e" :description "go backward word end")
|
||||
'(:key "g s" :description "visual search for line")
|
||||
'(:key "g r" :description "search for symbol (SPC s j/k)")))
|
||||
'(:key "g r" :description "visual search/replace")))
|
||||
#+end_src
|
||||
** Learn This
|
||||
Simple function to display a file in the top-right corner (if the file exists):
|
||||
|
|
38
ha-email.org
38
ha-email.org
|
@ -102,9 +102,7 @@ Next, we need some basic configuration settings and some global keybindings:
|
|||
"a m" '("read mail" . notmuch)
|
||||
"a c" '("compose mail" . compose-mail))
|
||||
|
||||
<<local-leader-keybindings>>
|
||||
|
||||
(ha-mail-hello-leader
|
||||
(ha-local-leader :keymaps 'notmuch-hello-mode-map
|
||||
"u" '("new mail" . notmuch-retrieve-messages)
|
||||
"m" '("read mail" . notmuch)
|
||||
"c" '("compose" . notmuch-mua-new-mail)
|
||||
|
@ -637,37 +635,10 @@ This means:
|
|||
(message "Noted! Reply Later: %s" email-string)))
|
||||
#+end_src
|
||||
** Bucket Keybindings
|
||||
In /Emacs/ mode, we can just call =define-key=, but since it starts in Evil state (and we may want to use Evil keybindings, let's create some local leaders:
|
||||
|
||||
#+NAME: local-leader-keybindings
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(general-create-definer ha-mail-hello-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'notmuch-hello-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
|
||||
(general-create-definer ha-mail-search-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'notmuch-search-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
|
||||
(general-create-definer ha-mail-show-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'notmuch-show-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
|
||||
A series of keybindings to quickly send messages to one of the pre-defined buckets.
|
||||
|
||||
#+NAME: hey-show-keybindings
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(ha-mail-show-leader
|
||||
(ha-local-leader :keymaps 'notmuch-show-mode-map
|
||||
"c" '("compose" . notmuch-mua-new-mail)
|
||||
"C" '("reply-later" . hey-notmuch-reply-later))
|
||||
|
||||
|
@ -678,7 +649,7 @@ The bindings in =notmuch-search-mode= are available when looking at a list of me
|
|||
|
||||
#+NAME: hey-search-keybindings
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(ha-mail-search-leader
|
||||
(ha-local-leader :keymaps 'notmuch-search-mode-map
|
||||
"r" '("reply" . notmuch-search-reply-to-thread)
|
||||
"R" '("reply-all" . notmuch-search-reply-to-thread-sender)
|
||||
"/" '("search" . notmuch-search-filter)
|
||||
|
@ -715,8 +686,7 @@ The gods ordained that Mail and Org should dance together, so step one is compos
|
|||
#+begin_src emacs-lisp
|
||||
(use-package org-mime
|
||||
:config
|
||||
(ha-local-leader
|
||||
:keymaps 'notmuch-message-mode-map
|
||||
(ha-local-leader :keymaps 'notmuch-message-mode-map
|
||||
"s" '("send" . notmuch-mua-send-and-exit)
|
||||
"m" '("mime it" . org-mime-htmlize)))
|
||||
#+end_src
|
||||
|
|
14
ha-irc.org
14
ha-irc.org
|
@ -118,19 +118,9 @@ And some global keys to display them:
|
|||
"a I" '("irc start" . ha-irc-persp-start))
|
||||
#+end_src
|
||||
|
||||
Let's create a leader for this mode:
|
||||
And a quick shortcuts to call it:
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-irc-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps '(erc-mode-map)
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
|
||||
And a quick shortcut to call it:
|
||||
#+begin_src emacs-lisp
|
||||
(ha-irc-leader
|
||||
(ha-local-leader :keymaps '(erc-mode-map)
|
||||
"o" '("next channel" . erc-track-switch-buffer)
|
||||
"w" '("resize text" . ha-erc-resize-text)
|
||||
"r" '("reconnect" . ha-erc-connect-irc)
|
||||
|
|
|
@ -245,7 +245,8 @@ This function does the heavy lifting. Note that I will need another function to
|
|||
Bind these functions to the /local/ mode key sequence:
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'ha-org
|
||||
(ha-org-leader "y" 'ha-org-yank-clipboard))
|
||||
(ha-local-leader :keymaps 'org-mode-map
|
||||
"y" 'ha-org-yank-clipboard))
|
||||
#+end_src
|
||||
* Technical Artifacts :noexport:
|
||||
Let's provide a name so we can =require= this file:
|
||||
|
|
|
@ -167,7 +167,7 @@ Another helper function for the content of website is to make sure to update =in
|
|||
Make it easy to publish all or just some of my website:
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'ha-org
|
||||
(ha-org-leader
|
||||
(ha-local-leader 'org-mode-map
|
||||
"p" '(:ignore t :which-key "publishing")
|
||||
"p a" '("all" . org-publish-all)
|
||||
"p p" '("project" . org-publish-project)))
|
||||
|
|
15
ha-org.org
15
ha-org.org
|
@ -50,17 +50,6 @@ Org is a /large/ complex beast with a gazillion settings, so I discuss these lat
|
|||
<<global-keybindings>>
|
||||
<<org-keybindings>>)
|
||||
#+end_src
|
||||
|
||||
One other helper routine is a =general= macro for org-mode files:
|
||||
#+name: ha-org-leader
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(general-create-definer ha-org-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'org-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
* Initialization Section
|
||||
Begin by initializing these org variables:
|
||||
#+name: variables
|
||||
|
@ -525,7 +514,7 @@ Bindings specific to org files:
|
|||
"gb" #'org-next-block
|
||||
"gB" #'org-previous-block)
|
||||
|
||||
(ha-org-leader
|
||||
(ha-local-leader :keymaps 'org-mode-map
|
||||
"e" '("exports" . org-export-dispatch)
|
||||
"I" '("insert id" . org-id-get-create)
|
||||
"l" '("insert link" . org-insert-link)
|
||||
|
@ -591,7 +580,7 @@ I have a special version of tweaked [[file:elisp/ox-confluence.el][Confluence ex
|
|||
:after org
|
||||
:straight nil ; Located in my "elisp" directory
|
||||
:config
|
||||
(ha-org-leader
|
||||
(ha-local-leader :keymaps 'org-mode-map
|
||||
"E" '("to confluence" . ox-export-to-confluence)))
|
||||
#+end_src
|
||||
|
||||
|
|
|
@ -48,26 +48,13 @@ Then for each project, create the project directory with this command:
|
|||
lein new app fresh-app
|
||||
#+end_src
|
||||
* Emacs Support
|
||||
Let’s create a keybinding menu of Clojure-related commands:
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-clojure-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'clojure-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
|
||||
Next, install and configure [[https://github.com/clojure-emacs/clojure-mode/][clojure-mode]]:
|
||||
Install and configure [[https://github.com/clojure-emacs/clojure-mode/][clojure-mode]]:
|
||||
#+begin_src emacs-lisp
|
||||
(use-package clojure-mode
|
||||
:init
|
||||
(add-to-list 'org-babel-load-languages '(clojure . t))
|
||||
|
||||
:config
|
||||
;; Predefine a "help" sequence used later on:
|
||||
(ha-clojure-leader "h" '(:ignore t :which-key "help"))
|
||||
|
||||
(defun ha-prettify-clojure ()
|
||||
"Make the Clojure syntax prettier."
|
||||
(push '("fn" . ?𝝀) prettify-symbols-alist)
|
||||
|
@ -117,7 +104,7 @@ Need the IDE features associated with [[https://github.com/clojure-emacs/cider][
|
|||
:hook (cider-repl-mode . #'subword-mode)
|
||||
|
||||
:config
|
||||
(ha-clojure-leader
|
||||
(ha-local-leader :keymaps clojure-mode-map
|
||||
"w" '(:ignore t :which-key "cider")
|
||||
"w s" '("start" . cider-jack-in)
|
||||
"w r" '("restart" . cider-restart)
|
||||
|
@ -215,7 +202,7 @@ This [[https://github.com/joshuamiller/clojars.el][clojars]] extension allows yo
|
|||
(use-package clojars
|
||||
:after clojure-mode
|
||||
:config
|
||||
(ha-clojure-leader
|
||||
(ha-local-leader :keymaps clojure-mode-map
|
||||
"h j" '("clojars" . clojars)))
|
||||
#+end_src
|
||||
** Clojure Cheatsheet
|
||||
|
@ -224,7 +211,7 @@ The [[https://github.com/clojure-emacs/clojure-cheatsheet][clojure-cheatsheet]]
|
|||
(use-package clojure-cheatsheet
|
||||
:after clojure-mode
|
||||
:config
|
||||
(ha-clojure-leader
|
||||
(ha-local-leader :keymaps clojure-mode-map
|
||||
"h c" '("cheatsheet" . clojure-cheatsheet)))
|
||||
#+end_src
|
||||
** Snippets
|
||||
|
@ -244,7 +231,7 @@ The [[https://github.com/clojure-emacs/clj-refactor.el][clj-refactor]] project:
|
|||
;; Configure the Clojure Refactoring prefix.
|
||||
(cljr-add-keybindings-with-prefix "C-c .")
|
||||
|
||||
(ha-clojure-leader
|
||||
(ha-local-leader :keymaps clojure-mode-map
|
||||
;; Would really like to have this on the , prefix:
|
||||
"r" '("refactoring" . hydra-cljr-help-menu/body)
|
||||
|
||||
|
|
|
@ -30,16 +30,6 @@ New, /non-literal/ source code comes from [[file:templates/emacs-lisp-mode.el][e
|
|||
#+begin_src emacs-lisp
|
||||
(ha-auto-insert-file (rx ".el" eol) "emacs-lisp-mode.el")
|
||||
#+end_src
|
||||
|
||||
Perhaps we should have an Emacs Lisp-specific leader for advanced commands:
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-elisp-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps '(emacs-lisp-mode-map lisp-mode-map)
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
* Syntax Display
|
||||
** Dim those Parenthesis
|
||||
The [[https://github.com/tarsius/paren-face][paren-face]] project lowers the color level of parenthesis which I find better.
|
||||
|
@ -65,8 +55,8 @@ And we should extend it with the [[https://github.com/xuchunyang/elisp-demos][el
|
|||
(use-package elisp-demos
|
||||
:after helpful
|
||||
:config
|
||||
(ha-elisp-leader
|
||||
"h a" '("add helpful demo" . elisp-demos-add-demo))
|
||||
(ha-local-leader :keymaps '(emacs-lisp-mode-map lisp-mode-map)
|
||||
"d a" '("add helpful demo" . elisp-demos-add-demo))
|
||||
|
||||
(advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update))
|
||||
#+end_src
|
||||
|
@ -129,7 +119,8 @@ My primary use-case is for its refactoring and other unique features. For instan
|
|||
(evil-define-key 'visual emacs-lisp-mode-map
|
||||
"o" 'lispy-mark-symbol) ; Mark symbol since "o" doesn't do anything
|
||||
|
||||
(ha-elisp-leader
|
||||
(ha-local-leader :keymaps '(emacs-lisp-mode-map lisp-mode-map)
|
||||
"r" '(:ignore t :which-key "refactor")
|
||||
"r i" '("cond→if" . lispy-to-ifs)
|
||||
"r c" '("if→cond" . lispy-to-cond)
|
||||
"r d" '("λ→𝑓" . lispy-to-defun)
|
||||
|
@ -142,7 +133,7 @@ My primary use-case is for its refactoring and other unique features. For instan
|
|||
"e j" '("debug-step-in" . lispy-debug-step-in)
|
||||
"e R" '("eval-and-replace" . lispy-eval-and-replace)
|
||||
|
||||
"h d" '("describe" . lispy-describe)
|
||||
"d d" '("describe" . lispy-describe)
|
||||
"t t" '("ert" . lispy-ert)))
|
||||
#+end_src
|
||||
** Lispyville
|
||||
|
@ -287,7 +278,7 @@ A feature I enjoyed from Spacemacs is the ability to evaluate the s-expression c
|
|||
|
||||
And we just need to bind it.
|
||||
#+begin_src emacs-lisp
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps '(emacs-lisp-mode-map lisp-mode-map)
|
||||
"e c" '("current" . ha-eval-current-expression))
|
||||
#+end_src
|
||||
* Technical Artifacts :noexport:
|
||||
|
|
|
@ -26,16 +26,7 @@ A literate programming file for configuring Python.
|
|||
* Introduction
|
||||
The critical part of Python integration with Emacs is running LSP in Python using [[file:ha-programming.org::*direnv][direnv]]. And the question to ask is if the Python we run it in Docker or in a virtual environment.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-python-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'python-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
While Emacs supplies a Python editing environment, we’ll still use =use-package= to grab the latest:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package python
|
||||
:after projectile flycheck
|
||||
|
@ -122,7 +113,7 @@ container_layout
|
|||
:after python
|
||||
:commands python-pytest-dispatch
|
||||
:init
|
||||
(ha-python-leader
|
||||
(ha-local-leader :keymaps 'python-mode-map
|
||||
"t" '(:ignore t :which-key "tests")
|
||||
"t a" '("all" . python-pytest)
|
||||
"t f" '("file dwim" . python-pytest-file-dwim)
|
||||
|
@ -176,7 +167,7 @@ Now that the [[file:ha-programming.org::*Language Server Protocol (LSP) Integrat
|
|||
(use-package lsp-mode
|
||||
;; :hook ((python-mode . lsp)))
|
||||
:config
|
||||
(ha-python-leader
|
||||
(ha-local-leader :keymaps 'lsp-mode-map
|
||||
"0" '("treemacs" . lsp-treemacs-symbols)
|
||||
|
||||
"/" '("complete" . completion-at-point)
|
||||
|
|
|
@ -185,16 +185,6 @@ Next, create a =.envrc= in the project’s directory:
|
|||
#+end_src
|
||||
While that approach works /fairly well/ with [[file:ha-programming.org::*direnv][my direnv configuration]], [[file:ha-programming.org::*Flycheck][Flycheck]] seems to want the checkers to be installed globally.
|
||||
* Configuration
|
||||
Ruby-specific commands are attached to the =ha-ruby-leader=, bound to ~,~:
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-ruby-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'ruby-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
|
||||
While Emacs supplies a Ruby editing environment, we’ll still use =use-package= to grab the latest:
|
||||
#+begin_src emacs-lisp
|
||||
(use-package ruby-mode
|
||||
|
@ -216,7 +206,7 @@ While Emacs supplies a Ruby editing environment, we’ll still use =use-package=
|
|||
#+BEGIN_SRC elisp
|
||||
(use-package inf-ruby
|
||||
:config
|
||||
(ha-ruby-leader
|
||||
(ha-local-leader 'ruby-mode-map
|
||||
"R" '("REPL" . inf-ruby)))
|
||||
#+END_SRC
|
||||
** Electric Ruby
|
||||
|
@ -232,7 +222,7 @@ The [[https://github.com/r0man/ruby-test-mode][ruby-test-mode]] project aims a r
|
|||
:hook (ruby-mode . ruby-test-mode)
|
||||
|
||||
:config
|
||||
(ha-ruby-leader
|
||||
(ha-local-leader 'ruby-mode-map
|
||||
"t" '(:ignore t :which-key "test")
|
||||
"t t" '("test one" . ruby-test-run-at-point)
|
||||
"t g" '("toggle code/test" . ruby-test-toggle-implementation-and-specification)
|
||||
|
@ -245,7 +235,7 @@ The [[https://github.com/dgutov/robe][Robe project]] can be used instead of [[fi
|
|||
(use-package robe
|
||||
|
||||
:config
|
||||
(ha-ruby-leader
|
||||
(ha-local-leader 'ruby-mode-map
|
||||
"w" '(:ignore t :which-key "robe")
|
||||
"ws" '("start" . robe-start))
|
||||
|
||||
|
@ -276,7 +266,7 @@ The [[https://github.com/endofunky/bundler.el][Bundler project]] integrates [[ht
|
|||
#+begin_src emacs-lisp
|
||||
(use-package bundler
|
||||
:config
|
||||
(ha-ruby-leader
|
||||
(ha-local-leader 'ruby-mode-map
|
||||
"g" '(:ignore t :which-key "bundler")
|
||||
"g o" '("open" . bundle-open)
|
||||
"g g" '("console" . bundle-console)
|
||||
|
|
|
@ -24,15 +24,7 @@ A literate programming file for helping me program.
|
|||
;;; Code:
|
||||
#+end_src
|
||||
* Introduction
|
||||
Seems that all programming interfaces and workflows behave similarly. One other helper routine is a =general= macro for org-mode files:
|
||||
#+begin_src emacs-lisp
|
||||
(general-create-definer ha-prog-leader
|
||||
:states '(normal visual motion)
|
||||
:keymaps 'prog-mode-map
|
||||
:prefix ","
|
||||
:global-prefix "<f17>"
|
||||
:non-normal-prefix "S-SPC")
|
||||
#+end_src
|
||||
Configuration for programming interfaces and workflows that behave similarly.
|
||||
* General
|
||||
The following work for all programming languages.
|
||||
** direnv
|
||||
|
@ -110,7 +102,7 @@ I’m interested in using [[https://devdocs.io/][devdocs]] instead, which is sim
|
|||
:general (:states 'normal "gD" 'devdocs-lookup)
|
||||
|
||||
:config
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"d" '(:ignore t :which-key "docs")
|
||||
"d e" '("eldoc" . eldoc)
|
||||
"d d" '("open" . devdocs-lookup)
|
||||
|
@ -127,7 +119,7 @@ The [[https://github.com/blahgeek/emacs-devdocs-browser][devdocs-browser]] proje
|
|||
:general (:states 'normal "gD" 'devdocs-browser-open)
|
||||
|
||||
:config
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"d" '(:ignore t :which-key "docs")
|
||||
"d d" '("open" . devdocs-browser-open)
|
||||
"d D" '("open in" . devdocs-browser-open-in)
|
||||
|
@ -381,7 +373,7 @@ Once upon a time, we use to create a =TAGS= file that contained the database for
|
|||
;; (defun evil-set-jump-args (&rest ns) (evil-set-jump))
|
||||
;; (advice-add 'dumb-jump-goto-file-line :before #'evil-set-jump-args)
|
||||
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"s" '(:ignore t :which-key "search")
|
||||
"s s" '("search" . xref-find-apropos)
|
||||
"s d" '("definitions" . xref-find-definitions)
|
||||
|
@ -390,15 +382,16 @@ Once upon a time, we use to create a =TAGS= file that contained the database for
|
|||
"s b" '("back" . xref-go-back)
|
||||
"s f" '("forward" . xref-go-forward))
|
||||
|
||||
:general (:states 'normal
|
||||
"g." 'xref-find-definitions
|
||||
"g>" 'xref-find-definitions-other-window
|
||||
"g," 'xref-go-back
|
||||
"g<" 'xref-go-forward
|
||||
"g/" 'xref-find-references
|
||||
"g?" 'xref-find-references-and-replace
|
||||
"gh" 'xref-find-apropos
|
||||
"gb" 'xref-go-back))
|
||||
:general
|
||||
(:states 'normal
|
||||
"g ." '("find def" . xref-find-definitions)
|
||||
"g >" '("find def o/win" . xref-find-definitions-other-window)
|
||||
"g ," '("def go back" . xref-go-back)
|
||||
"g <" '("def go forward" . xref-go-forward)
|
||||
"g /" '("find refs" . xref-find-references)
|
||||
"g ?" '("find/rep refs" . xref-find-references-and-replace)
|
||||
"g h" '("find apropos" . xref-find-apropos)
|
||||
"g b" '("def go back" . xref-go-back)))
|
||||
#+end_src
|
||||
|
||||
I have two different /jumping/ systems, the [[info:emacs#Xref][Xref interface]] and Evil’s. While comparable goals, they are behave different. Let’s compare evil keybindings:
|
||||
|
@ -430,7 +423,7 @@ Emacs has two LSP projects, and while I have used [[LSP Mode]], but since I don
|
|||
|
||||
:config
|
||||
(global-set-key (kbd "s-m") 'lsp)
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"w" '(:ignore t :which-key "lsp")
|
||||
"l" '(:ignore t :which-key "lsp")
|
||||
"ws" '("start" . lsp))
|
||||
|
@ -497,7 +490,7 @@ The [[https://github.com/emacs-lsp/lsp-ui/blob/master/lsp-ui-imenu.el][lsp-imenu
|
|||
:straight nil
|
||||
:after lsp-ui
|
||||
:config
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"g" '(:ignore t :which-key "goto")
|
||||
"g m" '("imenu" . lsp-ui-imenu))
|
||||
(add-hook 'lsp-after-open-hook 'lsp-enable-imenu))
|
||||
|
@ -565,7 +558,9 @@ I like =comment-dwim= (~M-;~), and I like =comment-box=, but I have an odd perso
|
|||
#+end_src
|
||||
And a keybinding:
|
||||
#+begin_src emacs-lisp
|
||||
(ha-prog-leader "c" '("comment line" . ha-comment-line))
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"c" '(:ignore t :which-key "comment")
|
||||
"c l" '("comment line" . ha-comment-line))
|
||||
#+end_src
|
||||
** Evaluation
|
||||
While I like [[help:eval-print-last-sexp][eval-print-last-sexp]], I would like a bit of formatting in order to /keep the results/ in the file.
|
||||
|
@ -588,7 +583,7 @@ While I like [[help:eval-print-last-sexp][eval-print-last-sexp]], I would like a
|
|||
|
||||
Typical keybindings for all programming modes:
|
||||
#+begin_src emacs-lisp
|
||||
(ha-prog-leader
|
||||
(ha-local-leader :keymaps 'prog-mode-map
|
||||
"e" '(:ignore t :which-key "eval")
|
||||
"e ;" '("expression" . eval-expression)
|
||||
"e b" '("buffer" . eval-buffer)
|
||||
|
|
Loading…
Reference in a new issue