* lib-src/emacsclient.c (main): emacsclient retrieves the current
working directory using get_current_dir_name which returns a newly
allocated string. Make sure this string is freed before exiting.
Copyright-paperwork-exempt: yes
* lib-src/emacsclient.c (main, decode_options)
(print_help_and_exit, longopts): New option '--tramp' / '-T' which
specifies how emacs should use tramp to find remote files.
* doc/emacs/misc.texi (TCP Emacs server): New subsection describing
the various knobs to tune server.el for TCP opereation.
(emacsclient Options): Reference "TCP Emacs server" from description of
--server-file. Document the new '--tramp' / '-T' options.
* doc/emacs/emacs.texi (Top): Update the top-level menu.
* etc/NEWS: Mention the new option.
* lib-src/emacsclient.c (print_help_and_exit, longopts)
(decode_options, main): Implement new option --suppress-output / -u to
suppress printing of eval-results.
* doc/emacs/misc.texi (emacsclient Options): Document the new
"--suppress-output/-u" options.
* etc/NEWS: Mention the new options.
* lib-src/emacsclient.c: Include <string.h>. This is needed on
platforms like FreeBSD 11 that use code involving strlen etc., and
because <config.h> no longer includes string.h.
This follows up on recent problems with the fact that config.h
includes stdlib.h etc.; some files need to include stdlib.h later.
config.h generally should limit itself to includes that are
universally safe; outside of MS-Windows, only stdbool.h makes
the cut among the files currently included. So, move the
other includes to just the files that need them (Bug#24506).
* configure.ac (config_opsysfile): Remove, as this generic hook
is no longer needed.
* lib-src/etags.c, src/unexmacosx.c, src/w32.c, src/w32notify.c:
* src/w32proc.c (_GNU_SOURCE):
Remove, as it’s OK for config.h to do this now.
* src/conf_post.h: Include <ms-w32.h>, instead of the generic
config_opsysfile, for simplicity as this old way of configuring is
now done only for the MS-Windows port. Do not include <ms-w32.h>
if DEFER_MS_W32_H, for the benefit of the few files that want its
effects later. Do not include <alloca.h>, <string.h>, or
<stdlib.h>. Other files modified to include these headers as
needed, or to not include headers that are no longer needed.
* src/lisp.h: Include <alloca.h> and <string.h> here, since
some of the inline functions need them.
* src/regex.c: Include <alloca.h> if not emacs. (If emacs,
we can rely on SAFE_ALLOCA.) There is no longer any need to
worry about HAVE_ALLOCA_H.
* src/unexmacosx.c: Rely on config.h not including stdlib.h.
* src/w32.c, src/w32notify.c, src/w32proc.c (DEFER_MS_W32_H):
Define before including <config.h> first, and include <ms-w32.h>
after the troublesome headers.
This fixes the following warning:
emacsclient.c: In function ‘set_local_socket’:
/usr/include/x86_64-linux-gnu/bits/string3.h:111:3: error:
‘tmpdir’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
return __builtin___stpcpy_chk (__dest, __src, __bos (__dest));
^
emacsclient.c:1197:17: note: ‘tmpdir’ was declared here
const char *tmpdir;
* lib-src/emacsclient.c (set_local_socket): Get rid of use_tmpdir
variable and instead use tmpdir being non-NULL as sign that it should
be used.
* nt/inc/ms-w32.h: Include stdint.h.
(_execvp, execve): Provide prototypes.
* lib-src/emacsclient.c [WINDOWSNT]: Remove prototype for execvp,
it is now in nt/inc/ms-w32.h.
* lib-src/ntlib.c (getppid): Avoid compiler warnings due to format
mismatch.
(sys_ctime): Remove, not used.
Nowadays GCC is smarter, or the Emacs code has mutated, or both,
and now is as good a time as any to remove uses of IF_LINT that
now seem to be unnecessary.
* lib-src/emacsclient.c (set_local_socket):
* lib-src/movemail.c (main) [MAIL_USE_MAILLOCK && HAVE_TOUCHLOCK]:
* src/buffer.c (fix_start_end_in_overlays, fix_overlays_before):
* src/casefiddle.c (casify_region):
* src/charset.c (load_charset_map):
* src/coding.c (decode_coding_object, encode_coding_object):
* src/data.c (Fmake_variable_buffer_local, Fmake_local_variable)
(cons_to_unsigned, cons_to_signed):
* src/frame.c (make_frame, x_set_frame_parameters):
* src/keyboard.c (read_event_from_main_queue):
* src/regex.c (regex_compile):
* src/syntax.c (back_comment):
* src/window.c (Frecenter):
* src/xfaces.c (Fx_list_fonts):
Remove IF_LINT that no longer seems necessary.
* src/image.c (png_load_body, jpeg_load_body): Simplify use of IF_LINT.
* src/keyboard.c (read_char): Use IF_LINT (volatile) rather than
a pragma dance to pacify GCC -Wclobbered.
* src/xdisp.c (x_produce_glyphs): Rewrite to avoid need for IF_LINT.
* src/xterm.c (x_connection_closed): Now _Noreturn, which should
mean we do not need IF_LINT any more.
(x_io_error_quitter): Now _Noreturn. Put an 'assume (false)’
at the end, to forestall warnings from older compilers.
Work around Bug#22884 by rewording comments and strings to avoid ‘(’
at the start of a line unless it starts a function. This change
is a short-term hack; in the longer run we plan to fix cc-mode’s
performance for C files that have ‘(’ at the start of a line in a
comment or string.
These auxiliary programs can’t use Emacs’s text-quoting-style,
and it’s too much trouble to redo that mechanism by hand.
So just use straight quotes for now.
* lib-src/ebrowse.c (main):
* lib-src/emacsclient.c (decode_options, main):
* lib-src/etags.c (Ada_help, default_C_help, Cplusplus_help)
(Forth_help, HTML_help, Lisp_help, Makefile_help, Objc_help)
(Perl_help, PHP_help, Python_help, Scheme_help, TeX_help, auto_help)
(none_help, print_language_names, print_help, add_regex)
(suggest_asking_for_help):
* lib-src/make-docfile.c (write_c_args, scan_c_stream):
Use straight quotes in diagnostics.
* lisp/emacs-lisp/cl-generic.el (cl-generic-define): Don't throw away
previously defined methods.
(cl-generic-define-method): Let-bind purify-flag instead of using `fset'.
(cl--generic-prefill-dispatchers): Only define during compilation.
(cl-method-qualifiers): Remove redundant alias.
(help-fns-short-filename): Silence byte-compiler.
* test/automated/cl-generic-tests.el: Adjust to new defgeneric semantics.
src/emacs.c <w32_daemon_event> [WINDOWSNT]: New global var.
(main) [WINDOWSNT]: Initialize it to NULL. Create the event to
signal clients we are ready for connections.
(Fdaemon_initialized): Use DAEMON_RUNNING.
[WINDOWSNT]: MS-Windows specific code to signal clients we are
ready for connections.
src/lisp.h (DAEMON_RUNNING): New macro, encapsulates Posix and
MS-Windows conditions for running in daemon mode.
src/minibuf.c (read_minibuf): Use DAEMON_RUNNING.
src/keyboard.c (kbd_buffer_get_event): Use DAEMON_RUNNING.
src/dispnew.c (init_display) [WINDOWSNT]: Initialize frames/terminal
even in daemon mode.
nt/inc/ms-w32.h (W32_DAEMON_EVENT): New macro.
lib-src/emacsclient.c (decode_options) [WINDOWSNT]: Don't reject empty
arguments for --alternate-editor.
(print_help_and_exit) [WINDOWSNT]: Don't refrain from advertising
empty arguments for --alternate-editor.
(start_daemon_and_retry_set_socket) [WINDOWSNT]: MS-Windows
specific code to start Emacs in daemon mode and wait for it to be
ready for client connections.
lisp/server.el (server-process-filter): Force GUI frames on
MS-Windows in daemon mode, even if a TTY frame was requested.
lisp/frameset.el (frameset-keep-original-display-p): Don't assume
windows-nt cannot be in daemon mode.
lisp/frame.el (window-system-for-display): Don't assume windows-nt
cannot be in daemon mode.
* lib-src/emacsclient.c (WCONTINUED): Move to ../src/syswait.h.
* src/process.c (handle_child_signal): Remove WCONTINUED ifdef,
because WCONTINUED is always defined now.
* src/syswait.h (WCONTINUED): Move here from ../lib-src/emacsclient.c.
Fixes: debbugs:15110 debbugs:17339
* emacsclient.c (handle_sigcont): Check for tcgetpgrp failure.
Cancel the continue only if tty. Send SIGTTIN to the process
group, not SIGSTOP to self, as this is what the glibc manual
recommends.
(main): If tty, and if started in the background, send SIGTTIN
to the process group.
Fixes: debbugs:16892
* lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ...
(usage_message): ... and replace it with this new static constant
containing multiple literals. All uses changed.
* lib-src/emacsclient.c (print_help_and_exit):
Rewrite to avoid string literals longer than the C89 limits.
(start_daemon_and_retry_set_socket):
Rewrite to avoid non-constant array initializer.
* lib-src/make-docfile.c (enum global_type): Omit trailing comma.
* src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
(B__dummy__): New dummy symbol, to pacify C89.
* src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
they can't grok varargs macros.
* src/dispnew.c (add_window_display_history)
(add_frame_display_history):
* src/print.c (print_object):
* src/xdisp.c (debug_method_add):
Use %p printf format only for void pointers.
* src/emacs.c (usage_message): New constant, replacing ...
(USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
(main): Adjust to usage reorg.
* src/fns.c (syms_of_fns):
* src/profiler.c (syms_of_profiler):
Don't use non-constant struct initializers.
* src/gnutls.h (gnutls_initstage_t):
* src/lisp.h (enum Lisp_Fwd_Type):
* src/lread.c (lisp_file_lexically_bound_p):
* src/xsettings.c (anonymous enum):
Remove trailing comma.
* src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
* src/lisp.h (ENUM_BF): Use unsigned if pedantic.
(DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
(DEFUN): Use it.
* src/regex.c (const_re_char): New type, to pacify strict C89.
All uses of 'const re_char' replaced to use it.
* src/regex.h (_Restrict_): Rename from __restrict, to avoid clash
with glibc when strict C89. This change is imported from gnulib.
All uses changed.
(_Restrict_arr_): Rename from __restrict_arr, similarly.
* src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
Omit GNU_LINUX implementation, since it requires long long.
* src/xterm.c (x_draw_underwave):
Do not assume the traditional order of struct's members.
(x_term_init): Rewrite to avoid the need for non-constant structure
initializers.
* admin/CPP-DEFINES (BSD_SYSTEM, HAVE_FSYNC): Remove.
* admin/merge-gnulib (GNULIB_MODULES): Add fsync, fdatasync.
* configure.ac (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
(fsync): Remove check; now done by gnulib.
* lib/fdatasync.c, lib/fsync.c, m4/fdatasync.m4, m4/fsync.m4:
New files, from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* lib-src/Makefile.in (LIB_FDATASYNC): New macro.
(emacsclient${EXEEXT}): Use it.
* lib-src/emacsclient.c (main): Use fdatasync, not fsync, since we don't
care about metadata. Keep trying if interrupted.
* lib-src/movemail.c (main, popmail): Don't worry about BSD_SYSTEM, since
fsync is available everywhere (or there is a substitute). Don't
report an error if fsync returns EINVAL.
* nt/inc/ms-w32.h (fdatasync): New macro, suggested by Eli Zaretskii.
* src/Makefile.in (LIB_FDATASYNC): New macro.
(LIBES): Use it.
* src/conf_post.h (BSD_SYSTEM, BSD_SYSTEM_AHB): Remove; no longer needed.
* src/fileio.c (Fwrite_region, write_region_inhibit_fsync):
Don't worry about HAVE_FSYNC, since a substitute fsync is
available if the system lacks one.
(Fwrite_regin): Retry fsync if interrupted.
Fixes: debbugs:13944
as gnulib does this if the system doesn't.
* lib-src/emacsclient.c (environ): Remove decl.
* src/callproc.c, src/editfns.c, src/process.c (environ) [!USE_CRT_DLL]:
* src/emacs.c (environ) [DOUG_LEA_MALLOC]:
* src/vm-limit.c (environ) [ORDINARY_LINK]: Remove decl.
* src/vm-limit.c: Include <unistd.h>, for 'environ'.
* configure.ac (DIRECTORY_SEP): Move here from src/lisp.h.
* src/lisp.h (DIRECTORY_SEP): Let configure set it.
* nt/config.nt (DIRECTORY_SEP): Move here from src/lisp.h.
* lib-src/movemail.c (DIRECTORY_SEP, IS_DIRECTORY_SEP):
* lib-src/make-docfile.c (DIRECTORY_SEP, IS_DIRECTORY_SEP):
* lib-src/emacsclient.c (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_DEVICE_SEP):
Remove (they are in config.h now).
* lib-src/emacsclient.c (main): Send -tty to Emacs under more circumstanced (Bug#8314).
* lisp/server.el (server-process-filter): Only try to open a window
system frame if compiled with graphical support (Bug#8314).
Fixes: debbugs:11102
Fix its buggy logic for the Windows case (regression from 23.4).
* lib-src/emacsclient.c (decode_options): Move -t -n corner case handling
into server.el.
* lisp/server.el (server-process-filter): Handle corner case where both
tty and nowait options are present.
Fixes: debbugs:11102
* lib-src/emacsclient.c (main): Handle -print-nonl command.
* lisp/server.el (server-msg-size): New constant.
(server-reply-print): New function.
(server-eval-and-print): Use it.
(server-eval-at): Use server-quote-arg and server-unquote-arg.
Handle -print-nonl.
* emacsclient.c (socket_name): Add const.
(get_server_config): Add parameter config_file, use it instead of
global server_file.
(set_tcp_socket): Add parameter local_server_file, pass it down to
get_server_config.
(set_local_socket): Add parameter local_socket_name, use it
instead of global socket_name.
(set_socket): Adjust calls to set_local_socket and set_tcp_socket.
Don't clobber global server_file or socket_name.
(main): No longer reset server_file or socket_name.
* lib-src/emacsclient.c (decode_options) [WINDOWSNT]: Don't force tty = 0;
instead, treat both -c and -t as always requesting a new "tty" frame,
and let server.el decide which kind is actually required.
Reported by Uwe Siart <usenet@siart.de> in this thread:
http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00303.html
* lisp/server.el (server-delete-client): On Windows, do not try to delete
the only terminal.
(server-process-filter): On Windows, treat requests for a tty frame as
if they were for a GUI frame if the running server is in GUI mode.
Parts of the changes by Fabrice Popineau <fabrice.popineau@supelec.fr>.
lib-src/makefile.w32-in (LOCAL_FLAGS): Add $(EMACS_EXTRA_C_FLAGS).
lib-src/emacsclient.c (main) <environ>: Remove declaration, already
pulled in by unistd.h on Posix hosts and stdlib.h on MS-Windows.
nt/inc/stdint.h (uint32_t, uint64_t) [_WIN64]: New typedefs.
(UINT64_MAX) [_WIN64]: Fix definition.
(uintmax_t, intmax_t): Fix definitions.
nt/inc/inttypes.h (strtoumax, strtoimax) [!__MINGW32__]: Provide
correct definitions.
nt/config.nt (HAVE_DECL_STRTOLL): Define.
(va_copy) [_WIN64]: Provide a better definition.
src/s/ms-w32.h (utimbuf) [_MSC_VER]: Don't define.
(snprintf) [_MSC_VER]: Redirect to _snprintf.
(strtoll) [_MSC_VER]: Redirect to _strtoi64.
(malloc, free, realloc, calloc): Redirect to e_* only when
compiling Emacs.
src/lisp.h (GCTYPEBITS): Move before first use.
(ALIGN_GCTYPEBITS) [_MSC_VER]: Define.
(DECL_ALIGN) [_MSC_VER]: Use it, as MSVC doesn't like bit ops in
this macro definition.
(tzname): Redirect to _tzname for all values of _MSC_VER.
Fixes: debbugs:9960
* emacsclient.c (xmalloc): Accept size_t, not unsigned int, to
avoid potential buffer overflow issues on typical 64-bit hosts.
Return void *, not long *.
(get_current_dir_name): Report a failure, instead of looping
forever, if buffer size calculation overflows. Treat malloc
failures like realloc failures, as that has better behavior and is
more consistent. Do not check whether xmalloc returns NULL, as
that's not possible.
(message): Do not arbitrarily truncate message to 2048 bytes when
sending it to stderr; use vfprintf instead.
(get_server_config, set_local_socket)
(start_daemon_and_retry_set_socket): Do not alloca
arbitrarily-large buffers; that's not safe.
(get_server_config, set_local_socket): Do not use sprintf when its
result might not fit in 'int'.
(set_local_socket): Do not assume uid fits in 'int'.
(get_current_dir_name, w32_getenv, get_server_config, find_tty):
(set_local_socket, main):
Use const char *, not char *, for pointers that are not assigned
through.
This is more consistent, and is nicer with gcc -Wstrict-prototypes.
* ebrowse.c, emacsclient.c, fakemail.c, make-docfile.c, movemail.c:
* profile.c, test-distrib.c, update-game-score.c:
Declare non-'main' functions and variables to be static.
* ebrowse.c: Omit redundant function prototypes.
* ebrowse.c, emacsclient.c: Include <getopt.h>, not "getopt.h".
Since getopt.h is no longer in this directory, there's no point
using the form with double-quotes.
* lib-src/emacsclient.c (get_server_config): Don't read Emacs pid from
the authentication file.
* lisp/server.el (server-start): Don't write pid to the authentication file.
(server-create-tty-frame): Don't send pid.
(server-process-filter): Send pid at the start of every connection.
* lib-src/emacsclient.c: Move socket related #includes together with the
rest of the #includes. Move a WINDOWSNT includes closer together.
(HAVE_CONFIG_H): Remove.
(NO_RETURN): Remove, defined in config.h.
(main): Convert definition to standard C.
Make getcwd conditional on HAVE_GETCWD and declare with the
correct POSIX profile (for some reason MinGW headers define
its 2nd arg as int, not size_t; but getcwd is not used on
Windows nonetheless).
* w32term.c (w32_initialize): Use GetModuleHandle for library that
is already loaded.
Set user model ID if supported (bug#1849).
* runemacs.c (set_user_model_id): New function.
(WinMain): Use it.
* emacsclient.c (w32_give_focus): Use GetModuleHandle for library
that is already loaded.
(w32_set_user_model_id): New function.
(main): Use it to associate emacsclient with emacs (bug#1849).
command-line-normalize-file-name so as to use the `dir' when provided.
* emacsclient.c (main): Always pass cwd via "-dir". Pass the file
names without prepending cwd to them, so Emacs uses its customary
rules to determine how to interpret the file name.
from the pipe.
* startup.el (command-line): Do not mention the server name in
case the user has not mentioned it, print a more explicit message.
* emacsclient.c (start_daemon_and_retry_set_socket): Improve error
checking.
(decode_options): Do not allow an empty alternate_editor on
WINDOWSNT.
(print_help_and_exit): Replace EMACS_DAEMON with WINDOWSNT.
(start_daemon_and_retry_set_socket): Likewise.
Changes when EMACS_DAEMON is not defined:
(print_help_and_exit): Don't add daemon information to help.
(start_daemon_and_retry_set_socket): Make a no-op.
(main): Don't set `start_daemon_if_needed' (which is initialized to 0).
argument does for --alternate-editor.
* emacsclient.1: Describe what an empty string argument does for
--alternate-editor.
* emacsclient.c (print_help_and_exit): Describe what an empty
string argument does for --alternate-editor.
(set_socket): Make it possible to not exit in case of an error.
(start_daemon_and_retry_set_socket): New function.
(main): Use it. Restore the NULL value for socket_name and
server_file after the set_socket call.