me
/
guix
Archived
1
0
Fork 0

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.
master
Alex Kost 2015-10-29 21:27:56 +03:00
parent fbd213a83f
commit 20ce2fee33
2 changed files with 28 additions and 9 deletions

View File

@ -646,12 +646,13 @@ Toggle (show/hide) the bodies of all build phases.
@end table @end table
There is also @kbd{M-x guix-build-log-minor-mode} which also provides 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 the same highlighting. And as it is a minor mode, it can be enabled in
mode, it can be enabled in any buffer. For example, if you are building any buffer. For example, if you are building some package in a shell
some package in a shell buffer (@pxref{Interactive Shell,,, emacs, The buffer (@pxref{Interactive Shell,,, emacs, The GNU Emacs Manual}), you
GNU Emacs Manual}), you may enable @command{guix-build-log-minor-mode} may enable @command{guix-build-log-minor-mode} to make it more colorful.
to make it more colorful. Guix build output is rather specific, so this Guix build output is rather specific, so this new highlighting shouldn't
new highlighting shouldn't conflict with the existing one. 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 @node Emacs Completions

View File

@ -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))) (3 'guix-build-log-phase-seconds prepend)))
"A list of `font-lock-keywords' for `guix-build-log-mode'.") "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))) (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-n") 'guix-build-log-next-phase)
(define-key map (kbd "M-p") 'guix-build-log-previous-phase) (define-key map (kbd "M-p") 'guix-build-log-previous-phase)
(define-key map (kbd "TAB") 'guix-build-log-phase-toggle) (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 (kbd "<backtab>") 'guix-build-log-phase-toggle-all)
(define-key map [(shift tab)] 'guix-build-log-phase-toggle-all) (define-key map [(shift tab)] 'guix-build-log-phase-toggle-all)
map) 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.") "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?) (defun guix-build-log-phase-start (&optional with-header?)
"Return the start point of the current build phase. "Return the start point of the current build phase.
If WITH-HEADER? is non-nil, do not skip 'starting phase ...' header. 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 log in the current buffer. This mode can be enabled
programmatically using hooks: 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 :init-value nil
:lighter " Guix-Build-Log" :lighter " Guix-Build-Log"
:keymap guix-build-log-minor-mode-map
:group 'guix-build-log :group 'guix-build-log
(if guix-build-log-minor-mode (if guix-build-log-minor-mode
(font-lock-add-keywords nil guix-build-log-font-lock-keywords) (font-lock-add-keywords nil guix-build-log-font-lock-keywords)