all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.
@ 2015-10-29 20:32 Alex Kost
  2015-10-30 16:49 ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-10-29 20:32 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

As suggested by Ludovic on IRC, after this patch, build log files (from
/var/log/guix/drvs) will be displayed in a 'guix-build-log-mode'.

I'm not sure about regexp though: are these files always "bz2" and
".../XX/XXXXX-30-more-characters-XXXXX/..."?

I didn't put "/var/log" in the beginning of the regexp to match, for example, /mnt/guix-from-sdc/var/log/guix/... files or alike.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Enable-guix-build-log-mode-for-build-log-files.patch --]
[-- Type: text/x-patch, Size: 1037 bytes --]

From 5a2beec8d91334ea755b709e51492c44fd2d0773 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 29 Oct 2015 20:48:53 +0300
Subject: [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.

* emacs/guix-build-log.el (auto-mode-alist): Add 'guix-build-log-mode'
  to 'auto-mode-alist'.
---
 emacs/guix-build-log.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emacs/guix-build-log.el b/emacs/guix-build-log.el
index c0855b2..0e13213 100644
--- a/emacs/guix-build-log.el
+++ b/emacs/guix-build-log.el
@@ -329,6 +329,13 @@ programmatically using hooks:
   (when font-lock-mode
     (font-lock-fontify-buffer)))
 
+;;;###autoload
+(add-to-list 'auto-mode-alist
+             ;; Regexp for log files (usually placed in /var/log/guix/...)
+             (cons (rx "guix/drvs/" (= 2 alnum) "/" (= 30 alnum)
+                       "-" (+ (any alnum "-.")) ".drv.bz2" string-end)
+                   'guix-build-log-mode))
+
 (provide 'guix-build-log)
 
 ;;; guix-build-log.el ends here
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.
  2015-10-29 20:32 [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files Alex Kost
@ 2015-10-30 16:49 ` Ludovic Courtès
  2015-10-31 20:30   ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2015-10-30 16:49 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> As suggested by Ludovic on IRC, after this patch, build log files (from
> /var/log/guix/drvs) will be displayed in a 'guix-build-log-mode'.
>
> I'm not sure about regexp though: are these files always "bz2" and
> ".../XX/XXXXX-30-more-characters-XXXXX/..."?

It’s not necessarily bz2, see ‘guix-daemon --disable-log-compression’.

The regexp should match 32 characters of ‘%nix-base32-chars’ in (guix
base32) if we want to be pedantic.

> I didn't put "/var/log" in the beginning of the regexp to match, for example, /mnt/guix-from-sdc/var/log/guix/... files or alike.

Good.

Could you update the patch accordingly?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.
  2015-10-30 16:49 ` Ludovic Courtès
@ 2015-10-31 20:30   ` Alex Kost
  2015-11-01 17:20     ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-10-31 20:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 937 bytes --]

Ludovic Courtès (2015-10-30 19:49 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> As suggested by Ludovic on IRC, after this patch, build log files (from
>> /var/log/guix/drvs) will be displayed in a 'guix-build-log-mode'.
>>
>> I'm not sure about regexp though: are these files always "bz2" and
>> ".../XX/XXXXX-30-more-characters-XXXXX/..."?
>
> It’s not necessarily bz2, see ‘guix-daemon --disable-log-compression’.

Thanks for the pointer, now I see.

> The regexp should match 32 characters of ‘%nix-base32-chars’ in (guix
> base32) if we want to be pedantic.

At first I didn't want to be so pedantic, but since these base32 chars
are used in 'guix-prettify-regexp' anyway, I agree, thanks!

> Could you update the patch accordingly?

So I'm attaching 2 patches: one for adding a regexp to match a hash
character and another for adding 'guix-build-log-mode' to
'auto-mode-alist'.


[-- Attachment #2: 0001-emacs-Add-guix-hash-char-regexp.patch --]
[-- Type: text/x-patch, Size: 1910 bytes --]

From 11fea59d41063b3511a84a0d783cfa2016ed68c4 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Sat, 31 Oct 2015 21:36:41 +0300
Subject: [PATCH 1/2] emacs: Add 'guix-hash-char-regexp'.

* emacs/guix-utils.el (guix-hash-char-regexp): New constant.
* emacs/guix-prettify.el (guix-prettify-regexp): Use it.
---
 emacs/guix-prettify.el | 8 ++++----
 emacs/guix-utils.el    | 6 ++++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/emacs/guix-prettify.el b/emacs/guix-prettify.el
index 38d72e8..0411aee 100644
--- a/emacs/guix-prettify.el
+++ b/emacs/guix-prettify.el
@@ -84,10 +84,10 @@ disabling `guix-prettify-mode' a little faster."
   ;; http://hydra.gnu.org/nar/…-foo-0.1
   ;; http://hydra.gnu.org/log/…-foo-0.1
 
-  (rx "/" (or "store" "nar" "log") "/"
-      ;; Hash-parts do not include "e", "o", "u" and "t".  See base32Chars
-      ;; at <https://github.com/NixOS/nix/blob/master/src/libutil/hash.cc>
-      (group (= 32 (any "0-9" "a-d" "f-n" "p-s" "v-z"))))
+  (rx-to-string
+   `(and "/" (or "store" "nar" "log") "/"
+         (group (= 32 (regexp ,guix-hash-char-regexp))))
+   t)
   "Regexp matching file names for prettifying.
 
 Disable `guix-prettify-mode' before modifying this variable and
diff --git a/emacs/guix-utils.el b/emacs/guix-utils.el
index d1f088b..d8dad91 100644
--- a/emacs/guix-utils.el
+++ b/emacs/guix-utils.el
@@ -33,6 +33,12 @@
   "String used to format time values.
 For possible formats, see `format-time-string'.")
 
+(defconst guix-hash-char-regexp
+  ;; Hash parts do not include "e", "o", "u" and "t".  See base32Chars
+  ;; at <https://github.com/NixOS/nix/blob/master/src/libutil/hash.cc>.
+  "[0-9a-df-np-sv-z]"
+  "Regexp matching a character used by Nix base32 hash.")
+
 (defun guix-get-string (val &optional face)
   "Convert VAL into a string and return it.
 
-- 
2.5.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-emacs-Enable-guix-build-log-mode-for-build-log-files.patch --]
[-- Type: text/x-patch, Size: 1397 bytes --]

From a9a1b1ef7c272a188745d367745f9ef4fc155be9 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 29 Oct 2015 20:48:53 +0300
Subject: [PATCH 2/2] emacs: Enable 'guix-build-log-mode' for build log files.

* emacs/guix-build-log.el (auto-mode-alist): Add 'guix-build-log-mode'
  to 'auto-mode-alist'.
---
 emacs/guix-build-log.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/emacs/guix-build-log.el b/emacs/guix-build-log.el
index c209100..ae2631e 100644
--- a/emacs/guix-build-log.el
+++ b/emacs/guix-build-log.el
@@ -24,6 +24,8 @@
 
 ;;; Code:
 
+(require 'guix-utils)
+
 (defgroup guix-build-log nil
   "Settings for `guix-build-log-mode'."
   :group 'guix)
@@ -346,6 +348,18 @@ programmatically using hooks:
   (when font-lock-mode
     (font-lock-fontify-buffer)))
 
+;;;###autoload
+(add-to-list 'auto-mode-alist
+             ;; Regexp for log files (usually placed in /var/log/guix/...)
+             (cons (rx-to-string
+                    `(and "guix/drvs/"
+                          (= 2 (regexp ,guix-hash-char-regexp)) "/"
+                          (= 30 (regexp ,guix-hash-char-regexp))
+                          "-" (+ (any alnum "-+."))
+                          ".drv" (? ".bz2") string-end)
+                    t)
+                   'guix-build-log-mode))
+
 (provide 'guix-build-log)
 
 ;;; guix-build-log.el ends here
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.
  2015-10-31 20:30   ` Alex Kost
@ 2015-11-01 17:20     ` Ludovic Courtès
  2015-11-02 13:01       ` Alex Kost
  0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2015-11-01 17:20 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From 11fea59d41063b3511a84a0d783cfa2016ed68c4 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Sat, 31 Oct 2015 21:36:41 +0300
> Subject: [PATCH 1/2] emacs: Add 'guix-hash-char-regexp'.
>
> * emacs/guix-utils.el (guix-hash-char-regexp): New constant.
> * emacs/guix-prettify.el (guix-prettify-regexp): Use it.

LGTM.  The only possible downside is if it noticeably slows things down,
which may be the case.  Have you seen any difference?

If it happens to be slower, I’m fine with the current (sloppier)
variant.

> From a9a1b1ef7c272a188745d367745f9ef4fc155be9 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 29 Oct 2015 20:48:53 +0300
> Subject: [PATCH 2/2] emacs: Enable 'guix-build-log-mode' for build log files.
>
> * emacs/guix-build-log.el (auto-mode-alist): Add 'guix-build-log-mode'
>   to 'auto-mode-alist'.

LGTM, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files.
  2015-11-01 17:20     ` Ludovic Courtès
@ 2015-11-02 13:01       ` Alex Kost
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Kost @ 2015-11-02 13:01 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-11-01 20:20 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> From 11fea59d41063b3511a84a0d783cfa2016ed68c4 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Sat, 31 Oct 2015 21:36:41 +0300
>> Subject: [PATCH 1/2] emacs: Add 'guix-hash-char-regexp'.
>>
>> * emacs/guix-utils.el (guix-hash-char-regexp): New constant.
>> * emacs/guix-prettify.el (guix-prettify-regexp): Use it.

I dropped this commit as ‘guix-hash-char-regexp’ is not really needed
(see below).

> LGTM.  The only possible downside is if it noticeably slows things down,
> which may be the case.  Have you seen any difference?
>
> If it happens to be slower, I’m fine with the current (sloppier)
> variant.

In my understanding it is not noticeably slower.  I think it would be
significant if regexp consisted only of [0-9a-df-np-sv-z] characters,
but since there are easy-to-search parts (like "/guix/drvs" or
"/store"), it shouldn't be slow (though I must admit I don't have deep
knowledge of how regexps work).

Anyway, after all I decided to stay on a simple variant (that uses
[[:alnum:]] instead of [0-9a-df-np-sv-z]), because using
‘guix-hash-char-regexp’ in a regexp for 'auto-mode-alist' would lead to
requiring another module (guix-utils.el) on start.

Don't read this ↑.  In short, /var/log/guix/drvs/... files should be
opened in 'guix-build-log-mode' automatically now.

-- 
Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-02 13:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29 20:32 [PATCH 1/3] emacs: Enable 'guix-build-log-mode' for build log files Alex Kost
2015-10-30 16:49 ` Ludovic Courtès
2015-10-31 20:30   ` Alex Kost
2015-11-01 17:20     ` Ludovic Courtès
2015-11-02 13:01       ` Alex Kost

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.