From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH] emacs: Enable 'guix-build-log-minor-mode' in shell buffers. Date: Sat, 31 Oct 2015 23:42:55 +0300 Message-ID: <871tcalqgg.fsf_-_@gmail.com> References: <877fm5za7d.fsf@gmail.com> <87oafge1ui.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsczH-0007wM-Ke for guix-devel@gnu.org; Sat, 31 Oct 2015 16:42:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsczE-000685-Dn for guix-devel@gnu.org; Sat, 31 Oct 2015 16:42:55 -0400 In-Reply-To: <87oafge1ui.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 30 Oct 2015 17:51:49 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2015-10-30 19:51 +0300) wrote: > Alex Kost skribis: > [...] >> + (add-hook 'shell-mode-hook 'guix-build-log-minor-mode) > > I wonder if we should do that automatically by default. That way > everyone would get the cool features, even those who didn=E2=80=99t bothe= r to > read all the manual. > > WDYT? Not sure if it's really worth, but this can be done the same way as with enabling 'guix-devel-mode' (as in the attached patch). So it can be disabled by: (setq guix-build-log-minor-mode-activate nil) But then why don't we enable 'guix-prettify-mode' by default? As for me, I don't think all these features should be automatically enabled, dunno what is considered to be a good default: "full-featured" or "as simple as possible". --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-emacs-Enable-guix-build-log-minor-mode-in-shell-buff.patch >From 3991193fcc6700b1e198d5befcb6b1c651839ae0 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sat, 31 Oct 2015 22:01:45 +0300 Subject: [PATCH] emacs: Enable 'guix-build-log-minor-mode' in shell buffers. * emacs/guix-build-log.el (guix-build-log-minor-mode-activate): New variable. (guix-build-log-minor-mode-activate-maybe): New function. * emacs/guix-init.el: Add it to 'shell-mode-hook'. * doc/emacs.texi (Emacs Build Log): Mention it. --- doc/emacs.texi | 12 +++++------- emacs/guix-build-log.el | 13 +++++++++++++ emacs/guix-init.el | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/emacs.texi b/doc/emacs.texi index 03dc951..e4608f0 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -646,13 +646,11 @@ 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. 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}. +the same highlighting and the same key bindings as the major mode, but +prefixed with @kbd{C-c}. By default, this minor mode is enabled in +shell buffers (@pxref{Interactive Shell,,, emacs, The GNU Emacs +Manual}). If you don't like it, set +@code{guix-build-log-minor-mode-activate} to nil. @node Emacs Completions diff --git a/emacs/guix-build-log.el b/emacs/guix-build-log.el index ae2631e..9e34525 100644 --- a/emacs/guix-build-log.el +++ b/emacs/guix-build-log.el @@ -104,6 +104,12 @@ "Face for the number of seconds for a phase." :group 'guix-build-log-faces) +(defcustom guix-build-log-minor-mode-activate t + "If non-nil, then `guix-build-log-minor-mode' is automatically +activated in `shell-mode' buffers." + :type 'boolean + :group 'guix-build-log) + (defcustom guix-build-log-mode-hook '() "Hook run after `guix-build-log-mode' is entered." :type 'hook @@ -324,6 +330,13 @@ forward." (setq font-lock-defaults '(guix-build-log-font-lock-keywords t))) ;;;###autoload +(defun guix-build-log-minor-mode-activate-maybe () + "Activate `guix-build-log-minor-mode' depending on +`guix-build-log-minor-mode-activate' variable." + (when guix-build-log-minor-mode-activate + (guix-build-log-minor-mode))) + +;;;###autoload (define-minor-mode guix-build-log-minor-mode "Toggle Guix Build Log minor mode. diff --git a/emacs/guix-init.el b/emacs/guix-init.el index 4b3d9c2..1612dee 100644 --- a/emacs/guix-init.el +++ b/emacs/guix-init.el @@ -15,5 +15,6 @@ avoid loading autoloads of Emacs packages installed in (guix-emacs-load-autoloads 'all)) (add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe) +(add-hook 'shell-mode-hook 'guix-build-log-minor-mode-activate-maybe) (provide 'guix-init) -- 2.5.0 --=-=-=--