diff options
| author | Juri Linkov | 2005-11-09 07:41:48 +0000 |
|---|---|---|
| committer | Juri Linkov | 2005-11-09 07:41:48 +0000 |
| commit | 8b363e6f08ce2f37fa84522b3ceb44440b9fe124 (patch) | |
| tree | b8015a6b73c1d1c5039d9e076db59f64ecdf1859 /lisp/replace.el | |
| parent | 217d155e3aba291dfb31d3e29333c7ea940b3cac (diff) | |
| download | emacs-8b363e6f08ce2f37fa84522b3ceb44440b9fe124.tar.gz emacs-8b363e6f08ce2f37fa84522b3ceb44440b9fe124.zip | |
(occur-excluded-properties): New defcustom.
(occur-1, occur-engine, occur-accumulate-lines): Use it.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 3016f5f6198..e74b8690c28 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -878,6 +878,16 @@ If the value is nil, don't highlight the buffer names specially." | |||
| 878 | :type 'face | 878 | :type 'face |
| 879 | :group 'matching) | 879 | :group 'matching) |
| 880 | 880 | ||
| 881 | (defcustom occur-excluded-properties | ||
| 882 | '(read-only invisible intangible field mouse-face help-echo local-map keymap | ||
| 883 | yank-handler follow-link) | ||
| 884 | "*Text properties to discard when copying lines to the *Occur* buffer. | ||
| 885 | The value should be a list of text properties to discard or t, | ||
| 886 | which means to discard all text properties." | ||
| 887 | :type '(choice (const :tag "All" t) (repeat symbol)) | ||
| 888 | :group 'matching | ||
| 889 | :version "22.1") | ||
| 890 | |||
| 881 | (defun occur-accumulate-lines (count &optional keep-props) | 891 | (defun occur-accumulate-lines (count &optional keep-props) |
| 882 | (save-excursion | 892 | (save-excursion |
| 883 | (let ((forwardp (> count 0)) | 893 | (let ((forwardp (> count 0)) |
| @@ -894,10 +904,12 @@ If the value is nil, don't highlight the buffer names specially." | |||
| 894 | (if (fboundp 'jit-lock-fontify-now) | 904 | (if (fboundp 'jit-lock-fontify-now) |
| 895 | (jit-lock-fontify-now beg end))) | 905 | (jit-lock-fontify-now beg end))) |
| 896 | (push | 906 | (push |
| 897 | (funcall (if keep-props | 907 | (if (and keep-props (not (eq occur-excluded-properties t))) |
| 898 | #'buffer-substring | 908 | (let ((str (buffer-substring beg end))) |
| 899 | #'buffer-substring-no-properties) | 909 | (remove-list-of-text-properties |
| 900 | beg end) | 910 | 0 (length str) occur-excluded-properties str) |
| 911 | str) | ||
| 912 | (buffer-substring-no-properties beg end)) | ||
| 901 | result) | 913 | result) |
| 902 | (forward-line (if forwardp 1 -1))) | 914 | (forward-line (if forwardp 1 -1))) |
| 903 | (nreverse result)))) | 915 | (nreverse result)))) |
| @@ -1033,7 +1045,8 @@ See also `multi-occur'." | |||
| 1033 | (and case-fold-search | 1045 | (and case-fold-search |
| 1034 | (isearch-no-upper-case-p regexp t)) | 1046 | (isearch-no-upper-case-p regexp t)) |
| 1035 | list-matching-lines-buffer-name-face | 1047 | list-matching-lines-buffer-name-face |
| 1036 | nil list-matching-lines-face t))) | 1048 | nil list-matching-lines-face |
| 1049 | (not (eq occur-excluded-properties t))))) | ||
| 1037 | (let* ((bufcount (length active-bufs)) | 1050 | (let* ((bufcount (length active-bufs)) |
| 1038 | (diff (- (length bufs) bufcount))) | 1051 | (diff (- (length bufs) bufcount))) |
| 1039 | (message "Searched %d buffer%s%s; %s match%s for `%s'" | 1052 | (message "Searched %d buffer%s%s; %s match%s for `%s'" |
| @@ -1102,13 +1115,15 @@ See also `multi-occur'." | |||
| 1102 | (text-property-not-all begpt endpt 'fontified t)) | 1115 | (text-property-not-all begpt endpt 'fontified t)) |
| 1103 | (if (fboundp 'jit-lock-fontify-now) | 1116 | (if (fboundp 'jit-lock-fontify-now) |
| 1104 | (jit-lock-fontify-now begpt endpt))) | 1117 | (jit-lock-fontify-now begpt endpt))) |
| 1105 | (setq curstring (buffer-substring begpt endpt)) | 1118 | (if (and keep-props (not (eq occur-excluded-properties t))) |
| 1106 | ;; Depropertize the string, and maybe | 1119 | (progn |
| 1107 | ;; highlight the matches | 1120 | (setq curstring (buffer-substring begpt endpt)) |
| 1121 | (remove-list-of-text-properties | ||
| 1122 | 0 (length curstring) occur-excluded-properties curstring)) | ||
| 1123 | (setq curstring (buffer-substring-no-properties begpt endpt))) | ||
| 1124 | ;; Highlight the matches | ||
| 1108 | (let ((len (length curstring)) | 1125 | (let ((len (length curstring)) |
| 1109 | (start 0)) | 1126 | (start 0)) |
| 1110 | (unless keep-props | ||
| 1111 | (set-text-properties 0 len nil curstring)) | ||
| 1112 | (while (and (< start len) | 1127 | (while (and (< start len) |
| 1113 | (string-match regexp curstring start)) | 1128 | (string-match regexp curstring start)) |
| 1114 | (add-text-properties | 1129 | (add-text-properties |