[Top][All Lists]

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

21/37: emacs: Split 'guix-root-map' keymap.

From: Alex Kost
Subject: 21/37: emacs: Split 'guix-root-map' keymap.
Date: Fri, 18 Dec 2015 18:51:29 +0000

alezost pushed a commit to branch wip-refactor-emacs-ui
in repository guix.

commit 3f747a214d3eb6e89012788a3e336cbb690eab35
Author: Alex Kost <address@hidden>
Date:   Sat Nov 21 12:25:19 2015 +0300

    emacs: Split 'guix-root-map' keymap.
    * emacs/guix-base.el: (guix-root-map): Split into...
      (guix-buffer-map): ... this and...
    * emacs/guix-ui.el (guix-ui-map): ... this.
      (guix-ui-define-interface): Generate
      'guix-ENTRY-TYPE-BUFFER-TYPE-mode-map' keymaps inheriting them from
      'guix-ui-map' and 'guix-BUFFER-TYPE-mode-map'.
    * emacs/guix-info.el (guix-info-mode-map): Use 'guix-buffer-map'.
    * emacs/guix-list.el (guix-list-mode-map): Likewise.
    * doc/emacs.texi (Emacs Keymaps): Document new keymaps.
 doc/emacs.texi     |    8 ++++++--
 emacs/guix-base.el |    6 ++----
 emacs/guix-info.el |    4 ++--
 emacs/guix-list.el |    2 +-
 emacs/guix-ui.el   |   18 ++++++++++++++++++
 5 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index 5828bb7..15abedb 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -439,8 +439,12 @@ If you want to change default key bindings, use the 
following keymaps
 (@pxref{Init Rebinding,,, emacs, The GNU Emacs Manual}):
 @table @code
address@hidden guix-root-map
-Parent keymap with general keys for all guix modes.
address@hidden guix-buffer-map
+Parent keymap with general keys for any buffer type.
address@hidden guix-ui-map
+Parent keymap with general keys for buffers used for Guix package
+management (for packages, outputs and generations).
 @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 3aaa266..73c9404 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -283,16 +283,14 @@ This alist is filled by `guix-buffer-define-interface' 
   "Return 'revert-confirm' value for BUFFER-TYPE/ENTRY-TYPE."
   (guix-buffer-value buffer-type entry-type 'revert-confirm))
-(defvar guix-root-map
+(defvar guix-buffer-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)
-  "Parent keymap for all guix modes.")
+  "Parent keymap for Guix buffer modes.")
 (defvar-local guix-profile nil
   "Profile used for the current buffer.")
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 3111643..c988d9c 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -396,10 +396,10 @@ See `insert-text-button' for the meaning of PROPERTIES."
 (defvar guix-info-mode-map
   (let ((map (make-sparse-keymap)))
-     map (make-composed-keymap (list guix-root-map button-buffer-map)
+     map (make-composed-keymap (list guix-buffer-map button-buffer-map)
-  "Parent keymap for info buffers.")
+  "Keymap for `guix-info-mode' buffers.")
 (define-derived-mode guix-info-mode special-mode "Guix-Info"
   "Parent mode for displaying information in info buffers.")
diff --git a/emacs/guix-list.el b/emacs/guix-list.el
index 9aed7dc..8a9c10f 100644
--- a/emacs/guix-list.el
+++ b/emacs/guix-list.el
@@ -380,7 +380,7 @@ Same as `tabulated-list-sort', but also restore marks after 
 (defvar guix-list-mode-map
   (let ((map (make-sparse-keymap)))
-     map (make-composed-keymap guix-root-map
+     map (make-composed-keymap guix-buffer-map
     (define-key map (kbd "RET") 'guix-list-describe)
     (define-key map (kbd "i")   'guix-list-describe)
diff --git a/emacs/guix-ui.el b/emacs/guix-ui.el
index 4f46882..25b110c 100644
--- a/emacs/guix-ui.el
+++ b/emacs/guix-ui.el
@@ -27,6 +27,13 @@
 (require 'cl-lib)
 (require 'guix-utils)
+(defvar guix-ui-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "M") 'guix-apply-manifest)
+    (define-key map (kbd "C-c C-z") 'guix-switch-to-repl)
+    map)
+  "Parent keymap for Guix package/generation buffers.")
 (defun guix-ui-list-describe (ids)
   "Describe 'ui' entries with IDS (list of identifiers)."
   (apply #'guix-get-show-entries
@@ -52,12 +59,23 @@ The rest keyword arguments are passed to
          (buffer-type-str (symbol-name buffer-type))
          (prefix          (concat "guix-" entry-type-str "-"
+         (mode-str        (concat prefix "-mode"))
+         (mode-map        (intern (concat mode-str "-map")))
+         (parent-map      (intern (format "guix-%s-mode-map"
+                                          buffer-type-str)))
          (required-var    (intern (concat prefix "-required-params")))
          (definer         (intern (format "guix-%s-define-interface"
     (guix-keyword-args-let args
         ((required-val    :required ''(id)))
+         (defvar ,mode-map
+           (let ((map (make-sparse-keymap)))
+             (set-keymap-parent
+              map (make-composed-keymap ,parent-map guix-ui-map))
+             map)
+           ,(format "Keymap for `%s' buffers." mode-str))
          (defvar ,required-var ,required-val
            ,(format "\
 List of the required '%s' parameters for '%s' buffer.

reply via email to

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