Merge branch 'master' into core-updates
[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, 2020 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-after 'unpack 'patch-program-file-names
135 (lambda _
136 (substitute* '("src/callproc.c"
137 "lisp/term.el"
138 "lisp/htmlfontify.el"
139 "lisp/textmodes/artist.el"
140 "lisp/progmodes/sh-script.el")
141 (("\"/bin/sh\"")
142 (format #f "~s" (which "sh"))))
143 #t))
144 (add-before 'configure 'fix-/bin/pwd
145 (lambda _
146 ;; Use `pwd', not `/bin/pwd'.
147 (substitute* (find-files "." "^Makefile\\.in$")
148 (("/bin/pwd")
149 "pwd"))
150 #t))
151 (add-after 'install 'install-site-start
152 ;; Use 'guix-emacs' in "site-start.el", which is used autoload the
153 ;; Elisp packages found in EMACSLOADPATH.
154 (lambda* (#:key inputs outputs #:allow-other-keys)
155 (let* ((out (assoc-ref outputs "out"))
156 (lisp-dir (string-append out "/share/emacs/site-lisp"))
157 (emacs (string-append out "/bin/emacs")))
158
159 ;; This is duplicated from emacs-utils to prevent coupling.
160 (define* (emacs-byte-compile-directory dir)
161 (let ((expr `(progn
162 (setq byte-compile-debug t)
163 (byte-recompile-directory
164 (file-name-as-directory ,dir) 0 1))))
165 (invoke emacs "--quick" "--batch"
166 (format #f "--eval=~s" expr))))
167
168 (copy-file (assoc-ref inputs "guix-emacs.el")
169 (string-append lisp-dir "/guix-emacs.el"))
170 (with-output-to-file (string-append lisp-dir "/site-start.el")
171 (lambda ()
172 (display
173 (string-append "(when (require 'guix-emacs nil t)\n"
174 " (guix-emacs-autoload-packages))\n"))))
175 ;; Remove the extraneous subdirs.el file, as it causes Emacs to
176 ;; add recursively all the the sub-directories of a profile's
177 ;; share/emacs/site-lisp union when added to EMACSLOADPATH,
178 ;; which leads to conflicts.
179 (delete-file (string-append lisp-dir "/subdirs.el"))
180 ;; Byte compile the site-start files.
181 (emacs-byte-compile-directory lisp-dir)))))))
182 (inputs
183 `(("gnutls" ,gnutls)
184 ("ncurses" ,ncurses)
185
186 ;; Avoid Emacs's limited movemail substitute that retrieves POP3 email
187 ;; only via insecure channels. This is not needed for (modern) IMAP.
188 ("mailutils" ,mailutils)
189
190 ;; TODO: Add the optional dependencies.
191 ("libx11" ,libx11)
192 ("gtk+" ,gtk+)
193 ("libxft" ,libxft)
194 ("libtiff" ,libtiff)
195 ("giflib" ,giflib)
196 ("libjpeg" ,libjpeg-turbo)
197 ("imagemagick" ,imagemagick)
198 ("acl" ,acl)
199
200 ;; When looking for libpng `configure' links with `-lpng -lz', so we
201 ;; must also provide zlib as an input.
202 ("libpng" ,libpng)
203 ("zlib" ,zlib)
204
205 ("librsvg" ,librsvg)
206 ("libxpm" ,libxpm)
207 ("libxml2" ,libxml2)
208 ("libice" ,libice)
209 ("libsm" ,libsm)
210 ("alsa-lib" ,alsa-lib)
211 ("dbus" ,dbus)
212
213 ;; multilingualization support
214 ("libotf" ,libotf)
215 ("m17n-lib" ,m17n-lib)))
216 (native-inputs
217 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
218 ("pkg-config" ,pkg-config)
219 ("texinfo" ,texinfo)))
220
221 (native-search-paths
222 (list (search-path-specification
223 (variable "EMACSLOADPATH")
224 ;; The versioned entry is for the Emacs' builtin libraries.
225 (files (list "share/emacs/site-lisp"
226 (string-append "share/emacs/" version "/lisp"))))
227 (search-path-specification
228 (variable "INFOPATH")
229 (files '("share/info")))))
230
231 (home-page "https://www.gnu.org/software/emacs/")
232 (synopsis "The extensible, customizable, self-documenting text editor")
233 (description
234 "GNU Emacs is an extensible and highly customizable text editor. It is
235 based on an Emacs Lisp interpreter with extensions for text editing. Emacs
236 has been extended in essentially all areas of computing, giving rise to a
237 vast array of packages supporting, e.g., email, IRC and XMPP messaging,
238 spreadsheets, remote server editing, and much more. Emacs includes extensive
239 documentation on all aspects of the system, from basic editing to writing
240 large Lisp programs. It has full Unicode support for nearly all human
241 languages.")
242 (license license:gpl3+)))
243
244 (define-public emacs-next
245 (let ((commit "36abf6864604b3061c2e070f8997491fa2bce44c")
246 (revision "0")
247 (emacs-version "27.0.50"))
248 (package
249 (inherit emacs)
250 (name "emacs-next")
251 (version (git-version emacs-version revision commit))
252 (source
253 (origin
254 (method git-fetch)
255 (uri (git-reference
256 (url "https://git.savannah.gnu.org/git/emacs.git")
257 (commit commit)))
258 (sha256
259 (base32 "1ckn607p0clz0dhhlizvv7l03p4nminy48h53xrpz55w4rcrcm2l"))
260 (file-name (git-file-name name version))
261 (patches (search-patches "emacs27-exec-path.patch"
262 "emacs-fix-scheme-indent-function.patch"
263 "emacs-source-date-epoch.patch"))
264 (modules (origin-modules (package-source emacs)))
265 ;; TODO: once the snippet for `emacs' is changed to not fail when
266 ;; eshell/esh-groups.el does not exist, replace this snippet with
267 ;; (snippet (origin-snippet (package-source emacs))))).
268 (snippet
269 '(with-directory-excursion "lisp"
270 ;; Make sure Tramp looks for binaries in the right places on
271 ;; remote Guix System machines, where 'getconf PATH' returns
272 ;; something bogus.
273 (substitute* "net/tramp-sh.el"
274 ;; Patch the line after "(defcustom tramp-remote-path".
275 (("\\(tramp-default-remote-path")
276 (format #f "(tramp-default-remote-path ~s ~s ~s ~s "
277 "~/.guix-profile/bin" "~/.guix-profile/sbin"
278 "/run/current-system/profile/bin"
279 "/run/current-system/profile/sbin")))
280
281 ;; Make sure Man looks for C header files in the right
282 ;; places.
283 (substitute* "man.el"
284 (("\"/usr/local/include\"" line)
285 (string-join
286 (list line
287 "\"~/.guix-profile/include\""
288 "\"/var/guix/profiles/system/profile/include\"")
289 " ")))
290 #t))))
291 (arguments
292 (substitute-keyword-arguments (package-arguments emacs)
293 ((#:configure-flags flags)
294 `(cons* "--with-harfbuzz" ,flags))
295 ((#:phases phases)
296 `(modify-phases ,phases
297 ;; The 'reset-gzip-timestamps phase will throw a
298 ;; permission error if gzip files aren't writable then
299 (add-before
300 'reset-gzip-timestamps
301 'make-compressed-files-writable
302 (lambda _
303 (for-each make-file-writable
304 (find-files %output ".*\\.t?gz$"))
305 #t))
306 ;; restore the dump file that Emacs installs somewhere in
307 ;; libexec/ to its original state
308 (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
309 (lambda* (#:key outputs target #:allow-other-keys)
310 (let* ((libexec (string-append (assoc-ref outputs "out")
311 "/libexec"))
312 ;; each of these find-files should return one file
313 (pdmp (find-files libexec "^emacs\\.pdmp$"))
314 (pdmp-real (find-files libexec
315 "^\\.emacs\\.pdmp-real$")))
316 (for-each (lambda (wrapper real)
317 (delete-file wrapper)
318 (rename-file real wrapper))
319 pdmp pdmp-real)
320 #t)))))))
321 (inputs
322 `(("jansson" ,jansson)
323 ("harfbuzz" ,harfbuzz)
324 ,@(package-inputs emacs)))
325 (native-inputs
326 `(("autoconf" ,autoconf) ; needed when building from trunk
327 ,@(package-native-inputs emacs)))
328
329 ;; TODO: consider changing `emacs' to use a more robust way of
330 ;; specifying version for "EMACSLOADPATH", so as to avoid having to
331 ;; duplicate native-search-paths here.
332 (native-search-paths
333 (list (search-path-specification
334 (variable "EMACSLOADPATH")
335 ;; The versioned entry is for the Emacs' builtin libraries.
336 (files
337 (list "share/emacs/site-lisp"
338 (string-append "share/emacs/" emacs-version "/lisp"))))
339 (search-path-specification
340 (variable "INFOPATH")
341 (files '("share/info"))))))))
342
343 (define-public emacs-minimal
344 ;; This is the version that you should use as an input to packages that just
345 ;; need to byte-compile .el files.
346 (package (inherit emacs)
347 (name "emacs-minimal")
348 (synopsis "The extensible text editor (used only for byte-compilation)")
349 (build-system gnu-build-system)
350 (arguments
351 (substitute-keyword-arguments (package-arguments emacs)
352 ((#:configure-flags flags ''())
353 `(list "--with-gnutls=no" "--disable-build-details"))))
354 (inputs
355 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
356 ("ncurses" ,ncurses)))
357 (native-inputs
358 `(("pkg-config" ,pkg-config)))))
359
360 (define-public emacs-xwidgets
361 (package
362 (inherit emacs)
363 (name "emacs-xwidgets")
364 (synopsis "The extensible, customizable, self-documenting text
365 editor (with xwidgets support)")
366 (build-system gnu-build-system)
367 (arguments
368 (substitute-keyword-arguments (package-arguments emacs)
369 ((#:configure-flags flags ''())
370 `(cons "--with-xwidgets" ,flags))))
371 (inputs
372 `(("webkitgtk" ,webkitgtk)
373 ("libxcomposite" ,libxcomposite)
374 ,@(package-inputs emacs)))))
375
376 (define-public emacs-no-x
377 (package (inherit emacs)
378 (name "emacs-no-x")
379 (synopsis "The extensible, customizable, self-documenting text
380 editor (console only)")
381 (build-system gnu-build-system)
382 (inputs (fold alist-delete
383 (package-inputs emacs)
384 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
385 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
386 "libsm"
387
388 ;; These depend on libx11, so remove them as well.
389 "libotf" "m17n-lib" "dbus")))))
390
391 (define-public emacs-no-x-toolkit
392 (package (inherit emacs)
393 (name "emacs-no-x-toolkit")
394 (synopsis "The extensible, customizable, self-documenting text
395 editor (without an X toolkit)" )
396 (build-system gnu-build-system)
397 (inputs (append `(("inotify-tools" ,inotify-tools))
398 (alist-delete "gtk+" (package-inputs emacs))))
399 (arguments
400 `(,@(substitute-keyword-arguments (package-arguments emacs)
401 ((#:configure-flags cf)
402 `(cons "--with-x-toolkit=no" ,cf)))))))
403
404 (define-public emacs-wide-int
405 (package
406 (inherit emacs)
407 (name "emacs-wide-int")
408 (synopsis "The extensible, customizable, self-documenting text
409 editor (with wide ints)" )
410 (arguments
411 (substitute-keyword-arguments (package-arguments emacs)
412 ((#:configure-flags flags)
413 `(cons "--with-wide-int" ,flags))))))
414
415 (define-public guile-emacs
416 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
417 (revision "0"))
418 (package (inherit emacs)
419 (name "guile-emacs")
420 (version (git-version "0.0.0" revision commit))
421 (source (origin
422 (method git-fetch)
423 (uri (git-reference
424 (url "https://git.hcoop.net/git/bpt/emacs.git")
425 (commit commit)))
426 (file-name (git-file-name name version))
427 (patches (search-patches "guile-emacs-fix-configure.patch"))
428 (sha256
429 (base32
430 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
431 (native-inputs
432 `(("autoconf" ,autoconf)
433 ("automake" ,automake)
434 ("guile" ,guile-for-guile-emacs)
435 ,@(package-native-inputs emacs)))
436 (arguments
437 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
438 #:parallel-build? #f
439 ;; Tests aren't passing for now.
440 #:tests? #f
441 ,@(package-arguments emacs))
442 ((#:phases phases)
443 `(modify-phases ,phases
444 (add-after 'unpack 'autogen
445 (lambda _
446 (invoke "sh" "autogen.sh")))
447 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
448 (add-before 'build 'make-deps-dir
449 (lambda _
450 (invoke "mkdir" "-p" "src/deps"))))))))))
451
452 (define-public m17n-db
453 (package
454 (name "m17n-db")
455 (version "1.8.0")
456 (source
457 (origin
458 (method url-fetch)
459 (uri (string-append "mirror://savannah/m17n/m17n-db-"
460 version ".tar.gz"))
461 (sha256
462 (base32
463 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
464 (build-system gnu-build-system)
465 (inputs
466 `(("gettext" ,gettext-minimal)))
467 (arguments
468 `(#:configure-flags
469 (list (string-append "--with-charmaps="
470 (assoc-ref %build-inputs "libc")
471 "/share/i18n/charmaps"))))
472 ;; With `guix lint' the home-page URI returns a small page saying
473 ;; that your browser does not handle frames. This triggers the "URI
474 ;; returns suspiciously small file" warning.
475 (home-page "https://www.nongnu.org/m17n/")
476 (synopsis "Multilingual text processing library (database)")
477 (description "The m17n library realizes multilingualization of
478 many aspects of applications. The m17n library represents
479 multilingual text as an object named M-text. M-text is a string with
480 attributes called text properties, and designed to substitute for
481 string in C. Text properties carry any information required to input,
482 display and edit the text.
483
484 This package contains the library database.")
485 (license license:lgpl2.1+)))
486
487 (define-public m17n-lib
488 (package
489 (name "m17n-lib")
490 (version "1.8.0")
491 (source
492 (origin
493 (method url-fetch)
494 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
495 version ".tar.gz"))
496 (sha256
497 (base32
498 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
499 (build-system gnu-build-system)
500 (inputs
501 `(("fribidi" ,fribidi)
502 ("gd" ,gd)
503 ("libotf" ,libotf)
504 ("libxft" ,libxft)
505 ("libxml2" ,libxml2)
506 ("m17n-db" ,m17n-db)))
507 (arguments
508 `(#:parallel-build? #f))
509 ;; With `guix lint' the home-page URI returns a small page saying
510 ;; that your browser does not handle frames. This triggers the "URI
511 ;; returns suspiciously small file" warning.
512 (home-page "https://www.nongnu.org/m17n/")
513 (synopsis "Multilingual text processing library (runtime)")
514 (description "The m17n library realizes multilingualization of
515 many aspects of applications. The m17n library represents
516 multilingual text as an object named M-text. M-text is a string with
517 attributes called text properties, and designed to substitute for
518 string in C. Text properties carry any information required to input,
519 display and edit the text.
520
521 This package contains the library runtime.")
522 (license license:lgpl2.1+)))