* [PATCH 4/6] gnu: Add emacs-constants.
@ 2015-12-30 17:33 Federico Beffa
2016-01-05 22:08 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Federico Beffa @ 2015-12-30 17:33 UTC (permalink / raw)
To: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 366 bytes --]
If found a few times the need to download a single, uncompressed file
which needs to be patched. The available fetch methods do not appear
to be appropriate. So, I've added the function
'uncompressed-file-fetch'. This and the function
'broken-tarball-fetch' which currently resides in 'engineering.scm'
should probably belong to '(guix build utils)'.
Regards,
Fede
[-- Attachment #2: 0004-gnu-Add-emacs-constants.patch --]
[-- Type: text/x-diff, Size: 7131 bytes --]
From 6035d4dfd7542a615fbd70bd80527c15424185a3 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Sat, 26 Dec 2015 11:02:01 +0100
Subject: [PATCH 4/6] gnu: Add emacs-constants.
* gnu/packages/emacs.scm (emacs-constants): New variable.
* gnu/packages/patches/emacs-constants-lisp-like.patch: New patch.
* gnu-system.am (dist_patch_DATA): Add it.
---
gnu-system.am | 1 +
gnu/packages/emacs.scm | 41 +++++++++++
.../patches/emacs-constants-lisp-like.patch | 81 ++++++++++++++++++++++
3 files changed, 123 insertions(+)
create mode 100644 gnu/packages/patches/emacs-constants-lisp-like.patch
diff --git a/gnu-system.am b/gnu-system.am
index 83a7e92..02f77ae 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -450,6 +450,7 @@ dist_patch_DATA = \
gnu/packages/patches/elfutils-tests-ptrace.patch \
gnu/packages/patches/emacs-exec-path.patch \
gnu/packages/patches/emacs-scheme-complete-scheme-r5rs-info.patch \
+ gnu/packages/patches/emacs-constants-lisp-like.patch \
gnu/packages/patches/eudev-rules-directory.patch \
gnu/packages/patches/evilwm-lost-focus-bug.patch \
gnu/packages/patches/expat-CVE-2015-1283.patch \
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 3a7c4ad..cc6fd85 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -26,6 +26,9 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix gexp)
+ #:use-module (guix monads)
+ #:use-module (guix store)
#:use-module (guix build-system gnu)
#:use-module (guix build-system emacs)
#:use-module (guix build-system glib-or-gtk)
@@ -1245,3 +1248,41 @@ to a key in your preferred mode.")
"This package provides a set of Emacs functions to search definitions of
identifiers in the MIT-Scheme documentation.")
(license license:gpl2+)))
+
+;;; XXX: move this procedure to an utility module
+(define* (uncompressed-file-fetch url hash-algo hash
+ #:optional name
+ #:key (system (%current-system))
+ (guile (default-guile)))
+ (mlet %store-monad ((drv (url-fetch url hash-algo hash name
+ #:system system
+ #:guile guile)))
+ (gexp->derivation (or name (basename url))
+ #~(begin
+ (mkdir #$output)
+ (setenv "PATH"
+ (string-append #$gzip "/bin"))
+ (chdir #$output)
+ (copy-file #$drv (basename #$url))))))
+
+(define-public emacs-constants
+ (package
+ (name "emacs-constants")
+ (version "2.2")
+ (source
+ (origin
+ (file-name (string-append name "-" version ".el"))
+ (method uncompressed-file-fetch)
+ (uri "https://staff.fnwi.uva.nl/c.dominik/Tools/constants/constants.el")
+ (patches
+ (list (search-patch "emacs-constants-lisp-like.patch")))
+ (sha256
+ (base32
+ "14q094aphsjhq8gklv7i5a7byl0ygz63cv3n6b5p8ji2jy0mnnw3"))))
+ (build-system emacs-build-system)
+ (home-page "https://staff.fnwi.uva.nl/c.dominik/Tools/constants")
+ (synopsis "Enter definition of constants into an Emacs buffer")
+ (description
+ "This package provides functions for inserting the definition of natural
+constants and units into an Emacs buffer.")
+ (license license:gpl2+)))
diff --git a/gnu/packages/patches/emacs-constants-lisp-like.patch b/gnu/packages/patches/emacs-constants-lisp-like.patch
new file mode 100644
index 0000000..5ec37f3
--- /dev/null
+++ b/gnu/packages/patches/emacs-constants-lisp-like.patch
@@ -0,0 +1,81 @@
+Add Scheme support
+
+--- constants/constants.el.orig 2015-12-26 17:44:31.734520833 +0100
++++ constants/constants.el 2015-12-30 17:41:28.402871263 +0100
+@@ -684,6 +684,33 @@
+
+ (eval-when-compile (defvar ctable))
+
++(defun constants-is-lisp-like (mode)
++ (save-match-data
++ (string-match "\\(lisp\\|scheme\\)" (symbol-name mode))))
++
++(defun constants-is-set-like ()
++ (save-excursion
++ (condition-case nil
++ (save-match-data
++ (progn (up-list -1)
++ (or (looking-at "(set[qf!]?\\>") (looking-at "(define\\>"))))
++ (error nil)))) ; return value nil means use default
++
++;;;###autoload
++(defun constants-lisp-like-function ()
++ "Check context for constants insertion."
++ (if (constants-is-set-like)
++ '(emacs-lisp-mode "%n %v%t; %d %u" "e" "(* %p %v)")
++ '(emacs-lisp-mode "(%n %v)%t; %d %u" "e" "(* %p %v)")))
++
++;;;###autoload
++(mapc (lambda (mode-hook)
++ (add-hook mode-hook
++ (lambda ()
++ (setq constants-language-function
++ 'constants-lisp-like-function))))
++ '(scheme-mode-hook emacs-lisp-mode-hook lisp-mode-hook))
++
+ ;;;###autoload
+ (defun constants-insert (&optional unit-system names)
+ "Insert one or more natural constant definitions in source code.
+@@ -826,8 +853,9 @@
+ (funcall process-func ins))
+ ;; Here comes the insertion stuff for source code editing modes.
+ ;; First make sure we start a new line
+- (if (string-match
+- "\\S-" (buffer-substring (point-at-bol) (point-at-eol)))
++ (if (and (string-match
++ "\\S-" (buffer-substring (point-at-bol) (point-at-eol)))
++ (not (constants-is-lisp-like mode)))
+ ;; non-empty line, insert after this line
+ (progn
+ (end-of-line 1)
+@@ -841,13 +869,24 @@
+ (if (string-match "\\(.*\\)%t\\(.*\\)" line)
+ (let ((comment-column 42))
+ (insert (match-string 1 line))
+- (indent-to comment-column)
+- (insert (match-string 2 line)))
++ (if (and (constants-is-lisp-like mode)
++ (or (constants-is-set-like)
++ (null clist)))
++ (save-excursion
++ (progn
++ (move-to-column comment-column t)
++ (insert (match-string 2 line))
++ ;; insert a newline such that paredit's M-) can mode
++ ;; the closing parentheses to the next line.
++ (newline-and-indent)))
++ (progn
++ (indent-to comment-column)
++ (insert (match-string 2 line)))))
+ (insert line)))
+- (if constants-indent-code
+- (newline-and-indent)
+- (newline))))))
+-
++ (unless (and (constants-is-lisp-like mode) (null clist))
++ (if constants-indent-code
++ (newline-and-indent)
++ (newline)))))))
+ ;;;###autoload
+ (defun constants-get (&optional const message)
+ "Return the value of CONST as defined in the constants package.
--
2.6.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 4/6] gnu: Add emacs-constants.
2015-12-30 17:33 [PATCH 4/6] gnu: Add emacs-constants Federico Beffa
@ 2016-01-05 22:08 ` Ludovic Courtès
2016-01-09 10:42 ` Federico Beffa
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2016-01-05 22:08 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> If found a few times the need to download a single, uncompressed file
> which needs to be patched. The available fetch methods do not appear
> to be appropriate. So, I've added the function
> 'uncompressed-file-fetch'. This and the function
> 'broken-tarball-fetch' which currently resides in 'engineering.scm'
> should probably belong to '(guix build utils)'.
Rather (guix download).
> From 6035d4dfd7542a615fbd70bd80527c15424185a3 Mon Sep 17 00:00:00 2001
> From: Federico Beffa <beffa@fbengineering.ch>
> Date: Sat, 26 Dec 2015 11:02:01 +0100
> Subject: [PATCH 4/6] gnu: Add emacs-constants.
>
> * gnu/packages/emacs.scm (emacs-constants): New variable.
> * gnu/packages/patches/emacs-constants-lisp-like.patch: New patch.
> * gnu-system.am (dist_patch_DATA): Add it.
[...]
> +(define* (uncompressed-file-fetch url hash-algo hash
> + #:optional name
> + #:key (system (%current-system))
> + (guile (default-guile)))
> + (mlet %store-monad ((drv (url-fetch url hash-algo hash name
> + #:system system
> + #:guile guile)))
> + (gexp->derivation (or name (basename url))
> + #~(begin
> + (mkdir #$output)
> + (setenv "PATH"
> + (string-append #$gzip "/bin"))
> + (chdir #$output)
> + (copy-file #$drv (basename #$url))))))
The dependency on gzip can be removed.
Also, the second derivation is okay, but kind of wasteful: it only
serves to move the file in a directory so the patch-application logic
can work.
However, I’m unsure the patch in question really belongs here. After
all, there’s just one file, and additionally it’s called ‘constants.el’!
;-)
> diff --git a/gnu/packages/patches/emacs-constants-lisp-like.patch b/gnu/packages/patches/emacs-constants-lisp-like.patch
> new file mode 100644
> index 0000000..5ec37f3
> --- /dev/null
> +++ b/gnu/packages/patches/emacs-constants-lisp-like.patch
> @@ -0,0 +1,81 @@
> +Add Scheme support
This is too terse, and I feel like the patch really does upstream work.
It seems that the file has a new home (or is it just a mirror?) at
https://github.com/emacsmirror/constants/blob/master/constants.el
Is the patch yours? If yes, could you find an upstream to submit it
too? If there’s no such thing, you could always become the upstream.
;-)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/6] gnu: Add emacs-constants.
2016-01-05 22:08 ` Ludovic Courtès
@ 2016-01-09 10:42 ` Federico Beffa
2016-01-10 20:45 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Federico Beffa @ 2016-01-09 10:42 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Tue, Jan 5, 2016 at 11:08 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>> +(define* (uncompressed-file-fetch url hash-algo hash
>> + #:optional name
>> + #:key (system (%current-system))
>> + (guile (default-guile)))
>> + (mlet %store-monad ((drv (url-fetch url hash-algo hash name
>> + #:system system
>> + #:guile guile)))
>> + (gexp->derivation (or name (basename url))
>> + #~(begin
>> + (mkdir #$output)
>> + (setenv "PATH"
>> + (string-append #$gzip "/bin"))
>> + (chdir #$output)
>> + (copy-file #$drv (basename #$url))))))
>
> The dependency on gzip can be removed.
>
> Also, the second derivation is okay, but kind of wasteful: it only
> serves to move the file in a directory so the patch-application logic
> can work.
Of course it would be better if the patch logic would recognize this
case. Then we wouldn't need the above procedure.
>
> However, I’m unsure the patch in question really belongs here. After
> all, there’s just one file, and additionally it’s called ‘constants.el’!
> ;-)
I'm not sure I understand what you are trying to say. Could you please
be more explicit.
>
>> diff --git a/gnu/packages/patches/emacs-constants-lisp-like.patch b/gnu/packages/patches/emacs-constants-lisp-like.patch
>> new file mode 100644
>> index 0000000..5ec37f3
>> --- /dev/null
>> +++ b/gnu/packages/patches/emacs-constants-lisp-like.patch
>> @@ -0,0 +1,81 @@
>> +Add Scheme support
>
> This is too terse, and I feel like the patch really does upstream work.
>
> It seems that the file has a new home (or is it just a mirror?) at
>
> https://github.com/emacsmirror/constants/blob/master/constants.el
>
> Is the patch yours? If yes, could you find an upstream to submit it
> too? If there’s no such thing, you could always become the upstream.
> ;-)
The above URL is just a snapshot of the file. No activity whatsoever.
Yes, the patch is mine, following suggestions in the file itself. It
is to make the package usable with lisp like syntax so that you don't
get e.g.:
c = 2.99...e8
when you insert a constant in a scheme/lisp buffer. Isn't this project
fanatic about scheme? ;-)
I don't think there is an upstream. In any case I have no intention of
becoming one.
Thanks for the review.
Regards,
Fede
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/6] gnu: Add emacs-constants.
2016-01-09 10:42 ` Federico Beffa
@ 2016-01-10 20:45 ` Ludovic Courtès
2016-02-03 9:53 ` Federico Beffa
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2016-01-10 20:45 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> On Tue, Jan 5, 2016 at 11:08 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Federico Beffa <beffa@ieee.org> skribis:
>
>>> +(define* (uncompressed-file-fetch url hash-algo hash
>>> + #:optional name
>>> + #:key (system (%current-system))
>>> + (guile (default-guile)))
>>> + (mlet %store-monad ((drv (url-fetch url hash-algo hash name
>>> + #:system system
>>> + #:guile guile)))
>>> + (gexp->derivation (or name (basename url))
>>> + #~(begin
>>> + (mkdir #$output)
>>> + (setenv "PATH"
>>> + (string-append #$gzip "/bin"))
>>> + (chdir #$output)
>>> + (copy-file #$drv (basename #$url))))))
>>
>> The dependency on gzip can be removed.
>>
>> Also, the second derivation is okay, but kind of wasteful: it only
>> serves to move the file in a directory so the patch-application logic
>> can work.
>
> Of course it would be better if the patch logic would recognize this
> case. Then we wouldn't need the above procedure.
It depends on the maintenance cost, because it’s a rare use case, I think.
>> However, I’m unsure the patch in question really belongs here. After
>> all, there’s just one file, and additionally it’s called ‘constants.el’!
>> ;-)
>
> I'm not sure I understand what you are trying to say. Could you please
> be more explicit.
[...]
>> https://github.com/emacsmirror/constants/blob/master/constants.el
>>
>> Is the patch yours? If yes, could you find an upstream to submit it
>> too? If there’s no such thing, you could always become the upstream.
>> ;-)
>
> The above URL is just a snapshot of the file. No activity whatsoever.
>
> Yes, the patch is mine, following suggestions in the file itself. It
> is to make the package usable with lisp like syntax so that you don't
> get e.g.:
>
> c = 2.99...e8
>
> when you insert a constant in a scheme/lisp buffer. Isn't this project
> fanatic about scheme? ;-)
It is! :-)
> I don't think there is an upstream. In any case I have no intention of
> becoming one.
You’re effectively becoming one, though.
Could get in touch with Carsten Dominik, for instance, and propose the
patch?
If he has no interest or is unresponsive, then we can choose to maintain
it in Guix as you propose. But since the changes are not Guix-specific
in any way, I think our job is to first try to get it upstream.
Does that make sense?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/6] gnu: Add emacs-constants.
2016-01-10 20:45 ` Ludovic Courtès
@ 2016-02-03 9:53 ` Federico Beffa
2016-02-03 21:52 ` Ludovic Courtès
0 siblings, 1 reply; 6+ messages in thread
From: Federico Beffa @ 2016-02-03 9:53 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Sun, Jan 10, 2016 at 9:45 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Could get in touch with Carsten Dominik, for instance, and propose the
> patch?
Dominik was kind enough to accept the patch. So, I've now pushed it.
Once the new release will be out, we can drop it.
Regards,
Fede
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/6] gnu: Add emacs-constants.
2016-02-03 9:53 ` Federico Beffa
@ 2016-02-03 21:52 ` Ludovic Courtès
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2016-02-03 21:52 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> On Sun, Jan 10, 2016 at 9:45 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Could get in touch with Carsten Dominik, for instance, and propose the
>> patch?
>
> Dominik was kind enough to accept the patch. So, I've now pushed it.
> Once the new release will be out, we can drop it.
Excellent, thank you!
Ludo’.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-03 21:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-30 17:33 [PATCH 4/6] gnu: Add emacs-constants Federico Beffa
2016-01-05 22:08 ` Ludovic Courtès
2016-01-09 10:42 ` Federico Beffa
2016-01-10 20:45 ` Ludovic Courtès
2016-02-03 9:53 ` Federico Beffa
2016-02-03 21:52 ` Ludovic Courtès
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).