all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Convert rectangle's lines to a flat string and put it in the kill ring
@ 2013-09-08 12:39 Teemu Likonen
  2013-09-08 12:58 ` Teemu Likonen
  0 siblings, 1 reply; 2+ messages in thread
From: Teemu Likonen @ 2013-09-08 12:39 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

I'm trying to write a custom rectangle copy command. It should convert
rectangle's lines to a flat string like this: "line1|line2|line3", that
is, use separator character "|" between lines. The resulting string
should be put in the kill ring so that the next yank command would
insert it.


    (defun tl-rectangle-string (beg end)
      (interactive "r")
      (let ((list (extract-rectangle beg end)))
        (kill-new (mapconcat 'substring-no-properties list "|"))
        (setq deactivate-mark t)))


It doesn't work. The next yank command inserts the region between BEG
and END, not the generated flat string. "yank + yank-pop" inserts the
generated string but I'd like to have it first in the yank list. Any
ideas?

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Convert rectangle's lines to a flat string and put it in the kill ring
  2013-09-08 12:39 Convert rectangle's lines to a flat string and put it in the kill ring Teemu Likonen
@ 2013-09-08 12:58 ` Teemu Likonen
  0 siblings, 0 replies; 2+ messages in thread
From: Teemu Likonen @ 2013-09-08 12:58 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

Teemu Likonen [2013-09-08 15:39:59 +03:00] wrote:

> I'm trying to write a custom rectangle copy command. It should convert
> rectangle's lines to a flat string like this: "line1|line2|line3", that
> is, use separator character "|" between lines.

> It doesn't work. The next yank command inserts the region between BEG
> and END, not the generated flat string.

The problem solved. I had select-active-regions=t so the region was
added to kill ring after my kill-new function call. When I set the
variable to symbol "only" my custom kill ring insert remains the first
one in the ring.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-08 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-08 12:39 Convert rectangle's lines to a flat string and put it in the kill ring Teemu Likonen
2013-09-08 12:58 ` Teemu Likonen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.