all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Software (Elisp) compose key
Date: Fri, 20 Dec 2013 00:15:02 +0100	[thread overview]
Message-ID: <87zjnwzb3k.fsf@nl106-137-194.student.uu.se> (raw)

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


                 reply	other threads:[~2013-12-19 23:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjnwzb3k.fsf@nl106-137-194.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.