Skip to content

Commit

Permalink
allow iedit-rectangle-mode to take beg end programatically
Browse files Browse the repository at this point in the history
- also add warning when no region is selected.
  • Loading branch information
Le Wang committed Oct 10, 2012
1 parent 9cfd76f commit 40222ff
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions iedit-rect.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ current mode is iedit-rect. Otherwise it is nil.
'(iedit-rectangle-mode . nil))

;;;###autoload
(defun iedit-rectangle-mode ()
(defun iedit-rectangle-mode (&optional beg end)
"Toggle Iedit-rect mode.
When Iedit-rect mode is on, a rectangle is started with visible
Expand All @@ -90,16 +90,17 @@ Iedit mechanism.
Commands:
\\{iedit-rect-keymap}"
(interactive)
(interactive (when (iedit-region-active)
(list (region-beginning)
(region-end))))
(if iedit-rectangle-mode
(iedit-rectangle-done)
(iedit-barf-if-lib-active)
(if (iedit-region-active)
(let ((beg (region-beginning))
(end (region-end)))
(setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
(iedit-rectangle-start beg end)))))
(if (and beg end)
(progn (setq mark-active nil)
(run-hooks 'deactivate-mark-hook)
(iedit-rectangle-start beg end))
(error "no region available."))))

(defun iedit-rectangle-start (beg end)
"Start Iedit mode for the region as a rectangle."
Expand Down

0 comments on commit 40222ff

Please sign in to comment.