aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorRichard M. Stallman2008-01-03 09:52:45 +0000
committerRichard M. Stallman2008-01-03 09:52:45 +0000
commitf8edc67ee2346ad2a569bd0575208a2504cbc616 (patch)
tree01348b16c3f2cbc2e49b8073114e499bbf827678 /lisp/replace.el
parent1c884795133931bf67bb3acddaa10554af35e57f (diff)
downloademacs-f8edc67ee2346ad2a569bd0575208a2504cbc616.tar.gz
emacs-f8edc67ee2346ad2a569bd0575208a2504cbc616.zip
(occur-context-lines): New subroutine, broken out of occur-engine.
(occur-engine): Call it.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el28
1 files changed, 18 insertions, 10 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index b76c64085c2..8bf6da30386 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1246,16 +1246,9 @@ See also `multi-occur'."
1246 (if (= nlines 0) 1246 (if (= nlines 0)
1247 ;; The simple display style 1247 ;; The simple display style
1248 out-line 1248 out-line
1249 ;; The complex multi-line display 1249 ;; The complex multi-line display style.
1250 ;; style. Generate a list of lines, 1250 (occur-context-lines out-line nlines keep-props)
1251 ;; concatenate them all together. 1251 )))
1252 (apply #'concat
1253 (nconc
1254 (occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ (abs nlines))) keep-props))))
1255 (list out-line)
1256 (if (> nlines 0)
1257 (occur-engine-add-prefix
1258 (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))))
1259 ;; Actually insert the match display data 1252 ;; Actually insert the match display data
1260 (with-current-buffer out-buf 1253 (with-current-buffer out-buf
1261 (let ((beg (point)) 1254 (let ((beg (point))
@@ -1293,6 +1286,21 @@ See also `multi-occur'."
1293 ;; Return the number of matches 1286 ;; Return the number of matches
1294 globalcount))) 1287 globalcount)))
1295 1288
1289;; Generate context display for occur.
1290;; OUT-LINE is the line where the match is.
1291;; NLINES and KEEP-PROPS are args to occur-engine.
1292;; Generate a list of lines, add prefixes to all but OUT-LINE,
1293;; then concatenate them all together.
1294(defun occur-context-lines (out-line nlines keep-props)
1295 (apply #'concat
1296 (nconc
1297 (occur-engine-add-prefix
1298 (nreverse (cdr (occur-accumulate-lines
1299 (- (1+ (abs nlines))) keep-props))))
1300 (list out-line)
1301 (if (> nlines 0)
1302 (occur-engine-add-prefix
1303 (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))
1296 1304
1297;; It would be nice to use \\[...], but there is no reasonable way 1305;; It would be nice to use \\[...], but there is no reasonable way
1298;; to make that display both SPC and Y. 1306;; to make that display both SPC and Y.