Skip to content

Loading…

allow iedit-rectangle-mode to take beg end programatically #22

Merged
merged 1 commit into from

2 participants

@lewang
Collaborator
  • also add warning when no region is selected.
Le Wang allow iedit-rectangle-mode to take beg end programatically
- also add warning when no region is selected.
40222ff
@lewang
Collaborator

I needed this to script iedit-rectangle-mode

@victorhge victorhge merged commit af0fa20 into victorhge:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 10, 2012
  1. allow iedit-rectangle-mode to take beg end programatically

    Le Wang committed
    - also add warning when no region is selected.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 8 deletions.
  1. +9 −8 iedit-rect.el
View
17 iedit-rect.el
@@ -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
@@ -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."
Something went wrong with that request. Please try again.