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.
Paul Eggert [Sat, 8 Jul 2017 01:08:00 +0000 (18:08 -0700)]
Fix ungetc bug when reading an encoding error
* src/lread.c (readchar, read_emacs_mule_char): Fix off-by-one
error when reading an encoding error from a file, e.g., a symbol
in an .elc file whose name is "\360\220\200\360".
Stephen Berman [Fri, 7 Jul 2017 20:03:21 +0000 (22:03 +0200)]
Add new todo-mode.el tests
* test/lisp/calendar/todo-mode-tests.el (with-todo-test):
Declare an Edebug spec. Restore pre-test-run state of test files.
(todo-test--show, todo-test--move-item)
(todo-test--insert-item): New functions.
(todo-test-get-archive): Remove, as subsumed by
todo-test--show. Adjust all callers.
(todo-test--is-current-buffer): Rename from
todo-test-is-current-buffer and adjust uses.
(todo-test-item-highlighting): Use todo-test--show.
(todo-test-revert-buffer01, todo-test-revert-buffer02)
(todo-test-raise-lower-priority)
(todo-test-todo-mark-unmark-category, todo-test-move-item01)
(todo-test-move-item02, todo-test-move-item03)
(todo-test-move-item04, todo-test-move-item05)
(todo-test-toggle-item-header01)
(todo-test-toggle-item-header02)
(todo-test-toggle-item-header03)
(todo-test-toggle-item-header04)
(todo-test-toggle-item-header05)
(todo-test-toggle-item-header06)
(todo-test-toggle-item-header07): New tests.
* test/lisp/calendar/todo-mode-resources/todo-test-1.toda:
* test/lisp/calendar/todo-mode-resources/todo-test-1.todo:
Modify to accommodate new tests.
Stephen Berman [Fri, 7 Jul 2017 15:48:14 +0000 (17:48 +0200)]
todo-mode.el: Fix handling of hidden item headers (bug#27609)
* lisp/calendar/todo-mode.el (todo--item-headers-hidden): New variable.
(todo-toggle-item-header): Use it. Make this command a noop
if the file has no items.
(todo-move-item, todo-item-done): Instead of concatenating the
items to move into one string, make a list of them to
facilitate handling hidden headers. Adjust insertion accordingly.
(todo-archive-done-item): Handle hidden headers in archive file.
(todo-unarchive-items): Handle hidden headers in todo file.
(todo-backward-item): Use todo--item-headers-hidden and handle
moving backward work when item date-time headers are hidden.
(todo-remove-item): Delete date-time header overlay.
(todo-get-overlay, todo-insert-with-overlays): Make them work
with hidden date-time headers.
(todo-modes-set-2): Make todo--item-headers-hidden buffer local.
Stephen Berman [Fri, 7 Jul 2017 15:37:46 +0000 (17:37 +0200)]
Fix several todo-mode bugs found while debugging bug#27609
* lisp/calendar/todo-mode.el (todo-toggle-mark-item): Calculate
current category only once.
(todo-mark-category): Update number of marked items to avoid
spurious duplication in todo-categories-with-marks alist and
corruption of the todo-categories alist. Handle empty line
when there are no todo items and done items are shown.
(todo-set-item-priority): Make noop if called from
todo-raise-item-priority or todo-lower-item-priority when
point is on a done todo item or an empty line.
(todo-move-item): Use markers instead of integer positions to
correctly handle deleting the now moved items from the source
category (without markers an infinite loop arises when moving
marked item to a preceding category).
(todo-unarchive-items): Put point on the (first) restored done
item, instead of leaving it at the end of the done items
separator string.
(todo-revert-buffer): Ensure buffer remains read-only after
reverting.
Eli Zaretskii [Fri, 7 Jul 2017 09:21:10 +0000 (12:21 +0300)]
Fix vertical-motion across the place where line-number width changes
* 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.
* doc/lispref/display.texi (Size of Displayed Text): Document
line-number-display-width.
* etc/NEWS: Mention line-number-display-width.
* 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.
Noam Postavsky [Fri, 30 Jun 2017 03:28:15 +0000 (23:28 -0400)]
Don't skip epg tests (Bug#23561)
* test/lisp/epg-tests.el (with-epg-tests): Ignore REQUIRE-PASSPHRASE
parameter, since we supply the passphrase via pinentry-program for all
GPG versions (as of 2017-02-28 "Fix epg-tests with dummy-pinentry
program (Bug#23619)").
(epg-tests-program-alist-for-passphrase-callback): Remove.
Eli Zaretskii [Thu, 6 Jul 2017 17:22:16 +0000 (20:22 +0300)]
Implement line numbers that disregard narrowing
* src/xdisp.c (display_count_lines_logically): New function,
counts line numbers disregarding narrowing. Suggested by Andy
Moreton <andrewjmoreton@gmail.com>.
(maybe_produce_line_number): Call display_count_lines_logically
instead of display_count_lines. Adapt BEGV, ZV, etc. to
display-line-numbers-widen.
(syms_of_xdisp) <display-line-numbers-widen>: New buffer-local
variable.
* lisp/cus-start.el (standard): Provide a customization form for
display-line-numbers-widen.
* lisp/frame.el: Add 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/emacs-lisp/lisp-mode.el (lisp-comment-indent): Only check for
open paren if we're looking at multiple comment characters.
* test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-comment-indent-1)
(lisp-comment-indent-2): New tests.
Noam Postavsky [Wed, 14 Jun 2017 04:13:06 +0000 (00:13 -0400)]
Don't put whitespace between open paren and comment in Lisp modes (Bug#19740)
* lisp/emacs-lisp/lisp-mode.el (lisp-comment-indent): If current
line's code ends in open paren, set comment indentation exactly to
column following it.
(lisp-mode-variables): Set `comment-indent-function' to
`lisp-comment-indent'.
Noam Postavsky [Wed, 14 Jun 2017 04:08:15 +0000 (00:08 -0400)]
Allow comment-indent-functions to specify exact indentation (Bug#385)
* lisp/newcomment.el (comment-choose-indent): Interpret a cons of two
integers as indicating a range of acceptable indentation.
(comment-indent): Don't apply `comment-inline-offset',
`comment-choose-indent' already does that.
(comment-indent-function):
* doc/emacs/programs.texi (Options for Comments): Document new
acceptable return values.
* etc/NEWS: Announce it.
Paul Eggert [Thu, 6 Jul 2017 01:58:11 +0000 (18:58 -0700)]
Check for integer overflow in xbm images
* src/image.c (XBM_TK_OVERFLOW): New constant.
(xbm_scan): Check for integer overflow instead of relying on
undefined behavior. Check that octal digits are actually octal.
Paul Eggert [Thu, 6 Jul 2017 00:51:31 +0000 (17:51 -0700)]
Convert hex digits more systematically
This makes the code a bit smaller and presumably faster, as
it substitutes a single lookup for conditional jumps.
* src/character.c (hexdigit): New constant.
(syms_of_character) [HEXDIGIT_IS_CONST]: Initialize it.
* src/character.h (HEXDIGIT_CONST, HEXDIGIT_IS_CONST): New macros.
(hexdigit): New decl.
(char_hexdigit): New inline function.
* src/charset.c: Do not include c-ctype.h.
* src/charset.c (read_hex):
* src/editfns.c (styled_format):
* src/image.c (xbm_scan):
* src/lread.c (read_escape):
* src/regex.c (ISXDIGIT) [emacs]:
Use char_hexdigit insted of doing it by hand.
Paul Eggert [Thu, 6 Jul 2017 00:14:50 +0000 (17:14 -0700)]
Don’t use -Woverride-init
I have some further changes in mind that would also need to
disable the -Woverride-init warnings. In practice these warnings
seem to be more trouble than they’re worth, so disable them in the
cc command line.
* configure.ac: Disable -Woverride-init here ...
* src/bytecode.c: ... rather than here.
* test/lisp/net/tramp-tests.el
(tramp-test36-asynchronous-requests): Trigger timers.
(tramp-test37-recursive-load, tramp-test38-remote-load-path):
Set `default-directory' to a trustworthy value.
Stefan Monnier [Wed, 5 Jul 2017 02:20:22 +0000 (22:20 -0400)]
* lisp/progmodes/cc-engine.el: Mark unused args
(c-beginning-of-statement-1, c-guess-basic-syntax):
Remove unused var c-in-literal-cache.
(c-debug-sws-msg): Silence byte-compiler, even if we don't use the arg.
(c-append-to-state-cache): Remove unused var `bra+1s'.
(c-remove-stale-state-cache): Remove unused var `pps-point-state'.
(c-invalidate-state-cache-1): Remove unused var `pa'.
(c-forward-decl-or-cast-1): Change comments so they don't look like
outline headers.
(c-restricted-<>-arglists, c-parse-and-markup-<>-arglists):
Declare before first use.
(c-forward-decl-or-cast-1): Remove unused var `backup-kwd-sym'.
(c-backward-over-enum-header): Remove unused var `up-sexp-pos'.
Noam Postavsky [Fri, 2 Jun 2017 03:09:36 +0000 (23:09 -0400)]
Fix infloop in uncomment-region-default (Bug#27112)
When `comment-continue' has only blanks, `comment-padright' produces a
regexp that matches the empty string, so `uncomment-region-default'
will loop infinitely.
* lisp/newcomment.el (comment-padright): Only return a regexp if STR
has nonblank characters.
Eli Zaretskii [Tue, 4 Jul 2017 15:43:03 +0000 (18:43 +0300)]
Fix display of current line number in visual mode
* src/xdisp.c (maybe_produce_line_number): Fix visual-mode display
of current line when line-number-current-line face was customized.
Reported by Filipe Silva <filipe.silva@gmail.com>.
Use hook instead of face list to inhibit electric quoting
This is more flexible and doesn't couple electric quoting to font
locking.
Give that 'electric-quote-code-faces' was just introduced, remove it
without formal deprecation.
* lisp/electric.el (electric-quote-inhibit-functions): New abnormal
hook variable.
(electric-quote-post-self-insert-function): Run the hook. Remove
use of old 'electric-quote-code-faces' variable.
* test/lisp/electric-tests.el (electric-quote-markdown-in-text)
(electric-quote-markdown-in-code): Adapt unit tests.
Offer non-aligned indentation in lists in js-mode (Bug#27503)
* lisp/progmodes/js.el (js--proper-indentation):
New customization option 'js-indent-align-list-continuation'.
Affects argument lists as well as arrays and object properties.
* test/manual/indent/js-indent-align-list-continuation-nil.js:
Test the change.
Eli Zaretskii [Mon, 3 Jul 2017 15:57:01 +0000 (18:57 +0300)]
Avoid errors in vertical-motion when buffer is narrowed
* src/indent.c (Fvertical_motion): If need to start from
window-start, and it is outside of the accessible portion,
temporarily widen the buffer. This avoids errors in evil-mode.
Reported by James Nguyen <james@jojojames.com>.
Michael Albinus [Mon, 3 Jul 2017 14:12:10 +0000 (16:12 +0200)]
(Re-)activate remote tests of filenotify-tests.el
* test/lisp/filenotify-tests.el
(file-notify-test-remote-temporary-file-directory):
Declare default host for mock method. Offer home directory
for mock method if it doesn't exist.
(file-notify-test09-watched-file-in-watched-dir-remote):
Remove, it doesn't work reliably.
Noam Postavsky [Sat, 17 Jun 2017 16:06:37 +0000 (12:06 -0400)]
Let ansi-color overlay hooks work in eshell (Bug#27407)
* lisp/ansi-color.el (ansi-color-make-extent): Add
`ansi-color-freeze-overlay' to `insert-behind-hooks' as well.
* lisp/eshell/esh-mode.el (eshell-output-filter): Let-bind
`inhibit-modification-hooks' to nil while inserting the string.
Noam Postavsky [Fri, 16 Jun 2017 03:23:44 +0000 (23:23 -0400)]
Fix and simplify ansi escape detection (Bug#21381)
* lisp/ansi-color.el (ansi-color-regexp, ansi-color-drop-regexp):
Remove.
(ansi-color-control-seq-regexp): New constant, matches all escape
sequences.
(ansi-color-filter-apply, ansi-color-apply)
(ansi-color-filter-region, ansi-color-apply-on-region): Use it instead
of matching color sequences separately from ignored sequences.
Differentiate color sequences simply by checking the last character.
Michael Albinus [Mon, 3 Jul 2017 11:21:39 +0000 (13:21 +0200)]
Fix tramp-tests.el for hydra
* test/Makefile.in: Remove instrumentation for tramp-tests.
* test/lisp/net/tramp-tests.el (tramp-test36-asynchronous-requests):
Remove instrumentation. Wrap with a timeout. Give hydra
another timer value. Set `default-directory' in timer.
Noam Postavsky [Thu, 11 May 2017 23:40:45 +0000 (19:40 -0400)]
Split shr-copy-url dwim behavior into separate functions (Bug#26826)
* lisp/net/shr.el (shr-url-at-point, shr-probe-url)
(shr-probe-and-copy-url, shr-maybe-probe-and-copy-url): New functions,
split out from `shr-copy-url'.
(shr-copy-url): Only copy the url, don't fetch it.
(shr-map): Bind 'w' and 'u' to `shr-maybe-probe-and-copy-url', which
has the same behavior as the old `shr-copy-url'.
* etc/NEWS: Announce changes.
Alex Branham [Sun, 2 Jul 2017 19:18:47 +0000 (21:18 +0200)]
Make eww-search-words prompt for query if nothing selected
* lisp/net/eww.el (eww-search-words): Make eww-search-words prompt the
user for a search query if the region is inactive or if the region is
just whitespace.
* lisp/emacs-lisp/cl-print.el (cl-print-compiled-button): t by default.
* lisp/emacs-lisp/debug.el (debugger-insert-backtrace):
* lisp/help-fns.el (describe-variable): No need to let-bind
`cl-print-compiled-button' to t anymore.
Philipp Stephani [Wed, 28 Jun 2017 21:47:57 +0000 (23:47 +0200)]
Electric quotes: Improve support for Markdown mode (Bug#24709)
Introduce a new user option 'electric-quote-context-sensitive'. If
non-nil, have ' insert an opening quote if sensible.
Also introduce a new variable 'electric-quote-code-faces'. Major
modes such as 'markdown-mode' can add faces to this list to treat text
as inline code and disable electric quoting.
* lisp/electric.el (electric-quote-context-sensitive): New user
option.
(electric-quote-code-faces): New variable.
(electric-quote-post-self-insert-function): Treat ' as ` if
desired and applicable; disable electric quoting for given faces.
Substitute "`?`" inside command with the current file name.
See details in:
https://lists.gnu.org/archive/html/emacs-devel/2017-06/msg00618.html
* lisp/dired-aux.el (dired-quark-subst-regexp, dired-star-subst-regexp):
Mark as obsolete.
(dired-isolated-string-re): New defun.
(dired--star-or-qmark-p): New predicate.
(dired-do-shell-command): Use dired--star-or-qmark-p. Substitute "`?`"
with the current file name.
* doc/emacs/dired.texi (Shell Commands in Dired): Update manual.
; * etc/NEWS: Mention it.
Alan Mackenzie [Sun, 2 Jul 2017 12:58:27 +0000 (12:58 +0000)]
Fix bug in yesterday's CC Mode commit.
* lisp/progmodes/cc-mode.el (c-quoted-number-head-before-point): Check a
search has succeded before using the match data.
(c-quoted-number-head-before-point, c-quoted-number-head-after-point):
Specify that the position of the extremity of the head or tail is in the
match data.
These FIXMEs can't be addressed because they would require breaking
changes to the module API. Furthermore, other module functions don't
return sentinel values as well, so users generally have to call
non_local_exit_check anyway.
The reader now warns about some unescaped character literals, but
still allows them for compatibility reasons. Slightly adapt the
manual to forbid them officially.
* doc/lispref/objects.texi (Basic Char Syntax): Document that
backslashes are now required before some characters.
Michael Albinus [Sun, 2 Jul 2017 09:41:58 +0000 (11:41 +0200)]
Fix Bug#27502
* lisp/autorevert.el (auto-revert-find-file-function): New defun.
(find-file-hook): Use it. (Bug#27502)
(auto-revert-remove-current-buffer): New defun.
(auto-revert-mode, auto-revert-buffers): Use it.