all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Software (Elisp) compose key
@ 2013-12-19 23:15 Emanuel Berg
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2013-12-19 23:15 UTC (permalink / raw
  To: help-gnu-emacs

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 = ä

then

[compose] har  =
h [compose] ar =
här

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 ()
           (interactive)
           (insert ,to)
           (compose-disable-all-followups
            ,mode-map
            ',key-to-revert-l ))))))

(defun activate-semi-colon-compose-key ()
  (interactive)
  (compose-followup-key
   'text-mode-map
   '(("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:  http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-19 23:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 23:15 Software (Elisp) compose key Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.