Eli Zaretskii [Sat, 7 Sep 2019 09:33:03 +0000 (12:33 +0300)]
Allow client connections when in recursive-edit
* lisp/server.el (server-goto-toplevel): Check minibuffer
depth, not recursion depth. This avoids exiting
recursive-edit if a client connection is accepted during
recursive-edit. (Bug#37176)
Eli Zaretskii [Sat, 7 Sep 2019 07:14:31 +0000 (10:14 +0300)]
Revert "file-truename now uses realpath for local files"
This reverts commit a59839d7556ef85058e09b005f0ff32e59b20ec3.
This commit broke the MS-Windows build (because there's no
realpath on MS-Windows). Even if I change the implementation
to always signal an error on MS-Windows, the build fails.
Paul Eggert [Fri, 6 Sep 2019 21:30:33 +0000 (14:30 -0700)]
file-truename now uses realpath for local files
This uses fewer syscalls on GNU/Linux and other GNUish platforms.
* lisp/files.el (file-truename): Try fileio--truename
if there are no handlers.
* src/fileio.c: Include stdlib.h, for realpath.
(Ffileio__truename): New function.
Mauro Aranda [Wed, 28 Aug 2019 11:29:57 +0000 (08:29 -0300)]
Improve file name completion in file and directory widgets (Bug#7779)
* lisp/wid-edit.el (widget 'file, widget 'directory): Respect the option
read-file-name-completion-ignore-case.
(widget 'directory): Filter the file names, to only perform directory name
completion.
Amin Bandali [Sat, 17 Aug 2019 18:09:11 +0000 (14:09 -0400)]
Fix erc-lurker-update-status (bug#36843)
Broken since 2013-08-22 "* lisp/erc/erc.el: Use lexical-binding".
* lisp/erc/erc.el (erc-message-parsed): New variable.
(erc-display-message): Dynamically bind it.
(erc-lurker-update-status): Check it instead of using `parsed'
directly. This results in `erc-lurker-state' being properly updated
to keep track of non-lurkers, and thus `erc-lurker-p' returning
correct results rather than return t for everyone.
Paul Eggert [Thu, 5 Sep 2019 20:25:43 +0000 (13:25 -0700)]
Fix bugs when recalculating consing_until_gc
Problem reported by Joseph Mingrone (Bug#37006#72).
* src/alloc.c (watch_gc_cons_threshold)
(watch_gc_cons_percentage):
Don’t try to store an intmax_t into an int.
Redo to make the code clearer.
(watch_gc_cons_percentage):
Use gc_cons_threshold, not consing_until_gc.
Paul Eggert [Thu, 5 Sep 2019 18:42:56 +0000 (11:42 -0700)]
Port :safe-renegotiation test to GnuTLS < 3.6.3
Problem reported by Robert Pluim in
https://lists.gnu.org/r/emacs-devel/2019-09/msg00127.html
* src/gnutls.c (Fgnutls_peer_status): Simplify test for
whether the :safe-renegotiation result is needed, so that it
works all the way back to GnuTLS 2.12.2.
Paul Eggert [Thu, 5 Sep 2019 06:13:54 +0000 (23:13 -0700)]
Use plain ‘static’ for Emacs C inline functions
This improved performance of ‘make compile-always’ by 8.2%
on my platform (AMD Phenom II X4 910e, Fedora 30 x86-64).
* src/conf_post.h (INLINE, EXTERN_INLINE, INLINE_HEADER_BEGIN)
(INLINE_HEADER_END) [!EMACS_EXTERN_INLINE]: Use plain ‘static’.
Robert Pluim [Mon, 2 Sep 2019 12:55:00 +0000 (14:55 +0200)]
Don't check for :safe-renegotiation with TLS1.3
* lisp/net/nsm.el (nsm-protocol-check--renegotiation-info-ext): Don't
check when using TLS1.3, renegotiation has been removed from TLS.
Reported in
<https://lists.gnu.org/archive/html/help-gnu-emacs/2019-09/msg00005.html>
Robert Pluim [Wed, 4 Sep 2019 21:43:56 +0000 (23:43 +0200)]
Fix nsm for unencrypted connections
When connecting using a cleartext connection, nsm was erroring out and
tearing down the connection because it was trying to display
nonexistent certificate information.
* lisp/net/nsm.el (nsm-query-user): Only format certificate status
when it is valid. (Bug#37221)
* lisp/epa-file.el (epa-file--replace-text): Gingerly replace the
text in the buffer to preserve as many markers as possible
(bug#34720). This emulates the behaviour of Finsert_file_contents
more accurately.
(epa-file-decode-and-insert): Remove compat code.
(epa-file-insert-file-contents): Use the new function.
Michael Albinus [Wed, 4 Sep 2019 12:13:13 +0000 (14:13 +0200)]
Further work on Bug#37202
* test/lisp/shadowfile-tests.el (shadow-debug): Set to t.
(shadow--tests-cleanup): Simplify.
(shadow-test*): Call `shadow-initialize'.
(shadow-test08-shadow-todo, shadow-test09-shadow-copy-files):
In cleanup, kill buffers used for test.
(top): Do not initialize.
Paul Eggert [Wed, 4 Sep 2019 04:54:58 +0000 (21:54 -0700)]
Prefer functions to macros in buffer.h
In buffer.h, prefer inline functions to function-like macros
when either will do. This helps avoid confusion about how
many times an arg is evaluated. On my platform, this patch
improves performance of ‘make compile-always’ by 5.7%.
Also, prefer enum constants to object-like macros
when either will do.
* src/buffer.h (BEG, BEG_BYTE, GAP_BYTES_DFL, GAP_BYTES_MIN)
(MAX_PER_BUFFER_VARS, NONEXISTENT_MODTIME_NSECS)
(UNKNOWN_MODTIME_NSECS, BUFFER_LISP_SIZE, BUFFER_REST_SIZE):
Now enum constants, instead of macros.
(BUFFER_CEILING_OF, BUFFER_FLOOR_OF, BUF_BEG, BUF_BEG_BYTE)
(BUF_BEGV, BUF_BEGV_BYTE, BUF_PT, BUF_PT_BYTE, BUF_ZV)
(BUF_ZV_BYTE, BUF_GPT_ADDR, BUF_Z_ADDR, BUF_GAP_END_ADDR)
(BUF_COMPUTE_UNCHANGED, SET_PT, TEMP_SET_PT, SET_PT_BOTH)
(TEMP_SET_PT_BOTH, BUF_TEMP_SET_PT, SET_BUF_BEGV, SET_BUF_ZV)
(SET_BUF_BEGV_BOTH, SET_BUF_ZV_BOTH, SET_BUF_PT_BOTH)
(BYTE_POS_ADDR, CHAR_POS_ADDR, CHAR_TO_BYTE, BYTE_TO_CHAR)
(PTR_BYTE_POS, FETCH_CHAR, FETCH_CHAR_AS_MULTIBYTE)
(BUF_BYTE_ADDRESS, BUF_CHAR_ADDRESS, BUF_PTR_BYTE_POS)
(BUF_FETCH_CHAR, BUF_FETCH_CHAR_AS_MULTIBYTE, BUF_FETCH_BYTE)
(BUFFER_PVEC_INIT, BUFFER_LIVE_P, BUFFER_HIDDEN_P)
(BUFFER_CHECK_INDIRECTION, OVERLAY_POSITION, PER_BUFFER_VALUE_P)
(SET_PER_BUFFER_VALUE_P, PER_BUFFER_IDX):
Now inline functions instead of macros.
Paul Eggert [Wed, 4 Sep 2019 04:54:58 +0000 (21:54 -0700)]
Take last_per_buffer_idx private
This will simplify future changes. Turn the runtime check
into an eassert, since it’s not needed in production.
* src/buffer.c (last_per_buffer_idx): Now static.
(valid_per_buffer_idx): New function.
* src/buffer.h (PER_BUFFER_VALUE_P, SET_PER_BUFFER_VALUE_P): Use it.
Paul Eggert [Wed, 4 Sep 2019 04:53:36 +0000 (21:53 -0700)]
Avoid macros in pdumper.c when it’s easy
Problem with DUMP_SET_REFERRER mentioned by Pip Cet at end of:
https://lists.gnu.org/archive/html/emacs-devel/2019-07/msg00548.html
* src/pdumper.c (DANGEROUS, EMACS_RELOC_TYPE_BITS)
(EMACS_RELOC_LENGTH_BITS, DUMP_RELOC_TYPE_BITS)
(DUMP_RELOC_ALIGNMENT_BITS, DUMP_RELOC_OFFSET_BITS)
(DUMP_RELOCATION_ALIGNMENT, DUMP_ALIGNMENT)
(WEIGHT_NONE, WEIGHT_NORMAL, WEIGHT_STRONG)
(PDUMPER_MAX_OBJECT_SIZE):
Now a constant, not a macro.
(divide_round_up): Now a function, not a macro DIVIDE_ROUND_UP.
All uses changed.
(enum link_weight_enum, WEIGHT_NONE_VALUE)
(WEIGHT_NORMAL_VALUE, WEIGHT_STRONG_VALUE): Remove.
(struct link_weight): Just use an int.
(dump_set_referrer): New function, replacing DUMP_SET_REFERRER
macro with a different API. All uses changed.
(dump_clear_referrer): Rename from DUMP_CLEAR_REFERRER.
All uses changed.
(DEFINE_FROMLISP_FUNC, DEFINE_TOLISP_FUNC): Remove.
(intmax_t_from_lisp, intmax_t_to_lisp, dump_off_from_lisp)
(dump_off_to_lisp): Define without using macros,
(dump_off_from_lisp): Add an eassert range check.
(DUMP_FIELD_COPY): Simplify.
Paul Eggert [Wed, 4 Sep 2019 00:34:08 +0000 (17:34 -0700)]
Avoid casting -1 to possibly-unsigned enum
* src/alloc.c (mark_maybe_pointer):
* src/pdumper.h (pdumper_object_p_precise):
Use pdumper_valid_object_type_p.
* src/pdumper.c (pdumper_find_object_type_impl):
* src/pdumper.h (pdumper_find_object_type):
Return int, not enum Lisp_Type. All callers changed.
* src/pdumper.h (PDUMPER_NO_OBJECT): Do not cast -1 to enum
Lisp_Type; in theory, C18 says this could yield 7, which would
mean PDUMPER_NO_OBJECT == Lisp_Float (!).
(pdumper_valid_object_type_p): New function.
Paul Eggert [Tue, 3 Sep 2019 20:03:34 +0000 (13:03 -0700)]
Sync consing_until_gc with gc-cons-threshold
Add watchers for gc-cons-threshold and gc-cons-percentage
that update consing_until_gc accordingly.
Suggested by Eli Zaretskii (Bug#37006#52).
* src/alloc.c (consing_threshold, bump_consing_until_gc)
(watch_gc_cons_threshold, watch_gc_cons_percentage):
New functions.
(garbage_collect_1): Use consing_threshold.
(syms_of_alloc): Arrange to watch gc-cons-threshold and
gc-cons-percentage.
Alan Mackenzie [Tue, 3 Sep 2019 17:33:26 +0000 (17:33 +0000)]
Use left margin to hold "=>" to indicate current error in fringeless windows
This applies to compilation-mode. It amends the fix for bug #36832.
* lisp/progmodes/compile.el (compilation-arrow-overlay): renamed from
overlay-arrow-overlay.
(compilation-margin-string, compilation--dummy-string): New variables.
(compilation-set-up-arrow-spec-in-margin)
(compilation-tear-down-arrow-spec-in-margin): New functions.
(compilation-set-overlay-arrow): Rewritten to use the new variables/functions.
Michael Albinus [Tue, 3 Sep 2019 11:55:42 +0000 (13:55 +0200)]
Fix Bug#37202
* lisp/shadowfile.el (shadow-debug): New defvar.
(shadow-read-files): Suppress error if there's no TODO file.
* test/lisp/shadowfile-tests.el (shadow-debug): Set to nil.
(shadow--tests-cleanup): New defun. Apply to all tests. (Bug#37202)
(shadow-test06-literal-groups): Cleanup temp buffer.
(shadow-test08-shadow-todo): Add debug messages.
(top): Cleanup initially.
Paul Eggert [Mon, 2 Sep 2019 19:37:52 +0000 (12:37 -0700)]
Update from Gnulib
This incorporates:
2019-08-25 intprops.h, verify.h: port better to clang
2019-08-21 New strip-trailing-space option for srclist-update
* .gitattributes: Remove doc/misc/texinfo.tex special case,
which is no longer needed now that Gnulib trims blank-at-eol.
* build-aux/install-sh, doc/misc/texinfo.tex, lib/intprops.h:
* lib/regex_internal.c, lib/verify.h: Copy from Gnulib.
Paul Eggert [Sun, 1 Sep 2019 01:17:20 +0000 (18:17 -0700)]
Make user-emacs-directory a variable
This is in response to Eli’s review here:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00712.html
* lisp/subr.el (user-emacs-directory): defvar, not defconst
Paul Eggert [Sat, 31 Aug 2019 21:47:04 +0000 (14:47 -0700)]
Calculate user-emacs-directory on startup
Problem reported by Glenn Morris (Bug#583#56).
* lisp/startup.el (startup--xdg-config-default): New constant.
(startup--xdg-config-home-emacs): New var.
(startup--xdg-or-homedot): New function.
(normal-top-level): Use it to set user-emacs-directory early on.
(command-line): Also use it to determine the startup init directory.
* lisp/subr.el (user-emacs-directory): Just initialize to nil.
Paul Eggert [Sat, 31 Aug 2019 17:35:08 +0000 (10:35 -0700)]
Check instead of relying on NOTREACHED
NOTREACHED was designed for traditional lint decades ago,
and _Noreturn now normally subsumes its function.
In the one case in Emacs where NORETURN might help and _Noreturn does
not, check for NOTREACHED instead of assuming it.
* lib-src/etags.c (main):
* src/xterm.c (x_connection_closed):
Remove NOTREACHED after a call to a _Noreturn function, as NOTREACHED
is no longer needed there. Also, one of the NOTREACHEDs was
misplaced, which defeated traditional lint checking anyway.
* lib-src/pop.c (pop_getline): Redo so as to not need NOTREACHED.
* src/emacs.c (main): Use eassume (false) rather than NOTREACHED,
so that running with ENABLE_CHECKING catches any internal error
causing the toplevel Frecursive_edit to return.
Paul Eggert [Fri, 30 Aug 2019 07:24:07 +0000 (00:24 -0700)]
emacsclient: adjust to new config file location
* 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.
Paul Eggert [Fri, 30 Aug 2019 05:29:52 +0000 (22:29 -0700)]
Prefer ~/.config/emacs to ~/.emacs.d if neither exists
That way, when Emacs starts in a fresh home directory,
it prefers the new (XDG) convention rather than the old one.
* lisp/files.el (locate-user-emacs-file): Make the parent
directories of user-emacs-directory if needed. This is useful
if user-emacs-directory is "~/.config/emacs" and "~/.config"
does not yet exist.
* lisp/startup.el (command-line):
* lisp/subr.el (user-emacs-directory):
Prefer XDG_CONFIG_HOME to ~/.emacs.d if neither exists.
Paul Eggert [Wed, 28 Aug 2019 18:34:48 +0000 (11:34 -0700)]
Don't worry about pre-1.0.0 alsa-lib include
Problem reported by Ergus in:
https://lists.gnu.org/r/emacs-devel/2019-08/msg00563.html
* configure.ac (ALSA_SUBDIR_INCLUDE): Do not define.
* src/sound.c: Assume ALSA_SUBDIR_INCLUDE.
Paul Eggert [Tue, 27 Aug 2019 21:21:45 +0000 (14:21 -0700)]
Use XDG conventions more consistently
Fit in better with the XDG conventions.
Something like this was suggested in 2008 (Bug#583)
and the XDG conventions seem to have settled down by now.
* doc/emacs/custom.texi (Init File, Init Syntax, Find Init):
* doc/lispref/files.texi (Standard File Names):
* doc/lispref/os.texi (Init File):
* doc/misc/url.texi (Customization):
* etc/NEWS:
Adjust accordingly.
* lisp/startup.el (startup--load-user-init-file):
If init-file-name is nil, do not load from it; instead
just use the alt-file.
(find-init-path): Remove; no longer used.
(command-line): Don't check twice for XDG.
Look at XDG_CONFIG_HOME instead of assuming it's ~/.config.
Prefer XDG configuration if it exists; the user can disable
this by setting XDG_CONFIG_HOME to some other place.
* lisp/subr.el (user-emacs-directory):
Prefer XDG configuration if it exists.
Juri Linkov [Tue, 27 Aug 2019 20:48:57 +0000 (23:48 +0300)]
Browser-like Info-history button menu (bug#37184)
* doc/misc/info.texi (Help-Int): Using tool-bar to navigate history.
* lisp/info.el (Info-history-menu): New function.
(Info-history-back-menu, Info-history-forward-menu): New commands.
(Info-mode-map): Bind Info-history-back-menu and
Info-history-forward-menu to tool-bar on C-key.
Eli Zaretskii [Tue, 27 Aug 2019 15:47:24 +0000 (18:47 +0300)]
Fix crashes on MS-Windows when using GnuTLS connections
* src/gnutls.c (init_gnutls_functions) [WINDOWSNT]: Define and
load gnutls_free by an explicit call to GetProcAddress.
(gnutls_free) [WINDOWSNT]: Define as a macro that dereferences
a function pointer. (Bug#31946)
(Fgnutls_format_certificate): Use make_string_from_bytes
instead of going through an intermediate malloc'ed buffer.
Alex Branham [Thu, 15 Aug 2019 16:02:38 +0000 (11:02 -0500)]
Fix filename completion in shell mode buffers
* lisp/shell.el (shell-dynamic-complete-functions): Move
pcomplete-completions-at-point down the list so that filename
completion has a chance to complete before pcompletion.
Mauro Aranda [Tue, 27 Aug 2019 06:41:44 +0000 (08:41 +0200)]
Make link widgets obey mouse-1-click-follows-link
* lisp/wid-edit.el (widget-link-keymap): New variable, a keymap to use
inside a link widget.
('link widget): Restore the :follow-link property and add
widget-link-keymap as the :keymap property (bug#15682).
Mauro Aranda [Tue, 27 Aug 2019 06:40:32 +0000 (08:40 +0200)]
Adapt recentf.el to the change in the Widget Library
* lisp/recentf.el (recentf-open-files-item): Stop overriding
:follow-link property of the link widgets, since now it should
work as expected (bug#15682).
Paul Eggert [Tue, 27 Aug 2019 01:57:56 +0000 (18:57 -0700)]
Fix Tramp rounding of file sizes and inode numbers
* lisp/net/tramp-sh.el (tramp-perl-file-attributes)
(tramp-perl-directory-files-and-attributes)
(tramp-do-file-attributes-with-stat)
(tramp-do-directory-files-and-attributes-with-stat):
Format file sizes and inode numbers without trailing ".0",
to avoid rounding errors when absolute values exceed 2**53
(Bug#36940#94). This fixes the problem for Emacs 27 and later,
and doesn't hurt in earlier Emacs.
Eli Zaretskii [Mon, 26 Aug 2019 16:06:13 +0000 (19:06 +0300)]
Fix crashes in networking with GnuTLS on MS-Windows
* src/gnutls.c (init_gnutls_functions) [WINDOWSNT]: Define and
load gnutls_free.
(Fgnutls_format_certificate): Use gnutls_free instead of
xfree. This prevents crashes on MS-Windows, since the memory
being released was allocated inside GnuTLS. (Bug#31946)
Allow finding gpg2 binaries when gpg2 has an "unknown" version string
* lisp/epg-config.el (epg-find-configuration): Allow finding a
usable configuration even if the version string looks like "gpg
(GnuPG) 2.2.15-unknown" (bug#35629).
Teemu Likonen [Mon, 26 Aug 2019 05:52:54 +0000 (07:52 +0200)]
Only use --sender for gpg when gpg supports it
* lisp/epg-config.el (epg-required-version-p): New function (bug#37025).
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/epg.el (epg-start-sign):
(epg-start-encrypt): Use it to only use --sender when the gpg
binary supports it.
Paul Eggert [Sun, 25 Aug 2019 17:01:46 +0000 (10:01 -0700)]
Fix misdisplay of PNG paletted images
Problem reported by Roland Winkler (Bug#37153).
Derived from a patch suggested by YAMAMOTO Mitsuharu (Bug#37153#62).
* src/image.c (png_get_valid) [WINDOWSNT]:
Do not dynamically link this function.
(png_get_tRNS) [WINDOWSNT && PNG_tRNS_SUPPORTED]:
Dynamically link this function instead.
(png_load_body): Do not assume that every paletted image supplies
only transparency data. Fix typo in use of transparent_p.
Alan Mackenzie [Sun, 25 Aug 2019 10:21:37 +0000 (10:21 +0000)]
Introduce new value t for compilation-context-lines to eliminate scrolling
In particular, to prevent scrolling in a window lacking a left fringe.
Instead, a visible arrow "=>" is inserted before column zero. This fixes
bug #36832.
* lisp/progmodes/compile.el (compilation-context-lines): Add the new value t.
(compilation-set-window): Amend to handle compilation-context-lines being t.
(overlay-arrow-overlay): New variable holding an overlay with before-string
property "=>".
(compilation-set-overlay-arrow): New function which manipulates
overlay-arrow-overlay.
(compilation-goto-locus, compilation-find-file): In addition to calling
compilation-set-window, also call compilation-set-overlay-arrow.
* doc/emacs/building.texi (Compilation Mode): Document the new value t which
compilation-context-lines can take.
Eli Zaretskii [Sun, 25 Aug 2019 08:08:11 +0000 (11:08 +0300)]
Fix a recent change in coding.c
This partially reverts the changes in "extern function cleanup".
* src/coding.c (encode_string_utf_8, decode_string_utf_8): Now
extern again. They should NOT be static, as they are intended
to be used by the likes of json.c, where we need
highly-optimized code for processing UTF-8 strings. E.g.,
decode_string_utf_8 beats make_string_from_utf8 by a factor of
2 to 5 in a large number of scenarios.