From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Adam Newsgroups: gmane.emacs.help Subject: Re: help create function alias Date: Tue, 21 Sep 2010 10:02:10 +1200 Organization: Ihug Ltd Message-ID: References: <87d3s8pks9.fsf@kuiper.lan.informatimago.com> <87aancp1c5.fsf@fh-trier.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: dough.gmane.org 1291947686 14661 80.91.229.12 (10 Dec 2010 02:21:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2010 02:21:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 10 03:21:20 2010 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.69) (envelope-from ) id 1PQsbo-00018u-7q for geh-help-gnu-emacs@m.gmane.org; Fri, 10 Dec 2010 03:21:20 +0100 Original-Received: from localhost ([127.0.0.1]:48983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQsbn-0005MV-JM for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 21:21:19 -0500 Original-Path: usenet.stanford.edu!newsfeed.berkeley.edu!ucberkeley!i.newsfeed.yosemite.net!newsfeed.yosemite.net!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 61 Original-NNTP-Posting-Host: 203.173.200.153 Original-X-Trace: lust.ihug.co.nz 1285019421 3270 203.173.200.153 (20 Sep 2010 21:50:21 GMT) Original-X-Complaints-To: abuse@ihug.co.nz Original-NNTP-Posting-Date: Mon, 20 Sep 2010 21:50:21 +0000 (UTC) User-Agent: KNode/0.9.2 Original-Xref: usenet.stanford.edu gnu.emacs.help:181389 X-Mailman-Approved-At: Thu, 09 Dec 2010 20:09:00 -0500 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:77193 Archived-At: Andreas Politz wrote: > Adam writes: > >> Pascal J. Bourguignon wrote: >> >>> Adam writes: >>> >>>>> Marc Mientki wrote: >>>> [ ... ] >>>> >>>> Here's the (insert-date) function. Which I now find doesn't >>>> work when called from the changed (id) example below. >>>> >>>> M-x id returns "Wrong type argument: stringp, nil" >>>> Strange, as I never used M-x insert-date with any prefix-argument. >>>> Indeed am not sure how I'd do that (to use its options). >>>> >>>> (defun insert-date (prefix) >>>> "Insert the current date. With prefix-argument, use ISO format. >>>> With >>>> two prefix arguments, write out the day and month name." >>>> (interactive "P") >>>> (let ((format (cond >>>> ((not prefix) "%A, %d %B %Y") >>>> ((equal prefix '(4)) "%Y-%m-%d") >>>> ((equal prefix '(16)) "%A, %d. %B %Y"))) >>>> (system-time-locale "de_DE")) >>>> (insert (format-time-string format)))) >>> >>> (defalias 'id 'insert-date) >>> >>> M-x id RET --> Monday, 20 September 2010 >>> C-y M-x id RET --> 2010-09-20 >> >> Thanks. I saw alias somewhere recently, but couldn't >> er.. didn't find it in a search looking for it simply >> by name. >> >> Out of interest, how does one use the (insert-date) function >> above with a prefix ? >> >> e.g. C-u 4 M-x insert-date returns an error, and >> evaluating (insert-date 4) is not right. > > keys | resulting arg > C-u 4 => 4 > C-u => (4) > > Since (equal 4 '(4)) is false and the cond has no default case, format > is nil and format-time-string reports an error for it. > > -ap OK. But I still don't get it. How do I work those 2 non-nil options ? Or how do I work them from two custom defuns, say M-x id4 M-x id16 ?