all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.