Subject: bug#33219: 25.2; crontab -e doesn't connect to existing emacs daemon

From: Boruch Baum <[email-masked]>
Date: Wed, 31 Oct 2018 17:44:32 -0400

When running 'crontab -e' with $EDITOR set to

  emacsclient -nw -c --alternate-editor=""

emacsclient issues an error that it had failed to locate the emacs
daemon socket file, so it spawns a new emacs daemon. On this
distribution (Devuan Ascii/Ceres, a derviative of Debian 9 without
systemd), the socket file is located at:

  /tmp/user/${UID}/emacs${UID}/server

which in this case the emacsclient binary isn't finding or looking for.

However, in other uses of emacsclient via $EDITOR (eg. mutt, newbeuter,
w3m) the client does find the socket file and does connect to the
existing daemon.

A work-around has been to define:

  export EDITOR="$HOME/.local/bin/emacsclient_wrapper"
  alias emacs="emacsclient_wrapper "

  #!/bin/sh
  # emacsclient_wrapper
  SOCKET_FILE="$(lsof -c emacs -u $USER | grep -m1 -o "[^[:blank:]]\+server")"
  [ -z "$SOCKET_FILE" ] \
  && emacsclient -nw -c --alternate-editor="" $@ \
  || emacsclient -nw -c --alternate-editor="" -s "$SOCKET_FILE" $@

In GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-08-26, modified by Debian built on x86-csail-01
System Description:	Devuan GNU/Linux 2.0.0 (ascii)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/25.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --build x86_64-linux-gnu
 --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/25.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/25.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-x=yes --with-x-toolkit=gtk3
 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-7bZ65w/emacs-25.2+1=.
 -fstack-protector-strong -Wformat -Werror=format-security -Wall'
 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0