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