/[gentoo-x86]/eclass/elisp-common.eclass
Gentoo

Diff of /eclass/elisp-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.71 Revision 1.79
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.71 2011/02/19 10:12:42 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.79 2012/02/11 12:20:33 ulm Exp $
4#
5# Copyright 2002-2004 Matthew Kennedy <mkennedy@gentoo.org>
6# Copyright 2003 Jeremy Maitin-Shepard <jbms@attbi.com>
7# Copyright 2004-2005 Mamoru Komachi <usata@gentoo.org>
8# Copyright 2007-2008 Christian Faulhammer <fauli@gentoo.org>
9# Copyright 2007-2011 Ulrich Müller <ulm@gentoo.org>
10# 4#
11# @ECLASS: elisp-common.eclass 5# @ECLASS: elisp-common.eclass
12# @MAINTAINER: 6# @MAINTAINER:
13# Feel free to contact the Emacs team through <emacs@gentoo.org> if you 7# Gentoo Emacs team <emacs@gentoo.org>
14# have problems, suggestions or questions. 8# @AUTHOR:
9# Matthew Kennedy <mkennedy@gentoo.org>
10# Jeremy Maitin-Shepard <jbms@attbi.com>
11# Mamoru Komachi <usata@gentoo.org>
12# Christian Faulhammer <fauli@gentoo.org>
13# Ulrich Müller <ulm@gentoo.org>
15# @BLURB: Emacs-related installation utilities 14# @BLURB: Emacs-related installation utilities
16# @DESCRIPTION: 15# @DESCRIPTION:
17# 16#
18# Usually you want to use this eclass for (optional) GNU Emacs support 17# Usually you want to use this eclass for (optional) GNU Emacs support
19# of your package. This is NOT for XEmacs! 18# of your package. This is NOT for XEmacs!
93# features. Be careful though. Commands as "load-library" or "require" 92# features. Be careful though. Commands as "load-library" or "require"
94# bloat the editor as they are loaded on every startup. When having 93# bloat the editor as they are loaded on every startup. When having
95# many Emacs support files, users may be annoyed by the start-up time. 94# many Emacs support files, users may be annoyed by the start-up time.
96# Also avoid keybindings as they might interfere with the user's 95# Also avoid keybindings as they might interfere with the user's
97# settings. Give a hint in pkg_postinst(), which should be enough. 96# settings. Give a hint in pkg_postinst(), which should be enough.
97# The guiding principle is that emerging your package should not by
98# itself cause a change of standard Emacs behaviour.
98# 99#
99# The naming scheme for this site-init file matches the shell pattern 100# The naming scheme for this site-init file matches the shell pattern
100# "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define 101# "[1-8][0-9]*-gentoo*.el", where the two digits at the beginning define
101# the loading order (numbers below 10 or above 89 are reserved for 102# the loading order (numbers below 10 or above 89 are reserved for
102# internal use). So if your initialisation depends on another Emacs 103# internal use). So if your initialisation depends on another Emacs
169# @FUNCTION: elisp-emacs-version 170# @FUNCTION: elisp-emacs-version
170# @DESCRIPTION: 171# @DESCRIPTION:
171# Output version of currently active Emacs. 172# Output version of currently active Emacs.
172 173
173elisp-emacs-version() { 174elisp-emacs-version() {
175 local ret
174 # The following will work for at least versions 18-23. 176 # The following will work for at least versions 18-23.
175 echo "(princ emacs-version)" >"${T}"/emacs-version.el 177 echo "(princ emacs-version)" >"${T}"/emacs-version.el
176 ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el 178 ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el
179 ret=$?
177 rm -f "${T}"/emacs-version.el 180 rm -f "${T}"/emacs-version.el
181 if [[ ${ret} -ne 0 ]]; then
182 eerror "elisp-emacs-version: Failed to run ${EMACS}"
183 fi
184 return ${ret}
178} 185}
179 186
180# @FUNCTION: elisp-need-emacs 187# @FUNCTION: elisp-need-emacs
181# @USAGE: <version> 188# @USAGE: <version>
182# @RETURN: 0 if true, 1 otherwise 189# @RETURN: 0 if true, 1 otherwise
183# @DESCRIPTION: 190# @DESCRIPTION:
184# Test if the eselected Emacs version is at least the major version 191# Test if the eselected Emacs version is at least the major version
185# specified as argument. 192# specified as argument.
186 193
187elisp-need-emacs() { 194elisp-need-emacs() {
188 local need_emacs=$1 195 local need_emacs=$1 have_emacs
189 local have_emacs=$(elisp-emacs-version) 196 have_emacs=$(elisp-emacs-version) || return
190 einfo "Emacs version: ${have_emacs}" 197 einfo "Emacs version: ${have_emacs}"
191 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then 198 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then
192 eerror "This package needs at least Emacs ${need_emacs%%.*}." 199 eerror "This package needs at least Emacs ${need_emacs%%.*}."
193 eerror "Use \"eselect emacs\" to select the active version." 200 eerror "Use \"eselect emacs\" to select the active version."
194 return 1 201 return 1
307# in /usr/share/emacs/site-lisp/. For backwards compatibility, this 314# in /usr/share/emacs/site-lisp/. For backwards compatibility, this
308# location is still supported when generating site-gentoo.el. 315# location is still supported when generating site-gentoo.el.
309 316
310elisp-site-regen() { 317elisp-site-regen() {
311 local sitelisp=${ROOT}${EPREFIX}${SITELISP} 318 local sitelisp=${ROOT}${EPREFIX}${SITELISP}
312 local sf i line null="" page=$'\f' 319 local sf i null="" page=$'\f'
313 local -a sflist 320 local -a sflist
314 321
315 if [ ! -d "${sitelisp}" ]; then 322 if [[ ! -d ${sitelisp} ]]; then
316 eerror "elisp-site-regen: Directory ${sitelisp} does not exist" 323 eerror "elisp-site-regen: Directory ${sitelisp} does not exist"
317 return 1 324 return 1
318 fi 325 fi
319 326
320 if [ ! -d "${T}" ]; then 327 if [[ ! -d ${T} ]]; then
321 eerror "elisp-site-regen: Temporary directory ${T} does not exist" 328 eerror "elisp-site-regen: Temporary directory ${T} does not exist"
322 return 1 329 return 1
323 fi 330 fi
324 331
325 einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." 332 ebegin "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE})"
326 333
327 # Until January 2009, elisp-common.eclass sometimes created an 334 # Until January 2009, elisp-common.eclass sometimes created an
328 # auxiliary file for backwards compatibility. Remove any such file. 335 # auxiliary file for backwards compatibility. Remove any such file.
329 rm -f "${sitelisp}"/00site-gentoo.el 336 rm -f "${sitelisp}"/00site-gentoo.el
330 337
331 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \ 338 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \
332 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el 339 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el
333 do 340 do
334 [ -r "${sf}" ] || continue 341 [[ -r ${sf} ]] || continue
335 # sort files by their basename. straight insertion sort. 342 # sort files by their basename. straight insertion sort.
336 for ((i=${#sflist[@]}; i>0; i--)); do 343 for ((i=${#sflist[@]}; i>0; i--)); do
337 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break 344 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
338 sflist[i]=${sflist[i-1]} 345 sflist[i]=${sflist[i-1]}
339 done 346 done
367 if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then 374 if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then
368 # This prevents outputting unnecessary text when there 375 # This prevents outputting unnecessary text when there
369 # was actually no change. 376 # was actually no change.
370 # A case is a remerge where we have doubled output. 377 # A case is a remerge where we have doubled output.
371 rm -f "${T}"/site-gentoo.el 378 rm -f "${T}"/site-gentoo.el
379 eend
372 echo " no changes." 380 einfo "... no changes."
373 else 381 else
374 mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el 382 mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el
375 echo 383 eend
376 case ${#sflist[@]} in 384 case ${#sflist[@]} in
377 0) ewarn "... Huh? No site initialisation files found." ;; 385 0) ewarn "... Huh? No site initialisation files found." ;;
378 1) einfo "... ${#sflist[@]} site initialisation file included." ;; 386 1) einfo "... ${#sflist[@]} site initialisation file included." ;;
379 *) einfo "... ${#sflist[@]} site initialisation files included." ;; 387 *) einfo "... ${#sflist[@]} site initialisation files included." ;;
380 esac 388 esac

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20