/[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.70 Revision 1.81
1# Copyright 1999-2010 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.70 2010/11/29 17:07:22 ulm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/elisp-common.eclass,v 1.81 2012/07/18 14:28:55 vapier 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-2010 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!
40# 39#
41# Please note that such tests should be limited to packages that are 40# Please note that such tests should be limited to packages that are
42# known to fail with lower Emacs versions; the standard case is to 41# known to fail with lower Emacs versions; the standard case is to
43# depend on virtual/emacs without version. 42# depend on virtual/emacs without version.
44# 43#
45# .SS 44# @ROFF .SS
46# src_compile() usage: 45# src_compile() usage:
47# 46#
48# An elisp file is compiled by the elisp-compile() function defined 47# An elisp file is compiled by the elisp-compile() function defined
49# here and simply takes the source files as arguments. The case of 48# here and simply takes the source files as arguments. The case of
50# interdependent elisp files is also supported, since the current 49# interdependent elisp files is also supported, since the current
59# (default: working directory) as its arguments. Use of this function 58# (default: working directory) as its arguments. Use of this function
60# requires that the elisp source files contain magic ";;;###autoload" 59# requires that the elisp source files contain magic ";;;###autoload"
61# comments. See the Emacs Lisp Reference Manual (node "Autoload") for 60# comments. See the Emacs Lisp Reference Manual (node "Autoload") for
62# a detailed explanation. 61# a detailed explanation.
63# 62#
64# .SS 63# @ROFF .SS
65# src_install() usage: 64# src_install() usage:
66# 65#
67# The resulting compiled files (.elc) should be put in a subdirectory of 66# The resulting compiled files (.elc) should be put in a subdirectory of
68# /usr/share/emacs/site-lisp/ which is named after the first argument 67# /usr/share/emacs/site-lisp/ which is named after the first argument
69# of elisp-install(). The following parameters are the files to be put 68# of elisp-install(). The following parameters are the files to be put
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
117# the extension will be stripped from the destination file's name. 118# the extension will be stripped from the destination file's name.
118# For example, a file "50${PN}-gentoo-${PV}.el" will be installed as 119# For example, a file "50${PN}-gentoo-${PV}.el" will be installed as
119# "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give 120# "50${PN}-gentoo.el". If your subdirectory is not named ${PN}, give
120# the differing name as second argument. 121# the differing name as second argument.
121# 122#
122# .SS 123# @ROFF .SS
123# pkg_postinst() / pkg_postrm() usage: 124# pkg_postinst() / pkg_postrm() usage:
124# 125#
125# After that you need to recreate the start-up file of Emacs after 126# After that you need to recreate the start-up file of Emacs after
126# emerging and unmerging by using 127# emerging and unmerging by using
127# 128#
156EMACS=${EPREFIX}/usr/bin/emacs 157EMACS=${EPREFIX}/usr/bin/emacs
157 158
158# @ECLASS-VARIABLE: EMACSFLAGS 159# @ECLASS-VARIABLE: EMACSFLAGS
159# @DESCRIPTION: 160# @DESCRIPTION:
160# Flags for executing Emacs in batch mode. 161# Flags for executing Emacs in batch mode.
161# These work for Emacs versions 18-23, so don't change them. 162# These work for Emacs versions 18-24, so don't change them.
162EMACSFLAGS="-batch -q --no-site-file" 163EMACSFLAGS="-batch -q --no-site-file"
163 164
164# @ECLASS-VARIABLE: BYTECOMPFLAGS 165# @ECLASS-VARIABLE: BYTECOMPFLAGS
165# @DESCRIPTION: 166# @DESCRIPTION:
166# Emacs flags used for byte-compilation in elisp-compile(). 167# Emacs flags used for byte-compilation in elisp-compile().
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-24.
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}"
198 if [[ ${have_emacs} =~ XEmacs|Lucid ]]; then
199 eerror "This package needs GNU Emacs."
200 return 1
201 fi
191 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then 202 if ! [[ ${have_emacs%%.*} -ge ${need_emacs%%.*} ]]; then
192 eerror "This package needs at least Emacs ${need_emacs%%.*}." 203 eerror "This package needs at least Emacs ${need_emacs%%.*}."
193 eerror "Use \"eselect emacs\" to select the active version." 204 eerror "Use \"eselect emacs\" to select the active version."
194 return 1 205 return 1
195 fi 206 fi
282 293
283 [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \ 294 [[ ${sf} == [0-9][0-9]*-gentoo*.el ]] \
284 || ewarn "elisp-site-file-install: bad name of site-init file" 295 || ewarn "elisp-site-file-install: bad name of site-init file"
285 sf="${T}/${sf/%-gentoo*.el/-gentoo.el}" 296 sf="${T}/${sf/%-gentoo*.el/-gentoo.el}"
286 ebegin "Installing site initialisation file for GNU Emacs" 297 ebegin "Installing site initialisation file for GNU Emacs"
287 [[ $1 = ${sf} ]] || cp "$1" "${sf}" 298 [[ $1 = "${sf}" ]] || cp "$1" "${sf}"
288 sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \ 299 sed -i -e "1{:x;/^\$/{n;bx;};/^;.*${PN}/I!s:^:${header}\n\n:;1s:^:\n:;}" \
289 -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \ 300 -e "s:@SITELISP@:${EPREFIX}${SITELISP}/${my_pn}:g" \
290 -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}" 301 -e "s:@SITEETC@:${EPREFIX}${SITEETC}/${my_pn}:g;\$q" "${sf}"
291 ( # subshell to avoid pollution of calling environment 302 ( # subshell to avoid pollution of calling environment
292 insinto "${SITELISP}/site-gentoo.d" 303 insinto "${SITELISP}/site-gentoo.d"
307# in /usr/share/emacs/site-lisp/. For backwards compatibility, this 318# in /usr/share/emacs/site-lisp/. For backwards compatibility, this
308# location is still supported when generating site-gentoo.el. 319# location is still supported when generating site-gentoo.el.
309 320
310elisp-site-regen() { 321elisp-site-regen() {
311 local sitelisp=${ROOT}${EPREFIX}${SITELISP} 322 local sitelisp=${ROOT}${EPREFIX}${SITELISP}
312 local sf i line null="" page=$'\f' 323 local sf i null="" page=$'\f'
313 local -a sflist 324 local -a sflist
314 325
315 if [ ! -d "${sitelisp}" ]; then 326 if [[ ! -d ${sitelisp} ]]; then
316 eerror "elisp-site-regen: Directory ${sitelisp} does not exist" 327 eerror "elisp-site-regen: Directory ${sitelisp} does not exist"
317 return 1 328 return 1
318 fi 329 fi
319 330
320 if [ ! -d "${T}" ]; then 331 if [[ ! -d ${T} ]]; then
321 eerror "elisp-site-regen: Temporary directory ${T} does not exist" 332 eerror "elisp-site-regen: Temporary directory ${T} does not exist"
322 return 1 333 return 1
323 fi 334 fi
324 335
325 einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." 336 ebegin "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE})"
326 337
327 # Until January 2009, elisp-common.eclass sometimes created an 338 # Until January 2009, elisp-common.eclass sometimes created an
328 # auxiliary file for backwards compatibility. Remove any such file. 339 # auxiliary file for backwards compatibility. Remove any such file.
329 rm -f "${sitelisp}"/00site-gentoo.el 340 rm -f "${sitelisp}"/00site-gentoo.el
330 341
331 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \ 342 for sf in "${sitelisp}"/[0-9][0-9]*-gentoo.el \
332 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el 343 "${sitelisp}"/site-gentoo.d/[0-9][0-9]*.el
333 do 344 do
334 [ -r "${sf}" ] || continue 345 [[ -r ${sf} ]] || continue
335 # sort files by their basename. straight insertion sort. 346 # sort files by their basename. straight insertion sort.
336 for ((i=${#sflist[@]}; i>0; i--)); do 347 for ((i=${#sflist[@]}; i>0; i--)); do
337 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break 348 [[ ${sf##*/} < ${sflist[i-1]##*/} ]] || break
338 sflist[i]=${sflist[i-1]} 349 sflist[i]=${sflist[i-1]}
339 done 350 done
367 if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then 378 if cmp -s "${sitelisp}"/site-gentoo.el "${T}"/site-gentoo.el; then
368 # This prevents outputting unnecessary text when there 379 # This prevents outputting unnecessary text when there
369 # was actually no change. 380 # was actually no change.
370 # A case is a remerge where we have doubled output. 381 # A case is a remerge where we have doubled output.
371 rm -f "${T}"/site-gentoo.el 382 rm -f "${T}"/site-gentoo.el
383 eend
372 echo " no changes." 384 einfo "... no changes."
373 else 385 else
374 mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el 386 mv "${T}"/site-gentoo.el "${sitelisp}"/site-gentoo.el
375 echo 387 eend
376 case ${#sflist[@]} in 388 case ${#sflist[@]} in
377 0) ewarn "... Huh? No site initialisation files found." ;; 389 0) ewarn "... Huh? No site initialisation files found." ;;
378 1) einfo "... ${#sflist[@]} site initialisation file included." ;; 390 1) einfo "... ${#sflist[@]} site initialisation file included." ;;
379 *) einfo "... ${#sflist[@]} site initialisation files included." ;; 391 *) einfo "... ${#sflist[@]} site initialisation files included." ;;
380 esac 392 esac

Legend:
Removed from v.1.70  
changed lines
  Added in v.1.81

  ViewVC Help
Powered by ViewVC 1.1.20