Gentoo Archives: gentoo-dev

From: Ulrich Mueller <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] RFC: elisp-common.eclass - make version detection more robust
Date: Mon, 29 Jul 2013 12:06:28
Message-Id: 20982.23222.279433.627794@a1i15.kph.uni-mainz.de
1 The patch below will make Emacs version detection more robust.
2
3 Rationale: Some users symlink /usr/bin/emacs to a microemacs variant.
4 Depending on the variant, current version detection will exit with an
5 error, output an empty version, or hang with the editor waiting for
6 user interaction. The patch should fix this for most microemacs
7 flavours. (Not for all of them, unfortunately. Some will start up
8 interactively even if TERM is unset.)
9
10 Please review. I intend to commit the changes in a few days.
11
12 Ulrich
13
14
15 --- elisp-common.eclass 16 Mar 2013 08:55:30 -0000 1.84
16 +++ elisp-common.eclass 29 Jul 2013 11:44:46 -0000
17 @@ -173,16 +173,28 @@
18 # Output version of currently active Emacs.
19
20 elisp-emacs-version() {
21 - local ret
22 + local version ret
23 # The following will work for at least versions 18-24.
24 echo "(princ emacs-version)" >"${T}"/emacs-version.el
25 - ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el
26 + version=$(
27 + # EMACS could be a microemacs variant that ignores the -batch
28 + # option and would therefore hang, waiting for user interaction.
29 + # Redirecting stdin and unsetting TERM and DISPLAY will cause
30 + # most of them to exit with an error.
31 + unset TERM DISPLAY
32 + ${EMACS} ${EMACSFLAGS} -l "${T}"/emacs-version.el </dev/null
33 + )
34 ret=$?
35 rm -f "${T}"/emacs-version.el
36 if [[ ${ret} -ne 0 ]]; then
37 eerror "elisp-emacs-version: Failed to run ${EMACS}"
38 + return ${ret}
39 + fi
40 + if [[ -z ${version} ]]; then
41 + eerror "elisp-emacs-version: Could not determine Emacs version"
42 + return 1
43 fi
44 - return ${ret}
45 + echo "${version}"
46 }
47
48 # @FUNCTION: elisp-need-emacs