From: Juri Linkov Date: Thu, 29 Oct 2020 09:09:20 +0000 (+0200) Subject: Widen buffer before going to point found by xref-find-definitions (bug#44294) X-Git-Tag: emacs-28.0.90~5360 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=46b3db5579e57b9daf16667914205adc99d3f104;p=emacs.git Widen buffer before going to point found by xref-find-definitions (bug#44294) * lisp/progmodes/elisp-mode.el (xref-location-marker): Widen before going to the found position. * lisp/progmodes/etags.el (etags-goto-tag-location): Rerun after removing narrowing. * lisp/simple.el (goto-line-read-args): Use buffer-narrowed-p. --- diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index eed73f57918..c7ff351845e 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -897,8 +897,10 @@ non-nil result supersedes the xrefs produced by (let ((buffer-point (find-function-search-for-symbol symbol type file))) (with-current-buffer (car buffer-point) (save-excursion - (goto-char (or (cdr buffer-point) (point-min))) - (point-marker)))))) + (save-restriction + (widen) + (goto-char (or (cdr buffer-point) (point-min))) + (point-marker))))))) (cl-defmethod xref-location-group ((l xref-elisp-location)) (xref-elisp-location-file l)) diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index f6af1f2ea84..41ed3177660 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -1406,8 +1406,13 @@ hits the start of file." offset (* 3 offset))) ; expand search window (or found (re-search-forward pat nil t) - (user-error "Rerun etags: `%s' not found in %s" - pat buffer-file-name))) + (if (and (buffer-narrowed-p) widen-automatically) + (progn + ;; Rerun after removing narrowing + (widen) + (etags-goto-tag-location tag-info)) + (user-error "Rerun etags: `%s' not found in %s" + pat buffer-file-name)))) ;; Position point at the right place ;; if the search string matched an extra Ctrl-m at the beginning. (and (eq selective-display t) diff --git a/lisp/simple.el b/lisp/simple.el index a29f85b3c36..2e40e3261c9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1291,11 +1291,11 @@ that uses or sets the mark." ""))) ;; Read the argument, offering that number (if any) as default. (list (read-number (format "Goto%s line%s: " - (if (= (point-min) 1) "" - ;; In a narrowed buffer. - (if relative " relative" " absolute")) + (if (buffer-narrowed-p) + (if relative " relative" " absolute") + "") buffer-prompt) - (list default (if (or relative (= (point-min) 1)) + (list default (if (or relative (not (buffer-narrowed-p))) (line-number-at-pos) (save-restriction (widen)