From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Decebal Newsgroups: gmane.emacs.help Subject: Re: Writing a function for a indented copy of a region Date: Wed, 17 Dec 2008 14:58:13 -0800 (PST) Organization: http://groups.google.com Message-ID: <54785952-0c0b-4c99-8e9d-e35156ff8fec@f40g2000pri.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1229557266 11837 80.91.229.12 (17 Dec 2008 23:41:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Dec 2008 23:41:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 18 00:42:11 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LD61r-0004kp-0t for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Dec 2008 00:42:11 +0100 Original-Received: from localhost ([127.0.0.1]:33478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LD60e-00071V-QZ for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Dec 2008 18:40:56 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!f40g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: 84.53.123.169 Original-X-Trace: posting.google.com 1229554693 19333 127.0.0.1 (17 Dec 2008 22:58:13 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 17 Dec 2008 22:58:13 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f40g2000pri.googlegroups.com; posting-host=84.53.123.169; posting-account=K-cdeAoAAAD_0d505kUtHXJaT5LFIu-3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:165427 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60758 Archived-At: 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?