diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 35 | ||||
| -rw-r--r-- | src/dispextern.h | 10 | ||||
| -rw-r--r-- | src/editfns.c | 11 | ||||
| -rw-r--r-- | src/keyboard.c | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 44 |
5 files changed, 92 insertions, 12 deletions
diff --git a/src/buffer.c b/src/buffer.c index d948aaa2662..ef7e6f18340 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5882,7 +5882,40 @@ this threshold. | |||
| 5882 | If nil, these display shortcuts will always remain disabled. | 5882 | If nil, these display shortcuts will always remain disabled. |
| 5883 | 5883 | ||
| 5884 | There is no reason to change that value except for debugging purposes. */); | 5884 | There is no reason to change that value except for debugging purposes. */); |
| 5885 | XSETFASTINT (Vlong_line_threshold, 10000); | 5885 | XSETFASTINT (Vlong_line_threshold, 50000); |
| 5886 | |||
| 5887 | DEFVAR_INT ("long-line-locked-narrowing-region-size", | ||
| 5888 | long_line_locked_narrowing_region_size, | ||
| 5889 | doc: /* Region size for locked narrowing in buffers with long lines. | ||
| 5890 | |||
| 5891 | This variable has effect only in buffers which contain one or more | ||
| 5892 | lines whose length is above `long-line-threshold', which see. For | ||
| 5893 | performance reasons, in such buffers, low-level hooks such as | ||
| 5894 | `fontification-functions' or `post-command-hook' are executed on a | ||
| 5895 | narrowed buffer, with a narrowing locked with `narrowing-lock'. This | ||
| 5896 | variable specifies the size of the narrowed region around point. | ||
| 5897 | |||
| 5898 | To disable that narrowing, set this variable to 0. | ||
| 5899 | |||
| 5900 | There is no reason to change that value except for debugging purposes. */); | ||
| 5901 | long_line_locked_narrowing_region_size = 500000; | ||
| 5902 | |||
| 5903 | DEFVAR_INT ("long-line-locked-narrowing-bol-search-limit", | ||
| 5904 | long_line_locked_narrowing_bol_search_limit, | ||
| 5905 | doc: /* Limit for beginning of line search in buffers with long lines. | ||
| 5906 | |||
| 5907 | This variable has effect only in buffers which contain one or more | ||
| 5908 | lines whose length is above `long-line-threshold', which see. For | ||
| 5909 | performance reasons, in such buffers, low-level hooks such as | ||
| 5910 | `fontification-functions' or `post-command-hook' are executed on a | ||
| 5911 | narrowed buffer, with a narrowing locked with `narrowing-lock'. The | ||
| 5912 | variable `long-line-locked-narrowing-region-size' specifies the size | ||
| 5913 | of the narrowed region around point. This variable, which should be a | ||
| 5914 | small integer, specifies the number of characters by which that region | ||
| 5915 | can be extended backwards to start it at the beginning of a line. | ||
| 5916 | |||
| 5917 | There is no reason to change that value except for debugging purposes. */); | ||
| 5918 | long_line_locked_narrowing_bol_search_limit = 128; | ||
| 5886 | 5919 | ||
| 5887 | DEFVAR_INT ("large-hscroll-threshold", large_hscroll_threshold, | 5920 | DEFVAR_INT ("large-hscroll-threshold", large_hscroll_threshold, |
| 5888 | doc: /* Horizontal scroll of truncated lines above which to use redisplay shortcuts. | 5921 | doc: /* Horizontal scroll of truncated lines above which to use redisplay shortcuts. |
diff --git a/src/dispextern.h b/src/dispextern.h index 2afbdeabaab..df6134e68f0 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2342,6 +2342,14 @@ struct it | |||
| 2342 | optimize display. */ | 2342 | optimize display. */ |
| 2343 | ptrdiff_t narrowed_zv; | 2343 | ptrdiff_t narrowed_zv; |
| 2344 | 2344 | ||
| 2345 | /* Begin position of the buffer for the locked narrowing around | ||
| 2346 | low-level hooks. */ | ||
| 2347 | ptrdiff_t locked_narrowing_begv; | ||
| 2348 | |||
| 2349 | /* End position of the buffer for the locked narrowing around | ||
| 2350 | low-level hooks. */ | ||
| 2351 | ptrdiff_t locked_narrowing_zv; | ||
| 2352 | |||
| 2345 | /* C string to iterate over. Non-null means get characters from | 2353 | /* C string to iterate over. Non-null means get characters from |
| 2346 | this string, otherwise characters are read from current_buffer | 2354 | this string, otherwise characters are read from current_buffer |
| 2347 | or it->string. */ | 2355 | or it->string. */ |
| @@ -3405,6 +3413,8 @@ void init_iterator (struct it *, struct window *, ptrdiff_t, | |||
| 3405 | ptrdiff_t get_narrowed_begv (struct window *, ptrdiff_t); | 3413 | ptrdiff_t get_narrowed_begv (struct window *, ptrdiff_t); |
| 3406 | ptrdiff_t get_narrowed_zv (struct window *, ptrdiff_t); | 3414 | ptrdiff_t get_narrowed_zv (struct window *, ptrdiff_t); |
| 3407 | ptrdiff_t get_closer_narrowed_begv (struct window *, ptrdiff_t); | 3415 | ptrdiff_t get_closer_narrowed_begv (struct window *, ptrdiff_t); |
| 3416 | ptrdiff_t get_locked_narrowing_begv (ptrdiff_t); | ||
| 3417 | ptrdiff_t get_locked_narrowing_zv (ptrdiff_t); | ||
| 3408 | void init_iterator_to_row_start (struct it *, struct window *, | 3418 | void init_iterator_to_row_start (struct it *, struct window *, |
| 3409 | struct glyph_row *); | 3419 | struct glyph_row *); |
| 3410 | void start_display (struct it *, struct window *, struct text_pos); | 3420 | void start_display (struct it *, struct window *, struct text_pos); |
diff --git a/src/editfns.c b/src/editfns.c index f73331fb53c..e6b66209b8b 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2659,7 +2659,7 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region, | |||
| 2659 | the (uninterned) Qoutermost_narrowing tag and records the narrowing | 2659 | the (uninterned) Qoutermost_narrowing tag and records the narrowing |
| 2660 | bounds that were set by the user and that are visible on display. | 2660 | bounds that were set by the user and that are visible on display. |
| 2661 | This alist is used internally by narrow-to-region, widen, | 2661 | This alist is used internally by narrow-to-region, widen, |
| 2662 | narrowing-lock and narrowing-unlock. */ | 2662 | narrowing-lock, narrowing-unlock and save-restriction. */ |
| 2663 | static Lisp_Object narrowing_locks; | 2663 | static Lisp_Object narrowing_locks; |
| 2664 | 2664 | ||
| 2665 | /* Retrieve one of the BEGV/ZV bounds of a narrowing in BUF from the | 2665 | /* Retrieve one of the BEGV/ZV bounds of a narrowing in BUF from the |
| @@ -3061,11 +3061,12 @@ DEFUN ("save-restriction", Fsave_restriction, Ssave_restriction, 0, UNEVALLED, 0 | |||
| 3061 | doc: /* Execute BODY, saving and restoring current buffer's restrictions. | 3061 | doc: /* Execute BODY, saving and restoring current buffer's restrictions. |
| 3062 | The buffer's restrictions make parts of the beginning and end invisible. | 3062 | The buffer's restrictions make parts of the beginning and end invisible. |
| 3063 | \(They are set up with `narrow-to-region' and eliminated with `widen'.) | 3063 | \(They are set up with `narrow-to-region' and eliminated with `widen'.) |
| 3064 | This special form, `save-restriction', saves the current buffer's restrictions | 3064 | This special form, `save-restriction', saves the current buffer's |
| 3065 | when it is entered, and restores them when it is exited. | 3065 | restrictions, as well as their locks if they have been locked with |
| 3066 | `narrowing-lock', when it is entered, and restores them when it is exited. | ||
| 3066 | So any `narrow-to-region' within BODY lasts only until the end of the form. | 3067 | So any `narrow-to-region' within BODY lasts only until the end of the form. |
| 3067 | The old restrictions settings are restored | 3068 | The old restrictions settings are restored even in case of abnormal exit |
| 3068 | even in case of abnormal exit (throw or error). | 3069 | \(throw or error). |
| 3069 | 3070 | ||
| 3070 | The value returned is the value of the last form in BODY. | 3071 | The value returned is the value of the last form in BODY. |
| 3071 | 3072 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 4b35a044eb0..cb308f5bfc1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1911,8 +1911,8 @@ safe_run_hooks_maybe_narrowed (Lisp_Object hook, struct window *w) | |||
| 1911 | specbind (Qinhibit_quit, Qt); | 1911 | specbind (Qinhibit_quit, Qt); |
| 1912 | 1912 | ||
| 1913 | if (current_buffer->long_line_optimizations_p) | 1913 | if (current_buffer->long_line_optimizations_p) |
| 1914 | narrow_to_region_locked (make_fixnum (get_narrowed_begv (w, PT)), | 1914 | narrow_to_region_locked (make_fixnum (get_locked_narrowing_begv (PT)), |
| 1915 | make_fixnum (get_narrowed_zv (w, PT)), | 1915 | make_fixnum (get_locked_narrowing_zv (PT)), |
| 1916 | hook); | 1916 | hook); |
| 1917 | 1917 | ||
| 1918 | run_hook_with_args (2, ((Lisp_Object []) {hook, hook}), | 1918 | run_hook_with_args (2, ((Lisp_Object []) {hook, hook}), |
diff --git a/src/xdisp.c b/src/xdisp.c index 658ce57b7ea..430201874c3 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -3533,6 +3533,34 @@ get_closer_narrowed_begv (struct window *w, ptrdiff_t pos) | |||
| 3533 | return max ((pos / len - 1) * len, BEGV); | 3533 | return max ((pos / len - 1) * len, BEGV); |
| 3534 | } | 3534 | } |
| 3535 | 3535 | ||
| 3536 | ptrdiff_t | ||
| 3537 | get_locked_narrowing_begv (ptrdiff_t pos) | ||
| 3538 | { | ||
| 3539 | if (long_line_locked_narrowing_region_size == 0) | ||
| 3540 | return BEGV; | ||
| 3541 | int begv; | ||
| 3542 | int len = long_line_locked_narrowing_region_size / 2; | ||
| 3543 | begv = max (pos - len, BEGV); | ||
| 3544 | int limit = long_line_locked_narrowing_bol_search_limit; | ||
| 3545 | while (limit) | ||
| 3546 | { | ||
| 3547 | if (begv == BEGV || FETCH_BYTE (CHAR_TO_BYTE (begv) - 1) == '\n') | ||
| 3548 | return begv; | ||
| 3549 | begv--; | ||
| 3550 | limit--; | ||
| 3551 | } | ||
| 3552 | return begv; | ||
| 3553 | } | ||
| 3554 | |||
| 3555 | ptrdiff_t | ||
| 3556 | get_locked_narrowing_zv (ptrdiff_t pos) | ||
| 3557 | { | ||
| 3558 | if (long_line_locked_narrowing_region_size == 0) | ||
| 3559 | return ZV; | ||
| 3560 | int len = long_line_locked_narrowing_region_size / 2; | ||
| 3561 | return min (pos + len, ZV); | ||
| 3562 | } | ||
| 3563 | |||
| 3536 | static void | 3564 | static void |
| 3537 | unwind_narrowed_begv (Lisp_Object point_min) | 3565 | unwind_narrowed_begv (Lisp_Object point_min) |
| 3538 | { | 3566 | { |
| @@ -4368,13 +4396,13 @@ handle_fontified_prop (struct it *it) | |||
| 4368 | 4396 | ||
| 4369 | if (current_buffer->long_line_optimizations_p) | 4397 | if (current_buffer->long_line_optimizations_p) |
| 4370 | { | 4398 | { |
| 4371 | ptrdiff_t begv = it->narrowed_begv; | 4399 | ptrdiff_t begv = it->locked_narrowing_begv; |
| 4372 | ptrdiff_t zv = it->narrowed_zv; | 4400 | ptrdiff_t zv = it->locked_narrowing_zv; |
| 4373 | ptrdiff_t charpos = IT_CHARPOS (*it); | 4401 | ptrdiff_t charpos = IT_CHARPOS (*it); |
| 4374 | if (charpos < begv || charpos > zv) | 4402 | if (charpos < begv || charpos > zv) |
| 4375 | { | 4403 | { |
| 4376 | begv = get_narrowed_begv (it->w, charpos); | 4404 | begv = get_locked_narrowing_begv (charpos); |
| 4377 | zv = get_narrowed_zv (it->w, charpos); | 4405 | zv = get_locked_narrowing_zv (charpos); |
| 4378 | } | 4406 | } |
| 4379 | narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), | 4407 | narrow_to_region_locked (make_fixnum (begv), make_fixnum (zv), |
| 4380 | Qfontification_functions); | 4408 | Qfontification_functions); |
| @@ -7435,12 +7463,20 @@ reseat (struct it *it, struct text_pos pos, bool force_p) | |||
| 7435 | { | 7463 | { |
| 7436 | it->narrowed_begv = get_narrowed_begv (it->w, window_point (it->w)); | 7464 | it->narrowed_begv = get_narrowed_begv (it->w, window_point (it->w)); |
| 7437 | it->narrowed_zv = get_narrowed_zv (it->w, window_point (it->w)); | 7465 | it->narrowed_zv = get_narrowed_zv (it->w, window_point (it->w)); |
| 7466 | it->locked_narrowing_begv | ||
| 7467 | = get_locked_narrowing_begv (window_point (it->w)); | ||
| 7468 | it->locked_narrowing_zv | ||
| 7469 | = get_locked_narrowing_zv (window_point (it->w)); | ||
| 7438 | } | 7470 | } |
| 7439 | else if ((pos.charpos < it->narrowed_begv || pos.charpos > it->narrowed_zv) | 7471 | else if ((pos.charpos < it->narrowed_begv || pos.charpos > it->narrowed_zv) |
| 7440 | && (!redisplaying_p || it->line_wrap == TRUNCATE)) | 7472 | && (!redisplaying_p || it->line_wrap == TRUNCATE)) |
| 7441 | { | 7473 | { |
| 7442 | it->narrowed_begv = get_narrowed_begv (it->w, pos.charpos); | 7474 | it->narrowed_begv = get_narrowed_begv (it->w, pos.charpos); |
| 7443 | it->narrowed_zv = get_narrowed_zv (it->w, pos.charpos); | 7475 | it->narrowed_zv = get_narrowed_zv (it->w, pos.charpos); |
| 7476 | it->locked_narrowing_begv | ||
| 7477 | = get_locked_narrowing_begv (window_point (it->w)); | ||
| 7478 | it->locked_narrowing_zv | ||
| 7479 | = get_locked_narrowing_zv (window_point (it->w)); | ||
| 7444 | } | 7480 | } |
| 7445 | } | 7481 | } |
| 7446 | 7482 | ||