help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-[ is undefined


From: Michael Brand
Subject: Re: C-[ is undefined
Date: Sun, 19 Aug 2018 18:02:39 +0200

Hi all

On Sun, Jul 29, 2018 at 1:40 AM, Michael Brand
<michael.ch.brand@gmail.com> wrote:

> According to the comment from Stefan in this thread I tried
> event-apply-modifier as
>
> #+begin_src emacs-lisp
>   (defun event-apply-modifier (event symbol lshiftby prefix)
>     "[...]"
>     (if (numberp event)
>         (cond ((eq symbol 'control)
>                (cond
>                 ;; C0 control characters (0 to 31, except 127).
>                 ((<= ?@ event ?_)
>                  (- event ?@))
>                 ;; A to Z from above as a to z.
>                 ((<= ?a event ?z)
>                  (- event ?a -1))
>                 (t
>                  (logior (lsh 1 lshiftby) event))))
>               ((eq symbol 'shift)
>                (if (<= ?a (downcase event) ?z)
>                    (upcase event)
>                  (logior (lsh 1 lshiftby) event)))
>               (t
>                (logior (lsh 1 lshiftby) event)))
>       (if (memq symbol (event-modifiers event))
>           event
>         (let ((event-type (if (symbolp event) event (car event))))
>           (setq event-type (intern (concat prefix (symbol-name event-type))))
>           (if (symbolp event)
>               event-type
>             (cons event-type (cdr event)))))))
> #+end_src
>
> and it solves the issue for:
>
> - The minimal complete example with ~C-x @ c [ t~ for ~M-t~, ~C-x @ c
>   [ u~ for ~M-u~ and so on.
>
> - My use case with key-chord-mode ~en [ t~ for ~M-t~, ~en [ u~ for
>   ~M-u~ and so on. (I will try to change my current key chord ~en~ for
>   event-apply-control-modifier to ~[[~ so that quickly typing ~[[~ will
>   be the Control modifier and ~[[[~ will be the Meta modifier).

I have been using ~[[~ for the Control modifier and ~[[[~ for the Meta
modifier or ESC with the above modification of ~event-apply-modifier~
for some time
now and I like it. (If anyone wants to know more or try it out get
key-chord.el http://www.emacswiki.org/emacs/KeyChord and my setup
http://github.com/brandm/emacs.d)

Now I would like to know how to proceed with ~event-apply-modifier~:

1) Should I use an advice for this function?

2) Should there be a configuration to choose between the original, the
above and possibly even more different function behaviors?

3) Should the function be changed to something similar to the above?
What to tell the users that rely on the current behavior?

Michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]