diff options
| author | Gregory Heytings | 2022-07-06 10:04:38 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2022-07-06 12:06:53 +0200 |
| commit | eb6d2fb58da56583490b18f4bfd705844b42180f (patch) | |
| tree | 15caaaf61ce6562daf5c1411c0f666b76b6b1af7 /src | |
| parent | 38b3780f6e1bdcbb2a9a7dde76fa55da36e2774f (diff) | |
| download | emacs-eb6d2fb58da56583490b18f4bfd705844b42180f.tar.gz emacs-eb6d2fb58da56583490b18f4bfd705844b42180f.zip | |
Various improvements to auto-narrow mode.
* lisp/files.el (auto-narrow-display-length): Improve docstring.
(auto-narrow-widen-automatically): Add 'undo' to the command list.
(auto-narrow-hook): New defcustom.
(auto-narrow-pre-command-function, auto-narrow-post-command-function):
Move initialization code.
(auto-narrow-mode): Do not make the 'auto-narrow-mode' permanent local
anymore.
* lisp/font-lock.el (turn-off-font-lock-mode): New convenience function.
* src/xdisp.c (set_vertical_scroll_bar): Fix typo.
(redisplay_window): Use the new convenience function.
* src/buffer.h (BUFFER_NEEDS_AUTO_NARROWING_P,
BUFFER_AUTO_NARROWED_NON_NARROWED_P): Two new convenience functions.
* src/window.c (Frecenter): Do not recenter auto-narrowed buffers that
are not actually narrowed.
* etc/NEWS: Improvement.
* doc/emacs/display.texi (Auto-Narrowing): Improvement.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.h | 16 | ||||
| -rw-r--r-- | src/window.c | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/src/buffer.h b/src/buffer.h index 19faa844e02..84492737b0e 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1120,12 +1120,28 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b) | |||
| 1120 | } | 1120 | } |
| 1121 | } | 1121 | } |
| 1122 | 1122 | ||
| 1123 | /* Check the state of auto-narrowed buffers. */ | ||
| 1124 | |||
| 1125 | INLINE bool | ||
| 1126 | BUFFER_NEEDS_AUTO_NARROWING_P (struct buffer *b) | ||
| 1127 | { | ||
| 1128 | return EQ (BVAR (b, auto_narrow__narrowing_state), Qneeded); | ||
| 1129 | } | ||
| 1130 | |||
| 1123 | INLINE bool | 1131 | INLINE bool |
| 1124 | BUFFER_AUTO_NARROWED_P (struct buffer *b) | 1132 | BUFFER_AUTO_NARROWED_P (struct buffer *b) |
| 1125 | { | 1133 | { |
| 1126 | return EQ (BVAR (b, auto_narrow__narrowing_state), Qauto); | 1134 | return EQ (BVAR (b, auto_narrow__narrowing_state), Qauto); |
| 1127 | } | 1135 | } |
| 1128 | 1136 | ||
| 1137 | INLINE bool | ||
| 1138 | BUFFER_AUTO_NARROWED_NON_NARROWED_P (struct buffer *b) | ||
| 1139 | { | ||
| 1140 | return BUFFER_AUTO_NARROWED_P (b) | ||
| 1141 | && BUF_BEG (b) == BUF_BEGV (b) | ||
| 1142 | && BUF_Z (b) == BUF_ZV (b); | ||
| 1143 | } | ||
| 1144 | |||
| 1129 | /* This structure holds the default values of the buffer-local variables | 1145 | /* This structure holds the default values of the buffer-local variables |
| 1130 | that have special slots in each buffer. | 1146 | that have special slots in each buffer. |
| 1131 | The default value occupies the same slot in this structure | 1147 | The default value occupies the same slot in this structure |
diff --git a/src/window.c b/src/window.c index af463b90ce6..218b3e6a4f8 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -6557,6 +6557,11 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 6557 | if (buf != current_buffer) | 6557 | if (buf != current_buffer) |
| 6558 | error ("`recenter'ing a window that does not display current-buffer."); | 6558 | error ("`recenter'ing a window that does not display current-buffer."); |
| 6559 | 6559 | ||
| 6560 | /* Refuse to recenter auto-narrowed buffers that are not actually narrowed, | ||
| 6561 | as this can be very slow. */ | ||
| 6562 | if (BUFFER_AUTO_NARROWED_NON_NARROWED_P (buf)) | ||
| 6563 | return Qnil; | ||
| 6564 | |||
| 6560 | /* If redisplay is suppressed due to an error, try again. */ | 6565 | /* If redisplay is suppressed due to an error, try again. */ |
| 6561 | buf->display_error_modiff = 0; | 6566 | buf->display_error_modiff = 0; |
| 6562 | 6567 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index be51a0eb136..7821c120ca0 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -18872,7 +18872,7 @@ set_vertical_scroll_bar (struct window *w) | |||
| 18872 | && NILP (echo_area_buffer[0]))) | 18872 | && NILP (echo_area_buffer[0]))) |
| 18873 | { | 18873 | { |
| 18874 | struct buffer *buf = XBUFFER (w->contents); | 18874 | struct buffer *buf = XBUFFER (w->contents); |
| 18875 | if (! BUFFER_AUTO_NARROWED_P (current_buffer)) | 18875 | if (! BUFFER_AUTO_NARROWED_P (buf)) |
| 18876 | { | 18876 | { |
| 18877 | whole = BUF_ZV (buf) - BUF_BEGV (buf); | 18877 | whole = BUF_ZV (buf) - BUF_BEGV (buf); |
| 18878 | start = marker_position (w->start) - BUF_BEGV (buf); | 18878 | start = marker_position (w->start) - BUF_BEGV (buf); |
| @@ -19142,7 +19142,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 19142 | variables. */ | 19142 | variables. */ |
| 19143 | set_buffer_internal_1 (XBUFFER (w->contents)); | 19143 | set_buffer_internal_1 (XBUFFER (w->contents)); |
| 19144 | 19144 | ||
| 19145 | if (EQ (BVAR (current_buffer, auto_narrow__narrowing_state), Qneeded)) | 19145 | if (BUFFER_NEEDS_AUTO_NARROWING_P (current_buffer)) |
| 19146 | { | 19146 | { |
| 19147 | safe_call (1, Qauto_narrow_mode); | 19147 | safe_call (1, Qauto_narrow_mode); |
| 19148 | /* Normally set by auto-narrow-mode, set it here anyway as a safety measure. */ | 19148 | /* Normally set by auto-narrow-mode, set it here anyway as a safety measure. */ |