branch: externals/consult commit 47a11cb39a20f34ef4ceaf63c0736d22c48e7804 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-line-multi/consult-info: Filter out blank lines --- consult-info.el | 6 +++--- consult.el | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/consult-info.el b/consult-info.el index 361a150c50..004e18eda4 100644 --- a/consult-info.el +++ b/consult-info.el @@ -45,11 +45,11 @@ (eol (pos-eol)) node cand) (when (save-excursion + (goto-char bol) (and - (> eol bol) - (goto-char bol) - (>= (- (point) 2) (point-min)) + (not (looking-at "^\\s-*$")) ;; Information separator character + (>= (- (point) 2) (point-min)) (not (eq (char-after (- (point) 2)) ?\^_)) ;; Only printable characters on the line, [:cntrl:] does ;; not work?! diff --git a/consult.el b/consult.el index f545adc249..9397c125f2 100644 --- a/consult.el +++ b/consult.el @@ -3042,16 +3042,17 @@ Start from top if TOP non-nil. CURR-LINE is the current line number." (consult--forbid-minibuffer) (consult--fontify-all) - (let* (default-cand candidates - (buffer (current-buffer)) - (line (line-number-at-pos (point-min) consult-line-numbers-widen))) + (let* ((buffer (current-buffer)) + (line (line-number-at-pos (point-min) consult-line-numbers-widen)) + default-cand candidates) (consult--each-line beg end - (let ((str (consult--buffer-substring beg end))) - (unless (string-blank-p str) - (push (consult--location-candidate str (cons buffer (point)) line) candidates) - (when (and (not default-cand) (>= line curr-line)) - (setq default-cand candidates))) - (cl-incf line))) + (unless (looking-at "^\\s-*$") + (push (consult--location-candidate (consult--buffer-substring beg end) + (cons buffer beg) line) + candidates) + (when (and (not default-cand) (>= line curr-line)) + (setq default-cand candidates))) + (cl-incf line)) (when candidates (nreverse (if (or top (not default-cand)) @@ -3165,7 +3166,8 @@ BUFFERS is the list of buffers." (cl-incf line (consult--count-lines (match-beginning 0))) (let ((bol (pos-bol)) (eol (pos-eol))) - (when (and (> eol bol) + (goto-char bol) + (when (and (not (looking-at "^\\s-*$")) (seq-every-p (lambda (r) (goto-char bol) (re-search-forward r eol t))