From: Adam <nospam@example.com>
To: help-gnu-emacs@gnu.org
Subject: Re: help create function alias
Date: Tue, 21 Sep 2010 10:02:10 +1200 [thread overview]
Message-ID: <i78kus$366$1@lust.ihug.co.nz> (raw)
In-Reply-To: 87aancp1c5.fsf@fh-trier.de
Andreas Politz wrote:
> 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.
>
> 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 ?
next prev parent reply other threads:[~2010-09-20 22:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-20 10:43 help create function alias Adam
2010-09-20 10:57 ` Marc Mientki
2010-09-20 11:46 ` Adam
[not found] ` <i77ma9$h97$1@lust.ihug.co.nz>
2010-09-20 14:11 ` Pascal J. Bourguignon
2010-09-20 19:54 ` Adam
2010-09-20 21:11 ` Andreas Politz
2010-09-20 22:02 ` Adam [this message]
2010-09-21 1:56 ` Barry Margolin
2010-09-21 2:19 ` Pascal J. Bourguignon
2010-09-20 15:35 ` Stefan Monnier
[not found] ` <i78cop$ts0$1@lust.ihug.co.nz>
2010-09-20 22:19 ` Stefan Monnier
2010-09-20 22:41 ` Adam
2010-09-22 2:07 ` Xah Lee
2010-09-24 0:11 ` Stefan Monnier
2010-12-09 21:35 ` Drew Adams
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='i78kus$366$1@lust.ihug.co.nz' \
--to=nospam@example.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).