Gentoo Archives: gentoo-commits

From: "José María Alonso" <nimiux@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/lisp:master commit in: eclass/
Date: Sat, 28 Oct 2017 14:25:13
Message-Id: 1509200703.50fcd4aacafbb5d9b08330e9c4d54196c010412c.nimiux@gentoo
1 commit: 50fcd4aacafbb5d9b08330e9c4d54196c010412c
2 Author: Chema Alonso Josa <nimiux <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 28 14:25:03 2017 +0000
4 Commit: José María Alonso <nimiux <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 28 14:25:03 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/lisp.git/commit/?id=50fcd4aa
7
8 elisp.eclass: Copy from gentoo repo
9
10 eclass/elisp-common.eclass | 414 +++++++++++++++++++++++++++++++++++++++++++++
11 eclass/elisp.eclass | 218 ++++++++++++++++++++++++
12 2 files changed, 632 insertions(+)
13
14 diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
15 new file mode 100644
16 index 00000000..05b03f49
17 --- /dev/null
18 +++ b/eclass/elisp-common.eclass
19 @@ -0,0 +1,414 @@
20 +# Copyright 1999-2015 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +
23 +# @ECLASS: elisp-common.eclass
24 +# @MAINTAINER:
25 +# Gentoo GNU Emacs project <gnu-emacs@g.o>
26 +# @AUTHOR:
27 +# Matthew Kennedy <mkennedy@g.o>
28 +# Jeremy Maitin-Shepard <jbms@×××××.com>
29 +# Mamoru Komachi <usata@g.o>
30 +# Christian Faulhammer <fauli@g.o>
31 +# Ulrich Müller <ulm@g.o>
32 +# @BLURB: Emacs-related installation utilities
33 +# @DESCRIPTION:
34 +#
35 +# Usually you want to use this eclass for (optional) GNU Emacs support
36 +# of your package. This is NOT for XEmacs!
37 +#
38 +# Many of the steps here are sometimes done by the build system of your
39 +# package (especially compilation), so this is mainly for standalone
40 +# elisp files you gathered from somewhere else.
41 +#
42 +# When relying on the emacs USE flag, you need to add
43 +#
44 +# @CODE
45 +# emacs? ( virtual/emacs )
46 +# @CODE
47 +#
48 +# to your DEPEND/RDEPEND line and use the functions provided here to
49 +# bring the files to the correct locations.
50 +#
51 +# If your package requires a minimum Emacs version, e.g. Emacs 24, then
52 +# the dependency should be on >=virtual/emacs-24 instead. Because the
53 +# user can select the Emacs executable with eselect, you should also
54 +# make sure that the active Emacs version is sufficient. This can be
55 +# tested with function elisp-need-emacs(), which would typically be
56 +# called from pkg_setup(), as in the following example:
57 +#
58 +# @CODE
59 +# elisp-need-emacs 24 || die "Emacs version too low"
60 +# @CODE
61 +#
62 +# Please note that such tests should be limited to packages that are
63 +# known to fail with lower Emacs versions; the standard case is to
64 +# depend on virtual/emacs without version.
65 +#
66 +# @ROFF .SS
67 +# src_compile() usage:
68 +#
69 +# An elisp file is compiled by the elisp-compile() function defined
70 +# here and simply takes the source files as arguments. The case of
71 +# interdependent elisp files is also supported, since the current
72 +# directory is added to the load-path which makes sure that all files
73 +# are loadable.
74 +#
75 +# @CODE
76 +# elisp-compile *.el
77 +# @CODE
78 +#
79 +# Function elisp-make-autoload-file() can be used to generate a file
80 +# with autoload definitions for the lisp functions. It takes the output
81 +# file name (default: "${PN}-autoloads.el") and a list of directories
82 +# (default: working directory) as its arguments. Use of this function
83 +# requires that the elisp source files contain magic ";;;###autoload"
84 +# comments. See the Emacs Lisp Reference Manual (node "Autoload") for
85 +# a detailed explanation.
86 +#
87 +# @ROFF .SS
88 +# src_install() usage:
89 +#
90 +# The resulting compiled files (.elc) should be put in a subdirectory of
91 +# /usr/share/emacs/site-lisp/ which is named after the first argument
92 +# of elisp-install(). The following parameters are the files to be put
93 +# in that directory. Usually the subdirectory should be ${PN}, you can
94 +# choose something else, but remember to tell elisp-site-file-install()
95 +# (see below) the change, as it defaults to ${PN}.
96 +#
97 +# @CODE
98 +# elisp-install ${PN} *.el *.elc
99 +# @CODE
100 +#
101 +# To let the Emacs support be activated by Emacs on startup, you need
102 +# to provide a site file (shipped in ${FILESDIR}) which contains the
103 +# startup code (have a look in the documentation of your software).
104 +# Normally this would look like this:
105 +#
106 +# @CODE
107 +# (add-to-list 'load-path "@SITELISP@")
108 +# (add-to-list 'auto-mode-alist '("\\.csv\\'" . csv-mode))
109 +# (autoload 'csv-mode "csv-mode" "Major mode for csv files." t)
110 +# @CODE
111 +#
112 +# If your Emacs support files are installed in a subdirectory of
113 +# /usr/share/emacs/site-lisp/ (which is strongly recommended), you need
114 +# to extend Emacs' load-path as shown in the first non-comment line.
115 +# The elisp-site-file-install() function of this eclass will replace
116 +# "@SITELISP@" and "@SITEETC@" by the actual paths.
117 +#
118 +# The next line tells Emacs to load the mode opening a file ending
119 +# with ".csv" and load functions depending on the context and needed
120 +# features. Be careful though. Commands as "load-library" or "require"
121 +# bloat the editor as they are loaded on every startup. When having
122 +# many Emacs support files, users may be annoyed by the start-up time.
123 +# Also avoid keybindings as they might interfere with the user's
124 +# settings. Give a hint in pkg_postinst(), which should be enough.
125 +# The guiding principle is that emerging your package should not by
126 +# itself cause a change of standard Emacs behaviour.
127 +#
128 +# The naming scheme for this site-init file matches the shell pattern
129 +# "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define
130 +# the loading order (numbers below 10 or above 89 are reserved for
131 +# internal use). So if your initialisation depends on another Emacs
132 +# package, your site file's number must be higher! If there are no such
133 +# interdependencies then the number should be 50. Otherwise, numbers
134 +# divisible by 10 are preferred.
135 +#
136 +# Best practice is to define a SITEFILE variable in the global scope of
137 +# your ebuild (e.g., right after S or RDEPEND):
138 +#
139 +# @CODE
140 +# SITEFILE="50${PN}-gentoo.el"
141 +# @CODE
142 +#
143 +# Which is then installed by
144 +#
145 +# @CODE
146 +# elisp-site-file-install "${FILESDIR}/${SITEFILE}"
147 +# @CODE
148 +#
149 +# in src_install(). Any characters after the "-gentoo" part and before
150 +# the extension will be stripped from the destination file's name.
151 +# For example, a file "50${PN}-gentoo-${PV}.el" will be installed as
152 +# "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give
153 +# the differing name as second argument.
154 +#
155 +# @ROFF .SS
156 +# pkg_postinst() / pkg_postrm() usage:
157 +#
158 +# After that you need to recreate the start-up file of Emacs after
159 +# emerging and unmerging by using
160 +#
161 +# @CODE
162 +# pkg_postinst() {
163 +# elisp-site-regen
164 +# }
165 +#
166 +# pkg_postrm() {
167 +# elisp-site-regen
168 +# }
169 +# @CODE
170 +#
171 +# When having optional Emacs support, you should prepend "use emacs &&"
172 +# to above calls of elisp-site-regen().
173 +# Don't use "has_version virtual/emacs"! When unmerging the state of
174 +# the emacs USE flag is taken from the package database and not from the
175 +# environment, so it is no problem when you unset USE=emacs between
176 +# merge and unmerge of a package.
177 +
178 +# @ECLASS-VARIABLE: SITELISP
179 +# @DESCRIPTION:
180 +# Directory where packages install Emacs Lisp files.
181 +SITELISP=/usr/share/emacs/site-lisp
182 +
183 +# @ECLASS-VARIABLE: SITEETC
184 +# @DESCRIPTION:
185 +# Directory where packages install miscellaneous (not Lisp) files.
186 +SITEETC=/usr/share/emacs/etc
187 +
188 +# @ECLASS-VARIABLE: EMACS
189 +# @DESCRIPTION:
190 +# Path of Emacs executable.
191 +EMACS=${EPREFIX}/usr/bin/emacs
192 +
193 +# @ECLASS-VARIABLE: EMACSFLAGS
194 +# @DESCRIPTION:
195 +# Flags for executing Emacs in batch mode.
196 +# These work for Emacs versions 18-24, so don't change them.
197 +EMACSFLAGS="-batch -q --no-site-file"
198 +
199 +# @ECLASS-VARIABLE: BYTECOMPFLAGS
200 +# @DESCRIPTION:
201 +# Emacs flags used for byte-compilation in elisp-compile().
202 +BYTECOMPFLAGS="-L ."
203 +
204 +# @FUNCTION: elisp-emacs-version
205 +# @RETURN: exit status of Emacs
206 +# @DESCRIPTION:
207 +# Output version of currently active Emacs.
208 +
209 +elisp-emacs-version() {
210 + local version ret
211 + # The following will work for at least versions 18-24.
212 + echo "(princ emacs-version)" >"${T}"/emacs-version.el
213 + version=$(
214 + # EMACS could be a microemacs variant that ignores the -batch
215 + # option and would therefore hang, waiting for user interaction.
216 + # Redirecting stdin and unsetting TERM and DISPLAY will cause
217 + # most of them to exit with an error.
218 + unset TERM DISPLAY
219 + ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el </dev/null
220 + )
221 + ret=$?
222 + rm -f "${T}"/emacs-version.el
223 + if [[ ${ret} -ne 0 ]]; then
224 + eerror "elisp-emacs-version: Failed to run ${EMACS}"
225 + return ${ret}
226 + fi
227 + if [[ -z ${version} ]]; then
228 + eerror "elisp-emacs-version: Could not determine Emacs version"
229 + return 1
230 + fi
231 + echo "${version}"
232 +}
233 +
234 +# @FUNCTION: elisp-need-emacs
235 +# @USAGE: <version>
236 +# @RETURN: 0 if true, 1 if false, 2 if trouble
237 +# @DESCRIPTION:
238 +# Test if the eselected Emacs version is at least the major version
239 +# of GNU Emacs specified as argument.
240 +
241 +elisp-need-emacs() {
242 + local need_emacs=$1 have_emacs
243 + have_emacs=$(elisp-emacs-version) || return 2
244 + einfo "Emacs version: ${have_emacs}"
245 + if [[ ${have_emacs} =~ XEmacs|Lucid ]]; then
246 + eerror "This package needs GNU Emacs."
247 + return 1
248 + fi
249 + if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then
250 + eerror "This package needs at least Emacs ${need_emacs%%.*}."
251 + eerror "Use \"eselect emacs\" to select the active version."
252 + return 1
253 + fi
254 + return 0
255 +}
256 +
257 +# @FUNCTION: elisp-compile
258 +# @USAGE: <list of elisp files>
259 +# @DESCRIPTION:
260 +# Byte-compile Emacs Lisp files.
261 +#
262 +# This function uses GNU Emacs to byte-compile all ".el" specified by
263 +# its arguments. The resulting byte-code (".elc") files are placed in
264 +# the same directory as their corresponding source file.
265 +#
266 +# The current directory is added to the load-path. This will ensure
267 +# that interdependent Emacs Lisp files are visible between themselves,
268 +# in case they require or load one another.
269 +
270 +elisp-compile() {
271 + ebegin "Compiling GNU Emacs Elisp files"
272 + ${EMACS} ${EMACSFLAGS} ${BYTECOMPFLAGS} -f batch-byte-compile "$@"
273 + eend $? "elisp-compile: batch-byte-compile failed" || die
274 +}
275 +
276 +# @FUNCTION: elisp-make-autoload-file
277 +# @USAGE: [output file] [list of directories]
278 +# @DESCRIPTION:
279 +# Generate a file with autoload definitions for the lisp functions.
280 +
281 +elisp-make-autoload-file() {
282 + local f="${1:-${PN}-autoloads.el}" null="" page=$'\f'
283 + shift
284 + ebegin "Generating autoload file for GNU Emacs"
285 +
286 + cat >"${f}" <<-EOF
287 + ;;; ${f##*/} --- autoloads for ${PN}
288 +
289 + ;;; Commentary:
290 + ;; Automatically generated by elisp-common.eclass
291 + ;; DO NOT EDIT THIS FILE
292 +
293 + ;;; Code:
294 + ${page}
295 + ;; Local ${null}Variables:
296 + ;; version-control: never
297 + ;; no-byte-compile: t
298 + ;; no-update-autoloads: t
299 + ;; End:
300 +
301 + ;;; ${f##*/} ends here
302 + EOF
303 +
304 + ${EMACS} ${EMACSFLAGS} \
305 + --eval "(setq make-backup-files nil)" \
306 + --eval "(setq generated-autoload-file (expand-file-name \"${f}\"))" \
307 + -f batch-update-autoloads "${@-.}"
308 +
309 + eend $? "elisp-make-autoload-file: batch-update-autoloads failed" || die
310 +}
311 +
312 +# @FUNCTION: elisp-install
313 +# @USAGE: <subdirectory> <list of files>
314 +# @DESCRIPTION:
315 +# Install files in SITELISP directory.
316 +
317 +elisp-install() {
318 + local subdir="$1"
319 + shift
320 + ebegin "Installing Elisp files for GNU Emacs support"
321 + ( # subshell to avoid pollution of calling environment
322 + insinto "${SITELISP}/${subdir}"
323 + doins "$@"
324 + )
325 + eend $? "elisp-install: doins failed" || die
326 +}
327 +
328 +# @FUNCTION: elisp-site-file-install
329 +# @USAGE: <site-init file> [subdirectory]
330 +# @DESCRIPTION:
331 +# Install Emacs site-init file in SITELISP directory. Automatically
332 +# inserts a standard comment header with the name of the package (unless
333 +# it is already present). Tokens @SITELISP@ and @SITEETC@ are replaced
334 +# by the path to the package's subdirectory in SITELISP and SITEETC,
335 +# respectively.
336 +
337 +elisp-site-file-install() {
338 + local sf="${1##*/}" my_pn="${2:-${PN}}" ret
339 + local header=";;; ${PN} site-lisp configuration"
340 +
341 + [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
342 + || ewarn "elisp-site-file-install: bad name of site-init file"
343 + [[ ${sf%-gentoo*.el} != "${sf}" ]] && sf="${sf%-gentoo*.el}-gentoo.el"
344 + sf="${T}/${sf}"
345 + ebegin "Installing site initialisation file for GNU Emacs"
346 + [[ $1 = "${sf}" ]] || cp "$1" "${sf}"
347 + sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \
348 + -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \
349 + -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}"
350 + ( # subshell to avoid pollution of calling environment
351 + insinto "${SITELISP}/site-gentoo.d"
352 + doins "${sf}"
353 + )
354 + ret=$?
355 + rm -f "${sf}"
356 + eend ${ret} "elisp-site-file-install: doins failed" || die
357 +}
358 +
359 +# @FUNCTION: elisp-site-regen
360 +# @DESCRIPTION:
361 +# Regenerate the site-gentoo.el file, based on packages' site
362 +# initialisation files in the /usr/share/emacs/site-lisp/site-gentoo.d/
363 +# directory.
364 +
365 +elisp-site-regen() {
366 + local sitelisp=${ROOT%/}${EPREFIX}${SITELISP}
367 + local sf i ret=0 null="" page=$'\f'
368 + local -a sflist
369 +
370 + if [[ ${EBUILD_PHASE} = *rm && ! -e ${sitelisp}/site-gentoo.el ]]; then
371 + ewarn "Refusing to create site-gentoo.el in ${EBUILD_PHASE} phase."
372 + return 0
373 + fi
374 +
375 + [[ -d ${sitelisp} ]] \
376 + || die "elisp-site-regen: Directory ${sitelisp} does not exist"
377 +
378 + [[ -d ${T} ]] \
379 + || die "elisp-site-regen: Temporary directory ${T} does not exist"
380 +
381 + ebegin "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE})"
382 +
383 + for sf in "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el; do
384 + [[ -r ${sf} ]] && sflist+=("${sf}")
385 + done
386 +
387 + cat <<-EOF >"${T}"/site-gentoo.el || ret=$?
388 + ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages
389 +
390 + ;;; Commentary:
391 + ;; Automatically generated by elisp-common.eclass
392 + ;; DO NOT EDIT THIS FILE
393 +
394 + ;;; Code:
395 + EOF
396 + # Use sed instead of cat here, since files may miss a trailing newline.
397 + sed '$q' "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el || ret=$?
398 + cat <<-EOF >>"${T}"/site-gentoo.el || ret=$?
399 +
400 + ${page}
401 + (provide 'site-gentoo)
402 +
403 + ;; Local ${null}Variables:
404 + ;; no-byte-compile: t
405 + ;; buffer-read-only: t
406 + ;; End:
407 +
408 + ;;; site-gentoo.el ends here
409 + EOF
410 +
411 + if [[ ${ret} -ne 0 ]]; then
412 + eend ${ret} "elisp-site-regen: Writing site-gentoo.el failed."
413 + die
414 + elif cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then
415 + # This prevents outputting unnecessary text when there
416 + # was actually no change.
417 + # A case is a remerge where we have doubled output.
418 + rm -f "${T}"/site-gentoo.el
419 + eend
420 + einfo "... no changes."
421 + else
422 + mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el
423 + eend $? "elisp-site-regen: Replacing site-gentoo.el failed" || die
424 + case ${#sflist[@]} in
425 + 0) [[ ${PN} = emacs-common-gentoo ]] \
426 + || ewarn "... Huh? No site initialisation files found." ;;
427 + 1) einfo "... ${#sflist[@]} site initialisation file included." ;;
428 + *) einfo "... ${#sflist[@]} site initialisation files included." ;;
429 + esac
430 + fi
431 +
432 + return 0
433 +}
434
435 diff --git a/eclass/elisp.eclass b/eclass/elisp.eclass
436 new file mode 100644
437 index 00000000..078a7994
438 --- /dev/null
439 +++ b/eclass/elisp.eclass
440 @@ -0,0 +1,218 @@
441 +# Copyright 1999-2015 Gentoo Foundation
442 +# Distributed under the terms of the GNU General Public License v2
443 +
444 +# @ECLASS: elisp.eclass
445 +# @MAINTAINER:
446 +# Gentoo GNU Emacs project <gnu-emacs@g.o>
447 +# @AUTHOR:
448 +# Matthew Kennedy <mkennedy@g.o>
449 +# Jeremy Maitin-Shepard <jbms@×××××.com>
450 +# Christian Faulhammer <fauli@g.o>
451 +# Ulrich Müller <ulm@g.o>
452 +# @BLURB: Eclass for Emacs Lisp packages
453 +# @DESCRIPTION:
454 +#
455 +# This eclass is designed to install elisp files of Emacs related
456 +# packages into the site-lisp directory. The majority of elisp packages
457 +# will only need to define the standard ebuild variables (like SRC_URI)
458 +# and optionally SITEFILE for successful installation.
459 +#
460 +# Emacs support for other than pure elisp packages is handled by
461 +# elisp-common.eclass where you won't have a dependency on Emacs itself.
462 +# All elisp-* functions are documented there.
463 +#
464 +# If the package's source is a single (in whatever way) compressed elisp
465 +# file with the file name ${P}.el, then this eclass will move ${P}.el to
466 +# ${PN}.el in src_unpack().
467 +
468 +# @ECLASS-VARIABLE: NEED_EMACS
469 +# @DEFAULT_UNSET
470 +# @DESCRIPTION:
471 +# If you need anything different from Emacs 23, use the NEED_EMACS
472 +# variable before inheriting elisp.eclass. Set it to the major version
473 +# your package uses and the dependency will be adjusted.
474 +
475 +# @ECLASS-VARIABLE: ELISP_PATCHES
476 +# @DEFAULT_UNSET
477 +# @DESCRIPTION:
478 +# Space separated list of patches to apply after unpacking the sources.
479 +# Patch files are searched for in the current working dir, WORKDIR, and
480 +# FILESDIR.
481 +
482 +# @ECLASS-VARIABLE: ELISP_REMOVE
483 +# @DEFAULT_UNSET
484 +# @DESCRIPTION:
485 +# Space separated list of files to remove after unpacking the sources.
486 +
487 +# @ECLASS-VARIABLE: SITEFILE
488 +# @DEFAULT_UNSET
489 +# @DESCRIPTION:
490 +# Name of package's site-init file. The filename must match the shell
491 +# pattern "[1-8][0-9]*-gentoo.el"; numbers below 10 and above 89 are
492 +# reserved for internal use. "50${PN}-gentoo.el" is a reasonable choice
493 +# in most cases.
494 +
495 +# @ECLASS-VARIABLE: ELISP_TEXINFO
496 +# @DEFAULT_UNSET
497 +# @DESCRIPTION:
498 +# Space separated list of Texinfo sources. Respective GNU Info files
499 +# will be generated in src_compile() and installed in src_install().
500 +
501 +# @ECLASS-VARIABLE: DOCS
502 +# @DEFAULT_UNSET
503 +# @DESCRIPTION:
504 +# DOCS="blah.txt ChangeLog" is automatically used to install the given
505 +# files by dodoc in src_install().
506 +
507 +inherit elisp-common
508 +
509 +case ${EAPI:-0} in
510 + 0|1)
511 + inherit eutils
512 + EXPORT_FUNCTIONS src_{unpack,compile,install} \
513 + pkg_{setup,postinst,postrm} ;;
514 + 2|3|4|5)
515 + inherit eutils
516 + EXPORT_FUNCTIONS src_{unpack,prepare,configure,compile,install} \
517 + pkg_{setup,postinst,postrm} ;;
518 + 6)
519 + EXPORT_FUNCTIONS src_{unpack,prepare,configure,compile,install} \
520 + pkg_{setup,postinst,postrm} ;;
521 + *) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
522 +esac
523 +
524 +DEPEND=">=virtual/emacs-${NEED_EMACS:-23}"
525 +RDEPEND="${DEPEND}"
526 +
527 +# @FUNCTION: elisp_pkg_setup
528 +# @DESCRIPTION:
529 +# Test if the eselected Emacs version is sufficient to fulfil the major
530 +# version requirement of the NEED_EMACS variable.
531 +
532 +elisp_pkg_setup() {
533 + elisp-need-emacs "${NEED_EMACS:-23}"
534 + case $? in
535 + 0) ;;
536 + 1) die "Emacs version too low" ;;
537 + *) die "Could not determine Emacs version" ;;
538 + esac
539 +}
540 +
541 +# @FUNCTION: elisp_src_unpack
542 +# @DESCRIPTION:
543 +# Unpack the sources; also handle the case of a single *.el file in
544 +# WORKDIR for packages distributed that way. For EAPIs without
545 +# src_prepare, call elisp_src_prepare.
546 +
547 +elisp_src_unpack() {
548 + [[ -n ${A} ]] && unpack ${A}
549 + if [[ -f ${P}.el ]]; then
550 + # the "simple elisp" case with a single *.el file in WORKDIR
551 + mv ${P}.el ${PN}.el || die
552 + [[ -d ${S} ]] || S=${WORKDIR}
553 + fi
554 +
555 + case ${EAPI:-0} in
556 + 0|1) [[ -d ${S} ]] && cd "${S}"
557 + elisp_src_prepare ;;
558 + esac
559 +}
560 +
561 +# @FUNCTION: elisp_src_prepare
562 +# @DESCRIPTION:
563 +# Apply any patches listed in ELISP_PATCHES. Patch files are searched
564 +# for in the current working dir, WORKDIR, and FILESDIR.
565 +
566 +elisp_src_prepare() {
567 + local patch file
568 + for patch in ${ELISP_PATCHES}; do
569 + if [[ -f ${patch} ]]; then
570 + file="${patch}"
571 + elif [[ -f ${WORKDIR}/${patch} ]]; then
572 + file="${WORKDIR}/${patch}"
573 + elif [[ -f ${FILESDIR}/${patch} ]]; then
574 + file="${FILESDIR}/${patch}"
575 + else
576 + die "Cannot find ${patch}"
577 + fi
578 + case ${EAPI:-0} in
579 + 0|1|2|3|4|5) epatch "${file}" ;;
580 + 6) eapply "${file}" ;;
581 + esac
582 + done
583 +
584 + # apply any user patches
585 + case ${EAPI:-0} in
586 + 0|1|2|3|4|5) epatch_user ;;
587 + 6) eapply_user ;;
588 + esac
589 +
590 + if [[ -n ${ELISP_REMOVE} ]]; then
591 + rm ${ELISP_REMOVE} || die
592 + fi
593 +}
594 +
595 +# @FUNCTION: elisp_src_configure
596 +# @DESCRIPTION:
597 +# Do nothing, because Emacs packages seldomly bring a full build system.
598 +
599 +elisp_src_configure() { :; }
600 +
601 +# @FUNCTION: elisp_src_compile
602 +# @DESCRIPTION:
603 +# Call elisp-compile to byte-compile all Emacs Lisp (*.el) files.
604 +# If ELISP_TEXINFO lists any Texinfo sources, call makeinfo to generate
605 +# GNU Info files from them.
606 +
607 +elisp_src_compile() {
608 + elisp-compile *.el
609 + if [[ -n ${ELISP_TEXINFO} ]]; then
610 + makeinfo ${ELISP_TEXINFO} || die
611 + fi
612 +}
613 +
614 +# @FUNCTION: elisp_src_install
615 +# @DESCRIPTION:
616 +# Call elisp-install to install all Emacs Lisp (*.el and *.elc) files.
617 +# If the SITEFILE variable specifies a site-init file, install it with
618 +# elisp-site-file-install. Also install any GNU Info files listed in
619 +# ELISP_TEXINFO and documentation listed in the DOCS variable.
620 +
621 +elisp_src_install() {
622 + elisp-install ${PN} *.el *.elc
623 + if [[ -n ${SITEFILE} ]]; then
624 + elisp-site-file-install "${FILESDIR}/${SITEFILE}"
625 + fi
626 + if [[ -n ${ELISP_TEXINFO} ]]; then
627 + set -- ${ELISP_TEXINFO}
628 + set -- ${@##*/}
629 + doinfo ${@/%.*/.info*} || die
630 + fi
631 + if [[ -n ${DOCS} ]]; then
632 + dodoc ${DOCS} || die
633 + fi
634 + if declare -f readme.gentoo_create_doc >/dev/null; then
635 + readme.gentoo_create_doc
636 + fi
637 +}
638 +
639 +# @FUNCTION: elisp_pkg_postinst
640 +# @DESCRIPTION:
641 +# Call elisp-site-regen, in order to collect the site initialisation for
642 +# all installed Emacs Lisp packages in the site-gentoo.el file.
643 +
644 +elisp_pkg_postinst() {
645 + elisp-site-regen
646 + if declare -f readme.gentoo_print_elog >/dev/null; then
647 + readme.gentoo_print_elog
648 + fi
649 +}
650 +
651 +# @FUNCTION: elisp_pkg_postrm
652 +# @DESCRIPTION:
653 +# Call elisp-site-regen, in order to collect the site initialisation for
654 +# all installed Emacs Lisp packages in the site-gentoo.el file.
655 +
656 +elisp_pkg_postrm() {
657 + elisp-site-regen
658 +}