summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Beffa <beffa@fbengineering.ch>2015-12-26 11:02:01 +0100
committerFederico Beffa <beffa@fbengineering.ch>2016-02-03 10:48:36 +0100
commite5045f303a0214c2e436c128ce3d6c59cf276f2a (patch)
tree92a15969e303fe8d8b6eaf6ebe9fb9c09e04ce9e
parent58a7dc1340986f11ff54a970f613a03e8ebd741c (diff)
downloadguix-patches-e5045f303a0214c2e436c128ce3d6c59cf276f2a.tar
guix-patches-e5045f303a0214c2e436c128ce3d6c59cf276f2a.tar.gz
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.
-rw-r--r--gnu-system.am1
-rw-r--r--gnu/packages/emacs.scm41
-rw-r--r--gnu/packages/patches/emacs-constants-lisp-like.patch81
3 files changed, 123 insertions, 0 deletions
diff --git a/gnu-system.am b/gnu-system.am
index 7b22138018..d282be3deb 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -452,6 +452,7 @@ dist_patch_DATA = \
gnu/packages/patches/duplicity-piped-password.patch \
gnu/packages/patches/duplicity-test_selection-tmp.patch \
gnu/packages/patches/elfutils-tests-ptrace.patch \
+ gnu/packages/patches/emacs-constants-lisp-like.patch \
gnu/packages/patches/emacs-exec-path.patch \
gnu/packages/patches/emacs-scheme-complete-scheme-r5rs-info.patch \
gnu/packages/patches/emacs-source-date-epoch.patch \
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 852945c135..50419c0537 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)
@@ -1297,3 +1300,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 0000000000..5ec37f3adf
--- /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.