* bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time'
@ 2021-03-22 0:46 Gabriel
2021-03-22 18:56 ` Lars Ingebrigtsen
0 siblings, 1 reply; 4+ messages in thread
From: Gabriel @ 2021-03-22 0:46 UTC (permalink / raw)
To: 47306
[-- Attachment #1: Type: text/plain, Size: 94 bytes --]
This patch adds an optional argument FORMAT to 'emacs-init-time',
similar to 'emacs-uptime'.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-optional-FORMAT-argument-to-emacs-init-time.patch --]
[-- Type: text/x-diff, Size: 1317 bytes --]
From 6dbeded25f78279e43e0a56333e9b2c829241a31 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel.nascimento@nubank.com.br>
Date: Sun, 21 Mar 2021 21:39:26 -0300
Subject: [PATCH] Add optional FORMAT argument to 'emacs-init-time'
* lisp/time.el (emacs-init-time): Add optional FORMAT argument.
---
lisp/time.el | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lisp/time.el b/lisp/time.el
index 1403c4ac00..7e1d9180f6 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -614,13 +614,14 @@ emacs-uptime
str))))
;;;###autoload
-(defun emacs-init-time ()
- "Return a string giving the duration of the Emacs initialization."
+(defun emacs-init-time (&optional format)
+ "Return a string giving the duration of the Emacs initialization.
+FORMAT is a string to format the result, using `format'. If nil,
+the default format \"%f seconds\" is used."
(interactive)
- (let ((str
- (format "%s seconds"
- (float-time
- (time-subtract after-init-time before-init-time)))))
+ (let ((str (format (or format "%f seconds")
+ (float-time (time-subtract after-init-time
+ before-init-time)))))
(if (called-interactively-p 'interactive)
(message "%s" str)
str)))
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time'
2021-03-22 0:46 bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time' Gabriel
@ 2021-03-22 18:56 ` Lars Ingebrigtsen
2021-03-22 23:04 ` Gabriel
0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-22 18:56 UTC (permalink / raw)
To: Gabriel; +Cc: 47306
Gabriel <gabriel376@hotmail.com> writes:
> This patch adds an optional argument FORMAT to 'emacs-init-time',
> similar to 'emacs-uptime'.
I'm not quite sure what the use case is here? `emacs-uptime' uses
format-seconds, so it's a bit different...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time'
2021-03-22 18:56 ` Lars Ingebrigtsen
@ 2021-03-22 23:04 ` Gabriel
2021-03-24 9:34 ` Lars Ingebrigtsen
0 siblings, 1 reply; 4+ messages in thread
From: Gabriel @ 2021-03-22 23:04 UTC (permalink / raw)
To: 47306
>> This patch adds an optional argument FORMAT to 'emacs-init-time',
>> similar to 'emacs-uptime'.
>
> I'm not quite sure what the use case is here? `emacs-uptime' uses
> format-seconds, so it's a bit different...
Hi Lars,
The idea is to provide a flexible way for users to define their own
format to 'emacs-init-time'. It's very common for user to copy-paste
this function just to change the format, e.g., to use 2 decimal
places. For instance, see:
https://www.reddit.com/r/emacs/comments/m8d55l/what_is_your_startup_time/
https://blog.d46.us/advanced-emacs-startup/
https://emacs.stackexchange.com/questions/19249/long-pause-during-emacs-startup-prior-to-init-file-running
https://github.com/emacs-dashboard/emacs-dashboard/issues/57
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time'
2021-03-22 23:04 ` Gabriel
@ 2021-03-24 9:34 ` Lars Ingebrigtsen
0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-03-24 9:34 UTC (permalink / raw)
To: Gabriel; +Cc: 47306
Gabriel <gabriel376@hotmail.com> writes:
> The idea is to provide a flexible way for users to define their own
> format to 'emacs-init-time'. It's very common for user to copy-paste
> this function just to change the format, e.g., to use 2 decimal
> places. For instance, see:
>
> https://www.reddit.com/r/emacs/comments/m8d55l/what_is_your_startup_time/
> https://blog.d46.us/advanced-emacs-startup/
> https://emacs.stackexchange.com/questions/19249/long-pause-during-emacs-startup-prior-to-init-file-running
> https://github.com/emacs-dashboard/emacs-dashboard/issues/57
Ah, I see. Yes, it definitely looks like there's a use case here, so
I've applied your patch to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-24 9:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 0:46 bug#47306: 28.0.50; [PATCH] Add optional FORMAT argument to 'emacs-init-time' Gabriel
2021-03-22 18:56 ` Lars Ingebrigtsen
2021-03-22 23:04 ` Gabriel
2021-03-24 9:34 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).