From: Juri Linkov Date: Tue, 23 Mar 2010 07:16:57 +0000 (+0200) Subject: * replace.el (occur-accumulate-lines, occur-engine): X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~680 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f14d1172a22ac7127d8e446614b5f2decddbf6d7;p=emacs.git * replace.el (occur-accumulate-lines, occur-engine): Use `occur-engine-line' instead of duplicate code. (occur-engine-line): New function created from duplicate code in `occur-accumulate-lines' and `occur-engine'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 77b970789ff..77bd0fa1826 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2010-03-23 Juri Linkov + + * replace.el (occur-accumulate-lines, occur-engine): + Use `occur-engine-line' instead of duplicate code. + (occur-engine-line): New function created from duplicate code + in `occur-accumulate-lines' and `occur-engine'. + 2010-03-23 Juri Linkov * finder.el: Remove TODO tasks. diff --git a/lisp/replace.el b/lisp/replace.el index 081d5c45f1d..613cced8ea5 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -1016,18 +1016,7 @@ which means to discard all text properties." (setq count (+ count (if forwardp -1 1))) (setq beg (line-beginning-position) end (line-end-position)) - (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode) - (text-property-not-all beg end 'fontified t)) - (if (fboundp 'jit-lock-fontify-now) - (jit-lock-fontify-now beg end))) - (push - (if (and keep-props (not (eq occur-excluded-properties t))) - (let ((str (buffer-substring beg end))) - (remove-list-of-text-properties - 0 (length str) occur-excluded-properties str) - str) - (buffer-substring-no-properties beg end)) - result) + (push (occur-engine-line beg end) result) (forward-line (if forwardp 1 -1))) (nreverse result)))) @@ -1228,17 +1217,7 @@ See also `multi-occur'." endpt (line-end-position))) (setq marker (make-marker)) (set-marker marker matchbeg) - (if (and keep-props - (if (boundp 'jit-lock-mode) jit-lock-mode) - (text-property-not-all begpt endpt 'fontified t)) - (if (fboundp 'jit-lock-fontify-now) - (jit-lock-fontify-now begpt endpt))) - (if (and keep-props (not (eq occur-excluded-properties t))) - (progn - (setq curstring (buffer-substring begpt endpt)) - (remove-list-of-text-properties - 0 (length curstring) occur-excluded-properties curstring)) - (setq curstring (buffer-substring-no-properties begpt endpt))) + (setq curstring (occur-engine-line begpt endpt)) ;; Highlight the matches (let ((len (length curstring)) (start 0)) @@ -1335,6 +1314,18 @@ See also `multi-occur'." ;; Return the number of matches globalcount))) +(defun occur-engine-line (beg end) + (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode) + (text-property-not-all beg end 'fontified t)) + (if (fboundp 'jit-lock-fontify-now) + (jit-lock-fontify-now beg end))) + (if (and keep-props (not (eq occur-excluded-properties t))) + (let ((str (buffer-substring beg end))) + (remove-list-of-text-properties + 0 (length str) occur-excluded-properties str) + str) + (buffer-substring-no-properties beg end))) + ;; Generate context display for occur. ;; OUT-LINE is the line where the match is. ;; NLINES and KEEP-PROPS are args to occur-engine.