[Arcana] extending input methods in emacs sucks
kfogel at red-bean.com
Thu Feb 12 21:49:16 CST 2009
Noah Friedman <friedman at splode.com> writes:
> There is a babel of different input method systems in emacs. A lot of them
> use "quail". Some are more direct (e.g. `ucs'). Some of them I just can't
> tell how they work.
> Anyway. All I wanted was to be able to type a euro symbol without having
> to remember what its unicode character number was. I usually use the
> rfc1345 input method, but of course the euro isn't defined in that.
> And as long as I was adding currency symbols, I wanted a common mnemonic
> prefix for all of them since I couldn't remember the others either.
> This is my completely graceless solution.
Wow. I just wrote functions and use M-x when I need odd symbols:
(defun kf-euro ()
"This is insane. I should really learn The Right Way to do this in Emacs."
;; (insert 342604) would work too, heh
(defun kf-顿号 ()
"And you thought `kf-euro' was insane!"
;; (insert 53410) would work too, heh
> ;; This is a macro so it can be used with approximately the same syntax as
> ;; quail-define-rules.
> (defmacro quail-annotate-input-method (method &rest bindings)
> "Add new bindings to quail-based input methods"
> (when (symbolp method)
> (setq method (symbol-name method)))
> (require 'quail)
> (unless (assoc ,method quail-package-alist)
> (load ,(format "quail/%s" method)))
> (let ((quail-orig (quail-name)))
> (quail-select-package ,method)
> (quail-define-rules ((append t)) , at bindings))
> (when quail-orig
> (quail-select-package quail-orig))))))
> ;; Put all the common currency symbols on a "&$" prefix.
> ;; Calling decode-char is a no-op in emacs 23, but emacs 22 doesn't use ucs
> ;; native coding.
> (eval-after-load 'rfc1345
> '(let ((bindings (mapcar (lambda (p)
> (list (car p) (decode-char 'ucs (cadr p))))
> '(("&$c" #x00a2) ; cent
> ("&$p" #x00a3) ; british pound
> ("&$u" #x00a4) ; generic currency sign
> ("&$y" #x00a5) ; yen
> ("&$e" #x20ac) ; euro
> ;; macro application for the lose
> (eval `(quail-annotate-input-method rfc1345 , at bindings))))
> Arcana mailing list
> Arcana at red-bean.com
More information about the Arcana