help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help create function alias


From: Adam
Subject: Re: help create function alias
Date: Wed, 08 Dec 2010 15:29:04 -0000
User-agent: KNode/0.9.2

Pascal J. Bourguignon wrote:

> Adam <nospam@example.com> 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. 










reply via email to

[Prev in Thread] Current Thread [Next in Thread]