1. 28 Mar, 2020 1 commit
    • Paul Eggert's avatar
      Stop using newly-deprecated dosname Gnulib module · 4f41188a
      Paul Eggert authored
      Code is supposed to use the filename module now.
      * admin/merge-gnulib (GNULIB_MODULES): Replace dosname with filename.
      * lib/dosname.h: Remove this forwarding stub.
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
      * lib-src/emacsclient.c, src/fileio.c:
      Include filename.h instead of dosname.h.
  2. 16 Jan, 2020 1 commit
    • Robert Pluim's avatar
      Make emacs prefer an existing ~/.emacs.d to an existing XDG location · 13995f31
      Robert Pluim authored
      * doc/emacs/custom.texi (Find Init): Update description of how Emacs
      finds its init file directory and the interaction with
      (Early Init File): Correct XDG location of early-init.el
      * etc/NEWS: Update description to make it clear the ~/.emacs.d is
      preferred, even if the XDG location exists.
      * lisp/startup.el: Prefer ~/.emacs.d even if the XDG location exists.
      * lib-src/emacsclient.c (open_config): Prefer home directory the XDG
  3. 01 Jan, 2020 1 commit
  4. 15 Sep, 2019 1 commit
  5. 30 Aug, 2019 1 commit
    • Paul Eggert's avatar
      emacsclient: adjust to new config file location · 44f15b63
      Paul Eggert authored
      * lib-src/emacsclient.c (open_config): New arg XDG, to respect
      XDG_CONFIG_HOME, consistently with Emacs proper.  Caller changed.
      Use XDG convention if available, falling back on the old names
      if not.
  6. 27 Jun, 2019 1 commit
  7. 26 Jun, 2019 1 commit
  8. 25 Jun, 2019 1 commit
    • Paul Eggert's avatar
      Prefer PATH_MAX to MAXPATHLEN · 824f7841
      Paul Eggert authored
      PATH_MAX is standardized, MAXPATHLEN is not.
      Also, the Gnulib pathmax module fixes some rare bugs with PATH_MAX.
      So prefer PATH_MAX to MAXPATHLEN unless we know the latter is
      also correct (for some platform-specific code).
      * admin/merge-gnulib (GNULIB_MODULES): Add pathmax.
      This module was already present, as a dependency of canonicalize-lgpl,
      but now Emacs is using it directly.  Sort.
      * lib-src/emacsclient.c: Include stdint.h, pathmax.h.
      (get_current_dir_name): Sync to current src/sysdep.c.
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
      * src/sysdep.c: Include pathmax.h.
      Use PATH_MAX instead of MAXPATHLEN.
  9. 20 Jun, 2019 1 commit
    • Paul Eggert's avatar
      Simplify lib-src version printing · b6af2792
      Paul Eggert authored
      * lib-src/Makefile.in (etags_cflags): Remove.
      All uses replaced by a simple ‘-o $@’.
      (ebrowse${EXEEXT}, emacsclient${EXEEXT}, emacsclientw${EXEEXT}):
      Omit -DVERSION= option.
      * lib-src/ebrowse.c (VERSION):
      * lib-src/emacsclient.c (VERSION):
      * lib-src/etags.c (EMACS_NAME, VERSION): Remove.
      All uses replaced by PACKAGE_NAME and PACKAGE_VERSION.
      * lib-src/ebrowse.c (version):
      * lib-src/etags.c (print_version):
      Use fputs to output the version info, since that’s fputs_unlocked.
      * lib-src/etags.c (PROGRAM_NAME): New macro.
      (print_version): Use it.
  10. 25 Apr, 2019 1 commit
  11. 20 Apr, 2019 1 commit
    • Paul Eggert's avatar
      Improve XDG_RUNTIME_DIR diagnostic · b3a12c62
      Paul Eggert authored
      * lib-src/emacsclient.c (set_local_socket):
      If there appears to be an XDG runtime directory for the user
      but XDG_RUNTIME_DIR is unset, suggest setting it while warning
      about potential security issues (Bug#35300).
  12. 01 Jan, 2019 1 commit
  13. 06 Dec, 2018 2 commits
    • Paul Eggert's avatar
      emacsclient: avoid background chatter · 46b81008
      Paul Eggert authored
      * lib-src/emacsclient.c (process_grouping): New function.
      (act_on_signals, main): Use it.
      (main): Omit "Waiting for Emacs..." and later "\n" messages
      if in background, since that messes up the screen.
    • Paul Eggert's avatar
      Fix emacsclient hang when backgrounded · 2f985977
      Paul Eggert authored
      Problem reported by Kaushal Modi in:
      The tcdrain call replaced an fdatasync call which had no
      effect on the tty, so removing it entirely shouldn’t cause
      problems.  The fdatasync call replaced an fsync call which
      also had no effect on the tty, and the fsync call seems to be
      badly-merged revenant of emacsclient’s old (circa 2004) way of
      communicating to and from Emacs via FILE * streams, where
      fsync was apparently needed when talking to sockets.
      * lib-src/emacsclient.c [!DOS_NT]: Don’t include termios.h.
      (flush_stdout): Remove.  All callers removed.
      (main): Do not drain the tty after "Waiting for Emacs..."
      message.  There should be no need to drain, and draining it
      might send us a SIGTTOU.  Do not fflush stdout just before
      exiting, as exiting does that for us.
  14. 03 Dec, 2018 5 commits
    • Paul Eggert's avatar
      emacsclient: fix typo on recent socket-leak change · bc6ffabe
      Paul Eggert authored
      This ports to POSIXish platforms like macOS that lack SOCK_CLOEXEC.
      Fix suggested by Eli Zaretskii in:
      * lib-src/emacsclient.c (set_local_socket):
      Don’t use SOCK_CLOEXEC; that’s cloexec_socket’s job.
    • Eli Zaretskii's avatar
      Fix WINDOWSNT/DOS_NT build · 2ff9dca1
      Eli Zaretskii authored
      Recent changes in sysdep.c and emacsclient unnecessarily
      removed useful code from DOS_NT builds.  This changeset
      reinstates that code.
      * nt/inc/ms-w32.h (tcdrain): Redirect to _commit.
      (fdatasync): No need to redirect anymore.
      * lib-src/emacsclient.c (flush_stdout): Don't avoid calling
      tcdrain on DOS_NT platforms.
      * src/sysdep.c (reset_sys_modes): Don't ifdef away the call to
      tcdrain on DOS_NT platforms.
    • Paul Eggert's avatar
      emacsclient: don’t leak socket to child processes · 5c412405
      Paul Eggert authored
      * lib-src/emacsclient.c [!WINDOWSNT]: Include fcntl.h.
      (cloexec_socket): New function.
      (set_tcp_socket, set_local_socket): Use it.
    • Paul Eggert's avatar
      Use tcdrain, not fdatasync, to drain ttys · f5090b91
      Paul Eggert authored
      fdatasync is for storage devices, not ttys.
      * admin/merge-gnulib (GNULIB_MODULES): Remove fdatasync.
      * lib/fdatasync.c, m4/fdatasync.m4: Remove.
      * lib-src/Makefile.in (LIB_FDATASYNC):
      * src/Makefile.in (LIB_FDATASYNC):
      Remove.  All uses removed.
      * lib-src/emacsclient.c [!DOS_NT]:
      Include <termios.h>, for tcdrain.
      * lib-src/emacsclient.c (flush_stdout):
      * src/sysdep.c (reset_sys_modes): On ttys, use tcdrain instead
      of fdatasync (except don’t use either function if DOS_NT).
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
    • Paul Eggert's avatar
      emacsclient: fix symlink/socket race · 3e5d7755
      Paul Eggert authored
      * lib-src/emacsclient.c (socket_status): New arg UID.
      All uses changed.
      (set_local_socket): Don’t create the unbound socket unless the
      initial sanity checks on the socket file succeed; this
      simplifies cleaning it up.  Check socket ownership again
      after connecting, to fix a race (Bug#33366).
  15. 02 Dec, 2018 1 commit
    • Paul Eggert's avatar
      emacsclient: prefer XDG_RUNTIME_DIR (Bug#33367) · 92282cb5
      Paul Eggert authored
      * lib-src/emacsclient.c: Disable -Wformat-truncation=2,
      to avoid false alarms about the new snprintf calls.
      (local_sockname): New function.
      (set_local_socket): Use it.  Prefer XDG_RUNTIME_DIR (if set)
      for location of socket directory.  Avoid unnecessary memory
      allocation by using snprintf to destination.
      * lisp/server.el (server-socket-dir): Prefer XDG_RUNTIME_DIR if set.
  16. 26 Nov, 2018 4 commits
    • Eli Zaretskii's avatar
      Unbreak compilation of emacsclient on MS-Windows · 038b425c
      Eli Zaretskii authored
      * lib-src/emacsclient.c (main): Make "-suspend" handling
      conditional on !WINDOWSNT, as there's no SIGSTOP nor 'kill'
    • Paul Eggert's avatar
      emacsclient: assume HAVE_INET_SOCKETS · ed3ae3fc
      Paul Eggert authored
      * configure.ac (HAVE_INET_SOCKETS): Remove.
      * lib-src/emacsclient.c: Simplify by assuming HAVE_SOCKETS and
      HAVE_INET_SOCKETS, which are always true nowadays, except perhaps
      for MS-DOS and if so this program shouldn’t be built there anyway.
      Don’t bother including sys/types.h, as it’s not needed on modern
      systems (and syswait.h does it for us anyway).
      (main): Simplify by assuming SIGSTOP (which is always defined
      if SIGCONT is), and by assuming HAVE_SOCKETS && HAVE_INET_SOCKETS.
    • Paul Eggert's avatar
      emacsclient: negate NO_SOCKETS_IN_FILE_SYSTEM · 5c1bf596
      Paul Eggert authored
      * lib-src/emacsclient.c (SOCKETS_IN_FILE_SYSTEM): Rename from
      NO_SOCKETS_IN_FILE_SYSTEM, with inverted sense.  All uses changed.
      All uses were of the form ‘#ifndef NO_SOCKETS_IN_FILE_SYSTEM’, and
      it’s easier to read ‘#ifdef SOCKETS_IN_FILE_SYSTEM’.
    • Paul Eggert's avatar
      emacsclient: fix some races on POSIX systems · 0331f2f4
      Paul Eggert authored
      Fix some longstanding race conditions due to emacsclient’s use of
      ‘signal’ instead of ‘sigaction’ and its use of nested signal
      handlers.  These races could cause premature exit or incorrect
      commands sent to Emacs.
      * lib-src/emacsclient.c (signal) [!WINDOWSNT]: Do not undef.
      (emacs_socket): Remove this static variable.  It is now a parameter.
      (send_to_emacs): Do not exit merely because ‘send’ was interrupted.
      Instead, act on the signal if possible, and then retry the ‘send’.
      (pass_signal_to_emacs): Remove; now done by act_on_signals.
      (reinstall_handler_if_needed, handle_sigttou, handle_sigwinch)
      (install_handler): New functions.
      (got_sigcont, got_sigtstp, got_sigttou, got_sigwinch):
      New globals, used for more-portable signal handling.
      (handle_sigcont, handle_sigtstp): Just set the static var; other
      actions are now done later by act_on_signals.
      (install_handler): New function that arranges for signals to
      never be reset to default, on modern POSIX platforms.
      This fixes some races.
      (act_on_signals): New function.  When acting on SIGCONT,
      don’t bother calling getpgrp if tcgetpgrp fails.
      (start_daemon_and_retry_set_socket): Return the socket
      rather than setting a global variable.  All uses changed.
      (flush_stdout): New function that acts on signals received while
      (main): Use it.  emacs_socket is now a local var.
      Act on signals received during recv.
  17. 23 Nov, 2018 4 commits
    • Eli Zaretskii's avatar
      Avoid compilation warning in emacsclient.c · 2b1bc701
      Eli Zaretskii authored
      * lib-src/emacsclient.c (set_tcp_socket): Avoid compilation
      warning in MS-Windows build.
    • Paul Eggert's avatar
      emacsclient: fix child exit when exec fails · 652dabff
      Paul Eggert authored
      * lib-src/emacsclient.c (start_daemon_and_retry_set_socket):
      If the execvp of Emacs fails exit instead of having the child
      run on and do the work of the parent.  Coalesce duplicate code.
    • Paul Eggert's avatar
      emacsclient: one ‘main’ function · ef1f6030
      Paul Eggert authored
      * lib-src/emacsclient.c (main): Simplify by having just one
      ‘main’ function instead of two.  Don’t assume argc is positive (!).
    • Paul Eggert's avatar
      emacsclient: tidy socket failure cleanup · 5daba9d8
      Paul Eggert authored
      * lib-src/emacsclient.c (set_tcp_socket, set_local_socket):
      Close socket (instead of leaking it) when ‘connect’ fails.
      (socket_status): Return errno if stat fails and -1 if we don’t own.
      (set_local_socket): Simplify based on socket_status change.
  18. 22 Nov, 2018 3 commits
    • Paul Eggert's avatar
      emacsclient: coalesce WINDOWSNT-specific code · 7a85753d
      Paul Eggert authored
      * lib-src/emacsclient.c (sock_err_message) [WINDOWSNT]:
      Do nothing if w32_window_app () && alternate_editor.
      Both callers changed.
    • Paul Eggert's avatar
      emacsclient: sockaddr portability fixes · 5773470f
      Paul Eggert authored
      * lib-src/emacsclient.c (get_server_config, set_tcp_socket)
      (set_local_socket): Initialize any platform-specific extensions
      of struct to zero, just in case.
      (set_tcp_socket, set_local_socket): Don’t assume struct
      layout details that POSIX does not specify.
      Use union to sidestep some problems with strict aliasing.
      Remove unnecessary casts.
    • Paul Eggert's avatar
      emacsclient: getopt minor cleanup · ad063d25
      Paul Eggert authored
      * lib-src/emacsclient.c (shortopts): New constant.
      (decode_options): Use it.  Do not assume EOF == -1.
  19. 21 Nov, 2018 5 commits
    • Paul Eggert's avatar
      emacsclient: omit EXTRA_SPACE guesswork · 0f22bf09
      Paul Eggert authored
      * lib-src/emacsclient.c: Include <intprops.h>.
      (EXTRA_SPACE): Remove; code no longer guesses this is enough.
      (open_config): New function.
      (get_server_config): Use it.
      (set_local_socket): Compute upper bound of buffer size
      instead of guessing via EXTRA_SPACE.
    • Paul Eggert's avatar
      emacsclient: take more care with int width · 8f49cb00
      Paul Eggert authored
      * lib-src/emacsclient.c: Include inttypes.h, stddef.h.
      (emacs_pid, main): Don’t assume pid fits in int.
      (fail): Don’t assume pointer difference fits in int.
      (set_local_socket): Don’t assume uid fits in long.
    • Paul Eggert's avatar
      emacsclient.c: use C99 to avoid {} · c0870736
      Paul Eggert authored
      * lib-src/emacsclient.c (set_local_socket):
      Assume C99 decl-after-statement and reindent.
    • Paul Eggert's avatar
      emacsclient: improve use of locals · 3fe110d3
      Paul Eggert authored
      * lib-src/emacsclient.c (main):
      Use smaller scopes for some locals.
    • Paul Eggert's avatar
      emacsclient: fix unlikely crash with "&" · 7a85a40e
      Paul Eggert authored
      * lib-src/emacsclient.c (quote_argument):
      Mention *DATA in comment so it’s clear DATA must be non-null.
      (quote_argument, unquote_argument): Simplify.
      (unquote_argument): Don’t crash if the string ends in "&".
  20. 19 Nov, 2018 4 commits
    • Eli Zaretskii's avatar
      Fix last change · 008bc1cb
      Eli Zaretskii authored
      * lib-src/emacsclient.c (start_daemon_and_retry_set_socket)
      [!WINDOWSNT]: Condition usage of socket_name on
      NO_SOCKETS_IN_FILE_SYSTEM being undefined.
    • Eli Zaretskii's avatar
      Avoid compiler warning in emacsclient.c · 57d5c14d
      Eli Zaretskii authored
      * lib-src/emacsclient.c (socket_name): Define only if
      NO_SOCKETS_IN_FILE_SYSTEM is not defined, to avoid a compiler
    • Paul Eggert's avatar
      emacsclient.c: file name component fixes · 0e3b2458
      Paul Eggert authored
      * lib-src/emacsclient.c: Include <dosname.h>.
      (file_name_absolute_p): Remove, as a code duplicate.
      All uses replaced by IS_ABSOLUTE_FILE_NAME.
      (set_local_socket): Don’t treat \ as a file name separator
      on GNU and POSIX hosts.
    • Paul Eggert's avatar
      emacsclient.c: reindent to fit in 80 · 736f1b36
      Paul Eggert authored
      * lib-src/emacsclient.c: Reindent slightly.