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 <bandali@gnu.org>
24 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
80 (uri (string-append "mirror://gnu/emacs/emacs-"
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)))
90 '(with-directory-excursion "lisp"
91 ;; Delete the bundled byte-compiled elisp files and generated
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")))
106 ;; Make sure Tramp looks for binaries in the right places on
107 ;; remote Guix System machines, where 'getconf PATH' returns
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")))
117 ;; Make sure Man looks for C header files in the right
119 (substitute* "man.el"
120 (("\"/usr/local/include\"" line)
123 "\"~/.guix-profile/include\""
124 "\"/var/guix/profiles/system/profile/include\"")
127 (build-system glib-or-gtk-build-system)
129 `(#:tests? #f ; no check target
130 #:configure-flags (list "--with-modules"
131 "--disable-build-details")
133 (modify-phases %standard-phases
134 (add-after 'unpack 'patch-program-file-names
136 (substitute* '("src/callproc.c"
138 "lisp/htmlfontify.el"
139 "lisp/textmodes/artist.el"
140 "lisp/progmodes/sh-script.el")
142 (format #f "~s" (which "sh"))))
144 (add-before 'configure 'fix-/bin/pwd
146 ;; Use `pwd', not `/bin/pwd'.
147 (substitute* (find-files "." "^Makefile\\.in$")
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")))
159 ;; This is duplicated from emacs-utils to prevent coupling.
160 (define* (emacs-byte-compile-directory dir)
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 #f "--eval=~s" expr))))
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")
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)))))))
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)
190 ;; TODO: Add the optional dependencies.
196 ("libjpeg" ,libjpeg-turbo)
197 ("imagemagick" ,imagemagick)
200 ;; When looking for libpng `configure' links with `-lpng -lz', so we
201 ;; must also provide zlib as an input.
210 ("alsa-lib" ,alsa-lib)
213 ;; multilingualization support
215 ("m17n-lib" ,m17n-lib)))
217 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
218 ("pkg-config" ,pkg-config)
219 ("texinfo" ,texinfo)))
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")))))
231 (home-page "https://www.gnu.org/software/emacs/")
232 (synopsis "The extensible, customizable, self-documenting text editor")
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
242 (license license:gpl3+)))
244 (define-public emacs-next
245 (let ((commit "36abf6864604b3061c2e070f8997491fa2bce44c")
247 (emacs-version "27.0.50"))
251 (version (git-version emacs-version revision commit))
256 (url "https://git.savannah.gnu.org/git/emacs.git")
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))))).
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
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")))
281 ;; Make sure Man looks for C header files in the right
283 (substitute* "man.el"
284 (("\"/usr/local/include\"" line)
287 "\"~/.guix-profile/include\""
288 "\"/var/guix/profiles/system/profile/include\"")
292 (substitute-keyword-arguments (package-arguments emacs)
293 ((#:configure-flags flags)
294 `(cons* "--with-harfbuzz" ,flags))
296 `(modify-phases ,phases
297 ;; The 'reset-gzip-timestamps phase will throw a
298 ;; permission error if gzip files aren't writable then
300 'reset-gzip-timestamps
301 'make-compressed-files-writable
303 (for-each make-file-writable
304 (find-files %output ".*\\.t?gz$"))
306 ;; restore the dump file that Emacs installs somewhere in
307 ;; libexec/ to its original state
308 (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
309 (lambda* (#:key outputs target #:allow-other-keys)
310 (let* ((libexec (string-append (assoc-ref outputs "out")
312 ;; each of these find-files should return one file
313 (pdmp (find-files libexec "^emacs\\.pdmp$"))
314 (pdmp-real (find-files libexec
315 "^\\.emacs\\.pdmp-real$")))
316 (for-each (lambda (wrapper real)
317 (delete-file wrapper)
318 (rename-file real wrapper))
322 `(("jansson" ,jansson)
323 ("harfbuzz" ,harfbuzz)
324 ,@(package-inputs emacs)))
326 `(("autoconf" ,autoconf) ; needed when building from trunk
327 ,@(package-native-inputs emacs)))
329 ;; TODO: consider changing `emacs' to use a more robust way of
330 ;; specifying version for "EMACSLOADPATH", so as to avoid having to
331 ;; duplicate native-search-paths here.
333 (list (search-path-specification
334 (variable "EMACSLOADPATH")
335 ;; The versioned entry is for the Emacs' builtin libraries.
337 (list "share/emacs/site-lisp"
338 (string-append "share/emacs/" emacs-version "/lisp"))))
339 (search-path-specification
340 (variable "INFOPATH")
341 (files '("share/info"))))))))
343 (define-public emacs-minimal
344 ;; This is the version that you should use as an input to packages that just
345 ;; need to byte-compile .el files.
346 (package (inherit emacs)
347 (name "emacs-minimal")
348 (synopsis "The extensible text editor (used only for byte-compilation)")
349 (build-system gnu-build-system)
351 (substitute-keyword-arguments (package-arguments emacs)
352 ((#:configure-flags flags ''())
353 `(list "--with-gnutls=no" "--disable-build-details"))))
355 `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
356 ("ncurses" ,ncurses)))
358 `(("pkg-config" ,pkg-config)))))
360 (define-public emacs-xwidgets
363 (name "emacs-xwidgets")
364 (synopsis "The extensible, customizable, self-documenting text
365 editor (with xwidgets support)")
366 (build-system gnu-build-system)
368 (substitute-keyword-arguments (package-arguments emacs)
369 ((#:configure-flags flags ''())
370 `(cons "--with-xwidgets" ,flags))))
372 `(("webkitgtk" ,webkitgtk)
373 ("libxcomposite" ,libxcomposite)
374 ,@(package-inputs emacs)))))
376 (define-public emacs-no-x
377 (package (inherit emacs)
379 (synopsis "The extensible, customizable, self-documenting text
380 editor (console only)")
381 (build-system gnu-build-system)
382 (inputs (fold alist-delete
383 (package-inputs emacs)
384 '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
385 "imagemagick" "libpng" "librsvg" "libxpm" "libice"
388 ;; These depend on libx11, so remove them as well.
389 "libotf" "m17n-lib" "dbus")))))
391 (define-public emacs-no-x-toolkit
392 (package (inherit emacs)
393 (name "emacs-no-x-toolkit")
394 (synopsis "The extensible, customizable, self-documenting text
395 editor (without an X toolkit)" )
396 (build-system gnu-build-system)
397 (inputs (append `(("inotify-tools" ,inotify-tools))
398 (alist-delete "gtk+" (package-inputs emacs))))
400 `(,@(substitute-keyword-arguments (package-arguments emacs)
401 ((#:configure-flags cf)
402 `(cons "--with-x-toolkit=no" ,cf)))))))
404 (define-public emacs-wide-int
407 (name "emacs-wide-int")
408 (synopsis "The extensible, customizable, self-documenting text
409 editor (with wide ints)" )
411 (substitute-keyword-arguments (package-arguments emacs)
412 ((#:configure-flags flags)
413 `(cons "--with-wide-int" ,flags))))))
415 (define-public guile-emacs
416 (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
418 (package (inherit emacs)
420 (version (git-version "0.0.0" revision commit))
424 (url "https://git.hcoop.net/git/bpt/emacs.git")
426 (file-name (git-file-name name version))
427 (patches (search-patches "guile-emacs-fix-configure.patch"))
430 "0lvcvsz0f4mawj04db35p1dvkffdqkz8pkhc0jzh9j9x2i63kcz6"))))
432 `(("autoconf" ,autoconf)
433 ("automake" ,automake)
434 ("guile" ,guile-for-guile-emacs)
435 ,@(package-native-inputs emacs)))
437 (substitute-keyword-arguments `(;; Build fails if we allow parallel build.
439 ;; Tests aren't passing for now.
441 ,@(package-arguments emacs))
443 `(modify-phases ,phases
444 (add-after 'unpack 'autogen
446 (invoke "sh" "autogen.sh")))
447 ;; Build sometimes fails: deps/dispnew.d: No such file or directory
448 (add-before 'build 'make-deps-dir
450 (invoke "mkdir" "-p" "src/deps"))))))))))
452 (define-public m17n-db
459 (uri (string-append "mirror://savannah/m17n/m17n-db-"
463 "0vfw7z9i2s9np6nmx1d4dlsywm044rkaqarn7akffmb6bf1j6zv5"))))
464 (build-system gnu-build-system)
466 `(("gettext" ,gettext-minimal)))
469 (list (string-append "--with-charmaps="
470 (assoc-ref %build-inputs "libc")
471 "/share/i18n/charmaps"))))
472 ;; With `guix lint' the home-page URI returns a small page saying
473 ;; that your browser does not handle frames. This triggers the "URI
474 ;; returns suspiciously small file" warning.
475 (home-page "https://www.nongnu.org/m17n/")
476 (synopsis "Multilingual text processing library (database)")
477 (description "The m17n library realizes multilingualization of
478 many aspects of applications. The m17n library represents
479 multilingual text as an object named M-text. M-text is a string with
480 attributes called text properties, and designed to substitute for
481 string in C. Text properties carry any information required to input,
482 display and edit the text.
484 This package contains the library database.")
485 (license license:lgpl2.1+)))
487 (define-public m17n-lib
494 (uri (string-append "mirror://savannah/m17n/m17n-lib-"
498 "0jp61y09xqj10mclpip48qlfhniw8gwy8b28cbzxy8hq8pkwmfkq"))))
499 (build-system gnu-build-system)
501 `(("fribidi" ,fribidi)
506 ("m17n-db" ,m17n-db)))
508 `(#:parallel-build? #f))
509 ;; With `guix lint' the home-page URI returns a small page saying
510 ;; that your browser does not handle frames. This triggers the "URI
511 ;; returns suspiciously small file" warning.
512 (home-page "https://www.nongnu.org/m17n/")
513 (synopsis "Multilingual text processing library (runtime)")
514 (description "The m17n library realizes multilingualization of
515 many aspects of applications. The m17n library represents
516 multilingual text as an object named M-text. M-text is a string with
517 attributes called text properties, and designed to substitute for
518 string in C. Text properties carry any information required to input,
519 display and edit the text.
521 This package contains the library runtime.")
522 (license license:lgpl2.1+)))