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:
Howard Abrams 2023-05-01 11:49:33 -07:00
parent e1eb3b85e3
commit 882cf0dba7
14 changed files with 70 additions and 174 deletions

View file

@ -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") :straight (:host codeberg :repo "martianh/mastodon.el")
:init :init
(setq mastodon-instance-url "https://emacs.ch" (setq mastodon-instance-url "https://emacs.ch"
mastodon-active-user "howard") mastodon-active-user "howard"))
:bind
(:map mastodon-mode-map
("g" . mastodon-tl--update)))
#+end_src #+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: 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-names) "mastodon" 'equal)))
(persp-switch "mastodon") (persp-switch "mastodon")
(unless already-tooted? (unless already-tooted?
(ha-leader (ha-local-leader :keymaps 'mastodon-mode-map
"a m t" '("toot" . mastodon-toot) ;; "," '("thread" . mastodon-tl--thread)
"a m u" '("update" . mastodon-tl--update) "t" '("toot" . mastodon-toot)
"a m f" '("favorite" . mastodon-toot--toggle-favourite) "u" '("update" . mastodon-tl--update)
"a m b" '("boost" . mastodon-toot--toggle-boost) "f" '("favorite" . mastodon-toot--toggle-favourite)
"a m d" '("discover" . mastodon-discover)) "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)))) (my-mastodon-start))))
(ha-leader (ha-leader
"a m" '(:ignore t :which-key "mastodon") "a m" '("mastodon" . mastodon-perspective)))
"a m m" '("perspective" . mastodon-perspective)))
#+end_src #+end_src
Starting the =mastodon= perspective, I set some initial windows: Starting the =mastodon= perspective, I set some initial windows:

View file

@ -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: Along with kicking off the org-capture, I want to be able to clock-in and out:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'ha-org (with-eval-after-load 'ha-org
(ha-org-leader (ha-local-leader :keymaps 'org-mode-map
"X" '("org capture" . org-capture) "X" '("org capture" . org-capture)
"c" '(:ignore t :which-key "clocks") "c" '(:ignore t :which-key "clocks")
"c i" '("clock in" . org-clock-in) "c i" '("clock in" . org-clock-in)

View file

@ -1077,7 +1077,7 @@ Note we bind the key ~M-R~ to the [[help:rg-menu][rg-menu]], which is a Magit-li
I dont 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: I dont 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 #+begin_src emacs-lisp
(use-package rg (use-package rg
:general (:states 'normal "gr" 'rg-dwim)) :general (:states 'normal "gS" 'rg-dwim))
#+end_src #+end_src
**** wgrep **** 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: 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 w~ :: words, ~W~ words with dashes, or ~o~ for programming symbols (like variables)
- ~gx i s~ :: sentences - ~gx i s~ :: sentences
- ~gx i p~ :: paragraphs - ~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 - ~gx i l~ :: lines, with the [[Evil Text Object Line][line-based text object]] project installed
*** Evil Commentary *** 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. 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 (use-package visual-regexp
:bind (("C-c r" . vr/replace) :bind (("C-c r" . vr/replace)
("C-c q" . vr/query-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 :config (ha-leader
"r" '("replace" . vr/replace) "r" '("replace" . vr/replace)
"R" '("query replace" . vr/query-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 (use-package expand-region
:bind ("C-=" . er/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 :general
(:states 'normal "v" 'ha-start-region)
;; Use escape to get out of visual mode, but hitting v again expands the selection. ;; Use escape to get out of visual mode, but hitting v again expands the selection.
(:states 'visual (:states 'visual
"v" 'er/expand-region "v" 'er/expand-region
"V" 'er/contract-region)) "V" 'er/contract-region
"-" 'er/contract-region))
#+end_src #+end_src
* Working Layout * 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). 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).

View file

@ -184,7 +184,7 @@ Lots of things to learn and keep straight. Lets try the [[https://github.com/
'(:key "g c" :description "comment line") '(:key "g c" :description "comment line")
'(:key "g e" :description "go backward word end") '(:key "g e" :description "go backward word end")
'(:key "g s" :description "visual search for line") '(: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 #+end_src
** Learn This ** Learn This
Simple function to display a file in the top-right corner (if the file exists): Simple function to display a file in the top-right corner (if the file exists):

View file

@ -102,9 +102,7 @@ Next, we need some basic configuration settings and some global keybindings:
"a m" '("read mail" . notmuch) "a m" '("read mail" . notmuch)
"a c" '("compose mail" . compose-mail)) "a c" '("compose mail" . compose-mail))
<<local-leader-keybindings>> (ha-local-leader :keymaps 'notmuch-hello-mode-map
(ha-mail-hello-leader
"u" '("new mail" . notmuch-retrieve-messages) "u" '("new mail" . notmuch-retrieve-messages)
"m" '("read mail" . notmuch) "m" '("read mail" . notmuch)
"c" '("compose" . notmuch-mua-new-mail) "c" '("compose" . notmuch-mua-new-mail)
@ -637,37 +635,10 @@ This means:
(message "Noted! Reply Later: %s" email-string))) (message "Noted! Reply Later: %s" email-string)))
#+end_src #+end_src
** Bucket Keybindings ** 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. A series of keybindings to quickly send messages to one of the pre-defined buckets.
#+NAME: hey-show-keybindings #+NAME: hey-show-keybindings
#+begin_src emacs-lisp :tangle no #+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" '("compose" . notmuch-mua-new-mail)
"C" '("reply-later" . hey-notmuch-reply-later)) "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 #+NAME: hey-search-keybindings
#+begin_src emacs-lisp :tangle no #+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" . notmuch-search-reply-to-thread)
"R" '("reply-all" . notmuch-search-reply-to-thread-sender) "R" '("reply-all" . notmuch-search-reply-to-thread-sender)
"/" '("search" . notmuch-search-filter) "/" '("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 #+begin_src emacs-lisp
(use-package org-mime (use-package org-mime
:config :config
(ha-local-leader (ha-local-leader :keymaps 'notmuch-message-mode-map
:keymaps 'notmuch-message-mode-map
"s" '("send" . notmuch-mua-send-and-exit) "s" '("send" . notmuch-mua-send-and-exit)
"m" '("mime it" . org-mime-htmlize))) "m" '("mime it" . org-mime-htmlize)))
#+end_src #+end_src

View file

@ -118,19 +118,9 @@ And some global keys to display them:
"a I" '("irc start" . ha-irc-persp-start)) "a I" '("irc start" . ha-irc-persp-start))
#+end_src #+end_src
Let's create a leader for this mode: And a quick shortcuts to call it:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(general-create-definer ha-irc-leader (ha-local-leader :keymaps '(erc-mode-map)
: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
"o" '("next channel" . erc-track-switch-buffer) "o" '("next channel" . erc-track-switch-buffer)
"w" '("resize text" . ha-erc-resize-text) "w" '("resize text" . ha-erc-resize-text)
"r" '("reconnect" . ha-erc-connect-irc) "r" '("reconnect" . ha-erc-connect-irc)

View file

@ -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: Bind these functions to the /local/ mode key sequence:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'ha-org (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 #+end_src
* Technical Artifacts :noexport: * Technical Artifacts :noexport:
Let's provide a name so we can =require= this file: Let's provide a name so we can =require= this file:

View 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: Make it easy to publish all or just some of my website:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'ha-org (with-eval-after-load 'ha-org
(ha-org-leader (ha-local-leader 'org-mode-map
"p" '(:ignore t :which-key "publishing") "p" '(:ignore t :which-key "publishing")
"p a" '("all" . org-publish-all) "p a" '("all" . org-publish-all)
"p p" '("project" . org-publish-project))) "p p" '("project" . org-publish-project)))

View file

@ -50,17 +50,6 @@ Org is a /large/ complex beast with a gazillion settings, so I discuss these lat
<<global-keybindings>> <<global-keybindings>>
<<org-keybindings>>) <<org-keybindings>>)
#+end_src #+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 * Initialization Section
Begin by initializing these org variables: Begin by initializing these org variables:
#+name: variables #+name: variables
@ -525,7 +514,7 @@ Bindings specific to org files:
"gb" #'org-next-block "gb" #'org-next-block
"gB" #'org-previous-block) "gB" #'org-previous-block)
(ha-org-leader (ha-local-leader :keymaps 'org-mode-map
"e" '("exports" . org-export-dispatch) "e" '("exports" . org-export-dispatch)
"I" '("insert id" . org-id-get-create) "I" '("insert id" . org-id-get-create)
"l" '("insert link" . org-insert-link) "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 :after org
:straight nil ; Located in my "elisp" directory :straight nil ; Located in my "elisp" directory
:config :config
(ha-org-leader (ha-local-leader :keymaps 'org-mode-map
"E" '("to confluence" . ox-export-to-confluence))) "E" '("to confluence" . ox-export-to-confluence)))
#+end_src #+end_src

View file

@ -48,26 +48,13 @@ Then for each project, create the project directory with this command:
lein new app fresh-app lein new app fresh-app
#+end_src #+end_src
* Emacs Support * Emacs Support
Lets create a keybinding menu of Clojure-related commands: Install and configure [[https://github.com/clojure-emacs/clojure-mode/][clojure-mode]]:
#+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]]:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package clojure-mode (use-package clojure-mode
:init :init
(add-to-list 'org-babel-load-languages '(clojure . t)) (add-to-list 'org-babel-load-languages '(clojure . t))
:config :config
;; Predefine a "help" sequence used later on:
(ha-clojure-leader "h" '(:ignore t :which-key "help"))
(defun ha-prettify-clojure () (defun ha-prettify-clojure ()
"Make the Clojure syntax prettier." "Make the Clojure syntax prettier."
(push '("fn" . ?𝝀) prettify-symbols-alist) (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) :hook (cider-repl-mode . #'subword-mode)
:config :config
(ha-clojure-leader (ha-local-leader :keymaps clojure-mode-map
"w" '(:ignore t :which-key "cider") "w" '(:ignore t :which-key "cider")
"w s" '("start" . cider-jack-in) "w s" '("start" . cider-jack-in)
"w r" '("restart" . cider-restart) "w r" '("restart" . cider-restart)
@ -215,7 +202,7 @@ This [[https://github.com/joshuamiller/clojars.el][clojars]] extension allows yo
(use-package clojars (use-package clojars
:after clojure-mode :after clojure-mode
:config :config
(ha-clojure-leader (ha-local-leader :keymaps clojure-mode-map
"h j" '("clojars" . clojars))) "h j" '("clojars" . clojars)))
#+end_src #+end_src
** Clojure Cheatsheet ** Clojure Cheatsheet
@ -224,7 +211,7 @@ The [[https://github.com/clojure-emacs/clojure-cheatsheet][clojure-cheatsheet]]
(use-package clojure-cheatsheet (use-package clojure-cheatsheet
:after clojure-mode :after clojure-mode
:config :config
(ha-clojure-leader (ha-local-leader :keymaps clojure-mode-map
"h c" '("cheatsheet" . clojure-cheatsheet))) "h c" '("cheatsheet" . clojure-cheatsheet)))
#+end_src #+end_src
** Snippets ** Snippets
@ -244,7 +231,7 @@ The [[https://github.com/clojure-emacs/clj-refactor.el][clj-refactor]] project:
;; Configure the Clojure Refactoring prefix. ;; Configure the Clojure Refactoring prefix.
(cljr-add-keybindings-with-prefix "C-c .") (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: ;; Would really like to have this on the , prefix:
"r" '("refactoring" . hydra-cljr-help-menu/body) "r" '("refactoring" . hydra-cljr-help-menu/body)

View file

@ -30,16 +30,6 @@ New, /non-literal/ source code comes from [[file:templates/emacs-lisp-mode.el][e
#+begin_src emacs-lisp #+begin_src emacs-lisp
(ha-auto-insert-file (rx ".el" eol) "emacs-lisp-mode.el") (ha-auto-insert-file (rx ".el" eol) "emacs-lisp-mode.el")
#+end_src #+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 * Syntax Display
** Dim those Parenthesis ** Dim those Parenthesis
The [[https://github.com/tarsius/paren-face][paren-face]] project lowers the color level of parenthesis which I find better. 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 (use-package elisp-demos
:after helpful :after helpful
:config :config
(ha-elisp-leader (ha-local-leader :keymaps '(emacs-lisp-mode-map lisp-mode-map)
"h a" '("add helpful demo" . elisp-demos-add-demo)) "d a" '("add helpful demo" . elisp-demos-add-demo))
(advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update)) (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update))
#+end_src #+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 (evil-define-key 'visual emacs-lisp-mode-map
"o" 'lispy-mark-symbol) ; Mark symbol since "o" doesn't do anything "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 i" '("cond→if" . lispy-to-ifs)
"r c" '("if→cond" . lispy-to-cond) "r c" '("if→cond" . lispy-to-cond)
"r d" '("λ→𝑓" . lispy-to-defun) "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 j" '("debug-step-in" . lispy-debug-step-in)
"e R" '("eval-and-replace" . lispy-eval-and-replace) "e R" '("eval-and-replace" . lispy-eval-and-replace)
"h d" '("describe" . lispy-describe) "d d" '("describe" . lispy-describe)
"t t" '("ert" . lispy-ert))) "t t" '("ert" . lispy-ert)))
#+end_src #+end_src
** Lispyville ** 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. And we just need to bind it.
#+begin_src emacs-lisp #+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)) "e c" '("current" . ha-eval-current-expression))
#+end_src #+end_src
* Technical Artifacts :noexport: * Technical Artifacts :noexport:

View file

@ -26,16 +26,7 @@ A literate programming file for configuring Python.
* Introduction * 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. 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, well still use =use-package= to grab the latest: While Emacs supplies a Python editing environment, well still use =use-package= to grab the latest:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package python (use-package python
:after projectile flycheck :after projectile flycheck
@ -122,7 +113,7 @@ container_layout
:after python :after python
:commands python-pytest-dispatch :commands python-pytest-dispatch
:init :init
(ha-python-leader (ha-local-leader :keymaps 'python-mode-map
"t" '(:ignore t :which-key "tests") "t" '(:ignore t :which-key "tests")
"t a" '("all" . python-pytest) "t a" '("all" . python-pytest)
"t f" '("file dwim" . python-pytest-file-dwim) "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 (use-package lsp-mode
;; :hook ((python-mode . lsp))) ;; :hook ((python-mode . lsp)))
:config :config
(ha-python-leader (ha-local-leader :keymaps 'lsp-mode-map
"0" '("treemacs" . lsp-treemacs-symbols) "0" '("treemacs" . lsp-treemacs-symbols)
"/" '("complete" . completion-at-point) "/" '("complete" . completion-at-point)

View file

@ -185,16 +185,6 @@ Next, create a =.envrc= in the projects directory:
#+end_src #+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. 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 * 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, well still use =use-package= to grab the latest: While Emacs supplies a Ruby editing environment, well still use =use-package= to grab the latest:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package ruby-mode (use-package ruby-mode
@ -216,7 +206,7 @@ While Emacs supplies a Ruby editing environment, well still use =use-package=
#+BEGIN_SRC elisp #+BEGIN_SRC elisp
(use-package inf-ruby (use-package inf-ruby
:config :config
(ha-ruby-leader (ha-local-leader 'ruby-mode-map
"R" '("REPL" . inf-ruby))) "R" '("REPL" . inf-ruby)))
#+END_SRC #+END_SRC
** Electric Ruby ** 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) :hook (ruby-mode . ruby-test-mode)
:config :config
(ha-ruby-leader (ha-local-leader 'ruby-mode-map
"t" '(:ignore t :which-key "test") "t" '(:ignore t :which-key "test")
"t t" '("test one" . ruby-test-run-at-point) "t t" '("test one" . ruby-test-run-at-point)
"t g" '("toggle code/test" . ruby-test-toggle-implementation-and-specification) "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 (use-package robe
:config :config
(ha-ruby-leader (ha-local-leader 'ruby-mode-map
"w" '(:ignore t :which-key "robe") "w" '(:ignore t :which-key "robe")
"ws" '("start" . robe-start)) "ws" '("start" . robe-start))
@ -274,9 +264,9 @@ Do we want to load Robe /automatically/?
The [[https://github.com/endofunky/bundler.el][Bundler project]] integrates [[https://bundler.io/][bundler]] to install a projects Gems. The [[https://github.com/endofunky/bundler.el][Bundler project]] integrates [[https://bundler.io/][bundler]] to install a projects Gems.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package bundler (use-package bundler
:config :config
(ha-ruby-leader (ha-local-leader 'ruby-mode-map
"g" '(:ignore t :which-key "bundler") "g" '(:ignore t :which-key "bundler")
"g o" '("open" . bundle-open) "g o" '("open" . bundle-open)
"g g" '("console" . bundle-console) "g g" '("console" . bundle-console)

View file

@ -24,15 +24,7 @@ A literate programming file for helping me program.
;;; Code: ;;; Code:
#+end_src #+end_src
* Introduction * Introduction
Seems that all programming interfaces and workflows behave similarly. One other helper routine is a =general= macro for org-mode files: Configuration for programming interfaces and workflows that behave similarly.
#+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
* General * General
The following work for all programming languages. The following work for all programming languages.
** direnv ** direnv
@ -110,7 +102,7 @@ Im interested in using [[https://devdocs.io/][devdocs]] instead, which is sim
:general (:states 'normal "gD" 'devdocs-lookup) :general (:states 'normal "gD" 'devdocs-lookup)
:config :config
(ha-prog-leader (ha-local-leader :keymaps 'prog-mode-map
"d" '(:ignore t :which-key "docs") "d" '(:ignore t :which-key "docs")
"d e" '("eldoc" . eldoc) "d e" '("eldoc" . eldoc)
"d d" '("open" . devdocs-lookup) "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) :general (:states 'normal "gD" 'devdocs-browser-open)
:config :config
(ha-prog-leader (ha-local-leader :keymaps 'prog-mode-map
"d" '(:ignore t :which-key "docs") "d" '(:ignore t :which-key "docs")
"d d" '("open" . devdocs-browser-open) "d d" '("open" . devdocs-browser-open)
"d D" '("open in" . devdocs-browser-open-in) "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)) ;; (defun evil-set-jump-args (&rest ns) (evil-set-jump))
;; (advice-add 'dumb-jump-goto-file-line :before #'evil-set-jump-args) ;; (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" '(:ignore t :which-key "search")
"s s" '("search" . xref-find-apropos) "s s" '("search" . xref-find-apropos)
"s d" '("definitions" . xref-find-definitions) "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 b" '("back" . xref-go-back)
"s f" '("forward" . xref-go-forward)) "s f" '("forward" . xref-go-forward))
:general (:states 'normal :general
"g." 'xref-find-definitions (:states 'normal
"g>" 'xref-find-definitions-other-window "g ." '("find def" . xref-find-definitions)
"g," 'xref-go-back "g >" '("find def o/win" . xref-find-definitions-other-window)
"g<" 'xref-go-forward "g ," '("def go back" . xref-go-back)
"g/" 'xref-find-references "g <" '("def go forward" . xref-go-forward)
"g?" 'xref-find-references-and-replace "g /" '("find refs" . xref-find-references)
"gh" 'xref-find-apropos "g ?" '("find/rep refs" . xref-find-references-and-replace)
"gb" 'xref-go-back)) "g h" '("find apropos" . xref-find-apropos)
"g b" '("def go back" . xref-go-back)))
#+end_src #+end_src
I have two different /jumping/ systems, the [[info:emacs#Xref][Xref interface]] and Evils. While comparable goals, they are behave different. Lets compare evil keybindings: I have two different /jumping/ systems, the [[info:emacs#Xref][Xref interface]] and Evils. While comparable goals, they are behave different. Lets compare evil keybindings:
@ -430,7 +423,7 @@ Emacs has two LSP projects, and while I have used [[LSP Mode]], but since I don
:config :config
(global-set-key (kbd "s-m") 'lsp) (global-set-key (kbd "s-m") 'lsp)
(ha-prog-leader (ha-local-leader :keymaps 'prog-mode-map
"w" '(:ignore t :which-key "lsp") "w" '(:ignore t :which-key "lsp")
"l" '(:ignore t :which-key "lsp") "l" '(:ignore t :which-key "lsp")
"ws" '("start" . 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 :straight nil
:after lsp-ui :after lsp-ui
:config :config
(ha-prog-leader (ha-local-leader :keymaps 'prog-mode-map
"g" '(:ignore t :which-key "goto") "g" '(:ignore t :which-key "goto")
"g m" '("imenu" . lsp-ui-imenu)) "g m" '("imenu" . lsp-ui-imenu))
(add-hook 'lsp-after-open-hook 'lsp-enable-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 #+end_src
And a keybinding: And a keybinding:
#+begin_src emacs-lisp #+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 #+end_src
** Evaluation ** 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. 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: Typical keybindings for all programming modes:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(ha-prog-leader (ha-local-leader :keymaps 'prog-mode-map
"e" '(:ignore t :which-key "eval") "e" '(:ignore t :which-key "eval")
"e ;" '("expression" . eval-expression) "e ;" '("expression" . eval-expression)
"e b" '("buffer" . eval-buffer) "e b" '("buffer" . eval-buffer)