unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
@ 2022-05-29 13:39 Lars Ingebrigtsen
  2022-05-29 14:12 ` Visuwesh
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-29 13:39 UTC (permalink / raw)
  To: 55704


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






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
  2022-05-29 13:39 bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs Lars Ingebrigtsen
@ 2022-05-29 14:12 ` Visuwesh
  2022-05-29 14:18   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Visuwesh @ 2022-05-29 14:12 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55704

[ஞாயிறு மே 29, 2022] Lars Ingebrigtsen wrote:

> 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.
>

If I'm not mistaken, isn't this already done by the compose input
method?  The commentary says,

    ;;; Commentary:

    ;; This input method supports the same key sequences as defined by the
    ;; standard X Multi_key: https://en.wikipedia.org/wiki/Compose_key

    ;; You can enable this input method transiently with `C-u C-x \ compose RET'.
    ;; Then typing `C-x \' will enable this input method temporarily, and
    ;; after typing a key sequence it will be disabled.  So typing
    ;; e.g. `C-x \ E =' will insert the Euro sign character, and disable
    ;; this input method automatically afterwards.

>[...]





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
  2022-05-29 14:12 ` Visuwesh
@ 2022-05-29 14:18   ` Lars Ingebrigtsen
  2022-05-29 16:09     ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-29 14:18 UTC (permalink / raw)
  To: Visuwesh; +Cc: 55704

Visuwesh <visuweshm@gmail.com> writes:

> If I'm not mistaken, isn't this already done by the compose input
> method?  The commentary says,
>
>     ;;; Commentary:
>
>     ;; This input method supports the same key sequences as defined by the
>     ;; standard X Multi_key: https://en.wikipedia.org/wiki/Compose_key

Oh, so it is.

I guess the only question is whether to parse the XKB files
automatically and possibly add the `C-+' command...

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
  2022-05-29 14:18   ` Lars Ingebrigtsen
@ 2022-05-29 16:09     ` Juri Linkov
  2022-05-29 16:33       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2022-05-29 16:09 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 55704, Visuwesh

>> If I'm not mistaken, isn't this already done by the compose input
>> method?  The commentary says,
>>
>>     ;;; Commentary:
>>
>>     ;; This input method supports the same key sequences as defined by the
>>     ;; standard X Multi_key: https://en.wikipedia.org/wiki/Compose_key
>
> Oh, so it is.
>
> I guess the only question is whether to parse the XKB files
> automatically and possibly add the `C-+' command...

I don't see the need to parse the XKB files - they are not changed
too often.  And the key was already added as `C-x \'.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs
  2022-05-29 16:09     ` Juri Linkov
@ 2022-05-29 16:33       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-29 16:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 55704, Visuwesh

Juri Linkov <juri@linkov.net> writes:

> I don't see the need to parse the XKB files - they are not changed
> too often.  And the key was already added as `C-x \'.

Okidoke; I'm closing this bug report, then.  😀

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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-29 16:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-29 13:39 bug#55704: 29.0.50; Wishlist: Add a command to use XKB "Compose" sequences in Emacs Lars Ingebrigtsen
2022-05-29 14:12 ` Visuwesh
2022-05-29 14:18   ` Lars Ingebrigtsen
2022-05-29 16:09     ` Juri Linkov
2022-05-29 16:33       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).