commit: 4c751e364e093f4632240fc30de89d2e34f616da Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Fri Mar 7 16:57:43 2025 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Fri Mar 7 16:57:43 2025 +0000 URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=4c751e36
Make running Emacs more robust * emacs.rc (checkconfig): Make running Emacs more robust. Taken from elisp-common.eclass. Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> ChangeLog | 5 +++++ emacs.rc | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82c0f88..bb62705 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-03-07 Ulrich Müller <[email protected]> + + * emacs.rc (checkconfig): Make running Emacs more robust. + Taken from elisp-common.eclass. + 2025-03-05 Ulrich Müller <[email protected]> * Version 0.23 released. diff --git a/emacs.rc b/emacs.rc index 449e45b..35a76f9 100644 --- a/emacs.rc +++ b/emacs.rc @@ -30,8 +30,12 @@ checkconfig() { return 1 fi - local has_daemon=$(${EMACS} -batch -q --no-site-file \ - --eval "(princ (fboundp 'daemonp))") + # EMACS could be a microemacs variant that ignores the -batch option + # and would therefore hang, waiting for user interaction. + # Redirecting stdin and unsetting TERM and DISPLAY will cause most + # of them to exit with an error. + local has_daemon=$(unset TERM DISPLAY; ${EMACS} -batch -q --no-site-file \ + --eval "(princ (fboundp 'daemonp))" </dev/null) if [ "${has_daemon}" != t ]; then eerror "${EMACS} does not support running as a daemon" return 1
