From: asjo@koldfront.dk (Adam Sjøgren)
To: emacs-devel@gnu.org
Subject: Re: emacs-uptime - insert text with C-u [patch]
Date: Tue, 10 Feb 2015 15:51:10 +0100 [thread overview]
Message-ID: <87oap1rfa9.fsf@topper.koldfront.dk> (raw)
In-Reply-To: 87fvc33tan.fsf@uwakimon.sk.tsukuba.ac.jp
Stephen writes:
>>> asjo@koldfront.dk (Adam Sjøgren) writes:
>>>> I don't know what the idiom is to distinguish a prefix argument from
>>>> an optional one[...]
> In this case the argument list is (format insert), and you probably
> want a interactive spec of "iP".
Thanks for the hints; here is a nicer patch, and a ChangeLog entry:
2015-02-10 Adam Sjøgren <asjo@koldfront.dk>
* time.el (emacs-uptime): insert at point when called with
prefix.
--- time.el.orig 2015-02-10 15:42:48.472482974 +0100
+++ time.el 2015-02-10 15:45:27.743592919 +0100
@@ -571,18 +571,22 @@
(cancel-timer elt)))))))
;;;###autoload
-(defun emacs-uptime (&optional format)
+(defun emacs-uptime (&optional format here)
"Return a string giving the uptime of this instance of Emacs.
FORMAT is a string to format the result, using `format-seconds'.
-For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
- (interactive)
+For example, the Unix uptime command format is \"%D, %z%2h:%.2m\".
+If the optional argument HERE is non-nil, insert string at
+point."
+ (interactive "i\nP")
(let ((str
(format-seconds (or format "%Y, %D, %H, %M, %z%S")
(float-time
(time-subtract (current-time) before-init-time)))))
- (if (called-interactively-p 'interactive)
- (message "%s" str)
- str)))
+ (if here
+ (insert str)
+ (if (called-interactively-p 'interactive)
+ (message "%s" str)
+ str))))
;;;###autoload
(defun emacs-init-time ()
--
"[T]he subject matter is so attractive that only Adam Sjøgren
extravagant incompetence could make it dull." asjo@koldfront.dk
next prev parent reply other threads:[~2015-02-10 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-25 18:35 emacs-uptime - insert text with C-u [patch] Adam Sjøgren
2014-12-25 19:53 ` Andreas Schwab
2014-12-25 19:56 ` Adam Sjøgren
2014-12-26 4:54 ` Stephen J. Turnbull
2015-02-10 14:51 ` Adam Sjøgren [this message]
2015-02-10 15:18 ` Andreas Schwab
2015-02-10 15:24 ` Adam Sjøgren
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oap1rfa9.fsf@topper.koldfront.dk \
--to=asjo@koldfront.dk \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.