Martin Rudalics [Mon, 22 Jul 2019 07:19:18 +0000 (09:19 +0200)]
Handle persistence of windows' scroll bar and fringes settings (Bug#36193)
* doc/lispref/display.texi (Fringe Size/Pos): Document new
argument PERSISTENT of 'set-window-fringes'.
(Scroll Bars): Document new argument PERSISTENT of
'set-window-scroll-bars'. Mention that HORIZONTAL-TYPE must
be 'bottom' to show a horizontal scroll bar on mini windows.
* lisp/window.el (window-min-pixel-height): For mini windows the
minimum height is one line.
(window--min-size-1): Use value returned by
'window-min-pixel-height' when dealing with mini windows.
(window--resize-mini-window): Try to handle horizontal scroll
bars and size restrictions more accurately.
(window--state-put-2): Handle persistence of scroll bar
settings.
* src/frame.c (make_frame): Allow horizontal scroll bars in
mini windows.
(adjust_frame_size): Drop PIXELWISE argument in
'resize_frame_windows' calls.
* src/window.c (set_window_buffer): Don't override WINDOW's
scroll bar and fringe settings when marked as persistent.
(resize_frame_windows): Drop fourth argument PIXELWISE - SIZE
is always specified in terms of pixels. Try to handle height
of mini windows more accurately.
(grow_mini_window, shrink_mini_window): Use body height of
mini window when calculating expected height change. Take
horizontal scroll bars into account.
(struct saved_window): Two new members to handle persistence
of window fringes and scroll bars.
(Fset_window_configuration, save_window_save): Handle
persistence of fringes and scroll bars.
(set_window_fringes, set_window_scroll_bars): New arguments
PERSISTENT. Make dimension checks more accurate.
(Fset_window_fringes): New argument PERSISTENT.
(Fwindow_fringes, Fwindow_scroll_bars): Add PERSISTENT to
return values.
(Fset_window_scroll_bars): New argument PERSISTENT. In
doc-string mention that 'bottom' must be specified to get a
horizontal scroll bar in mini windows.
(compare_window_configurations): Add checks for persistence of
fringes and scroll bars.
* src/window.h (struct window): New boolean slots
'fringes_persistent' and 'scroll_bars_persistent'.
(WINDOW_HAS_HORIZONTAL_SCROLL_BAR): Allow horizontal scroll bars
for mini windows.
(resize_frame_windows): Remove fourth argument of
'resize_frame_windows' in external declaration.
* src/xdisp.c (resize_mini_window): Use box text height to
tell whether mini window height changed.
(set_horizontal_scroll_bar): Set mini window's horizontal
scroll bar when its type is specified as 'bottom'.
* etc/NEWS: Mention new options for 'set-window-fringes' and
'set-window-scroll-bars'.
Alan Mackenzie [Sun, 21 Jul 2019 21:08:03 +0000 (21:08 +0000)]
Implement C++ Mode attributes. This fixes bug #36650.
* lisp/progmodes/cc-engine.el (c-looking-at-c++-attribute)
(c-enclosing-c++-attribute, c-slow-enclosing-c++-attribute): New macro and
functions.
(c-crosses-statement-barrier-p): Add [ into skip-chars for C++ Mode, and use
it to detect and skip over an attribute whilst scanning forward.
(c-sws-lit-type): Use the new value 'attribute.
(c-invalidate-sws-region-before): Put a save-match-data around this function.
Detect and handle an enclosing attribute at either END or BEG.
(c-invalidate-sws-region-after): Handle C++ attributes.
(c-forward-sws, c-backward-sws): Handle C++ attributes.
* lisp/progmodes/cc-mode.el (c-fl-decl-end): Detect and handle point being
inside a C++ attribute.
Paul Eggert [Sun, 21 Jul 2019 19:31:51 +0000 (12:31 -0700)]
Fix lifetime error in previous patch
Problem reported by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00520.html
* src/alloc.c (inhibit_garbage_collection): Use new function.
(allow_garbage_collection): Accept intmax_t, not pointer.
* src/eval.c (default_toplevel_binding, do_one_unbind)
(backtrace_eval_unrewind, Fbacktrace__locals, mark_specpdl):
Support SPECPDL_UNWIND_INTMAX.
(record_unwind_protect_excursion): New function.
* src/lisp.h (enum specbind_tag): New constant SPECPDL_UNWIND_INTMAX.
(union specbinding): New member unwind_intmax.
Paul Eggert [Sun, 21 Jul 2019 18:20:07 +0000 (11:20 -0700)]
Speed up maybe_gc when GC is inhibited
* src/alloc.c (allow_garbage_collection)
(inhibit_garbage_collection): Temporarily bump
consing_until_gc, to improve performance of maybe_gc while
garbage collection is inhibited. Suggested by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00511.html
Paul Eggert [Sun, 21 Jul 2019 18:20:07 +0000 (11:20 -0700)]
Avoid integer overflow in hash table size
* src/fns.c (INDEX_SIZE_BOUND): Use a tighter bound.
(maybe_resize_hash_table): Avoid integer overflow when
checking for hash table size overflow. Fix confusion
between INDEX_SIZE_BOUND (which is for the index vector)
and hash table size. Fix typo in debugging message
when ENABLE_CHECKING.
Paul Eggert [Sun, 21 Jul 2019 18:20:07 +0000 (11:20 -0700)]
Improve doc for hash tables
* doc/lispref/hash.texi (Creating Hash, Defining Hash):
* src/fns.c (Fsxhash_eq, Fsxhash_eql, Fsxhash_equal):
Say that hashes are fixnums.
(Fmake_hash_table): Say that that an integer rehash-size
should be a fixnum.
* doc/lispref/hash.texi (Defining Hash): Say that hash and
comparison functions should be consistent and pure, and should
return quickly.
Paul Eggert [Sun, 21 Jul 2019 18:20:07 +0000 (11:20 -0700)]
pure_alloc returns cleared memory
* src/alloc.c (pure_alloc): Clear any heap-allocated storage.
This is simpler than auditing all the callers to make sure
they don’t assume pure memory is cleared memory, and the
performance implication is nonexistent except when Emacs
is misconfigured. Also, add an assertion to catch
caller misuse when pure space is exhausted.
Ken Brown [Mon, 15 Jul 2019 13:32:49 +0000 (09:32 -0400)]
Fix expand-file-name for names starting with '~'
* src/fileio.c: (file_name_absolute_no_tilde_p):
New static function.
(Fexpand_file_name): If the current buffer's default-directory
starts with "~user" where "user" is not a valid user name, don't
give the '~' a special meaning. Just treat the value of
default-directory as a relative name. (Bug#36502)
* test/src/fileio-tests.el
(fileio-tests--relative-default-directory): Add a test.
Paul Eggert [Sun, 21 Jul 2019 06:21:14 +0000 (23:21 -0700)]
Tweak recent hash-table fix
* src/fns.c (maybe_resize_hash_table): Completely initialize the
new ‘next’ vector before allocating more vectors, as this
preserves locality a bit better and it’s safer not to leave an
uninitialized Lisp object around. Use next_size instead of
new_size to compute new index size.
Paul Eggert [Sun, 21 Jul 2019 02:40:03 +0000 (19:40 -0700)]
Fix crash if user test munges hash table
* src/fns.c (restore_mutability)
(hash_table_user_defined_call): New functions.
(cmpfn_user_defined, hashfn_user_defined): Use them.
(make_hash_table, copy_hash_table):
Mark new hash table as mutable.
(check_mutable_hash_table): New function.
(Fclrhash, Fputhash, Fremhash): Use it instead of CHECK_IMPURE.
* src/lisp.h (struct hash_table_test): User-defined functions
now take pointers to struct Lisp_Hash_Table, not to struct
hash_table_test. All uses changed.
(struct Lisp_Hash_Table): New member ‘mutable’.
* src/pdumper.c (dump_hash_table): Copy it.
* test/src/fns-tests.el (test-hash-function-that-mutates-hash-table):
New test, which tests for the bug.
Paul Eggert [Sun, 21 Jul 2019 02:40:03 +0000 (19:40 -0700)]
Simplify hashfn/cmpfn calling convention
* src/fns.c (cmpfn_eql, cmpfn_equal, cmpfn_user_defined)
(hashfn_eq, hashfn_equal, hashfn_eql, hashfn_user_defined):
* src/profiler.c (cmpfn_profiler, hashfn_profiler):
Use new calling convention where the return value is a fixnum
instead of EMACS_UINT. While we’re at it, put the hash table
at the end, since that’s a bit simpler and generates better
code (at least on the x86-64). All callers changed.
* src/fns.c (hash_lookup): Store fixnum rather than EMACS_UINT.
All callers changed.
(hash_put): Take a fixnum rather than an EMACS_UINT.
All callers changed. Remove unnecessary eassert (XUFIXNUM does it).
* src/lisp.h (struct hash_table_test):
Adjust signatures of cmpfn and hashfn.
Paul Eggert [Sun, 21 Jul 2019 02:40:03 +0000 (19:40 -0700)]
Inhibit GC after inhibit_garbage_collection
Without this patch, there are unlikely ways that garbage
collection could occur (sometimes causing undefined behavior)
even when inhibit_garbage_collection is in effect.
* src/alloc.c (garbage_collection_inhibited): New var.
(pure_alloc): Increment it if pure space is exhausted, so that
garbage_collect_1 no longer needs to inspect
pure_bytes_used_before_overflow.
(allow_garbage_collection): New function.
(inhibit_garbage_collection): Increment the new variable rather
than specbinding a user variable.
(garbage_collect_1): Do not garbage collect if the new variable
is set, rather than if pure_bytes_used_before_overflow is set.
Paul Eggert [Sun, 21 Jul 2019 02:40:03 +0000 (19:40 -0700)]
Simplify maybe_gc implementation
* src/alloc.c (consing_until_gc): New variable, replacing the
combination of consing_since_gc and gc_relative_threshold.
All uses changed.
(byte_ct): Move decl here from lisp.h.
(memory_full_cons_threshold): New an enum constant.
(free_cons): Check for integer overflow in
statistics calculation.
* src/lisp.h (object_ct): Move decl here from alloc.c.
(OBJECT_CT_MAX): New macro.
(maybe_gc): Simplify accordingly.
Paul Eggert [Sun, 21 Jul 2019 02:40:03 +0000 (19:40 -0700)]
Rename ‘pure’ to ‘purecopy’
* src/lisp.h (struct Lisp_Hash_Table): Rename ‘pure’ member to
‘purecopy’, as the old name was quite confusing (it did not
mean the hash table was pure). All uses changed.
Paul Eggert [Sun, 21 Jul 2019 02:40:02 +0000 (19:40 -0700)]
Fix hash table overallocation etc.
* src/fns.c (set_hash_key_and_value, set_hash_next)
(set_hash_hash, set_hash_index): Remove. All uses removed.
(maybe_resize_hash_table): Don’t update h->next until it’s
known that all the allocations succeeded, to avoid trashing
the hash table if memory is exhausted. Don’t overallocate the
other vectors. Don’t output growth message if the hash table
didn’t actually grow due to allocation failure. Assume C99
decls after statements.
Handle completely undecoded input in term (Bug#29918)
* lisp/term.el (term-emulate-terminal): Avoid errors if the whole
decoded string is eight-bit characters. Don't attempt to save the
string for next iteration in that case.
* test/lisp/term-tests.el (term-decode-partial)
(term-undecodable-input): New tests.
* lisp/image.el (image-rotate): Extend with an optional argument
specifying the rotation in degrees (bug#35421).
* doc/lispref/display.texi (Showing Images):
* etc/NEWS: Document the change.
* test/lisp/image-tests.el (image-rotate): New test.
Adam Sjøgren [Sat, 20 Jul 2019 13:02:22 +0000 (15:02 +0200)]
Enable showing local time and lapsed time in Gnus
* lisp/gnus/gnus-art.el (article-make-date-combine-with-lapsed) factor
code out into new function, used for providing both combined-lapsed
and combined-local-lapsed.
Make REs in magic-(fallback-)mode-alist case-sensitive.
These variables are used for well-defined file formats where relaxed
case matching is not wanted usually.
* lisp/files.el (magic-mode-alist, magic-fallback-mode-alist): Update
the doc string.
(set-auto-mode): Make looking-at for elements of magic-mode-alist and
magic-fallback-mode-alist use case-fold-search == nil.
* lisp/files.el (files-test-magic-mode-alist-re-baseline)
(files-test-magic-mode-alist-re-no-match)
(files-test-magic-mode-alist-re-case-diff): Add.
Stefan Kangas [Thu, 11 Jul 2019 22:43:12 +0000 (00:43 +0200)]
Make finder-exit use quit-window (Bug#33610)
* lisp/finder.el (finder-exit): Quit window instead of
deleting. This restores previous contents of the window,
if any, that was usurped by "C-h p" to show the list of
packages.
* lisp/progmodes/octave.el (octave-eldoc-function): The
test of position of the opening parenthesis in
inferior-octave-process was duplicated. Remove one of
the tests. (Bug#36557)
Martin Rudalics [Fri, 19 Jul 2019 08:08:08 +0000 (10:08 +0200)]
Have 'display-buffer-reuse-window' prefer window on selected frame (Bug#36680)
* lisp/window.el (display-buffer-reuse-window): Preferably reuse
window on selected frame (Bug#36680).
* doc/lispref/windows.texi (Buffer Display Action Functions): Say
that 'display-buffer-reuse-window' prefers window on the selected
frame.
* lisp/progmodes/elisp-mode.el (emacs-lisp-set-electric-text-pairs):
New function.
(emacs-lisp-mode): Add it to electric-pair-mode-hook, if elec-pair
hasn't been loaded yet.
Sam Steingold [Tue, 16 Jul 2019 21:23:27 +0000 (17:23 -0400)]
Treat the "Link" link in gnus-summary-browse-urls specially
* lisp/gnus/gnus-sum.el (gnus-collect-urls): Make sure that
the URL labeled "Link" is the first in the return list.
(gnus-summary-browse-url): Use the 1st URL as the default.
* lisp/wid-edit.el (widget-text): New function.
* lisp/progmodes/cc-engine.el (c-semi-pp-to-literal): User
c-with-extended-string-fences around a parse-partial-sexp.
(c-full-get-near-cache-entry): Fix an off-by-one error.
(c-full-pp-to-literal): Avoid writing duplicate entries into a cache.
(c-after-change-unmark-raw-strings): Use c-clear-syn-tab-properties.
* lisp/progmodes/cc-mode.el (c-leave-cc-mode-mode): Clear the c-fl-syn-tab
properties, too.
(c-basic-common-init): Mark c-fl-syn-tab as a non-sticky text property.
(c-depropertize-new-text): Also handle c-fl-syn-tab.
(c-multiline-string-check-final-quote, c-parse-quotes-after-change): Use
c-is-escaped.
(c-fl-syn-tab-region): New variable.
(c-clear-string-fences, c-restore-string-fences, c-remove-string-fences): New
functions.
(c-before-change-check-unbalanced-strings)
(c-after-change-mark-abnormal-strings, c-after-change-escape-NL-in-string):
Use the new functions and macros.
(c-before-change, c-after-change, c-font-lock-fontify-region): Restore the
syntax-table text properties from c-fl-syn-tab text properties for these
functions.
(c-electric-pair-inhibit-predicate): Test the c-fl-syn-tab property rather
than syntax-table.
* test/lisp/net/secrets-tests.el: Use lexical-binding.
(secrets-test03-items): Do not assume :xdg:schema attribute is
silently added to the front of the collection (bug#36694).
(secrets-test04-search, secrets-test-all): Quote function symbols as
such.
Fix calc number formatting with digit grouping (bug#36689)
The functions math-format-hex and math-format-octal were not
implemented, yet called, leading to a crash when using hex or octal
radix with digit grouping.
* lisp/emacs-lisp/ert.el (ert-results-mode): Set revert-buffer-function
to re-run the same test selection. It is a good fit and permits use of
the standard "g" key binding.
Stephen Berman [Tue, 16 Jul 2019 09:04:56 +0000 (11:04 +0200)]
Prevent infinite loop on entering wdired-mode
* lisp/wdired.el (wdired-preprocess-symlinks): Remove unneeded use
of beginning-of-line, which also triggers an infinite loop in a
find-dired buffer that doesn't end with a newline (see discussion
in bug#35609).
Stefan Monnier [Mon, 15 Jul 2019 19:28:07 +0000 (15:28 -0400)]
* lisp/gnus/nntp.el: Use lexical-binding
(nntp-server-action-alist): Expose the code to the compiler.
(nntp-with-open-group-function): No need to obfuscate identifiers any more.
(nntp-authinfo-rejected): Use `define-error`.
Fix INITIAL-INPUT cons handling in ido-read-internal
* lisp/ido.el (ido-read-internal): Is INITIAL-INPUT is a cons that
specifies cursor position, adjust the number to be palatable for
`read-for-minibuffer' (bug#27807).
Fix saving certificates in the NSM on high security levels
* lisp/net/nsm.el (nsm-check-certificate): `nsm-fingerprint-ok-p'
will save the fingerprint in the correct temporary/permanent
storage, so saving it once more (in the permanent storage) if the
security level is high or greater is a mistake (bug#27823).
Michael Albinus [Mon, 15 Jul 2019 09:11:59 +0000 (11:11 +0200)]
Fix edge cases in Tramp's copy
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):
Special handling for "rsync".
(tramp-find-inline-compress): Make check more robust on MS Windows.
* lisp/ffap.el (ffap-prompter, ffap-other-window)
(ffap-other-frame, ffap-read-only)
(ffap-read-only-other-window, ffap-read-only-other-frame)
(ffap-alternate-file, ffap-alternate-file-other-window)
(ffap-literally): Rework to be able to specify different prompts
for different actions (bug#30284) and don't use
`call-interactively' all over the place.