diff options
| author | Colin Walters | 2002-04-23 20:35:37 +0000 |
|---|---|---|
| committer | Colin Walters | 2002-04-23 20:35:37 +0000 |
| commit | c06bd65eac1292cf5f7f424eac4599fe8f49c161 (patch) | |
| tree | e30adc4554850730d28dc9798a9d02cac77c0aa3 | |
| parent | 68608d9c9fd22c29aa52ba67aabbfff8fbf5e73d (diff) | |
| download | emacs-c06bd65eac1292cf5f7f424eac4599fe8f49c161.tar.gz emacs-c06bd65eac1292cf5f7f424eac4599fe8f49c161.zip | |
(ibuffer-depropertize-string): Delete.
(ibuffer-occur-match-face): Delete.
(ibuffer-occur-props, ibuffer-occur-mode): Delete.
(ibuffer-occur-mouse-display-occurence): Delete.
(ibuffer-occur-goto-occurence, ibuffer-occur-display-occurence):
Delete.
(ibuffer-do-occur-1, ibuffer-occur-revert-buffer-function):
Delete.
(ibuffer-occur-engine): Moved to replace.el.
(ibuffer-do-occur): Simply call `occur-1'.
| -rw-r--r-- | lisp/ibuf-ext.el | 221 |
1 files changed, 1 insertions, 220 deletions
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 64e335c3540..6669846ebc0 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el | |||
| @@ -46,15 +46,6 @@ | |||
| 46 | (setq alist (delete entry alist))) | 46 | (setq alist (delete entry alist))) |
| 47 | alist)) | 47 | alist)) |
| 48 | 48 | ||
| 49 | (defun ibuffer-depropertize-string (str &optional nocopy) | ||
| 50 | "Return a copy of STR with text properties removed. | ||
| 51 | If optional argument NOCOPY is non-nil, actually modify the string directly." | ||
| 52 | (let ((str (if nocopy | ||
| 53 | str | ||
| 54 | (copy-sequence str)))) | ||
| 55 | (set-text-properties 0 (length str) nil str) | ||
| 56 | str)) | ||
| 57 | |||
| 58 | (defcustom ibuffer-never-show-predicates nil | 49 | (defcustom ibuffer-never-show-predicates nil |
| 59 | "A list of predicates (a regexp or function) for buffers not to display. | 50 | "A list of predicates (a regexp or function) for buffers not to display. |
| 60 | If a regexp, then it will be matched against the buffer's name. | 51 | If a regexp, then it will be matched against the buffer's name. |
| @@ -86,11 +77,6 @@ Do not set this variable directly! Use the function | |||
| 86 | 77 | ||
| 87 | (defvar ibuffer-auto-buffers-changed nil) | 78 | (defvar ibuffer-auto-buffers-changed nil) |
| 88 | 79 | ||
| 89 | (defcustom ibuffer-occur-match-face 'font-lock-warning-face | ||
| 90 | "Face used for displaying matched strings for `ibuffer-do-occur'." | ||
| 91 | :type 'face | ||
| 92 | :group 'ibuffer) | ||
| 93 | |||
| 94 | (defcustom ibuffer-saved-filters '(("gnus" | 80 | (defcustom ibuffer-saved-filters '(("gnus" |
| 95 | ((or (mode . message-mode) | 81 | ((or (mode . message-mode) |
| 96 | (mode . mail-mode) | 82 | (mode . mail-mode) |
| @@ -1060,72 +1046,6 @@ You can then feed the file name(s) to other commands with C-y. | |||
| 1060 | (with-current-buffer buf | 1046 | (with-current-buffer buf |
| 1061 | (eq major-mode 'dired-mode))))) | 1047 | (eq major-mode 'dired-mode))))) |
| 1062 | 1048 | ||
| 1063 | ;;; An implementation of multi-buffer `occur' | ||
| 1064 | |||
| 1065 | (defvar ibuffer-occur-props nil) | ||
| 1066 | |||
| 1067 | (define-derived-mode ibuffer-occur-mode occur-mode "Ibuffer-Occur" | ||
| 1068 | "A special form of Occur mode for multiple buffers. | ||
| 1069 | Note this major mode is not meant for interactive use! | ||
| 1070 | See also `occur-mode'." | ||
| 1071 | (define-key ibuffer-occur-mode-map (kbd "n") 'forward-line) | ||
| 1072 | (define-key ibuffer-occur-mode-map (kbd "q") 'bury-buffer) | ||
| 1073 | (define-key ibuffer-occur-mode-map (kbd "p") 'previous-line) | ||
| 1074 | (define-key ibuffer-occur-mode-map (kbd "RET") 'ibuffer-occur-display-occurence) | ||
| 1075 | (define-key ibuffer-occur-mode-map (kbd "f") 'ibuffer-occur-goto-occurence) | ||
| 1076 | (define-key ibuffer-occur-mode-map [(mouse-2)] 'ibuffer-occur-mouse-display-occurence) | ||
| 1077 | (set (make-local-variable 'revert-buffer-function) | ||
| 1078 | #'ibuffer-occur-revert-buffer-function) | ||
| 1079 | (set (make-local-variable 'ibuffer-occur-props) nil) | ||
| 1080 | (setq buffer-read-only nil) | ||
| 1081 | (erase-buffer) | ||
| 1082 | (setq buffer-read-only t) | ||
| 1083 | (message (concat | ||
| 1084 | "Use RET " | ||
| 1085 | (if (or (and (< 21 emacs-major-version) | ||
| 1086 | window-system) | ||
| 1087 | (featurep 'mouse)) | ||
| 1088 | "or mouse-2 ") | ||
| 1089 | "to display an occurence."))) | ||
| 1090 | |||
| 1091 | (defun ibuffer-occur-mouse-display-occurence (e) | ||
| 1092 | "Display occurence on this line in another window." | ||
| 1093 | (interactive "e") | ||
| 1094 | (let* ((occurbuf (save-window-excursion (mouse-select-window e) | ||
| 1095 | (selected-window))) | ||
| 1096 | (target (with-current-buffer occurbuf | ||
| 1097 | (get-text-property (save-excursion | ||
| 1098 | (mouse-set-point e) | ||
| 1099 | (point)) | ||
| 1100 | 'ibuffer-occur-target)))) | ||
| 1101 | (unless target | ||
| 1102 | (error "No occurence on this line")) | ||
| 1103 | (let ((buf (car target)) | ||
| 1104 | (line (cdr target))) | ||
| 1105 | (switch-to-buffer occurbuf) | ||
| 1106 | (delete-other-windows) | ||
| 1107 | (pop-to-buffer buf) | ||
| 1108 | (goto-line line)))) | ||
| 1109 | |||
| 1110 | (defun ibuffer-occur-goto-occurence () | ||
| 1111 | "Switch to the buffer which has the occurence on this line." | ||
| 1112 | (interactive) | ||
| 1113 | (ibuffer-occur-display-occurence t)) | ||
| 1114 | |||
| 1115 | (defun ibuffer-occur-display-occurence (&optional goto) | ||
| 1116 | "Display occurence on this line in another window." | ||
| 1117 | (interactive "P") | ||
| 1118 | (let ((target (get-text-property (point) 'ibuffer-occur-target))) | ||
| 1119 | (unless target | ||
| 1120 | (error "No occurence on this line")) | ||
| 1121 | (let ((buf (car target)) | ||
| 1122 | (line (cdr target))) | ||
| 1123 | (delete-other-windows) | ||
| 1124 | (if goto | ||
| 1125 | (switch-to-buffer buf) | ||
| 1126 | (pop-to-buffer buf)) | ||
| 1127 | (goto-line line)))) | ||
| 1128 | |||
| 1129 | ;;;###autoload | 1049 | ;;;###autoload |
| 1130 | (defun ibuffer-do-occur (regexp &optional nlines) | 1050 | (defun ibuffer-do-occur (regexp &optional nlines) |
| 1131 | "View lines which match REGEXP in all marked buffers. | 1051 | "View lines which match REGEXP in all marked buffers. |
| @@ -1157,146 +1077,7 @@ defaults to one." | |||
| 1157 | (ibuffer-map-marked-lines | 1077 | (ibuffer-map-marked-lines |
| 1158 | #'(lambda (buf mark) | 1078 | #'(lambda (buf mark) |
| 1159 | (push buf ibuffer-do-occur-bufs))) | 1079 | (push buf ibuffer-do-occur-bufs))) |
| 1160 | (ibuffer-do-occur-1 regexp ibuffer-do-occur-bufs | 1080 | (occur-1 regexp nlines ibuffer-do-occur-bufs))) |
| 1161 | (get-buffer-create "*Ibuffer-occur*") | ||
| 1162 | nlines))) | ||
| 1163 | |||
| 1164 | (defun ibuffer-do-occur-1 (regexp buffers out-buf nlines) | ||
| 1165 | (let ((count (ibuffer-occur-engine regexp buffers out-buf nlines))) | ||
| 1166 | (if (> count 0) | ||
| 1167 | (progn | ||
| 1168 | (switch-to-buffer out-buf) | ||
| 1169 | (setq buffer-read-only t) | ||
| 1170 | (delete-other-windows) | ||
| 1171 | (goto-char (point-min)) | ||
| 1172 | (message "Found %s matches in %s buffers" count (length buffers))) | ||
| 1173 | (message "No matches found")))) | ||
| 1174 | |||
| 1175 | |||
| 1176 | (defun ibuffer-occur-revert-buffer-function (ignore-auto noconfirm) | ||
| 1177 | "Update the *Ibuffer occur* buffer." | ||
| 1178 | (assert (eq major-mode 'ibuffer-occur-mode)) | ||
| 1179 | (ibuffer-do-occur-1 (car ibuffer-occur-props) | ||
| 1180 | (cadr ibuffer-occur-props) | ||
| 1181 | (current-buffer) | ||
| 1182 | (caddr ibuffer-occur-props))) | ||
| 1183 | |||
| 1184 | (defun ibuffer-occur-engine (regexp buffers out-buf nlines) | ||
| 1185 | (macrolet ((insert-get-point | ||
| 1186 | (&rest args) | ||
| 1187 | `(progn | ||
| 1188 | (insert ,@args) | ||
| 1189 | (point))) | ||
| 1190 | (maybe-put-overlay | ||
| 1191 | (over prop value) | ||
| 1192 | `(when (ibuffer-use-fontification) | ||
| 1193 | (overlay-put ,over ,prop ,value))) | ||
| 1194 | (maybe-ibuffer-propertize | ||
| 1195 | (obj &rest args) | ||
| 1196 | (let ((objsym (gensym "--maybe-ibuffer-propertize-"))) | ||
| 1197 | `(let ((,objsym ,obj)) | ||
| 1198 | (if (ibuffer-use-fontification) | ||
| 1199 | (propertize ,objsym ,@args) | ||
| 1200 | ,objsym))))) | ||
| 1201 | (with-current-buffer out-buf | ||
| 1202 | (ibuffer-occur-mode) | ||
| 1203 | (setq buffer-read-only nil) | ||
| 1204 | (let ((globalcount 0)) | ||
| 1205 | ;; Map over all the buffers | ||
| 1206 | (dolist (buf buffers) | ||
| 1207 | (when (buffer-live-p buf) | ||
| 1208 | (let ((c 0) ;; count of matched lines | ||
| 1209 | (l 1) ;; line count | ||
| 1210 | (headerpt (with-current-buffer out-buf (point)))) | ||
| 1211 | (save-excursion | ||
| 1212 | (set-buffer buf) | ||
| 1213 | (save-excursion | ||
| 1214 | (goto-char (point-min)) ;; begin searching in the buffer | ||
| 1215 | (while (not (eobp)) | ||
| 1216 | ;; The line we're matching against | ||
| 1217 | (let ((curline (buffer-substring | ||
| 1218 | (line-beginning-position) | ||
| 1219 | (line-end-position)))) | ||
| 1220 | (when (string-match regexp curline) | ||
| 1221 | (incf c) ;; increment match count | ||
| 1222 | (incf globalcount) | ||
| 1223 | ;; Depropertize the string, and maybe highlight the matches | ||
| 1224 | (setq curline | ||
| 1225 | (progn | ||
| 1226 | (ibuffer-depropertize-string curline t) | ||
| 1227 | (when (ibuffer-use-fontification) | ||
| 1228 | (let ((len (length curline)) | ||
| 1229 | (start 0)) | ||
| 1230 | (while (and (< start len) | ||
| 1231 | (string-match regexp curline start)) | ||
| 1232 | (put-text-property (match-beginning 0) | ||
| 1233 | (match-end 0) | ||
| 1234 | 'face ibuffer-occur-match-face | ||
| 1235 | curline) | ||
| 1236 | (setq start (match-end 0))))) | ||
| 1237 | curline)) | ||
| 1238 | ;; Generate the string to insert for this match | ||
| 1239 | (let ((data | ||
| 1240 | (if (= nlines 1) | ||
| 1241 | ;; The simple display style | ||
| 1242 | (concat (maybe-ibuffer-propertize | ||
| 1243 | (format "%-6d:" l) | ||
| 1244 | 'face 'bold) | ||
| 1245 | curline | ||
| 1246 | "\n") | ||
| 1247 | ;; The complex multi-line display style | ||
| 1248 | (let ((prevlines (nreverse | ||
| 1249 | (ibuffer-accumulate-lines (- nlines)))) | ||
| 1250 | (nextlines (ibuffer-accumulate-lines nlines)) | ||
| 1251 | ;; The lack of `flet' seriously sucks. | ||
| 1252 | (fun #'(lambda (lines) | ||
| 1253 | (mapcar | ||
| 1254 | #'(lambda (line) | ||
| 1255 | (concat " :" line "\n")) | ||
| 1256 | lines)))) | ||
| 1257 | (setq prevlines (funcall fun prevlines)) | ||
| 1258 | (setq nextlines (funcall fun nextlines)) | ||
| 1259 | ;; Yes, I am trying to win the award for the | ||
| 1260 | ;; most consing. | ||
| 1261 | (apply #'concat | ||
| 1262 | (nconc | ||
| 1263 | prevlines | ||
| 1264 | (list | ||
| 1265 | (concat | ||
| 1266 | (maybe-ibuffer-propertize | ||
| 1267 | (format "%-6d" l) | ||
| 1268 | 'face 'bold) | ||
| 1269 | ":" | ||
| 1270 | curline | ||
| 1271 | "\n")) | ||
| 1272 | nextlines)))))) | ||
| 1273 | ;; Actually insert the match display data | ||
| 1274 | (with-current-buffer out-buf | ||
| 1275 | (let ((beg (point)) | ||
| 1276 | (end (insert-get-point | ||
| 1277 | data))) | ||
| 1278 | (unless (= nlines 1) | ||
| 1279 | (insert "-------\n")) | ||
| 1280 | (put-text-property | ||
| 1281 | beg (1- end) 'ibuffer-occur-target (cons buf l)) | ||
| 1282 | (put-text-property | ||
| 1283 | beg (1- end) 'mouse-face 'highlight)))))) | ||
| 1284 | ;; On to the next line... | ||
| 1285 | (incf l) | ||
| 1286 | (forward-line 1)))) | ||
| 1287 | (when (not (zerop c)) ;; is the count zero? | ||
| 1288 | (with-current-buffer out-buf | ||
| 1289 | (goto-char headerpt) | ||
| 1290 | (let ((beg (point)) | ||
| 1291 | (end (insert-get-point | ||
| 1292 | (format "%d lines matching \"%s\" in buffer %s\n" | ||
| 1293 | c regexp (buffer-name buf))))) | ||
| 1294 | (let ((o (make-overlay beg end))) | ||
| 1295 | (maybe-put-overlay o 'face 'underline))) | ||
| 1296 | (goto-char (point-max))))))) | ||
| 1297 | (setq ibuffer-occur-props (list regexp buffers nlines)) | ||
| 1298 | ;; Return the number of matches | ||
| 1299 | globalcount)))) | ||
| 1300 | 1081 | ||
| 1301 | (provide 'ibuf-ext) | 1082 | (provide 'ibuf-ext) |
| 1302 | 1083 | ||