From 8d581712403c7f3b9af2ec8c8c753e2fffe5cffe Mon Sep 17 00:00:00 2001 From: mbneedham Date: Wed, 16 Jan 2013 00:22:11 -0500 Subject: [PATCH 1/3] bugfix for iedit-hide-unmatched-lines fixed bug where iedit-hide-unmatched-lines goes into an infinite loop if two matching lines are exactly context-lines apart --- iedit-lib.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iedit-lib.el b/iedit-lib.el index 0b7d7b3..fcc78bb 100644 --- a/iedit-lib.el +++ b/iedit-lib.el @@ -521,14 +521,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)) From 232cd0e5ec96c65db7702ee13adc7d5346363449 Mon Sep 17 00:00:00 2001 From: mbneedham Date: Thu, 17 Jan 2013 22:40:16 -0500 Subject: [PATCH 2/3] tweak to use isearch case sensitivity have iedit-mode use the same case sensitivity as isearch if we enter the mode from a search. also a partial bugfix for when the search has no results --- iedit.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/iedit.el b/iedit.el index d17fa4a..4f4e2f3 100644 --- a/iedit.el +++ b/iedit.el @@ -356,15 +356,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." From 95e7731a91d17ca1542af67f4e51b9492c32ff6e Mon Sep 17 00:00:00 2001 From: mbneedham Date: Thu, 17 Jan 2013 22:41:49 -0500 Subject: [PATCH 3/3] bugfix for when there are no occurrences --- iedit-lib.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/iedit-lib.el b/iedit-lib.el index fcc78bb..a2174d8 100644 --- a/iedit-lib.el +++ b/iedit-lib.el @@ -769,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 ()