]> git.eshelyaron.com Git - emacs.git/commitdiff
(occur-context-lines): New subroutine, broken out of occur-engine.
authorRichard M. Stallman <rms@gnu.org>
Thu, 3 Jan 2008 09:52:45 +0000 (09:52 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 3 Jan 2008 09:52:45 +0000 (09:52 +0000)
(occur-engine): Call it.

lisp/ChangeLog
lisp/replace.el

index 06972d33e2314fd201c8d34184fd42051d0a69f4..da4dd53eda3934ac3d53bb955a9e0c016802841c 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-03  Richard Stallman  <rms@gnu.org>
+
+       * replace.el (occur-context-lines): New subroutine,
+       broken out of occur-engine.
+       (occur-engine): Call it.
+
 2008-01-03  Alexandre Julliard  <julliard@winehq.org>
 
        * vc-git.el (vc-git--ls-files-state): New function.
index b76c64085c23677cf4a3565f94414d01e5c9474e..8bf6da3038692cfcc29f246f64d9f621cde7ba46 100644 (file)
@@ -1246,16 +1246,9 @@ See also `multi-occur'."
                            (if (= nlines 0)
                                ;; The simple display style
                                out-line
-                             ;; The complex multi-line display
-                             ;; style.  Generate a list of lines,
-                             ;; concatenate them all together.
-                             (apply #'concat
-                                    (nconc
-                                     (occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ (abs nlines))) keep-props))))
-                                     (list out-line)
-                                     (if (> nlines 0)
-                                         (occur-engine-add-prefix
-                                          (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))))
+                             ;; The complex multi-line display style.
+                             (occur-context-lines out-line nlines keep-props)
+                             )))
                      ;; Actually insert the match display data
                      (with-current-buffer out-buf
                        (let ((beg (point))
@@ -1293,6 +1286,21 @@ See also `multi-occur'."
       ;; Return the number of matches
       globalcount)))
 
+;; Generate context display for occur.
+;; OUT-LINE is the line where the match is.
+;; NLINES and KEEP-PROPS are args to occur-engine.
+;; Generate a list of lines, add prefixes to all but OUT-LINE,
+;; then concatenate them all together.
+(defun occur-context-lines (out-line nlines keep-props)
+  (apply #'concat
+        (nconc
+         (occur-engine-add-prefix
+          (nreverse (cdr (occur-accumulate-lines
+                          (- (1+ (abs nlines))) keep-props))))
+         (list out-line)
+         (if (> nlines 0)
+             (occur-engine-add-prefix
+              (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))
 \f
 ;; It would be nice to use \\[...], but there is no reasonable way
 ;; to make that display both SPC and Y.