From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 2/3] emacs: Add key bindings for 'guix-build-log-minor-mode'.
Date: Thu, 29 Oct 2015 23:33:26 +0300 [thread overview]
Message-ID: <877fm5za7d.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
I use (add-hook 'shell-mode-hook 'guix-build-log-minor-mode) and I found
that along with phases highlighting, it is useful to have some key
bindings available in this minor mode, so this patch adds "C-c
M-n/M-p/TAB/S-TAB" keys to it.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-emacs-Add-key-bindings-for-guix-build-log-minor-mode.patch --]
[-- Type: text/x-patch, Size: 4178 bytes --]
From fe50e7233fa5144f31f7db583d0289f056dd9dd0 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 29 Oct 2015 21:27:56 +0300
Subject: [PATCH 2/3] emacs: Add key bindings for 'guix-build-log-minor-mode'.
* emacs/guix-build-log.el (guix-build-log-mode-map): Move keys to ...
(guix-build-log-common-map): ...here. New variable.
(guix-build-log-minor-mode-map): New variable.
(guix-build-log-minor-mode): Use it.
* doc/emacs.texi (Emacs Build Log): Document it.
---
doc/emacs.texi | 13 +++++++------
emacs/guix-build-log.el | 24 +++++++++++++++++++++---
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/doc/emacs.texi b/doc/emacs.texi
index b36e859..03dc951 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -646,12 +646,13 @@ Toggle (show/hide) the bodies of all build phases.
@end table
There is also @kbd{M-x guix-build-log-minor-mode} which also provides
-the same highlighting (but not key bindings). And as it is a minor
-mode, it can be enabled in any buffer. For example, if you are building
-some package in a shell buffer (@pxref{Interactive Shell,,, emacs, The
-GNU Emacs Manual}), you may enable @command{guix-build-log-minor-mode}
-to make it more colorful. Guix build output is rather specific, so this
-new highlighting shouldn't conflict with the existing one.
+the same highlighting. And as it is a minor mode, it can be enabled in
+any buffer. For example, if you are building some package in a shell
+buffer (@pxref{Interactive Shell,,, emacs, The GNU Emacs Manual}), you
+may enable @command{guix-build-log-minor-mode} to make it more colorful.
+Guix build output is rather specific, so this new highlighting shouldn't
+conflict with the existing one. This mode also provides the same key
+bindings as the major mode, but prefixed with @kbd{C-c}.
@node Emacs Completions
diff --git a/emacs/guix-build-log.el b/emacs/guix-build-log.el
index 0e13213..1242607 100644
--- a/emacs/guix-build-log.el
+++ b/emacs/guix-build-log.el
@@ -178,9 +178,8 @@ STATE is a symbol denoting how a build phase was ended. It should be
(3 'guix-build-log-phase-seconds prepend)))
"A list of `font-lock-keywords' for `guix-build-log-mode'.")
-(defvar guix-build-log-mode-map
+(defvar guix-build-log-common-map
(let ((map (make-sparse-keymap)))
- (set-keymap-parent map special-mode-map)
(define-key map (kbd "M-n") 'guix-build-log-next-phase)
(define-key map (kbd "M-p") 'guix-build-log-previous-phase)
(define-key map (kbd "TAB") 'guix-build-log-phase-toggle)
@@ -188,8 +187,24 @@ STATE is a symbol denoting how a build phase was ended. It should be
(define-key map (kbd "<backtab>") 'guix-build-log-phase-toggle-all)
(define-key map [(shift tab)] 'guix-build-log-phase-toggle-all)
map)
+ "Parent keymap for 'build-log' buffers.
+For `guix-build-log-mode' this map is used as is.
+For `guix-build-log-minor-mode' this map is prefixed with 'C-c'.")
+
+(defvar guix-build-log-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent
+ map (make-composed-keymap (list guix-build-log-common-map)
+ special-mode-map))
+ map)
"Keymap for `guix-build-log-mode' buffers.")
+(defvar guix-build-log-minor-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "C-c") guix-build-log-common-map)
+ map)
+ "Keymap for `guix-build-log-minor-mode' buffers.")
+
(defun guix-build-log-phase-start (&optional with-header?)
"Return the start point of the current build phase.
If WITH-HEADER? is non-nil, do not skip 'starting phase ...' header.
@@ -319,9 +334,12 @@ When Guix Build Log minor mode is enabled, it highlights build
log in the current buffer. This mode can be enabled
programmatically using hooks:
- (add-hook 'shell-mode-hook 'guix-build-log-minor-mode)"
+ (add-hook 'shell-mode-hook 'guix-build-log-minor-mode)
+
+\\{guix-build-log-minor-mode-map}"
:init-value nil
:lighter " Guix-Build-Log"
+ :keymap guix-build-log-minor-mode-map
:group 'guix-build-log
(if guix-build-log-minor-mode
(font-lock-add-keywords nil guix-build-log-font-lock-keywords)
--
2.5.0
next reply other threads:[~2015-10-29 20:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 20:33 Alex Kost [this message]
2015-10-30 16:51 ` [PATCH 2/3] emacs: Add key bindings for 'guix-build-log-minor-mode' Ludovic Courtès
2015-10-31 20:42 ` [PATCH] emacs: Enable 'guix-build-log-minor-mode' in shell buffers Alex Kost
2015-11-01 17:46 ` Ludovic Courtès
2015-11-02 13:01 ` Alex Kost
2015-11-02 14:14 ` Ludovic Courtès
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=877fm5za7d.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/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/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.