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>
26 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
83 (uri (string-append "mirror://gnu/emacs/emacs-"
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)))
94 '(with-directory-excursion "lisp"
95 ;; Delete the bundled byte-compiled elisp files and generated
98 (append (find-files "." "\\.elc$")
99 (find-files "." "loaddefs\\.el$")
100 (find-files "eshell" "^esh-groups\\.el$")))
102 ;; Make sure Tramp looks for binaries in the right places on
103 ;; remote Guix System machines, where 'getconf PATH' returns
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")))
113 ;; Make sure Man looks for C header files in the right
115 (substitute* "man.el"
116 (("\"/usr/local/include\"" line)
119 "\"~/.guix-profile/include\""
120 "\"/var/guix/profiles/system/profile/include\"")
123 (build-system glib-or-gtk-build-system)
125 `(#:tests? #f ; no check target
126 #:configure-flags (list "--with-modules"
128 "--disable-build-details")
130 (modify-phases %standard-phases
131 (add-after 'unpack 'patch-program-file-names
133 (substitute* '("src/callproc.c"
135 "lisp/htmlfontify.el"
136 "lisp/textmodes/artist.el"
137 "lisp/progmodes/sh-script.el")
139 (format #f "~s" (which "sh"))))
141 (add-before 'configure 'fix-/bin/pwd
143 ;; Use `pwd', not `/bin/pwd'.
144 (substitute* (find-files "." "^Makefile\\.in$")
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")))
156 ;; This is duplicated from emacs-utils to prevent coupling.
157 (define* (emacs-byte-compile-directory dir)
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))))
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")
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))
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")
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))
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
203 ,(version-major+minor (package-version emacs)))
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.
211 (for-each make-file-writable
212 (find-files %output ".*\\.t?gz$"))
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)
222 ;; TODO: Add the optional dependencies.
227 ("harfbuzz" ,harfbuzz)
231 ("libjpeg" ,libjpeg-turbo)
236 ;; When looking for libpng `configure' links with `-lpng -lz', so we
237 ;; must also provide zlib as an input.
246 ("alsa-lib" ,alsa-lib)
249 ;; multilingualization support
251 ("m17n-lib" ,m17n-lib)))
253 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
254 ("pkg-config" ,pkg-config)
255 ("texinfo" ,texinfo)))
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")))))
267 (home-page "https://www.gnu.org/software/emacs/")
268 (synopsis "The extensible, customizable, self-documenting text editor")
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
278 (license license:gpl3+)))
280 (define-public emacs-next
281 (let ((commit "2ea34662c20f71d35dd52a5ed996542c7386b9cb")
283 (emacs-version "28.0.50.1"))
284 (package/inherit emacs
286 (version (git-version emacs-version revision commit))
289 (inherit (package-source emacs))
292 (url "https://git.savannah.gnu.org/git/emacs.git/")
294 (file-name (git-file-name name version))
297 "0igjm9kwiswn2dpiy2k9xikbdfc7njs07ry48fqz70anljj8y7y3"))))
299 (substitute-keyword-arguments (package-arguments emacs)
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
310 ,(version-major+minor+point (package-version emacs-next)))
314 `(("autoconf" ,autoconf)
315 ,@(package-native-inputs emacs))))))
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)
325 (substitute-keyword-arguments (package-arguments emacs)
326 ((#:configure-flags flags ''())
327 `(list "--with-gnutls=no" "--disable-build-details"))
329 `(modify-phases ,phases
330 (delete 'restore-emacs-pdmp)
331 (delete 'strip-double-wrap)))))
333 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
334 ("ncurses" ,ncurses)))
336 `(("pkg-config" ,pkg-config)))))
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)
345 (substitute-keyword-arguments (package-arguments emacs)
346 ((#:configure-flags flags ''())
347 `(cons "--with-xwidgets" ,flags))
349 `(modify-phases ,phases
350 (delete 'restore-emacs-pdmp)
351 (delete 'strip-double-wrap)))))
353 `(("webkitgtk" ,webkitgtk)
354 ("libxcomposite" ,libxcomposite)
355 ,@(package-inputs emacs)))))
357 (define-public emacs-no-x
358 (package/inherit emacs
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"
369 ;; These depend on libx11, so remove them as well.
370 "libotf" "m17n-lib" "dbus")))
372 (substitute-keyword-arguments (package-arguments emacs)
373 ((#:configure-flags flags ''())
374 `(delete "--with-cairo" ,flags))
376 `(modify-phases ,phases
377 (delete 'restore-emacs-pdmp)
378 (delete 'strip-double-wrap)))))))
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))))
389 (substitute-keyword-arguments (package-arguments emacs)
390 ((#:configure-flags flags ''())
391 `(cons "--with-x-toolkit=no" ,flags))
393 `(modify-phases ,phases
394 (delete 'restore-emacs-pdmp)
395 (delete 'strip-double-wrap)))))))
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)" )
403 (substitute-keyword-arguments (package-arguments emacs)
404 ((#:configure-flags flags)
405 `(cons "--with-wide-int" ,flags))))))
407 (define-public guile-emacs
408 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
410 (package/inherit emacs
412 (version (git-version "0.0.0" revision commit))
416 (url "https://git.hcoop.net/git/bpt/emacs.git")
418 (file-name (git-file-name name version))
419 (patches (search-patches "guile-emacs-fix-configure.patch"))
422 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
424 `(("autoconf" ,autoconf)
425 ("automake" ,automake)
426 ("guile" ,guile-for-guile-emacs)
427 ,@(package-native-inputs emacs)))
429 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
431 ;; Tests aren't passing for now.
433 ,@(package-arguments emacs))
434 ((#:configure-flags flags ''())
435 `(delete "--with-cairo" ,flags))
437 `(modify-phases ,phases
438 (add-after 'unpack 'autogen
440 (invoke "sh" "autogen.sh")))
441 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
442 (add-before 'build 'make-deps-dir
444 (invoke "mkdir" "-p" "src/deps")))
445 (delete 'restore-emacs-pdmp)
446 (delete 'strip-double-wrap))))))))
448 (define-public m17n-db
455 (uri (string-append "mirror://savannah/m17n/m17n-db-"
459 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
460 (build-system gnu-build-system)
462 `(("gettext" ,gettext-minimal)))
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.
480 This package contains the library database.")
481 (license license:lgpl2.1+)))
483 (define-public m17n-lib
490 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
494 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
495 (build-system gnu-build-system)
497 `(("fribidi" ,fribidi)
502 ("m17n-db" ,m17n-db)))
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.
517 This package contains the library runtime.")
518 (license license:lgpl2.1+)))