commit: 0381452423e624e26fc554f759ea84d6f47a8143 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Sun Mar 9 19:39:22 2025 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Sun Mar 9 19:39:22 2025 +0000 URL: https://gitweb.gentoo.org/proj/emacs-tools.git/commit/?id=03814524
Wrapper and site-init moved to emacs-common * emacs-wrapper.sh: * 10emacs-daemon-gentoo.el: Files removed. These have been moved to the emacs-common package. * Makefile (DISTFILES): Updated. Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> 10emacs-daemon-gentoo.el | 26 -------------------------- ChangeLog | 7 +++++++ Makefile | 3 +-- emacs-wrapper.sh | 3 --- emacs.conf | 6 ++---- emacs.rc | 42 +++++++++++++++++++++--------------------- 6 files changed, 31 insertions(+), 56 deletions(-) diff --git a/10emacs-daemon-gentoo.el b/10emacs-daemon-gentoo.el deleted file mode 100644 index b878eb4..0000000 --- a/10emacs-daemon-gentoo.el +++ /dev/null @@ -1,26 +0,0 @@ -;;; emacs-daemon site-lisp configuration - -;; Copyright 2008-2025 Gentoo Authors -;; Distributed under the terms of the GNU General Public License v2 or later - -(and - (daemonp) - (null after-init-time) - (let* ((file (concat "/var/run/emacs/" (user-login-name) "/emacs.pid")) - (pid (if (file-readable-p file) - ;; Get process id from file - (with-temp-buffer - (ignore-errors - (insert-file-contents-literally file nil 0 100) - (and (looking-at "[0-9]+") - (string-to-number (match-string 0)))))))) - (when (and (integerp pid) - (string-match - "emacs" (or (cdr (assq 'comm (process-attributes pid))) "")) - (/= pid (emacs-pid))) - ;; If another Emacs daemon is already running for this user, - ;; then we would steal its server socket. So we better die. - (message "Another Emacs daemon is already running at process id %d" pid) - (kill-emacs)) - ;; Restart the server if signal SIGUSR1 is received. - (define-key special-event-map [sigusr1] #'server-start))) diff --git a/ChangeLog b/ChangeLog index bb62705..35823a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-03-09 Ulrich Müller <[email protected]> + + * emacs-wrapper.sh: + * 10emacs-daemon-gentoo.el: Files removed. These have been moved + to the emacs-common package. + * Makefile (DISTFILES): Updated. + 2025-03-07 Ulrich Müller <[email protected]> * emacs.rc (checkconfig): Make running Emacs more robust. diff --git a/Makefile b/Makefile index f180383..2e866ae 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ PV = $(shell sed '/^[ \t]*\* .*[Vv]ersion/!d;s/[^0-9.]*\([0-9.]*\).*/\1/;q' \ ChangeLog) P = $(PN)-$(PV) -DISTFILES = README ChangeLog emacs.rc emacs.conf emacs-wrapper.sh \ - 10emacs-daemon-gentoo.el +DISTFILES = README ChangeLog emacs.rc emacs.conf .PHONY: all dist clean diff --git a/emacs-wrapper.sh b/emacs-wrapper.sh deleted file mode 100644 index 22c8cd9..0000000 --- a/emacs-wrapper.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -# Start Emacs with a login shell wrapper to read the user's profile -exec -l "${SHELL}" -c "exec \"${EMACS}\" $*" diff --git a/emacs.conf b/emacs.conf index b962fd9..54a4880 100644 --- a/emacs.conf +++ b/emacs.conf @@ -8,10 +8,8 @@ # Options to pass to emacs. Don't remove "--fg-daemon". #EMACS_OPTS="--fg-daemon" -# Emacs detaches and exits the parent process only after loading the -# user's .emacs (initialisation). Anything may happen there, so we use -# a wrapper script to ensure that the Emacs daemon properly starts. -# This also executes a login shell to read the user's profile. #246460 +# Wrapper script for starting Emacs. This executes a login shell, +# in order to read the user's profile. #246460 #EMACS_START="/usr/libexec/emacs/emacs-wrapper.sh" # Optionally, you may execute a custom script before stopping the diff --git a/emacs.rc b/emacs.rc index 35a76f9..8302aa8 100644 --- a/emacs.rc +++ b/emacs.rc @@ -2,11 +2,11 @@ # Copyright 2008-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 or later -: ${EMACS:=/usr/bin/emacs} -: ${EMACS_OPTS:=--fg-daemon} -: ${EMACS_SHELL=/bin/bash} -: ${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh} -: ${EMACS_TIMEOUT:=30} +: "${EMACS:=/usr/bin/emacs}" +: "${EMACS_OPTS:=--fg-daemon}" +: "${EMACS_SHELL=/bin/bash}" +: "${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh}" +: "${EMACS_TIMEOUT:=30}" USER=${RC_SVCNAME##*.} PIDFILE_DIR=/var/run/emacs/${USER} PIDFILE=${PIDFILE_DIR}/emacs.pid @@ -20,14 +20,14 @@ depend() { checkconfig() { if [ "${USER}" = "${RC_SVCNAME}" ]; then - eerror "You have to create an init script for each user:" - eerror "ln -s emacs /etc/init.d/emacs.<user>" - return 1 + eerror "You have to create an init script for each user:" + eerror "ln -s emacs /etc/init.d/emacs.<user>" + return 1 fi if ! id -u "${USER}" >/dev/null; then - eerror "${USER}: No such user" - return 1 + eerror "${USER}: No such user" + return 1 fi # EMACS could be a microemacs variant that ignores the -batch option @@ -35,10 +35,10 @@ checkconfig() { # 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) + --eval "(princ (fboundp 'daemonp))" </dev/null) if [ "${has_daemon}" != t ]; then - eerror "${EMACS} does not support running as a daemon" - return 1 + eerror "${EMACS} does not support running as a daemon" + return 1 fi checkpath -d --owner 0 --mode 0755 "${PIDFILE_DIR%/*}" @@ -52,7 +52,7 @@ start() { eval home="~${USER}" SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \ - /etc/passwd)} + /etc/passwd)} export SHELL EMACS # XDG_RUNTIME_DIR points to /run/user/0 which is not writable for us @@ -61,22 +61,22 @@ start() { ebegin "Starting Emacs daemon for user ${USER}" start-stop-daemon --start --background --make-pidfile \ - --user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \ - --exec "${EMACS_START}" -- ${EMACS_OPTS} + --user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \ + --exec "${EMACS_START}" -- ${EMACS_OPTS} eend $? } stop() { # Optionally, call a custom script before stopping. if [ "${EMACS_STOP}" ] && [ -x "${EMACS_STOP}" ]; then - export USER PIDFILE EMACS EMACS_TIMEOUT - ebegin "Calling Emacs stop script for ${USER}" - "${EMACS_STOP}" - eend $? || return + export USER PIDFILE EMACS EMACS_TIMEOUT + ebegin "Calling Emacs stop script for ${USER}" + "${EMACS_STOP}" + eend $? || return fi ebegin "Stopping Emacs daemon for user ${USER}" start-stop-daemon --stop --retry "TERM/${EMACS_TIMEOUT}/KILL/5" \ - --user "${USER}" --pidfile "${PIDFILE}" --exec "${EMACS}" + --user "${USER}" --pidfile "${PIDFILE}" --exec "${EMACS}" eend $? }
