[bug#33466,2/2] repl: Add 'colorized' and 'readline' support.

Message ID 20181122144228.31573-2-go.wigust@gmail.com
State Accepted
Headers show
Series Improve guix repl | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied

Commit Message

Oleg Pykhalov Nov. 22, 2018, 2:42 p.m. UTC
* guix/scripts/repl.scm (guix-repl): Add 'colorized' and 'readline' support.
---
 guix/scripts/repl.scm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Ludovic Courtès Nov. 25, 2018, 8:40 p.m. UTC | #1
Oleg Pykhalov <go.wigust@gmail.com> skribis:

> * guix/scripts/repl.scm (guix-repl): Add 'colorized' and 'readline' support.
> ---
>  guix/scripts/repl.scm | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
> index 1a105f51e..eeaf4acc4 100644
> --- a/guix/scripts/repl.scm
> +++ b/guix/scripts/repl.scm
> @@ -188,6 +188,23 @@ call THUNK."
>               (save-module-excursion
>                (lambda ()
>                  (set-current-module user-module)
> +                (cond ((false-if-exception (resolve-interface '(ice-9 readline)))
> +                       =>
> +                       (lambda (module)
> +                         ;; Enable completion and input history at the REPL.
> +                         ((module-ref module 'activate-readline))))

What about simply loading ~/.guile when it exists?

Ludo’.

Patch

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 1a105f51e..eeaf4acc4 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -188,6 +188,23 @@  call THUNK."
              (save-module-excursion
               (lambda ()
                 (set-current-module user-module)
+                (cond ((false-if-exception (resolve-interface '(ice-9 readline)))
+                       =>
+                       (lambda (module)
+                         ;; Enable completion and input history at the REPL.
+                         ((module-ref module 'activate-readline))))
+                      (else
+                       (display "Consider installing the 'guile-readline' package for
+convenient interactive line editing and input history.\n\n")))
+                (unless (getenv "INSIDE_EMACS")
+                  (cond ((false-if-exception (resolve-interface '(ice-9 colorized)))
+                         =>
+                         (lambda (module)
+                           ;; Enable completion and input history at the REPL.
+                           ((module-ref module 'activate-colorized))))
+                        (else
+                         (display "Consider installing the 'guile-colorized' package
+for a colorful Guile experience.\n\n"))))
                 ;; Do not exit repl on SIGINT.
                 ((@@ (ice-9 top-repl) call-with-sigint)
                  (lambda ()