From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Software (Elisp) compose key Date: Fri, 20 Dec 2013 00:15:02 +0100 Organization: Aioe.org NNTP Server Message-ID: <87zjnwzb3k.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1387495217 29619 80.91.229.3 (19 Dec 2013 23:20:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Dec 2013 23:20:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 20 00:20:23 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VtmtB-0003pW-K7 for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Dec 2013 00:20:21 +0100 Original-Received: from localhost ([::1]:46851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtmtB-0003KO-4p for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Dec 2013 18:20:21 -0500 X-Received: by 10.180.105.68 with SMTP id gk4mr2614838wib.0.1387494929320; Thu, 19 Dec 2013 15:15:29 -0800 (PST) Original-Path: usenet.stanford.edu!i6no882159wiy.1!news-out.google.com!h6ni12275wiy.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 79 Original-NNTP-Posting-Host: VVbyYd/iFZoeWNmD9i++cQ.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:J3RI7jPxsoMa1jsDeHJ4qgIze4I= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:202831 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95101 Archived-At: 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