]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve goto-line in regard to narrowed buffers (bug#44294)
authorJuri Linkov <juri@linkov.net>
Sat, 31 Oct 2020 19:38:26 +0000 (21:38 +0200)
committerJuri Linkov <juri@linkov.net>
Sat, 31 Oct 2020 19:39:28 +0000 (21:39 +0200)
* lisp/simple.el (goto-line): Rewrite to first find the position
of the line where to go, then later don't widen the buffer
when the found position is still inside narrowed part of buffer.

* lisp/isearch.el (isearch-message-prefix): Warn about narrowed buffer
in case of no more matches found.

lisp/isearch.el
lisp/simple.el

index c3d5ff2d313943cc8a8355740ee33715ac56ed19..245bf452b1f19f076289f591f9f5c30820a794c3 100644 (file)
@@ -3262,6 +3262,8 @@ the word mode."
                              (< (point) isearch-opoint)))
                       "over")
                   (if isearch-wrapped "wrapped ")
+                   (if (and (not isearch-success) (buffer-narrowed-p) widen-automatically)
+                       "narrowed-buffer " "")
                    (if (and (not isearch-success) (not isearch-case-fold-search))
                        "case-sensitive ")
                    (let ((prefix ""))
index d871be104cfc95a191e2a2b13480d3f9cd49fb80..e96c7c9a6eab719dde60e04225d0aca382a5ba0e 100644 (file)
@@ -1344,18 +1344,20 @@ rather than line counts."
   ;; Leave mark at previous position
   (or (region-active-p) (push-mark))
   ;; Move to the specified line number in that buffer.
-  (if (and (not relative) (not widen-automatically))
-      (save-restriction
-        (widen)
-        (goto-char (point-min))
-        (if (eq selective-display t)
-            (re-search-forward "[\n\C-m]" nil 'end (1- line))
-          (forward-line (1- line))))
-    (unless relative (widen))
-    (goto-char (point-min))
-    (if (eq selective-display t)
-       (re-search-forward "[\n\C-m]" nil 'end (1- line))
-      (forward-line (1- line)))))
+  (let ((pos (save-restriction
+               (unless relative (widen))
+               (goto-char (point-min))
+               (if (eq selective-display t)
+                   (re-search-forward "[\n\C-m]" nil 'end (1- line))
+                 (forward-line (1- line)))
+               (point))))
+    (when (and (not relative)
+               (buffer-narrowed-p)
+               widen-automatically
+               ;; Position is outside narrowed part of buffer
+               (or (> (point-min) pos) (> pos (point-max))))
+      (widen))
+    (goto-char pos)))
 
 (defun goto-line-relative (line &optional buffer)
   "Go to LINE, counting from line at (point-min).