From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: How do we copy rectangular selected region Date: Mon, 06 May 2019 12:50:50 +0200 Message-ID: <87d0kv7t6d.fsf@web.de> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="114610"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Budi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 06 12:51:11 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hNbDC-000TjC-Ri for geh-help-gnu-emacs@m.gmane.org; Mon, 06 May 2019 12:51:10 +0200 Original-Received: from localhost ([127.0.0.1]:54281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNbDB-0005KR-P6 for geh-help-gnu-emacs@m.gmane.org; Mon, 06 May 2019 06:51:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNbCy-0005KK-Fx for help-gnu-emacs@gnu.org; Mon, 06 May 2019 06:50:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNbCx-0007pS-CY for help-gnu-emacs@gnu.org; Mon, 06 May 2019 06:50:56 -0400 Original-Received: from mout.web.de ([212.227.17.11]:49549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNbCx-0007oo-2Z for help-gnu-emacs@gnu.org; Mon, 06 May 2019 06:50:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1557139851; bh=O6nXac70sQ2wuRi+WdFOS/vKUqagH1unds9jEAn4wfA=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=QNP8tcc0C1whoIdx105D1bfe8CBYDSXecfh6kpBodGUMv4ohS6H/J3oZwDrdvdCvc N2C35zJjhgwsftu9dvuKacwWc+x9mijEe1MThOpNhnMawFr4Gx8No3notN6Yglp/DT 0yS8TYh3HDkr8pJoj1huL92CMu3sP4ed/JFaAOZw= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.66.186.107]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LbJCQ-1h08IL0awE-00kuXF; Mon, 06 May 2019 12:50:51 +0200 In-Reply-To: (Budi's message of "Sun, 5 May 2019 14:21:40 +0700") X-Provags-ID: V03:K1:PWmvNSihdbtpsnvBY7GMz/wvKo0kqRdSkha4h3ZYz3clm05NQcZ 7DR4Jat18sqsOW1FGCTKKHlTa4kgBuPDdQHhO7gYS2f4pcDs9qpL5JbiAk2I/auC4PWcrE4 D43bcC81YkXldAWPuB7HkHzaNA1Gc2d/QFEpI877D1FccsQZlY3b/8sky4Y8CzN97NMeQUA 0vSdYDAlIyu5XGoLX2UwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:K3hxrLAhdAE=:fhv9jvECwwPM4zrSTjOeQ6 zg/N60BZTNpf1FPR2Qyg/UGf0E9s5C3tVCquGsSLxIzpP8wRwz6CM7ixzsHS/fFdWePQXV/wr rw5Ugtdgb67pL8p5ahv1SJwxcjh1WwGt85bgA5xYkZDqTUyRIrmsJ6JPVPwrDaTx1+KYij5rN 5rDoHJUFs9IaiblBPlVa+vdPjPp5FfXyVn0xv8i0pgwTXfAmLcm5HBmrRPQrbZ4xcYCNhVJGq dkJzifT3YHp3saB/AAgMg85BmppLn73Kzs3qX34qA4dmNAL/nk121tiqiHYAYdvLC1UTYGFtJ d6V3XJO48E4Z62XHzg3Szt5I6KlSRr3gArG8mzav+YOyxLY5RA+4SjiXonhymOkGg9pkhh4cd yRU8UkHh8mY1vRoio3TAPwLCnrmLSDgbW4pHYDWEQhd68p+EiO3rMeAi0/6tc1wr29xlpu8y7 i+gjS6dwALpI30YnyrkvYjWZx/2vzkt/fKgABBitspgMDUicc0/N0lcX8jt8e36K/1yVmsT4W O3B6BcAkQv0oEUjlPh/GF33XoemOaPoaxCBMy/TmQ9K/+MxydRHtK5gSwOkTggsdJGAuwF6NS pZyaHTI+gInA8Gp9ssR3eWoklwdAImWJ7e+lCztuWFgGPHA3QNpbpwJuqh9U7ZTnTueUwnKfq nLtcaRPJpWHcVpfqHp2CSE89SVKC8GyWZMgKrUfBi+YhzfXnicJ2L8JumZ32iDEahwQxSKQCf ndX8+xeKHf5RySurHmaB/lTAO6SlUjiHvkBtTJMnRDzclUSquBkj0jmlOPqTODFZUQ4UhIHV X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:120223 Archived-At: Budi writes: > How can we copy rectangular selected region on latest emacs > we paste it as line region instead > how do such by script elisp.. thanks in advance Dunno if I understand correctly. What I sometimes want is that a yanked rectangle moves the text after the insertion point completely after the inserted rectangle text, instead of merging the rectangle into the text. I do it like following. Maybe I'm missing something and it can be done with Emacs ways, dunno. Anyway, the code modifies the command 'yank-rectangle' to get the alternative insertion behavior by calling it with a prefix arg. #+begin_src emacs-lisp (defun my-insert-rectangle-with-newlines (rectangle) "Like `insert-rectangle', but (insert ?\\n) is used to change lines." (let ((lines rectangle) (insertcolumn (current-column)) (first t)) (push-mark) (while lines (or first (progn (insert ?\n) (or (bolp) (insert ?\n)) (move-to-column insertcolumn t))) (setq first nil) (insert (car lines)) (setq lines (cdr lines))) (save-excursion (insert ?\n)))) (eval-when-compile (require 'rect)) (defun my-yank-rectangle (&optional insert-newlines) "The optional argument INSERT-NEWLINES specifies if `forward-line' or (insert ?\\n) is used to change lines. A value of nil means that `forward-line' will be used and text after point will occur beside the inserted rectangle. With any other value, newlines will be inserted instead, with the effect that any following text will remain after the inserted rectangle." (interactive "*P") (funcall (if insert-newlines #'my-insert-rectangle-with-newlines #'insert-rectangle) killed-rectangle)) (advice-add 'yank-rectangle :override #'my-yank-rectangle) #+end_src Michael.