[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing a function for a indented copy of a region
From: |
Decebal |
Subject: |
Re: Writing a function for a indented copy of a region |
Date: |
Wed, 17 Dec 2008 14:58:13 -0800 (PST) |
User-agent: |
G2/1.0 |
I found a better way.
(defun my-indented-yank(indent)
"Put indented region in the kill-ring"
(interactive "p")
(if mark-active
(let (do-kill)
(setq indent (cond ((eq indent 0) 1)
((eq indent 1) 4)
(t indent)
)
)
(if (< indent 0)
(setq indent (- 0 indent)
do-kill t
)
)
(indent-rigidly (region-beginning) (region-end) indent)
(if do-kill
(kill-region (region-beginning) (region-end))
(copy-region-as-kill (region-beginning) (region-end))
(undo)
)
)
(message "my-indented-yank needs a region")
)
)
(global-set-key (kbd "C-c C-w") 'my-indented-yank)
Now a negative value will kill the region instead of yanking it and
when no region is selected an apriote message will be displayed.
I have also bind the funtion to a a key combination. Is my choice a
good one, or is there a better key combination?
Re: Writing a function for a indented copy of a region,
Decebal <=
Re: Writing a function for a indented copy of a region, Decebal, 2008/12/18