[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Software (Elisp) compose key

From: Emanuel Berg
Subject: Software (Elisp) compose key
Date: Fri, 20 Dec 2013 00:15:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

I have implemented a compose key in Elisp. It is
actually better than a "real" compose key, because it
"holds" until a valid char comes so, if

[compose] + a = ä


[compose] har  =
h [compose] ar =

The code (more talk after, if you are still reading):

(defun compose-disable-all-followups (mode-map key-to-revert-l)
  (dolist (key-to-revert key-to-revert-l)
    (let ((key    (car   key-to-revert))
          (revert (nth 2 key-to-revert)))
      (define-key mode-map key revert) )))

(defun compose-followup-key (mode-map key-to-revert-l)
  (dolist (key-to-revert key-to-revert-l)
    (let ((key    (car   key-to-revert))
          (to     (nth 1 key-to-revert))
          (revert (nth 2 key-to-revert)))
      (define-key (symbol-value mode-map) key
        `(lambda ()
           (insert ,to)
            ',key-to-revert-l ))))))

(defun activate-semi-colon-compose-key ()
   '(("A" "Ä" self-insert-command)
     ("a" "ä" self-insert-command)
     ("O" "Ö" self-insert-command)
     ("o" "ö" self-insert-command)
     (":" "Å" self-insert-command)
     (";" "å" activate-semi-colon-compose-key) )))

(define-key text-mode-map ";" 'activate-semi-colon-compose-key)

I wanted it to be close, so I picked the semi-colon as
the console key. It is the right little finger when the
right hand is in typing position.

The semi-colon is used in Swedish as 1) a "soft full
stop" and 2) a subdivider in lists - but I never used
it for either (or anything else) so I don't think I'll
miss it.

As for the setup, I wanted it to be intuitive: ;a = ä,
and ;o = ö (same for uppercase) - for å, I couldn't
come up with something intuitive - 0 (zero) perhaps,
but then the uppercase (right paren) wouldn't make
sense. So I decided if it can't be intuitive, it can
still be close and fast: ;; = å, ;: = Å.

Also, if you cannot have the key at *one* hit - you
should get it with the second best, namely two.

Last, I didn't want it to put any character in the
buffer except the desired char, not even
temporarily. Also, it shouldn't show anything in the
echo area. (But I get that that can be useful for more
complicated strokes.)

There is no interface to it, but it is easy to specify
key, rules, and mode, in Elisp (the true interface).

Check it out :)

Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]