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