unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Migration from define-key to bind-key with prefix-command
@ 2015-11-09 12:55 Karl Voit
  2015-11-09 18:12 ` Alex Kost
  0 siblings, 1 reply; 4+ messages in thread
From: Karl Voit @ 2015-11-09 12:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

How can I define "define-key" commands with a global prefix-command to
bind-key(s) syntax?

I don't want to loose the ability to change my global prefix "my-map"
to a different one on one single place. I also want to keep my habit
of defining key bindings on many different places scattered all over
my init file and not on one single spot.

What I do have in my Emacs initialization file(s):

#+BEGIN_SRC elisp
(define-prefix-command 'my-map)
(global-set-key (kbd "C-c C-,") 'my-map)
(global-set-key (kbd "C-c ,") 'my-map)

[...]

;; scale text size (C-c C-, +/-)
(define-key my-map "-" 'text-scale-decrease)
(define-key my-map "+" 'text-scale-increase)

[...]

;; remove trailing whitespaces (C-c C-, " ")
(define-key my-map " " 'delete-trailing-whitespace)
#+END_SRC

What I think of (in totally wrong Elisp):

#+BEGIN_SRC elisp
(define-prefix-command 'my-map)
(global-set-key (kbd "C-c C-,") 'my-map)
(global-set-key (kbd "C-c ,") 'my-map)

[...]

;; scale text size (C-c C-, +/-)
(my-bind-key my-map "-" 'text-scale-decrease)
(my-bind-key my-map "+" 'text-scale-increase)

[...]

;; remove trailing whitespaces (C-c C-, " ")
(my-bind-key my-map " " 'delete-trailing-whitespace)
#+END_SRC

Or do I have to change my habits, get rid of my unified prefix
(my-map), and use define-key with repeating "C-c C-," prefix?

Thanks!


-- 
All in all, one of the most disturbing things today is the definitive
fact that the NSA, GCHQ, and many more government organizations are
massively terrorizing the freedom of us and the next generations.
                                                  http://Karl-Voit.at




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

end of thread, other threads:[~2015-11-10 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-09 12:55 Migration from define-key to bind-key with prefix-command Karl Voit
2015-11-09 18:12 ` Alex Kost
2015-11-10 12:54   ` Karl Voit
2015-11-10 21:53     ` Emanuel Berg

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