From e31cffb5abfe68b62047532765a2076ac4885475 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Fri, 8 Jul 2022 23:31:56 +0200 Subject: [PATCH] Revert commits 9ea9533f17, c0c4600ece, 7b19ce51fc, 051d2a1e36 and eb6d2fb58d. --- doc/emacs/display.texi | 20 +++++--------------- etc/NEWS | 13 ++++--------- lisp/files.el | 37 +++++++++++-------------------------- lisp/font-lock.el | 5 ----- lisp/isearch.el | 5 +---- src/buffer.h | 16 ---------------- src/window.c | 5 ----- src/xdisp.c | 25 ++++++------------------- 8 files changed, 27 insertions(+), 99 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index feb4675b32d..9fe9533e88c 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -474,10 +474,9 @@ it. @xref{Disabling}. @vindex auto-narrow-long-line-threshold @vindex auto-narrow-display-length @vindex auto-narrow-widen-automatically -@vindex auto-narrow-hook When a file with extremely long lines is opened or inserted in a -buffer, Emacs automatically enters Auto-Narrow mode, and the word +buffer, Emacs automatically enters auto-narrow mode, and the word @samp{Auto-Narrow} appears in the mode line. This means that Emacs restricts display, but not editing, to a portion of the buffer above and below point. All editing commands, including narrowing commands, @@ -486,21 +485,12 @@ remain available, and they act on the whole buffer. For example, happen with ordinary narrowing, to the end of the portion of the buffer to which display is currently restricted. - The behavior of Auto-Narrow mode is controlled by four variables: + The behavior of auto-narrow mode is controlled by three variables: @code{auto-narrow-long-line-threshold} is the line length above which -Auto-Narrow move is entered, @code{auto-narrow-display-length} is the -number of characters to which display is restricted, +auto-narrow move is entered, @code{auto-narrow-display-length} is the +number of characters to which display is restricted, and @code{auto-narrow-widen-automatically} is a list of commands for which -display is widened before they are executed, and -@code{auto-narrow-hook} is a list of functions that are called when -Auto-Narrow mode is entered. By default, Font Lock mode is disabled -in Auto-Narrow mode. - - If you still experience slowdowns while editing a file when -Auto-Narrow mode is enabled, this is not due to Emacs itself, but to -the current major mode or one of the enabled minor modes, and you -should open the file with @kbd{M-x find-file-literally} instead of -@kbd{C-x C-f}. +display is widened before they are executed. @node View Mode @section View Mode diff --git a/etc/NEWS b/etc/NEWS index 3df1fb9c4e7..51d31bcf173 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -905,15 +905,10 @@ automatically enters auto-narrow mode. This means that Emacs restricts display, but not editing, to a portion of the buffer above and below point. All editing commands, including narrowing commands, remain available, and they act on the whole buffer. The behavior of -that mode is controlled by four variables: -auto-narrow-long-line-threshold, auto-narrow-display-length, -auto-narrow-widen-automatically and auto-narrow-hook (which by default -disables font-lock-mode). To disable that feature, set -auto-narrow-long-line-threshold to nil in your init file. If you -still experience slowdowns while editing a file in auto-narrow mode, -this is due to the current major mode or one of the enabled minor -modes: you should open the file with M-x find-file-literally instead -of C-x C-f. +that mode is controlled by three variables: +auto-narrow-long-line-threshold, auto-narrow-display-length and +auto-narrow-widen-automatically. To disable that feature, set +auto-narrow-long-line-threshold to nil in your init file. --- ** 'zap-to-char' and 'zap-up-to-char' are case-sensitive for upper-case chars. diff --git a/lisp/files.el b/lisp/files.el index 9d7273cb1c7..0e6f1a935db 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2692,9 +2692,9 @@ the file contents into it using `insert-file-contents-literally'." "Number of characters to which display is restricted in `auto-narrow-mode'. When `auto-narrow-mode' is in effect, the number of characters -displayed above and below point is at least one third and at most -two thirds of `auto-narrow-display-line-length', except at the -beginning and end of the buffer." +displayed above and below point is one third of +`auto-narrow-display-line-length', except at the beginning and +end of the buffer." :group 'files :group 'find-file :version "29.1" @@ -2706,40 +2706,30 @@ beginning and end of the buffer." beginning-of-buffer end-of-buffer goto-char goto-line mark-sexp mark-defun mark-paragraph mark-whole-buffer mark-page exchange-point-and-mark pop-global-mark set-mark-command jump-to-register - bookmark-jump undo) + bookmark-jump) "Commands for which display is automatically widened in `auto-narrow-mode'." :group 'files :group 'find-file :version "29.1" :type '(repeat function)) -(defcustom auto-narrow-hook '(turn-off-font-lock-mode) - "List of functions to be called when `auto-narrow-mode' is entered." - :group 'find-file - :type 'hook - :version "29.1" - :type '(repeat function)) - (defvar-local auto-narrow--widen-automatically nil "Internal variable used by `auto-narrow-mode'.") (defvar-local auto-narrow--isearch-widen-automatically nil "Internal variable used by `auto-narrow-mode'.") -(defvar-local auto-narrow--isearch-lazy-highlight nil - "Internal variable used by `auto-narrow-mode'.") - -(defun auto-narrow--reset-isearch-lazy-highlight () - "Internal function used by `auto-narrow-mode'." - (when auto-narrow-mode - (setq-local isearch-lazy-highlight auto-narrow--isearch-lazy-highlight))) - (defvar-local auto-narrow--initialized nil "Internal variable used by `auto-narrow-mode'.") (defun auto-narrow-pre-command-function () "Conditionally widen display when `auto-narrow-mode' is in effect." (when auto-narrow-mode + (unless auto-narrow--initialized + (setq auto-narrow--widen-automatically widen-automatically + auto-narrow--isearch-widen-automatically isearch-widen-automatically + auto-narrow--narrowing-state 'auto + auto-narrow--initialized t)) (setq-local widen-automatically t isearch-widen-automatically t) (if (memq this-command '(narrow-to-region narrow-to-defun narrow-to-page)) @@ -2757,13 +2747,7 @@ beginning and end of the buffer." (when (and auto-narrow-mode (not (eq auto-narrow--narrowing-state 'explicit))) (unless auto-narrow--initialized - (run-hooks 'auto-narrow-hook) - (add-hook 'isearch-mode-end-hook #'auto-narrow--reset-isearch-lazy-highlight) - (setq auto-narrow--widen-automatically widen-automatically - auto-narrow--isearch-widen-automatically isearch-widen-automatically - auto-narrow--isearch-lazy-highlight isearch-lazy-highlight - auto-narrow--narrowing-state 'auto - auto-narrow--initialized t)) + (setq auto-narrow--narrowing-state 'auto)) (let (point cur-point-min buf-point-min buf-point-max size) (setq point (point) cur-point-min (point-min) size (/ auto-narrow-display-length 3)) @@ -2793,6 +2777,7 @@ in a buffer. It restricts display, but not editing, to executing any of the commands listed in `auto-narrow-widen-automatically'." :group 'files :version "29.1" + :after-hook (progn (put 'auto-narrow-mode 'permanent-local t)) (if auto-narrow-mode (auto-narrow-post-command-function) (when (not (eq auto-narrow--narrowing-state 'explicit)) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 0c30173d9ae..206879b1694 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -2045,11 +2045,6 @@ Sets various variables using `font-lock-defaults' and (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords)))) (font-lock-flush))) - -(defun turn-off-font-lock-mode () - "Unconditionally turn off `font-lock-mode'." - (interactive) - (font-lock-mode -1)) ;;; Color etc. support. diff --git a/lisp/isearch.el b/lisp/isearch.el index 29036201ad8..a6e034df6b9 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3658,10 +3658,7 @@ Optional third argument, if t, means if fail just return nil (no error). (isearch-search-string isearch-string nil t)) (if (and (not isearch-success) (buffer-narrowed-p) isearch-widen-automatically widen-automatically) - (progn - (when auto-narrow-mode - (setq-local isearch-lazy-highlight nil)) - (widen)) + (widen) ;; Clear RETRY unless the search predicate says ;; to skip this search hit. (if (or (not isearch-success) diff --git a/src/buffer.h b/src/buffer.h index 84492737b0e..19faa844e02 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1120,28 +1120,12 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b) } } -/* Check the state of auto-narrowed buffers. */ - -INLINE bool -BUFFER_NEEDS_AUTO_NARROWING_P (struct buffer *b) -{ - return EQ (BVAR (b, auto_narrow__narrowing_state), Qneeded); -} - INLINE bool BUFFER_AUTO_NARROWED_P (struct buffer *b) { return EQ (BVAR (b, auto_narrow__narrowing_state), Qauto); } -INLINE bool -BUFFER_AUTO_NARROWED_NON_NARROWED_P (struct buffer *b) -{ - return BUFFER_AUTO_NARROWED_P (b) - && BUF_BEG (b) == BUF_BEGV (b) - && BUF_Z (b) == BUF_ZV (b); -} - /* This structure holds the default values of the buffer-local variables that have special slots in each buffer. The default value occupies the same slot in this structure diff --git a/src/window.c b/src/window.c index 218b3e6a4f8..af463b90ce6 100644 --- a/src/window.c +++ b/src/window.c @@ -6557,11 +6557,6 @@ and redisplay normally--don't erase and redraw the frame. */) if (buf != current_buffer) error ("`recenter'ing a window that does not display current-buffer."); - /* Refuse to recenter auto-narrowed buffers that are not actually narrowed, - as this can be very slow. */ - if (BUFFER_AUTO_NARROWED_NON_NARROWED_P (buf)) - return Qnil; - /* If redisplay is suppressed due to an error, try again. */ buf->display_error_modiff = 0; diff --git a/src/xdisp.c b/src/xdisp.c index a583e102528..be51a0eb136 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -18872,32 +18872,19 @@ set_vertical_scroll_bar (struct window *w) && NILP (echo_area_buffer[0]))) { struct buffer *buf = XBUFFER (w->contents); - ptrdiff_t window_end_pos = w->window_end_pos; - - /* If w->window_end_pos cannot be trusted, recompute it "the - hard way". */ - if (!w->window_end_valid) - { - struct it it; - struct text_pos start_pos; - - SET_TEXT_POS_FROM_MARKER (start_pos, w->start); - start_display (&it, w, start_pos); - move_it_to (&it, -1, it.last_visible_x, window_box_height (w), -1, - MOVE_TO_X | MOVE_TO_Y); - window_end_pos = BUF_Z (buf) - IT_CHARPOS (it); - } - if (! BUFFER_AUTO_NARROWED_P (buf)) + if (! BUFFER_AUTO_NARROWED_P (current_buffer)) { whole = BUF_ZV (buf) - BUF_BEGV (buf); start = marker_position (w->start) - BUF_BEGV (buf); - end = BUF_Z (buf) - window_end_pos - BUF_BEGV (buf); + /* I don't think this is guaranteed to be right. For the + moment, we'll pretend it is. */ + end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf); } else { whole = BUF_Z (buf) - BUF_BEG (buf); start = marker_position (w->start) - BUF_BEG (buf); - end = BUF_Z (buf) - window_end_pos - BUF_BEG (buf); + end = BUF_Z (buf) - w->window_end_pos - BUF_BEG (buf); } if (end < start) @@ -19155,7 +19142,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) variables. */ set_buffer_internal_1 (XBUFFER (w->contents)); - if (BUFFER_NEEDS_AUTO_NARROWING_P (current_buffer)) + if (EQ (BVAR (current_buffer, auto_narrow__narrowing_state), Qneeded)) { safe_call (1, Qauto_narrow_mode); /* Normally set by auto-narrow-mode, set it here anyway as a safety measure. */ -- 2.39.2