All pastes #2047200 Raw Edit

bkuhn's Emacs unicode

public text v1 · immutable
#2047200 ·published 2011-04-16 17:42 UTC
rendered paste body

(defun bkuhn/unicode-insert (char)
  "Read a unicode code point and insert said character.
    Input uses `read-quoted-char-radix'.  If you want to copy
    the values from the Unicode charts, you should set it to 16."
  (interactive (list (read-quoted-char "Char: ")))
  (ucs-insert char))


(setq bkuhn/unicode-chars-of-interest-map '(
      ("degrees-fahrenheit" . "2109")
      ("degrees-celsius" . "2103")
      ("not-equal" . "2260")
      ("mdash" . "2014")
      ("pi-small" . "03C0") ("scissors" . "2702")
      ("smiley" . "263A") ("frown" . "2639") ("recycle" . "267B")
      ("spade" . "2660") ("heart" . "2665") ("diamond" . "2666")
      ("club" . "2663") ("coffee" . "2615") ("poison" . "2620")
      ("euro" . "20AC") ("pound" . "00A3") ("yen" . "00A5")
      ("times" . "00D7 ")  ("alpha" . "03B1") ("beta" . "03B2")
      ("cloud" . "2601") ("umbrella" . "2602") ("box-checked" . "2611")
      ("comet" . "2604")  ("poo" . "1F4A9") ("paragraph" . "00b6")
      ("sep-paragraph" . "2909") ("notes-eighth" . "266B")
      ("notes-sixteenth" . "266C") ("notes-quarter" . "2669")
      ("fraction-quarter" . "00BC")
      ("half" . "00BD") ("not-equal" . "2260")
      ("snowman" . "2603") ("umbrella-with-rain" . "2614") ("forall" . "2200")
      ("exists" . "2203") ("exists-not" . "2204") ("left-arrow" . "2192")
      ("right-double-arrow" . "21D2")
      ("hat" . "1F3A9") ("trademark". "2122") 
      ("gamma" . "03B4") ("delta" . "03B5") ("hellip" . "2026")
      ("union" . "222A") ("intersect" . "2229") ("approx-equal" . "2248")
      ("telephone-black" . "260E") ("telephone-white" . "260F")
      ("therefore" . "2234")   	("because" . "2235") ("micro" . "00B5")
      ("infinity" . "221E") ("airplane" . "2708") ("envelope" . "2709") ("checkmark" . "2714") ("coffin" . "26AD") ("section" . "00A7")
      ("peace" . "262E") ("copyright" . "00A9")))

(defun bkuhn/unicode-get-char-by-name (val) (cdr (assoc val bkuhn/unicode-chars-of-interest-map)))
(defun bkuhn/unicode-insert-char-by-name (val) (bkuhn/unicode-insert (bkuhn/unicode-get-char-by-name val)))

(defun bkuhn/insert-unicode-char-by-name-interactive ()
  (interactive)
 (let ((name (completing-read "Unicode character: "
                  (mapcar 'car bkuhn/unicode-chars-of-interest-map))))
   (bkuhn/unicode-insert-char-by-name name)))