gnu: calibre: Wrap QTWEBENGINEPROCESS_PATH.
[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, 2020 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 Nikita <nikita@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 ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
24 ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
25 ;;;
26 ;;; This file is part of GNU Guix.
27 ;;;
28 ;;; GNU Guix is free software; you can redistribute it and/or modify it
29 ;;; under the terms of the GNU General Public License as published by
30 ;;; the Free Software Foundation; either version 3 of the License, or (at
31 ;;; your option) any later version.
32 ;;;
33 ;;; GNU Guix is distributed in the hope that it will be useful, but
34 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 ;;; GNU General Public License for more details.
37 ;;;
38 ;;; You should have received a copy of the GNU General Public License
39 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
40
41 (define-module (gnu packages emacs)
42 #:use-module ((guix licenses) #:prefix license:)
43 #:use-module (guix packages)
44 #:use-module (guix download)
45 #:use-module (guix git-download)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system glib-or-gtk)
48 #:use-module (gnu packages)
49 #:use-module (gnu packages acl)
50 #:use-module (gnu packages autotools)
51 #:use-module (gnu packages base)
52 #:use-module (gnu packages compression)
53 #:use-module (gnu packages fontutils)
54 #:use-module (gnu packages fribidi)
55 #:use-module (gnu packages gd)
56 #:use-module (gnu packages gettext)
57 #:use-module (gnu packages glib)
58 #:use-module (gnu packages gnome) ; for librsvg
59 #:use-module (gnu packages gtk)
60 #:use-module (gnu packages guile)
61 #:use-module (gnu packages image)
62 #:use-module (gnu packages imagemagick)
63 #:use-module (gnu packages linux) ; alsa-lib
64 #:use-module (gnu packages mail) ; for mailutils
65 #:use-module (gnu packages multiprecision)
66 #:use-module (gnu packages ncurses)
67 #:use-module (gnu packages pkg-config)
68 #:use-module (gnu packages texinfo)
69 #:use-module (gnu packages tls)
70 #:use-module (gnu packages web) ; for jansson
71 #:use-module (gnu packages webkit)
72 #:use-module (gnu packages xml)
73 #:use-module (gnu packages xorg)
74 #:use-module (guix utils)
75 #:use-module (srfi srfi-1))
76
77 (define-public emacs
78 (package
79 (name "emacs")
80 (version "27.1")
81 (source (origin
82 (method url-fetch)
83 (uri (string-append "mirror://gnu/emacs/emacs-"
84 version ".tar.xz"))
85 (sha256
86 (base32
87 "0h9f2wpmp6rb5rfwvqwv1ia1nw86h74p7hnz3vb3gjazj67i4k2a"))
88 (patches (search-patches "emacs-exec-path.patch"
89 "emacs-fix-scheme-indent-function.patch"
90 "emacs-ignore-empty-xim-styles.patch"
91 "emacs-source-date-epoch.patch"))
92 (modules '((guix build utils)))
93 (snippet
94 '(with-directory-excursion "lisp"
95 ;; Delete the bundled byte-compiled elisp files and generated
96 ;; autoloads.
97 (for-each delete-file
98 (append (find-files "." "\\.elc$")
99 (find-files "." "loaddefs\\.el$")
100 (find-files "eshell" "^esh-groups\\.el$")))
101
102 ;; Make sure Tramp looks for binaries in the right places on
103 ;; remote Guix System machines, where 'getconf PATH' returns
104 ;; something bogus.
105 (substitute* "net/tramp-sh.el"
106 ;; Patch the line after "(defcustom tramp-remote-path".
107 (("\\(tramp-default-remote-path")
108 (format #f "(tramp-default-remote-path ~s ~s ~s ~s "
109 "~/.guix-profile/bin" "~/.guix-profile/sbin"
110 "/run/current-system/profile/bin"
111 "/run/current-system/profile/sbin")))
112
113 ;; Make sure Man looks for C header files in the right
114 ;; places.
115 (substitute* "man.el"
116 (("\"/usr/local/include\"" line)
117 (string-join
118 (list line
119 "\"~/.guix-profile/include\""
120 "\"/var/guix/profiles/system/profile/include\"")
121 " ")))
122 #t))))
123 (build-system glib-or-gtk-build-system)
124 (arguments
125 `(#:tests? #f ; no check target
126 #:configure-flags (list "--with-modules"
127 "--with-cairo"
128 "--disable-build-details")
129 #:phases
130 (modify-phases %standard-phases
131 (add-after 'unpack 'patch-program-file-names
132 (lambda _
133 (substitute* '("src/callproc.c"
134 "lisp/term.el"
135 "lisp/htmlfontify.el"
136 "lisp/textmodes/artist.el"
137 "lisp/progmodes/sh-script.el")
138 (("\"/bin/sh\"")
139 (format #f "~s" (which "sh"))))
140 #t))
141 (add-before 'configure 'fix-/bin/pwd
142 (lambda _
143 ;; Use `pwd', not `/bin/pwd'.
144 (substitute* (find-files "." "^Makefile\\.in$")
145 (("/bin/pwd")
146 "pwd"))
147 #t))
148 (add-after 'install 'install-site-start
149 ;; Use 'guix-emacs' in "site-start.el", which is used autoload the
150 ;; Elisp packages found in EMACSLOADPATH.
151 (lambda* (#:key inputs outputs #:allow-other-keys)
152 (let* ((out (assoc-ref outputs "out"))
153 (lisp-dir (string-append out "/share/emacs/site-lisp"))
154 (emacs (string-append out "/bin/emacs")))
155
156 ;; This is duplicated from emacs-utils to prevent coupling.
157 (define* (emacs-byte-compile-directory dir)
158 (let ((expr `(progn
159 (setq byte-compile-debug t)
160 (byte-recompile-directory
161 (file-name-as-directory ,dir) 0 1))))
162 (invoke emacs "--quick" "--batch"
163 (format #f "--eval=~s" expr))))
164
165 (copy-file (assoc-ref inputs "guix-emacs.el")
166 (string-append lisp-dir "/guix-emacs.el"))
167 (with-output-to-file (string-append lisp-dir "/site-start.el")
168 (lambda ()
169 (display
170 (string-append "(when (require 'guix-emacs nil t)\n"
171 " (guix-emacs-autoload-packages))\n"))))
172 ;; Remove the extraneous subdirs.el file, as it causes Emacs to
173 ;; add recursively all the the sub-directories of a profile's
174 ;; share/emacs/site-lisp union when added to EMACSLOADPATH,
175 ;; which leads to conflicts.
176 (delete-file (string-append lisp-dir "/subdirs.el"))
177 ;; Byte compile the site-start files.
178 (emacs-byte-compile-directory lisp-dir))
179 #t))
180 (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
181 ;; restore the dump file that Emacs installs somewhere in
182 ;; libexec/ to its original state
183 (lambda* (#:key outputs target #:allow-other-keys)
184 (let* ((libexec (string-append (assoc-ref outputs "out")
185 "/libexec"))
186 ;; each of these find-files should return one file
187 (pdmp (find-files libexec "^emacs\\.pdmp$"))
188 (pdmp-real (find-files libexec
189 "^\\.emacs\\.pdmp-real$")))
190 (for-each (lambda (wrapper real)
191 (delete-file wrapper)
192 (rename-file real wrapper))
193 pdmp pdmp-real))
194 #t))
195 (add-after 'glib-or-gtk-wrap 'strip-double-wrap
196 (lambda* (#:key outputs #:allow-other-keys)
197 ;; Directly copy emacs-X.Y to emacs, so that it is not wrapped
198 ;; twice. This also fixes a minor issue, where WMs would not be
199 ;; able to track emacs back to emacs.desktop.
200 (with-directory-excursion (assoc-ref outputs "out")
201 (copy-file (string-append
202 "bin/emacs-"
203 ,(version-major+minor (package-version emacs)))
204 "bin/emacs")
205 #t)))
206 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
207 ;; The 'reset-gzip-timestamps phase will throw a permission error
208 ;; if gzip files aren't writable then. This phase is needed when
209 ;; building from a git checkout.
210 (lambda _
211 (for-each make-file-writable
212 (find-files %output ".*\\.t?gz$"))
213 #t)))))
214 (inputs
215 `(("gnutls" ,gnutls)
216 ("ncurses" ,ncurses)
217
218 ;; Avoid Emacs's limited movemail substitute that retrieves POP3 email
219 ;; only via insecure channels. This is not needed for (modern) IMAP.
220 ("mailutils" ,mailutils)
221
222 ;; TODO: Add the optional dependencies.
223 ("libx11" ,libx11)
224 ("gtk+" ,gtk+)
225 ("cairo" ,cairo)
226 ("pango" ,pango)
227 ("harfbuzz" ,harfbuzz)
228 ("libxft" ,libxft)
229 ("libtiff" ,libtiff)
230 ("giflib" ,giflib)
231 ("libjpeg" ,libjpeg-turbo)
232 ("acl" ,acl)
233 ("jansson" ,jansson)
234 ("gmp" ,gmp)
235
236 ;; When looking for libpng `configure' links with `-lpng -lz', so we
237 ;; must also provide zlib as an input.
238 ("libpng" ,libpng)
239 ("zlib" ,zlib)
240
241 ("librsvg" ,librsvg)
242 ("libxpm" ,libxpm)
243 ("libxml2" ,libxml2)
244 ("libice" ,libice)
245 ("libsm" ,libsm)
246 ("alsa-lib" ,alsa-lib)
247 ("dbus" ,dbus)
248
249 ;; multilingualization support
250 ("libotf" ,libotf)
251 ("m17n-lib" ,m17n-lib)))
252 (native-inputs
253 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
254 ("pkg-config" ,pkg-config)
255 ("texinfo" ,texinfo)))
256
257 (native-search-paths
258 (list (search-path-specification
259 (variable "EMACSLOADPATH")
260 ;; The versioned entry is for the Emacs' builtin libraries.
261 (files (list "share/emacs/site-lisp"
262 (string-append "share/emacs/" version "/lisp"))))
263 (search-path-specification
264 (variable "INFOPATH")
265 (files '("share/info")))))
266
267 (home-page "https://www.gnu.org/software/emacs/")
268 (synopsis "The extensible, customizable, self-documenting text editor")
269 (description
270 "GNU Emacs is an extensible and highly customizable text editor. It is
271 based on an Emacs Lisp interpreter with extensions for text editing. Emacs
272 has been extended in essentially all areas of computing, giving rise to a
273 vast array of packages supporting, e.g., email, IRC and XMPP messaging,
274 spreadsheets, remote server editing, and much more. Emacs includes extensive
275 documentation on all aspects of the system, from basic editing to writing
276 large Lisp programs. It has full Unicode support for nearly all human
277 languages.")
278 (license license:gpl3+)))
279
280 (define-public emacs-next
281 (let ((commit "2ea34662c20f71d35dd52a5ed996542c7386b9cb")
282 (revision "0")
283 (emacs-version "28.0.50.1"))
284 (package/inherit emacs
285 (name "emacs-next")
286 (version (git-version emacs-version revision commit))
287 (source
288 (origin
289 (inherit (package-source emacs))
290 (method git-fetch)
291 (uri (git-reference
292 (url "https://git.savannah.gnu.org/git/emacs.git/")
293 (commit commit)))
294 (file-name (git-file-name name version))
295 (sha256
296 (base32
297 "0igjm9kwiswn2dpiy2k9xikbdfc7njs07ry48fqz70anljj8y7y3"))))
298 (arguments
299 (substitute-keyword-arguments (package-arguments emacs)
300 ((#:phases phases)
301 `(modify-phases ,phases
302 (replace 'strip-double-wrap
303 (lambda* (#:key outputs #:allow-other-keys)
304 ;; Directly copy emacs-X.Y to emacs, so that it is not wrapped
305 ;; twice. This also fixes a minor issue, where WMs would not be
306 ;; able to track emacs back to emacs.desktop.
307 (with-directory-excursion (assoc-ref outputs "out")
308 (copy-file (string-append
309 "bin/emacs-"
310 ,(version-major+minor+point (package-version emacs-next)))
311 "bin/emacs")
312 #t)))))))
313 (native-inputs
314 `(("autoconf" ,autoconf)
315 ,@(package-native-inputs emacs))))))
316
317 (define-public emacs-minimal
318 ;; This is the version that you should use as an input to packages that just
319 ;; need to byte-compile .el files.
320 (package/inherit emacs
321 (name "emacs-minimal")
322 (synopsis "The extensible text editor (used only for byte-compilation)")
323 (build-system gnu-build-system)
324 (arguments
325 (substitute-keyword-arguments (package-arguments emacs)
326 ((#:configure-flags flags ''())
327 `(list "--with-gnutls=no" "--disable-build-details"))
328 ((#:phases phases)
329 `(modify-phases ,phases
330 (delete 'restore-emacs-pdmp)
331 (delete 'strip-double-wrap)))))
332 (inputs
333 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
334 ("ncurses" ,ncurses)))
335 (native-inputs
336 `(("pkg-config" ,pkg-config)))))
337
338 (define-public emacs-xwidgets
339 (package/inherit emacs
340 (name "emacs-xwidgets")
341 (synopsis "The extensible, customizable, self-documenting text
342 editor (with xwidgets support)")
343 (build-system gnu-build-system)
344 (arguments
345 (substitute-keyword-arguments (package-arguments emacs)
346 ((#:configure-flags flags ''())
347 `(cons "--with-xwidgets" ,flags))
348 ((#:phases phases)
349 `(modify-phases ,phases
350 (delete 'restore-emacs-pdmp)
351 (delete 'strip-double-wrap)))))
352 (inputs
353 `(("webkitgtk" ,webkitgtk)
354 ("libxcomposite" ,libxcomposite)
355 ,@(package-inputs emacs)))))
356
357 (define-public emacs-no-x
358 (package/inherit emacs
359 (name "emacs-no-x")
360 (synopsis "The extensible, customizable, self-documenting text
361 editor (console only)")
362 (build-system gnu-build-system)
363 (inputs (fold alist-delete
364 (package-inputs emacs)
365 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
366 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
367 "libsm" "cairo" "pango" "harfbuzz"
368
369 ;; These depend on libx11, so remove them as well.
370 "libotf" "m17n-lib" "dbus")))
371 (arguments
372 (substitute-keyword-arguments (package-arguments emacs)
373 ((#:configure-flags flags ''())
374 `(delete "--with-cairo" ,flags))
375 ((#:phases phases)
376 `(modify-phases ,phases
377 (delete 'restore-emacs-pdmp)
378 (delete 'strip-double-wrap)))))))
379
380 (define-public emacs-no-x-toolkit
381 (package/inherit emacs
382 (name "emacs-no-x-toolkit")
383 (synopsis "The extensible, customizable, self-documenting text
384 editor (without an X toolkit)" )
385 (build-system gnu-build-system)
386 (inputs (append `(("inotify-tools" ,inotify-tools))
387 (alist-delete "gtk+" (package-inputs emacs))))
388 (arguments
389 (substitute-keyword-arguments (package-arguments emacs)
390 ((#:configure-flags flags ''())
391 `(cons "--with-x-toolkit=no" ,flags))
392 ((#:phases phases)
393 `(modify-phases ,phases
394 (delete 'restore-emacs-pdmp)
395 (delete 'strip-double-wrap)))))))
396
397 (define-public emacs-wide-int
398 (package/inherit emacs
399 (name "emacs-wide-int")
400 (synopsis "The extensible, customizable, self-documenting text
401 editor (with wide ints)" )
402 (arguments
403 (substitute-keyword-arguments (package-arguments emacs)
404 ((#:configure-flags flags)
405 `(cons "--with-wide-int" ,flags))))))
406
407 (define-public guile-emacs
408 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
409 (revision "0"))
410 (package/inherit emacs
411 (name "guile-emacs")
412 (version (git-version "0.0.0" revision commit))
413 (source (origin
414 (method git-fetch)
415 (uri (git-reference
416 (url "https://git.hcoop.net/git/bpt/emacs.git")
417 (commit commit)))
418 (file-name (git-file-name name version))
419 (patches (search-patches "guile-emacs-fix-configure.patch"))
420 (sha256
421 (base32
422 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
423 (native-inputs
424 `(("autoconf" ,autoconf)
425 ("automake" ,automake)
426 ("guile" ,guile-for-guile-emacs)
427 ,@(package-native-inputs emacs)))
428 (arguments
429 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
430 #:parallel-build? #f
431 ;; Tests aren't passing for now.
432 #:tests? #f
433 ,@(package-arguments emacs))
434 ((#:configure-flags flags ''())
435 `(delete "--with-cairo" ,flags))
436 ((#:phases phases)
437 `(modify-phases ,phases
438 (add-after 'unpack 'autogen
439 (lambda _
440 (invoke "sh" "autogen.sh")))
441 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
442 (add-before 'build 'make-deps-dir
443 (lambda _
444 (invoke "mkdir" "-p" "src/deps")))
445 (delete 'restore-emacs-pdmp)
446 (delete 'strip-double-wrap))))))))
447
448 (define-public m17n-db
449 (package
450 (name "m17n-db")
451 (version "1.8.0")
452 (source
453 (origin
454 (method url-fetch)
455 (uri (string-append "mirror://savannah/m17n/m17n-db-"
456 version ".tar.gz"))
457 (sha256
458 (base32
459 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
460 (build-system gnu-build-system)
461 (inputs
462 `(("gettext" ,gettext-minimal)))
463 (arguments
464 `(#:configure-flags
465 (list (string-append "--with-charmaps="
466 (assoc-ref %build-inputs "libc")
467 "/share/i18n/charmaps"))))
468 ;; With `guix lint' the home-page URI returns a small page saying
469 ;; that your browser does not handle frames. This triggers the "URI
470 ;; returns suspiciously small file" warning.
471 (home-page "https://www.nongnu.org/m17n/")
472 (synopsis "Multilingual text processing library (database)")
473 (description "The m17n library realizes multilingualization of
474 many aspects of applications. The m17n library represents
475 multilingual text as an object named M-text. M-text is a string with
476 attributes called text properties, and designed to substitute for
477 string in C. Text properties carry any information required to input,
478 display and edit the text.
479
480 This package contains the library database.")
481 (license license:lgpl2.1+)))
482
483 (define-public m17n-lib
484 (package
485 (name "m17n-lib")
486 (version "1.8.0")
487 (source
488 (origin
489 (method url-fetch)
490 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
491 version ".tar.gz"))
492 (sha256
493 (base32
494 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
495 (build-system gnu-build-system)
496 (inputs
497 `(("fribidi" ,fribidi)
498 ("gd" ,gd)
499 ("libotf" ,libotf)
500 ("libxft" ,libxft)
501 ("libxml2" ,libxml2)
502 ("m17n-db" ,m17n-db)))
503 (arguments
504 `(#:parallel-build? #f))
505 ;; With `guix lint' the home-page URI returns a small page saying
506 ;; that your browser does not handle frames. This triggers the "URI
507 ;; returns suspiciously small file" warning.
508 (home-page "https://www.nongnu.org/m17n/")
509 (synopsis "Multilingual text processing library (runtime)")
510 (description "The m17n library realizes multilingualization of
511 many aspects of applications. The m17n library represents
512 multilingual text as an object named M-text. M-text is a string with
513 attributes called text properties, and designed to substitute for
514 string in C. Text properties carry any information required to input,
515 display and edit the text.
516
517 This package contains the library runtime.")
518 (license license:lgpl2.1+)))