mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-22 18:35:09 +00:00
Support occur command operating on the region from Isearch.
* lisp/isearch.el (isearch-occur): Use region-bounds as region arg of occur. (isearch-query-replace): Use use-region-p. * lisp/replace.el (occur--region-start-line): Rename from occur--matches-threshold. (occur): Use complete lines when region is active for line-oriented occur. (occur-engine): Count lines either from occur--region-start-line or 1.
This commit is contained in:
parent
5c414441ed
commit
31350817ae
@ -1853,11 +1853,11 @@ replacements from Isearch is `M-s w ... M-%'."
|
||||
(concat "Query replace"
|
||||
(isearch--describe-regexp-mode (or delimited isearch-regexp-function) t)
|
||||
(if backward " backward" "")
|
||||
(if (and transient-mark-mode mark-active) " in region" ""))
|
||||
(if (use-region-p) " in region" ""))
|
||||
isearch-regexp)
|
||||
t isearch-regexp (or delimited isearch-regexp-function) nil nil
|
||||
(if (and transient-mark-mode mark-active) (region-beginning))
|
||||
(if (and transient-mark-mode mark-active) (region-end))
|
||||
(if (use-region-p) (region-beginning))
|
||||
(if (use-region-p) (region-end))
|
||||
backward))
|
||||
(and isearch-recursive-edit (exit-recursive-edit)))
|
||||
|
||||
@ -1920,7 +1920,8 @@ characters in that string."
|
||||
'isearch-regexp-function-descr
|
||||
(isearch--describe-regexp-mode isearch-regexp-function))
|
||||
regexp)
|
||||
nlines)))
|
||||
nlines
|
||||
(if (use-region-p) (region-bounds)))))
|
||||
|
||||
(declare-function hi-lock-read-face-name "hi-lock" ())
|
||||
|
||||
|
@ -1387,7 +1387,7 @@ invoke `occur'."
|
||||
;; Region limits when `occur' applies on a region.
|
||||
(defvar occur--region-start nil)
|
||||
(defvar occur--region-end nil)
|
||||
(defvar occur--matches-threshold nil)
|
||||
(defvar occur--region-start-line nil)
|
||||
(defvar occur--orig-line nil)
|
||||
(defvar occur--final-pos nil)
|
||||
|
||||
@ -1441,13 +1441,15 @@ is not modified."
|
||||
(or end (setq end (point-max))))
|
||||
(let ((occur--region-start start)
|
||||
(occur--region-end end)
|
||||
(occur--matches-threshold
|
||||
(occur--region-start-line
|
||||
(and in-region-p
|
||||
(line-number-at-pos (min start end))))
|
||||
(occur--orig-line
|
||||
(line-number-at-pos (point))))
|
||||
(save-excursion ; If no matches `occur-1' doesn't restore the point.
|
||||
(and in-region-p (narrow-to-region start end))
|
||||
(and in-region-p (narrow-to-region
|
||||
(save-excursion (goto-char start) (line-beginning-position))
|
||||
(save-excursion (goto-char end) (line-end-position))))
|
||||
(occur-1 regexp nlines (list (current-buffer)))
|
||||
(and in-region-p (widen))))))
|
||||
|
||||
@ -1621,7 +1623,7 @@ See also `multi-occur'."
|
||||
(let ((lines 0) ;; count of matching lines
|
||||
(matches 0) ;; count of matches
|
||||
(curr-line ;; line count
|
||||
(or occur--matches-threshold 1))
|
||||
(or occur--region-start-line 1))
|
||||
(orig-line occur--orig-line)
|
||||
(orig-line-shown-p)
|
||||
(prev-line nil) ;; line number of prev match endpt
|
||||
@ -1754,7 +1756,7 @@ See also `multi-occur'."
|
||||
(setq orig-line-shown-p t)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- orig-line))
|
||||
(forward-line (- orig-line (or occur--region-start-line 1)))
|
||||
(occur-engine-line (line-beginning-position)
|
||||
(line-end-position) keep-props)))))
|
||||
;; Actually insert the match display data
|
||||
@ -1792,7 +1794,7 @@ See also `multi-occur'."
|
||||
(let ((orig-line-str
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- orig-line))
|
||||
(forward-line (- orig-line (or occur--region-start-line 1)))
|
||||
(occur-engine-line (line-beginning-position)
|
||||
(line-end-position) keep-props))))
|
||||
(add-face-text-property
|
||||
|
Loading…
Reference in New Issue
Block a user