diff options
| author | Juri Linkov | 2018-02-06 23:20:10 +0200 |
|---|---|---|
| committer | Juri Linkov | 2018-02-06 23:20:10 +0200 |
| commit | 31350817ae6eda2e071dbc28f1f1edc50e5f3b0c (patch) | |
| tree | 60bc5152558543048b7dc6446ca27a13b7091926 /lisp/replace.el | |
| parent | 5c414441ed73f1a302a2953dc493e83b98589262 (diff) | |
| download | emacs-31350817ae6eda2e071dbc28f1f1edc50e5f3b0c.tar.gz emacs-31350817ae6eda2e071dbc28f1f1edc50e5f3b0c.zip | |
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.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 0efd0820966..c6892328d71 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -1387,7 +1387,7 @@ invoke `occur'." | |||
| 1387 | ;; Region limits when `occur' applies on a region. | 1387 | ;; Region limits when `occur' applies on a region. |
| 1388 | (defvar occur--region-start nil) | 1388 | (defvar occur--region-start nil) |
| 1389 | (defvar occur--region-end nil) | 1389 | (defvar occur--region-end nil) |
| 1390 | (defvar occur--matches-threshold nil) | 1390 | (defvar occur--region-start-line nil) |
| 1391 | (defvar occur--orig-line nil) | 1391 | (defvar occur--orig-line nil) |
| 1392 | (defvar occur--final-pos nil) | 1392 | (defvar occur--final-pos nil) |
| 1393 | 1393 | ||
| @@ -1441,13 +1441,15 @@ is not modified." | |||
| 1441 | (or end (setq end (point-max)))) | 1441 | (or end (setq end (point-max)))) |
| 1442 | (let ((occur--region-start start) | 1442 | (let ((occur--region-start start) |
| 1443 | (occur--region-end end) | 1443 | (occur--region-end end) |
| 1444 | (occur--matches-threshold | 1444 | (occur--region-start-line |
| 1445 | (and in-region-p | 1445 | (and in-region-p |
| 1446 | (line-number-at-pos (min start end)))) | 1446 | (line-number-at-pos (min start end)))) |
| 1447 | (occur--orig-line | 1447 | (occur--orig-line |
| 1448 | (line-number-at-pos (point)))) | 1448 | (line-number-at-pos (point)))) |
| 1449 | (save-excursion ; If no matches `occur-1' doesn't restore the point. | 1449 | (save-excursion ; If no matches `occur-1' doesn't restore the point. |
| 1450 | (and in-region-p (narrow-to-region start end)) | 1450 | (and in-region-p (narrow-to-region |
| 1451 | (save-excursion (goto-char start) (line-beginning-position)) | ||
| 1452 | (save-excursion (goto-char end) (line-end-position)))) | ||
| 1451 | (occur-1 regexp nlines (list (current-buffer))) | 1453 | (occur-1 regexp nlines (list (current-buffer))) |
| 1452 | (and in-region-p (widen)))))) | 1454 | (and in-region-p (widen)))))) |
| 1453 | 1455 | ||
| @@ -1621,7 +1623,7 @@ See also `multi-occur'." | |||
| 1621 | (let ((lines 0) ;; count of matching lines | 1623 | (let ((lines 0) ;; count of matching lines |
| 1622 | (matches 0) ;; count of matches | 1624 | (matches 0) ;; count of matches |
| 1623 | (curr-line ;; line count | 1625 | (curr-line ;; line count |
| 1624 | (or occur--matches-threshold 1)) | 1626 | (or occur--region-start-line 1)) |
| 1625 | (orig-line occur--orig-line) | 1627 | (orig-line occur--orig-line) |
| 1626 | (orig-line-shown-p) | 1628 | (orig-line-shown-p) |
| 1627 | (prev-line nil) ;; line number of prev match endpt | 1629 | (prev-line nil) ;; line number of prev match endpt |
| @@ -1754,7 +1756,7 @@ See also `multi-occur'." | |||
| 1754 | (setq orig-line-shown-p t) | 1756 | (setq orig-line-shown-p t) |
| 1755 | (save-excursion | 1757 | (save-excursion |
| 1756 | (goto-char (point-min)) | 1758 | (goto-char (point-min)) |
| 1757 | (forward-line (1- orig-line)) | 1759 | (forward-line (- orig-line (or occur--region-start-line 1))) |
| 1758 | (occur-engine-line (line-beginning-position) | 1760 | (occur-engine-line (line-beginning-position) |
| 1759 | (line-end-position) keep-props))))) | 1761 | (line-end-position) keep-props))))) |
| 1760 | ;; Actually insert the match display data | 1762 | ;; Actually insert the match display data |
| @@ -1792,7 +1794,7 @@ See also `multi-occur'." | |||
| 1792 | (let ((orig-line-str | 1794 | (let ((orig-line-str |
| 1793 | (save-excursion | 1795 | (save-excursion |
| 1794 | (goto-char (point-min)) | 1796 | (goto-char (point-min)) |
| 1795 | (forward-line (1- orig-line)) | 1797 | (forward-line (- orig-line (or occur--region-start-line 1))) |
| 1796 | (occur-engine-line (line-beginning-position) | 1798 | (occur-engine-line (line-beginning-position) |
| 1797 | (line-end-position) keep-props)))) | 1799 | (line-end-position) keep-props)))) |
| 1798 | (add-face-text-property | 1800 | (add-face-text-property |