emacs-devel
[Top][All Lists]
Advanced

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

Re: Getting magic numbers 134217734 etc in a repetable keymap


From: Ramesh Nedunchezian
Subject: Re: Getting magic numbers 134217734 etc in a repetable keymap
Date: Sat, 3 Apr 2021 17:28:12 +0530
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0


On 03/04/21 1:02 pm, Eli Zaretskii wrote:
>> From: Ramesh Nedunchezian <rameshnedunchezian@outlook.com>
>> Date: Sat, 3 Apr 2021 11:50:50 +0530
>>
>> I would like to create a repeatable keymap which has magic number
>> 134217734 etc in it using either `define-key' or any other API.
>>
>> I have tried the following, and it desn't work
>>
>>     (define-key sexp--repeat-map
>>       (vector
>>        (car
>>      (listify-key-sequence
>>       (kbd "C-M-f"))))
>>       'forward-sexp)
>>
>> Getting numbers like 134217734 etc in to the repeatable keymap are
>> important for successful setting up of repetition. That is, for
>> repetition to succeed, the condition below in `repeat-post-hook' need
>> to succeed.
>>
>>     (or (memq last-command-event keys)
>>      (memq this-original-command '(universal-argument
>>                                    universal-argument-more
>>                                    digit-argument
>>                                    negative-argument)))
>>
>> ... and when I invoke C-M-f `last-command-event' comes out as 134217734.
>>
>> ----------------
>>
>> For now I have hard-coded `sexp--repeat-map' as below, and this works
>> as expected.  But I want a cleaner and less-hackish recipe for achieving the 
>> same.
> 
> Display the "magic" numbers in hex, and I think you will see the way
> clearly.
> 

I am dumb.  I unable to take your hint.  Can I have a full
recipe.

Getting the magic value of C-M-f is not an issue.

But, getting the magic number _verbatim_ in to the _repeat-map__ is
the issue.  Note the emphasis on words "verbatim" and "repeat-map".

i.e., I want a recipe which will create this keymap

  '(keymap
          (134217734 . forward-sexp)
          ;; (102 . forward-sexp)
          )

instead of the

  (keymap
   (27 keymap
       (6 . forward-sexp)))

i.e. The problem with `define-key' is that it is converting C-M-f in
to ESC C-f and this 2-level keymap I DO NOT want.  The two level
keymap gets in the way of setting up a repeatable keymap which will
help me do C-M-f f f f f etc.

To  summarize, I want the "not ok" to be fixed.

  (progn
    (defvar test-repeat-map
      (let
          ((map
            (make-sparse-keymap)))
        map)
      "Keymap used to repeatedly invoke  `forward-sexp' with C-M-f f f f .....")
    (cl-loop for
             (cmd . key)
             in
             '((forward-sexp .
                             [134217734]) ;; Not ok
               (forward-sexp . "f"))
             do
             (define-key test-repeat-map key cmd)
             (put cmd 'repeat-map 'test-repeat-map))
    test-repeat-map)

----------------

This is the crux of my problem, and it appears in the context of
newly introduced `repeat-mode' feature.

  Getting numbers like 134217734 etc in to the repeatable keymap are
  important for successful setting up of repetition. That is, for
  repetition to succeed, the condition below in `repeat-post-hook' need
  to succeed.

      (or (memq last-command-event keys)
          (memq this-original-command '(universal-argument
                                        universal-argument-more
                                        digit-argument
                                        negative-argument)))

  ... and when I invoke C-M-f `last-command-event' comes out as 134217734.




reply via email to

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