aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2010-03-30 19:38:45 +0300
committerJuri Linkov2010-03-30 19:38:45 +0300
commit0ef84fc806f9f4c08f1ce0ba046fbc46af2ff9e6 (patch)
treec5ba8a21bbf48e47d48ad79ccb0d9952ce2a7620
parentbd924a5d6cea9a17c4c46f6ce3ecdef875dad69f (diff)
downloademacs-0ef84fc806f9f4c08f1ce0ba046fbc46af2ff9e6.tar.gz
emacs-0ef84fc806f9f4c08f1ce0ba046fbc46af2ff9e6.zip
* replace.el (occur-accumulate-lines): Move occur-engine related
functions `occur-accumulate-lines' and `occur-engine-add-prefix' to be located after `occur-engine'.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/replace.el46
2 files changed, 29 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 301d061c822..426db447d51 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -4,6 +4,12 @@
4 4
52010-03-30 Juri Linkov <juri@jurta.org> 52010-03-30 Juri Linkov <juri@jurta.org>
6 6
7 * replace.el (occur-accumulate-lines): Move occur-engine related
8 functions `occur-accumulate-lines' and `occur-engine-add-prefix'
9 to be located after `occur-engine'.
10
112010-03-30 Juri Linkov <juri@jurta.org>
12
7 Make occur handle multi-line matches cleanly with context. 13 Make occur handle multi-line matches cleanly with context.
8 http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01280.html 14 http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg01280.html
9 15
diff --git a/lisp/replace.el b/lisp/replace.el
index 14a1869b4f9..487974073aa 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1005,23 +1005,6 @@ which means to discard all text properties."
1005 :group 'matching 1005 :group 'matching
1006 :version "22.1") 1006 :version "22.1")
1007 1007
1008(defun occur-accumulate-lines (count &optional keep-props pt)
1009 (save-excursion
1010 (when pt
1011 (goto-char pt))
1012 (let ((forwardp (> count 0))
1013 result beg end moved)
1014 (while (not (or (zerop count)
1015 (if forwardp
1016 (eobp)
1017 (and (bobp) (not moved)))))
1018 (setq count (+ count (if forwardp -1 1)))
1019 (setq beg (line-beginning-position)
1020 end (line-end-position))
1021 (push (occur-engine-line beg end keep-props) result)
1022 (setq moved (= 0 (forward-line (if forwardp 1 -1)))))
1023 (nreverse result))))
1024
1025(defun occur-read-primary-args () 1008(defun occur-read-primary-args ()
1026 (list (read-regexp "List lines matching regexp" 1009 (list (read-regexp "List lines matching regexp"
1027 (car regexp-history)) 1010 (car regexp-history))
@@ -1175,12 +1158,6 @@ See also `multi-occur'."
1175 (set-buffer-modified-p nil) 1158 (set-buffer-modified-p nil)
1176 (run-hooks 'occur-hook))))))) 1159 (run-hooks 'occur-hook)))))))
1177 1160
1178(defun occur-engine-add-prefix (lines)
1179 (mapcar
1180 #'(lambda (line)
1181 (concat " :" line "\n"))
1182 lines))
1183
1184(defun occur-engine (regexp buffers out-buf nlines case-fold-search 1161(defun occur-engine (regexp buffers out-buf nlines case-fold-search
1185 title-face prefix-face match-face keep-props) 1162 title-face prefix-face match-face keep-props)
1186 (with-current-buffer out-buf 1163 (with-current-buffer out-buf
@@ -1356,6 +1333,29 @@ See also `multi-occur'."
1356 str) 1333 str)
1357 (buffer-substring-no-properties beg end))) 1334 (buffer-substring-no-properties beg end)))
1358 1335
1336(defun occur-engine-add-prefix (lines)
1337 (mapcar
1338 #'(lambda (line)
1339 (concat " :" line "\n"))
1340 lines))
1341
1342(defun occur-accumulate-lines (count &optional keep-props pt)
1343 (save-excursion
1344 (when pt
1345 (goto-char pt))
1346 (let ((forwardp (> count 0))
1347 result beg end moved)
1348 (while (not (or (zerop count)
1349 (if forwardp
1350 (eobp)
1351 (and (bobp) (not moved)))))
1352 (setq count (+ count (if forwardp -1 1)))
1353 (setq beg (line-beginning-position)
1354 end (line-end-position))
1355 (push (occur-engine-line beg end keep-props) result)
1356 (setq moved (= 0 (forward-line (if forwardp 1 -1)))))
1357 (nreverse result))))
1358
1359;; Generate context display for occur. 1359;; Generate context display for occur.
1360;; OUT-LINE is the line where the match is. 1360;; OUT-LINE is the line where the match is.
1361;; NLINES and KEEP-PROPS are args to occur-engine. 1361;; NLINES and KEEP-PROPS are args to occur-engine.