Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A small minor mode for easily entering Unicode double and single quotes, em and en dashes, and horizontal ellipses.
;; look at 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