Skip to content

Instantly share code, notes, and snippets.

@tkurtbond
Last active July 12, 2021 07:10
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 tkurtbond/3dad54a2141422f39033533e72f53110 to your computer and use it in GitHub Desktop.
Save tkurtbond/3dad54a2141422f39033533e72f53110 to your computer and use it in GitHub Desktop.
A small minor mode for easily entering Unicode double and single quotes, em and en dashes, and horizontal ellipses.
;; look at https://github.com/ndw/xmlunicode for xmlunicode.el
;; xmlunicode-character-list.el. xmlunicode.el provides the
;; "smart-unicode-*" functions.
(load-library "unichars")
(load-library "xmlunicode")
(defun tkb-describe-character (before)
"Describe the character after point (before if a prefix was specified)
if it is a unicode character."
(interactive "P")
(let* ((char (if before (char-before) (char-after)))
(info (assoc (encode-char char 'ucs) unicode-character-list))
(info (cons (format "#x%X" (car info)) info)))
(message "%S" info)))
(tkb-keys ((kbd "C-c k d") #'tkb-describe-character))
(define-minor-mode tkb-smart-unicode-mode
"Toggle smart unicode punctuation" nil " ♻⚔☣☥☸◉⅙✽☮" ; "✘▧▧⚅☑☢☹☺♠♥♦♣♨"
'(("\"" . unicode-smart-double-quote)
("'" . unicode-smart-single-quote)
("-" . unicode-smart-hyphen)
("." . unicode-smart-period)))
(defadvice unicode-smart-hyphen (after tkb-after-unicode-smart-hyphen last
activate compile)
(tkb-describe-character t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment