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>.
Eli Zaretskii [Sat, 1 Jul 2017 07:22:45 +0000 (10:22 +0300)]
Avoid slow redisplay under 'visual' mode of line numbers
* src/xdisp.c (display_count_lines_visually): Avoid very slow
redisplay when this function is invoked very far from point.
Reported by Alex <agrambot@gmail.com>.
Eli Zaretskii [Fri, 30 Jun 2017 19:48:36 +0000 (22:48 +0300)]
Fix relative-number display with non-nil display-line-number-width
* src/xdisp.c (maybe_produce_line_number): Don't treat a zero
value of display-line-number-width as acceptable.
Handle the case of 'relative' with display-line-number-width
non-nil and smaller than the absolute line number requires.
Reported by Alex <agrambot@gmail.com>.
Eli Zaretskii [Fri, 30 Jun 2017 14:33:06 +0000 (17:33 +0300)]
Add documentation for display-line-numbers
* 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.
(Optional Mode Line): Fix the index entry to not conflict with
that in "Display Custom".
* doc/emacs/basic.texi (Position Info): Add cross-reference to
"Display Custom", for line-number display.
* src/xdisp.c (syms_of_xdisp): <display-line-numbers>: Mention
display-line-numbers-disable in the doc string.
Eli Zaretskii [Fri, 30 Jun 2017 13:37:57 +0000 (16:37 +0300)]
Support displaying zero as the number of the current line
* src/xdisp.c (syms_of_xdisp)
<display-line-numbers-current-absolute>: New variable.
<display-line-numbers>: Doc fix.
(maybe_produce_line_number): Support nil value of
display-line-numbers-current-absolute.
* lisp/cus-start.el (standard): Add customization form for
display-line-numbers-current-absolute.
Eli Zaretskii [Fri, 30 Jun 2017 12:55:51 +0000 (15:55 +0300)]
Speed up the visual-mode relative line numbers
* src/xdisp.c (display_count_lines_visually): Introduce a
shortcut: if a relative line number was already calculated for
this iterator object, just increase it instead of the
expensive call to move_it_to. Argument list changed to pass a
pointer to the iterator object.
(maybe_produce_line_number): Adjust for change in signature of
display_count_lines_visually. Record the relative line number and
the corresponding byte position in the iterator object also in the
'visual' mode.
Eli Zaretskii [Fri, 30 Jun 2017 09:24:13 +0000 (12:24 +0300)]
Fix hscrolling with line numbers on TTY frames
* src/xdisp.c (hscroll_window_tree): Correct the X offset
calculations on TTY frames.
* src/term.c (produce_glyphs): Use it->lnum_pixel_width instead of
a kludge using it->lnum_width.
Eli Zaretskii [Fri, 30 Jun 2017 08:43:49 +0000 (11:43 +0300)]
Fix TAB display when the line-number face uses a smaller/larger font
* src/dispextern.h (struct it): New member lnum_pixel_width.
* src/xdisp.c (maybe_produce_line_number): Compute the width of
the line-number display in pixels.
(x_produce_glyphs): Use it->lnum_pixel_width instead of a kludge
that used it->lnum_width and made assumptions about pixel width.
Eli Zaretskii [Thu, 29 Jun 2017 18:09:55 +0000 (21:09 +0300)]
Minor fixes
* src/xdisp.c (maybe_produce_line_number): Fix bug that caused
line numbers to be displayed in empty lines beyond ZV.
(x_produce_glyphs): Start fixing TAB display in truncated lines.
Eli Zaretskii [Mon, 26 Jun 2017 20:20:49 +0000 (23:20 +0300)]
Initial support for visually-relative line numbers
Works very slowly.
* src/xdisp.c (display_count_lines_visually): New function.
(maybe_produce_line_number): Support 'visual' mode of line-number
display.
* src/xdisp.c (maybe_produce_line_number): Update IT's metrics
also when glyph_row is NULL. This is important for move_it_*
functions.
(syms_of_xdisp) <display-line-number-width>: Now buffer-local.
(try_window_id, redisplay_window, try_cursor_movement): For
'visual' line-number display, disable the same redisplay
optimizations as for 'relative'.
* lisp/cus-start.el (standard): Add new value for the
customization form of display-line-numbers.
Eli Zaretskii [Sun, 25 Jun 2017 17:53:05 +0000 (20:53 +0300)]
Allow to disable display of line numbers beyond EOB
* src/buffer.c (disable_line_numbers_overlay_at_eob): New
function.
* src/lisp.h (disable_line_numbers_overlay_at_eob): Add prototype.
* src/xdisp.c (should_produce_line_number): When at ZV, call
disable_line_numbers_overlay_at_eob to determine whether line
numbers should be displayed beyond ZV.
Eli Zaretskii [Sun, 25 Jun 2017 16:33:04 +0000 (19:33 +0300)]
Fix line number display for overlay/display strings with newlines
* src/xdisp.c (maybe_produce_line_number): Fix the condition for
producing space glyphs instead of a line number to include the
case of display strings and overlays.
Eli Zaretskii [Sat, 24 Jun 2017 16:03:39 +0000 (19:03 +0300)]
Partial fix of hscroll of truncated lines with line numbers
* src/xdisp.c (x_produce_glyphs, hscroll_window_tree): Adjust
hscroll calculations to line-number display.
* src/term.c (produce_glyphs): Adjust tab stop to window's
hscroll. These two changes fix horizontal scrolling when line
numbers are displayed. But there's still a bug: the horizontal
shift of lines that begin with a TAB is different from the rest.
* src/xdisp.c (move_it_in_display_line_to): Call
should_produce_line_number to determine whether a line number
should be produced for this screen line.
Eli Zaretskii [Sat, 24 Jun 2017 13:58:01 +0000 (16:58 +0300)]
Allow Lisp program to disable line-number display for specific lines
* etc/NEWS: Update the documentation.
* src/xdisp.c (syms_of_xdisp) <display-line-numbers-disable>: New
symbol.
(should_produce_line_number): New function.
(display_line): Use should_produce_line_number to determine
whether a line number should be produced for each glyph row.
Eli Zaretskii [Sat, 24 Jun 2017 12:45:23 +0000 (15:45 +0300)]
Support a separate face for displaying the current line's number
* lisp/faces.el (line-number-current-line): New face.
* src/xdisp.c (syms_of_xdisp) <line-number-current-line>: New
symbol.
(try_window_id, try_cursor_movement): Disable these optimizations
when the line-number-current-line face is different from
line-number face.
(maybe_produce_line_number): Display the current line in the
line-number-current-line face, if it's different from line-number.
Eli Zaretskii [Sat, 24 Jun 2017 09:37:30 +0000 (12:37 +0300)]
Fix problems with line-number updates in Follow mode
* src/xdisp.c (redisplay_window): If forced window-start requires
to move a window's point, and the window is under relative
line-number display, force another round of redisplay to update
the relative line numbers. This fixes follow-mode "redisplay" of
its window group.
* lisp/frame.el: Add display-line-numbers to the list of variables
that should trigger redisplay of the current buffer.
Eli Zaretskii [Sat, 24 Jun 2017 08:34:52 +0000 (11:34 +0300)]
Fix display of line numbers with fonts larger than the default
* src/xdisp.c (maybe_produce_line_number): Update the metrics in
IT, not in IT->glyph_row, since the latter gets overwritten in
display_line. Fixes display of line numbers when the font used
for them is larger than that of the default face.
Eli Zaretskii [Fri, 23 Jun 2017 15:13:53 +0000 (18:13 +0300)]
Fix background color beyond EOB and cursor display
* src/xdisp.c: (maybe_produce_line_number): Use the default face
for background of the blank glyphs in the line-number area which
are drawn beyond EOB.
(display_line): Reset the glyph row's displays_text_p flag only on
empty lines that don't display line numbers. This fixes cursor
display beyond EOB. Fix the bidi information in the glyphs
produced for line numbers. Set the avoid_cursor_p flag of glyphs
produced for line numbers.
Eli Zaretskii [Fri, 23 Jun 2017 14:13:01 +0000 (17:13 +0300)]
Fix display of indicate-empty-lines when line numbers are displayed
* src/xdisp.c (row_text_area_empty): New function.
(display_line): 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.
(display_line): Delete the argument FORCE; all callers changed.
Remove the condition for actually producing the glyphs for the
line number, as even if the number didn't change we need to
produce empty space.
Eli Zaretskii [Sat, 17 Jun 2017 14:42:44 +0000 (17:42 +0300)]
Finish up native display of line numbers
* src/xdisp.c (maybe_produce_line_number): Produce a blank before
the number, for R2L rows. Increment 'g' in the loop even if
glyph_row is NULL. Accept 2nd argument FORCE and produce the
line-number glyphs if it is non-zero.
(move_it_in_display_line_to): Account for the space taken by the
line-number glyphs. Call maybe_produce_line_number with 2nd
argument non-zero.
(set_cursor_from_row): Fix calculation of cursor X coordinate in
R2L rows with display-produced glyphs at the beginning.
(syms_of_xdisp) <line-number>: New face symbol.
<relative, display-line-width>: New symbols.
(maybe_produce_line_number): Use the line-number face for
displaying line numbers. Support relative line-number display.
Support user-defined width for displaying line numbers.
(try_cursor_movement, try_window_id): Disable these optimizations
when displaying relative line numbers.
* src/dispextern.h (struct it): New member 'pt_lnum'.
* lisp/faces.el (line-number): New face.
* lisp/cus-start.el (standard): Provide customization forms for
display-line-numbers and display-line-width.
* lisp/menu-bar.el (menu-bar-showhide-menu): Add menu-bar item to
turn display-line-numbers on and off.
Eli Zaretskii [Fri, 16 Jun 2017 19:44:48 +0000 (22:44 +0300)]
Initial version of native display of line numbers
* src/xdisp.c (syms_of_xdisp) <display-line-numbers>: New
buffer-local variable.
Include <math.h>.
(maybe_produce_line_number): New function.
(DISP_INFINITY): Rename from INFINITY, since math.h defines INFINITY.
(try_window_reusing_current_matrix): Don't use this method when
display-line-numbers is in effect.
* src/dispextern.h (struct it): New members 'lnum'.
Alan Mackenzie [Thu, 15 Jun 2017 20:47:11 +0000 (20:47 +0000)]
Create a toggle between block and line comments in CC Mode.
Also (unrelated change) initialize the modes' keymaps at each loading.
* lisp/progmodes/cc-cmds.el (c-update-modeline): amend for the new information
on the modeline.
(c-block-comment-flag): New variable.
(c-toggle-comment-style): New function.
* lisp/progmodes/cc-langs.el (c-block-comment-starter)
(c-line-comment-starter): Make them c-lang-defvars.
(c-block-comment-is-default): New c-lang-defvar.
(comment-start, comment-end): Make the default values dependent on
c-block-comment-is-default.
* lisp/progmodes/cc-mode.el (c-mode-base-map): Define C-c C-k in this map.
(c-basic-common-init): Initialize c-block-comment-flag.
(c-mode-map, c++-mode-map, objc-mode-map, java-mode-map, idl-mode-map)
(pike-mode-map, awk-mode-map): Make entries in these key maps each time the
mode is loaded rather than just once per Emacs session.
* doc/misc/cc-mode.texi (Comment Commands): Introduce the notion of comment
style.
(Minor Modes): Define comment style. Describe how comment style influences
the information displayed on the modeline. Document c-toggle-comment-style.
(FAQ): Add a question about toggling the comment style.
Paul Eggert [Thu, 15 Jun 2017 20:29:04 +0000 (13:29 -0700)]
Pacify clang without munging C source
* configure.ac (WARN_CFLAGS): With Clang, use
-Wno-tautological-compare regardless of --enable-gcc-warnings.
(WERROR_CFLAGS): Simplify assignments, and guarantee it’s always set.
* lib/strftime.c: Copy from gnulib, reverting Clang-specific
change which I hope is no longer needed.
* src/emacs.c (main): Revert rlim_t change, as rlim_t is signed on
some older non-POSIX hosts.
Paul Eggert [Thu, 15 Jun 2017 19:34:00 +0000 (12:34 -0700)]
No need to complicate make-docfile.c for Clang
* lib-src/make-docfile.c (put_filename): Undo recent change.
The Clang false alarm occurs only with CFLAGS=-save-temps and
we needn’t worry about pacifying unusual compiler configurations.
Paul Eggert [Thu, 15 Jun 2017 17:33:10 +0000 (10:33 -0700)]
Don’t worry about __STDC_VERSION__ in emacs-module
* src/emacs-module.h: Remove __STDC_VERSION__ check. In the past
we’ve found that some compilers do not define this symbol even
when they work well enough. If necessary features like stdbool.h
are missing the compiler will complain eventually anyway.
Eli Zaretskii [Wed, 14 Jun 2017 16:09:21 +0000 (19:09 +0300)]
Avoid compiler warning in image.c on MS-Windows
* src/image.c (x_create_x_image_and_pixmap) [HAVE_NTGUI]: Avoid
compilation warning under -Warray-bounds by temporarily disabling
the -Warray-bounds option.
Michael Albinus [Wed, 14 Jun 2017 12:17:22 +0000 (14:17 +0200)]
Fix Bug#27315
* lisp/net/tramp-cache.el (tramp-cache-read-persistent-data):
New defvar.
(top): Use it.
* lisp/net/tramp.el (tramp-handle-file-name-case-insensitive-p):
Check for connected, not for connectable. (Bug#27315)
(tramp-process-actions):
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
Use `tramp-cache-read-persistent-data'.
* test/lisp/net/tramp-tests.el (top): Set also
`tramp-cache-read-persistent-data'.
Philipp Stephani [Wed, 14 Jun 2017 10:35:58 +0000 (12:35 +0200)]
Remove some tautological comparisons involving rlim_t
Clang on macOS warns about these with -Wtautological-compare. POSIX
guarantees that rlim_t is
unsigned (cf.
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html),
so these resource limits can never be negative.
Paul Eggert [Wed, 14 Jun 2017 01:19:30 +0000 (18:19 -0700)]
Port cleanup attribute to Oracle Studio 12.5
* INSTALL (--with-modules): List cleanup attribute as prereq.
* src/conf_post.h (__has_attribute_cleanup): Remove; no longer needed.
* src/emacs-module.c (MODULE_SETJMP_1): Don’t attempt to verify
(__has_attribute (cleanup)), as Oracle Studio 12.5 supports
__has_attribute only inside preprocessor expressions. The C
compiler should check the cleanup attribute in the next line anyway.
(module_reset_handlerlist): Remove an unnecessary ‘const’
that causes Oracle Studio 12.5 to refuse to compile.
Philipp Stephani [Tue, 13 Jun 2017 18:46:03 +0000 (20:46 +0200)]
Inline test module Makefile into main test Makefile
The test/data/emacs-module/Makefile only built a single target, and
inlining it into test/Makefile simplifies dependency tracking and
reduces code duplication.
Noam Postavsky [Sun, 11 Jun 2017 13:49:44 +0000 (09:49 -0400)]
Buttonize #<bytecode> part of printed functions (Bug#25226)
* lisp/emacs-lisp/cl-print.el: Autoload `disassemble-1'.
(cl-print-compiled-button): New variable.
(help-byte-code): New button type, calls `disassemble' in its action.
(cl-print-object): Use it if `cl-print-compiled-button' is
non-nil.
Alan Third [Mon, 12 Jun 2017 17:26:23 +0000 (18:26 +0100)]
Note how fullscreen differs on the NS port
doc/lispref/frames.texi (Size Parameters):
doc/emacs/frames.texi (Tool Bars): Add a description of how macOS
hides the tool-bar and menu-bar in fullscreen.
Alan Third [Sun, 11 Jun 2017 16:07:28 +0000 (17:07 +0100)]
Add no-focus-on-map to NS build (bug#25408)
* src/nsfns.m (ns_frame_parm_handlers): Add x_set_no_focus_on_map.
(x-create-frame): Check for no-focus-on-map.
* src/nsterm.h (x_set_no_focus_on_map): New function.
* src/nsterm.m (x_set_no_focus_on_map): New function.
(ns_raise_frame): Add parameter for specifying whether to focus the
frame.
(ns_frame_raise_lower):
(x_make_frame_visible): Handle new parameter for ns_raise_frame.
Paul Eggert [Mon, 12 Jun 2017 17:38:27 +0000 (10:38 -0700)]
_Noreturn not noreturn
_Noreturn is more portable to non-C11 platforms. See:
https://www.gnu.org/software/gnulib/manual/html_node/stdnoreturn_002eh.html
* src/emacs-module.c: Use _Noreturn, not noreturn. No need to
include <stdnoreturn.h>. Reindent to fit in 80 columns.
Eli Zaretskii [Mon, 12 Jun 2017 15:04:04 +0000 (18:04 +0300)]
Avoid compilation warnings with pre-C99 libc
* src/emacs-module.c (module_free_global_ref)
(module_assert_runtime, module_assert_env, value_to_lisp): Use 'pD'
instead of C99 't' format descriptor.
Add a new command-line option '-module-assertions' that users can
enable developing or debugging a module. If this option is present,
Emacs performs additional checks to verify that modules fulfill their
requirements. These checks are expensive and crash Emacs if modules
are invalid, so disable them by default.
This is a command-line option instead of an ordinary variable because
changing it while Emacs is running would cause data structure
imbalances.
* src/emacs.c (main): New command line option '-module-assertions'.
* src/emacs-module.c (module_assert_main_thread)
(module_assert_runtime, module_assert_env, module_assert_value):
New functions to assert module requirements.
(syms_of_module): New uninterned variable 'module-runtimes'.
(init_module_assertions, in_main_thread, module_abort): New helper
functions.
(initialize_environment): Initialize value list. If assertions are
enabled, use a heap-allocated environment object.
(finalize_environment): Add assertion that environment list is never
empty.
(finalize_runtime_unwind): Pop module runtime object stack.
(value_to_lisp): Assert that the value is valid.
(lisp_to_value): Record new value if assertions are enabled.
(mark_modules): Mark allocated object list.
(MODULE_FUNCTION_BEGIN_NO_CATCH)
(module_non_local_exit_check, module_non_local_exit_clear)
(module_non_local_exit_get, module_non_local_exit_signal)
(module_non_local_exit_throw): Assert thread and environment.
(module_get_environment): Assert thread and runtime.
(module_make_function, module_funcall, module_intern)
(module_funcall, module_make_integer, module_make_float)
(module_make_string, module_make_user_ptr, module_vec_get)
(funcall_module, Fmodule_load): Adapt callers.
(module_make_global_ref): If assertions are enabled, use the global
environment to store global values.
(module_free_global_ref): Remove value from global value list.
* test/Makefile.in (EMACSOPT): Enable module assertions when testing
modules.
* test/data/emacs-module/mod-test.c (Fmod_test_invalid_store)
(Fmod_test_invalid_load): New functions to test module assertions.
(emacs_module_init): Bind the new functions.
* test/src/emacs-module-tests.el (mod-test-emacs): New constant for
the Emacs binary file.
(mod-test-file): New constant for the test module file name.
(module--test-assertions): New unit test.
Paul Eggert [Mon, 12 Jun 2017 00:29:21 +0000 (17:29 -0700)]
Merge from gnulib
This incorporates:
2017-06-11 getopt-posix: port to glibc 2.25.90
2017-06-04 same-inode: port better to VMS 8.2 and later
* doc/misc/texinfo.tex, lib/getopt-pfx-core.h, lib/getopt-pfx-ext.h:
* m4/sys_types_h.m4: Copy from gnulib.
Paul Eggert [Mon, 12 Jun 2017 00:05:03 +0000 (17:05 -0700)]
Remove Lisp_Misc_Float
* src/data.c (Ftype_of): Do not worry about Lisp_Misc_Float.
* src/lisp.h (Lisp_Misc_Float): Remove. This placeholder has been
unused for two decades; if we ever want to change floats to be a
misc type we can bring it back then.
Glenn Morris [Sun, 11 Jun 2017 23:20:40 +0000 (16:20 -0700)]
Merge from origin/emacs-25
eaa00584ceb Improve documentation of 'gnutls-verify-error' 908498cc01b ; etc/PROBLEMS: Describe GTK-related crashes on elementar... 741daec617e ; Describe the problem with ksh when resizing shell window
Simen Heggestøyl [Sun, 11 Jun 2017 15:41:09 +0000 (17:41 +0200)]
Fix highlighting of CSS selectors with double hyphens
* lisp/textmodes/css-mode.el (css--font-lock-keywords): Fix
highlighting of selectors that contain double hyphens. They would be
mistaken for a variable.