From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: help create function alias
Date: Mon, 20 Sep 2010 21:56:15 -0400 [thread overview]
Message-ID: <barmar-66D20F.21561520092010@62-183-169-81.bb.dnainternet.fi> (raw)
In-Reply-To: i78deq$ue5$1@lust.ihug.co.nz
In article <i78deq$ue5$1@lust.ihug.co.nz>, Adam <nospam@example.com>
wrote:
> 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.
See the Emacs Lisp Reference Manual section on prefix arguments. If you
enter a number explicitly, the prefix argument is just the number. But
if you do C-u M-x insert-date or C-u C-u M-x insert-date, it puts the
default argument in a list, which is what the function expects.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
next prev parent reply other threads:[~2010-09-21 1:56 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
2010-09-21 1:56 ` Barry Margolin [this message]
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=barmar-66D20F.21561520092010@62-183-169-81.bb.dnainternet.fi \
--to=barmar@alum.mit.edu \
--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).