Permalink
Browse files

Merge branch 'master' of https://github.com/mbneedham/iedit

  • Loading branch information...
2 parents 22f4729 + 95e7731 commit 6e6d4bc478bf8b8155456c53e6aba5dc0753521f @victorhge committed Jan 19, 2013
Showing with 30 additions and 21 deletions.
  1. +18 −12 iedit-lib.el
  2. +12 −9 iedit.el
View
30 iedit-lib.el
@@ -519,14 +519,18 @@ value of `iedit-occurrence-context-lines' is used for this time."
(save-excursion
(iedit-first-occurrence)
(while (/= (point) (point-max))
- (forward-line (- context-lines))
- (let ((line-beginning (line-beginning-position)))
- (if (> line-beginning prev-occurrence-end)
- (push (list prev-occurrence-end (1- line-beginning)) unmatched-lines)))
+ (let ((current-start (point)))
+ (forward-line (- context-lines))
+ (let ((line-beginning (line-beginning-position)))
+ (if (> line-beginning prev-occurrence-end)
+ (push (list prev-occurrence-end (1- line-beginning)) unmatched-lines)))
+ (goto-char current-start))
;; goto the end of the occurrence
(goto-char (next-single-char-property-change (point) 'iedit-occurrence-overlay-name))
- (forward-line context-lines)
- (setq prev-occurrence-end (line-end-position))
+ (let ((current-end (point)))
+ (forward-line context-lines)
+ (setq prev-occurrence-end (1+ (line-end-position)))
+ (goto-char current-end))
;; goto the beginning of next occurrence
(goto-char (next-single-char-property-change (point) 'iedit-occurrence-overlay-name)))
(if (< prev-occurrence-end (point-max))
@@ -765,12 +769,14 @@ This function is supposed to be called in overlay keymap."
(defun iedit-current-occurrence-string ()
"Return current occurrence string.
Return nil if occurrence string is empty string."
- (let* ((ov (or (iedit-find-current-occurrence-overlay)
- (car iedit-occurrences-overlays)))
- (beg (overlay-start ov))
- (end (overlay-end ov)))
- (if (and ov (/= beg end))
- (buffer-substring-no-properties beg end)
+ (let ((ov (or (iedit-find-current-occurrence-overlay)
+ (car iedit-occurrences-overlays))))
+ (if ov
+ (let ((beg (overlay-start ov))
+ (end (overlay-end ov)))
+ (if (and ov (/= beg end))
+ (buffer-substring-no-properties beg end)
+ nil))
nil)))
(defun iedit-occurrence-string-length ()
View
21 iedit.el
@@ -358,15 +358,18 @@ Keymap used within overlays:
(if (or isearch-regexp isearch-word)
nil
(setq iedit-initial-string-local isearch-string))
- (isearch-exit)
- (setq mark-active nil)
- (run-hooks 'deactivate-mark-hook)
- (iedit-start regexp (point-min) (point-max))
- ;; TODO: reconsider how to avoid the loop in iedit-same-length
- (if (iedit-same-length)
- nil
- (iedit-done)
- (message "Matches are not the same length.")))
+ (let ((iedit-case-sensitive (not isearch-case-fold-search)))
+ (isearch-exit)
+ (setq mark-active nil)
+ (run-hooks 'deactivate-mark-hook)
+ (iedit-start regexp (point-min) (point-max))
+ ;; TODO: reconsider how to avoid the loop in iedit-same-length
+ (cond ((not iedit-occurrences-overlays)
+ (message "No matches found")
+ (iedit-done))
+ ((not (iedit-same-length))
+ (message "Matches are not the same length.")
+ (iedit-done)))))
(defun iedit-start (occurrence-regexp beg end)
"Start Iedit mode for the `occurrence-regexp' in the current buffer."

0 comments on commit 6e6d4bc

Please sign in to comment.