unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#61434] [PATCH] gnu: Add emacs-pasp-mode.
@ 2023-02-11 15:15 Liliana Marie Prikler
  2023-02-11 15:15 ` Liliana Marie Prikler
  2023-02-11 16:59 ` [bug#61434] " Nicolas Goaziou
  0 siblings, 2 replies; 6+ messages in thread
From: Liliana Marie Prikler @ 2023-02-11 15:15 UTC (permalink / raw)
  To: 61434

* gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch: New file.
* gnu/local.mk: Register it here.
* gnu/packages/emacs-xyz.scm (emacs-pasp-mode): New variable.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/emacs-xyz.scm                    | 47 +++++++++++++++++++
 .../emacs-pasp-mode-quote-file-names.patch    | 20 ++++++++
 3 files changed, 68 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index bf4b20577d..0548fc4e3d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1070,6 +1070,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch   \
   %D%/packages/patches/emacs-native-comp-driver-options.patch   \
+  %D%/packages/patches/emacs-emacs-pasp-mode-quote-file-names.patch  \
   %D%/packages/patches/emacs-polymode-fix-lexical-variable-error.patch  \
   %D%/packages/patches/emacs-source-date-epoch.patch		\
   %D%/packages/patches/emacs-telega-path-placeholder.patch	\
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index bbaafcc730..b6780ace02 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -4387,6 +4387,53 @@ (define-public emacs-pabbrev
 during idle time, while Emacs is doing nothing else.")
     (license license:gpl3+)))
 
+(define-public emacs-pasp-mode
+  (let ((commit "59385eb0e8ebcfc8c11dd811fb145d4b0fa3cc92")
+        (revision "1"))
+    (package
+     (name "emacs-pasp-mode")
+     (version (git-version "0.1.0" revision commit))
+     (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/santifa/pasp-mode.git")
+                    (commit commit)))
+              (patches
+               (search-patches "emacs-pasp-mode-quote-file-names.patch"))
+              (sha256
+               (base32
+                "1ar4vws3izzmir7m870mccci620ns3c5j26dcmwaxavhgw45wcmf"))))
+     (build-system emacs-build-system)
+     (arguments
+      (list
+       #:phases
+       #~(modify-phases %standard-phases
+           (add-after 'unpack 'defconst-version
+             (lambda _
+               (emacs-batch-edit-file "pasp-mode.el"
+                 '(progn
+                   (search-forward-regexp
+                           "(defcustom pasp-mode-version \"[^\"]*\"[
+ ]*\\(\"[^\"]*\"\\)[^()]*)")
+                   (let ((docstring (match-string 1)))
+                     (backward-sexp)
+                     (kill-sexp)
+                     (insert (format "(defconst emacs-pasp-version \"%s\" %s)"
+                                     #$version docstring))
+                     (basic-save-buffer))))))
+           (add-after 'unpack 'hardcode-clingo
+             (lambda* (#:key inputs #:allow-other-keys)
+               (emacs-substitute-variables "pasp-mode.el"
+                 ("pasp-clingo-path"
+                  (search-input-file inputs "/bin/clingo"))))))))
+     (inputs (list clingo))
+     (home-page "https://github.com/santifa/pasp-mode")
+     (synopsis "Major mode for editing Answer Set Programs.")
+     (description
+      "This package provides a major mode for editing answer set programs,
+in particular ones that can be solved by @command{clingo}.")
+     (license license:gpl3+))))
+
 (define-public emacs-pdf-tools
   (package
     (name "emacs-pdf-tools")
diff --git a/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch b/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch
new file mode 100644
index 0000000000..39dc5d0253
--- /dev/null
+++ b/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch
@@ -0,0 +1,20 @@
+diff --git a/pasp-mode.el b/pasp-mode.el
+index 7f83645..5daf08e 100644
+--- a/pasp-mode.el
++++ b/pasp-mode.el
+@@ -199,9 +199,12 @@
+ Argument ENCODING The current buffer which holds the problem encoding.
+ Optional argument INSTANCE The problem instance which is solved by the encoding.
+   If no instance it is assumed to be also in the encoding file."
+-  (if 'instance
+-      (concat pasp-clingo-path " " pasp-clingo-options " " encoding " " instance)
+-    (concat pasp-clingo-path " " pasp-clingo-options " " encoding)))
++  (if instance
++      (concat pasp-clingo-path " " pasp-clingo-options " "
++              (shell-quote-argument encoding) " "
++              (shell-quote-argument instance))
++    (concat pasp-clingo-path " " pasp-clingo-options " "
++            (shell-quote-argument encoding))))
+ 
+ (defun pasp-run-clingo (encoding &optional instance)
+   "Run Clingo with some ASP input files.
-- 
2.39.1





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

* [bug#61434] [PATCH] gnu: Add emacs-pasp-mode.
  2023-02-11 15:15 [bug#61434] [PATCH] gnu: Add emacs-pasp-mode Liliana Marie Prikler
@ 2023-02-11 15:15 ` Liliana Marie Prikler
  2023-02-19  7:42   ` bug#61434: " Liliana Marie Prikler
  2023-02-11 16:59 ` [bug#61434] " Nicolas Goaziou
  1 sibling, 1 reply; 6+ messages in thread
From: Liliana Marie Prikler @ 2023-02-11 15:15 UTC (permalink / raw)
  To: 61434; +Cc: Nicolas Goaziou

* gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch: New file.
* gnu/local.mk: Register it here.
* gnu/packages/emacs-xyz.scm (emacs-pasp-mode): New variable.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/emacs-xyz.scm                    | 48 +++++++++++++++++++
 .../emacs-pasp-mode-quote-file-names.patch    | 20 ++++++++
 3 files changed, 69 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index dc230d30d9..efbee0238b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1071,6 +1071,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch   \
   %D%/packages/patches/emacs-native-comp-driver-options.patch   \
+  %D%/packages/patches/emacs-pasp-mode-quote-file-names.patch  \
   %D%/packages/patches/emacs-polymode-fix-lexical-variable-error.patch  \
   %D%/packages/patches/emacs-source-date-epoch.patch		\
   %D%/packages/patches/emacs-telega-path-placeholder.patch	\
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 729c190969..49fa5df7e1 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -203,6 +203,7 @@ (define-module (gnu packages emacs-xyz)
   #:use-module (gnu packages lisp-xyz)
   #:use-module (gnu packages lsof)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages maths)
   #:use-module (gnu packages music)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages imagemagick)
@@ -4387,6 +4388,53 @@ (define-public emacs-pabbrev
 during idle time, while Emacs is doing nothing else.")
     (license license:gpl3+)))
 
+(define-public emacs-pasp-mode
+  (let ((commit "59385eb0e8ebcfc8c11dd811fb145d4b0fa3cc92")
+        (revision "1"))
+    (package
+     (name "emacs-pasp-mode")
+     (version (git-version "0.1.0" revision commit))
+     (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/santifa/pasp-mode")
+                    (commit commit)))
+              (patches
+               (search-patches "emacs-pasp-mode-quote-file-names.patch"))
+              (sha256
+               (base32
+                "1ar4vws3izzmir7m870mccci620ns3c5j26dcmwaxavhgw45wcmf"))))
+     (build-system emacs-build-system)
+     (arguments
+      (list
+       #:phases
+       #~(modify-phases %standard-phases
+           (add-after 'unpack 'defconst-version
+             (lambda _
+               (emacs-batch-edit-file "pasp-mode.el"
+                 '(progn
+                   (search-forward-regexp "(defcustom pasp-mode-version")
+                   (forward-sexp)
+                   (kill-sexp)
+                   (backward-sexp)
+                   (beginning-of-line)
+                   (kill-sexp)
+                   (insert (format "(defconst emacs-pasp-version \"%s\" %s)"
+                                   #$version (cadr kill-ring)))
+                   (basic-save-buffer)))))
+           (add-after 'unpack 'hardcode-clingo
+             (lambda* (#:key inputs #:allow-other-keys)
+               (emacs-substitute-variables "pasp-mode.el"
+                 ("pasp-clingo-path"
+                  (search-input-file inputs "/bin/clingo"))))))))
+     (inputs (list clingo))
+     (home-page "https://github.com/santifa/pasp-mode")
+     (synopsis "Major mode for editing answer set programs")
+     (description
+      "This package provides a major mode for editing answer set programs,
+in particular ones that can be solved by @command{clingo}.")
+     (license license:gpl3+))))
+
 (define-public emacs-pdf-tools
   (package
     (name "emacs-pdf-tools")
diff --git a/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch b/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch
new file mode 100644
index 0000000000..39dc5d0253
--- /dev/null
+++ b/gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch
@@ -0,0 +1,20 @@
+diff --git a/pasp-mode.el b/pasp-mode.el
+index 7f83645..5daf08e 100644
+--- a/pasp-mode.el
++++ b/pasp-mode.el
+@@ -199,9 +199,12 @@
+ Argument ENCODING The current buffer which holds the problem encoding.
+ Optional argument INSTANCE The problem instance which is solved by the encoding.
+   If no instance it is assumed to be also in the encoding file."
+-  (if 'instance
+-      (concat pasp-clingo-path " " pasp-clingo-options " " encoding " " instance)
+-    (concat pasp-clingo-path " " pasp-clingo-options " " encoding)))
++  (if instance
++      (concat pasp-clingo-path " " pasp-clingo-options " "
++              (shell-quote-argument encoding) " "
++              (shell-quote-argument instance))
++    (concat pasp-clingo-path " " pasp-clingo-options " "
++            (shell-quote-argument encoding))))
+ 
+ (defun pasp-run-clingo (encoding &optional instance)
+   "Run Clingo with some ASP input files.
-- 
2.39.1





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

* [bug#61434] [PATCH] gnu: Add emacs-pasp-mode.
  2023-02-11 15:15 [bug#61434] [PATCH] gnu: Add emacs-pasp-mode Liliana Marie Prikler
  2023-02-11 15:15 ` Liliana Marie Prikler
@ 2023-02-11 16:59 ` Nicolas Goaziou
  2023-02-11 17:24   ` Liliana Marie Prikler
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2023-02-11 16:59 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: 61434

Hello,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> * gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch: New file.
> * gnu/local.mk: Register it here.
> * gnu/packages/emacs-xyz.scm (emacs-pasp-mode): New variable.

Thank you. Some comments follow.

> +     (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/santifa/pasp-mode.git")

You can remove the ".git" suffix.

> +           (add-after 'unpack 'defconst-version
> +             (lambda _
> +               (emacs-batch-edit-file "pasp-mode.el"
> +                 '(progn
> +                   (search-forward-regexp
> +                           "(defcustom pasp-mode-version \"[^\"]*\"[
> + ]*\\(\"[^\"]*\"\\)[^()]*)")
> +                   (let ((docstring (match-string 1)))
> +                     (backward-sexp)
> +                     (kill-sexp)
> +                     (insert (format "(defconst emacs-pasp-version \"%s\" %s)"
> +                                     #$version docstring))
> +                     (basic-save-buffer))))))

This dance is not necessary. You can simply use
`emacs-substitute-variables', change the value, and keep the defcustom.
A defconst is not a constant in Elisp anyway.

> +     (synopsis "Major mode for editing Answer Set Programs.")

You can remove the final full stop.

It may be clearer to also mention "Potassco" so as to understand better
the PASP acronym.

> +     (description
> +      "This package provides a major mode for editing answer set programs,
> +in particular ones that can be solved by @command{clingo}.")

I suggest "Answer Set Programs", since this seems to be a very specific thing.

I didn't build it, but LGTM.

Regards,
-- 
Nicolas Goaziou




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

* [bug#61434] [PATCH] gnu: Add emacs-pasp-mode.
  2023-02-11 16:59 ` [bug#61434] " Nicolas Goaziou
@ 2023-02-11 17:24   ` Liliana Marie Prikler
  2023-02-11 18:55     ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Liliana Marie Prikler @ 2023-02-11 17:24 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: 61434

Am Samstag, dem 11.02.2023 um 17:59 +0100 schrieb Nicolas Goaziou:
> > +     (source (origin
> > +              (method git-fetch)
> > +              (uri (git-reference
> > +                    (url
> > "https://github.com/santifa/pasp-mode.git")
> 
> You can remove the ".git" suffix.
Will do.

> > +           (add-after 'unpack 'defconst-version
> > +             (lambda _
> > +               (emacs-batch-edit-file "pasp-mode.el"
> > +                 '(progn
> > +                   (search-forward-regexp
> > +                           "(defcustom pasp-mode-version
> > \"[^\"]*\"[
> > + ]*\\(\"[^\"]*\"\\)[^()]*)")
> > +                   (let ((docstring (match-string 1)))
> > +                     (backward-sexp)
> > +                     (kill-sexp)
> > +                     (insert (format "(defconst emacs-pasp-version
> > \"%s\" %s)"
> > +                                     #$version docstring))
> > +                     (basic-save-buffer))))))
> 
> This dance is not necessary. You can simply use
> `emacs-substitute-variables', change the value, and keep the
> defcustom.  A defconst is not a constant in Elisp anyway.
A defconst does raise a warning if it's changed, so I'd rather do that.

> > +     (synopsis "Major mode for editing Answer Set Programs.")
> 
> You can remove the final full stop.
Will do that.

> It may be clearer to also mention "Potassco" so as to understand
> better the PASP acronym.
Somewhat unsure about this.

> > +     (description
> > +      "This package provides a major mode for editing answer set
> > programs,
> > +in particular ones that can be solved by @command{clingo}.")
> 
> I suggest "Answer Set Programs", since this seems to be a very
> specific thing.
Also unsure about this, since there doesn't seem to be a coherent term
shared among the clingo packages and if we do that, I think it should
be applied across the board.

Cheers

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

* [bug#61434] [PATCH] gnu: Add emacs-pasp-mode.
  2023-02-11 17:24   ` Liliana Marie Prikler
@ 2023-02-11 18:55     ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2023-02-11 18:55 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: 61434

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

>> This dance is not necessary. You can simply use
>> `emacs-substitute-variables', change the value, and keep the
>> defcustom.  A defconst is not a constant in Elisp anyway.
> A defconst does raise a warning if it's changed, so I'd rather do
> that.

It seems that you are trying to fix a design issue without any serious
usability consequence (who is going to set this variable anyway? Why
would it matter to us?). I believe this kind of fix is out of the scope
of a package definition.

Besides, it makes the definition less readable, to say the least. The
regexp itself is appalling (not that you can do much about it, of
course).

If you really insist of changing this defcustom, maybe 1. search forward
for "defcustom pasp-mode-version" 2. kill next regexp 3. insert
"#$version" 4. search backward for "defcustom", 5. replace match with
"defconst". It would still be awful (no serious regexp), but possibly
slightly less so.




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

* bug#61434: [PATCH] gnu: Add emacs-pasp-mode.
  2023-02-11 15:15 ` Liliana Marie Prikler
@ 2023-02-19  7:42   ` Liliana Marie Prikler
  0 siblings, 0 replies; 6+ messages in thread
From: Liliana Marie Prikler @ 2023-02-19  7:42 UTC (permalink / raw)
  To: 61434-done; +Cc: Nicolas Goaziou

Am Samstag, dem 11.02.2023 um 16:15 +0100 schrieb Liliana Marie
Prikler:
> * gnu/packages/patches/emacs-pasp-mode-quote-file-names.patch: New
> file.
> * gnu/local.mk: Register it here.
> * gnu/packages/emacs-xyz.scm (emacs-pasp-mode): New variable.
Pushed.




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

end of thread, other threads:[~2023-02-19  7:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-11 15:15 [bug#61434] [PATCH] gnu: Add emacs-pasp-mode Liliana Marie Prikler
2023-02-11 15:15 ` Liliana Marie Prikler
2023-02-19  7:42   ` bug#61434: " Liliana Marie Prikler
2023-02-11 16:59 ` [bug#61434] " Nicolas Goaziou
2023-02-11 17:24   ` Liliana Marie Prikler
2023-02-11 18:55     ` Nicolas Goaziou

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).