From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: How do you scroll the screen without moving the cursor ? Date: Wed, 8 Oct 2008 10:07:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0495effa-11ff-4c52-bcd7-e7a09f477b3f@f40g2000pri.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223487788 17784 80.91.229.12 (8 Oct 2008 17:43:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2008 17:43:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 08 19:44:01 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Knd4h-0002RZ-7X for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 19:43:51 +0200 Original-Received: from localhost ([127.0.0.1]:34176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Knd3c-00033C-UB for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2008 13:42:44 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!f40g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 134 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1223485623 19030 127.0.0.1 (8 Oct 2008 17:07:03 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 8 Oct 2008 17:07:03 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f40g2000pri.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:163209 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:58553 Archived-At: On Oct 8, 9:19 am, "Lorenzo Isella" 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 the= re. > 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: =E2=80=A2 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 =E2=86=91 next-history-element M-p previous-history-element =E2=86=93 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 "") 'previous-matching- input) (define-key minibuffer-local-map (kbd "") '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-=E2=80=B9ke= y=E2=80=BA 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 "") 'comint-previous-matching- input) (define-key comint-mode-map (kbd "") 'comint-next-matching- input) )) Xah =E2=88=91 http://xahlee.org/ =E2=98=84