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 <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 #: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 "~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 "--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 ((#:phases phases)
294 `(modify-phases ,phases
295 ;; The 'reset-gzip-timestamps phase will throw a
296 ;; permission error if gzip files aren't writable then
297 (add-before
298 'reset-gzip-timestamps
299 'make-compressed-files-writable
300 (lambda _
301 (for-each make-file-writable
302 (find-files %output ".*\\.t?gz$"))
303 #t))
304 ;; restore the dump file that Emacs installs somewhere in
305 ;; libexec/ to its original state
306 (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
307 (lambda* (#:key outputs target #:allow-other-keys)
308 (let* ((libexec (string-append (assoc-ref outputs "out")
309 "/libexec"))
310 ;; each of these find-files should return one file
311 (pdmp (find-files libexec "^emacs\\.pdmp$"))
312 (pdmp-real (find-files libexec
313 "^\\.emacs\\.pdmp-real$")))
314 (for-each (lambda (wrapper real)
315 (delete-file wrapper)
316 (rename-file real wrapper))
317 pdmp pdmp-real)
318 #t)))))))
319 (inputs
320 `(("jansson" ,jansson)
321 ,@(package-inputs emacs)))
322 (native-inputs
323 `(("autoconf" ,autoconf) ; needed when building from trunk
324 ,@(package-native-inputs emacs)))
325
326 ;; TODO: consider changing `emacs' to use a more robust way of
327 ;; specifying version for "EMACSLOADPATH", so as to avoid having to
328 ;; duplicate native-search-paths here.
329 (native-search-paths
330 (list (search-path-specification
331 (variable "EMACSLOADPATH")
332 ;; The versioned entry is for the Emacs' builtin libraries.
333 (files
334 (list "share/emacs/site-lisp"
335 (string-append "share/emacs/" emacs-version "/lisp"))))
336 (search-path-specification
337 (variable "INFOPATH")
338 (files '("share/info"))))))))
339
340 (define-public emacs-minimal
341 ;; This is the version that you should use as an input to packages that just
342 ;; need to byte-compile .el files.
343 (package (inherit emacs)
344 (name "emacs-minimal")
345 (synopsis "The extensible text editor (used only for byte-compilation)")
346 (build-system gnu-build-system)
347 (arguments
348 (substitute-keyword-arguments (package-arguments emacs)
349 ((#:configure-flags flags ''())
350 `(list "--with-gnutls=no" "--disable-build-details"))))
351 (inputs
352 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
353 ("ncurses" ,ncurses)))
354 (native-inputs
355 `(("pkg-config" ,pkg-config)))))
356
357 (define-public emacs-xwidgets
358 (package
359 (inherit emacs)
360 (name "emacs-xwidgets")
361 (synopsis "The extensible, customizable, self-documenting text
362 editor (with xwidgets support)")
363 (build-system gnu-build-system)
364 (arguments
365 (substitute-keyword-arguments (package-arguments emacs)
366 ((#:configure-flags flags ''())
367 `(cons "--with-xwidgets" ,flags))))
368 (inputs
369 `(("webkitgtk" ,webkitgtk)
370 ("libxcomposite" ,libxcomposite)
371 ,@(package-inputs emacs)))))
372
373 (define-public emacs-no-x
374 (package (inherit emacs)
375 (name "emacs-no-x")
376 (synopsis "The extensible, customizable, self-documenting text
377 editor (console only)")
378 (build-system gnu-build-system)
379 (inputs (fold alist-delete
380 (package-inputs emacs)
381 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
382 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
383 "libsm"
384
385 ;; These depend on libx11, so remove them as well.
386 "libotf" "m17n-lib" "dbus")))))
387
388 (define-public emacs-no-x-toolkit
389 (package (inherit emacs)
390 (name "emacs-no-x-toolkit")
391 (synopsis "The extensible, customizable, self-documenting text
392 editor (without an X toolkit)" )
393 (build-system gnu-build-system)
394 (inputs (append `(("inotify-tools" ,inotify-tools))
395 (alist-delete "gtk+" (package-inputs emacs))))
396 (arguments
397 `(,@(substitute-keyword-arguments (package-arguments emacs)
398 ((#:configure-flags cf)
399 `(cons "--with-x-toolkit=no" ,cf)))))))
400
401 (define-public guile-emacs
402 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
403 (revision "0"))
404 (package (inherit emacs)
405 (name "guile-emacs")
406 (version (git-version "0.0.0" revision commit))
407 (source (origin
408 (method git-fetch)
409 (uri (git-reference
410 (url "https://git.hcoop.net/git/bpt/emacs.git")
411 (commit commit)))
412 (file-name (git-file-name name version))
413 (patches (search-patches "guile-emacs-fix-configure.patch"))
414 (sha256
415 (base32
416 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
417 (native-inputs
418 `(("autoconf" ,autoconf)
419 ("automake" ,automake)
420 ("guile" ,guile-for-guile-emacs)
421 ,@(package-native-inputs emacs)))
422 (arguments
423 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
424 #:parallel-build? #f
425 ;; Tests aren't passing for now.
426 #:tests? #f
427 ,@(package-arguments emacs))
428 ((#:phases phases)
429 `(modify-phases ,phases
430 (add-after 'unpack 'autogen
431 (lambda _
432 (invoke "sh" "autogen.sh")))
433 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
434 (add-before 'build 'make-deps-dir
435 (lambda _
436 (invoke "mkdir" "-p" "src/deps"))))))))))
437
438 (define-public m17n-db
439 (package
440 (name "m17n-db")
441 (version "1.8.0")
442 (source
443 (origin
444 (method url-fetch)
445 (uri (string-append "mirror://savannah/m17n/m17n-db-"
446 version ".tar.gz"))
447 (sha256
448 (base32
449 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
450 (build-system gnu-build-system)
451 (inputs
452 `(("gettext" ,gettext-minimal)))
453 (arguments
454 `(#:configure-flags
455 (list (string-append "--with-charmaps="
456 (assoc-ref %build-inputs "libc")
457 "/share/i18n/charmaps"))))
458 ;; With `guix lint' the home-page URI returns a small page saying
459 ;; that your browser does not handle frames. This triggers the "URI
460 ;; returns suspiciously small file" warning.
461 (home-page "https://www.nongnu.org/m17n/")
462 (synopsis "Multilingual text processing library (database)")
463 (description "The m17n library realizes multilingualization of
464 many aspects of applications. The m17n library represents
465 multilingual text as an object named M-text. M-text is a string with
466 attributes called text properties, and designed to substitute for
467 string in C. Text properties carry any information required to input,
468 display and edit the text.
469
470 This package contains the library database.")
471 (license license:lgpl2.1+)))
472
473 (define-public m17n-lib
474 (package
475 (name "m17n-lib")
476 (version "1.8.0")
477 (source
478 (origin
479 (method url-fetch)
480 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
481 version ".tar.gz"))
482 (sha256
483 (base32
484 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
485 (build-system gnu-build-system)
486 (inputs
487 `(("fribidi" ,fribidi)
488 ("gd" ,gd)
489 ("libotf" ,libotf)
490 ("libxft" ,libxft)
491 ("libxml2" ,libxml2)
492 ("m17n-db" ,m17n-db)))
493 (arguments
494 `(#:parallel-build? #f))
495 ;; With `guix lint' the home-page URI returns a small page saying
496 ;; that your browser does not handle frames. This triggers the "URI
497 ;; returns suspiciously small file" warning.
498 (home-page "https://www.nongnu.org/m17n/")
499 (synopsis "Multilingual text processing library (runtime)")
500 (description "The m17n library realizes multilingualization of
501 many aspects of applications. The m17n library represents
502 multilingual text as an object named M-text. M-text is a string with
503 attributes called text properties, and designed to substitute for
504 string in C. Text properties carry any information required to input,
505 display and edit the text.
506
507 This package contains the library runtime.")
508 (license license:lgpl2.1+)))