unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to detect C-u supplied arguments from other prefix arguments
Date: Tue, 07 Aug 2007 23:06:38 -0600	[thread overview]
Message-ID: <f9bj0l$3cq$1@sea.gmane.org> (raw)
In-Reply-To: <87wsw7hvba.fsf@debby.local.net>

Dieter Wilhelm wrote:
> Hi
> 
> 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= "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).

-- 
Kevin Rodgers
Denver, Colorado, USA

  reply	other threads:[~2007-08-08  5:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 21:46 How to detect C-u supplied arguments from other prefix arguments Dieter Wilhelm
2007-08-08  5:06 ` Kevin Rodgers [this message]
     [not found] ` <mailman.4513.1186549602.32220.help-gnu-emacs@gnu.org>
2007-08-08  8:32   ` dieter.wilhelm
     [not found] <mailman.4504.1186523154.32220.help-gnu-emacs@gnu.org>
2007-08-08 11:55 ` Johan Bockgård
2007-08-08 12:27   ` dieter.wilhelm
2007-08-09  4:04     ` Barry Margolin
2007-08-09  6:52       ` Dieter Wilhelm
2007-08-09 17:49 ` Stefan Monnier
2007-08-09 20:16   ` Dieter Wilhelm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='f9bj0l$3cq$1@sea.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).