aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2015-11-20 02:00:48 +0200
committerJuri Linkov2015-11-20 02:00:48 +0200
commit32845e3aad4d45a03851e92973ce0d31fd8a81e1 (patch)
treef738dcb17c7a754f519daa28a97b57bbef064b79
parentc593538968a6d6c3d03da9ef6f489da6210e70e1 (diff)
downloademacs-32845e3aad4d45a03851e92973ce0d31fd8a81e1.tar.gz
emacs-32845e3aad4d45a03851e92973ce0d31fd8a81e1.zip
* lisp/replace.el (occur-regexp-descr): New function.
(occur-1, occur-engine): Use it. * lisp/isearch.el (isearch-occur): Propertize regexp with isearch-string and isearch-regexp-function-descr for occur-regexp-descr to display the correct description message in the header (bug#21176, bug#21180).
-rw-r--r--lisp/isearch.el8
-rw-r--r--lisp/replace.el26
2 files changed, 26 insertions, 8 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 9f8ba8d8d7b..080eb578aa7 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1828,7 +1828,13 @@ characters in that string."
1828 isearch-regexp-lax-whitespace 1828 isearch-regexp-lax-whitespace
1829 isearch-lax-whitespace) 1829 isearch-lax-whitespace)
1830 search-whitespace-regexp))) 1830 search-whitespace-regexp)))
1831 (occur regexp nlines))) 1831 (occur (if isearch-regexp-function
1832 (propertize regexp
1833 'isearch-string isearch-string
1834 'isearch-regexp-function-descr
1835 (isearch--describe-regexp-mode isearch-regexp-function))
1836 regexp)
1837 nlines)))
1832 1838
1833(declare-function hi-lock-read-face-name "hi-lock" ()) 1839(declare-function hi-lock-read-face-name "hi-lock" ())
1834 1840
diff --git a/lisp/replace.el b/lisp/replace.el
index b6802aeaf57..7727562cf31 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1416,6 +1416,17 @@ See also `multi-occur'."
1416 buf)) 1416 buf))
1417 (buffer-list)))))) 1417 (buffer-list))))))
1418 1418
1419(defun occur-regexp-descr (regexp)
1420 (format " for %s\"%s\""
1421 (or (get-text-property 0 'isearch-regexp-function-descr regexp)
1422 "")
1423 (if (get-text-property 0 'isearch-string regexp)
1424 (propertize
1425 (query-replace-descr
1426 (get-text-property 0 'isearch-string regexp))
1427 'help-echo regexp)
1428 (query-replace-descr regexp))))
1429
1419(defun occur-1 (regexp nlines bufs &optional buf-name) 1430(defun occur-1 (regexp nlines bufs &optional buf-name)
1420 (unless (and regexp (not (equal regexp ""))) 1431 (unless (and regexp (not (equal regexp "")))
1421 (error "Occur doesn't work with the empty regexp")) 1432 (error "Occur doesn't work with the empty regexp"))
@@ -1484,9 +1495,11 @@ See also `multi-occur'."
1484 (if (= count 1) "" "es") 1495 (if (= count 1) "" "es")
1485 ;; Don't display regexp if with remaining text 1496 ;; Don't display regexp if with remaining text
1486 ;; it is longer than window-width. 1497 ;; it is longer than window-width.
1487 (if (> (+ (length regexp) 42) (window-width)) 1498 (if (> (+ (length (or (get-text-property 0 'isearch-string regexp)
1488 "" (format-message 1499 regexp))
1489 " for `%s'" (query-replace-descr regexp))))) 1500 42)
1501 (window-width))
1502 "" (occur-regexp-descr regexp))))
1490 (setq occur-revert-arguments (list regexp nlines bufs)) 1503 (setq occur-revert-arguments (list regexp nlines bufs))
1491 (if (= count 0) 1504 (if (= count 0)
1492 (kill-buffer occur-buf) 1505 (kill-buffer occur-buf)
@@ -1647,8 +1660,7 @@ See also `multi-occur'."
1647 lines (if (= lines 1) "" "s"))) 1660 lines (if (= lines 1) "" "s")))
1648 ;; Don't display regexp for multi-buffer. 1661 ;; Don't display regexp for multi-buffer.
1649 (if (> (length buffers) 1) 1662 (if (> (length buffers) 1)
1650 "" (format " for \"%s\"" 1663 "" (occur-regexp-descr regexp))
1651 (query-replace-descr regexp)))
1652 (buffer-name buf)) 1664 (buffer-name buf))
1653 'read-only t)) 1665 'read-only t))
1654 (setq end (point)) 1666 (setq end (point))
@@ -1661,14 +1673,14 @@ See also `multi-occur'."
1661 (goto-char (point-min)) 1673 (goto-char (point-min))
1662 (let ((beg (point)) 1674 (let ((beg (point))
1663 end) 1675 end)
1664 (insert (format "%d match%s%s total for \"%s\":\n" 1676 (insert (format "%d match%s%s total%s:\n"
1665 global-matches (if (= global-matches 1) "" "es") 1677 global-matches (if (= global-matches 1) "" "es")
1666 ;; Don't display the same number of lines 1678 ;; Don't display the same number of lines
1667 ;; and matches in case of 1 match per line. 1679 ;; and matches in case of 1 match per line.
1668 (if (= global-lines global-matches) 1680 (if (= global-lines global-matches)
1669 "" (format " in %d line%s" 1681 "" (format " in %d line%s"
1670 global-lines (if (= global-lines 1) "" "s"))) 1682 global-lines (if (= global-lines 1) "" "s")))
1671 (query-replace-descr regexp))) 1683 (occur-regexp-descr regexp)))
1672 (setq end (point)) 1684 (setq end (point))
1673 (when title-face 1685 (when title-face
1674 (add-face-text-property beg end title-face))) 1686 (add-face-text-property beg end title-face)))