gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / emacs.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2014 Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com>
5 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014, 2015, 2016, 2017 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2016, 2018 Arun Isaac <arunisaac@systemreboot.net>
8 ;;; Copyright © 2016 Federico Beffa <beffa@fbengineering.ch>
9 ;;; Copyright © 2016 David Thompson <dthompson2@worcester.edu>
10 ;;; Copyright © 2016 ng0 <ng0@n0.is>
11 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
12 ;;; Copyright © 2017, 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
13 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
14 ;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
15 ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
16 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
17 ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
18 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
19 ;;; Copyright © 2019 Jesse John Gildersleve <jessejohngildersleve@zohomail.eu>
20 ;;; Copyright © 2019 Valentin Ignatev <valentignatev@gmail.com>
21 ;;; Copyright © 2019 Leo Prikler <leo.prikler@student.tugraz.at>
22 ;;; Copyright © 2019 Amin Bandali <bandali@gnu.org>
23 ;;;
24 ;;; This file is part of GNU Guix.
25 ;;;
26 ;;; GNU Guix is free software; you can redistribute it and/or modify it
27 ;;; under the terms of the GNU General Public License as published by
28 ;;; the Free Software Foundation; either version 3 of the License, or (at
29 ;;; your option) any later version.
30 ;;;
31 ;;; GNU Guix is distributed in the hope that it will be useful, but
32 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
33 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 ;;; GNU General Public License for more details.
35 ;;;
36 ;;; You should have received a copy of the GNU General Public License
37 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
38
39 (define-module (gnu packages emacs)
40 #:use-module ((guix licenses) #:prefix license:)
41 #:use-module (guix packages)
42 #:use-module (guix download)
43 #:use-module (guix git-download)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system glib-or-gtk)
46 #:use-module (gnu packages)
47 #:use-module (gnu packages acl)
48 #:use-module (gnu packages autotools)
49 #:use-module (gnu packages base)
50 #:use-module (gnu packages compression)
51 #:use-module (gnu packages fontutils)
52 #:use-module (gnu packages fribidi)
53 #:use-module (gnu packages gd)
54 #:use-module (gnu packages gettext)
55 #:use-module (gnu packages glib)
56 #:use-module (gnu packages gnome) ; for librsvg
57 #:use-module (gnu packages gtk)
58 #:use-module (gnu packages guile)
59 #:use-module (gnu packages image)
60 #:use-module (gnu packages imagemagick)
61 #:use-module (gnu packages linux) ; alsa-lib
62 #:use-module (gnu packages mail) ; for mailutils
63 #:use-module (gnu packages ncurses)
64 #:use-module (gnu packages pkg-config)
65 #:use-module (gnu packages texinfo)
66 #:use-module (gnu packages tls)
67 #:use-module (gnu packages web) ; for jansson
68 #:use-module (gnu packages webkit)
69 #:use-module (gnu packages xml)
70 #:use-module (gnu packages xorg)
71 #:use-module (guix utils)
72 #:use-module (srfi srfi-1))
73
74 (define-public emacs
75 (package
76 (name "emacs")
77 (version "26.3")
78 (source (origin
79 (method url-fetch)
80 (uri (string-append "mirror://gnu/emacs/emacs-"
81 version ".tar.xz"))
82 (sha256
83 (base32
84 "119ldpk7sgn9jlpyngv5y4z3i7bb8q3xp4p0qqi7i5nq39syd42d"))
85 (patches (search-patches "emacs-exec-path.patch"
86 "emacs-fix-scheme-indent-function.patch"
87 "emacs-source-date-epoch.patch"))
88 (modules '((guix build utils)))
89 (snippet
90 '(with-directory-excursion "lisp"
91 ;; Delete the bundled byte-compiled elisp files and generated
92 ;; autoloads.
93 (for-each delete-file
94 (append (find-files "." "\\.elc$")
95 (find-files "." "loaddefs\\.el$")
96 ;; This is the only "autoloads" file that
97 ;; does not have "*loaddefs.el" name.
98 ;; TODO: Next time changing this package,
99 ;; replace the following with a call to
100 ;; `find-files', so that `delete-file'
101 ;; wouldn't error out when the file is
102 ;; missing, making the entire snippet field
103 ;; reusable as-is for `emacs-next' below.
104 '("eshell/esh-groups.el")))
105
106 ;; Make sure Tramp looks for binaries in the right places on
107 ;; remote Guix System machines, where 'getconf PATH' returns
108 ;; something bogus.
109 (substitute* "net/tramp-sh.el"
110 ;; Patch the line after "(defcustom tramp-remote-path".
111 (("\\(tramp-default-remote-path")
112 (format #f "(tramp-default-remote-path ~s ~s ~s ~s "
113 "~/.guix-profile/bin" "~/.guix-profile/sbin"
114 "/run/current-system/profile/bin"
115 "/run/current-system/profile/sbin")))
116
117 ;; Make sure Man looks for C header files in the right
118 ;; places.
119 (substitute* "man.el"
120 (("\"/usr/local/include\"" line)
121 (string-join
122 (list line
123 "\"~/.guix-profile/include\""
124 "\"/var/guix/profiles/system/profile/include\"")
125 " ")))
126 #t))))
127 (build-system glib-or-gtk-build-system)
128 (arguments
129 `(#:tests? #f ; no check target
130 #:configure-flags (list "--with-modules"
131 "--disable-build-details")
132 #:phases
133 (modify-phases %standard-phases
134 (add-before 'configure 'fix-/bin/pwd
135 (lambda _
136 ;; Use `pwd', not `/bin/pwd'.
137 (substitute* (find-files "." "^Makefile\\.in$")
138 (("/bin/pwd")
139 "pwd"))
140 #t))
141 (add-after 'install 'install-site-start
142 ;; Use 'guix-emacs' in "site-start.el". This way, Emacs packages
143 ;; provided by Guix and installed in
144 ;; ~/.guix-profile/share/emacs/site-lisp/guix.d/PACKAGE-VERSION are
145 ;; automatically found.
146 (lambda* (#:key inputs outputs #:allow-other-keys)
147 (let* ((out (assoc-ref outputs "out"))
148 (lisp-dir (string-append out "/share/emacs/site-lisp")))
149 (copy-file (assoc-ref inputs "guix-emacs.el")
150 (string-append lisp-dir "/guix-emacs.el"))
151 (with-output-to-file (string-append lisp-dir "/site-start.el")
152 (lambda ()
153 (display
154 (string-append "(when (require 'guix-emacs nil t)\n"
155 " (guix-emacs-autoload-packages))\n"))))
156 ;; Remove the extraneous subdirs.el file, as it causes Emacs to
157 ;; add recursively all the the sub-directories of a profile's
158 ;; share/emacs/site-lisp union when added to EMACSLOADPATH,
159 ;; which leads to conflicts.
160 (delete-file (string-append lisp-dir "/subdirs.el"))
161 #t))))))
162 (inputs
163 `(("gnutls" ,gnutls)
164 ("ncurses" ,ncurses)
165
166 ;; Avoid Emacs's limited movemail substitute that retrieves POP3 email
167 ;; only via insecure channels. This is not needed for (modern) IMAP.
168 ("mailutils" ,mailutils)
169
170 ;; TODO: Add the optional dependencies.
171 ("libx11" ,libx11)
172 ("gtk+" ,gtk+)
173 ("libxft" ,libxft)
174 ("libtiff" ,libtiff)
175 ("giflib" ,giflib)
176 ("libjpeg" ,libjpeg)
177 ("imagemagick" ,imagemagick)
178 ("acl" ,acl)
179
180 ;; When looking for libpng `configure' links with `-lpng -lz', so we
181 ;; must also provide zlib as an input.
182 ("libpng" ,libpng)
183 ("zlib" ,zlib)
184
185 ("librsvg" ,librsvg)
186 ("libxpm" ,libxpm)
187 ("libxml2" ,libxml2)
188 ("libice" ,libice)
189 ("libsm" ,libsm)
190 ("alsa-lib" ,alsa-lib)
191 ("dbus" ,dbus)
192
193 ;; multilingualization support
194 ("libotf" ,libotf)
195 ("m17n-lib" ,m17n-lib)))
196 (native-inputs
197 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
198 ("pkg-config" ,pkg-config)
199 ("texinfo" ,texinfo)))
200
201 (native-search-paths
202 (list (search-path-specification
203 (variable "EMACSLOADPATH")
204 ;; The versioned entry is for the Emacs' builtin libraries.
205 (files (list "share/emacs/site-lisp"
206 (string-append "share/emacs/" version "/lisp"))))
207 (search-path-specification
208 (variable "INFOPATH")
209 (files '("share/info")))))
210
211 (home-page "https://www.gnu.org/software/emacs/")
212 (synopsis "The extensible, customizable, self-documenting text editor")
213 (description
214 "GNU Emacs is an extensible and highly customizable text editor. It is
215 based on an Emacs Lisp interpreter with extensions for text editing. Emacs
216 has been extended in essentially all areas of computing, giving rise to a
217 vast array of packages supporting, e.g., email, IRC and XMPP messaging,
218 spreadsheets, remote server editing, and much more. Emacs includes extensive
219 documentation on all aspects of the system, from basic editing to writing
220 large Lisp programs. It has full Unicode support for nearly all human
221 languages.")
222 (license license:gpl3+)))
223
224 (define-public emacs-next
225 (let ((commit "36abf6864604b3061c2e070f8997491fa2bce44c")
226 (revision "0")
227 (emacs-version "27.0.50"))
228 (package
229 (inherit emacs)
230 (name "emacs-next")
231 (version (git-version emacs-version revision commit))
232 (source
233 (origin
234 (method git-fetch)
235 (uri (git-reference
236 (url "https://git.savannah.gnu.org/git/emacs.git")
237 (commit commit)))
238 (sha256
239 (base32 "1ckn607p0clz0dhhlizvv7l03p4nminy48h53xrpz55w4rcrcm2l"))
240 (file-name (git-file-name name version))
241 (patches (search-patches "emacs27-exec-path.patch"
242 "emacs-fix-scheme-indent-function.patch"
243 "emacs-source-date-epoch.patch"))
244 (modules (origin-modules (package-source emacs)))
245 ;; TODO: once the snippet for `emacs' is changed to not fail when
246 ;; eshell/esh-groups.el does not exist, replace this snippet with
247 ;; (snippet (origin-snippet (package-source emacs))))).
248 (snippet
249 '(with-directory-excursion "lisp"
250 ;; Make sure Tramp looks for binaries in the right places on
251 ;; remote Guix System machines, where 'getconf PATH' returns
252 ;; something bogus.
253 (substitute* "net/tramp-sh.el"
254 ;; Patch the line after "(defcustom tramp-remote-path".
255 (("\\(tramp-default-remote-path")
256 (format #f "(tramp-default-remote-path ~s ~s ~s ~s "
257 "~/.guix-profile/bin" "~/.guix-profile/sbin"
258 "/run/current-system/profile/bin"
259 "/run/current-system/profile/sbin")))
260
261 ;; Make sure Man looks for C header files in the right
262 ;; places.
263 (substitute* "man.el"
264 (("\"/usr/local/include\"" line)
265 (string-join
266 (list line
267 "\"~/.guix-profile/include\""
268 "\"/var/guix/profiles/system/profile/include\"")
269 " ")))
270 #t))))
271 (arguments
272 (substitute-keyword-arguments (package-arguments emacs)
273 ((#:phases phases)
274 `(modify-phases ,phases
275 ;; The 'reset-gzip-timestamps phase will throw a
276 ;; permission error if gzip files aren't writable then
277 (add-before
278 'reset-gzip-timestamps
279 'make-compressed-files-writable
280 (lambda _
281 (for-each make-file-writable
282 (find-files %output ".*\\.t?gz$"))
283 #t))
284 ;; restore the dump file that Emacs installs somewhere in
285 ;; libexec/ to its original state
286 (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
287 (lambda* (#:key outputs target #:allow-other-keys)
288 (let* ((libexec (string-append (assoc-ref outputs "out")
289 "/libexec"))
290 ;; each of these find-files should return one file
291 (pdmp (find-files libexec "^emacs\\.pdmp$"))
292 (pdmp-real (find-files libexec
293 "^\\.emacs\\.pdmp-real$")))
294 (for-each (lambda (wrapper real)
295 (delete-file wrapper)
296 (rename-file real wrapper))
297 pdmp pdmp-real)
298 #t)))))))
299 (inputs
300 `(("jansson" ,jansson)
301 ,@(package-inputs emacs)))
302 (native-inputs
303 `(("autoconf" ,autoconf) ; needed when building from trunk
304 ,@(package-native-inputs emacs)))
305
306 ;; TODO: consider changing `emacs' to use a more robust way of
307 ;; specifying version for "EMACSLOADPATH", so as to avoid having to
308 ;; duplicate native-search-paths here.
309 (native-search-paths
310 (list (search-path-specification
311 (variable "EMACSLOADPATH")
312 ;; The versioned entry is for the Emacs' builtin libraries.
313 (files
314 (list "share/emacs/site-lisp"
315 (string-append "share/emacs/" emacs-version "/lisp"))))
316 (search-path-specification
317 (variable "INFOPATH")
318 (files '("share/info"))))))))
319
320 (define-public emacs-minimal
321 ;; This is the version that you should use as an input to packages that just
322 ;; need to byte-compile .el files.
323 (package (inherit emacs)
324 (name "emacs-minimal")
325 (synopsis "The extensible text editor (used only for byte-compilation)")
326 (build-system gnu-build-system)
327 (arguments
328 (substitute-keyword-arguments (package-arguments emacs)
329 ((#:phases phases)
330 `(modify-phases ,phases
331 (delete 'install-site-start)))
332 ((#:configure-flags flags ''())
333 `(list "--with-gnutls=no" "--disable-build-details"))))
334 (inputs
335 `(("ncurses" ,ncurses)))
336 (native-inputs
337 `(("pkg-config" ,pkg-config)))))
338
339 (define-public emacs-xwidgets
340 (package
341 (inherit emacs)
342 (name "emacs-xwidgets")
343 (synopsis "The extensible, customizable, self-documenting text
344 editor (with xwidgets support)")
345 (build-system gnu-build-system)
346 (arguments
347 (substitute-keyword-arguments (package-arguments emacs)
348 ((#:configure-flags flags ''())
349 `(cons "--with-xwidgets" ,flags))))
350 (inputs
351 `(("webkitgtk" ,webkitgtk)
352 ("libxcomposite" ,libxcomposite)
353 ,@(package-inputs emacs)))))
354
355 (define-public emacs-no-x
356 (package (inherit emacs)
357 (name "emacs-no-x")
358 (synopsis "The extensible, customizable, self-documenting text
359 editor (console only)")
360 (build-system gnu-build-system)
361 (inputs (fold alist-delete
362 (package-inputs emacs)
363 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
364 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
365 "libsm"
366
367 ;; These depend on libx11, so remove them as well.
368 "libotf" "m17n-lib" "dbus")))))
369
370 (define-public emacs-no-x-toolkit
371 (package (inherit emacs)
372 (name "emacs-no-x-toolkit")
373 (synopsis "The extensible, customizable, self-documenting text
374 editor (without an X toolkit)" )
375 (build-system gnu-build-system)
376 (inputs (append `(("inotify-tools" ,inotify-tools))
377 (alist-delete "gtk+" (package-inputs emacs))))
378 (arguments
379 `(,@(substitute-keyword-arguments (package-arguments emacs)
380 ((#:configure-flags cf)
381 `(cons "--with-x-toolkit=no" ,cf)))))))
382
383 (define-public guile-emacs
384 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
385 (revision "0"))
386 (package (inherit emacs)
387 (name "guile-emacs")
388 (version (git-version "0.0.0" revision commit))
389 (source (origin
390 (method git-fetch)
391 (uri (git-reference
392 (url "https://git.hcoop.net/git/bpt/emacs.git")
393 (commit commit)))
394 (file-name (git-file-name name version))
395 (patches (search-patches "guile-emacs-fix-configure.patch"))
396 (sha256
397 (base32
398 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
399 (native-inputs
400 `(("autoconf" ,autoconf)
401 ("automake" ,automake)
402 ("guile" ,guile-for-guile-emacs)
403 ,@(package-native-inputs emacs)))
404 (arguments
405 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
406 #:parallel-build? #f
407 ;; Tests aren't passing for now.
408 #:tests? #f
409 ,@(package-arguments emacs))
410 ((#:phases phases)
411 `(modify-phases ,phases
412 (add-after 'unpack 'autogen
413 (lambda _
414 (invoke "sh" "autogen.sh")))
415 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
416 (add-before 'build 'make-deps-dir
417 (lambda _
418 (invoke "mkdir" "-p" "src/deps"))))))))))
419
420 (define-public m17n-db
421 (package
422 (name "m17n-db")
423 (version "1.8.0")
424 (source
425 (origin
426 (method url-fetch)
427 (uri (string-append "mirror://savannah/m17n/m17n-db-"
428 version ".tar.gz"))
429 (sha256
430 (base32
431 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
432 (build-system gnu-build-system)
433 (inputs
434 `(("gettext" ,gettext-minimal)))
435 (arguments
436 `(#:configure-flags
437 (list (string-append "--with-charmaps="
438 (assoc-ref %build-inputs "libc")
439 "/share/i18n/charmaps"))))
440 ;; With `guix lint' the home-page URI returns a small page saying
441 ;; that your browser does not handle frames. This triggers the "URI
442 ;; returns suspiciously small file" warning.
443 (home-page "https://www.nongnu.org/m17n/")
444 (synopsis "Multilingual text processing library (database)")
445 (description "The m17n library realizes multilingualization of
446 many aspects of applications. The m17n library represents
447 multilingual text as an object named M-text. M-text is a string with
448 attributes called text properties, and designed to substitute for
449 string in C. Text properties carry any information required to input,
450 display and edit the text.
451
452 This package contains the library database.")
453 (license license:lgpl2.1+)))
454
455 (define-public m17n-lib
456 (package
457 (name "m17n-lib")
458 (version "1.8.0")
459 (source
460 (origin
461 (method url-fetch)
462 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
463 version ".tar.gz"))
464 (sha256
465 (base32
466 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
467 (build-system gnu-build-system)
468 (inputs
469 `(("fribidi" ,fribidi)
470 ("gd" ,gd)
471 ("libotf" ,libotf)
472 ("libxft" ,libxft)
473 ("libxml2" ,libxml2)
474 ("m17n-db" ,m17n-db)))
475 (arguments
476 `(#:parallel-build? #f))
477 ;; With `guix lint' the home-page URI returns a small page saying
478 ;; that your browser does not handle frames. This triggers the "URI
479 ;; returns suspiciously small file" warning.
480 (home-page "https://www.nongnu.org/m17n/")
481 (synopsis "Multilingual text processing library (runtime)")
482 (description "The m17n library realizes multilingualization of
483 many aspects of applications. The m17n library represents
484 multilingual text as an object named M-text. M-text is a string with
485 attributes called text properties, and designed to substitute for
486 string in C. Text properties carry any information required to input,
487 display and edit the text.
488
489 This package contains the library runtime.")
490 (license license:lgpl2.1+)))