| 1 | # Copyright 1999-2008 Gentoo Foundation |
1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.36 2008/02/22 09:30:40 ulm Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.37 2008/03/07 08:19:19 ulm Exp $ |
| 4 | # |
4 | # |
| 5 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
5 | # Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org> |
| 6 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
6 | # Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com> |
| 7 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
7 | # Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org> |
| 8 | # Copyright 2007-2008 Christian Faulhammer <opfer@gentoo.org> |
8 | # Copyright 2007-2008 Christian Faulhammer <opfer@gentoo.org> |
| … | |
… | |
| 201 | |
201 | |
| 202 | elisp-emacs-version() { |
202 | elisp-emacs-version() { |
| 203 | # The following will work for at least versions 18--23. |
203 | # The following will work for at least versions 18--23. |
| 204 | echo "(princ emacs-version)" >"${T}"/emacs-version.el |
204 | echo "(princ emacs-version)" >"${T}"/emacs-version.el |
| 205 | ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el |
205 | ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el |
|
|
206 | rm -f "${T}"/emacs-version.el |
| 206 | } |
207 | } |
| 207 | |
208 | |
| 208 | # @FUNCTION: elisp-make-autoload-file |
209 | # @FUNCTION: elisp-make-autoload-file |
| 209 | # @USAGE: [output file] [list of directories] |
210 | # @USAGE: [output file] [list of directories] |
| 210 | # @DESCRIPTION: |
211 | # @DESCRIPTION: |
| … | |
… | |
| 260 | # @USAGE: <site-init file> [subdirectory] |
261 | # @USAGE: <site-init file> [subdirectory] |
| 261 | # @DESCRIPTION: |
262 | # @DESCRIPTION: |
| 262 | # Install Emacs site-init file in SITELISP directory. |
263 | # Install Emacs site-init file in SITELISP directory. |
| 263 | |
264 | |
| 264 | elisp-site-file-install() { |
265 | elisp-site-file-install() { |
| 265 | local sf="${1##*/}" my_pn="${2:-${PN}}" |
266 | local sf="${T}/${1##*/}" my_pn="${2:-${PN}}" ret |
| 266 | ebegin "Installing site initialisation file for GNU Emacs" |
267 | ebegin "Installing site initialisation file for GNU Emacs" |
| 267 | cp "$1" "${T}/${sf}" |
268 | cp "$1" "${sf}" |
| 268 | sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ |
269 | sed -i -e "s:@SITELISP@:${SITELISP}/${my_pn}:g" \ |
| 269 | -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${T}/${sf}" |
270 | -e "s:@SITEETC@:${SITEETC}/${my_pn}:g" "${sf}" |
| 270 | ( # subshell to avoid pollution of calling environment |
271 | ( # subshell to avoid pollution of calling environment |
| 271 | insinto "${SITELISP}/site-gentoo.d" |
272 | insinto "${SITELISP}/site-gentoo.d" |
| 272 | doins "${T}/${sf}" |
273 | doins "${sf}" |
| 273 | ) |
274 | ) |
|
|
275 | ret=$? |
|
|
276 | rm -f "${sf}" |
| 274 | eend $? "doins failed" |
277 | eend ${ret} "doins failed" |
| 275 | } |
278 | } |
| 276 | |
279 | |
| 277 | # @FUNCTION: elisp-site-regen |
280 | # @FUNCTION: elisp-site-regen |
| 278 | # @DESCRIPTION: |
281 | # @DESCRIPTION: |
| 279 | # Regenerate site-gentoo.el file. The old location for site initialisation |
282 | # Regenerate site-gentoo.el file. The old location for site initialisation |
| … | |
… | |
| 283 | # when generating the start-up file. |
286 | # when generating the start-up file. |
| 284 | |
287 | |
| 285 | elisp-site-regen() { |
288 | elisp-site-regen() { |
| 286 | local i sf line obsolete |
289 | local i sf line obsolete |
| 287 | local -a sflist |
290 | local -a sflist |
|
|
291 | local tmpdir=${T:-/tmp} |
| 288 | |
292 | |
| 289 | if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \ |
293 | if [ ! -e "${ROOT}${SITELISP}"/site-gentoo.el ] \ |
| 290 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then |
294 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ]; then |
| 291 | einfo "Creating default ${SITELISP}/site-start.el ..." |
295 | einfo "Creating default ${SITELISP}/site-start.el ..." |
| 292 | cat <<-EOF >"${T}"/site-start.el |
296 | cat <<-EOF >"${tmpdir}"/site-start.el |
| 293 | ;;; site-start.el |
297 | ;;; site-start.el |
| 294 | |
298 | |
| 295 | ;;; Commentary: |
299 | ;;; Commentary: |
| 296 | ;; This default site startup file is installed by elisp-common.eclass. |
300 | ;; This default site startup file is installed by elisp-common.eclass. |
| 297 | ;; You may replace this file by your own site initialisation, or even |
301 | ;; You may replace this file by your own site initialisation, or even |
| … | |
… | |
| 328 | [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t |
332 | [ "${sf%/*}" = "${ROOT}${SITELISP}" ] && obsolete=t |
| 329 | done |
333 | done |
| 330 | |
334 | |
| 331 | eval "${old_shopts}" |
335 | eval "${old_shopts}" |
| 332 | |
336 | |
| 333 | cat <<-EOF >"${T}"/site-gentoo.el |
337 | cat <<-EOF >"${tmpdir}"/site-gentoo.el |
| 334 | ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
338 | ;;; site-gentoo.el --- site initialisation for Gentoo-installed packages |
| 335 | |
339 | |
| 336 | ;;; Commentary: |
340 | ;;; Commentary: |
| 337 | ;; Automatically generated by elisp-common.eclass |
341 | ;; Automatically generated by elisp-common.eclass |
| 338 | ;; DO NOT EDIT THIS FILE |
342 | ;; DO NOT EDIT THIS FILE |
| 339 | |
343 | |
| 340 | ;;; Code: |
344 | ;;; Code: |
| 341 | EOF |
345 | EOF |
| 342 | cat "${sflist[@]}" </dev/null >>"${T}"/site-gentoo.el |
346 | cat "${sflist[@]}" </dev/null >>"${tmpdir}"/site-gentoo.el |
| 343 | cat <<-EOF >>"${T}"/site-gentoo.el |
347 | cat <<-EOF >>"${tmpdir}"/site-gentoo.el |
| 344 | |
348 | |
| 345 | (provide 'site-gentoo) |
349 | (provide 'site-gentoo) |
| 346 | |
350 | |
| 347 | ;; Local Variables: |
351 | ;; Local Variables: |
| 348 | ;; no-byte-compile: t |
352 | ;; no-byte-compile: t |
| 349 | ;; End: |
353 | ;; End: |
| 350 | ;;; site-gentoo.el ends here |
354 | ;;; site-gentoo.el ends here |
| 351 | EOF |
355 | EOF |
| 352 | |
356 | |
| 353 | if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${T}"/site-gentoo.el; then |
357 | if cmp -s "${ROOT}${SITELISP}"/site-gentoo.el "${tmpdir}"/site-gentoo.el |
|
|
358 | then |
| 354 | # This prevents outputting unnecessary text when there |
359 | # This prevents outputting unnecessary text when there |
| 355 | # was actually no change. |
360 | # was actually no change. |
| 356 | # A case is a remerge where we have doubled output. |
361 | # A case is a remerge where we have doubled output. |
| 357 | echo " no changes." |
362 | echo " no changes." |
| 358 | else |
363 | else |
| 359 | mv "${T}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el |
364 | mv "${tmpdir}"/site-gentoo.el "${ROOT}${SITELISP}"/site-gentoo.el |
| 360 | [ -f "${T}"/site-start.el ] \ |
365 | [ -f "${tmpdir}"/site-start.el ] \ |
| 361 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ |
366 | && [ ! -e "${ROOT}${SITELISP}"/site-start.el ] \ |
| 362 | && mv "${T}"/site-start.el "${ROOT}${SITELISP}"/site-start.el |
367 | && mv "${tmpdir}"/site-start.el "${ROOT}${SITELISP}"/site-start.el |
| 363 | echo; einfo |
368 | echo; einfo |
| 364 | for sf in "${sflist[@]##*/}"; do |
369 | for sf in "${sflist[@]##*/}"; do |
| 365 | einfo " Adding ${sf} ..." |
370 | einfo " Adding ${sf} ..." |
| 366 | done |
371 | done |
| 367 | einfo "Regenerated ${SITELISP}/site-gentoo.el." |
372 | einfo "Regenerated ${SITELISP}/site-gentoo.el." |
| … | |
… | |
| 402 | # visible to old eclass versions. |
407 | # visible to old eclass versions. |
| 403 | for sf in "${sflist[@]}"; do |
408 | for sf in "${sflist[@]}"; do |
| 404 | [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \ |
409 | [ "${sf%/*}" = "${ROOT}${SITELISP}/site-gentoo.d" ] \ |
| 405 | && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el |
410 | && cat "${sf}" >>"${ROOT}${SITELISP}"/00site-gentoo.el |
| 406 | done |
411 | done |
|
|
412 | |
|
|
413 | # cleanup |
|
|
414 | rm -f "${tmpdir}"/site-{gentoo,start}.el |
| 407 | } |
415 | } |