unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#54508] [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo.
@ 2022-03-21 17:41 Maxim Cournoyer
  2022-03-21 17:43 ` [bug#54508] [PATCH 1/2] build: emacs-utils: Add a (as-display) subform to `emacs-substitute-variables' Maxim Cournoyer
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Cournoyer @ 2022-03-21 17:41 UTC (permalink / raw)
  To: 54508; +Cc: Maxim Cournoyer

Hello,

This allows formatting sexps using "~a" (display) instead of "~s" (write) when
using `emacs-substitute-variables', as shown in patch 2/2.

Thanks,

Maxim Cournoyer (2):
  build: emacs-utils: Add a (as-display) subform to
    `emacs-substitute-variables'.
  gnu: emacs-gnugo: Patch 'gnugo-program' variable.

 gnu/packages/emacs-xyz.scm | 26 ++++++++++++---------
 guix/build/emacs-utils.scm | 47 +++++++++++++++++++++++++++++---------
 2 files changed, 51 insertions(+), 22 deletions(-)

-- 
2.34.0





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

* [bug#54508] [PATCH 1/2] build: emacs-utils: Add a (as-display) subform to `emacs-substitute-variables'.
  2022-03-21 17:41 [bug#54508] [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo Maxim Cournoyer
@ 2022-03-21 17:43 ` Maxim Cournoyer
  2022-03-21 17:43   ` [bug#54508] [PATCH 2/2] gnu: emacs-gnugo: Patch 'gnugo-program' variable Maxim Cournoyer
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Cournoyer @ 2022-03-21 17:43 UTC (permalink / raw)
  To: 54508; +Cc: Maxim Cournoyer

* guix/build/emacs-utils.scm (as-display): New variable.
(replacement-helper): New syntax helper.
(emacs-substitute-sexps): Use it and update doc.
(emacs-substitute-variables): Add an optional 'modifier' datum to the
replacement specification, and document it.
---
 guix/build/emacs-utils.scm | 47 +++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 11 deletions(-)

diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 64ef40e25a..60a754b9e9 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
-;;; Copyright © 2018, 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2018, 2020, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2019 Liliana Marie Prikler <liliana.prikler@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -28,6 +28,8 @@ (define-module (guix build emacs-utils)
             emacs-batch-disable-compilation
             emacs-generate-autoloads
             emacs-byte-compile-directory
+
+            as-display
             emacs-substitute-sexps
             emacs-substitute-variables))
 
@@ -82,6 +84,24 @@ (define* (emacs-byte-compile-directory dir)
                 (byte-recompile-directory (file-name-as-directory ,dir) 0 1))))
     (emacs-batch-eval expr)))
 
+(define as-display         ;syntactic keyword for 'emacs-substitute-sexps'
+  '(as display))
+
+(define-syntax replacement-helper
+  (syntax-rules (as-display)
+    ((_ (leading-regexp replacement (as-display)))
+     `(progn (goto-char (point-min))
+             (re-search-forward ,leading-regexp)
+             (kill-sexp)
+             (insert " ")
+             (insert ,(format #f "~a" replacement))))
+    ((_ (leading-regexp replacement))
+     `(progn (goto-char (point-min))
+             (re-search-forward ,leading-regexp)
+             (kill-sexp)
+             (insert " ")
+             (insert ,(format #f "~s" replacement))))))
+
 (define-syntax emacs-substitute-sexps
   (syntax-rules ()
     "Substitute the S-expression immediately following the first occurrence of
@@ -95,14 +115,15 @@ (define-syntax emacs-substitute-sexps
 
 This replaces the default values of the `w3m-command' and `w3m-image-viewer'
 variables declared in `w3m.el' with the results of the `string-append' calls
-above.  Note that LEADING-REGEXP uses Emacs regexp syntax."
-    ((emacs-substitute-sexps file (leading-regexp replacement) ...)
+above.  Note that LEADING-REGEXP uses Emacs regexp syntax.
+
+Here is another example that uses the '(as-display)' subform to avoid having
+the Elisp procedure symbol from being double quoted:
+  (emacs-substitute-sexps \"gnugo.el\"
+    (\"defvar gnugo-xpms\" \"#'gnugo-imgen-create-xpms\" (as-display))"
+    ((_ file replacement-spec ...)
      (emacs-batch-edit-file file
-       `(progn (progn (goto-char (point-min))
-                      (re-search-forward ,leading-regexp)
-                      (kill-sexp)
-                      (insert " ")
-                      (insert ,(format #f "~S" replacement)))
+       `(progn ,(replacement-helper replacement-spec)
                ...
                (basic-save-buffer))))))
 
@@ -117,11 +138,15 @@ (define-syntax emacs-substitute-variables
 
 This replaces the default values of the `w3m-command' and `w3m-image-viewer'
 variables declared in `w3m.el' with the results of the `string-append' calls
-above."
-    ((emacs-substitute-variables file (variable replacement) ...)
+above.  Similarly to `emacs-substitute-sexps', the '(as-display)' subform can
+be used to have the replacement formatted like `display' would, which can be
+useful to avoid double quotes being added when the replacement is provided as
+a string."
+    ((_ file (variable replacement modifier ...) ...)
      (emacs-substitute-sexps file
        ((string-append "(def[a-z]+[[:space:]\n]+" variable "\\>")
-        replacement)
+        replacement
+        modifier ...)
        ...))))
 
 ;;; emacs-utils.scm ends here
-- 
2.34.0





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

* [bug#54508] [PATCH 2/2] gnu: emacs-gnugo: Patch 'gnugo-program' variable.
  2022-03-21 17:43 ` [bug#54508] [PATCH 1/2] build: emacs-utils: Add a (as-display) subform to `emacs-substitute-variables' Maxim Cournoyer
@ 2022-03-21 17:43   ` Maxim Cournoyer
  2022-04-04  3:57     ` bug#54508: [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo Maxim Cournoyer
  0 siblings, 1 reply; 4+ messages in thread
From: Maxim Cournoyer @ 2022-03-21 17:43 UTC (permalink / raw)
  To: 54508; +Cc: Maxim Cournoyer

* gnu/packages/emacs-xyz.scm (emacs-gnugo)
[phases]{configure-default-gnugo-xpms-variable}: Rename to...
{configure}: ... this.  Patch the 'gnugo-program' variable.
[inputs]: Add gnugo.
[description]: Describe basic usage entry points.
---
 gnu/packages/emacs-xyz.scm | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..167d706c05 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -31,7 +31,7 @@
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2017 Mike Gerwitz <mtg@gnu.org>
-;;; Copyright © 2017, 2018, 2019, 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2017, 2018, 2019, 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2018 Sohom Bhattacharjee <soham.bhattacharjee15@gmail.com>
 ;;; Copyright © 2018, 2019 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2018, 2019, 2020, 2021 Pierre Neidhardt <mail@ambrevar.xyz>
@@ -157,6 +157,7 @@ (define-module (gnu packages emacs-xyz)
   #:use-module (gnu packages emacs)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages games)
   #:use-module (gnu packages golang)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages gtk)
@@ -14752,20 +14753,23 @@ (define-public emacs-gnugo
          "138gzdyi8scqimvs49da66j8f5a43bhgpasn1bxzdj2zffwlwp6g"))))
     (build-system emacs-build-system)
     (arguments
-     `(#:phases (modify-phases %standard-phases
-                  (add-after 'unpack 'configure-default-gnugo-xpms-variable
-                    (lambda _
-                      (substitute* "gnugo.el"
-                        (("defvar gnugo-xpms nil")
-                         "defvar gnugo-xpms #'gnugo-imgen-create-xpms"))
-                      #t)))))
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'configure
+           (lambda* (#:key inputs #:allow-other-keys)
+             (emacs-substitute-variables "gnugo.el"
+               ("gnugo-xpms" "#'gnugo-imgen-create-xpms" (as-display))
+               ("gnugo-program" (search-input-file inputs "/bin/gnugo"))))))))
+    (inputs (list gnugo))
     (propagated-inputs
      (list emacs-ascii-art-to-unicode emacs-xpm))
     (home-page "https://elpa.gnu.org/packages/gnugo.html")
     (synopsis "Emacs major mode for playing GNU Go")
-    (description "This package provides an Emacs based interface for GNU Go.
-It has a graphical mode where the board and stones are drawn using XPM images
-and supports the use of a mouse.")
+    (description "This package provides an Emacs based interface for GNU Go,
+which can be started via @samp{M-x gnugo}.  It has a graphical mode where the
+board and stones are drawn using XPM images and supports the use of a mouse.
+You can switch to the graphical mode by running @samp{M-x
+gnugo-image-display-mode}.")
     (license license:gpl3+)))
 
 (define-public emacs-gnuplot
-- 
2.34.0





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

* bug#54508: [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo.
  2022-03-21 17:43   ` [bug#54508] [PATCH 2/2] gnu: emacs-gnugo: Patch 'gnugo-program' variable Maxim Cournoyer
@ 2022-04-04  3:57     ` Maxim Cournoyer
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Cournoyer @ 2022-04-04  3:57 UTC (permalink / raw)
  To: 54508-done

Hello,

Pushed as 4ddbcbb6b8d134d9ce9a8d191ba3f0079084eaf8.

Closing.

Maxim




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

end of thread, other threads:[~2022-04-04  3:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 17:41 [bug#54508] [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo Maxim Cournoyer
2022-03-21 17:43 ` [bug#54508] [PATCH 1/2] build: emacs-utils: Add a (as-display) subform to `emacs-substitute-variables' Maxim Cournoyer
2022-03-21 17:43   ` [bug#54508] [PATCH 2/2] gnu: emacs-gnugo: Patch 'gnugo-program' variable Maxim Cournoyer
2022-04-04  3:57     ` bug#54508: [PATCH 0/2] Extend emacs-substitute-variables and patch emacs-gnugo Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).