1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 15:00:45 -08:00
Commit graph

1307 commits

Author SHA1 Message Date
Eli Zaretskii
f93a5180a6 Update the documentation of overlays (bug#59996)
* src/buffer.c (Foverlay_recenter, Foverlay_lists): Update the doc
strings.

* lisp/subr.el (copy-overlay): Update comment.

* doc/lispref/internals.texi (Buffer Internals): Remove buffer
fields relevant to the old implementation; add the new interval
tree field.
* doc/lispref/display.texi (Overlays, Managing Overlays): Update
text to be consistent with the new implementation of overlays.
(Managing Overlays): Remove documentation of 'overlay-recenter'.

* etc/NEWS: Mention incompatible aspects of overlay
reimplementation.
2022-12-14 20:13:47 +02:00
Gregory Heytings
7d787564c0 Actually improve detection of long lines
* src/xdisp.c (redisplay_window): Update condition.

* src/xdisp.c (mark_window_display_accurate_1):
* src/pdumper.c (dump_buffer):
* src/buffer.h (BUF_CHARS_UNCHANGED_MODIFIED):
(struct buffer_text):
* src/buffer.c (Fget_buffer_create):
Revert 1c837c42c2, which was misguided.
2022-12-11 00:16:27 +01:00
Gregory Heytings
849223fba1 Merge branch 'feature/improved-locked-narrowing' 2022-11-27 22:19:41 +01:00
Gregory Heytings
4b5e31bf02 Docstring improvements
* src/xdisp.c (syms_of_xdisp):
* src/keyboard.c (syms_of_keyboard):
* src/buffer.c (syms_of_buffer):
Docstring improvements.
2022-11-26 17:30:31 +01:00
Gregory Heytings
558084c7f7 Improve locked narrowing around low-level hooks.
* src/buffer.c (syms_of_buffer): Two new variables,
'long-line-locked-narrowing-region-size' and
'long-line-locked-narrowing-bol-search-limit', to make the locked
narrowing around low-level hooks configurable.

Increase the default value of 'long-line-threshold'.  After
carefully considering the (few) bug reports about long line
optimizations, I concluded that the previous default value was too
low.

* src/xdisp.c (get_locked_narrowing_begv)
(get_locked_narrowing_zv): Two new functions.
(handle_fontified_prop, reseat): Use them.

* src/keyboard.c (safe_run_hooks_maybe_narrowed): Use them.

* src/dispextern.h (struct it): Add two new fields to store the
values returned by these functions.
Make them externally visible.

* src/editfns.c: (Fsave_restriction): Update docstring.
2022-11-26 15:10:17 +01:00
Yuan Fu
aaeaa310f0
Merge remote-tracking branch 'savannah/master' into feature/tree-sitter 2022-11-21 12:54:35 -08:00
Stefan Monnier
5525bd3932 itree: Make sure a deleted overlay has NULL pointer fields
* src/buffer.c (delete_all_overlays): Use POST_ORDER to set the node's
pointers to NULL, as god intended.

* src/itree.c (itree_insert_node): Uncomment the assertion accordingly.
2022-11-18 11:11:46 -05:00
Stefan Monnier
091e0f04ff itree.c: Get rid of the old iterator code
Only use the new iterator which relies on a fixed size (and small)
state in the iterator.
This makes non-local exits safe within ITREE_FOREACH loops.

* src/itree.c (make_nav, nav_nodeptr, nav_flag, itree_stack_clear)
(itree_stack_push_flagged): Delete functions.
(nodeptr_and_flag): Delete type.
(struct itree_stack): Make the array hold plain pointers instead.
(itree_stack_push): Inline the former code of `itree_stack_push_flagged`.
(itree_stack_pop): Change return type.
(itree_contains): Don't call `ITREE_FOREACH_ABORT` any more.
(itree_insert_gap): Simplify access to the stack of nodes.
(itree_delete_gap, itree_insert_gap): Adjust code to new return type of
`itree_stack_pop`.
(itree_iterator_finish): Delete function.
(itree_iterator_start): Don't setup the `stack` field any more.
(itree_iterator_next): Delete function.
(itree_iter_next): Rename to `itree_iterator_next` and make it non-static.
(itree_iterator_narrow): Don't check the `running` flag any more.

* src/itree.h (itree_iterator_finish): Remove declaration.
(struct itree_iterator): Remove the `stack` and `running` fields.
(ITREE_FOREACH_ABORT): Delete macro.
(ITREE_FOREACH): Don't call `itree_iterator_finish` any more.

* src/xdisp.c (strings_with_newlines):
* src/buffer.c (overlays_in, next_overlay_change, overlay_touches_p):
Don't call `ITREE_FOREACH_ABORT` any more.
2022-11-17 18:09:37 -05:00
Eli Zaretskii
435861a3ba ; * src/buffer.c (Foverlays_in): Doc fix. (Bug#59067) 2022-11-10 12:18:18 +02:00
Stefan Monnier
6e5ec08551 buffer.c: evaporate overlays in all indirect buffers
This fixes bug#58928.  The patch works by moving the
`evaporate_overlays` check closer to `itree_delete_gap`.

* src/buffer.c (adjust_overlays_for_delete_in_buffer): New function,
integrating the functionality of `evaporate_overlays`.
(adjust_overlays_for_delete): Use it.
(evaporate_overlays): Delete function.

* src/buffer.h (evaporate_overlays): Delete declaration.

* src/insdel.c (adjust_markers_for_replace): Minor optimization.
(adjust_after_replace, replace_range, replace_range_2, del_range_2):
Don't call `evaporate_overlays`.

* test/src/buffer-tests.el (buffer-tests--overlays-indirect-evaporate):
Remove the `:expected-result :failed` attribute.
2022-11-05 17:22:37 -04:00
Matt Armstrong
26d2ac38e9 Minor tweaks to the fix for `insert-before-markers' overlay fix
(bug#58928)

* src/buffer.c (adjust_overlays_for_insert): wrap to less than 80
chars.
* src/itree.c: document BEFORE_MARKERS.
2022-11-05 16:45:18 -04:00
Paul Eggert
90a0aac3e8 Pacify gcc -Wanalyzer-null-dereference
This is for gcc 12.2.1 20220819 (Red Hat 12.2.1-2) x86-64
when Emacs is configured with --enable-gcc-warnings.
* src/buffer.c (Fmove_overlay): Prefer BASE_EQ to EQ in a place
where they’re equivalent because the only symbol allowed here is nil.
2022-11-04 11:02:08 -07:00
Stefan Monnier
ff679e16f8 itree: Reproduce markers's behavior more faithfully (bug#58928)
The most obvious problem was the lack of support for
`insert-before-markers`, but the behavior was also different in a few
other cases.

* src/itree.h (itree_insert_gap):
* src/itree.c (itree_insert_gap): Add `before_markers` arg.
* src/lisp.h (adjust_overlays_for_insert):
* src/buffer.c (adjust_overlays_for_insert): Add `before_markers` arg.

* src/insdel.c (adjust_markers_for_replace, adjust_markers_for_insert)
(adjust_markers_for_delete): Adjust overlays directly from here.
(insert_1_both, insert_from_string_1, insert_from_gap)
(insert_from_buffer_1, adjust_after_replace, replace_range)
(replace_range_2, del_range_2): Don't adjust overlays explicitly here
any more.

* test/src/buffer-tests.el (test-overlay-insert-before-markers-empty)
(test-overlay-insert-before-markers-non-empty): New tests.
2022-11-03 22:44:55 -04:00
Basil L. Contovounesios
a66280162f Port interval trees to --enable-checking=structs
Some names under the interval_* namespace were renamed under the
itree_* namespace in commits:

  0. f421b58db5 of 2022-10-19
  "Prefix all itree.h type names with itree_".
  1. 37a1145410 of 2022-10-19
  "Rename all exported itree.h functions with the itree_ prefix"

Further, some values still referenced in commentary were removed in
commits:

  2. 258e618364 of 2022-10-17
  "Delete the itree_null sentinel node, use NULL everywhere."
  3. 2c4a3910b3 of 2022-10-02
  "itree: Use a single iterator object"

* src/emacs.c (main): Allocate global itree iterator once and for
all.
* src/alloc.c (mark_overlay):
* src/buffer.c (set_overlays_multibyte):
* src/itree.c (itree_destroy): Update commentary.
(interval_stack_ensure_space, itree_insert_gap): Prefer
unsigned-to-unsigned comparisons over signed-to-unsigned.
(interval_stack_push_flagged, interval_tree_insert)
(interval_tree_contains, itree_iterator_start)
(itree_iterator_finish, itree_iterator_next, itree_iterator_narrow):
Improve assertions.
(itree_init): Rename...
(init_itree): ...to this, for consistency with other global init
functions.
(itree_create): Stop leaking a global iterator allocation on each
call.
(interval_tree_init): Complete renames of
interval_tree -> itree_tree and interval_tree_clear -> itree_clear.
(interval_tree_remove_fix): Fix indentation.
* src/itree.h: Declare init_itree.
(ITREE_FOREACH): Fix typo in commentary.

* src/pdumper.c [CHECK_STRUCTS]
(dump_interval_node): Use the correct name in the HASH condition
and #error message.
(dump_overlay, dump_buffer): Update HASH (bug#58975).
2022-11-03 16:49:05 +02:00
Stefan Monnier
8a5678906f src/buffer.c: Fix interaction between overlays & indirect buffers (bug#58928)
* src/buffer.c (adjust_overlays_for_insert)
(adjust_overlays_for_delete): Repeat for all buffers sharing the same text.

* src/itree.c (itree_insert_gap, itree_delete_gap): Allow an empty tree.

* test/src/buffer-tests.el (buffer-tests--overlays-indirect-bug58928):
New test.
2022-11-01 21:39:12 -04:00
Stefan Monnier
71589b101c Merge remote-tracking branch 'origin/feature/noverlay' 2022-10-28 17:44:44 -04:00
Matt Armstrong
f2a51774a9 Fix a narrow-to-region vs. overlays-at bug
See bug#58703.

* src/buffer.c (overlays_in): Add a new TRAILING arg expressing the
behavior wanted by `overlays-at', namely to include all overlays
beginning at the POS passed to `overlays-at', even if POS is the end
of the narrowed region.  Pass true and the search range is extended to
ZV+1 if END is greater than ZV, just as is done for EMPTY.
(overlays_at): Pass 'true' for the new trailing arg.  At present this
is the only caller passing 'true'.
(mouse_face_overlay_overlaps): Pass 'false' for the new trailing arg.
(disable_line_numbers_overlay_at_eob): ditto.
(Foverlays_in): ditto.
* src/editfns.c (overlays_around): ditto.
* test/src/buffer-tests.el (sorted-overlays): Add a spot test for
this.
2022-10-21 19:58:34 -07:00
Matt Armstrong
a2fde77b5c Fix handling of overlays that begin at END in 'overlays_in'
When passed EMPTY, 'overlays_in' should return empty overlays at END.
It was doing so, but it was also returning any other overlay that
happened to begin at END.

bug#58672

* src/buffer.c (overlays_in): Don't return overlays at END unless they
are empty overlays.
(disable_line_numbers_overlay_at_eob): Pass 'false' instead of 'NULL'
for the bool 'empty' arg.
* test/src/buffer-tests.el (sorted-overlays-in): New helper function.
(test-overlays-in-empty-range): New test exhaustively covering these
edge conditions.
(test-overlays-in-empty-range-bug58672): Simple test for one case.
2022-10-21 16:19:56 -07:00
Matt Armstrong
37a1145410 Rename all exported itree.h functions with the itree_ prefix
For the most part, I replaced the interval_tree_ prefix with itree_,
interval_node_ with itree_node_, etc.

* src/alloc.c: Rename everywhere as appropriate.
* src/alloc.c: ditto.
* src/buffer.c: ditto.
* src/buffer.h: ditto.
* src/itree.c: ditto.
* src/itree.h: ditto.
2022-10-19 21:35:09 -04:00
Matt Armstrong
f421b58db5 Prefix all itree.h type names with itree_
Rename interval_node -> itree_node, interval_tree -> itree_tree,
interval_tree_order -> itree_order.

* src/alloc.c: Renames.
* src/buffer.c: ditto.
* src/itree.c: ditto.
* src/itree.h: ditto.
* src/lisp.h: ditto.
* src/pdumper.h: ditto.
* src/textprop.h: ditto.
* src/xdisp.h: ditto.
2022-10-19 21:35:09 -04:00
Matt Armstrong
1c44f6c83d ; * src/buffer.c (set_overlay_region): remove unused function. 2022-10-19 15:09:42 -07:00
Stefan Monnier
7cbeeabc7e Tighten up handling of otick
Move args between `build_overlay` and `add_buffer_overlay`,
to try and keep buffer positions together with their buffer.
Be more strict in the `otick` values passed to `interval_tree_insert`.
Move a few things around to try and reduce dependencies through `.h` files.
Fix a thinko bug in `check_tree`.

* src/alloc.c (build_overlay): Remove `begin` and `end` args.

* src/buffer.c (add_buffer_overlay): Move from `buffer.h`.
Add `begin` and `end` args.
(copy_overlays): Adjust accordingly.
(Fmake_overlay): Use BUF_BEG and BUF_Z; adjust call to `build_overlay`
and `add_buffer_overlay`.
(Fmove_overlay): Use BUF_BEG and BUF_Z; Use the new `begin` and `end`
args of `add_buffer_overlay` so we don't need to use
`interval_node_set_region` when moving to a new buffer.
(remove_buffer_overlay, set_overlay_region): Move from `buffer.h`.

* src/buffer.h (set_overlay_region, add_buffer_overlay)
(remove_buffer_overlay): Move to `buffer.c`.
(build_overlay): Move from `lisp.h`.
(maybe_alloc_buffer_overlays): Delete function (inline into its only
caller).

* src/itree.c (interval_tree_insert): Move declaration `from buffer.h`.
(check_tree): Fix initial offset in call to `recurse_check_tree`.
Remove redundant check of the `limit` value.
(interval_node_init): Remove `begin` and `end` args.
(interval_tree_insert): Mark it as static.
Assert that the new node's `otick` should already be uptodate and its
new parent as well.
(itree_insert_node): New function.
(interval_tree_insert_gap): Assert the otick of the removed+added nodes
were uptodate and mark them as uptodate again after adjusting
their positions.
(interval_tree_inherit_offset): Check that the parent is at least as
uptodate as the child.

* src/lisp.h (build_overlay): Move to `buffer.h`.

* src/itree.h (interval_node_init): Adjust accordingly.
(interval_tree_insert): Remove declaration.
(itree_insert_node): New declaration.
2022-10-09 19:45:26 -04:00
Stefan Monnier
c3eb6c0563 Merge remote-tracking branch 'origin/feature/noverlay' into noverlay 2022-10-02 01:31:59 -04:00
Stefan Monnier
1303f55161 New ITREE_FOREACH macro
* src/itree.h (interval_tree_iter_start): Adjust type.
(interval_tree_nodes): Delete declaration.
(ITREE_FOREACH, ITREE_FOREACH_ABORT, ITREE_FOREACH_NARROW): New macros.

* src/itree.c (interval_tree_contains, interval_tree_insert_gap):
Use the new ITREE_FOREACH macro.
(interval_tree_nodes): Delete function.
(interval_tree_iter_start): Return the iterator.
(interval_generator_next, interval_tree_destroy):
Don't accept a NULL arg any more.

* src/xdisp.c (load_overlay_strings, strings_with_newlines):
* src/textprop.c (get_char_property_and_overlay):
* src/buffer.c (copy_overlays, delete_all_overlays)
(set_overlays_multibyte, swap_buffer_overlays, overlays_in)
(next_overlay_change, previous_overlay_change, overlay_touches_p)
(overlay_strings, Foverlay_lists, report_overlay_modification)
(evaporate_overlays): Use the new ITREE_FOREACH macro.

* src/buffer.h (buffer_overlay_iter_start1)
(buffer_overlay_iter_start, buffer_overlay_iter_next)
(buffer_overlay_iter_finish, buffer_overlay_iter_narrow):
Delete declarations.
2022-10-02 01:30:44 -04:00
Gerd Möllmann
c55254dccc Make it compile with ITREE_DEBUG defined
* src/buffer.c (make_lispy_interval_node): Use make_fixnum.
(overlay_tree): Use ITREE_NULL.
2022-10-01 08:32:05 +02:00
Stefan Monnier
ab2926aad3 itree.c: Improve division between tree and iterator
* src/buffer.c (delete_all_overlays): Add comment.

* src/itree.c (struct interval_generator): New fields `running`,
`file`, and `line` moved from `interval_tree`.
(interval_stack_push_flagged): Adjust comment to resolve a FIXME.
(interval_tree_clear): Replace assignment with an a
(interval_tree_iter_next): Delete function.
(interval_tree_clear): Don't set `iter_running` here any more.
(interval_generator_create): Set it here instead.
(interval_tree_iter_start): Fetch `iter` once and for all.
(interval_generator_narrow): Mark it as non-static.
(interval_tree_iter_next, interval_tree_iter_narrow):
Delete functions.  Inline their old bodies in the callers.
(interval_tree_iter_finish): Take the iter rather than
the whole tree.  Adjust all callers.
(interval_generator_next): Move `running `assertion here from
`interval_tree_iter_next`.

* src/buffer.h: Adjust accordingly.

* src/itree.h (struct interval_tree): Remove fields `iter_running`,
`file`, and `line`, moved to `interval_generator`.
(interval_generator_narrow): Replace `interval_tree_iter_narrow`.
2022-09-30 20:37:15 -04:00
Stefan Monnier
757c116f6b free_buffer_overlays: Move nearer to its sole caller
* src/buffer.c (free_buffer_overlays): Move from `buffer.h`.
* src/buffer.h (free_buffer_overlays): Move to `buffer.c`.

* src/itree.c (interval_tree_iter_narrow, interval_tree_iter_finish)
(interval_tree_iter_next): Prefer `eassert`.
2022-09-29 16:15:01 -04:00
Stefan Monnier
ea8daec9bb itree.[ch]: Add sanity checks, comments, and minor tweaks
* src/alloc.c (mark_overlay): Add sanity check.

* src/buffer.c (next_overlay_change, previous_overlay_change):
Tweak code to keep the same vars for the bounds.

* src/itree.c (interval_tree_clear, interval_tree_insert)
(interval_tree_remove, interval_tree_insert_fix, interval_tree_remove_fix):
Adjust to the `color` -> `red` change.
(interval_tree_clear): Prefer `true/false` for booleans.
(interval_generator_create): Use an actual `interval_tree_order` value
rather than 0.
(interval_generator_next): Simplify a tiny bit.  Add comment.
(interval_generator_narrow): Add sanity check.

* src/itree.h (struct interval_node): Replace `color` field with
boolean `red` field.
(enum interval_tree_order): Remove unused `ITREE_DEFLT_ORDER` value.

* src/pdumper.c (dump_interval_node): Adjust to the
`color` -> `red` change.
2022-09-28 19:05:16 -04:00
Stefan Monnier
1a77f09f3c * src/buffer.c (overlays_in): Fix confusion Z-vs-ZV
This fixes test failures in `test-overlays-in-2` and `test-remove-overlays`.
2022-09-25 22:24:35 -04:00
Stefan Monnier
650c20f1ca Merge 'master' into noverlay 2022-09-25 16:15:16 -04:00
Yuan Fu
77d5a0cf9f Merge remote-tracking branch 'origin/master' into feature/tree-sitter 2022-08-29 11:41:10 -07:00
Gregory Heytings
1c837c42c2 Improve detection of long lines.
* src/buffer.h (struct buffer_text): New field.
(BUF_CHARS_UNCHANGED_MODIFIED, CHARS_UNCHANGED_MODIFIED): New macros.

* src/buffer.c (Fget_buffer_create): Initialize the new field.

* src/xdisp.c (mark_window_display_accurate_1): Set the new field.
(redisplay_window): Use it, together with CHARS_MODIFF, instead of
MODIFF and UNCHANGED_MODIFIED to decide whether to check for long
lines.

* src/pdumper.c (dump_buffer): Dump the new field.
2022-08-23 17:48:51 +02:00
Stefan Monnier
b24f7667ad * src/buffer.c (Frename_buffer): Fix bug#56693 2022-08-16 17:29:26 -04:00
Paul Eggert
23561f9665 Work around Bug#57211
* src/buffer.c (Fgenerate_new_buffer_name): Allocate a bigger buffer.
2022-08-14 13:49:33 -07:00
Eli Zaretskii
94c10c426e Speed up display of long lines under 'truncate-lines'
* src/xdisp.c (partial_line_height): Return zero for long and
truncated lines.
(fast_move_it_horizontally): New function.
(hscroll_window_tree, display_line): Use
'fast_move_it_horizontally' in preference to
'move_it_in_display_line_to', when dealing with long and truncated
lines.
(redisplay_internal): Optimize "optimization 3" for long and
truncated lines.
* src/buffer.c (syms_of_buffer) <large-hscroll-threshold>: New
variable.

* etc/NEWS: Announce 'large-hscroll-threshold'.
2022-08-13 16:59:22 +03:00
Gregory Heytings
d0e4ec3c29 Fix forgotten initialization for long line optimizations.
* src/xdisp.c (init_iterator): Initialize the 'narrowed_begv'
field.

* src/buffer.c (syms_of_buffer): Docstring clarification.
2022-08-01 15:28:25 +02:00
Eli Zaretskii
72278f21e0 ; Clarify doc string of 'long-line-threshold'
* src/buffer.c (syms_of_buffer) <long-line-threshold>: Clarify the
doc string.
2022-07-21 15:59:50 +03:00
Gregory Heytings
616da8fa8e Merge branch 'feature/fix-the-long-lines-display-bug' 2022-07-21 12:37:45 +02:00
Gregory Heytings
c7eef61eee Further tweaks to long lines handling.
* src/xdisp.c (redisplay_window): Increase the threshold above which
long lines detection is performed in the buffer.  This should avoid
triggering that detection for most simple editing operations.

* src/lisp.h (modiff_incr): Explain why the counter is incremented
logarithmically.

* src/buffer.h (struct buffer_text): Adapt the comment about the
'modiff' field accordingly.

* src/buffer.c (modify_overlay): Increase the counter by 1 instead of
the size of the buffer section on which the overlay is placed.

* etc/NEWS: Small improvement.
2022-07-20 19:14:41 +02:00
Gregory Heytings
7c0fc85364 Simplified and improved heuristic for long lines detection.
* src/lisp.h (modiff_incr): Add a parameter to 'modiff_incr' to record
the extent of the modification.

* src/insdel.c (insert_1_both, insert_from_string_1, insert_from_gap,
insert_from_buffer_1, adjust_after_replace, replace_range,
replace_range_2, del_range_2, modify_text): Add an argument to each
call to 'modiff_incr'.

* src/textprop.c (modify_text_properties): Add an argument to the call
to 'modiff_incr'.

* src/buffer.c (Frestore_buffer_modified_p, Fbuffer_swap_text,
modify_overlay): Add an argument to each call to 'modiff_incr'.

* src/xdisp.c (redisplay_window): Use the improved version of 'MODIFF'
for the heuristic.
2022-07-19 23:34:09 +02:00
Gregory Heytings
c6bee17075 Revert commits 1ff69cc744 and 9a894206f6. 2022-07-19 23:30:17 +02:00
Stefan Kangas
4b807380cf Merge from origin/emacs-28
282dde887d ; Fix typo missed in previous change
62c47ffd5f ; * lisp/net/tramp-crypt.el: Improve commentary
cba30431ff Merge branch 'emacs-28' of git.savannah.gnu.org:/srv/git/e...
8f9993bb3f ; * src/buffer.c (syms_of_buffer) <mode-line-format>: Doc ...
fec4bb89f9 ; Fix typos (Bug#56550)
2022-07-19 06:30:56 +02:00
Gregory Heytings
1ff69cc744 Improve the heuristic for long lines detection.
* src/buffer.h (struct buffer_text): New 'unchanged_size' field.
(BUF_UNCHANGED_SIZE): New macro to access the field.

* src/buffer.c (Fget_buffer_create): Initialize the field.
(Fbuffer_swap_text): Handle it.

* src/xdisp.c (mark_window_display_accurate_1): Set the field.
(redisplay_window): Use the field for long lines detection.
2022-07-18 17:54:55 +02:00
Eli Zaretskii
8f9993bb3f ; * src/buffer.c (syms_of_buffer) <mode-line-format>: Doc fix. 2022-07-18 15:31:26 +03:00
Gregory Heytings
e7b5912b23 Improvements to long lines handling.
* src/buffer.h (struct buffer): New field 'long_line_optimizations_p'.

* src/buffer.c (syms_of_buffer): New variable 'long-line-threshold'.
(reset_buffer): Initialize the 'long_line_optimizations_p' field.
(Fbuffer_swap_text): Handle it.

* src/xdisp.c (redisplay_window): Set 'long_line_optimizations_p' when
a buffer contains long lines.
(init_iterator): Use 'long_line_optimizations_p'.
(get_narrowed_begv): Update.
(SET_WITH_NARROWED_BEGV): New macro.
(unwind_narrowed_begv): New internal function used by the new macro.
(back_to_previous_line_start, get_visually_first_element,
move_it_vertically_backward): Use the new macro.

* src/search.c (find_newline1): Make it externally visible.

* src/lisp.h: Make 'find_newline1' externally visible.

* src/dispextern.h (struct it): Update comment.  Remove the
'WITH_NARROWED_BEGV' macro.

* etc/NEWS: Mention the 'long-line-threshold' variable.
2022-07-16 21:13:33 +02:00
Lars Ingebrigtsen
f62e1f39be Fix buffer-stale-function fix
* src/buffer.c (Fmake_indirect_buffer): Kill the local
buffer-stale-function variable instead of setting it
buffer-locally to the default value.  This should have the same
effect, but is less confusing.
2022-07-12 14:39:52 +02:00
Lars Ingebrigtsen
b2e6e95581 Only reset buffer-local buffer-stale-function in make-indirect-buffer
* src/buffer.c (Fmake_indirect_buffer): Don't set the global
buffer-stale-function (bug#48348).
2022-07-11 16:05:08 +02:00
Gregory Heytings
60e51595c8 Revert commit 38b3780f6e. 2022-07-08 23:36:18 +02:00
Gregory Heytings
38b3780f6e Actually fix the long lines display bug (bug#56393).
* lisp/files.el (auto-narrow-mode): New minor mode.
(auto-narrow-pre-command-function, auto-narrow-post-command-function):
New auxiliary functions for the minor mode.
(auto-narrow-display-length, auto-narrow-widen-automatically): New
defcustoms for the minor mode.
(auto-narrow--widen-automatically, auto-narrow--isearch-widen-automatically,
auto-narrow--initialized): New internal variables for the minor mode.

* src/buffer.h (struct buffer): New internal variable for the minor mode.
(bset_auto_narrow__narrowing_state, BUFFER_AUTO_NARROWED_P): New
auxiliary functions.

* src/buffer.c (init_buffer_once, syms_of_buffer): New internal variable
for the minor mode. Update the docstring of mode-line-format.

* src/fileio.c (Finsert_file_contents): Detect whether the minor mode should
be entered when the buffer is displayed.
(syms_of_fileio): New defcustom for the minor mode.

* src/keyboard.c (syms_of_keyboard): New hook functions for the minor mode.
(command_loop_1): Execute the hook functions.

* src/xdisp.c (redisplay_window): Enter the minor mode when the buffer is
displayed.
(decode_mode_spec): Indicate when the minor mode is active
in the modeline.  Indicate the buffer position relative to the whole buffer.
(set_vertical_scroll_bar): Indicate the buffer position relative to the
whole buffer.
(syms_of_xdisp): Two new symbols.

* lisp/isearch.el (isearch-widen-automatically): New defcustom.
(isearch-search): Use the new defcustom.

* lisp/bindings.el (mode-line-modes): Do not propertize the indication
in the modeline when the new minor mode is active.

* etc/NEWS: Announce the new minor mode, and remove the unobsoletion
indication for 'longlines-mode'.

* lisp/longlines.el: Reobsolete longlines-mode.

* doc/emacs/display.texi (Auto-Narrowing): New section, describing the new
minor mode.
(Display): Entry for the new section.

* doc/emacs/trouble.texi (Long Lines): Remove the section.
(Lossage): Remove the entry for the Long Lines section.

* doc/emacs/emacs.texi (Top): Remove the entry for the Long Lines section.
2022-07-06 00:43:56 +02:00
Lars Ingebrigtsen
e193ea3c34 Allow `kill-buffer' query to save the buffer first
* lisp/loadup.el ("emacs-lisp/rmc"): Preload.

* lisp/simple.el (kill-buffer--possibly-save): New function to
offer to save the buffer before killing (bug#47075).

* src/buffer.c (Fkill_buffer): Call the new function to query the
user.
(syms_of_buffer): Define symbol.
2022-06-24 11:04:51 +02:00