aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGregory Heytings2022-07-08 23:36:18 +0200
committerGregory Heytings2022-07-08 23:36:18 +0200
commit60e51595c8a89ffc34dbe0d36c75d1c119a7d5c5 (patch)
treee9736bab9374cbe83431fc70f499b51ae1c92313 /src
parente31cffb5abfe68b62047532765a2076ac4885475 (diff)
downloademacs-60e51595c8a89ffc34dbe0d36c75d1c119a7d5c5.tar.gz
emacs-60e51595c8a89ffc34dbe0d36c75d1c119a7d5c5.zip
Revert commit 38b3780f6e.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c9
-rw-r--r--src/buffer.h14
-rw-r--r--src/fileio.c21
-rw-r--r--src/keyboard.c28
-rw-r--r--src/xdisp.c122
5 files changed, 30 insertions, 164 deletions
diff --git a/src/buffer.c b/src/buffer.c
index d5b4292a21d..509ce51b55e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5276,9 +5276,6 @@ 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;
5282 XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; 5279 XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx;
5283 5280
5284 /* buffer_local_flags contains no pointers, so it's safe to treat it 5281 /* buffer_local_flags contains no pointers, so it's safe to treat it
@@ -5665,7 +5662,7 @@ A string is printed verbatim in the mode line except for %-constructs:
5665 %p -- print percent of buffer above top of window, or Top, Bot or All. 5662 %p -- print percent of buffer above top of window, or Top, Bot or All.
5666 %P -- print percent of buffer above bottom of window, perhaps plus Top, 5663 %P -- print percent of buffer above bottom of window, perhaps plus Top,
5667 or print Bottom or All. 5664 or print Bottom or All.
5668 %n -- print Narrow or Auto-Narrow if appropriate. 5665 %n -- print Narrow if appropriate.
5669 %t -- visited file is text or binary (if OS supports this distinction). 5666 %t -- visited file is text or binary (if OS supports this distinction).
5670 %z -- print mnemonics of keyboard, terminal, and buffer coding systems. 5667 %z -- print mnemonics of keyboard, terminal, and buffer coding systems.
5671 %Z -- like %z, but including the end-of-line format. 5668 %Z -- like %z, but including the end-of-line format.
@@ -6366,10 +6363,6 @@ see `display-graphic-p'.
6366If value is a floating point number, it specifies the spacing relative 6363If value is a floating point number, it specifies the spacing relative
6367to the default frame line height. A value of nil means add no extra space. */); 6364to the default frame line height. A value of nil means add no extra space. */);
6368 6365
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
6373 DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", 6366 DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
6374 &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil, 6367 &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil,
6375 doc: /* Non-nil means show a cursor in non-selected windows. 6368 doc: /* Non-nil means show a cursor in non-selected windows.
diff --git a/src/buffer.h b/src/buffer.h
index 19faa844e02..135eaf72d30 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -561,9 +561,6 @@ 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
567 /* Cursor type to display in non-selected windows. 564 /* Cursor type to display in non-selected windows.
568 t means to use hollow box cursor. 565 t means to use hollow box cursor.
569 See `cursor-type' for other values. */ 566 See `cursor-type' for other values. */
@@ -835,11 +832,6 @@ bset_width_table (struct buffer *b, Lisp_Object val)
835{ 832{
836 b->width_table_ = val; 833 b->width_table_ = val;
837} 834}
838INLINE void
839bset_auto_narrow__narrowing_state (struct buffer *b, Lisp_Object val)
840{
841 b->auto_narrow__narrowing_state_ = val;
842}
843 835
844/* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return 836/* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
845 the max (resp. min) p such that 837 the max (resp. min) p such that
@@ -1120,12 +1112,6 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
1120 } 1112 }
1121} 1113}
1122 1114
1123INLINE bool
1124BUFFER_AUTO_NARROWED_P (struct buffer *b)
1125{
1126 return EQ (BVAR (b, auto_narrow__narrowing_state), Qauto);
1127}
1128
1129/* This structure holds the default values of the buffer-local variables 1115/* This structure holds the default values of the buffer-local variables
1130 that have special slots in each buffer. 1116 that have special slots in each buffer.
1131 The default value occupies the same slot in this structure 1117 The default value occupies the same slot in this structure
diff --git a/src/fileio.c b/src/fileio.c
index bb6f73fe39a..10d4b8bc15e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4997,16 +4997,6 @@ 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
5010 unbind_to (count1, Qnil); 5000 unbind_to (count1, Qnil);
5011 } 5001 }
5012 5002
@@ -6648,17 +6638,6 @@ This includes interactive calls to `delete-file' and
6648 /* Lisp function for recursively deleting directories. */ 6638 /* Lisp function for recursively deleting directories. */
6649 DEFSYM (Qdelete_directory, "delete-directory"); 6639 DEFSYM (Qdelete_directory, "delete-directory");
6650 6640
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.
6654When 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.
6657When nil, `auto-narrow-mode' is disabled. */);
6658 Vauto_narrow_long_line_threshold = Qnil;
6659
6660 DEFSYM (Qauto_narrow_mode, "auto-narrow-mode");
6661
6662 DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name"); 6641 DEFSYM (Qsubstitute_env_in_file_name, "substitute-env-in-file-name");
6663 DEFSYM (Qget_buffer_window_list, "get-buffer-window-list"); 6642 DEFSYM (Qget_buffer_window_list, "get-buffer-window-list");
6664 6643
diff --git a/src/keyboard.c b/src/keyboard.c
index 38aa64774dc..bed8307b6f2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1290,9 +1290,6 @@ 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
1296 /* Make sure this hook runs after commands that get errors and 1293 /* Make sure this hook runs after commands that get errors and
1297 throw to top level. */ 1294 throw to top level. */
1298 /* Note that the value cell will never directly contain nil 1295 /* Note that the value cell will never directly contain nil
@@ -1475,8 +1472,6 @@ command_loop_1 (void)
1475 Vreal_this_command = cmd; 1472 Vreal_this_command = cmd;
1476 safe_run_hooks (Qpre_command_hook); 1473 safe_run_hooks (Qpre_command_hook);
1477 1474
1478 safe_run_hooks (Qauto_narrow_pre_command_function);
1479
1480 already_adjusted = 0; 1475 already_adjusted = 0;
1481 1476
1482 if (NILP (Vthis_command)) 1477 if (NILP (Vthis_command))
@@ -1527,8 +1522,6 @@ command_loop_1 (void)
1527 } 1522 }
1528 kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg); 1523 kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg);
1529 1524
1530 safe_run_hooks (Qauto_narrow_post_command_function);
1531
1532 safe_run_hooks (Qpost_command_hook); 1525 safe_run_hooks (Qpost_command_hook);
1533 1526
1534 /* If displaying a message, resize the echo area window to fit 1527 /* If displaying a message, resize the echo area window to fit
@@ -12047,11 +12040,6 @@ syms_of_keyboard (void)
12047 DEFSYM (Qpre_command_hook, "pre-command-hook"); 12040 DEFSYM (Qpre_command_hook, "pre-command-hook");
12048 DEFSYM (Qpost_command_hook, "post-command-hook"); 12041 DEFSYM (Qpost_command_hook, "post-command-hook");
12049 12042
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
12055 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary"); 12043 DEFSYM (Qundo_auto__add_boundary, "undo-auto--add-boundary");
12056 DEFSYM (Qundo_auto__undoably_changed_buffers, 12044 DEFSYM (Qundo_auto__undoably_changed_buffers,
12057 "undo-auto--undoably-changed-buffers"); 12045 "undo-auto--undoably-changed-buffers");
@@ -12616,22 +12604,6 @@ avoid making Emacs unresponsive while the user types.
12616See also `pre-command-hook'. */); 12604See also `pre-command-hook'. */);
12617 Vpost_command_hook = Qnil; 12605 Vpost_command_hook = Qnil;
12618 12606
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'.
12622If non-nil, and `auto-narrow-mode' is enabled, the function is
12623called before each command is executed, after `pre-command-hook'.
12624It 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'.
12630If non-nil, and `auto-narrow-mode' is enabled, the function is
12631called after each command is executed, before `post-command-hook'.
12632It is called without arguments. */);
12633 Vauto_narrow_post_command_function = Qnil;
12634
12635#if 0 12607#if 0
12636 DEFVAR_LISP ("echo-area-clear-hook", ..., 12608 DEFVAR_LISP ("echo-area-clear-hook", ...,
12637 doc: /* Normal hook run when clearing the echo area. */); 12609 doc: /* Normal hook run when clearing the echo area. */);
diff --git a/src/xdisp.c b/src/xdisp.c
index be51a0eb136..4089525e10f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -18872,20 +18872,11 @@ 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 whole = BUF_ZV (buf) - BUF_BEGV (buf);
18876 { 18876 start = marker_position (w->start) - BUF_BEGV (buf);
18877 whole = BUF_ZV (buf) - BUF_BEGV (buf); 18877 /* I don't think this is guaranteed to be right. For the
18878 start = marker_position (w->start) - BUF_BEGV (buf); 18878 moment, we'll pretend it is. */
18879 /* I don't think this is guaranteed to be right. For the 18879 end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf);
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 }
18889 18880
18890 if (end < start) 18881 if (end < start)
18891 end = start; 18882 end = start;
@@ -19142,14 +19133,6 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
19142 variables. */ 19133 variables. */
19143 set_buffer_internal_1 (XBUFFER (w->contents)); 19134 set_buffer_internal_1 (XBUFFER (w->contents));
19144 19135
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
19153 current_matrix_up_to_date_p 19136 current_matrix_up_to_date_p
19154 = (w->window_end_valid 19137 = (w->window_end_valid
19155 && !current_buffer->clip_changed 19138 && !current_buffer->clip_changed
@@ -27684,12 +27667,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
27684 27667
27685 case 'n': 27668 case 'n':
27686 if (BUF_BEGV (b) > BUF_BEG (b) || BUF_ZV (b) < BUF_Z (b)) 27669 if (BUF_BEGV (b) > BUF_BEG (b) || BUF_ZV (b) < BUF_Z (b))
27687 { 27670 return " Narrow";
27688 if (! BUFFER_AUTO_NARROWED_P (b))
27689 return " Narrow";
27690 else
27691 return " Auto-Narrow";
27692 }
27693 break; 27671 break;
27694 27672
27695 /* Display the "degree of travel" of the window through the buffer. */ 27673 /* Display the "degree of travel" of the window through the buffer. */
@@ -27697,27 +27675,17 @@ decode_mode_spec (struct window *w, register int c, int field_width,
27697 { 27675 {
27698 ptrdiff_t toppos = marker_position (w->start); 27676 ptrdiff_t toppos = marker_position (w->start);
27699 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; 27677 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
27700 ptrdiff_t beg, z; 27678 ptrdiff_t begv = BUF_BEGV (b);
27679 ptrdiff_t zv = BUF_ZV (b);
27701 27680
27702 if (! BUFFER_AUTO_NARROWED_P (b)) 27681 if (zv <= botpos)
27703 { 27682 return toppos <= begv ? "All" : "Bottom";
27704 beg = BUF_BEGV (b); 27683 else if (toppos <= begv)
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)
27716 return "Top"; 27684 return "Top";
27717 else 27685 else
27718 { 27686 {
27719 sprintf (decode_mode_spec_buf, "%2d%%", 27687 sprintf (decode_mode_spec_buf, "%2d%%",
27720 percent99 (toppos - beg, (toppos - beg) + (z - botpos))); 27688 percent99 (toppos - begv, (toppos - begv) + (zv - botpos)));
27721 return decode_mode_spec_buf; 27689 return decode_mode_spec_buf;
27722 } 27690 }
27723 } 27691 }
@@ -27726,27 +27694,17 @@ decode_mode_spec (struct window *w, register int c, int field_width,
27726 case 'p': 27694 case 'p':
27727 { 27695 {
27728 ptrdiff_t pos = marker_position (w->start); 27696 ptrdiff_t pos = marker_position (w->start);
27729 ptrdiff_t beg, z; 27697 ptrdiff_t begv = BUF_BEGV (b);
27698 ptrdiff_t zv = BUF_ZV (b);
27730 27699
27731 if (! BUFFER_AUTO_NARROWED_P (b)) 27700 if (w->window_end_pos <= BUF_Z (b) - zv)
27732 { 27701 return pos <= begv ? "All" : "Bottom";
27733 beg = BUF_BEGV (b); 27702 else if (pos <= begv)
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)
27745 return "Top"; 27703 return "Top";
27746 else 27704 else
27747 { 27705 {
27748 sprintf (decode_mode_spec_buf, "%2d%%", 27706 sprintf (decode_mode_spec_buf, "%2d%%",
27749 percent99 (pos - beg, z - beg)); 27707 percent99 (pos - begv, zv - begv));
27750 return decode_mode_spec_buf; 27708 return decode_mode_spec_buf;
27751 } 27709 }
27752 } 27710 }
@@ -27756,26 +27714,16 @@ decode_mode_spec (struct window *w, register int c, int field_width,
27756 { 27714 {
27757 ptrdiff_t toppos = marker_position (w->start); 27715 ptrdiff_t toppos = marker_position (w->start);
27758 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; 27716 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
27759 ptrdiff_t beg, z; 27717 ptrdiff_t begv = BUF_BEGV (b);
27718 ptrdiff_t zv = BUF_ZV (b);
27760 27719
27761 if (! BUFFER_AUTO_NARROWED_P (b)) 27720 if (zv <= botpos)
27762 { 27721 return toppos <= begv ? "All" : "Bottom";
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";
27774 else 27722 else
27775 { 27723 {
27776 sprintf (decode_mode_spec_buf, 27724 sprintf (decode_mode_spec_buf,
27777 &"Top%2d%%"[beg < toppos ? sizeof "Top" - 1 : 0], 27725 &"Top%2d%%"[begv < toppos ? sizeof "Top" - 1 : 0],
27778 percent99 (botpos - beg, z - beg)); 27726 percent99 (botpos - begv, zv - begv));
27779 return decode_mode_spec_buf; 27727 return decode_mode_spec_buf;
27780 } 27728 }
27781 } 27729 }
@@ -27786,25 +27734,15 @@ decode_mode_spec (struct window *w, register int c, int field_width,
27786 { 27734 {
27787 ptrdiff_t toppos = marker_position (w->start); 27735 ptrdiff_t toppos = marker_position (w->start);
27788 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos; 27736 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
27789 ptrdiff_t beg, z; 27737 ptrdiff_t begv = BUF_BEGV (b);
27738 ptrdiff_t zv = BUF_ZV (b);
27790 int top_perc, bot_perc; 27739 int top_perc, bot_perc;
27791 27740
27792 if (! BUFFER_AUTO_NARROWED_P (b)) 27741 if ((toppos <= begv) && (zv <= botpos))
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))
27804 return "All "; 27742 return "All ";
27805 27743
27806 top_perc = toppos <= beg ? 0 : percent99 (toppos - beg, z - beg); 27744 top_perc = toppos <= begv ? 0 : percent99 (toppos - begv, zv - begv);
27807 bot_perc = z <= botpos ? 100 : percent99 (botpos - beg, z - beg); 27745 bot_perc = zv <= botpos ? 100 : percent99 (botpos - begv, zv - begv);
27808 27746
27809 if (top_perc == bot_perc) 27747 if (top_perc == bot_perc)
27810 sprintf (decode_mode_spec_buf, "%d%%", top_perc); 27748 sprintf (decode_mode_spec_buf, "%d%%", top_perc);
@@ -35892,8 +35830,6 @@ be let-bound around code that needs to disable messages temporarily. */);
35892 DEFSYM (Qinhibit_point_motion_hooks, "inhibit-point-motion-hooks"); 35830 DEFSYM (Qinhibit_point_motion_hooks, "inhibit-point-motion-hooks");
35893 DEFSYM (Qeval, "eval"); 35831 DEFSYM (Qeval, "eval");
35894 DEFSYM (QCdata, ":data"); 35832 DEFSYM (QCdata, ":data");
35895 DEFSYM (Qneeded, "needed");
35896 DEFSYM (Qauto, "auto");
35897 35833
35898 /* Names of text properties relevant for redisplay. */ 35834 /* Names of text properties relevant for redisplay. */
35899 DEFSYM (Qdisplay, "display"); 35835 DEFSYM (Qdisplay, "display");