Skip to content

Commit

Permalink
fix regexp match to --context filename
Browse files Browse the repository at this point in the history
  • Loading branch information
mhayashi1120 committed Jul 6, 2012
1 parent 8094715 commit f701229
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions wgrep.el
Expand Up @@ -4,7 +4,7 @@
;; Keywords: grep edit extensions
;; URL: http://github.com/mhayashi1120/Emacs-wgrep/raw/master/wgrep.el
;; Emacs: GNU Emacs 22 or later
;; Version: 2.0.0
;; Version: 2.0.1

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -81,9 +81,6 @@
;; * Reinforce checking error.
;; * Support removing whole line include new-line.

;;; TODO:
;; * sort-lines

;;; Code:

(require 'grep)
Expand Down Expand Up @@ -616,12 +613,17 @@ This change will be applied when \\[wgrep-finish-edit]."
(forward-line (1- line)))

;; -A -B -C output may be misunderstood and set read-only.
;; (e.g. filename-20-2010/01/01 23:59:99)
;; Context match break font-lock if context have at least two `:'.
;; e.g.
;; filename-1-2010-01-01 23:59:99
;; filename:2:hoge
;; filename-3-20:10:25
(defun wgrep-prepare-context-while (filename line forward)
(let* ((diff (if forward 1 -1))
(next (+ diff line)))
(next (+ diff line))
(fregexp (regexp-quote filename)))
(forward-line diff)
(while (looking-at (format "^%s\\(-\\)%d\\(-\\)" filename next))
(while (looking-at (format "^%s\\(-\\)%d\\(-\\)" fregexp next))
(let ((line-head (format "%s:%d:" filename next)))
(replace-match line-head nil nil nil 0)
(forward-line diff)
Expand Down

0 comments on commit f701229

Please sign in to comment.