diff options
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index ed02e051506..30c07377e29 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -317,6 +317,10 @@ A positive number means to include that many lines both before and after.") | |||
| 317 | 317 | ||
| 318 | (defalias 'list-matching-lines 'occur) | 318 | (defalias 'list-matching-lines 'occur) |
| 319 | 319 | ||
| 320 | (defvar list-matching-lines-face 'bold | ||
| 321 | "*Face used by M-x list-matching-lines to show the text that matches. | ||
| 322 | If the value is nil, don't highlight the matching portions specially.") | ||
| 323 | |||
| 320 | (defun occur (regexp &optional nlines) | 324 | (defun occur (regexp &optional nlines) |
| 321 | "Show all lines in the current buffer containing a match for REGEXP. | 325 | "Show all lines in the current buffer containing a match for REGEXP. |
| 322 | 326 | ||
| @@ -352,6 +356,8 @@ It serves as a menu to find any of the occurrences in this buffer. | |||
| 352 | (dir default-directory) | 356 | (dir default-directory) |
| 353 | (linenum 1) | 357 | (linenum 1) |
| 354 | (prevpos (point-min)) | 358 | (prevpos (point-min)) |
| 359 | sje-start | ||
| 360 | sje-len | ||
| 355 | (final-context-start (make-marker))) | 361 | (final-context-start (make-marker))) |
| 356 | ;;; (save-excursion | 362 | ;;; (save-excursion |
| 357 | ;;; (beginning-of-line) | 363 | ;;; (beginning-of-line) |
| @@ -399,6 +405,14 @@ It serves as a menu to find any of the occurrences in this buffer. | |||
| 399 | (forward-line (1+ nlines)) | 405 | (forward-line (1+ nlines)) |
| 400 | (forward-line 1)) | 406 | (forward-line 1)) |
| 401 | (point))) | 407 | (point))) |
| 408 | ;; Record where the actual match | ||
| 409 | (match-offset | ||
| 410 | (save-excursion | ||
| 411 | (goto-char (match-beginning 0)) | ||
| 412 | (beginning-of-line) | ||
| 413 | ;; +6 to skip over line number | ||
| 414 | (+ 6 (- (match-beginning 0) (point))))) | ||
| 415 | (match-len (- (match-end 0) (match-beginning 0))) | ||
| 402 | (tag (format "%5d" linenum)) | 416 | (tag (format "%5d" linenum)) |
| 403 | (empty (make-string (length tag) ?\ )) | 417 | (empty (make-string (length tag) ?\ )) |
| 404 | tem) | 418 | tem) |
| @@ -424,13 +438,20 @@ It serves as a menu to find any of the occurrences in this buffer. | |||
| 424 | (if (null tag) | 438 | (if (null tag) |
| 425 | (setq tag (format "%5d" this-linenum))) | 439 | (setq tag (format "%5d" this-linenum))) |
| 426 | (insert tag ?:) | 440 | (insert tag ?:) |
| 427 | (put-text-property (save-excursion | 441 | (setq line-start |
| 428 | (beginning-of-line) | 442 | (save-excursion |
| 429 | (point)) | 443 | (beginning-of-line) |
| 444 | (point))) | ||
| 445 | (put-text-property line-start | ||
| 430 | (save-excursion | 446 | (save-excursion |
| 431 | (end-of-line) | 447 | (end-of-line) |
| 432 | (point)) | 448 | (point)) |
| 433 | 'mouse-face 'highlight) | 449 | 'mouse-face 'highlight) |
| 450 | (if list-matching-lines-face | ||
| 451 | (put-text-property | ||
| 452 | (+ line-start match-offset) | ||
| 453 | (+ line-start match-offset match-len) | ||
| 454 | 'face list-matching-lines-face)) | ||
| 434 | (forward-line 1) | 455 | (forward-line 1) |
| 435 | (setq tag nil) | 456 | (setq tag nil) |
| 436 | (setq this-linenum (1+ this-linenum))) | 457 | (setq this-linenum (1+ this-linenum))) |