unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Getting magic numbers 134217734 etc in a repetable keymap
@ 2021-04-03  6:20 Ramesh Nedunchezian
  2021-04-03  7:32 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ramesh Nedunchezian @ 2021-04-03  6:20 UTC (permalink / raw)
  To: emacs-devel


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.



(setq sexp--repeat-map
      '(keymap
	;; How can I get 134217734 here?
	
	;; (define-key sexp--repeat-map (kbd "C-M-f") 'forward-sexp)
	;; puts a nested list in keymap

	;; The numerical vaues here are values of `last-command-event'  in
	;; `repeat-post-hook'
	(134217734 . forward-sexp)
	(134217730 . backward-sexp)
	(134217729 . beginning-of-defun)
	(134217733 . end-of-defun)
	(134217732 . down-list)
	(134217749 . backward-up-list)

	;; I can get 102 here with
	;;   (define-key sexp--repeat-map "f" 'forward-sexp)
	(102 . forward-sexp)
	(98 . backward-sexp)
	(97 . beginning-of-defun)
	(101 . end-of-defun)
	(100 . down-list)
	(117 . backward-up-list)))

(progn
  (put 'forward-sexp 'repeat-map 'sexp--repeat-map)
  (put 'backward-sexp 'repeat-map 'sexp--repeat-map)
  (put 'beginning-of-defun 'repeat-map 'sexp--repeat-map)
  (put 'end-of-defun 'repeat-map 'sexp--repeat-map)
  (put 'down-list 'repeat-map 'sexp--repeat-map)
  (put 'backward-up-list 'repeat-map 'sexp--repeat-map))

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

FWIW, to convert C-M-f to 102, I used this

    (vector
     (event-basic-type
      (car
       (listify-key-sequence
	(kbd "C-M-f")))))












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

end of thread, other threads:[~2021-04-05 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03  6:20 Getting magic numbers 134217734 etc in a repetable keymap Ramesh Nedunchezian
2021-04-03  7:32 ` Eli Zaretskii
2021-04-03 11:58   ` Ramesh Nedunchezian
2021-04-03 13:14     ` Eli Zaretskii
2021-04-03 15:14       ` Ramesh Nedunchezian
2021-04-03  8:16 ` Andreas Schwab
2021-04-05 20:47 ` Juri Linkov

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