From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: dieter.wilhelm@googlemail.com Newsgroups: gmane.emacs.help Subject: Re: How to detect C-u supplied arguments from other prefix arguments Date: Wed, 08 Aug 2007 08:32:22 -0000 Organization: http://groups.google.com Message-ID: <1186561942.080037.232590@o61g2000hsh.googlegroups.com> References: <87wsw7hvba.fsf@debby.local.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1186563017 7074 80.91.229.12 (8 Aug 2007 08:50:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 8 Aug 2007 08:50:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 08 10:50:16 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IIhF6-0007EC-NI for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Aug 2007 10:50:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IIhF5-0002ID-GF for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Aug 2007 04:50:11 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!o61g2000hsh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-NNTP-Posting-Host: 192.35.17.11 Original-X-Trace: posting.google.com 1186561942 16796 127.0.0.1 (8 Aug 2007 08:32:22 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 8 Aug 2007 08:32:22 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.4) Gecko/20060614 Fedora/1.5.0.4-1.2.fc5 Firefox/1.5.0.4 pango-text,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 proxy11-int (NetCache NetApp/6.0.6) Complaints-To: groups-abuse@google.com Injection-Info: o61g2000hsh.googlegroups.com; posting-host=192.35.17.11; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:150821 X-Mailman-Approved-At: Wed, 08 Aug 2007 04:44:44 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46398 Archived-At: On 8 ao=FBt, 07:06, Kevin Rodgers wrote: > Dieter Wilhelm wrote: > > I'd like to detect whether prefix arguments of a command are supplied > > by C-u or otherwise. > > My idea is to use this-command-keys and compare it to some string, > > like the following pseudo code: > > > (defun bla (arg) > > (interactive "p") > > (when (string=3D "C-u" (substring (this-command-keys) 0 2)) > > (message "hurray"))) > > > I just don't understand how to compare key sequences. Or maybe > > there's better way of doing it? > > Yuck. If all you're concerned about is whether the prefix arg was > specified by 1 or more C-u keys (with no minus sign or digits), you > can use (consp current-prefix-arg). Unfortunately this doesn't work in all cases: I'd also like to specify numerical arguments with C-u (not only powers of 4). For example C-u 3 M-x some-command and would like to distinguish it from other means of supplying numerical arguments e.g.: M-3 M-x some-command > Kevin Rodgers Thanks Dieter