Skip to content

Latest commit

 

History

History
100 lines (79 loc) · 2.83 KB

emacs-f2.org

File metadata and controls

100 lines (79 loc) · 2.83 KB

F2 Keybindings for Emacs

Pairs

While M-' inserts a pair of single quotes, I would also like to insert a pair of unicode quotes:

(defun insert-single-quotes (p)
  "Inserts a pair of unicode rounded quotes, `SINGLE TURNED COMMA
QUOTATION MARK' and `SINGLE COMMA QUOTATION MARK'."
  (interactive "P")
  (insert-pair p 8216 8217))

(defun insert-double-quotes (p)
  "Inserts a pair of unicode double rounded quotes."
  (interactive "P")
  (insert-pair p 8220 8221))

(bind-key "M-C-'"  #'insert-single-quotes)  ; ‘Nice!’
(bind-key "M-C-\"" #'insert-double-quotes)  ; “Goody”

Unicode Characters

The F2 is used to enter odd characters not normally available or phrases I want to type a bit too often.

(mapc (lambda (tuple)
        (define-key key-translation-map
            (kbd (concat "<f2> " (nth 0 tuple))) ; Keybinding
            (kbd (nth 1 tuple))))                ; Character to insert
      '(("<up>" "")
        ("<down>" "")
        ("<left>" "")
        ("<right>" "")
        ("S-<up>" "")
        ("S-<down>" "")
        ("S-<left>" "")
        ("S-<right>" "")

        ("p" "")   ;; Representation of a cursor
        ("'" "")
        ("\"" "")

        ("8" "")
        ("*" "°")
        ("d" "")
        ("D" "")
        ("-" "")
        ("." "")
        (";" "😉")
        (")" "")

        ("a" "α")   ;; Lowercase Greek is uppercase
        ("b" "β")
        ("e" "ε")
        ("l" "λ")
        ("p" "π")
        ("m" "μ")
        ("t" "θ")

        ("!" "¹")   ; For footnotes and things
        ("@" "²")
        ("#" "³")
        ("$" "")

        ("2" "½")   ; Fractions
        ("3" "")
        ("4" "¼")))

Technical Artifacts

Make sure that we can simply require this library.

(provide 'init-f2)

Before you can build this on a new system, make sure that you put the cursor over any of these properties, and hit: C-c C-c