all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: 55704@debbugs.gnu.org
Subject: bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
Date: Sun, 29 May 2022 15:39:38 +0200	[thread overview]
Message-ID: <87sfoszcdh.fsf@gnus.org> (raw)


This spins out of bug#43866.

Juri posted the code below, and Eli then made the point that we should
pre-generate this data from the two files that are being parsed.

I think that sounds like a good idea (i.e., we'd include the two files
and then have a Lisp snippet that transforms it into an .el file, as we
do with other similar data files).

And I think using `C-+' sounds fine, too.

--------


Here's is a working implementation.  It binds all key sequences to the key
'C-+' that has the mnemonics of adding a character.  'C-+' is free because
it can't be used to zoom text since its counterpart key 'C--' is already
taken to input numeric arguments.  'C-+ C-+' is bound to 'insert-char'
like the current longer key sequence 'C-x 8 RET' that is hard to type.

;;; x-compose.el --- Compose input method from X11   -*- lexical-binding: t; -*-

(defvar x-compose-keymap
  (let ((map (make-sparse-keymap)))
    (let ((keysymdef (make-hash-table :test 'equal)))
      (with-temp-buffer
        (insert-file-contents "/usr/include/X11/keysymdef.h")
        (while (re-search-forward "^#define XK_\\(\\S-+\\).+/\\* U\\+\\(\\w+\\)" nil t)
          (puthash (match-string 1) (match-string 2) keysymdef)))
      (with-temp-buffer
        (insert-file-contents "/usr/share/X11/locale/en_US.UTF-8/Compose")
        (while (re-search-forward "^<Multi_key> \\([^:]+\\): \"\\([^\"]+\\)\"" nil t)
          (let* ((to-char (string-to-char (match-string 2)))
                 (from-keys (match-string 1))
                 (from-chars
                  (mapcar (lambda (s)
                            (if (string-match "^U\\([[:xdigit:]]+\\)" s)
                                (string-to-number (match-string 1 s) 16)
                              (string-to-number (gethash s keysymdef "0000") 16)))
                          (split-string from-keys "[<> \t]+" t))))
            (unless (memq 0 from-chars)
              (define-key map (apply 'vector from-chars) (vector to-char)))))))
    map)
  "Keymap for keys of the Compose input method.")

(define-key key-translation-map [(control ?+)] x-compose-keymap)
(global-set-key [(control ?+) (control ?+)] 'insert-char)

(provide 'x-compose)
;;; x-compose.el ends here



In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2022-05-17 built on xo
Repository revision: 803041e01474f2a522170c9f388068e8460be2ae
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






             reply	other threads:[~2022-05-29 13:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-29 13:39 Lars Ingebrigtsen [this message]
2022-05-29 14:12 ` bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs Visuwesh
2022-05-29 14:18   ` Lars Ingebrigtsen
2022-05-29 16:09     ` Juri Linkov
2022-05-29 16:33       ` Lars Ingebrigtsen

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=87sfoszcdh.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=55704@debbugs.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.