unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Budi <budikusasi@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How do we copy rectangular selected region
Date: Tue, 7 May 2019 13:27:02 +0700	[thread overview]
Message-ID: <CAH0GyZACruiEcQbRVNxfyQG2S=XQkm9v_AEioNb_W18Fm1Gd2g@mail.gmail.com> (raw)
In-Reply-To: <87d0kv7t6d.fsf@web.de>

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.
>



  reply	other threads:[~2019-05-07  6:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05  7:21 How do we copy rectangular selected region Budi
2019-05-05 13:22 ` Óscar Fuentes
2019-05-06 10:50 ` Michael Heerdegen
2019-05-07  6:27   ` Budi [this message]
2019-05-10  8:40 ` mickbert
2019-05-10  9:08   ` YUE Daian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH0GyZACruiEcQbRVNxfyQG2S=XQkm9v_AEioNb_W18Fm1Gd2g@mail.gmail.com' \
    --to=budikusasi@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).