Paul Eggert [Sun, 9 Dec 2018 06:53:15 +0000 (22:53 -0800)]
Port VECTOR_ELTS_MAX to older GCC etc.
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-12/msg00182.html
* src/alloc.c (VECTOR_ELTS_MAX): Now a macro.
Needed for portability to older GCC and non-GCC.
Paul Eggert [Sun, 9 Dec 2018 00:56:32 +0000 (16:56 -0800)]
Streamline and fix vector-size checks
* src/alloc.c (VECTOR_ELTS_MAX): New constant.
(allocate_vectorlike): LEN now must be positive. Assume LEN
is in range. All callers changed.
(allocate_vector): Arg is now ptrdiff_t, not EMACS_INT.
All callers changed. Return zero vector here, not in
allocate_vectorlike.
* src/lisp.h (make_uninit_vector): Simplify.
* src/xwidget.c (webkit_js_to_lisp):
Check for overflow in ptrdiff_t calculations.
Martin Rudalics [Sat, 8 Dec 2018 08:18:28 +0000 (09:18 +0100)]
Adjust windows' previous buffers when reverting dired buffers (Bug#33458)
* lisp/dired.el (dired-save-positions, dired-restore-positions):
For each window that showed the reverted buffer before, fix the
point positions in its list of previously shown buffers the way
these routines handle window point for all windows currently
showing the buffer (Bug#33458).
Martin Rudalics [Sat, 8 Dec 2018 08:01:23 +0000 (09:01 +0100)]
Improve how 'balance-windows' handles fixed-size windows (Bug#33254)
* lisp/window.el (balance-windows-2): When a child window has
fixed size, don't count it as resizable (Bug#33254).
Handle case where a window has no resizable child windows.
Alan Mackenzie [Fri, 7 Dec 2018 17:38:03 +0000 (17:38 +0000)]
CC Mode: Compensate for backward-sexp ignoring trailing commas after {...}
This fixes bug #32808.
* lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): New variable
comma-delimited, set when we're about to scan backward over a comma. Do not
reckon a brace block as bounding a statement when it is followed or preceded
by a comma (except when argument comma-delim is non-nil).
(c-guess-basic-syntax, CASE 9C): Call c-beginning-of-statement-1 with argument
comma-delim changed to non-nil.
Michael Albinus [Fri, 7 Dec 2018 16:21:03 +0000 (17:21 +0100)]
Refactor some Tramp functions
* lisp/net/tramp-compat.el (tramp-compat-file-local-name): New defsubst.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote):
* lisp/net/tramp.el (tramp-handle-file-name-case-insensitive-p)
(tramp-handle-file-truename, tramp-get-remote-tmpdir):
* lisp/net/tramp-adb.el (tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file, tramp-adb-handle-exec-path):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-directly)
(tramp-sh-handle-exec-path, tramp-find-inline-encoding)
(tramp-get-remote-touch): Use it.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Use `tramp-handle-expand-file-name'.
(tramp-adb-handle-expand-file-name): Move to tramp.el.
(tramp-adb-handle-file-writable-p): Adapt docstring.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Use `tramp-handle-file-local-copy', `tramp-handle-file-writable-p'
and `tramp-handle-write-region'.
(tramp-gvfs-handle-file-local-copy)
(tramp-gvfs-handle-file-writable-p)
(tramp-gvfs-handle-write-region): Move to tramp.el.
* lisp/net/tramp-rclone.el: Dont't require `tramp-adb' and
`tramp-gvfs' anymore.
(tramp-rclone-file-name-handler-alist):
Use `tramp-handle-expand-file-name', `tramp-handle-file-local-copy',
`tramp-handle-file-writable-p' and `tramp-handle-write-region'.
(tramp-rclone-handle-directory-files): Simplify.
Eli Zaretskii [Fri, 7 Dec 2018 08:54:57 +0000 (10:54 +0200)]
Fix the value of default-directory upon startup on MS-Windows
* src/w32.c (w32_get_current_directory): New function.
(GetCachedVolumeInformation, init_environment): Use it.
(w32_init_current_directory): New function.
* src/w32.h (w32_init_current_directory): Add prototype.
* src/emacs.c (main) [WINDOWSNT]: Use w32_init_current_directory
to get the accurate value of cwd. This is needed to record
the correct directory in emacs_wd, which is now initialized
way earlier in the startup process, when init_environment was
not yet called. For details, see the problems reported in
http://lists.gnu.org/archive/html/emacs-devel/2018-12/msg00068.html.
Reported by Angelo Graziosi <angelo.g0@libero.it>.
Paul Eggert [Thu, 6 Dec 2018 18:46:06 +0000 (10:46 -0800)]
emacsclient: avoid background chatter
* 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 [Thu, 6 Dec 2018 16:54:00 +0000 (08:54 -0800)]
Fix emacsclient hang when backgrounded
Problem reported by Kaushal Modi in:
https://lists.gnu.org/r/emacs-devel/2018-12/msg00083.html
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.
Michael Albinus [Thu, 6 Dec 2018 15:11:27 +0000 (16:11 +0100)]
Add missing handler to tramp-rclone.el, improve robustness
* lisp/net/tramp-rclone.el (tramp-adb): Require.
(tramp-rclone-file-name-handler-alist):
Use `tramp-adb-handle-expand-file-name'.
(tramp-rclone-flush-directory-cache): New defun, derived from
`tramp-rclone-flush-mount'.
(tramp-rclone-do-copy-or-rename-file)
(tramp-rclone-handle-delete-directory)
(tramp-rclone-handle-delete-file)
(tramp-rclone-handle-make-directory): Use it.
(tramp-rclone-handle-directory-files)
(tramp-rclone-local-file-name):
Use `tramp-compat-file-name-quoted-p', `tramp-compat-file-name-quote'
and ´tramp-compat-file-name-unquote'.
(tramp-rclone-handle-file-executable-p)
(tramp-rclone-handle-file-readable-p): Cache result.
(tramp-rclone-handle-file-name-all-completions)
(tramp-rclone-mounted-p, tramp-rclone-remote-file-name)
(tramp-rclone-maybe-open-connection): Rewrite.
* test/lisp/net/tramp-tests.el (tramp--test-rclone-p): New defun.
(tramp-test05-expand-file-name-relative)
(tramp--test-special-characters): Use it.
Michael Albinus [Thu, 6 Dec 2018 14:25:22 +0000 (15:25 +0100)]
Make stronger tests for Tramp multi hops
* lisp/net/tramp.el (tramp-dissect-file-name, tramp-dissect-hop-name):
Check, that method is capable of multi hops.
* test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect)
(tramp-test02-file-name-dissect-simplified)
(tramp-test02-file-name-dissect-separate): Suppress check for multihops.
(tramp-test03-file-name-method-rules): Check for error if multi
hops cannot be applied.
Eli Zaretskii [Tue, 4 Dec 2018 18:27:20 +0000 (20:27 +0200)]
Support IBM038 (a.k.a. "EBCDIC-INT") encoding
* lisp/international/mule-conf.el (ibm038): New charset.
(ebcdic-int, cp038): Alias charsets of ibm038.
* lisp/language/english.el (ibm038): New coding-system.
(ebcdic-int, cp038): Alias coding-systems of ibm038.
(Bug#33612)
* etc/NEWS: Announce the new coding system ibm038.
Juri Linkov [Tue, 4 Dec 2018 00:41:54 +0000 (02:41 +0200)]
* lisp/isearch.el (isearch-yank-on-move): New defcustom
with shift-move related options extracted from `search-exit-option'.
(isearch-pre-command-hook): Rename search-exit-option to
isearch-yank-on-move in shift-move related places.
(isearch-post-command-hook): Check for isearch-pre-move-point
instead of search-exit-option. (Bug#15839)
* doc/emacs/search.texi (Not Exiting Isearch): Rename
search-exit-option to isearch-yank-on-move.
* lisp/menu-bar.el (menu-bar-i-search-menu): Add more isearch commands.
Juri Linkov [Tue, 4 Dec 2018 00:24:29 +0000 (02:24 +0200)]
* lisp/isearch.el (isearch-allow-scroll): New option `unlimited'.
(isearch-pre-command-hook): Call isearch-pre-scroll-point unless
isearch-allow-scroll is 'unlimited'.
(isearch-post-command-hook): Use `when' instead of `cond'.
Call isearch-lazy-highlight-new-loop when isearch-allow-scroll is
'unlimited'. (Bug#15839)
Paul Eggert [Mon, 3 Dec 2018 16:06:46 +0000 (08:06 -0800)]
emacsclient: fix typo on recent socket-leak change
This ports to POSIXish platforms like macOS that lack SOCK_CLOEXEC.
Fix suggested by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-12/msg00055.html
* lib-src/emacsclient.c (set_local_socket):
Don’t use SOCK_CLOEXEC; that’s cloexec_socket’s job.
Eli Zaretskii [Mon, 3 Dec 2018 10:29:34 +0000 (12:29 +0200)]
Fix WINDOWSNT/DOS_NT build
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 [Mon, 3 Dec 2018 07:11:09 +0000 (23:11 -0800)]
Use tcdrain, not fdatasync, to drain ttys
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 [Mon, 3 Dec 2018 06:32:28 +0000 (22:32 -0800)]
emacsclient: fix symlink/socket race
* 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).
Eli Zaretskii [Sun, 2 Dec 2018 18:04:05 +0000 (20:04 +0200)]
Revert "Revert "Fix infloop in GC mark_kboards""
This reverts commit c418c85617babbe7b63730fefb71e2c87a0141af.
This reinstates the original fix, as it had nothing to do
with the behavior reported in bug#33571, which seems to be
the expected behavior.
Paul Eggert [Sun, 2 Dec 2018 07:06:06 +0000 (23:06 -0800)]
emacsclient: prefer XDG_RUNTIME_DIR (Bug#33367)
* 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.
Paul Eggert [Fri, 30 Nov 2018 22:22:54 +0000 (14:22 -0800)]
Fix infloop in GC mark_kboards
* src/keyboard.c (KBD_BUFFER_SIZE): Now a constant, not a macro.
(kbd_fetch_ptr, kbd_store_ptr): These now always point somewhere
into kbd_buffer, instead of sometimes pointing just past the
end which led to serious bugs (Bug#33547). All uses changed.
(kbd_store_ptr): No longer volatile. This variable has not been
accessed by a signal handler for some time, it seems.
(next_kbd_event, prev_kbd_event): New functions.
(kbd_buffer_nr_stored, process_special_events): Simplify.
Michael Albinus [Fri, 30 Nov 2018 11:04:57 +0000 (12:04 +0100)]
Fix Bug#33556
* lisp/autorevert.el (auto-revert-notify-add-watch):
Assert that a key in `auto-revert-notify-watch-descriptor-hash-list'
is a valid file notification descriptor. (Bug#33556)
Robert Pluim [Thu, 29 Nov 2018 14:26:44 +0000 (15:26 +0100)]
Convert NS face colors to RGBA when comparing with frame values
The NS port uses indexes into a color table to specify the colors of
faces, whereas frames use RGBA pixel values. In
extend_face_to_end_of_line the two needed to be compared to ensure
that the backgrounds of certain faces are not extended to the edge of
the window, which was failing because of this difference, thus causing
a visual difference with other platforms. Convert from index to RGBA
when doing such comparisons.
* src/dispextern.h (FACE_COLOR_TO_PIXEL) [HAVE_NS]: New macro. Call
ns_color_index_to_rgba under NS only.
* src/nsgui.h: Add prototype for ns_color_index_to_rgba.
* src/nsterm.m (ns_color_index_to_rgba): New function. Converts a
color_table entry to corresponding RGBA pixel value.
* src/xdisp.c (extend_face_to_end_of_line): Call FACE_COLOR_TO_PIXEL
on face background color when comparing with frame color.
Eric Abrahamsen [Wed, 28 Nov 2018 17:31:40 +0000 (09:31 -0800)]
Further small tweaks to Gnus modes cleanup
* lisp/gnus/gnus-sum.el: Remove explicit definition of
`gnus-summary-mode-hook', this is now created automatically.
* lisp/gnus/nnir.el (nnir-open-server): Attach `nnir-mode' to the
`gnus-summary-prepared-hook', instead of
`gnus-summary-mode-hook'. The latter no longer has access to the
buffer-local value of `gnus-newsgroup-name', which `nnir-mode'
needs.
Glenn Morris [Wed, 28 Nov 2018 15:51:12 +0000 (07:51 -0800)]
Merge from origin/emacs-26
74a3a79 (origin/emacs-26) Fix a typo in a doc string 911766d Minor markup fix in frames.texi 19ed1e9 * lisp/net/trampver.el (customize-package-emacs-version-alist... d7132ad * lisp/mh-e/mh-e.el (customize-package-emacs-version-alist): ... 5f39260 * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Pass format to m... a291f62 Don't call xwidget functions until GTK has been initialized f0531b8 Improve documentation of Ediff wordwise commands 2925ce5 Support Hunspell 1.7.0 in ispell.el 03bb7a8 Avoid clearing echo-area message by auto-save-visited-file-name
Alan Mackenzie [Wed, 28 Nov 2018 13:15:50 +0000 (13:15 +0000)]
Make compilation mode work with warnings from compiled buffer functions
In particular, warning messages from compile_defun now contain the source
buffer name and line and column numbers. Typing CR on such a warning now
moves to the pertinent place in the source buffer.
This fixes bug #33475
* lisp/emacs-lisp/bytecomp.el (top-level): Require compile.elc?.
(emacs-lisp-compilation-file-name-or-buffer)
(emacs-lisp-compilation-parse-errors-filename-function): New
variables/constants.
(emacs-lisp-compilation-mode): New mode derived from compilation-mode.
(byte-compile-log-file): Check byte-compile-current-file for being a string,
not merely non-nil. Change wording in message from "buffer" to "in buffer".
Go into emacs-lisp-compilation-mode rather than the plain compilation-mode.
(compile-defun): Bind byte-compile-current-file to current-buffer, not nil.
* lisp/progmodes/compilation-mode
(compilation-parse-errors-filename-function): Amend comments to specify that
this function may return a buffer, and that it need not save the match data.
(Several places): Amend comments to allow for the use of a buffer rather than
a file name.
(compilation-next-error-function): If the "file name" in file struct is
actually a buffer, use it rather than compilation-find-file's result.
(compilation-get-file-structure): save-match-data around the call to
compilation-parse-errors-filename-function. Only call
command-line-normalize-file-name when `filename' is a string.
Michael Albinus [Tue, 27 Nov 2018 13:52:58 +0000 (14:52 +0100)]
Fixes in tramp-clone.el
* lisp/net/tramp-rclone.el (tramp-rclone-parse-device-names):
Wrap by connection property "rclone-device-names".
(tramp-rclone-maybe-open-connection): Do not check for `non-essential'.
Eli Zaretskii [Tue, 27 Nov 2018 08:09:55 +0000 (10:09 +0200)]
Improve documentation of Ediff wordwise commands
* lisp/vc/ediff.el (ediff-windows-wordwise)
(ediff-windows-linewise, ediff-regions-wordwise): Update and
clarify the doc strings.
* doc/misc/ediff.texi (Major Entry Points): Update and clarify
the documentation of 'ediff-windows-wordwise' and
'ediff-regions-wordwise'. See the discussion starting at
https://lists.gnu.org/archive/html/help-gnu-emacs/2018-11/msg00197.html
for the details.
Paul Eggert [Mon, 26 Nov 2018 19:36:51 +0000 (11:36 -0800)]
emacsclient: assume HAVE_INET_SOCKETS
* 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 [Mon, 26 Nov 2018 18:32:35 +0000 (10:32 -0800)]
emacsclient: negate NO_SOCKETS_IN_FILE_SYSTEM
* 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 [Mon, 26 Nov 2018 16:25:36 +0000 (08:25 -0800)]
emacsclient: fix some races on POSIX systems
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
flushing.
(main): Use it. emacs_socket is now a local var.
Act on signals received during recv.
Eli Zaretskii [Mon, 26 Nov 2018 17:31:24 +0000 (19:31 +0200)]
Support Hunspell 1.7.0 in ispell.el
* lisp/textmodes/ispell.el
(ispell-find-hunspell-dictionaries): Invoke Hunspell with an
additional command-line argument, to work around a misfeature
in Hunspell 1.7.0 that prevents it from reporting the loaded
dictionary. (Bug#33493)