Martin Rudalics [Mon, 10 Sep 2018 12:07:05 +0000 (14:07 +0200)]
Fix last change of 'run_window_size_change_functions'
* src/window.c (run_window_size_change_functions): Fix two
type mixups in last change. Reported by Michael Albinus
<michael.albinus@gmx.de> on emacs-devel.
* src/window.c (run_window_size_change_functions): Run a
buffer-local value once per each frame and only if at least
one window showing the buffer on that frame has changed its
size. (Bug#32637)
* doc/lispref/windows.texi (Window Hooks): Describe new
behavior of buffer-local 'window-size-change-functions'.
* doc/lispref/threads.texi (The Thread List): Cross-reference
'Basic Thread Functions'. Use defvar for thread-list-refresh-seconds.
Improve descriptions of the backtrace and signal commands.
Gemini Lasswell [Thu, 9 Aug 2018 21:21:57 +0000 (14:21 -0700)]
Show backtraces of threads from thread list buffer
* src/eval.c (backtrace_thread_p, backtrace_thread_top)
(backtrace_thread_next, Fbacktrace_frames_from_thread): New functions.
* lisp/thread.el (thread-list-mode-map): Add keybinding and
menu item for 'thread-list-pop-to-backtrace'.
(thread-list-mode): Make "Thread Name" column wide enough
for the result of printing a thread with no name with 'prin1'.
(thread-list--get-entries): Use 'thread-list--name'.
(thread-list--send-signal): Remove unnecessary calls to 'threadp'.
(thread-list-backtrace--thread): New variable.
(thread-list-pop-to-backtrace): New command.
(thread-list-backtrace--revert-hook-function)
(thread-list--make-backtrace-frame)
(thread-list-backtrace--insert-header, thread-list--name): New
functions.
Gemini Lasswell [Wed, 1 Aug 2018 16:25:28 +0000 (09:25 -0700)]
Improve docstrings of thread-list functions
* lisp/thread.el (thread-list--timer-func): Change
argument from 'buf' to 'buffer'.
(thread-list--get-entries, thread-list--get-status): Improve
docstring.
(thread-list--send-signal): Change argument from 'sgnl' to
'signal'. Tell the user when the thread is no longer alive.
Paul Eggert [Fri, 7 Sep 2018 16:17:25 +0000 (09:17 -0700)]
Fix overenthusiastic header size check
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00222.html
* doc/lispref/internals.texi (Garbage Collection):
Document vector sizes and slot counts more accurately.
* src/lisp.h: Omit header_size sanity check that was too picky.
Add some less-picky checks.
Eli Zaretskii [Fri, 7 Sep 2018 14:41:21 +0000 (17:41 +0300)]
Read Windows OS info for report-emacs-bug from Registry
* lisp/w32-fns.el (w32--os-description): New function.
* lisp/mail/emacsbug.el (report-emacs-bug--os-description):
Use 'w32--os-description' instead of launching the
'systeminfo' program, which can be very slow, and is also
missing on versions of Windows before XP Professional.
Paul Eggert [Fri, 7 Sep 2018 02:17:14 +0000 (19:17 -0700)]
Shrink pseudovectors a bit
sizeof (struct Lisp_Marker) was 32 on x86, where 24 would do.
Problem noted by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00165.html
* src/bignum.h (struct Lisp_Bignum):
* src/frame.h (struct frame):
* src/lisp.h (struct Lisp_Vector, struct Lisp_Bool_Vector)
(struct Lisp_Char_Table, struct Lisp_Hash_Table)
(struct Lisp_Marker, struct Lisp_Overlay)
(struct Lisp_Misc_Ptr, struct Lisp_User_Ptr)
(struct Lisp_Finalizer, struct Lisp_Float)
(struct Lisp_Module_Function):
* src/process.h (struct Lisp_Process):
* src/termhooks.h (struct terminal):
* src/thread.h (struct thread_state, struct Lisp_Mutex)
(struct Lisp_CondVar):
* src/window.c (struct save_window_data):
* src/window.h (struct window):
* src/xterm.h (struct scroll_bar):
* src/xwidget.h (struct xwidget, struct xwidget_view):
Add GCALIGNED_STRUCT attribute.
* src/lisp.h (GCALIGNED_UNION_MEMBER): Renamed from GCALIGNED_UNION.
All uses changed.
(GCALIGNED_STRUCT_MEMBER, GCALIGNED_STRUCT, GCALIGNED): New macros.
All uses of open-coded GCALIGNED changed to use GCALIGNED.
(union vectorlike_header): No longer GC-aligned.
(PSEUDOVECSIZE): Yield 0 for pseudovectors without Lisp
objects that place a member before where the first Lisp object
member would be.
Paul Eggert [Wed, 5 Sep 2018 23:19:47 +0000 (16:19 -0700)]
Fix timer.el minor rounding error
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Fix rounding error by using integers rather than floats.
* test/lisp/emacs-lisp/timer-tests.el (timer-test-multiple-of-time):
New test.
Stephen Gildea [Mon, 3 Sep 2018 00:06:29 +0000 (17:06 -0700)]
Do not call mh-next-msg from mh-junk-process-* fns
* mh-junk.el (mh-junk-process-blacklist, mh-junk-process-whitelist): Do
not call mh-next-msg. Now that these functions are called from
mh-execute-commands, they should not change the current message pointer.
The calls to mh-next-msg are probably left over from when blacklist and
whitelist message processing was done immediately.
Paul Eggert [Wed, 5 Sep 2018 07:21:02 +0000 (00:21 -0700)]
Improve (round FIXNUM FIXNUM) performance
* src/floatfns.c (rounding_driver):
New arg fixnum_divide. All callers changed.
(ceiling2, floor2, truncate2, round2): New functions.
Not that new, actually; these are essentially taken from Emacs 26.
(Fceiling, Ffloor, Fround, Ftruncate): Use them.
Paul Eggert [Wed, 5 Sep 2018 02:14:01 +0000 (19:14 -0700)]
Fix format-time-string bignum bug
The problem can occur on 32-bit platforms with current timestamps.
* src/editfns.c (disassemble_lisp_time, decode_time_components):
Support seconds counts that are bignums.
* test/src/editfns-tests.el (editfns-tests--have-leap-seconds):
New function.
(format-time-string-with-bignum-on-32-bit): New test.
* lisp/vc/vc-git.el (vc-git-grep-template): New variable, allows
changing the default arguments passed to git-grep when using
'vc-git-grep'.
* etc/NEWS: Mention 'vc-git-grep-template'. (Bug#32549)
Noam Postavsky [Fri, 10 Aug 2018 01:26:30 +0000 (21:26 -0400)]
Allow t as a catch-all condition-case handler (Bug#24618)
* src/eval.c (find_handler_clause): Accept a handler of t as always
matching.
(Fcondition_case):
* doc/lispref/control.texi (Handling Errors): Document this.
* etc/NEWS: Announce it.
Paul Eggert [Tue, 4 Sep 2018 18:49:41 +0000 (11:49 -0700)]
Fix (round FLOAT BIGNUM) bug
* src/floatfns.c (rounding_driver): Fix bug when one
argument is a float and the other is a bignum.
* test/src/floatfns-tests.el (bignum-round): Test for the bug.
Paul Eggert [Tue, 4 Sep 2018 17:24:51 +0000 (10:24 -0700)]
Tweak nthcdr for bignum efficiency
* src/fns.c (Fnthcdr): Use mpz_tdiv_ui and mpz_tdiv_r
instead of mpz_mod_ui and mpz_mod, as they are more efficient.
Suggested by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00073.html
Paul Eggert [Tue, 4 Sep 2018 16:30:57 +0000 (09:30 -0700)]
Fix bignum initialization
Problem reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00072.html
and crystal-ball diagnosis by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00075.html
* src/alloc.c (xrealloc_for_gmp, xfree_for_gmp): Move to bignum.c.
(init_alloc): Move bignum initialization to init_bignum.
* src/bignum.c (init_bignum): Rename from init_bignum_once.
All users changed.
* src/emacs.c (main): Call init_bignum after init_alloc,
instead of calling init_bignum_once after init_bignum.
Paul Eggert [Tue, 4 Sep 2018 01:37:40 +0000 (18:37 -0700)]
Speed up (+ 2 2) by a factor of 10
Improve arithmetic performance by avoiding bignums until needed.
Also, simplify bignum memory management, fixing some unlikely leaks.
This patch improved the performance of (+ 2 2) by a factor of ten
on a simple microbenchmark computing (+ x 2), byte-compiled,
with x a local variable initialized to 2 via means the byte
compiler could not predict: performance improved from 135 to 13 ns.
The platform was Fedora 28 x86-64, AMD Phenom II X4 910e.
Performance also improved 0.6% on ‘make compile-always’.
* src/bignum.c (init_bignum_once): New function.
* src/emacs.c (main): Use it.
* src/bignum.c (mpz): New global var.
(make_integer_mpz): Rename from make_integer. All uses changed.
* src/bignum.c (double_to_bignum, make_bignum_bits)
(make_bignum, make_bigint, make_biguint, make_integer_mpz):
* src/data.c (bignum_arith_driver, Frem, Flogcount, Fash)
(expt_integer, Fadd1, Fsub1, Flognot):
* src/floatfns.c (Fabs, rounding_driver, rounddiv_q):
* src/fns.c (Fnthcdr):
Use mpz rather than mpz_initting and mpz_clearing private
temporaries.
* src/bignum.h (bignum_integer): New function.
* src/data.c (Frem, Fmod, Fash, expt_integer):
* src/floatfns.c (rounding_driver):
Use it to simplify code.
* src/data.c (FIXNUMS_FIT_IN_LONG, free_mpz_value):
Remove. All uses removed.
(floating_point_op): New function.
(floatop_arith_driver): New function, with much of the guts
of the old float_arith_driver.
(float_arith_driver): Use it.
(floatop_arith_driver, arith_driver):
Simplify by assuming NARGS is at least 2.
All callers changed.
(float_arith_driver):
New arg, containing the partly converted value of the next arg.
Reorder args for consistency. All uses changed.
(bignum_arith_driver): New function.
(arith_driver): Use it. Do fixnum-only integer calculations
in intmax_t instead of mpz_t, when they fit.
Break out mpz_t calculations into bignum_arith_driver.
(Fquo): Use floatop_arith_driver instead of float_arith_driver,
since the op is known to be valid.
(Flogcount, Fash): Simplify by coalescing bignum and fixnum code.
(Fadd1, Fsub1): Simplify by using make_int.
Stephen Berman [Mon, 3 Sep 2018 20:40:24 +0000 (22:40 +0200)]
Make todo-show work when adding and deleting a new todo file
* lisp/calendar/todo-mode.el (todo-add-file): Since
todo-current-todo-file must be set before calling todo-show, but
the buffer is not yet in todo-mode, which makes it buffer local,
explicitly set it buffer locally (bug#32627).
* test/lisp/calendar/todo-mode-tests.el (todo-test--add-file)
(todo-test--delete-file): New functions.
(todo-test-add-and-delete-file): New test.
Paul Eggert [Fri, 31 Aug 2018 16:13:31 +0000 (09:13 -0700)]
Rename Emacs-specific INFINITY constants
Although these constants were not erroneous, as they were
used only in modules that did not include <math.h>, it's
less confusing to names that cannot be confused with
the now-standard INFINITY macro.
* src/dispextern.h (SCROLL_INFINITY): New constant.
* src/dispnew.c, src/scroll.c (INFINITY):
Remove. All uses replaced with SCROLL_INFINITY.
* src/process.c (wait_reading_process_output):
Rename private constant.
Paul Eggert [Fri, 31 Aug 2018 15:50:45 +0000 (08:50 -0700)]
Port better to non-IEEE platforms
* src/lread.c (string_to_number) [!IEEE_FLOATING_POINT]:
Do not use the INFINITY macro, since the C standard requires
it to provoke a compile-time error on platforms that do not
support infinities.
Michael Albinus [Fri, 31 Aug 2018 09:15:48 +0000 (11:15 +0200)]
Merge from origin/emacs-26
ac7936cb8f Rename thread-alive-p to thread-live-p 3d09d533d1 rcirc: Document /reconnect as a built-in command (Bug#29656) a1e615618d * test/lisp/calc/calc-tests.el (calc-imaginary-i): New test.
Michael Albinus [Fri, 31 Aug 2018 08:47:03 +0000 (10:47 +0200)]
Rename thread-alive-p to thread-live-p
* doc/lispref/threads.texi (Basic Thread Functions): Use thread-live-p.
* etc/NEWS: 'thread-alive-p' has been renamed to 'thread-live-p'.
* src/thread.c (thread_live_p): Rename from thread_alive_p. Adapt
all callees.
(Fthread_live_p): Rename from Fthread_alive_p.
(syms_of_threads): Make thread-alive-p an alias of thread-live-p.
* test/src/thread-tests.el (all): Replace `thread-alive-p' by
`thread-live-p'.
(threads-live): Rename from `threads-alive'.
Paul Eggert [Fri, 31 Aug 2018 07:25:07 +0000 (00:25 -0700)]
Several fixes for formatting bignums
* src/bignum.c: Include stdlib.h, for abs.
(bignum_bufsize, bignum_to_c_string): New functions.
* src/bignum.c (bignum_to_string):
* src/print.c (print_vectorlike): Use them.
* src/editfns.c (styled_format): Instead of having a separate
buffer for sprintf (which does not work for bignums), just append
to the main buffer. When formatting bignums, add support for the
standard integer flags -, #, 0, + and space. Fix some comments.
Capitalize properly when formatting bignums with %X. Use
functions like c_isdigit rather than reinventing the wheel.
Simplify computation of excess precision.
* src/print.c: Do not include bignum.h; no longer needed.
(print_vectorlike): Avoid recalculating string length.
* test/src/editfns-tests.el (format-bignum):
Test some of the above fixes.
Paul Eggert [Fri, 31 Aug 2018 01:10:18 +0000 (18:10 -0700)]
Fix bignum FIXME in emacs-module.c
* src/emacs-module.c: Do not include bignum.h; no longer needed.
(module_extract_integer): Use bignum_to_intmax to avoid
incorrectly signaling overflow on platforms where intmax_t
is wider than long int.
Paul Eggert [Thu, 30 Aug 2018 21:28:19 +0000 (14:28 -0700)]
Fix off-by-1 typo in recent bignum changes
Problem reported by Yuri D’Elia in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00977.html
and crucial clue provided by Michael Heerdegen in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg01043.html
* src/font.c (font_unparse_xlfd): Fix off-by-1 typo.
* src/thread.c: Include "keyboard.h".
(poll_suppress_count) Don't declare extern.
(Fthread_signal): Raise event if THREAD is the main thread. (Bug#32502)
* test/src/thread-tests.el (thread): Require it.
(threads-signal-main-thread): New test.
Paul Eggert [Thu, 30 Aug 2018 17:03:43 +0000 (10:03 -0700)]
Pacify -Wdouble-promotion in ImageMagick code
* src/image.c (imagemagick_load_image): Use double division, and
eliminate a cast. This avoids a -Wdouble-promotion warning with
GCC 7.3 on Ubuntu 18.04.
Miciah Masters [Mon, 11 Dec 2017 00:56:48 +0000 (19:56 -0500)]
rcirc: Document /reconnect as a built-in command (Bug#29656)
The change "New command rcirc-cmd-reconnect" from 2014-04-09 (shipped
in Emacs 25.1) added a /reconnect command to rcirc but did not
document it and did not delete the example /reconnect command
definition in the manual.
* doc/misc/rcirc.texi (rcirc commands): Document the built-in /reconnect
command.
(Hacking and Tweaking): Delete example reconnect command.
Stefan Monnier [Wed, 29 Aug 2018 14:43:41 +0000 (10:43 -0400)]
* src/keymap.c: Make better use of access_keymap's functionality
(Flookup_key): Allow `keymap' to be a list of keymaps.
(Fcommand_remapping, Fkey_binding): Simplify accordingly.
(shadow_lookup, describe_map_tree): Simplify.
* lisp/net/tramp-sh.el (tramp-convert-file-attributes):
Use `seconds-to-time' for {access, modification, status change}
time. Simplify check for inode.
* test/lisp/net/tramp-tests.el (tramp-test22-file-times):
Use `seconds-to-time'.
Paul Eggert [Tue, 28 Aug 2018 18:59:21 +0000 (11:59 -0700)]
Improve (format "%g" bignum) precision
* src/editfns.c (styled_format): When formatting bignums with
floating-point conversions like %g, use long double if that
would lose less information than double, which is what the
code was already doing for fixnums. On Fedora 28 x86-64, for
example, (format "%.100g" (1- (ash 1 64))) now yields
"18446744073709551615" instead of the numerically incorrect
"18446744073709549568". Also, fix a stray INTEGERP that
can just be FIXNUMP, since bignums are not possible there.
Noam Postavsky [Wed, 15 Aug 2018 03:26:50 +0000 (23:26 -0400)]
Fix math-imaginary-i check
Reported by Bastian Erdnüß at
<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00300.html>.
* lisp/calc/calc-cplx.el (math-imaginary-i): Check for a value
of (polar 1 <quarter-circle>).
Noam Postavsky [Thu, 15 Feb 2018 00:58:07 +0000 (19:58 -0500)]
; Let pre-commit git hook check merged in changes (Bug#29197)
* build-aux/git-hooks/pre-commit: If GIT_MERGE_CHECK_OTHER is 'true',
check changes against the merge target, rather than the current
branch. Include file name when giving error message about
non-standard characters.
Paul Eggert [Tue, 28 Aug 2018 04:27:50 +0000 (21:27 -0700)]
Modularize bignums better
* src/bignum.c, src/bignum.h: New files. Only modules that
need to know how bignums are implemented should include
bignum.h. Currently these are alloc.c, bignum.c (of course),
data.c, emacs.c, emacs-module.c, floatfns.c, fns.c, print.c.
* src/Makefile.in (base_obj): Add bignum.o.
* src/alloc.c (make_bignum_str): Move to bignum.c.
(make_number): Remove; replaced by bignum.c’s make_integer.
All callers changed.
* src/conf_post.h (ARG_NONNULL): New macro.
* src/json.c (json_to_lisp): Use it.
* src/data.c (Fnatnump):
Move NATNUMP’s implementation here from lisp.h.
* src/data.c (Fnumber_to_string):
* src/editfns.c (styled_format):
Move conversion of string to bignum to bignum_to_string, and
call it here.
* src/emacs-module.c (module_make_integer):
* src/floatfns.c (Fabs):
Simplify by using make_int.
* src/emacs.c: Include bignum.h, to expand its inline fns.
* src/floatfns.c (Ffloat): Simplify by using XFLOATINT.
(rounding_driver): Simplify by using double_to_bignum.
(rounddiv_q): Clarify use of temporaries.
* src/lisp.h: Move decls that need to know bignum internals to
bignum.h. Do not include gmp.h or mini-gmp.h; that is now
bignum.h’s job.
(GMP_NUM_BITS, struct Lisp_Bignum, XBIGNUM, mpz_set_intmax):
Move to bignum.h.
(make_int): New function.
(NATNUMP): Remove; all callers changed to use Fnatnump.
(XFLOATINT): If arg is a bignum, use bignum_to_double, so that
bignum internals are not exposed here.
* src/print.c (print_vectorlike): Use SAFE_ALLOCA to avoid the
need for a record_unwind_protect_ptr.
Alex Branham [Tue, 21 Aug 2018 15:21:39 +0000 (10:21 -0500)]
New commands bibtex-next/previous-entry (Bug#32378)
* lisp/textmodes/bibtex.el (bibtex-next-entry)
(bibtex-previous-entry): New commands.
(bibtex-mode-map): Bind to to forward-paragraph and
backward-paragraph. Add to menu under "Moving inside an Entry".
Alan Mackenzie [Mon, 27 Aug 2018 20:37:49 +0000 (20:37 +0000)]
CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont
This happened when the type of the previous function was a struct, etc.,
declaration.
* lisp/progmodes/cc-mode (c-guess-basic-syntax CASE 5N): Check here (for
'topmost-intro-cont) that the first opening brace after BOD is the opening
brace preceding the starting point.
Alan Mackenzie [Mon, 27 Aug 2018 19:49:25 +0000 (19:49 +0000)]
c-where-wrt-brace-construct: deal with point following a struct's semicolon.
More precisely, when point is right after the terminating semicolon of a
construct like "struct foo { .... } bar;", the function must return
'at-function-end.
* lisp/progmodes/cc-cmds.el (c-where-wrt-brace-construct): Surround an
existing test for 'at-function-end with an `or' form, the other arm testing
for being after the semicolon above.
Gemini Lasswell [Wed, 8 Aug 2018 02:39:06 +0000 (19:39 -0700)]
Fix links in backtraces to work on advised built-ins (Bug#25393)
* lisp/emacs-lisp/backtrace.el (backtrace--print-func-and-args): Make
links to the original definition of advised functions. Handle the
case when the function slot of the backtrace frame contains the
definition of a built-in function.
Glenn Morris [Sun, 26 Aug 2018 22:10:50 +0000 (15:10 -0700)]
Merge from origin/emacs-26
54fb383 (origin/emacs-26) Fix detection of freed emacs_values (Bug#32... 769d0cd ; Fix out-of-tree build for mod-test.so 9a1329e Avoid crashes with very wide TTY frames on MS-Windows 9a613d3 Prevent `modify-file-local-variable-prop-line' from adding ex... 624e7dc Update GNOME bugtracker URLs 51ef6d5 Clarify in the Emacs manual that ChangeLog files are not used 6e08019 Recognize codepage 65001 as a valid encoding 1a350d7 ; * etc/NEWS: Fix format of first lines of some entries. 22d1f53 Avoid compilation warning in nt/addpm.c 7bc9ce7 Fix duplicate custom group names in bibtex.el a9cf938 Fix outdated text in the Calc manual
Alan Mackenzie [Sun, 26 Aug 2018 11:05:22 +0000 (11:05 +0000)]
CC Mode: make c-display-defun-name work with a pointer return type.
Fixes bug #32403.
* lisp/progmodes/cc-cmds.el (c-in-function-trailer-p): No longer insist on
c-beginning-of-decl-1 returning 'same.
(c-where-wrt-brace-construct): Tighten up the test for looking at a symbol by
excluding keywords. When point is after a }, do not return 'at-function-end
for a struct/union/class/...
(c-defun-name-1): Considerably simplify, by amalgamating the two cond arms
which find structs etc., and by using functions like c-forward-declarator
rather than the faulty analysis of the source by hand.
Paul Eggert [Sun, 26 Aug 2018 02:03:26 +0000 (19:03 -0700)]
Improve format-seconds accuracy
* doc/lispref/os.texi (Time Parsing): It works with bignums.
* lisp/calendar/time-date.el (format-seconds):
Take the floor so that the resulting arithmetic is exact.
Sergey Vinokurov [Sun, 19 Aug 2018 20:31:01 +0000 (21:31 +0100)]
Fix detection of freed emacs_values (Bug#32479)
* src/emacs-module.c (module_free_global_ref): Compare a value to be
freed with all entries of the list.
* test/data/emacs-module/mod-test.c (Fmod_test_globref_free): New
function.
(emacs_module_init): Make it accessible from Lisp.
* test/src/emacs-module-tests.el (mod-test-globref-free-test): New
test which uses it.
Paul Eggert [Sat, 25 Aug 2018 20:39:18 +0000 (13:39 -0700)]
Improve performance of CONSP, FIXNUMP, etc.
Optimization opportunity noted by Pip Cet in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00828.html
On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e,
user+system time), this improved ‘make compile-always’
performance by 0.4% and shrank text size by a similar amount.
* src/lisp.h (TAGGEDP, lisp_h_TAGGEDP): New macros and function.
(lisp_h_CONSP, lisp_h_FLOATP, lisp_h_SYMBOLP)
(lisp_h_VECTORLIKEP, make_lisp_ptr, STRINGP): Use them.
(lisp_h_FIXNUMP): Use the same idea that lisp_h_TAGGEDP uses.