gnu: emacs.scm: Remove unused module import.
[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 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-after 'glib-or-gtk-wrap 'strip-double-wrap
195 (lambda* (#:key outputs #:allow-other-keys)
196 ;; Directly copy emacs-X.Y to emacs, so that it is not wrapped
197 ;; twice. This also fixes a minor issue, where WMs would not be
198 ;; able to track emacs back to emacs.desktop. The version is
199 ;; accessed using using THIS-PACKAGE so it "just works" for
200 ;; inherited Emacs packages of different versions.
201 (with-directory-excursion (assoc-ref outputs "out")
202 (copy-file (string-append
203 "bin/emacs-"
204 ,(let ((this-version (package-version this-package)))
205 (or (false-if-exception
206 (version-major+minor+point this-version))
207 (version-major+minor this-version))))
208 "bin/emacs")
209 #t)))
210 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
211 ;; The 'reset-gzip-timestamps phase will throw a permission error
212 ;; if gzip files aren't writable then. This phase is needed when
213 ;; building from a git checkout.
214 (lambda _
215 (for-each make-file-writable
216 (find-files %output ".*\\.t?gz$"))
217 #t)))))
218 (inputs
219 `(("gnutls" ,gnutls)
220 ("ncurses" ,ncurses)
221
222 ;; Avoid Emacs's limited movemail substitute that retrieves POP3 email
223 ;; only via insecure channels. This is not needed for (modern) IMAP.
224 ("mailutils" ,mailutils)
225
226 ;; TODO: Add the optional dependencies.
227 ("libx11" ,libx11)
228 ("gtk+" ,gtk+)
229 ("cairo" ,cairo)
230 ("pango" ,pango)
231 ("harfbuzz" ,harfbuzz)
232 ("libxft" ,libxft)
233 ("libtiff" ,libtiff)
234 ("giflib" ,giflib)
235 ("libjpeg" ,libjpeg-turbo)
236 ("acl" ,acl)
237 ("jansson" ,jansson)
238 ("gmp" ,gmp)
239
240 ;; When looking for libpng `configure' links with `-lpng -lz', so we
241 ;; must also provide zlib as an input.
242 ("libpng" ,libpng)
243 ("zlib" ,zlib)
244
245 ("librsvg" ,librsvg)
246 ("libxpm" ,libxpm)
247 ("libxml2" ,libxml2)
248 ("libice" ,libice)
249 ("libsm" ,libsm)
250 ("alsa-lib" ,alsa-lib)
251 ("dbus" ,dbus)
252
253 ;; multilingualization support
254 ("libotf" ,libotf)
255 ("m17n-lib" ,m17n-lib)))
256 (native-inputs
257 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
258 ("pkg-config" ,pkg-config)
259 ("texinfo" ,texinfo)))
260
261 (native-search-paths
262 (list (search-path-specification
263 (variable "EMACSLOADPATH")
264 ;; The versioned entry is for the Emacs' builtin libraries.
265 (files (list "share/emacs/site-lisp"
266 (string-append "share/emacs/" version "/lisp"))))
267 (search-path-specification
268 (variable "INFOPATH")
269 (files '("share/info")))))
270
271 (home-page "https://www.gnu.org/software/emacs/")
272 (synopsis "The extensible, customizable, self-documenting text editor")
273 (description
274 "GNU Emacs is an extensible and highly customizable text editor. It is
275 based on an Emacs Lisp interpreter with extensions for text editing. Emacs
276 has been extended in essentially all areas of computing, giving rise to a
277 vast array of packages supporting, e.g., email, IRC and XMPP messaging,
278 spreadsheets, remote server editing, and much more. Emacs includes extensive
279 documentation on all aspects of the system, from basic editing to writing
280 large Lisp programs. It has full Unicode support for nearly all human
281 languages.")
282 (license license:gpl3+)))
283
284 (define-public emacs-next
285 (let ((commit "2ea34662c20f71d35dd52a5ed996542c7386b9cb")
286 (revision "0"))
287 (package/inherit emacs
288 (name "emacs-next")
289 (version (git-version "28.0.50" revision commit))
290 (source
291 (origin
292 (inherit (package-source emacs))
293 (method git-fetch)
294 (uri (git-reference
295 (url "https://git.savannah.gnu.org/git/emacs.git/")
296 (commit commit)))
297 (file-name (git-file-name name version))
298 (sha256
299 (base32
300 "0igjm9kwiswn2dpiy2k9xikbdfc7njs07ry48fqz70anljj8y7y3"))))
301 (native-inputs
302 `(("autoconf" ,autoconf)
303 ,@(package-native-inputs emacs)))
304 (native-search-paths
305 (list (search-path-specification
306 (variable "EMACSLOADPATH")
307 ;; The versioned entry is for the Emacs' builtin libraries.
308 (files (list "share/emacs/site-lisp"
309 (string-append "share/emacs/"
310 (version-major+minor+point version)
311 "/lisp"))))
312 (search-path-specification
313 (variable "INFOPATH")
314 (files '("share/info"))))))))
315
316 (define-public emacs-minimal
317 ;; This is the version that you should use as an input to packages that just
318 ;; need to byte-compile .el files.
319 (package/inherit emacs
320 (name "emacs-minimal")
321 (synopsis "The extensible text editor (used only for byte-compilation)")
322 (build-system gnu-build-system)
323 (arguments
324 (substitute-keyword-arguments (package-arguments emacs)
325 ((#:configure-flags flags ''())
326 `(list "--with-gnutls=no" "--disable-build-details"))
327 ((#:phases phases)
328 `(modify-phases ,phases
329 (delete 'restore-emacs-pdmp)
330 (delete 'strip-double-wrap)))))
331 (inputs
332 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
333 ("ncurses" ,ncurses)))
334 (native-inputs
335 `(("pkg-config" ,pkg-config)))))
336
337 (define-public emacs-xwidgets
338 (package/inherit emacs
339 (name "emacs-xwidgets")
340 (synopsis "The extensible, customizable, self-documenting text
341 editor (with xwidgets support)")
342 (build-system gnu-build-system)
343 (arguments
344 (substitute-keyword-arguments (package-arguments emacs)
345 ((#:configure-flags flags ''())
346 `(cons "--with-xwidgets" ,flags))
347 ((#:phases phases)
348 `(modify-phases ,phases
349 (delete 'restore-emacs-pdmp)
350 (delete 'strip-double-wrap)))))
351 (inputs
352 `(("webkitgtk" ,webkitgtk)
353 ("libxcomposite" ,libxcomposite)
354 ,@(package-inputs emacs)))))
355
356 (define-public emacs-no-x
357 (package/inherit emacs
358 (name "emacs-no-x")
359 (synopsis "The extensible, customizable, self-documenting text
360 editor (console only)")
361 (build-system gnu-build-system)
362 (inputs (fold alist-delete
363 (package-inputs emacs)
364 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
365 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
366 "libsm" "cairo" "pango" "harfbuzz"
367
368 ;; These depend on libx11, so remove them as well.
369 "libotf" "m17n-lib" "dbus")))
370 (arguments
371 (substitute-keyword-arguments (package-arguments emacs)
372 ((#:configure-flags flags ''())
373 `(delete "--with-cairo" ,flags))
374 ((#:phases phases)
375 `(modify-phases ,phases
376 (delete 'restore-emacs-pdmp)
377 (delete 'strip-double-wrap)))))))
378
379 (define-public emacs-no-x-toolkit
380 (package/inherit emacs
381 (name "emacs-no-x-toolkit")
382 (synopsis "The extensible, customizable, self-documenting text
383 editor (without an X toolkit)" )
384 (build-system gnu-build-system)
385 (inputs (append `(("inotify-tools" ,inotify-tools))
386 (alist-delete "gtk+" (package-inputs emacs))))
387 (arguments
388 (substitute-keyword-arguments (package-arguments emacs)
389 ((#:configure-flags flags ''())
390 `(cons "--with-x-toolkit=no" ,flags))
391 ((#:phases phases)
392 `(modify-phases ,phases
393 (delete 'restore-emacs-pdmp)
394 (delete 'strip-double-wrap)))))))
395
396 (define-public emacs-wide-int
397 (package/inherit emacs
398 (name "emacs-wide-int")
399 (synopsis "The extensible, customizable, self-documenting text
400 editor (with wide ints)" )
401 (arguments
402 (substitute-keyword-arguments (package-arguments emacs)
403 ((#:configure-flags flags)
404 `(cons "--with-wide-int" ,flags))))))
405
406 (define-public guile-emacs
407 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
408 (revision "0"))
409 (package/inherit emacs
410 (name "guile-emacs")
411 (version (git-version "0.0.0" revision commit))
412 (source (origin
413 (method git-fetch)
414 (uri (git-reference
415 (url "https://git.hcoop.net/git/bpt/emacs.git")
416 (commit commit)))
417 (file-name (git-file-name name version))
418 (patches (search-patches "guile-emacs-fix-configure.patch"))
419 (sha256
420 (base32
421 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
422 (native-inputs
423 `(("autoconf" ,autoconf)
424 ("automake" ,automake)
425 ("guile" ,guile-for-guile-emacs)
426 ,@(package-native-inputs emacs)))
427 (arguments
428 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
429 #:parallel-build? #f
430 ;; Tests aren't passing for now.
431 #:tests? #f
432 ,@(package-arguments emacs))
433 ((#:configure-flags flags ''())
434 `(delete "--with-cairo" ,flags))
435 ((#:phases phases)
436 `(modify-phases ,phases
437 (add-after 'unpack 'autogen
438 (lambda _
439 (invoke "sh" "autogen.sh")))
440 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
441 (add-before 'build 'make-deps-dir
442 (lambda _
443 (invoke "mkdir" "-p" "src/deps")))
444 (delete 'restore-emacs-pdmp)
445 (delete 'strip-double-wrap))))))))
446
447 (define-public m17n-db
448 (package
449 (name "m17n-db")
450 (version "1.8.0")
451 (source
452 (origin
453 (method url-fetch)
454 (uri (string-append "mirror://savannah/m17n/m17n-db-"
455 version ".tar.gz"))
456 (sha256
457 (base32
458 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
459 (build-system gnu-build-system)
460 (inputs
461 `(("gettext" ,gettext-minimal)))
462 (arguments
463 `(#:configure-flags
464 (list (string-append "--with-charmaps="
465 (assoc-ref %build-inputs "libc")
466 "/share/i18n/charmaps"))))
467 ;; With `guix lint' the home-page URI returns a small page saying
468 ;; that your browser does not handle frames. This triggers the "URI
469 ;; returns suspiciously small file" warning.
470 (home-page "https://www.nongnu.org/m17n/")
471 (synopsis "Multilingual text processing library (database)")
472 (description "The m17n library realizes multilingualization of
473 many aspects of applications. The m17n library represents
474 multilingual text as an object named M-text. M-text is a string with
475 attributes called text properties, and designed to substitute for
476 string in C. Text properties carry any information required to input,
477 display and edit the text.
478
479 This package contains the library database.")
480 (license license:lgpl2.1+)))
481
482 (define-public m17n-lib
483 (package
484 (name "m17n-lib")
485 (version "1.8.0")
486 (source
487 (origin
488 (method url-fetch)
489 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
490 version ".tar.gz"))
491 (sha256
492 (base32
493 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
494 (build-system gnu-build-system)
495 (inputs
496 `(("fribidi" ,fribidi)
497 ("gd" ,gd)
498 ("libotf" ,libotf)
499 ("libxft" ,libxft)
500 ("libxml2" ,libxml2)
501 ("m17n-db" ,m17n-db)))
502 (arguments
503 `(#:parallel-build? #f))
504 ;; With `guix lint' the home-page URI returns a small page saying
505 ;; that your browser does not handle frames. This triggers the "URI
506 ;; returns suspiciously small file" warning.
507 (home-page "https://www.nongnu.org/m17n/")
508 (synopsis "Multilingual text processing library (runtime)")
509 (description "The m17n library realizes multilingualization of
510 many aspects of applications. The m17n library represents
511 multilingual text as an object named M-text. M-text is a string with
512 attributes called text properties, and designed to substitute for
513 string in C. Text properties carry any information required to input,
514 display and edit the text.
515
516 This package contains the library runtime.")
517 (license license:lgpl2.1+)))