From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: yank-repeat-newline Date: Tue, 26 Jul 2011 12:32:06 -0700 Message-ID: <79F08F04553C4C42AAE0804AB5A00E1F@us.oracle.com> References: <4E2F11A3.3090102@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1311708755 2097 80.91.229.12 (26 Jul 2011 19:32:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2011 19:32:35 +0000 (UTC) To: "=?iso-8859-1?Q?'Andreas_R=F6hler'?=" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 26 21:32:31 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QlnMj-0002of-V9 for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2011 21:32:30 +0200 Original-Received: from localhost ([::1]:46086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlnMe-00059x-Cu for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2011 15:32:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlnMZ-00059s-T0 for help-gnu-emacs@gnu.org; Tue, 26 Jul 2011 15:32:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlnMY-0001LO-T2 for help-gnu-emacs@gnu.org; Tue, 26 Jul 2011 15:32:19 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]:42972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlnMY-0001LG-MY for help-gnu-emacs@gnu.org; Tue, 26 Jul 2011 15:32:18 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p6QJWCps029247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Jul 2011 19:32:14 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p6QJWC0J017794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Jul 2011 19:32:12 GMT Original-Received: from abhmt106.oracle.com (abhmt106.oracle.com [141.146.116.58]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p6QJW6qf006720; Tue, 26 Jul 2011 14:32:06 -0500 Original-Received: from dradamslap1 (/10.159.42.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Jul 2011 12:32:06 -0700 X-Mailer: Microsoft Office Outlook 11 x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.6109 In-Reply-To: <4E2F11A3.3090102@easy-emacs.de> Thread-Index: AcxLyASf7/IbY40/QcOrkb5dhUvI0gAANNkQ X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090209.4E2F163E.0152:SCFMA922111,ss=1,re=-4.000,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 148.87.113.117 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81793 Archived-At: > (defun yank-repeat-newline (arg &optional nl) > "With numerical ARG, repeat last yank ARG times. > With optional arg NL, also insert newlines. " > (interactive "p\nP*") > (let ((nl nl) > (num arg)) > (dotimes (i num) > (if nl > (insert (concat (car kill-ring) "\n")) > (insert (car kill-ring)))))) You don't need the `let'. But you cannot do what your doc string claims, at least not the way you're trying. As Teemu explained, there is only _one_ prefix arg. You can look at either its numeric value or its raw value or both, but there is only ONE prefix arg. You apparently want to have a prefix arg express both a numeric quantity and a boolean. If the user uses C-u (or its variants) to specify a (non-nil) prefix arg then, well, the raw value is non-nil. If the raw value is nil, then the user did not use C-u (or its variants). If you want to let the user specify a numeric value, default 1, and also specify whether to add a newline, then one way to do that is to distinguish positive from negative prefix arg (there's your boolean). E.g.: M-x yank... -> just one, no newline M-- yank... -> one, newline C-u -1 yank... -> one, newline C-u -2 yank... -> two, newlines C-u 2 yank... -> two, no newlines Something like this: (defun myyank (&optional arg) (interactive "p") (dotimes (i (abs arg)) (if (natnump arg) (insert (car kill-ring)) (insert (concat (car kill-ring) "\n")))))