emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Global keymaps


From: Juri Linkov
Subject: Re: Global keymaps
Date: Sun, 29 Jun 2008 22:28:09 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

>> 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)
  
! (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)
  
! 
! (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)
  
! (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)
  
! (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 via email to

[Prev in Thread] Current Thread [Next in Thread]