* [PATCH] emacs: Add 'guix-root-map'.
@ 2015-06-24 13:55 Alex Kost
2015-06-24 21:11 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2015-06-24 13:55 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
This patch does not modify the current interface in any way. I just
realized that it is possible to make a root keymap instead of binding
common keys in all other maps. It became possible after commit dfeb023
but it's better late than never :-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Add-guix-root-map.patch --]
[-- Type: text/x-patch, Size: 3848 bytes --]
From 1888974254efc8b71d3a109926ec1a13660f3b9d Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Wed, 24 Jun 2015 10:36:18 +0300
Subject: [PATCH] emacs: Add 'guix-root-map'.
* emacs/guix-base.el (guix-define-buffer-type): Move common key bindings
from here...
(guix-root-map): ... to here. New variable.
* emacs/guix-info.el (guix-info-mode-map): Use it.
* emacs/guix-list.el (guix-list-mode-map): Use it.
* doc/emacs.texi (Emacs Keymaps): Document it.
---
doc/emacs.texi | 3 +++
emacs/guix-base.el | 21 ++++++++++++---------
emacs/guix-info.el | 2 +-
emacs/guix-list.el | 4 +++-
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/doc/emacs.texi b/doc/emacs.texi
index 0e89a11..180037a 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -426,6 +426,9 @@ If you want to change default key bindings, use the following keymaps
(@pxref{Init Rebinding,,, emacs, The GNU Emacs Manual}):
@table @code
+@item guix-root-map
+Parent keymap with general keys for all guix modes.
+
@item guix-list-mode-map
Parent keymap with general keys for ``list'' buffers.
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 587288e..fe89584 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -295,6 +295,17 @@ See `guix-update-after-operation' for details."
\f
;;; Common definitions for buffer types
+(defvar guix-root-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "l") 'guix-history-back)
+ (define-key map (kbd "r") 'guix-history-forward)
+ (define-key map (kbd "g") 'revert-buffer)
+ (define-key map (kbd "R") 'guix-redisplay-buffer)
+ (define-key map (kbd "M") 'guix-apply-manifest)
+ (define-key map (kbd "C-c C-z") 'guix-switch-to-repl)
+ map)
+ "Parent keymap for all guix modes.")
+
(defvar-local guix-profile nil
"Profile used for the current buffer.")
(put 'guix-profile 'permanent-local t)
@@ -440,15 +451,7 @@ following keywords are available:
"\\{" mode-map-str "}")
(setq-local revert-buffer-function 'guix-revert-buffer)
(setq-local guix-history-size ,history-var)
- (and (fboundp ',mode-init-fun) (,mode-init-fun)))
-
- (let ((map ,mode-map))
- (define-key map (kbd "l") 'guix-history-back)
- (define-key map (kbd "r") 'guix-history-forward)
- (define-key map (kbd "g") 'revert-buffer)
- (define-key map (kbd "R") 'guix-redisplay-buffer)
- (define-key map (kbd "M") 'guix-apply-manifest)
- (define-key map (kbd "C-c C-z") 'guix-switch-to-repl)))))
+ (and (fboundp ',mode-init-fun) (,mode-init-fun))))))
(put 'guix-define-buffer-type 'lisp-indent-function 'defun)
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index cbf8f46..bb21024 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -395,7 +395,7 @@ See `insert-text-button' for the meaning of PROPERTIES."
(defvar guix-info-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent
- map (make-composed-keymap button-buffer-map
+ map (make-composed-keymap (list guix-root-map button-buffer-map)
special-mode-map))
map)
"Parent keymap for info buffers.")
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 26dfeac..e84d60a 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -371,7 +371,9 @@ Same as `tabulated-list-sort', but also restore marks after sorting."
\f
(defvar guix-list-mode-map
(let ((map (make-sparse-keymap)))
- (set-keymap-parent map tabulated-list-mode-map)
+ (set-keymap-parent
+ map (make-composed-keymap guix-root-map
+ tabulated-list-mode-map))
(define-key map (kbd "RET") 'guix-list-describe)
(define-key map (kbd "m") 'guix-list-mark)
(define-key map (kbd "*") 'guix-list-mark)
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] emacs: Add 'guix-root-map'.
2015-06-24 13:55 [PATCH] emacs: Add 'guix-root-map' Alex Kost
@ 2015-06-24 21:11 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-06-24 21:11 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> This patch does not modify the current interface in any way. I just
> realized that it is possible to make a root keymap instead of binding
> common keys in all other maps. It became possible after commit dfeb023
> but it's better late than never :-)
:-)
> From 1888974254efc8b71d3a109926ec1a13660f3b9d Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Wed, 24 Jun 2015 10:36:18 +0300
> Subject: [PATCH] emacs: Add 'guix-root-map'.
>
> * emacs/guix-base.el (guix-define-buffer-type): Move common key bindings
> from here...
> (guix-root-map): ... to here. New variable.
> * emacs/guix-info.el (guix-info-mode-map): Use it.
> * emacs/guix-list.el (guix-list-mode-map): Use it.
> * doc/emacs.texi (Emacs Keymaps): Document it.
Sure, please push!
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-24 21:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-24 13:55 [PATCH] emacs: Add 'guix-root-map' Alex Kost
2015-06-24 21:11 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.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.