From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Bill Brodie Newsgroups: gmane.emacs.help Subject: Numeric argument defaulting Date: Sun, 20 Jun 2004 12:58:21 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1088537088 22167 80.91.224.253 (29 Jun 2004 19:24:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 29 Jun 2004 19:24:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 29 21:24:38 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BfODc-0006Ha-00 for ; Tue, 29 Jun 2004 21:24:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BfOFI-0005Hy-Q6 for geh-help-gnu-emacs@m.gmane.org; Tue, 29 Jun 2004 15:26:20 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!panix!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 Original-NNTP-Posting-Host: panix1.panix.com Original-X-Trace: reader2.panix.com 1087736301 17861 166.84.1.1 (20 Jun 2004 12:58:21 GMT) Original-X-Complaints-To: abuse@panix.com Original-NNTP-Posting-Date: Sun, 20 Jun 2004 12:58:21 +0000 (UTC) User-Agent: tin/1.6.1-20030810 ("Mingulay") (UNIX) (NetBSD/1.5.4_ALPHA (i386)) Original-Xref: shelby.stanford.edu gnu.emacs.help:123853 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 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 Xref: main.gmane.org gmane.emacs.help:19212 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:19212 I have several utility functions that take optional numeric arguments and that I'd also like to make interactive. There are two ways to do this: 1. Define the function to accept either a raw or a numeric argument. (defun f (&optional x) (interactive "P") (cond ((numberp x)) ((null x) (setq x )) (t (setq x (prefix-numeric-value x)))) ...) -or- 2. Define an interactive wrapper around the function. (defun f (&optional x) (if (null x) (setq x )) ...) (defun f-interactive (x) (interactive "P") (if x (f (prefix-numeric-value x)) (f))) Neither of these seems especially clean. Is there a standard Emacs Lisp idiom for this?