| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 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.76 2011/10/09 09:10:41 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 | |
| 173 | elisp-emacs-version() { |
174 | elisp-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 | |
| 187 | elisp-need-emacs() { |
194 | elisp-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 |
| … | |
… | |
| 310 | elisp-site-regen() { |
317 | elisp-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 line 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 | einfon "Regenerating site-gentoo.el for GNU Emacs (${EBUILD_PHASE}) ..." |
| … | |
… | |
| 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 |