Skip to content

Commit

Permalink
Emacs key bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
EnigmaCurry committed Jan 9, 2025
1 parent 4da4a4b commit 76c2e67
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hugo/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ blockquote {
color: rgb(255, 129, 129) !important
}

.table > ul > li {
font-size: 2em;
}

@media only screen and (max-width: 600px) {
h1 {
font-size: 2em;
Expand Down
41 changes: 41 additions & 0 deletions notes/2025-01-08-19-39-59-guix-server-(debian).org
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#+hugo_base_dir: ../hugo
#+hugo_section: /notes/2025-01-08
#+hugo_weight: auto
#+hugo_paired_shortcodes: %notice badge button %children %index run stdout edit math mermaid openapi result expand
#+startup: align
* 2025-01-08
:PROPERTIES:
:EXPORT_FILE_NAME: _index
:EXPORT_HUGO_SLUG: _index
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :alwaysopen false
:END:
#+begin_comment
This is the default index for 2025-01-08 and it is boilerplate.
Don't write anything here.
This section will be overwriten by the template
(enigmacurry/org/notes/_template/note.o.txt).
Write your new top level sections below this one.
#+end_comment
#+attr_shortcode: :depth 999 :sort title
#+begin_index
index
#+end_index
* Guix Server
:PROPERTIES:
:EXPORT_FILE_NAME: 000000-guix-server-(debian)
:EXPORT_HUGO_SLUG: guix-server-(debian)
:EXPORT_HUGO_WEIGHT: auto
:header-args: :results output :exports true :wrap stdout :dir /ssh:guixvm:tmp/guix
:END:

This org-babel session uses TRAMP to manage a Devian server named =guixvm= over SSH.

#+begin_src shell :async
sudo apt update
sudo apt install -y guix
guix pull
#+end_src

#+RESULTS:
: b4a9a7e62c351c350ea1ddcbc25e7db0

163 changes: 163 additions & 0 deletions notes/2025-01-09-12-01-20-emacs-keybindings.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#+hugo_base_dir: ../hugo
#+hugo_section: /notes/Emacs
#+hugo_weight: auto
#+hugo_paired_shortcodes: %notice badge button %children %index run stdout edit math mermaid openapi result expand
#+STARTUP: align

* Emacs
:PROPERTIES:
:EXPORT_FILE_NAME: _index
:EXPORT_HUGO_SLUG: _index
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :alwaysopen false
:END:
#+BEGIN_COMMENT
This is the default index for Emacs and it is boilerplate.
Don't write anything here.
This section will be overwriten by the template
(enigmacurry/org/notes/_template/note.o.txt).
Write your new top level sections below this one.
#+END_COMMENT
#+attr_shortcode: :depth 999 :sort title
#+begin_index
index
#+end_index


* Emacs Keybindings
:PROPERTIES:
:EXPORT_FILE_NAME: 000000-emacs-keybindings
:EXPORT_HUGO_SLUG: emacs-keybindings
:EXPORT_HUGO_WEIGHT: auto
:END:

Keybindings in Emacs are managed via [[https://github.com/noctuid/general.el][general.el]]:

* To show all of your documented bindings, press =C-h B= (=M-x
general-describe-keybindings=). Thankfully this does not show every
single binding, because that would be overwhelming. This only shows
those bindings that are documented in your [[https://github.com/EnigmaCurry/emacs/blob/straight/init.el][init.el]] via the
use-package =:general= config. Use =C-u C-h B= to filter the table
to the current buffer minor modes.

* To see a complete list of bindings for the current buffer, press
=C-h b= (=M-x describe-bindings=). This shows an exhaustive list,
but only for the current buffer modes.

As you learn new keybindings, you should document each one in your own
init.el, and then they will show up in the
=general-describe-keybindings= list. This way you can "own" the
default keybinding and it creates your own personalized cheat sheet:

#+begin_src emacs-lisp
;;; Example:
;;; Your custom global bindings for Emacs builtin functions::
(general-define-key
"C-h B" 'general-describe-keybindings
"s-b" 'quick-switch-buffer
"s-B" 'buffer-menu "C-x B" 'ibuffer-list-buffers
"s-o" 'browse-url
"C-;" 'comment-region ; C-u C-; to uncomment
"s-<down-mouse-1>" 'mouse-drag-region-rectangle)

;; The Emacs default bindings that you did not change, but you still
;; want to remember (these will show up in general-describe-keybindings):
(general-define-key
"M-SPC" 'cycle-spacing ; If you document it, you will use it.
"M-h" 'mark-paragraph ; C-h B is like your personal cheat sheet.
"C-h b" 'describe-bindings
"C-x 4 c" 'clone-indirect-buffer-other-window)

;; To create global keybindings for optional packages, do this inside
;; the use-package :general config:
(use-package amx
:general
("M-x" 'amx
"<menu>" 'amx))

;; You can customize the bindings of specific modes too:
(use-package paredit
:general
(:keymaps 'paredit-mode-map
"C-<right>" nil
"C-<left>" nil
"s-<right>" 'paredit-forward-barf-sexp
"s-<left>" 'paredit-forward-slurp-sexp))
#+end_src

Here we capture the =general-describe-keybindings= output in org-babel
block:

#+begin_src emacs-lisp :results value :exports true :wrap table
;; Capture Emacs general keybindings in org-mode block:
(with-temp-buffer
(let ((output-buffer (current-buffer)))
(with-current-buffer "*General Keybindings*"
(copy-to-buffer output-buffer (point-min) (point-max))))
;; prepend two spaces to every line to circumvent regular org-mode parsing:
(replace-regexp-in-string "^" " " (buffer-string)))
#+end_src

#+RESULTS:
#+begin_table
* Local Keybindings
* Global Keybindings
| key | command | previous |
|--------------------+--------------------------------------+--------------------------------------|
| =C-h B= | ~general-describe-keybindings~ | ~nil~ |
| =s-B= | ~buffer-menu~ | ~nil~ |
| =C-x B= | ~ibuffer-list-buffers~ | ~nil~ |
| =C-;= | ~comment-region~ | ~nil~ |
| =s-<down-mouse-1>= | ~mouse-drag-region-rectangle~ | ~nil~ |
| =M-SPC= | ~cycle-spacing~ | ~cycle-spacing~ |
| =M-h= | ~mark-paragraph~ | ~mark-paragraph~ |
| =C-h b= | ~describe-bindings~ | ~describe-bindings~ |
| =C-x 4 c= | ~clone-indirect-buffer-other-window~ | ~clone-indirect-buffer-other-window~ |
| =C-== | ~default-text-scale-increase~ | ~nil~ |
| =C--= | ~default-text-scale-decrease~ | ~negative-argument~ |
| =M-x= | ~amx~ | ~execute-extended-command~ |
| =<menu>= | ~amx~ | ~execute-extended-command~ |
| =M-y= | ~counsel-yank-pop~ | ~yank-pop~ |
| =s-b= | ~ivy-switch-buffer~ | ~quick-switch-buffer~ |
| =s-<up>= | ~org-previous-visible-heading~ | ~nil~ |
| =s-<down>= | ~org-next-visible-heading~ | ~nil~ |
| =C-c o k= | ~org-babel-remove-result~ | ~nil~ |
| =C-c g= | ~magit-status~ | ~nil~ |
| =s-s= | ~avy-goto-word-1~ | ~nil~ |
| =C-c s= | ~avy-goto-char~ | ~nil~ |
| =C-c S= | ~avy-goto-word-1~ | ~nil~ |
| =s-a= | ~lsp-execute-code-action~ | ~nil~ |
| =C-c t= | ~my-vterm-toggle~ | ~nil~ |
| =M-o= | ~ace-window~ | ~nil~ |
| =s-o= | ~ace-window~ | ~browse-url~ |
| =s-SPC= | ~set-rectangular-region-anchor~ | ~nil~ |
| =s-n= | ~mc/mark-next-like-this~ | ~nil~ |
| =s-N= | ~mc/mark-all-like-this~ | ~nil~ |
| =<f5>= | ~whisper-run~ | ~nil~ |
| =M-<f5>= | ~say-buffer-from-point~ | ~say-buffer-from-point~ |
| =C-c C-g= | ~gptel-menu~ | ~nil~ |

* Paredit-Mode-Map Keybindings
| key | command | previous |
|-------------+------------------------------+------------------------------|
| =C-<right>= | ~nil~ | ~paredit-forward-slurp-sexp~ |
| =C-<left>= | ~nil~ | ~paredit-forward-barf-sexp~ |
| =s-<right>= | ~paredit-forward-barf-sexp~ | ~nil~ |
| =s-<left>= | ~paredit-forward-slurp-sexp~ | ~nil~ |

* Gptel-Mode-Map Keybindings
| key | command | previous |
|-----------+--------------+----------|
| =C-c C-c= | ~gptel-send~ | ~nil~ |

* Dired-Mode-Map Keybindings
| key | command | previous |
|-----------+--------------------------+----------|
| =C-c C-q= | ~dired-toggle-read-only~ | ~nil~ |

* Emacs-Lisp-Mode-Map Keybindings
| key | command | previous |
|-------+------------------------+----------|
| =s-e= | ~eval-defun~ | ~nil~ |
| =M-;= | ~paredit-comment-dwim~ | ~nil~ |

#+end_table

0 comments on commit 76c2e67

Please sign in to comment.