[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help create function alias
From: |
Pascal J. Bourguignon |
Subject: |
Re: help create function alias |
Date: |
Wed, 08 Dec 2010 15:29:09 -0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Adam <nospam@example.com> writes:
> 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.
Sorry, I meant C-u, not C-y. A raw prefix is just C-u.
--
__Pascal Bourguignon__ http://www.informatimago.com/
- help create function alias, Adam, 2010/12/09
- Re: help create function alias, Marc Mientki, 2010/12/08
- Re: help create function alias, Adam, 2010/12/09
- Re: help create function alias, Adam, 2010/12/09
- Re: help create function alias, Pascal J. Bourguignon, 2010/12/08
- Re: help create function alias, Adam, 2010/12/09
- Re: help create function alias, Andreas Politz, 2010/12/08
- Re: help create function alias, Adam, 2010/12/09
- Re: help create function alias, Barry Margolin, 2010/12/08
- Re: help create function alias,
Pascal J. Bourguignon <=
Re: help create function alias, Stefan Monnier, 2010/12/08