branch: externals/consult commit 951c8b47b74b8196468852f9e94828a03188226f Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Use without-restriction --- consult-flymake.el | 51 +++++++++++++++++++++++++-------------------------- consult-imenu.el | 3 +-- consult-register.el | 3 +-- consult.el | 3 +-- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/consult-flymake.el b/consult-flymake.el index ae47e55dc3..f96fbee4ea 100644 --- a/consult-flymake.el +++ b/consult-flymake.el @@ -27,6 +27,7 @@ (require 'consult) (require 'flymake) +(eval-when-compile (require 'cl-lib)) (defconst consult-flymake--narrow '((?e . "Error") @@ -41,26 +42,29 @@ DIAGS should be a list of diagnostics as returned from `flymake-diagnostics'." (lambda (diag) (let ((buffer (flymake-diagnostic-buffer diag)) (type (flymake-diagnostic-type diag))) - (with-current-buffer buffer - (save-excursion - (save-restriction - (widen) - (goto-char (flymake-diagnostic-beg diag)) - (list (buffer-name buffer) - (line-number-at-pos) - type - (flymake-diagnostic-text diag) - (point-marker) - (flymake-diagnostic-end diag) - (pcase (flymake--lookup-type-property type 'flymake-category) - ('flymake-error ?e) - ('flymake-warning ?w) - (_ ?n)))))))) - (seq-filter (lambda (diag) - (buffer-live-p (flymake-diagnostic-buffer diag))) - diags))) - (buffer-width (apply #'max (mapcar (lambda (x) (length (nth 0 x))) diags))) - (line-width (apply #'max (mapcar (lambda (x) (length (number-to-string (nth 1 x)))) diags))) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (save-excursion + (without-restriction + (goto-char (flymake-diagnostic-beg diag)) + (list (buffer-name buffer) + (line-number-at-pos) + type + (flymake-diagnostic-text diag) + (point-marker) + (flymake-diagnostic-end diag) + (pcase (flymake--lookup-type-property type 'flymake-category) + ('flymake-error ?e) + ('flymake-warning ?w) + (_ ?n))))))))) + diags)) + (diags (or (delq nil diags) + (user-error "No flymake errors (Status: %s)" + (if (seq-difference (flymake-running-backends) + (flymake-reporting-backends)) + 'running 'finished)))) + (buffer-width (cl-loop for x in diags maximize (length (nth 0 x)))) + (line-width (cl-loop for x in diags maximize (length (number-to-string (nth 1 x))))) (fmt (format "%%-%ds %%-%dd %%-7s %%s" buffer-width line-width))) (mapcar (pcase-lambda (`(,buffer ,line ,type ,text ,beg ,end ,narrow)) @@ -94,15 +98,10 @@ buffers in the current project instead of just the current buffer." (consult--forbid-minibuffer) (consult--read (consult-flymake--candidates - (or (if-let (((and project (fboundp 'flymake--project-diagnostics))) (project (project-current))) (flymake--project-diagnostics project) - (flymake-diagnostics)) - (user-error "No flymake errors (Status: %s)" - (if (seq-difference (flymake-running-backends) - (flymake-reporting-backends)) - 'running 'finished)))) + (flymake-diagnostics))) :prompt "Flymake diagnostic: " :category 'consult-flymake-error :history t ;; disable history diff --git a/consult-imenu.el b/consult-imenu.el index 53f65e5972..d1b073b930 100644 --- a/consult-imenu.el +++ b/consult-imenu.el @@ -117,8 +117,7 @@ TYPES is the mode-specific types configuration." ;; Generate imenu, see `imenu--make-index-alist'. (items (imenu--truncate-items (save-excursion - (save-restriction - (widen) + (without-restriction (funcall imenu-create-index-function))))) (config (cdr (seq-find (lambda (x) (derived-mode-p (car x))) consult-imenu-config)))) ;; Fix toplevel items, e.g., emacs-lisp-mode toplevel items are functions diff --git a/consult-register.el b/consult-register.el index f7e58cba01..dff679d288 100644 --- a/consult-register.el +++ b/consult-register.el @@ -67,8 +67,7 @@ Each element of the list must have the form (char . name).") "Describe marker register VAL." (with-current-buffer (marker-buffer val) (save-excursion - (save-restriction - (widen) + (without-restriction (goto-char val) (let* ((line (line-number-at-pos)) (str (propertize (consult--line-with-mark val) diff --git a/consult.el b/consult.el index 55cb8b8fc4..99c06b739e 100644 --- a/consult.el +++ b/consult.el @@ -928,8 +928,7 @@ Also temporarily increase the GC limit via `consult--with-increased-gc'." (when (buffer-live-p buffer) (with-current-buffer buffer (save-excursion - (save-restriction - (widen) + (without-restriction (goto-char (point-min)) ;; Location data might be invalid by now! (ignore-errors