From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Budi <budikusasi@gmail.com>
Newsgroups: gmane.emacs.help
Subject: Re: How do we copy rectangular selected region
Date: Tue, 7 May 2019 13:27:02 +0700
Message-ID: <CAH0GyZACruiEcQbRVNxfyQG2S=XQkm9v_AEioNb_W18Fm1Gd2g@mail.gmail.com>
References: <CAH0GyZDwfwt-wJG7SEixZkd8uE40hkF8JsmDnh8PtNPJzrU0SA@mail.gmail.com>
	<87d0kv7t6d.fsf@web.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="250131"; mail-complaints-to="usenet@blaine.gmane.org"
Cc: help-gnu-emacs@gnu.org
To: Michael Heerdegen <michael_heerdegen@web.de>
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 07 08:33:07 2019
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
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 <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1hNtf1-0012z0-HH
	for geh-help-gnu-emacs@m.gmane.org; Tue, 07 May 2019 08:33:07 +0200
Original-Received: from localhost ([127.0.0.1]:40881 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>)
	id 1hNtf0-0000vl-Az
	for geh-help-gnu-emacs@m.gmane.org; Tue, 07 May 2019 02:33:06 -0400
Original-Received: from eggs.gnu.org ([209.51.188.92]:38546)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <budikusasi@gmail.com>) id 1hNtZB-0003v6-87
	for help-gnu-emacs@gnu.org; Tue, 07 May 2019 02:27:06 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <budikusasi@gmail.com>) id 1hNtZA-0004ud-5i
	for help-gnu-emacs@gnu.org; Tue, 07 May 2019 02:27:05 -0400
Original-Received: from mail-it1-x133.google.com ([2607:f8b0:4864:20::133]:36982)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <budikusasi@gmail.com>)
	id 1hNtZA-0004tq-13
	for help-gnu-emacs@gnu.org; Tue, 07 May 2019 02:27:04 -0400
Original-Received: by mail-it1-x133.google.com with SMTP id r85so23947362itc.2
	for <help-gnu-emacs@gnu.org>; Mon, 06 May 2019 23:27:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:in-reply-to:references:from:date:message-id:subject:to
	:cc; bh=/7hACckD+MITWMIJ76wX72FrC/v1kqTqD1a3a4ovXE0=;
	b=epE0m3nPNzXfSaRWlL+5CU876j3FEjGgJR7GMQ43SfWi7JJ9QwXMkjEINywNYfbU2o
	F6dK9Broxryy8Bit1pFjlJyrTIdZIgT3xntToPisDh9VY2YUs5XkBkNRhJvl1jvnGLOQ
	7R6EbgPEwcQSfbAaFgiPvDVBDp5Jwi5keOM/HzBRed3y9B4yZ7F8hh6h0kNzR3x9ICxN
	Uiux3nkxAjLBZGmcBIcdsU3sm/XBUYECq9Pq7ezsyJ43ZQMZfMe0MYd40oqGAU5VP4X5
	+iQ36eWpT7gf0G8zjZw5oQQVMvlKkkFc9GefBH2gt748I9hZNfXPmf9nQScmFABa81FW
	bbNw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:cc;
	bh=/7hACckD+MITWMIJ76wX72FrC/v1kqTqD1a3a4ovXE0=;
	b=Dry4fNQHIqWajFJ0pPj5N7DNGS37yBisyg6JFwLYAif07nIV/e0/ebKligYIhkOcVU
	YVApuy8B58wOArOY5vhtE7Il/yXiv+wo/puFkiMifsTeRbAOsmEYNbCQOeHFs6YOhWDm
	mdCe6wZP/3EGJJOZtWHgW6kt9WwGycCKWEBHtK/smhETuCHJlKJiLMma+WYKw7Ltl2TP
	ZM1xBZcmZJlzdh90KBBr/H0JQd1FsE9p8Ywe0MkLjnASIxzb7HA2ydsmxuHA5XU/Bf+G
	1qipMep8jgwDD9bGJYqReHl1wlDO1KhlsJxuqZNOIc+YJSlLKdPGI6BWONC8OeL9e7a+
	fa+Q==
X-Gm-Message-State: APjAAAUcpQH/0tkzYsegufc8zqeHGuI15vJ9VxyBKSYCepOgU+iLOzdg
	sSXOFeelKUaHo/CYCmnFu2mMcD+SXM8RqsZjSjg=
X-Google-Smtp-Source: APXvYqzBhbPDcL/QT+dJ1bSWrULmtlWpEs9DmOvMyE3LUnfxC7v3O2skqVOfYLSflJknNPIu1gguJQJh+trCfG0YdkY=
X-Received: by 2002:a24:3f85:: with SMTP id d127mr21005016ita.38.1557210422717;
	Mon, 06 May 2019 23:27:02 -0700 (PDT)
Original-Received: by 2002:a02:5b45:0:0:0:0:0 with HTTP;
	Mon, 6 May 2019 23:27:02 -0700 (PDT)
In-Reply-To: <87d0kv7t6d.fsf@web.de>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 2607:f8b0:4864:20::133
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 <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/help-gnu-emacs/>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: "help-gnu-emacs"
	<help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.help:120246
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/120246>

Michael, I am sorry, I did mail the amended question but someone still
got the obsolete one.
The rectangle selected region question is replaced with " symbol's
function definition is void : t " error problem as calling a function

the copy into clipboard function is meant to save to kill-ring with or
without a selected region, if it exist then save that region otherwise
make up a full line region and save that
but got symbol's function definition is void : t  error above


(defun copy (b e)
  (interactive "r")
  (if (use-region-p) (call-interactively 'kill-ring-save)
  (beginning-of-line)
  (push-mark (line-end-position))
  (activate-mark)
  (call-interactively 'kill-ring-save)
  (deactivate-mark)
  (pop-mark)))
(global-set-key (kbd "C-c") 'copy)

invaluable thanks to anyone help me out.

On 5/6/19, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Budi <budikusasi@gmail.com> 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.
>