Here's a visual layout of the default keybinds in emacs:
http://xahlee.org/emacs/emacs_kb_shortcuts.html
A important aspect in designing default keyboard shortcuts is have kb
shortcuts for the most frequently used commands, and, the top most
frequently used commands should have most easily-pressed keystrokes.
For example, they should be on the home row.
Use this program to compute the command frequency of your emacs use.
http://xahlee.org/emacs/command-frequency.el
Once you have accumulated 20k runs of self-insert-command, please send
me the results.
I hope to comile some stats. I will do a report here when i get
results.
Thanks.
Xah
···@xahlee.org
∑ http://xahlee.org/
Of interest!
(global-set-key (kbd "M-<left>") 'previous-user-buffer)
(global-set-key (kbd "M-<right>") 'next-user-buffer)
(global-set-key (kbd "M-S-<left>") 'previous-emacs-buffer)
(global-set-key (kbd "M-S-<right>") 'next-emacs-buffer)
(defun next-user-buffer ()
"Switch to the next user buffer in cyclic order.\n
User buffers are those not starting with *."
(interactive)
(next-buffer)
(let ((i 0))
(while (and (string-match "^*" (buffer-name)) (< i 10))
(setq i (1+ i)) (next-buffer) )))
(defun previous-user-buffer ()
"Switch to the next user buffer in cyclic order.\n
User buffers are those not starting with *."
(interactive)
(previous-buffer)
(let ((i 0))
(while (and (string-match "^*" (buffer-name)) (< i 10))
(setq i (1+ i)) (previous-buffer) )))
(defun next-emacs-buffer ()
"Switch to the next emacs buffer in cyclic order.\n
Emacs buffers are those starting with *."
(interactive)
(next-buffer)
(let ((i 0))
(while (and (not (string-match "^*" (buffer-name))) (< i 10))
(setq i (1+ i)) (next-buffer) )))
(defun previous-emacs-buffer ()
"Switch to the next user buffer in cyclic order.\n
Emacs buffers are those starting with *."
(interactive)
(previous-buffer)
(let ((i 0))
(while (and (not (string-match "^*" (buffer-name))) (< i 10))
(setq i (1+ i)) (previous-buffer) )))
Xah
···@xahlee.org
∑ http://xahlee.org/
"Xah Lee" <···@xahlee.org> writes:
> Of interest!
>
In Emacs 22:
,----[ C-h f next-buffer RET ]
| next-buffer is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x <C-right>, C-x <right>, <menu-bar> <buffer> <next-buffer>.
| (next-buffer)
|
| Switch to the next buffer in cyclic order.
`----
,----[ C-h f previous-buffer RET ]
| previous-buffer is an interactive compiled Lisp function in `simple.el'.
| It is bound to C-x <C-left>, C-x <left>, <menu-bar> <buffer> <previous-buffer>.
| (previous-buffer)
|
| Switch to the previous buffer in cyclic order.
|
| [back]
`----
There is also already cyclebuffer.el.
http://www.emacswiki.org/cgi-bin/wiki/CycleBuffer
--
-John Sullivan
-http://www.wjsullivan.net
-GPG Key: AE8600B6
Raoul Gough wrote:
«I've begun to notice that C-x is really quite awkward for me to type
(this is on a US QWERTY layout). My usual finger positions for this
key-chord are left little finger on CTRL and left middle on X, which
puts the left middle finger under an unusual strain since it's cramped
up diagonally. Any ideas on improving this situation?»
Thanks for reminding me of this extremely fucked emacs design, which
has escaped my notice.
The need to press x with modifiers, is the single most frequently
needed operation in emacs. This is so critical that the command
frequency list doesn't even bring the issue up, since these prefix
keystrokes are needed to call up any command.
The Control-x is possibly the most awkward key combination on a
standard keyboard, and unfortunately, it is the key strokes that emacs
wants people to use the most. It is in fact, the sole contribution to
the well-known “emacs pinky” repetitive strain injury, and is one
of the main driving force for people to detest emacs.
Given that we are stuck with the C-x (at least for now), for a article
on How To Avoid The Emacs Pinky Problem, see
http://xahlee.org/emacs/emacs_pinky.html
In short, one of the most important thing is that you should use a
proper keyboard with large modifier keys, and with them positioned on
both sides of the keyboard in a symmetric way to the left/right home
keys, so that the right side set are actually touch-type functional.
(keyboard layout and the physical keyboard design are the other
extremely fucked up products of shameless fuckers in our society (and
supported as a side effect of political struggle by our tech geekers.
That's why we still have it to this day.))
Many people, as a sloppy work-around with the emacs pinky problem,
swaps the conventional positions of the left Control key and Cap Lock
key. This does work as a work around, but is not a solution as tech
geekers drivels about.
As we have discussed before, the most used commands must have the most
easy-to-type keystrokes. The C-x, as a prefix keystroke for calling
emacs command, therefore must have the most easy to type.
Assume that we are given the physical design of a conventional keyboard
and the common qwerty layout, then the most comfortable key combo for
the control combination would be one of the DF or JK keys, both are
under the home row pressed by the index and middle fingers. And given
that most keyboards don't have a touch-type-functional right set
Control and Meta keys, therefore JK would be the optimal choices for
the command prefix keys. (so that, the left hand can hold down the
modifier keys, and the other hand, can press J or K. Between the
choices of J vs K, K is probably better since the longer middle finger
makes it more comfortable to type. Therefore, C-x and M-x really should
be C-t and M-k.
On the dvorak keyboard (which is one major fix up of the fucked
keyboard layout that is qwerty which by itself contributed to endless
hand injuries), the right hand index finger's key is T. Thus, on the
dvorak layout, the C-x should be C-t.
(Note: if you are using dvorak, the x is the qwerty's b, so that you
can type C-x by having your left hand hold down control on the left
side, and right hand's index finger moves to the lower left to press
the x. However, this won't work if you are using a Split Keyboard
(which is a major fix up to the fucked up physical keyboard design). On
a split keyboard, the Qwerty's B is on the left side of the keyboard,
and is very awkward to press C-b either with left hand itself or both
left and right hands. (photo here
http://xahlee.org/emacs/i/ms_wnm_keyboard.jpg ))
I use a Dvorak keyboard layout. I use a split key physical keyboard. I
have C-x remapped to C-t.
Please see also:
Modernization of Emacs
http://xahlee.org/emacs/modernization.html
Xah
···@xahlee.org
∑ http://xahlee.org/
From: Jochem Huhmann
Subject: Re: Emacs's Command Frequency and default keyboard shortcuts
Date:
Message-ID: <m2slhnt8z7.fsf@marvin.revier.com>
"Xah Lee" <···@xahlee.org> writes:
> The Control-x is possibly the most awkward key combination on a
> standard keyboard, and unfortunately, it is the key strokes that emacs
> wants people to use the most. It is in fact, the sole contribution to
> the well-known “emacs pinky” repetitive strain injury, and is one
> of the main driving force for people to detest emacs.
Why does anyone need a finger to press the Control key? Try to keep your
fingers in the home position (index fingers on f and j) and press and
hold left Control with your hand without moving any finger. Works fine
for me. If I had to use my pinky for that, I'd have moved back to vi
long ago.
Jochem
--
"A designer knows he has arrived at perfection not when there is no
longer anything to add, but when there is no longer anything to take away."
- Antoine de Saint-Exupery
Jochem Huhmann wrote:
> "Xah Lee" <···@xahlee.org> writes:
>
> > The Control-x is possibly the most awkward key combination on a
> > standard keyboard, and unfortunately, it is the key strokes that emacs
> > wants people to use the most. It is in fact, the sole contribution to
> > the well-known "emacs pinky" repetitive strain injury, and is one
> > of the main driving force for people to detest emacs.
>
> Why does anyone need a finger to press the Control key? Try to keep your
> fingers in the home position (index fingers on f and j) and press and
> hold left Control with your hand without moving any finger. Works fine
> for me. If I had to use my pinky for that, I'd have moved back to vi
> long ago.
That seems difficult to me! I assume you're managing to hold it down
with the palm of your hand - have you got one of those over-sized
control keys on your keyboard?
I've tried out using C-j remapped to be the same as C-x as follows:
(global-set-key "\C-j" 'Control-X-prefix) ;; Was newline-and-indent
C-j is really easy to type on a QWERTY layout. Unfortunately some of
the major modes have C-j in their mode-maps, so it can get remapped to
something ordinary like sh-newline-and-indent.
So what I'm trying now is a modified CAPSLOCK which maps to the HYPER
modifier and then maping H-j to be an equivalent C-x prefix key*.
Unfortunately, this isn't ideal either, since some of the keys in
ctl-x-map are designed to work with the control key held down. e.g.
it's more awkward to type H-j C-q than C-x C-q.
Maybe I'll stick with C-j and use find-file-hooks to reset C-j after
the major mode has messed with it...
I also noticed that iswitchb-mode sets up some keys like this:
(global-set-key "\C-xb" 'iswitchb-buffer)
instead of
(define-key ctl-x-map "b" 'iswitchb-buffer)
Is this a bug in iswitchb-mode?
* Emacs complains about "\H-j" as a key specifier with the error
"Invalid modifier in string". I had to follow the FAQ's advice and map
H-j to something interactively and then examine command-history to find
out that [16777322] is the vector specifying H-j.
--
Raoul Gough.
··········@yahoo.co.uk writes:
> * Emacs complains about "\H-j" as a key specifier with the error
> "Invalid modifier in string".
Hyper events can't be put in strings. You can use a vector, [?\H-j],
or the kbd macro, (kbd "H-j").
--
Johan Bockgård
On 19.10.2006 12:14, ··········@yahoo.co.uk wrote:
> So what I'm trying now is a modified CAPSLOCK which maps to the HYPER
> modifier and then maping H-j to be an equivalent C-x prefix key*.
> Unfortunately, this isn't ideal either, since some of the keys in
> ctl-x-map are designed to work with the control key held down. e.g.
> it's more awkward to type H-j C-q than C-x C-q.
This is very interesting, how do you map CAPSLOCK to the HYPER
modifier? Could this be done with emacs-lisp only, too?
curiously,
Bernd
P.S. f'up2 comp.emacs, ok?
> (global-set-key "\C-j" 'Control-X-prefix) ;; Was newline-and-indent
> C-j is really easy to type on a QWERTY layout. Unfortunately some of
> the major modes have C-j in their mode-maps, so it can get remapped to
> something ordinary like sh-newline-and-indent.
You can try
(define-key key-translation-map [?\C-j] [?\C-x])
But this will not only turn `C-j k' into `C-x k' but also `C-j C-j' into
`C-x C-x'. Another option:
(define my-remap-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [?\C-j] 'Control-X-prefix)
map))
(define-minor-mode my-remap-mode
"A minor mode to remap C-j to C-x."
:global t)
(my-remap-mode 1)
It may still be overridden by other minor modes, but at least it will
override major mode bindings. In Emacs-22 you'll be able to use
emulation-mode-map-alists, which takes precedence over minor-mode bindings.
> I also noticed that iswitchb-mode sets up some keys like this:
> (global-set-key "\C-xb" 'iswitchb-buffer)
> instead of
> (define-key ctl-x-map "b" 'iswitchb-buffer)
> Is this a bug in iswitchb-mode?
Arguably, yes. Although it shouldn't affect you: as long as your C-x is
still bound to Control-X-prefix, then the above will modify the
Control-X-prefix map and will thus also affect your C-j prefix.
> * Emacs complains about "\H-j" as a key specifier with the error
> "Invalid modifier in string". I had to follow the FAQ's advice and map
> H-j to something interactively and then examine command-history to find
> out that [16777322] is the vector specifying H-j.
Don't use strings to represent key-sequences. [16777322] is usually written
[?\H-j]. Emacs also accepts the XEmacs syntax [(hyper j)], or [(hyper ?j)].
Stefan
From: Evan Monroig
Subject: Re: Emacs's Command Frequency and default keyboard shortcuts
Date:
Message-ID: <87vemj9uj6.fsf@gmail.com>
"Xah Lee" <···@xahlee.org> writes:
[...]
> On the dvorak keyboard (which is one major fix up of the fucked
> keyboard layout that is qwerty which by itself contributed to endless
> hand injuries), the right hand index finger's key is T.
Under the right hand index is the letter H, isn't it? T is on its
right.
(unless I have a strange dvorak layout..)
Evan