summaryrefslogtreecommitdiff
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-01-03 03:11:11 +0000
committerRichard M. Stallman <rms@gnu.org>1997-01-03 03:11:11 +0000
commit7b87b78108adc23b700ca30ce81a2e4ed8003f53 (patch)
tree70e57311f0fa3927180b957374238a49e9e7763f /lisp/replace.el
parent9aa46d7c4443c8ef46fa1404c6c4d1437a65355f (diff)
downloademacs-7b87b78108adc23b700ca30ce81a2e4ed8003f53.tar.gz
(list-matching-lines-face): New variable.
(occur): Highlight the actual matching characters.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el27
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.")
(defalias 'list-matching-lines 'occur)
+(defvar list-matching-lines-face 'bold
+ "*Face used by M-x list-matching-lines to show the text that matches.
+If the value is nil, don't highlight the matching portions specially.")
+
(defun occur (regexp &optional nlines)
"Show all lines in the current buffer containing a match for REGEXP.
@@ -352,6 +356,8 @@ It serves as a menu to find any of the occurrences in this buffer.
(dir default-directory)
(linenum 1)
(prevpos (point-min))
+ sje-start
+ sje-len
(final-context-start (make-marker)))
;;; (save-excursion
;;; (beginning-of-line)
@@ -399,6 +405,14 @@ It serves as a menu to find any of the occurrences in this buffer.
(forward-line (1+ nlines))
(forward-line 1))
(point)))
+ ;; Record where the actual match
+ (match-offset
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (beginning-of-line)
+ ;; +6 to skip over line number
+ (+ 6 (- (match-beginning 0) (point)))))
+ (match-len (- (match-end 0) (match-beginning 0)))
(tag (format "%5d" linenum))
(empty (make-string (length tag) ?\ ))
tem)
@@ -424,13 +438,20 @@ It serves as a menu to find any of the occurrences in this buffer.
(if (null tag)
(setq tag (format "%5d" this-linenum)))
(insert tag ?:)
- (put-text-property (save-excursion
- (beginning-of-line)
- (point))
+ (setq line-start
+ (save-excursion
+ (beginning-of-line)
+ (point)))
+ (put-text-property line-start
(save-excursion
(end-of-line)
(point))
'mouse-face 'highlight)
+ (if list-matching-lines-face
+ (put-text-property
+ (+ line-start match-offset)
+ (+ line-start match-offset match-len)
+ 'face list-matching-lines-face))
(forward-line 1)
(setq tag nil)
(setq this-linenum (1+ this-linenum)))