From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: interleaving text lines of two regions Date: Fri, 27 Jan 2017 12:01:29 -0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1485547342 5256 195.159.176.226 (27 Jan 2017 20:02:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 27 Jan 2017 20:02:22 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 27 21:02:17 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cXCir-0000aE-C9 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Jan 2017 21:02:13 +0100 Original-Received: from localhost ([::1]:47639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXCiw-0002Km-JX for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Jan 2017 15:02:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cXCiV-0002Kg-VW for help-gnu-emacs@gnu.org; Fri, 27 Jan 2017 15:01:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cXCiV-000596-Cz for help-gnu-emacs@gnu.org; Fri, 27 Jan 2017 15:01:52 -0500 Original-Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:36685) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cXCiV-000592-9d for help-gnu-emacs@gnu.org; Fri, 27 Jan 2017 15:01:51 -0500 Original-Received: by mail-qt0-x231.google.com with SMTP id k15so153620875qtg.3 for ; Fri, 27 Jan 2017 12:01:51 -0800 (PST) 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; bh=G7fZ7IPneGU9ImhhyE7unQ760IrYKrv/MJNuup/lY1s=; b=Jk4z9A/Vo47/sBTD5VzdLgirnrCPPNDBJhukVF5OGxXm64qYLWqcPB+MNCd7jcwfxu zi6ezUpjK7YU7+7/RXMijCAKztH9WPB6sTkjGgXmWqOmJ6V+q7Awcv8PxlGm4tcqLN92 QPFvSODjidJ1StGtc1ccyUVWSJJYNiRf/b97lxI5tTi95AUzG2ZT2ez8VTJ1YNuiBiB0 ir2ez0wIttlPenDGhzkoY5TzyS/61Yl0yghZp3AjWau2Z2yh3AcmiYraaoCXLHQ1PNwJ PjC1qw/JY3IAqPru5qgzC5IaZ5SDReBRStS05iGYu6JtTBezVYifCtDzmvUiVJKZ4GXc pZ6Q== 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; bh=G7fZ7IPneGU9ImhhyE7unQ760IrYKrv/MJNuup/lY1s=; b=d+EC1JKf6jVSUlbI3/+dFcE1HwJZ7V4Q6XkOtXPqx/cNJDKEnQzsrfkz9AsQuNSbmZ hML0/3O2daIXLPqktyWwE2JoQ0vi/QbHkAMxA18K84HKoomcXoGGMLCt0h445nFxJWM7 TA0QziD4kzacfgTsjQrC5kMk1LIyUoCZv1WAMmjdD8nbDKJ1R0/GwV1z2sUnqYyK9YdO YZ1EZDkPne5xYfga7KcPwSBT/UCeFRL49QVCa7Ft5giz3TYJRQxMtRIrADkNfRvTFRVU dO5oH4PEEqpbKKc79vRgnoSUv2LhGB29Sy1Z1996S5kJ9tNiJwEpDLB88/dmDZd2CZdb qBIA== X-Gm-Message-State: AIkVDXKVTLYrfJD5Lmb61OaMyvxyWz9AZ1kAWFzzEcsayDwtQZYr5jdd4i8EM7zk3u2jt9wAScY2CNuTbxSAKg== X-Received: by 10.233.237.136 with SMTP id c130mr10589238qkg.160.1485547310243; Fri, 27 Jan 2017 12:01:50 -0800 (PST) Original-Received: by 10.237.41.2 with HTTP; Fri, 27 Jan 2017 12:01:29 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::231 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:112178 Archived-At: John Mastro wrote: > > If I understand correctly, I think something simpler like this could > work: > > (defun yank-interleaved () > (interactive) > (let ((lines-0 (split-string (current-kill 0 t) "\n" t "\\s-")) > (lines-1 (split-string (current-kill 1 t) "\n" t "\\s-"))) > (while (or lines-0 lines-1) > (when lines-0 (insert (pop lines-0) "\n")) > (when lines-1 (insert (pop lines-1) "\n"))))) > > It interleaves the last two kills (and could easily be generalized to > interleave the last N kills). Just for one, here's a version that interleaves the last N kills (default 2): (defun yank-interleaved (n) (interactive (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 2))) (let ((yanks (mapcar (lambda (i) (split-string (current-kill i t) "\n" t "\\s-")) (number-sequence 0 (1- n))))) (while (seq-some #'consp yanks) (dotimes (i n) (when (nth i yanks) (insert (pop (nth i yanks)) "\n"))))))