From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.devel Subject: more than one prefix argument Date: Tue, 26 Jul 2011 21:59:08 +0200 Message-ID: <4E2F1C8C.9010802@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1311710364 12210 80.91.229.12 (26 Jul 2011 19:59:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2011 19:59:24 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 26 21:59:20 2011 Return-path: Envelope-to: ged-emacs-devel@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 1Qlnmd-0004n4-88 for ged-emacs-devel@m.gmane.org; Tue, 26 Jul 2011 21:59:15 +0200 Original-Received: from localhost ([::1]:55105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qlnmc-0002aG-LF for ged-emacs-devel@m.gmane.org; Tue, 26 Jul 2011 15:59:14 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:40286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qlnma-0002aA-2T for emacs-devel@gnu.org; Tue, 26 Jul 2011 15:59:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlnmY-0008AC-TY for emacs-devel@gnu.org; Tue, 26 Jul 2011 15:59:12 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:56304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlnmY-0008A4-IC for emacs-devel@gnu.org; Tue, 26 Jul 2011 15:59:10 -0400 Original-Received: from [192.168.178.27] (brln-4dbc49d1.pool.mediaWays.net [77.188.73.209]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0M8dKp-1RgMiU03eN-00vnd8; Tue, 26 Jul 2011 21:59:09 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11 X-Provags-ID: V02:K0:jIq/6LqYbAJPRQ+Gb6D8+J06EjNe++3nku/LoB6d29B vbuQiBuP9ZPbCrLk02f64gZSho2meU7h4WXW/x5TTbMLf26iwv j0bjdlAvpaHlFWKGpiLxCCzfKWx+V6SQqCXO+0MNvI65sdBTsw EqfONOtKrwBEqNlQEqAwAQVv8/epQ5qlBWLkBhGvsU2Z/KLXeF XQ1BpOWz/+tsiV9YROv97N6DH8WP3cqW7gudnY7j4A= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:142317 Archived-At: Hi, what about allowing more than one prefix argument by making interactive codes "p" and "P" sending truly separated. Would reserve "p" for numerical args, while "P" basically should send a kind of exception flag, branching execution. Below a use-case for it, yank-repeat should add newlines if C-u follows the numeric argument. As both inputs interfere, that's not possible that way for now. ;; not working now (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)))))) Drew presented a solution at help-gnu-emacs@gnu.org: ;;;;;;;;;;;;;;;;; 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"))))) ;;;;;;;;;;;;; However, that solution seems too complicated for a part of non-programmers, it's not mnemonic, rather tricky - even not uncommon in Emacs. Would be glad to have C-u as general branch key. Thanks all, Andreas -- https://launchpad.net/python-mode https://launchpad.net/s-x-emacs-werkstatt/