all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org, Miles Bader <miles@gnu.org>
Subject: Re: Global keymaps
Date: Sun, 29 Jun 2008 22:28:09 +0300	[thread overview]
Message-ID: <8763rsf3cm.fsf@jurta.org> (raw)
In-Reply-To: <jwvvdzsdsqb.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 29 Jun 2008 14:03:01 -0400")

>> The package bookmark.el already defines a map `bookmark-map',
>> but it is not bound to any key by default.  It also adds
>> three keys to the `C-x r' prefix as:
>
>>   ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
>>   ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
>>   ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)
>
>> So it seems inevitable to create a new map `ctl-x-r-map' and bind
>> these key to it as:
>
>>   ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
>>   ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
>>   ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
>
>> Alternatively, when multiple inheritance will be available, a keymap
>> with these three keys could be named as `bookmark-mixin-map' to be
>> merged with register and rectangle maps in ctl-x-r-map.
>
> Yes,

Please review the following patch.  It creates a new keymap
ctl-x-r-map, and moves its keybindings to their corresponding
files rect.el and register.el.  The file bookmark.el already
has these autoloads, so this patch just changes ctl-x-map to
ctl-x-r-map in bookmark.el.  It also creates new keymaps
`abbrev-map' and `narrow-map' (it seems this name is better
as an identifier than `narrowing-map'), and rebinds global
keys to these maps.

Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.208
diff -c -r1.208 bindings.el
*** lisp/bindings.el	25 Jun 2008 20:17:07 -0000	1.208
--- lisp/bindings.el	29 Jun 2008 19:27:01 -0000
***************
*** 700,709 ****
  ;These commands are defined in editfns.c
  ;but they are not assigned to keys there.
  (put 'narrow-to-region 'disabled t)
! (define-key ctl-x-map "nn" 'narrow-to-region)
! (define-key ctl-x-map "nw" 'widen)
! ;; (define-key ctl-x-map "n" 'narrow-to-region)
! ;; (define-key ctl-x-map "w" 'widen)
  
  ;; Quitting
  (define-key global-map "\e\e\e" 'keyboard-escape-quit)
--- 700,713 ----
  ;These commands are defined in editfns.c
  ;but they are not assigned to keys there.
  (put 'narrow-to-region 'disabled t)
! 
! (defvar narrow-map (make-sparse-keymap)
!   "Keymap for narrowing commands.")
! (defalias 'narrow-map-prefix narrow-map)
! (define-key ctl-x-map "n" 'narrow-map-prefix)
! 
! (define-key narrow-map "n" 'narrow-to-region)
! (define-key narrow-map "w" 'widen)
  
  ;; Quitting
  (define-key global-map "\e\e\e" 'keyboard-escape-quit)
***************
*** 744,753 ****
  (define-key esc-map "!" 'shell-command)
  (define-key esc-map "|" 'shell-command-on-region)
  
! (define-key global-map [?\C-x right] 'next-buffer)
! (define-key global-map [?\C-x C-right] 'next-buffer)
! (define-key global-map [?\C-x left] 'previous-buffer)
! (define-key global-map [?\C-x C-left] 'previous-buffer)
  
  (let ((map minibuffer-local-map))
    (define-key map "\en"   'next-history-element)
--- 748,757 ----
  (define-key esc-map "!" 'shell-command)
  (define-key esc-map "|" 'shell-command-on-region)
  
! (define-key ctl-x-map [right] 'next-buffer)
! (define-key ctl-x-map [C-right] 'next-buffer)
! (define-key ctl-x-map [left] 'previous-buffer)
! (define-key ctl-x-map [C-left] 'previous-buffer)
  
  (let ((map minibuffer-local-map))
    (define-key map "\en"   'next-history-element)
***************
*** 809,815 ****
  
  (defvar goto-map (make-sparse-keymap)
    "Keymap for navigation commands.")
! (define-key esc-map "g" goto-map)
  
  (define-key goto-map    "g" 'goto-line)
  (define-key goto-map "\M-g" 'goto-line)
--- 813,820 ----
  
  (defvar goto-map (make-sparse-keymap)
    "Keymap for navigation commands.")
! (defalias 'goto-map-prefix goto-map)
! (define-key esc-map "g" 'goto-map-prefix)
  
  (define-key goto-map    "g" 'goto-line)
  (define-key goto-map "\M-g" 'goto-line)
***************
*** 820,826 ****
  
  (defvar search-map (make-sparse-keymap)
    "Keymap for search related commands.")
! (define-key esc-map "s" search-map)
  
  (define-key search-map "o"  'occur)
  (define-key search-map "hr" 'highlight-regexp)
--- 825,832 ----
  
  (defvar search-map (make-sparse-keymap)
    "Keymap for search related commands.")
! (defalias 'search-map-prefix search-map)
! (define-key esc-map "s" 'search-map-prefix)
  
  (define-key search-map "o"  'occur)
  (define-key search-map "hr" 'highlight-regexp)
***************
*** 1089,1113 ****
  (define-key ctl-x-4-map "m" 'compose-mail-other-window)
  (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
  \f
! (define-key ctl-x-map "r\C-@" 'point-to-register)
! (define-key ctl-x-map [?r ?\C-\ ] 'point-to-register)
! (define-key ctl-x-map "r " 'point-to-register)
! (define-key ctl-x-map "rj" 'jump-to-register)
! (define-key ctl-x-map "rs" 'copy-to-register)
! (define-key ctl-x-map "rx" 'copy-to-register)
! (define-key ctl-x-map "ri" 'insert-register)
! (define-key ctl-x-map "rg" 'insert-register)
! (define-key ctl-x-map "rr" 'copy-rectangle-to-register)
! (define-key ctl-x-map "rn" 'number-to-register)
! (define-key ctl-x-map "r+" 'increment-register)
! (define-key ctl-x-map "rc" 'clear-rectangle)
! (define-key ctl-x-map "rk" 'kill-rectangle)
! (define-key ctl-x-map "rd" 'delete-rectangle)
! (define-key ctl-x-map "ry" 'yank-rectangle)
! (define-key ctl-x-map "ro" 'open-rectangle)
! (define-key ctl-x-map "rt" 'string-rectangle)
! (define-key ctl-x-map "rw" 'window-configuration-to-register)
! (define-key ctl-x-map "rf" 'frame-configuration-to-register)
  
  (define-key esc-map "q" 'fill-paragraph)
  (define-key ctl-x-map "." 'set-fill-prefix)
--- 1095,1105 ----
  (define-key ctl-x-4-map "m" 'compose-mail-other-window)
  (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
  \f
! 
! (defvar ctl-x-r-map (make-sparse-keymap)
!   "Keymap for subcommands of C-x r.")
! (defalias 'ctl-x-r-prefix ctl-x-r-map)
! (define-key ctl-x-map "r" 'ctl-x-r-prefix)
  
  (define-key esc-map "q" 'fill-paragraph)
  (define-key ctl-x-map "." 'set-fill-prefix)
***************
*** 1127,1142 ****
  (define-key ctl-x-map "np" 'narrow-to-page)
  ;; (define-key ctl-x-map "p" 'narrow-to-page)
  \f
! (define-key ctl-x-map "al" 'add-mode-abbrev)
! (define-key ctl-x-map "a\C-a" 'add-mode-abbrev)
! (define-key ctl-x-map "ag" 'add-global-abbrev)
! (define-key ctl-x-map "a+" 'add-mode-abbrev)
! (define-key ctl-x-map "aig" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "ail" 'inverse-add-mode-abbrev)
! ;; (define-key ctl-x-map "a\C-h" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "a-" 'inverse-add-global-abbrev)
! (define-key ctl-x-map "ae" 'expand-abbrev)
! (define-key ctl-x-map "a'" 'expand-abbrev)
  ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
  ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
  ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
--- 1119,1139 ----
  (define-key ctl-x-map "np" 'narrow-to-page)
  ;; (define-key ctl-x-map "p" 'narrow-to-page)
  \f
! (defvar abbrev-map (make-sparse-keymap)
!   "Keymap for abbrev commands.")
! (defalias 'abbrev-map-prefix abbrev-map)
! (define-key ctl-x-map "a" 'abbrev-map-prefix)
! 
! (define-key abbrev-map "l" 'add-mode-abbrev)
! (define-key abbrev-map "\C-a" 'add-mode-abbrev)
! (define-key abbrev-map "g" 'add-global-abbrev)
! (define-key abbrev-map "+" 'add-mode-abbrev)
! (define-key abbrev-map "ig" 'inverse-add-global-abbrev)
! (define-key abbrev-map "il" 'inverse-add-mode-abbrev)
! ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev)
! (define-key abbrev-map "-" 'inverse-add-global-abbrev)
! (define-key abbrev-map "e" 'expand-abbrev)
! (define-key abbrev-map "'" 'expand-abbrev)
  ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
  ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
  ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)

Index: lisp/bookmark.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bookmark.el,v
retrieving revision 1.114
diff -c -r1.114 bookmark.el
*** lisp/bookmark.el	25 Jun 2008 16:51:32 -0000	1.114
--- lisp/bookmark.el	29 Jun 2008 19:27:14 -0000
***************
*** 217,225 ****
  ;; Set up these bindings dumping time *only*;
  ;; if the user alters them, don't override the user when loading bookmark.el.
  
! ;;;###autoload (define-key ctl-x-map "rb" 'bookmark-jump)
! ;;;###autoload (define-key ctl-x-map "rm" 'bookmark-set)
! ;;;###autoload (define-key ctl-x-map "rl" 'bookmark-bmenu-list)
  
  ;;;###autoload
  (defvar bookmark-map
--- 217,225 ----
  ;; Set up these bindings dumping time *only*;
  ;; if the user alters them, don't override the user when loading bookmark.el.
  
! ;;;###autoload (define-key ctl-x-r-map "b" 'bookmark-jump)
! ;;;###autoload (define-key ctl-x-r-map "m" 'bookmark-set)
! ;;;###autoload (define-key ctl-x-r-map "l" 'bookmark-bmenu-list)
  
  ;;;###autoload
  (defvar bookmark-map

Index: lisp/rect.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/rect.el,v
retrieving revision 1.58
diff -c -r1.58 rect.el
*** lisp/rect.el	6 May 2008 07:57:48 -0000	1.58
--- lisp/rect.el	29 Jun 2008 19:27:18 -0000
***************
*** 31,36 ****
--- 31,44 ----
  ;; intrusive and fill lines with whitespaces only when needed. A few functions
  ;; are untouched though, as noted above their definition.
  
+ ;;; Global key bindings
+ 
+ ;;;###autoload (define-key ctl-x-r-map "c" 'clear-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "k" 'kill-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "d" 'delete-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "y" 'yank-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "o" 'open-rectangle)
+ ;;;###autoload (define-key ctl-x-r-map "t" 'string-rectangle)
  
  ;;; Code:
  
Index: lisp/register.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/register.el,v
retrieving revision 1.60
diff -c -r1.60 register.el
*** lisp/register.el	6 May 2008 07:57:48 -0000	1.60
--- lisp/register.el	29 Jun 2008 19:27:35 -0000
***************
*** 28,33 ****
--- 28,49 ----
  ;; pieces of buffer state to named variables.  The entry points are
  ;; documented in the Emacs user's manual.
  
+ ;;; Global key bindings
+ 
+ ;;;###autoload (define-key ctl-x-r-map "\C-@" 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map [?\C-\ ] 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map " " 'point-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "j" 'jump-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "s" 'copy-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "x" 'copy-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "i" 'insert-register)
+ ;;;###autoload (define-key ctl-x-r-map "g" 'insert-register)
+ ;;;###autoload (define-key ctl-x-r-map "r" 'copy-rectangle-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "n" 'number-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "+" 'increment-register)
+ ;;;###autoload (define-key ctl-x-r-map "w" 'window-configuration-to-register)
+ ;;;###autoload (define-key ctl-x-r-map "f" 'frame-configuration-to-register)
+ 
  ;;; Code:
  
  (defvar register-alist nil

Index: lisp/expand.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/expand.el,v
retrieving revision 1.22
diff -c -r1.22 expand.el
*** lisp/expand.el	6 May 2008 07:57:34 -0000	1.22
--- lisp/expand.el	29 Jun 2008 19:27:55 -0000
***************
*** 427,434 ****
  	(goto-char (aref expand-pos expand-index))
  	(run-hooks 'expand-jump-hook))))
  
! ;;;###autoload (define-key ctl-x-map "ap" 'expand-jump-to-previous-slot)
! ;;;###autoload (define-key ctl-x-map "an" 'expand-jump-to-next-slot)
  
  (defun expand-build-list (len l)
    "Build a vector of offset positions from the list of positions."
--- 427,434 ----
  	(goto-char (aref expand-pos expand-index))
  	(run-hooks 'expand-jump-hook))))
  
! ;;;###autoload (define-key abbrev-map "p" 'expand-jump-to-previous-slot)
! ;;;###autoload (define-key abbrev-map "n" 'expand-jump-to-next-slot)
  
  (defun expand-build-list (len l)
    "Build a vector of offset positions from the list of positions."

-- 
Juri Linkov
http://www.jurta.org/emacs/




  reply	other threads:[~2008-06-29 19:28 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-14 16:57 Yanking isearch to highlight-regexp Lennart Borgman (gmail)
2008-06-14 21:42 ` Mathias Dahl
2008-06-14 21:50   ` Stefan Monnier
2008-06-14 21:54     ` Mathias Dahl
2008-06-15  0:32       ` Juri Linkov
2008-06-15  0:08     ` Lennart Borgman (gmail)
2008-06-15  0:33       ` Juri Linkov
2008-06-15  1:48       ` Stefan Monnier
2008-06-15  9:47         ` Lennart Borgman (gmail)
2008-06-15 20:48           ` Juri Linkov
2008-06-15 21:10             ` Lennart Borgman (gmail)
2008-06-15 22:54               ` Juri Linkov
2008-06-15 23:09                 ` Lennart Borgman (gmail)
2008-06-16  9:34                   ` Juri Linkov
2008-06-16 11:13                     ` Lennart Borgman
2008-06-16 21:48                       ` Juri Linkov
2008-06-16 18:50             ` David Koppelman
2008-06-16 19:08               ` Lennart Borgman (gmail)
2008-06-16 21:50               ` Juri Linkov
2008-06-17 18:50                 ` David Koppelman
2008-06-24 23:09                   ` Juri Linkov
2008-06-25  1:43                     ` Stefan Monnier
2008-06-25 20:32                       ` Juri Linkov
2008-06-25 22:16                         ` Miles Bader
2008-06-25 22:22                           ` Lennart Borgman (gmail)
2008-06-25 22:58                             ` Miles Bader
2008-06-27 23:15                           ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
2008-06-27 23:20                             ` Lennart Borgman (gmail)
2008-06-27 23:32                               ` Juri Linkov
2008-06-28  0:28                             ` Global keymaps Miles Bader
2008-06-28  1:25                               ` Stefan Monnier
2008-06-28 19:45                               ` Juri Linkov
2008-06-28 22:51                                 ` Stefan Monnier
2008-06-29 16:17                                   ` Juri Linkov
2008-06-29 18:03                                     ` Stefan Monnier
2008-06-29 19:28                                       ` Juri Linkov [this message]
2008-06-29 20:03                                         ` Stefan Monnier
2008-06-29 20:52                                           ` Juri Linkov
2008-06-29 21:24                                             ` Lennart Borgman (gmail)
2008-06-30  1:00                                               ` Stefan Monnier
2008-06-28 22:02             ` Yanking isearch to highlight-regexp Juri Linkov
2008-06-28 22:23               ` Stefan Monnier
2008-06-29 16:19                 ` Juri Linkov
2008-06-29 18:07                   ` Stefan Monnier
2008-06-29 19:29                     ` Juri Linkov
2008-06-29 20:05                       ` Stefan Monnier
2008-06-29 20:55                         ` Juri Linkov
2008-06-30  1:01                           ` Stefan Monnier
2008-06-30 19:59                             ` Juri Linkov
2008-07-01 21:34                               ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
2008-07-01 21:44                                 ` Grep key bindings Miles Bader
2008-07-01 21:54                                   ` Juri Linkov
2008-07-01 22:11                                     ` Miles Bader
2008-07-02 22:42                                       ` Juri Linkov
2008-07-03  6:53                                         ` joakim
2008-07-03  7:07                                           ` Miles Bader
2008-07-03 13:18                                         ` Ted Zlatanov
2008-07-03 22:06                                           ` Stefan Monnier
2008-07-03 14:50                                         ` Dan Nicolaescu
2008-07-03 15:37                                       ` Phil Jackson
2008-07-03 16:59                                         ` Drew Adams
2008-07-04 10:46                                       ` Eli Zaretskii
2008-07-04 10:59                                         ` Miles Bader
2008-07-30 17:49                               ` Yanking isearch to highlight-regexp Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8763rsf3cm.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.