unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: How do you scroll the screen without moving the cursor ?
@ 2008-10-08 16:19 Lorenzo Isella
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Isella @ 2008-10-08 16:19 UTC (permalink / raw
  To: help-gnu-emacs

> aww cool thanks... i just tried the stuffs
>
> this is what i ended up with ->
>
> ;; ^E in Vi
> (defun ctrl-e-in-vi (n)
>  (interactive "p")
>  (scroll-down n))
>
> ;; ^Y in Vi
> (defun ctrl-y-in-vi (n)
>  (interactive "p")
>  (scroll-up n))
>
> (global-set-key "\M-n" 'ctrl-y-in-vi)
> (global-set-key "\M-p" 'ctrl-e-in-vi)

Hello,
Sorry for jumping into this thread. I tried the functions above in my
.emacs file (the only trivial difference is that I keybound them to f1
and f2).
They work beautifully with e.g. python, Fortran etc.. codes, but not
with .tex files (where I use latex).
In that case, the cursor moves when I invoke one of the functions above.
How comes? I am not redefining any key-binding involving my f1 and f2 there.
If needed, I can post the part of my .emacs file dealing with the
customization of auctex, but I am not sure the problem lies there.
Any suggestions?
Cheers

Lorenzo




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

* Re: How do you scroll the screen without moving the cursor ?
       [not found] <mailman.578.1223482753.25473.help-gnu-emacs@gnu.org>
@ 2008-10-08 17:07 ` Xah
  0 siblings, 0 replies; 2+ messages in thread
From: Xah @ 2008-10-08 17:07 UTC (permalink / raw
  To: help-gnu-emacs

On Oct 8, 9:19 am, "Lorenzo Isella" <lorenzo.ise...@gmail.com> wrote:
> > aww cool thanks... i just tried the stuffs
>
> > this is what i ended up with ->
>
> > ;; ^E in Vi
> > (defun ctrl-e-in-vi (n)
> >  (interactive "p")
> >  (scroll-down n))
>
> > ;; ^Y in Vi
> > (defun ctrl-y-in-vi (n)
> >  (interactive "p")
> >  (scroll-up n))
>
> > (global-set-key "\M-n" 'ctrl-y-in-vi)
> > (global-set-key "\M-p" 'ctrl-e-in-vi)
>
> Hello,
> Sorry for jumping into this thread. I tried the functions above in my
> .emacs file (the only trivial difference is that I keybound them to f1
> and f2).
> They work beautifully with e.g. python, Fortran etc.. codes, but not
> with .tex files (where I use latex).
> In that case, the cursor moves when I invoke one of the functions above.
> How comes? I am not redefining any key-binding involving my f1 and f2 there.
> If needed, I can post the part of my .emacs file dealing with the
> customization of auctex, but I am not sure the problem lies there.
> Any suggestions?
> Cheers

The latex mode you are using probably defined its own binding for M-p
M-n. The rebinding of these 2 keys is actually very common.

What you want to do is to bind them back. :D

See:

• How To Reclaim Keybindings
http://xahlee.org/emacs/ergonomic_emacs_keybinding_minibuffer.html

Here's plain text version:
------------------------------

How To Reclaim Keybindings

Xah Lee, 2008-07

The following are some tips on how to reclaim keybindings.

To reclaim your binding, you'll need to find out the mode's name, then
use a hook to rebind keys in its keymap. Here's a example.

Suppose you defined:

(global-set-key (kbd "M-s") 'isearch-forward)
(global-set-key (kbd "M-S") 'isearch-backward)

You want to use M-s to repeat the search. However, once you are in the
isearch prompt, technically it is a mode named isearch-mode. In
isearch-mode, C-s is defined to run isearch-repeat-forward and M-s is
not defined. You want M-s to run isearch-repeat-forward. Here's the
code to reclaim it:

(add-hook 'isearch-mode-hook
 (lambda ()
 (define-key isearch-mode-map (kbd "M-s") 'isearch-repeat-forward)
 (define-key isearch-mode-map (kbd "M-S") 'isearch-repeat-backward)
 )
)

In general, when you want to reclaim some bindings used in some mode,
first find out the mode's name, then the hook name would be xyz-mode-
hook, and its keymap name would typically be xyz-mode-map.

When you redefine some keys in a mode's keymap, be sure to make
bindings for the displaced commands if those commands are important to
you. (use describe-key to find out a key's binding while in that
mode.)
Reclaim Bindings for Minibuffer

The minibuffer is where emacs does prompts. It defines the following
keybindings:
Minibuffer's Keybindings Key	Command
C-j	exit-minibuffer
Enter	exit-minibuffer
C-g	abort-recursive-edit
M-n	next-history-element
↑	next-history-element
M-p	previous-history-element
↓	previous-history-element
M-s	next-matching-history-element
M-r	previous-matching-history-element

Note that several of the keys conflicts with our ergo keymap. Here's
how we fixed it in our ergo keymap dvorak:

;; reclaim some bindings used in minibuffer
(define-key minibuffer-local-map (kbd "M-p") 'kill-word)
(define-key minibuffer-local-map (kbd "M-n") 'forward-char)
(define-key minibuffer-local-map (kbd "M-r") 'forward-word)
(define-key minibuffer-local-map (kbd "M-s") 'isearch-forward)
(define-key minibuffer-local-map (kbd "<f11>") 'previous-matching-
input)
(define-key minibuffer-local-map (kbd "<f12>") 'next-matching-input)

Reference: Elisp Manual: Text-from-Minibuffer.
Reclaim Bindings for Shell

The shell mode (M-x shell), and shell command (M-!) both have M-‹key›
that conflics with our ergo keymaps. Here's how we fixed it for the
ergo keymap dvorak.

;; reclaim some binding used by shell mode and shell-command.
;; the shell mode and associated mode and commands use keys in comint-
mode-map.
(add-hook 'comint-mode-hook
 (lambda ()
   (define-key comint-mode-map (kbd "M-p") 'kill-word)
   (define-key comint-mode-map (kbd "M-n") 'forward-char)
   (define-key comint-mode-map (kbd "M-r") 'forward-word)
   (define-key comint-mode-map (kbd "<f11>") 'comint-previous-matching-
input)
   (define-key comint-mode-map (kbd "<f12>") 'comint-next-matching-
input)
))

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-08 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 16:19 How do you scroll the screen without moving the cursor ? Lorenzo Isella
     [not found] <mailman.578.1223482753.25473.help-gnu-emacs@gnu.org>
2008-10-08 17:07 ` Xah

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