Skip to content

Instantly share code, notes, and snippets.

@defaultxr
Last active January 8, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defaultxr/814ce4f5889471e408f205310d60d9b1 to your computer and use it in GitHub Desktop.
Save defaultxr/814ce4f5889471e408f205310d60d9b1 to your computer and use it in GitHub Desktop.
nanoish reference window for emacs
(defun make-nanoish-ref-buffer-and-window ()
"Create a buffer showing a reference of Emacs' standard shortcuts, and then display it at the bottom a la nano."
(interactive)
;; ensure the rules for displaying the window are set up.
(setq display-buffer-alist (assoc-delete-all "*nanoish-ref*" display-buffer-alist #'equal))
(push '("*nanoish-ref*"
(display-buffer-at-bottom)
(window-height . 2)
(preserve-size . (nil . t))
(dedicated . t)
(window-parameters . ((no-other-window . t)
(no-delete-other-windws . t)
(mode-line-format . none))))
display-buffer-alist)
;; create the buffer
(let ((buf (get-buffer-create "*nanoish-ref*")))
(with-current-buffer buf
(delete-region (point-min) (point-max))
(insert "[C-n] next line [C-p] previous line [C-v] page down [C-l] recenter [C-w] kill (cut) [C-y] yank (paste) [C-g] cancel [C-h k] key help [C-x C-f] open file [C-x k] kill buffer [C-x 1] one window [C-x 2] split vertically" ?\n
"[C-f] forward char [C-b] backward char [M-v] page up [C-k] kill line [M-w] kill (copy) [C-s] search [M-x] command [C-h f] function help [C-x b] switch buffer [C-x o] next window [C-x 0] delete window [C-x 3] split horizontally"))
;; display it!
(display-buffer buf)))
(make-nanoish-ref-buffer-and-window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment