diff options
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/replace.el | 44 |
2 files changed, 45 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 68a9575bcbe..c27f5d25a0e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2013-03-24 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | * replace.el (list-matching-lines-prefix-face): New defcustom. | ||
| 4 | (occur-1): Pass `list-matching-lines-prefix-face' to the function | ||
| 5 | `occur-engine' if `face-differs-from-default-p' returns t. | ||
| 6 | (occur-engine): Add `,' inside backquote construct to evaluate | ||
| 7 | `prefix-face'. Propertize the prefix with the `prefix-face' face. | ||
| 8 | Pass `prefix-face' to the functions `occur-context-lines' and | ||
| 9 | `occur-engine-add-prefix'. | ||
| 10 | (occur-engine-add-prefix, occur-context-lines): Add optional arg | ||
| 11 | `prefix-face' and propertize the prefix with `prefix-face'. | ||
| 12 | (Bug#14017) | ||
| 13 | |||
| 1 | 2013-03-24 Leo Liu <sdl.web@gmail.com> | 14 | 2013-03-24 Leo Liu <sdl.web@gmail.com> |
| 2 | 15 | ||
| 3 | * nxml/rng-valid.el (rng-validate-while-idle) | 16 | * nxml/rng-valid.el (rng-validate-while-idle) |
diff --git a/lisp/replace.el b/lisp/replace.el index 17eea19edd8..1bebff448fa 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -1125,6 +1125,14 @@ If the value is nil, don't highlight the buffer names specially." | |||
| 1125 | :type 'face | 1125 | :type 'face |
| 1126 | :group 'matching) | 1126 | :group 'matching) |
| 1127 | 1127 | ||
| 1128 | (defcustom list-matching-lines-prefix-face 'shadow | ||
| 1129 | "Face used by \\[list-matching-lines] to show the prefix column. | ||
| 1130 | If the face doesn't differ from the default face, | ||
| 1131 | don't highlight the prefix with line numbers specially." | ||
| 1132 | :type 'face | ||
| 1133 | :group 'matching | ||
| 1134 | :version "24.4") | ||
| 1135 | |||
| 1128 | (defcustom occur-excluded-properties | 1136 | (defcustom occur-excluded-properties |
| 1129 | '(read-only invisible intangible field mouse-face help-echo local-map keymap | 1137 | '(read-only invisible intangible field mouse-face help-echo local-map keymap |
| 1130 | yank-handler follow-link) | 1138 | yank-handler follow-link) |
| @@ -1334,7 +1342,9 @@ See also `multi-occur'." | |||
| 1334 | (isearch-no-upper-case-p regexp t) | 1342 | (isearch-no-upper-case-p regexp t) |
| 1335 | case-fold-search) | 1343 | case-fold-search) |
| 1336 | list-matching-lines-buffer-name-face | 1344 | list-matching-lines-buffer-name-face |
| 1337 | nil list-matching-lines-face | 1345 | (if (face-differs-from-default-p list-matching-lines-prefix-face) |
| 1346 | list-matching-lines-prefix-face) | ||
| 1347 | list-matching-lines-face | ||
| 1338 | (not (eq occur-excluded-properties t)))))) | 1348 | (not (eq occur-excluded-properties t)))))) |
| 1339 | (let* ((bufcount (length active-bufs)) | 1349 | (let* ((bufcount (length active-bufs)) |
| 1340 | (diff (- (length bufs) bufcount))) | 1350 | (diff (- (length bufs) bufcount))) |
| @@ -1423,7 +1433,7 @@ See also `multi-occur'." | |||
| 1423 | (apply #'propertize (format "%7d:" lines) | 1433 | (apply #'propertize (format "%7d:" lines) |
| 1424 | (append | 1434 | (append |
| 1425 | (when prefix-face | 1435 | (when prefix-face |
| 1426 | `(font-lock-face prefix-face)) | 1436 | `(font-lock-face ,prefix-face)) |
| 1427 | `(occur-prefix t mouse-face (highlight) | 1437 | `(occur-prefix t mouse-face (highlight) |
| 1428 | ;; Allow insertion of text at | 1438 | ;; Allow insertion of text at |
| 1429 | ;; the end of the prefix (for | 1439 | ;; the end of the prefix (for |
| @@ -1447,7 +1457,9 @@ See also `multi-occur'." | |||
| 1447 | ;; of multi-line matches. | 1457 | ;; of multi-line matches. |
| 1448 | (replace-regexp-in-string | 1458 | (replace-regexp-in-string |
| 1449 | "\n" | 1459 | "\n" |
| 1450 | "\n :" | 1460 | (if prefix-face |
| 1461 | (propertize "\n :" 'font-lock-face prefix-face) | ||
| 1462 | "\n :") | ||
| 1451 | match-str) | 1463 | match-str) |
| 1452 | ;; Add marker at eol, but no mouse props. | 1464 | ;; Add marker at eol, but no mouse props. |
| 1453 | (propertize "\n" 'occur-target marker))) | 1465 | (propertize "\n" 'occur-target marker))) |
| @@ -1458,7 +1470,8 @@ See also `multi-occur'." | |||
| 1458 | ;; The complex multi-line display style. | 1470 | ;; The complex multi-line display style. |
| 1459 | (setq ret (occur-context-lines | 1471 | (setq ret (occur-context-lines |
| 1460 | out-line nlines keep-props begpt endpt | 1472 | out-line nlines keep-props begpt endpt |
| 1461 | lines prev-lines prev-after-lines)) | 1473 | lines prev-lines prev-after-lines |
| 1474 | prefix-face)) | ||
| 1462 | ;; Set first elem of the returned list to `data', | 1475 | ;; Set first elem of the returned list to `data', |
| 1463 | ;; and the second elem to `prev-after-lines'. | 1476 | ;; and the second elem to `prev-after-lines'. |
| 1464 | (setq prev-after-lines (nth 1 ret)) | 1477 | (setq prev-after-lines (nth 1 ret)) |
| @@ -1482,7 +1495,7 @@ See also `multi-occur'." | |||
| 1482 | (when prev-after-lines | 1495 | (when prev-after-lines |
| 1483 | (with-current-buffer out-buf | 1496 | (with-current-buffer out-buf |
| 1484 | (insert (apply #'concat (occur-engine-add-prefix | 1497 | (insert (apply #'concat (occur-engine-add-prefix |
| 1485 | prev-after-lines))))))) | 1498 | prev-after-lines prefix-face))))))) |
| 1486 | (when (not (zerop matches)) ;; is the count zero? | 1499 | (when (not (zerop matches)) ;; is the count zero? |
| 1487 | (setq globalcount (+ globalcount matches)) | 1500 | (setq globalcount (+ globalcount matches)) |
| 1488 | (with-current-buffer out-buf | 1501 | (with-current-buffer out-buf |
| @@ -1537,10 +1550,13 @@ See also `multi-occur'." | |||
| 1537 | str) | 1550 | str) |
| 1538 | (buffer-substring-no-properties beg end))) | 1551 | (buffer-substring-no-properties beg end))) |
| 1539 | 1552 | ||
| 1540 | (defun occur-engine-add-prefix (lines) | 1553 | (defun occur-engine-add-prefix (lines &optional prefix-face) |
| 1541 | (mapcar | 1554 | (mapcar |
| 1542 | #'(lambda (line) | 1555 | #'(lambda (line) |
| 1543 | (concat " :" line "\n")) | 1556 | (concat (if prefix-face |
| 1557 | (propertize " :" 'font-lock-face prefix-face) | ||
| 1558 | " :") | ||
| 1559 | line "\n")) | ||
| 1544 | lines)) | 1560 | lines)) |
| 1545 | 1561 | ||
| 1546 | (defun occur-accumulate-lines (count &optional keep-props pt) | 1562 | (defun occur-accumulate-lines (count &optional keep-props pt) |
| @@ -1569,7 +1585,8 @@ See also `multi-occur'." | |||
| 1569 | ;; Generate a list of lines, add prefixes to all but OUT-LINE, | 1585 | ;; Generate a list of lines, add prefixes to all but OUT-LINE, |
| 1570 | ;; then concatenate them all together. | 1586 | ;; then concatenate them all together. |
| 1571 | (defun occur-context-lines (out-line nlines keep-props begpt endpt | 1587 | (defun occur-context-lines (out-line nlines keep-props begpt endpt |
| 1572 | lines prev-lines prev-after-lines) | 1588 | lines prev-lines prev-after-lines |
| 1589 | &optional prefix-face) | ||
| 1573 | ;; Find after- and before-context lines of the current match. | 1590 | ;; Find after- and before-context lines of the current match. |
| 1574 | (let ((before-lines | 1591 | (let ((before-lines |
| 1575 | (nreverse (cdr (occur-accumulate-lines | 1592 | (nreverse (cdr (occur-accumulate-lines |
| @@ -1609,10 +1626,13 @@ See also `multi-occur'." | |||
| 1609 | ;; Return a list where the first element is the output line. | 1626 | ;; Return a list where the first element is the output line. |
| 1610 | (apply #'concat | 1627 | (apply #'concat |
| 1611 | (append | 1628 | (append |
| 1612 | (and prev-after-lines | 1629 | (if prev-after-lines |
| 1613 | (occur-engine-add-prefix prev-after-lines)) | 1630 | (occur-engine-add-prefix prev-after-lines prefix-face)) |
| 1614 | (and separator (list separator)) | 1631 | (if separator |
| 1615 | (occur-engine-add-prefix before-lines) | 1632 | (list (if prefix-face |
| 1633 | (propertize separator 'font-lock-face prefix-face) | ||
| 1634 | separator))) | ||
| 1635 | (occur-engine-add-prefix before-lines prefix-face) | ||
| 1616 | (list out-line))) | 1636 | (list out-line))) |
| 1617 | ;; And the second element is the list of context after-lines. | 1637 | ;; And the second element is the list of context after-lines. |
| 1618 | (if (> nlines 0) after-lines)))) | 1638 | (if (> nlines 0) after-lines)))) |