diff options
| author | Gregory Heytings | 2022-07-06 00:43:56 +0200 |
|---|---|---|
| committer | Gregory Heytings | 2022-07-06 00:43:56 +0200 |
| commit | 38b3780f6e1bdcbb2a9a7dde76fa55da36e2774f (patch) | |
| tree | d0642db75c1bfbbe11e50d8f48511a9f1ea94f5a /src | |
| parent | 0463368a7b70dfc7914e5c5577c9690f8d0c4f7c (diff) | |
| download | emacs-38b3780f6e1bdcbb2a9a7dde76fa55da36e2774f.tar.gz emacs-38b3780f6e1bdcbb2a9a7dde76fa55da36e2774f.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 9 | ||||
| -rw-r--r-- | src/buffer.h | 14 | ||||
| -rw-r--r-- | src/fileio.c | 21 | ||||
| -rw-r--r-- | src/keyboard.c | 28 | ||||
| -rw-r--r-- | src/xdisp.c | 122 |
5 files changed, 164 insertions, 30 deletions
diff --git a/src/buffer.c b/src/buffer.c index 509ce51b55e..d5b4292a21d 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5276,6 +5276,9 @@ init_buffer_once (void) | |||
| 5276 | XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx; | 5276 | XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx; |
| 5277 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx; | 5277 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx; |
| 5278 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; | 5278 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; |
| 5279 | XSETFASTINT (BVAR (&buffer_local_flags, auto_narrow__narrowing_state), idx); | ||
| 5280 | /* Make this one a permanent local. */ | ||
| 5281 | buffer_permanent_local_flags[idx++] = 1; | ||
| 5279 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; | 5282 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; |
| 5280 | 5283 | ||
| 5281 | /* buffer_local_flags contains no pointers, so it's safe to treat it | 5284 | /* buffer_local_flags contains no pointers, so it's safe to treat it |
| @@ -5662,7 +5665,7 @@ A string is printed verbatim in the mode line except for %-constructs: | |||
| 5662 | %p -- print percent of buffer above top of window, or Top, Bot or All. | 5665 | %p -- print percent of buffer above top of window, or Top, Bot or All. |
| 5663 | %P -- print percent of buffer above bottom of window, perhaps plus Top, | 5666 | %P -- print percent of buffer above bottom of window, perhaps plus Top, |
| 5664 | or print Bottom or All. | 5667 | or print Bottom or All. |
| 5665 | %n -- print Narrow if appropriate. | 5668 | %n -- print Narrow or Auto-Narrow if appropriate. |
| 5666 | %t -- visited file is text or binary (if OS supports this distinction). | 5669 | %t -- visited file is text or binary (if OS supports this distinction). |
| 5667 | %z -- print mnemonics of keyboard, terminal, and buffer coding systems. | 5670 | %z -- print mnemonics of keyboard, terminal, and buffer coding systems. |
| 5668 | %Z -- like %z, but including the end-of-line format. | 5671 | %Z -- like %z, but including the end-of-line format. |
| @@ -6363,6 +6366,10 @@ see `display-graphic-p'. | |||
| 6363 | If value is a floating point number, it specifies the spacing relative | 6366 | If value is a floating point number, it specifies the spacing relative |
| 6364 | to the default frame line height. A value of nil means add no extra space. */); | 6367 | to the default frame line height. A value of nil means add no extra space. */); |
| 6365 | 6368 | ||
| 6369 | DEFVAR_PER_BUFFER ("auto-narrow--narrowing-state", | ||
| 6370 | &BVAR (current_buffer, auto_narrow__narrowing_state), Qnil, | ||
| 6371 | doc: /* Internal variable used by `auto-narrow-mode'. */); | ||
| 6372 | |||
| 6366 | DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", | 6373 | DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", |
| 6367 | &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil, | 6374 | &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil, |
| 6368 | doc: /* Non-nil means show a cursor in non-selected windows. | 6375 | doc: /* Non-nil means show a cursor in non-selected windows. |
diff --git a/src/buffer.h b/src/buffer.h index 135eaf72d30..19faa844e02 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -561,6 +561,9 @@ struct buffer | |||
| 561 | in the display of this buffer. */ | 561 | in the display of this buffer. */ |
| 562 | Lisp_Object extra_line_spacing_; | 562 | Lisp_Object extra_line_spacing_; |
| 563 | 563 | ||
| 564 | /* Narrowing state when auto-narrow mode is in effect. */ | ||
| 565 | Lisp_Object auto_narrow__narrowing_state_; | ||
| 566 | |||
| 564 | /* Cursor type to display in non-selected windows. | 567 | /* Cursor type to display in non-selected windows. |
| 565 | t means to use hollow box cursor. | 568 | t means to use hollow box cursor. |
| 566 | See `cursor-type' for other values. */ | 569 | See `cursor-type' for other values. */ |
| @@ -832,6 +835,11 @@ bset_width_table (struct buffer *b, Lisp_Object val) | |||
| 832 | { | 835 | { |
| 833 | b->width_table_ = val; | 836 | b->width_table_ = val; |
| 834 | } | 837 | } |
| 838 | INLINE void | ||
| 839 | bset_auto_narrow__narrowing_state (struct buffer *b, Lisp_Object val) | ||
| 840 | { | ||
| 841 | b->auto_narrow__narrowing_state_ = val; | ||
| 842 | } | ||
| 835 | 843 | ||
| 836 | /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return | 844 | /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return |
| 837 | the max (resp. min) p such that | 845 | the max (resp. min) p such that |
| @@ -1112,6 +1120,12 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b) | |||
| 1112 | } | 1120 | } |
| 1113 | } | 1121 | } |
| 1114 | 1122 | ||
| 1123 | INLINE bool | ||
| 1124 | BUFFER_AUTO_NARROWED_P (struct buffer *b) | ||
| 1125 | { | ||
| 1126 | return EQ (BVAR (b, auto_narrow__narrowing_state), Qauto); | ||
| 1127 | } | ||
| 1128 | |||
| 1115 | /* This structure holds the default values of the buffer-local variables | 1129 | /* This structure holds the default values of the buffer-local variables |
| 1116 | that have special slots in each buffer. | 1130 | that have special slots in each buffer. |
| 1117 | The default value occupies the same slot in this structure | 1131 | The default value occupies the same slot in this structure |
diff --git a/src/fileio.c b/src/fileio.c index 10d4b8bc15e..bb6f73fe39a 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4997,6 +4997,16 @@ by calling `format-decode', which see. */) | |||
| 4997 | Otherwise start with an empty undo_list. */ | 4997 | Otherwise start with an empty undo_list. */ |
| 4998 | bset_undo_list (current_buffer, EQ (old_undo, Qt) ? Qt : Qnil); | 4998 | bset_undo_list (current_buffer, EQ (old_undo, Qt) ? Qt : Qnil); |
| 4999 | 4999 | ||
| 5000 | if (!noninteractive | ||
| 5001 | && !NILP (Vauto_narrow_long_line_threshold) | ||
| 5002 | && !NILP (CALLN | ||
| 5003 | (Fgtr, | ||
| 5004 | Fcar (Fcdr (Fbuffer_line_statistics (Fcurrent_buffer ()))), | ||
| 5005 | Vauto_narrow_long_line_threshold))) | ||
| 5006 | { | ||
| 5007 | bset_auto_narrow__narrowing_state (current_buffer, Qneeded); | ||
| 5008 | } | ||
| 5009 | |||
| 5000 | unbind_to (count1, Qnil); | 5010 | unbind_to (count1, Qnil); |
| 5001 | } | 5011 | } |
| 5002 | 5012 | ||
| @@ -6638,6 +6648,17 @@ This includes interactive calls to `delete-file' and | |||
| 6638 | /* Lisp function for recursively deleting directories. */ | 6648 | /* Lisp function for recursively deleting directories. */ |
| 6639 | DEFSYM (Qdelete_directory, "delete-directory"); | 6649 | DEFSYM (Qdelete_directory, "delete-directory"); |
| 6640 | 6650 | ||
| 6651 | DEFVAR_LISP ("auto-narrow-long-line-threshold", | ||
| 6652 | Vauto_narrow_long_line_threshold, | ||
| 6653 | doc: /* Line length above which `auto-narrow-mode' is entered. | ||
| 6654 | When non-nil, and when a file with one or more lines longer than | ||
| 6655 | `auto-narrow-long-line-threshold' is opened or inserted in a buffer, | ||
| 6656 | `auto-narrow-mode' is automatically enabled. | ||
| 6657 | When nil, `auto-narrow-mode' is disabled. */); | ||
| 6658 | Vauto_narrow_long_line_threshold = Qnil; | ||
| 6659 | |||
| 6660 | DEFSYM (Qauto_narrow_mode, "auto-narrow-mode"); | ||
| 6661 | |||
| 6641 | DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); | 6662 | DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); |
| 6642 | DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); | 6663 | DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); |
| 6643 | 6664 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index bed8307b6f2..38aa64774dc 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1290,6 +1290,9 @@ command_loop_1 (void) | |||
| 1290 | 1290 | ||
| 1291 | if (NILP (Vmemory_full)) | 1291 | if (NILP (Vmemory_full)) |
| 1292 | { | 1292 | { |
| 1293 | if (!NILP (Vauto_narrow_post_command_function) && !NILP (Vrun_hooks)) | ||
| 1294 | safe_run_hooks (Qauto_narrow_post_command_function); | ||
| 1295 | |||
| 1293 | /* Make sure this hook runs after commands that get errors and | 1296 | /* Make sure this hook runs after commands that get errors and |
| 1294 | throw to top level. */ | 1297 | throw to top level. */ |
| 1295 | /* Note that the value cell will never directly contain nil | 1298 | /* Note that the value cell will never directly contain nil |
| @@ -1472,6 +1475,8 @@ command_loop_1 (void) | |||
| 1472 | Vreal_this_command = cmd; | 1475 | Vreal_this_command = cmd; |
| 1473 | safe_run_hooks (Qpre_command_hook); | 1476 | safe_run_hooks (Qpre_command_hook); |
| 1474 | 1477 | ||
| 1478 | safe_run_hooks (Qauto_narrow_pre_command_function); | ||
| 1479 | |||
| 1475 | already_adjusted = 0; | 1480 | already_adjusted = 0; |
| 1476 | 1481 | ||
| 1477 | if (NILP (Vthis_command)) | 1482 | if (NILP (Vthis_command)) |
| @@ -1522,6 +1527,8 @@ command_loop_1 (void) | |||
| 1522 | } | 1527 | } |
| 1523 | kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg); | 1528 | kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg); |
| 1524 | 1529 | ||
| 1530 | safe_run_hooks (Qauto_narrow_post_command_function); | ||
| 1531 | |||
| 1525 | safe_run_hooks (Qpost_command_hook); | 1532 | safe_run_hooks (Qpost_command_hook); |
| 1526 | 1533 | ||
| 1527 | /* If displaying a message, resize the echo area window to fit | 1534 | /* If displaying a message, resize the echo area window to fit |
| @@ -12040,6 +12047,11 @@ syms_of_keyboard (void) | |||
| 12040 | DEFSYM (Qpre_command_hook, "pre-command-hook"); | 12047 | DEFSYM (Qpre_command_hook, "pre-command-hook"); |
| 12041 | DEFSYM (Qpost_command_hook, "post-command-hook"); | 12048 | DEFSYM (Qpost_command_hook, "post-command-hook"); |
| 12042 | 12049 | ||
| 12050 | DEFSYM (Qauto_narrow_pre_command_function, | ||
| 12051 | "auto-narrow-pre-command-function"); | ||
| 12052 | DEFSYM (Qauto_narrow_post_command_function, | ||
| 12053 | "auto-narrow-post-command-function"); | ||
| 12054 | |||
| 12043 | DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); | 12055 | DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); |
| 12044 | DEFSYM (Qundo_auto__undoably_changed_buffers, | 12056 | DEFSYM (Qundo_auto__undoably_changed_buffers, |
| 12045 | "undo-auto--undoably-changed-buffers"); | 12057 | "undo-auto--undoably-changed-buffers"); |
| @@ -12604,6 +12616,22 @@ avoid making Emacs unresponsive while the user types. | |||
| 12604 | See also `pre-command-hook'. */); | 12616 | See also `pre-command-hook'. */); |
| 12605 | Vpost_command_hook = Qnil; | 12617 | Vpost_command_hook = Qnil; |
| 12606 | 12618 | ||
| 12619 | DEFVAR_LISP ("auto-narrow-pre-command-function", | ||
| 12620 | Vauto_narrow_pre_command_function, | ||
| 12621 | doc: /* Function executed before each command is executed in `auto-narrow-mode'. | ||
| 12622 | If non-nil, and `auto-narrow-mode' is enabled, the function is | ||
| 12623 | called before each command is executed, after `pre-command-hook'. | ||
| 12624 | It is called without arguments. */); | ||
| 12625 | Vauto_narrow_pre_command_function = Qnil; | ||
| 12626 | |||
| 12627 | DEFVAR_LISP ("auto-narrow-post-command-function", | ||
| 12628 | Vauto_narrow_post_command_function, | ||
| 12629 | doc: /* Function executed after each command is executed in `auto-narrow-mode'. | ||
| 12630 | If non-nil, and `auto-narrow-mode' is enabled, the function is | ||
| 12631 | called after each command is executed, before `post-command-hook'. | ||
| 12632 | It is called without arguments. */); | ||
| 12633 | Vauto_narrow_post_command_function = Qnil; | ||
| 12634 | |||
| 12607 | #if 0 | 12635 | #if 0 |
| 12608 | DEFVAR_LISP ("echo-area-clear-hook", ..., | 12636 | DEFVAR_LISP ("echo-area-clear-hook", ..., |
| 12609 | doc: /* Normal hook run when clearing the echo area. */); | 12637 | doc: /* Normal hook run when clearing the echo area. */); |
diff --git a/src/xdisp.c b/src/xdisp.c index 4089525e10f..be51a0eb136 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -18872,11 +18872,20 @@ 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 | whole = BUF_ZV (buf) - BUF_BEGV (buf); | 18875 | if (! BUFFER_AUTO_NARROWED_P (current_buffer)) |
| 18876 | start = marker_position (w->start) - BUF_BEGV (buf); | 18876 | { |
| 18877 | /* I don't think this is guaranteed to be right. For the | 18877 | whole = BUF_ZV (buf) - BUF_BEGV (buf); |
| 18878 | moment, we'll pretend it is. */ | 18878 | start = marker_position (w->start) - BUF_BEGV (buf); |
| 18879 | end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf); | 18879 | /* I don't think this is guaranteed to be right. For the |
| 18880 | moment, we'll pretend it is. */ | ||
| 18881 | end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf); | ||
| 18882 | } | ||
| 18883 | else | ||
| 18884 | { | ||
| 18885 | whole = BUF_Z (buf) - BUF_BEG (buf); | ||
| 18886 | start = marker_position (w->start) - BUF_BEG (buf); | ||
| 18887 | end = BUF_Z (buf) - w->window_end_pos - BUF_BEG (buf); | ||
| 18888 | } | ||
| 18880 | 18889 | ||
| 18881 | if (end < start) | 18890 | if (end < start) |
| 18882 | end = start; | 18891 | end = start; |
| @@ -19133,6 +19142,14 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 19133 | variables. */ | 19142 | variables. */ |
| 19134 | set_buffer_internal_1 (XBUFFER (w->contents)); | 19143 | set_buffer_internal_1 (XBUFFER (w->contents)); |
| 19135 | 19144 | ||
| 19145 | if (EQ (BVAR (current_buffer, auto_narrow__narrowing_state), Qneeded)) | ||
| 19146 | { | ||
| 19147 | safe_call (1, Qauto_narrow_mode); | ||
| 19148 | /* Normally set by auto-narrow-mode, set it here anyway as a safety measure. */ | ||
| 19149 | bset_auto_narrow__narrowing_state (current_buffer, Qauto); | ||
| 19150 | message1 ("Auto-Narrow mode enabled in current buffer"); | ||
| 19151 | } | ||
| 19152 | |||
| 19136 | current_matrix_up_to_date_p | 19153 | current_matrix_up_to_date_p |
| 19137 | = (w->window_end_valid | 19154 | = (w->window_end_valid |
| 19138 | && !current_buffer->clip_changed | 19155 | && !current_buffer->clip_changed |
| @@ -27667,7 +27684,12 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27667 | 27684 | ||
| 27668 | case 'n': | 27685 | case 'n': |
| 27669 | if (BUF_BEGV (b) > BUF_BEG (b) || BUF_ZV (b) < BUF_Z (b)) | 27686 | if (BUF_BEGV (b) > BUF_BEG (b) || BUF_ZV (b) < BUF_Z (b)) |
| 27670 | return " Narrow"; | 27687 | { |
| 27688 | if (! BUFFER_AUTO_NARROWED_P (b)) | ||
| 27689 | return " Narrow"; | ||
| 27690 | else | ||
| 27691 | return " Auto-Narrow"; | ||
| 27692 | } | ||
| 27671 | break; | 27693 | break; |
| 27672 | 27694 | ||
| 27673 | /* Display the "degree of travel" of the window through the buffer. */ | 27695 | /* Display the "degree of travel" of the window through the buffer. */ |
| @@ -27675,17 +27697,27 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27675 | { | 27697 | { |
| 27676 | ptrdiff_t toppos = marker_position (w->start); | 27698 | ptrdiff_t toppos = marker_position (w->start); |
| 27677 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; | 27699 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; |
| 27678 | ptrdiff_t begv = BUF_BEGV (b); | 27700 | ptrdiff_t beg, z; |
| 27679 | ptrdiff_t zv = BUF_ZV (b); | ||
| 27680 | 27701 | ||
| 27681 | if (zv <= botpos) | 27702 | if (! BUFFER_AUTO_NARROWED_P (b)) |
| 27682 | return toppos <= begv ? "All" : "Bottom"; | 27703 | { |
| 27683 | else if (toppos <= begv) | 27704 | beg = BUF_BEGV (b); |
| 27705 | z = BUF_ZV (b); | ||
| 27706 | } | ||
| 27707 | else | ||
| 27708 | { | ||
| 27709 | beg = BUF_BEG (b); | ||
| 27710 | z = BUF_Z (b); | ||
| 27711 | } | ||
| 27712 | |||
| 27713 | if (z <= botpos) | ||
| 27714 | return toppos <= beg ? "All" : "Bottom"; | ||
| 27715 | else if (toppos <= beg) | ||
| 27684 | return "Top"; | 27716 | return "Top"; |
| 27685 | else | 27717 | else |
| 27686 | { | 27718 | { |
| 27687 | sprintf (decode_mode_spec_buf, "%2d%%", | 27719 | sprintf (decode_mode_spec_buf, "%2d%%", |
| 27688 | percent99 (toppos - begv, (toppos - begv) + (zv - botpos))); | 27720 | percent99 (toppos - beg, (toppos - beg) + (z - botpos))); |
| 27689 | return decode_mode_spec_buf; | 27721 | return decode_mode_spec_buf; |
| 27690 | } | 27722 | } |
| 27691 | } | 27723 | } |
| @@ -27694,17 +27726,27 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27694 | case 'p': | 27726 | case 'p': |
| 27695 | { | 27727 | { |
| 27696 | ptrdiff_t pos = marker_position (w->start); | 27728 | ptrdiff_t pos = marker_position (w->start); |
| 27697 | ptrdiff_t begv = BUF_BEGV (b); | 27729 | ptrdiff_t beg, z; |
| 27698 | ptrdiff_t zv = BUF_ZV (b); | ||
| 27699 | 27730 | ||
| 27700 | if (w->window_end_pos <= BUF_Z (b) - zv) | 27731 | if (! BUFFER_AUTO_NARROWED_P (b)) |
| 27701 | return pos <= begv ? "All" : "Bottom"; | 27732 | { |
| 27702 | else if (pos <= begv) | 27733 | beg = BUF_BEGV (b); |
| 27734 | z = BUF_ZV (b); | ||
| 27735 | } | ||
| 27736 | else | ||
| 27737 | { | ||
| 27738 | beg = BUF_BEG (b); | ||
| 27739 | z = BUF_Z (b); | ||
| 27740 | } | ||
| 27741 | |||
| 27742 | if (w->window_end_pos <= BUF_Z (b) - z) | ||
| 27743 | return pos <= beg ? "All" : "Bottom"; | ||
| 27744 | else if (pos <= beg) | ||
| 27703 | return "Top"; | 27745 | return "Top"; |
| 27704 | else | 27746 | else |
| 27705 | { | 27747 | { |
| 27706 | sprintf (decode_mode_spec_buf, "%2d%%", | 27748 | sprintf (decode_mode_spec_buf, "%2d%%", |
| 27707 | percent99 (pos - begv, zv - begv)); | 27749 | percent99 (pos - beg, z - beg)); |
| 27708 | return decode_mode_spec_buf; | 27750 | return decode_mode_spec_buf; |
| 27709 | } | 27751 | } |
| 27710 | } | 27752 | } |
| @@ -27714,16 +27756,26 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27714 | { | 27756 | { |
| 27715 | ptrdiff_t toppos = marker_position (w->start); | 27757 | ptrdiff_t toppos = marker_position (w->start); |
| 27716 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; | 27758 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; |
| 27717 | ptrdiff_t begv = BUF_BEGV (b); | 27759 | ptrdiff_t beg, z; |
| 27718 | ptrdiff_t zv = BUF_ZV (b); | ||
| 27719 | 27760 | ||
| 27720 | if (zv <= botpos) | 27761 | if (! BUFFER_AUTO_NARROWED_P (b)) |
| 27721 | return toppos <= begv ? "All" : "Bottom"; | 27762 | { |
| 27763 | beg = BUF_BEGV (b); | ||
| 27764 | z = BUF_ZV (b); | ||
| 27765 | } | ||
| 27766 | else | ||
| 27767 | { | ||
| 27768 | beg = BUF_BEG (b); | ||
| 27769 | z = BUF_Z (b); | ||
| 27770 | } | ||
| 27771 | |||
| 27772 | if (z <= botpos) | ||
| 27773 | return toppos <= beg ? "All" : "Bottom"; | ||
| 27722 | else | 27774 | else |
| 27723 | { | 27775 | { |
| 27724 | sprintf (decode_mode_spec_buf, | 27776 | sprintf (decode_mode_spec_buf, |
| 27725 | &"Top%2d%%"[begv < toppos ? sizeof "Top" - 1 : 0], | 27777 | &"Top%2d%%"[beg < toppos ? sizeof "Top" - 1 : 0], |
| 27726 | percent99 (botpos - begv, zv - begv)); | 27778 | percent99 (botpos - beg, z - beg)); |
| 27727 | return decode_mode_spec_buf; | 27779 | return decode_mode_spec_buf; |
| 27728 | } | 27780 | } |
| 27729 | } | 27781 | } |
| @@ -27734,15 +27786,25 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27734 | { | 27786 | { |
| 27735 | ptrdiff_t toppos = marker_position (w->start); | 27787 | ptrdiff_t toppos = marker_position (w->start); |
| 27736 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; | 27788 | ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; |
| 27737 | ptrdiff_t begv = BUF_BEGV (b); | 27789 | ptrdiff_t beg, z; |
| 27738 | ptrdiff_t zv = BUF_ZV (b); | ||
| 27739 | int top_perc, bot_perc; | 27790 | int top_perc, bot_perc; |
| 27740 | 27791 | ||
| 27741 | if ((toppos <= begv) && (zv <= botpos)) | 27792 | if (! BUFFER_AUTO_NARROWED_P (b)) |
| 27793 | { | ||
| 27794 | beg = BUF_BEGV (b); | ||
| 27795 | z = BUF_ZV (b); | ||
| 27796 | } | ||
| 27797 | else | ||
| 27798 | { | ||
| 27799 | beg = BUF_BEG (b); | ||
| 27800 | z = BUF_Z (b); | ||
| 27801 | } | ||
| 27802 | |||
| 27803 | if ((toppos <= beg) && (z <= botpos)) | ||
| 27742 | return "All "; | 27804 | return "All "; |
| 27743 | 27805 | ||
| 27744 | top_perc = toppos <= begv ? 0 : percent99 (toppos - begv, zv - begv); | 27806 | top_perc = toppos <= beg ? 0 : percent99 (toppos - beg, z - beg); |
| 27745 | bot_perc = zv <= botpos ? 100 : percent99 (botpos - begv, zv - begv); | 27807 | bot_perc = z <= botpos ? 100 : percent99 (botpos - beg, z - beg); |
| 27746 | 27808 | ||
| 27747 | if (top_perc == bot_perc) | 27809 | if (top_perc == bot_perc) |
| 27748 | sprintf (decode_mode_spec_buf, "%d%%", top_perc); | 27810 | sprintf (decode_mode_spec_buf, "%d%%", top_perc); |
| @@ -35830,6 +35892,8 @@ be let-bound around code that needs to disable messages temporarily. */); | |||
| 35830 | DEFSYM (Qinhibit_point_motion_hooks, "inhibit-point-motion-hooks"); | 35892 | DEFSYM (Qinhibit_point_motion_hooks, "inhibit-point-motion-hooks"); |
| 35831 | DEFSYM (Qeval, "eval"); | 35893 | DEFSYM (Qeval, "eval"); |
| 35832 | DEFSYM (QCdata, ":data"); | 35894 | DEFSYM (QCdata, ":data"); |
| 35895 | DEFSYM (Qneeded, "needed"); | ||
| 35896 | DEFSYM (Qauto, "auto"); | ||
| 35833 | 35897 | ||
| 35834 | /* Names of text properties relevant for redisplay. */ | 35898 | /* Names of text properties relevant for redisplay. */ |
| 35835 | DEFSYM (Qdisplay, "display"); | 35899 | DEFSYM (Qdisplay, "display"); |