Vincent Belaïche [Mon, 17 Jul 2017 17:58:12 +0000 (19:58 +0200)]
Fix symbol completion and document it.
* doc/misc/ses.texi (Configuring what printer function
applies): Add description of keys for completing local printer
symbols and listing local printers in a help buffer.
(Formulas): Add decription for key to list the named cell
symbols in a help buffer.
* lisp/ses.el (ses-completion-keys): New constant.
(ses--completion-table): New defvar.
(ses--list-orig-buffer): New defvar.
(ses-mode-edit-map): Fixed for symbol completion, plus add
help functions to list named cells or local printers.
(ses-edit-cell-complete-symbol)
(ses--edit-cell-completion-at-point-function): New defuns for
completion during formula edition.
(ses-edit-cell): Redefine dynamically edit keymap for
completion keys to point at the right function.
(ses-read-printer-complete-symbol)
(ses--read-printer-completion-at-point-function): New defuns
for completion during printer edition.
(ses-read-printer): Redefine dynamically edit keymap for
completion keys to point at the right function.
(ses-list-local-printers): New defun.
(ses-list-named-cells): New defun.
* src/gtkutil.c (xg_get_gdk_scale): Remove.
(xg_get_default_scrollbar_height)
(xg_get_default_scrollbar_width): Pass in a frame to check for
scaling.
(xg_frame_set_char_size): Use the API for querying scale
instead of looking at the GDK_SCALE variable.
(xg_get_default_scrollbar_width): Ditto.
(xg_get_default_scrollbar_height): Ditto.
(xg_update_scrollbar_pos): Ditto.
* src/xfns.c (x_set_scroll_bar_default_height): Pass in the
frame to get the width.
Eli Zaretskii [Mon, 17 Jul 2017 14:50:37 +0000 (17:50 +0300)]
Allow user control on what starts and ends a paragraph for bidi
* src/buffer.h (struct buffer): New members
bidi_paragraph_separate_re_ and bidi_paragraph_start_re_.
* src/buffer.c (bset_bidi_paragraph_start_re)
(bset_bidi_paragraph_separate_re): New setters/
(Fbuffer_swap_text): Swap the values of bidi-paragraph-start-re and
bidi-paragraph-separate-re.
(init_buffer_once): Init the values of bidi-paragraph-start-re and
bidi-paragraph-separate-re.
(syms_of_buffer) <bidi-paragraph-start-re, bidi-paragraph-separate-re>:
New per-buffer variables.
* src/bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start):
Support bidi-paragraph-start-re and bidi-paragraph-separate-re.
(bidi_move_to_visually_next): Handle correctly the case when the
separator matches an empty string. (Bug#27526)
If TESTFN is non-nil, then it is the predicate to lookup
the alist. Otherwise, use 'eq' (Bug#27584).
* lisp/subr.el (alist-get): Add optional arg FULL.
* lisp/emacs-lisp/map.el (map-elt, map-put): Add optional arg TESTFN.
* lisp/emacs-lisp/gv.el (alist-get): Update expander.
* doc/lispref/lists.texi (Association Lists): Update manual.
* etc/NEWS: Announce the changes.
* test/lisp/emacs-lisp/map-tests.el (test-map-put-testfn-alist)
(test-map-elt-testfn): New tests.
Michael Albinus [Mon, 17 Jul 2017 12:12:20 +0000 (14:12 +0200)]
Fix `tramp-test39-unload'
* test/lisp/net/tramp-tests.el (tramp--test-instrument-test-case-p)
(tramp--test-instrument-test-case): Rename. Adapt all callees.
(tramp-test36-asynchronous-requests): Bind `timer-max-repeats'.
(tramp-test39-unload): Expect it to pass. Ignore buffer-local
variables and autoload functions; they are not removed. Check
also for `-function(s)'.
Stephen Berman [Mon, 17 Jul 2017 09:09:07 +0000 (11:09 +0200)]
Preserve point under 'dired-auto-revert-buffer' (second case)
* lisp/dired.el (dired): Use pop-to-buffer-same-window instead
of switch-to-buffer. This preserves Dired window point when
dired-auto-revert-buffer is non-nil. (Bug#27243)
* test/lisp/dired-tests.el (dired-test-bug27243): New test.
Paul Eggert [Sun, 16 Jul 2017 23:22:33 +0000 (16:22 -0700)]
Use explicit_bzero to clear GnuTLS keys
* admin/merge-gnulib (GNULIB_MODULES): Add explicit_bzero.
* lib/explicit_bzero.c, m4/explicit_bzero.m4: New files.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* src/gnutls.c (clear_storage): New function.
(gnutls_symmetric_aead): Use it instead of memset.
Paul Eggert [Sun, 16 Jul 2017 23:22:33 +0000 (16:22 -0700)]
Merge from gnulib
This incorporates:
2017-07-16 explicit_bzero: new module
2017-07-15 getdtablesize: Add minimal support for OpenVMS.
* lib/getdtablesize.c, lib/string.in.h, m4/getdtablesize.m4:
* m4/string_h.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
Fix test when running from test/lisp/subr-tests.elc
* test/lisp/subr-tests.el (subr-test-backtrace-simple-tests): Don't
assume a lambda expression will be `equal' to its quoted form. That's
not true if the lambda expression has been compiled.
* lisp/ls-lisp.el (ls-lisp-filesize-d-fmt, ls-lisp-filesize-f-fmt)
(ls-lisp-filesize-b-fmt): Add space in front (Bug#27693).
* test/lisp/dired-tests.el (dired-test-bug27693): Add test.
Eli Zaretskii [Sat, 15 Jul 2017 13:54:12 +0000 (16:54 +0300)]
Avoid link errors with older versions of GnuTLS
* src/gnutls.c (Fgnutls_ciphers, gnutls_symmetric_aead)
(Fgnutls_macs, Fgnutls_digests): Conditionally compile code that
calls GnuTLS functions which might be unavailable in older
versions of GnuTLS.
Eli Zaretskii [Sat, 15 Jul 2017 11:03:44 +0000 (14:03 +0300)]
Fix compilation of gnutls.c with older GnuTLS
* src/gnutrls.c (syms_of_gnutls): Condition some defsubr's
on HAVE_GNUTLS3, to avoid compilation errors when GnuTLS
v3.X is not available. Reported by Colin Baxter <m43cap@yandex.com>.
Paul Eggert [Fri, 14 Jul 2017 23:18:37 +0000 (16:18 -0700)]
GnuTLS integer-overflow and style fixes
This tweaks the recently-added GnuTLS improvements so that
they avoid some integer-overflow problems and follow typical
Emacs style a bit better.
* configure.ac (HAVE_GNUTLS3_HMAC, HAVE_GNUTLS3_AEAD)
(HAVE_GNUTLS3_CIPHER): Use AC_CACHE_CHECK so that the
configure-time results are displayed.
* src/fns.c (extract_data_from_object): Return char *, not char
const *, since one gnutls caller wants a non-const pointer. Use
CONSP rather than !NILP when testing for conses. Use CAR_SAFE
instead of rolling our own code. Prefer signed types to unsigned
when either will do. Report problems for lengths out of range,
instead of silently mishandling them.
* src/gnutls.c (emacs_gnutls_strerror): New function, to simplify
callers. All callers of gnutls_sterror changed.
(Fgnutls_boot): Check for integers out of range rather than
silently truncating them.
(gnutls_symmetric_aead): Check for integer overflow in size
calculations.
(gnutls_symmetric_aead, Fgnutls_macs, Fgnutls_digests):
Prefer signed to unsigned integers where either will do.
(gnutls_symmetric_aead, gnutls_symmetric):
Work even if ptrdiff_t is wider than ‘long’.
(gnutls_symmetric, Fgnutls_hash_mac, Fgnutls_hash_digest):
Check for integer overflow in algorithm selection.
Eli Zaretskii [Fri, 14 Jul 2017 19:00:55 +0000 (22:00 +0300)]
Fix the MS-Windows build due to added GnuTLS functions
* src/gnutls.c [WINDOWSNT]: Add DEF_DLL_FN for new functions.
(init_gnutls_functions) [WINDOWSNT]: Add LOAD_DLL_FN for new
functions. Add #define redirections for new functions.
(gnutls_symmetric_aead): Fix format specs to be more portable when
printing ptrdiff_t arguments.
* src/fns.c (gnutls_rnd) [WINDOWSNT]: Redirect to w32_gnutls_rnd
wrapper.
* src/gnutls.h [WINDOWSNT]: Add prototype for w32_gnutls_rnd.
* test/lisp/net/gnutls-tests.el (gnutls-tests-tested-macs)
(gnutls-tests-tested-digests, gnutls-tests-tested-ciphers): Call
gnutls-available-p, otherwise GnuTLS functions might not be loaded
from the DLL on MS-Windows.
Stefan Monnier [Fri, 14 Jul 2017 15:27:21 +0000 (11:27 -0400)]
* lisp/emacs-lisp/bytecomp.el: Fix bug#14860.
* lisp/emacs-lisp/bytecomp.el (byte-compile--function-signature): New fun.
Dig into advice wrappers to find the "real" signature.
(byte-compile-callargs-warn, byte-compile-arglist-warn): Use it.
(byte-compile-arglist-signature): Don't bother with "new-style" arglists,
since bytecode functions are now handled in byte-compile--function-signature.
* lisp/files.el (create-file-buffer, insert-directory):
Remove workaround introduced for (bug#14860).
* lisp/help-fns.el (help-fns--analyse-function): `nadvice` is preloaded.
* lisp/help.el (help-function-arglist):
Dig into advice wrappers to find the "real" signature.
* src/fns.c (Fsecure_hash_algorithms): Add function to list
supported `secure-hash' algorithms.
(extract_data_from_object): Add data extraction function that
can operate on buffers and strings.
(secure_hash): Use it.
(Fsecure_hash): Mention `secure-hash-algorithms'.
Paul Eggert [Fri, 14 Jul 2017 11:54:05 +0000 (04:54 -0700)]
Improve stack-overflow heuristic on GNU/Linux
Problem reported by Steve Kemp (Bug#27585).
* src/eval.c (near_C_stack_top): Remove. All uses replaced
by current_thread->stack_top.
(record_in_backtrace): Set current_thread->stack_top.
This is for when the Lisp interpreter calls itself.
* src/lread.c (read1): Set current_thread->stack_top.
This is for recursive s-expression reads.
* src/print.c (print_object): Set current_thread->stack_top.
This is for recursive s-expression printing.
* src/thread.c (mark_one_thread): Get stack top first.
* src/thread.h (struct thread_state.stack_top): Now void *, not char *.
Eli Zaretskii [Fri, 14 Jul 2017 07:53:36 +0000 (10:53 +0300)]
Prevent display corruption when display-line-numbers is set
* src/xdisp.c (try_window_reusing_current_matrix): If giving up
due to display-line-numbers, clear the window's desired glyph
matrix before returning, as the following call to try_window will
call display_line, which expects rows of the desired matrix
cleared. (Bug#27668)
Eli Zaretskii [Fri, 14 Jul 2017 06:24:44 +0000 (09:24 +0300)]
Revert "Use fixed-pitch font for display-line-numbers"
This reverts commit d014a5e15c1110af77e7a96f06ccd0f0cafb099f.
* lisp/faces.el (line-number): Don't use a fixed-pitch font, by
popular demand. For relevant discussions, see
Paul Eggert [Fri, 14 Jul 2017 02:24:06 +0000 (19:24 -0700)]
Merge from gnulib
This incorporates:
2017-07-13 Improve cross-compilation guesses for native Windows
2017-07-11 More systematic m4 quoting and indentation
2017-07-10 Make sure $host and $host_os are defined when used
2017-07-03 stdioext: Port to OpenVMS
2017-06-24 xalloc-oversized: port to icc
* doc/misc/texinfo.tex, lib/fpending.c, lib/stdio-impl.h:
* lib/xalloc-oversized.h, m4/dirfd.m4, m4/gettimeofday.m4:
* m4/lstat.m4, m4/mktime.m4, m4/pselect.m4, m4/putenv.m4:
* m4/stdint.m4, m4/strtoimax.m4, m4/utimes.m4:
Copy from Gnulib.
Alan Mackenzie [Thu, 13 Jul 2017 19:56:00 +0000 (19:56 +0000)]
C++ Mode. Fix anomaly occurring when a ">" is deleted then reinserted.
This fontification anomaly happened because after deleting the ">",
c-forward-<>-arglist parses the preceding identifier as a putative type but
stores it in c-found-types before it becomes clear it is not an unambiguous
type. c-forward-<>-arglist fails, leaving the spurious type id in
c-found-types. Fix this by "binding" c-found-types "to itself" in
c-forward-<>-arglist, and restoring the original value when that function call
fails.
* lisp/progmodes/cc-engine.el (c-copy-found-types): New function.
(c-forward-<>-arglist): Record the original value of c-found-types at the
beginning of the function, and restore it at the end on failure.
* lisp/progmodes/cc-mode.el (c-unfind-coalesced-tokens): Rewrite more
accurately.
Vincent Belaïche [Thu, 13 Jul 2017 18:58:22 +0000 (20:58 +0200)]
Add tests for SES, and fix one more cell renaming bug.
* lisp/ses.el (ses-relocate-all): In case of insertion, do not
relocate value for named cells as they keep the same symbol.
(ses-rename-cell): Set new cell name symbol to cell value --- do not
rely on recalculating. Push cells with updated data --- cell name,
cell reference list, or cell formula --- to deferred write list.
* test/lisp/ses-tests.el: New file, with 7 tests for SES.
Alan Mackenzie [Wed, 12 Jul 2017 17:03:35 +0000 (17:03 +0000)]
CC Mode: create and use c-set-keymap-parent.
* lisp/progmodes/cc-defs.el (c-set-keymap-parent): New macro.
* lisp/progmodes/cc-mode.el (top-level): Remove cc-bytecomp-defun for
set-keymap-parents.
(c-make-inherited-keymap): Use c-set-keymap-parent in place of inline code.
Eli Zaretskii [Tue, 11 Jul 2017 15:16:36 +0000 (18:16 +0300)]
Use fixed-pitch font for display-line-numbers
* lisp/faces.el (line-number): Use a fixed-pitch font by default,
even if the default face uses a variable-pitch font. Reported by
James Cloos <cloos@jhcloos.com>.
* test/src/emacs-module-tests.el
(module--test-assertions--load-non-live-object)
(module--test-assertions--call-emacs-from-gc):
Avoid test failures due to backtraces.
Paul Eggert [Sun, 9 Jul 2017 23:04:02 +0000 (16:04 -0700)]
Fix core dump in substitute-object-in-subtree
Without this fix, (substitute-object-in-subtree #0=(#0# 'a) 'a)
would dump core, since the C code would recurse indefinitely through
the infinite structure. This patch adds an argument to the function,
and renames it to lread--substitute-object-in-subtree as the function
is not general-purpose and should not be relied on by outside code.
See Bug#23660.
* src/intervals.c (traverse_intervals_noorder): ARG is now void *,
not Lisp_Object, so that callers need not cons unnecessarily.
All callers changed. Also, remove related #if-0 code that was
“temporary” in the early 1990s and has not been compilable for
some time.
* src/lread.c (struct subst): New type, for substitution closure data.
(seen_list): Remove this static var, as this info is now part of
struct subst. All uses removed.
(Flread__substitute_object_in_subtree): Rename from
Fsubstitute_object_in_subtree, and give it a 3rd arg so that it
doesn’t dump core when called from the top level with an
already-cyclic structure. All callers changed.
(SUBSTITUTE): Remove. All callers expanded and then simplified.
(substitute_object_recurse): Take a single argument SUBST rather
than a pair OBJECT and PLACEHOLDER, so that its address can be
passed around as part of a closure; this avoids the need for an
AUTO_CONS call. All callers changed. If the COMPLETED component
is t, treat every subobject as potentially circular.
(substitute_in_interval): Take a struct subst * rather than a
Lisp_Object, for the closure data. All callers changed.
* test/src/lread-tests.el (lread-lread--substitute-object-in-subtree):
New test, to check that the core dump does not reoccur.
* src/emacs-module.c (module_free_global_ref): Re-add assertion that
the reference count is zero. This assertion was removed in commit 8afaa1321f8088bfb877fe4b6676e8517adb0bb7, but it's not included in the
test performed by XFASTINT before, because the previous reference
count could have been zero already in the case of a buggy
implementation. This assertion might have detected Bug#27587.
Further improve electric quote support for Markdown (Bug#24709)
Markdown sets both 'comment-start' and 'comment-use-syntax' to non-nil
values. Therefore 'electric-quote-mode' recognized it as a
programming mode. Fix this by first checking whether the current
major mode is derived from 'text-mode'.
* lisp/electric.el (electric-quote-post-self-insert-function): Treat
'text-mode' as stronger signal than comment syntax.
* test/lisp/electric-tests.el (electric-quote-markdown-in-text)
(electric-quote-markdown-in-code): Adapt unit tests.
Brings the the time for `ucs-normalize-part1' from 200s down to 130s.
* test/lisp/international/ucs-normalize-tests.el
(ucs-normalize-tests--parse-column): Use character instead of string
of length 1 for terminator. Convert return value into string since
all callers need that form anyway.
(ucs-normalize-tests--normalization-equal-p): Rename from
ucs-normalize-tests--normalize. Use dedicated buffer instead of
messing with narrowing. Take string to compare against and insert it
into buffer so that compare-buffer-substrings can be used instead of
allocating a new string from buffer contents.
(ucs-normalize-tests--normalization-chareq-p): New macro, specialized
for comparing single character.
(ucs-normalize-tests--rule1-holds-p)
(ucs-normalize-tests--rule2-holds-p): Turn into defsubst.
(ucs-normalize-tests--rule1-failing-for-partX): Use `eq' instead of
`='.
* test/lisp/international/ucs-normalize-tests.el
(ucs-normalize-tests--failing-lines-part2): Update for new
admin/unidata/NormalizationTest.txt version.
Semi-automate the procedure for updating UCS normalize test bad lines
* test/lisp/international/ucs-normalize-tests.el: Remove incorrect
commentary describing a manual procedure for producing the updated
failing lines, it did not actually work. Replace it with pointer to
new function which prints the updated values.
(ucs-normalize-tests--rule1-holds-p): Renamed from
ucs-normalize-tests--invariants-hold-p.
(ucs-normalize-tests--rule2-holds-p): Renamed from
ucs-normalize-tests--invariants-rule2-hold-p.
(ucs-normalize-tests--rule1-failing-for-partX): Renamed from
ucs-normalize-tests--invariants-failing-for-part.
(ucs-normalize-tests--rule1-failing-for-lines): Renamed from
ucs-normalize-tests--invariants-failing-for-lines.
(ucs-normalize-tests--part2-rule1-failed-lines): New variable.
(ucs-normalize-part2): Set it.
(ucs-normalize-part1): Always run through to end of test before
checking for failures.
(ucs-normalize-tests--insert-failing-lines)
(ucs-normalize-check-failing-lines): New functions, used to update
the *--failing-lines-part* variables.
It's technically possible to write a user pointer finalizer that calls
into Emacs module functions. This would be disastrous because it
would allow arbitrary Lisp code to run during garbage collection.
Therefore extend the module assertions to check for this case.
* src/emacs-module.c (module_assert_thread): Also check whether a
garbage collection is in progress.
* test/data/emacs-module/mod-test.c (invalid_finalizer)
(Fmod_test_invalid_finalizer): New test module functions.
(emacs_module_init): Register new test function.
* test/src/emacs-module-tests.el (module--test-assertion)
(module--with-temp-directory): New helper macros.
(module--test-assertions--load-non-live-object): Rename existing
unit test, use helper macros.
(module--test-assertions--call-emacs-from-gc): New unit test.
* src/xdisp.c (dump_glyph, dump_glyph_row, Fdump_glyph_matrix):
Use pD directives for ptrdiff_t values instead of pI, to avoid
compilation warnings on 64-bit hosts. (Bug#27597)
Eli Zaretskii [Sat, 8 Jul 2017 07:49:36 +0000 (10:49 +0300)]
Support display of line numbers natively
This merges branch 'line-numbers'.
* src/buffer.c (disable_line_numbers_overlay_at_eob): New
function.
* src/lisp.h (disable_line_numbers_overlay_at_eob): Add prototype.
* src/dispextern.h (struct it): New members pt_lnum, lnum,
lnum_bytepos, lnum_width, and lnum_pixel_width.
* src/indent.c (line_number_display_width): New function,
refactored from line-number width calculations in vertical-motion.
(Fvertical_motion): Call line_number_display_width when the width
of line-number display is needed.
(Fline_number_display_width): New defun.
(syms_of_indent): Defsubr it.
* src/indent.c (Fvertical_motion): Help C-n/C-p estimate correctly
the width used up by line numbers by looking near the window-start
point. If window-start is outside of the accessible portion,
temporarily widen the buffer.
* src/term.c (produce_glyphs): Adjust tab stops for the horizontal
space taken by the line-number display.
* src/xdisp.c (display_count_lines_logically)
(display_count_lines_visually, maybe_produce_line_number)
(should_produce_line_number, row_text_area_empty): New functions.
(try_window_reusing_current_matrix): Don't use this method when
display-line-numbers is in effect.
(try_window_id, try_cursor_movement): Disable these optimizations
when the line-number-current-line face is different from
line-number face and for relative line numbers.
(try_window_id, redisplay_window, try_cursor_movement): For
visual line-number display, disable the same redisplay
optimizations as for relative.
(x_produce_glyphs): Adjust tab stops for the horizontal
space taken by the line-number display.
(hscroll_window_tree): Adjust hscroll calculations to line-number
display.
(DISP_INFINITY): Renamed from INFINITY to avoid clashes with
math.h; all users changed.
(set_cursor_from_row): Fix calculation of cursor X coordinate in
R2L rows with display-produced glyphs at the beginning.
(display_line): Use should_produce_line_number to determine
whether a line number should be produced for each glyph row, and
maybe_produce_line_number to produce line numbers.
Don't display line numbers in the minibuffer and in tooltip
frames.
Call row_text_area_empty to verify that a glyph
row's text area is devoid of any glyphs that came from a buffer or
a string. This fixes a bug with empty-lines indication
disappearing when line numbers or line-prefix are displayed.
(syms_of_xdisp) <display-line-numbers, display-line-numbers-widen>
<display-line-number-width>: New buffer-local variables.
<display-line-numbers-current-absolute>: New variable.
* lisp/cus-start.el (standard): Provide customization forms for
display-line-numbers and its sub-features.
* lisp/faces.el (line-number, line-number-current-line): New faces.
* lisp/frame.el: Add display-line-numbers, display-line-numbers-widen,
display-line-numbers-current-absolute, and
display-line-number-width to the list of variables that should
trigger redisplay of the current buffer.
* lisp/menu-bar.el (menu-bar-showhide-menu): Add menu-bar item to
turn display-line-numbers on and off.
(toggle-display-line-numbers): New function.
* lisp/simple.el (last--line-number-width): New internal variable.
(line-move-visual): Use it to adjust temporary-goal-column when
line-number display changes its width.
* doc/emacs/basic.texi (Position Info): Add cross-reference to
"Display Custom", for line-number display.
* doc/emacs/custom.texi (Init Rebinding):
* doc/emacs/modes.texi (Minor Modes): Remove references to
linum-mode.
* doc/emacs/display.texi (Display Custom): Describe the
line-number display.
* doc/lispref/display.texi (Size of Displayed Text): Document
line-number-display-width.
* etc/NEWS: Document display-line-numbers and its customizations.
Paul Eggert [Sat, 8 Jul 2017 01:12:16 +0000 (18:12 -0700)]
Fix more ungetc bugs with encoding errors
* src/lread.c (infile): New variable, replacing ...
(instream): ... this. All uses changed.
(readbyte_from_stdio): New function, which deals with lookahead.
(readbyte_from_file, Fget_file_char): Use it.
(Fget_file_char): When misused, signal an error instead of
relying on undefined behavior.
(close_infile_unwind): New function.
(Fload): Use it.
(readevalloop): 2nd arg is now struct infile *, not FILE *.
All callers changed.
(read1): Handle lookahead when copying doc strings with
encoding errors.