time.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. ;;; time.el --- display time, load and mail indicator in mode line of Emacs
  2. ;; Copyright (C) 1985-1987, 1993-1994, 1996, 2000-2017 Free Software
  3. ;; Foundation, Inc.
  4. ;; Maintainer: emacs-devel@gnu.org
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; Facilities to display current time/date and a new-mail indicator
  18. ;; in the Emacs mode line. The entry point is `display-time'.
  19. ;; Display time world in a buffer, the entry point is
  20. ;; `display-time-world'.
  21. ;;; Code:
  22. (defgroup display-time nil
  23. "Display time and load in mode line of Emacs."
  24. :group 'mode-line
  25. :group 'mail)
  26. (defcustom display-time-mail-file nil
  27. "File name of mail inbox file, for indicating existence of new mail.
  28. Non-nil and not a string means don't check for mail; nil means use
  29. default, which is system-dependent, and is the same as used by Rmail."
  30. :type '(choice (const :tag "None" none)
  31. (const :tag "Default" nil)
  32. (file :format "%v"))
  33. :group 'display-time)
  34. (defcustom display-time-mail-directory nil
  35. "Name of mail inbox directory, for indicating existence of new mail.
  36. Any nonempty regular file in the directory is regarded as newly arrived mail.
  37. If nil, do not check a directory for arriving mail."
  38. :type '(choice (const :tag "None" nil)
  39. (directory :format "%v"))
  40. :group 'display-time)
  41. (defcustom display-time-mail-function nil
  42. "Function to call, for indicating existence of new mail.
  43. If nil, that means use the default method: check that the file
  44. specified by `display-time-mail-file' is nonempty or that the
  45. directory `display-time-mail-directory' contains nonempty files."
  46. :type '(choice (const :tag "Default" nil)
  47. (function))
  48. :group 'display-time)
  49. (defcustom display-time-default-load-average 0
  50. "Which load average value will be shown in the mode line.
  51. Almost every system can provide values of load for the past 1 minute,
  52. past 5 or past 15 minutes. The default is to display 1-minute load average.
  53. The value can be one of:
  54. 0 => 1 minute load
  55. 1 => 5 minutes load
  56. 2 => 15 minutes load
  57. nil => None (do not display the load average)"
  58. :type '(choice (const :tag "1 minute load" 0)
  59. (const :tag "5 minutes load" 1)
  60. (const :tag "15 minutes load" 2)
  61. (const :tag "None" nil))
  62. :group 'display-time)
  63. (defvar display-time-load-average nil
  64. "Value of the system's load average currently shown on the mode line.
  65. See `display-time-default-load-average'.
  66. This is an internal variable; setting it has no effect.")
  67. (defcustom display-time-load-average-threshold 0.1
  68. "Load-average values below this value won't be shown in the mode line."
  69. :type 'number
  70. :group 'display-time)
  71. ;;;###autoload
  72. (defcustom display-time-day-and-date nil "\
  73. Non-nil means \\[display-time] should display day and date as well as time."
  74. :type 'boolean
  75. :group 'display-time)
  76. (defvar display-time-timer nil)
  77. (defcustom display-time-interval 60
  78. "Seconds between updates of time in the mode line."
  79. :type 'integer
  80. :group 'display-time)
  81. (defcustom display-time-24hr-format nil
  82. "Non-nil indicates time should be displayed as hh:mm, 0 <= hh <= 23.
  83. A value of nil means 1 <= hh <= 12, and an AM/PM suffix is used."
  84. :type 'boolean
  85. :group 'display-time)
  86. (defvar display-time-string nil
  87. "String used in mode lines to display a time string.
  88. It should not be set directly, but is instead updated by the
  89. `display-time' function.")
  90. ;;;###autoload(put 'display-time-string 'risky-local-variable t)
  91. (defcustom display-time-hook nil
  92. "List of functions to be called when the time is updated on the mode line."
  93. :type 'hook
  94. :group 'display-time)
  95. (defvar display-time-server-down-time nil
  96. "Time when mail file's file system was recorded to be down.
  97. If that file system seems to be up, the value is nil.")
  98. (defcustom zoneinfo-style-world-list
  99. '(("America/Los_Angeles" "Seattle")
  100. ("America/New_York" "New York")
  101. ("Europe/London" "London")
  102. ("Europe/Paris" "Paris")
  103. ("Asia/Calcutta" "Bangalore")
  104. ("Asia/Tokyo" "Tokyo"))
  105. "Alist of zoneinfo-style time zones and places for `display-time-world'.
  106. Each element has the form (TIMEZONE LABEL).
  107. TIMEZONE should be a string of the form AREA/LOCATION, where AREA is
  108. the name of a region -- a continent or ocean, and LOCATION is the name
  109. of a specific location, e.g., a city, within that region.
  110. LABEL is a string to display as the label of that TIMEZONE's time."
  111. :group 'display-time
  112. :type '(repeat (list string string))
  113. :version "23.1")
  114. (defcustom legacy-style-world-list
  115. '(("PST8PDT" "Seattle")
  116. ("EST5EDT" "New York")
  117. ("GMT0BST" "London")
  118. ("CET-1CDT" "Paris")
  119. ("IST-5:30" "Bangalore")
  120. ("JST-9" "Tokyo"))
  121. "Alist of traditional-style time zones and places for `display-time-world'.
  122. Each element has the form (TIMEZONE LABEL).
  123. TIMEZONE should be a string of the form:
  124. std[+|-]offset[dst[offset][,date[/time],date[/time]]]
  125. See the documentation of the TZ environment variable on your system,
  126. for more details about the format of TIMEZONE.
  127. LABEL is a string to display as the label of that TIMEZONE's time."
  128. :group 'display-time
  129. :type '(repeat (list string string))
  130. :version "23.1")
  131. (defcustom display-time-world-list
  132. ;; Determine if zoneinfo style timezones are supported by testing that
  133. ;; America/New York and Europe/London return different timezones.
  134. (let ((nyt (format-time-string "%z" nil "America/New_York"))
  135. (gmt (format-time-string "%z" nil "Europe/London")))
  136. (if (string-equal nyt gmt)
  137. legacy-style-world-list
  138. zoneinfo-style-world-list))
  139. "Alist of time zones and places for `display-time-world' to display.
  140. Each element has the form (TIMEZONE LABEL).
  141. TIMEZONE should be in a format supported by your system. See the
  142. documentation of `zoneinfo-style-world-list' and
  143. `legacy-style-world-list' for two widely used formats. LABEL is
  144. a string to display as the label of that TIMEZONE's time."
  145. :group 'display-time
  146. :type '(repeat (list string string))
  147. :version "23.1")
  148. (defcustom display-time-world-time-format "%A %d %B %R %Z"
  149. "Format of the time displayed, see `format-time-string'."
  150. :group 'display-time
  151. :type 'string
  152. :version "23.1")
  153. (defcustom display-time-world-buffer-name "*wclock*"
  154. "Name of the world clock buffer."
  155. :group 'display-time
  156. :type 'string
  157. :version "23.1")
  158. (defcustom display-time-world-timer-enable t
  159. "If non-nil, a timer will update the world clock."
  160. :group 'display-time
  161. :type 'boolean
  162. :version "23.1")
  163. (defcustom display-time-world-timer-second 60
  164. "Interval in seconds for updating the world clock."
  165. :group 'display-time
  166. :type 'integer
  167. :version "23.1")
  168. ;;;###autoload
  169. (defun display-time ()
  170. "Enable display of time, load level, and mail flag in mode lines.
  171. This display updates automatically every minute.
  172. If `display-time-day-and-date' is non-nil, the current day and date
  173. are displayed as well.
  174. This runs the normal hook `display-time-hook' after each update."
  175. (interactive)
  176. (display-time-mode 1))
  177. ;; This business used to be simpler when all mode lines had the same
  178. ;; face and the image could just be pbm. Now we try to rely on an xpm
  179. ;; image with a transparent background. Otherwise, set the background
  180. ;; for pbm.
  181. (defcustom display-time-mail-face nil
  182. "Face to use for `display-time-mail-string'.
  183. If `display-time-use-mail-icon' is non-nil, the image's
  184. background color is the background of this face. Set this to
  185. make the mail indicator stand out on a color display."
  186. :group 'mode-line-faces
  187. :group 'display-time
  188. :version "22.1"
  189. :type '(choice (const :tag "None" nil) face))
  190. (defvar display-time-mail-icon
  191. (find-image '((:type xpm :file "letter.xpm" :ascent center)
  192. (:type pbm :file "letter.pbm" :ascent center)))
  193. "Image specification to offer as the mail indicator on a graphic display.
  194. See `display-time-use-mail-icon' and `display-time-mail-face'.")
  195. ;; Fixme: Default to icon on graphical display?
  196. (defcustom display-time-use-mail-icon nil
  197. "Non-nil means use an icon as mail indicator on a graphic display.
  198. Otherwise use `display-time-mail-string'. The icon may consume less
  199. of the mode line. It is specified by `display-time-mail-icon'."
  200. :group 'display-time
  201. :type 'boolean)
  202. ;; Fixme: maybe default to the character if we can display Unicode.
  203. (defcustom display-time-mail-string "Mail"
  204. "String to use as the mail indicator in `display-time-string-forms'.
  205. This can use the Unicode letter character if you can display it."
  206. :group 'display-time
  207. :version "22.1"
  208. :type '(choice (const "Mail")
  209. ;; Use :tag here because the Lucid menu won't display
  210. ;; multibyte text.
  211. (const :tag "Unicode letter character" "✉")
  212. string))
  213. (defcustom display-time-format nil
  214. "String specifying format for displaying the time in the mode line.
  215. See the function `format-time-string' for an explanation of
  216. how to write this string. If this is nil, the defaults
  217. depend on `display-time-day-and-date' and `display-time-24hr-format'."
  218. :type '(choice (const :tag "Default" nil)
  219. string)
  220. :group 'display-time)
  221. (defcustom display-time-string-forms
  222. '((if (and (not display-time-format) display-time-day-and-date)
  223. (format-time-string "%a %b %e " now)
  224. "")
  225. (propertize
  226. (format-time-string (or display-time-format
  227. (if display-time-24hr-format "%H:%M" "%-I:%M%p"))
  228. now)
  229. 'help-echo (format-time-string "%a %b %e, %Y" now))
  230. load
  231. (if mail
  232. ;; Build the string every time to act on customization.
  233. ;; :set-after doesn't help for `customize-option'. I think it
  234. ;; should.
  235. (concat
  236. " "
  237. (propertize
  238. display-time-mail-string
  239. 'display `(when (and display-time-use-mail-icon
  240. (display-graphic-p))
  241. ,@display-time-mail-icon
  242. ,@(if (and display-time-mail-face
  243. (memq (plist-get (cdr display-time-mail-icon)
  244. :type)
  245. '(pbm xbm)))
  246. (let ((bg (face-attribute display-time-mail-face
  247. :background)))
  248. (if (stringp bg)
  249. (list :background bg)))))
  250. 'face display-time-mail-face
  251. 'help-echo "You have new mail; mouse-2: Read mail"
  252. 'mouse-face 'mode-line-highlight
  253. 'local-map (make-mode-line-mouse-map 'mouse-2
  254. read-mail-command)))
  255. ""))
  256. "List of expressions governing display of the time in the mode line.
  257. For most purposes, you can control the time format using `display-time-format'
  258. which is a more standard interface.
  259. This expression is a list of expressions that can involve the keywords
  260. `load', `day', `month', and `year', `12-hours', `24-hours', `minutes',
  261. `seconds', all numbers in string form, and `monthname', `dayname', `am-pm',
  262. and `time-zone' all alphabetic strings, and `mail' a true/nil value.
  263. For example:
  264. ((substring year -2) \"/\" month \"/\" day
  265. \" \" 24-hours \":\" minutes \":\" seconds
  266. (if time-zone \" (\") time-zone (if time-zone \")\")
  267. (if mail \" Mail\" \"\"))
  268. would give mode line times like `94/12/30 21:07:48 (UTC)'."
  269. :type '(repeat sexp)
  270. :group 'display-time)
  271. (defun display-time-event-handler ()
  272. (display-time-update)
  273. (let* ((current (current-time))
  274. (timer display-time-timer)
  275. ;; Compute the time when this timer will run again, next.
  276. (next-time (timer-relative-time
  277. (list (aref timer 1) (aref timer 2) (aref timer 3))
  278. (* 5 (aref timer 4)) 0)))
  279. ;; If the activation time is far in the past,
  280. ;; skip executions until we reach a time in the future.
  281. ;; This avoids a long pause if Emacs has been suspended for hours.
  282. (or (> (nth 0 next-time) (nth 0 current))
  283. (and (= (nth 0 next-time) (nth 0 current))
  284. (> (nth 1 next-time) (nth 1 current)))
  285. (and (= (nth 0 next-time) (nth 0 current))
  286. (= (nth 1 next-time) (nth 1 current))
  287. (> (nth 2 next-time) (nth 2 current)))
  288. (progn
  289. (timer-set-time timer (timer-next-integral-multiple-of-time
  290. current display-time-interval)
  291. display-time-interval)
  292. (timer-activate timer)))))
  293. (defun display-time-next-load-average ()
  294. "Switch between different load averages in the mode line.
  295. Switches from the 1 to 5 to 15 minute load average, and then back to 1."
  296. (interactive)
  297. (if (= 3 (setq display-time-load-average (1+ display-time-load-average)))
  298. (setq display-time-load-average 0))
  299. (display-time-update))
  300. (defun display-time-mail-check-directory ()
  301. (let ((mail-files (directory-files display-time-mail-directory t))
  302. (size 0))
  303. (while (and mail-files (= size 0))
  304. ;; Count size of regular files only.
  305. (setq size (+ size (or (and (file-regular-p (car mail-files))
  306. (nth 7 (file-attributes (car mail-files))))
  307. 0)))
  308. (setq mail-files (cdr mail-files)))
  309. (if (> size 0)
  310. size
  311. nil)))
  312. (with-no-warnings
  313. ;; Warnings are suppressed to avoid "global/dynamic var `X' lacks a prefix".
  314. (defvar now)
  315. (defvar time)
  316. (defvar load)
  317. (defvar mail)
  318. (defvar 24-hours)
  319. (defvar hour)
  320. (defvar 12-hours)
  321. (defvar am-pm)
  322. (defvar minutes)
  323. (defvar seconds)
  324. (defvar time-zone)
  325. (defvar day)
  326. (defvar year)
  327. (defvar monthname)
  328. (defvar month)
  329. (defvar dayname))
  330. (defun display-time-update ()
  331. "Update the display-time info for the mode line.
  332. However, don't redisplay right now.
  333. This is used for things like Rmail `g' that want to force an
  334. update which can wait for the next redisplay."
  335. (let* ((now (current-time))
  336. (time (current-time-string now))
  337. (load (if (null display-time-load-average)
  338. ""
  339. (condition-case ()
  340. ;; Do not show values less than
  341. ;; `display-time-load-average-threshold'.
  342. (if (> (* display-time-load-average-threshold 100)
  343. (nth display-time-load-average (load-average)))
  344. ""
  345. ;; The load average number is mysterious, so
  346. ;; provide some help.
  347. (let ((str (format " %03d"
  348. (nth display-time-load-average
  349. (load-average)))))
  350. (propertize
  351. (concat (substring str 0 -2) "." (substring str -2))
  352. 'local-map (make-mode-line-mouse-map
  353. 'mouse-2 'display-time-next-load-average)
  354. 'mouse-face 'mode-line-highlight
  355. 'help-echo (concat
  356. "System load average for past "
  357. (if (= 0 display-time-load-average)
  358. "1 minute"
  359. (if (= 1 display-time-load-average)
  360. "5 minutes"
  361. "15 minutes"))
  362. "; mouse-2: next"))))
  363. (error ""))))
  364. (mail-spool-file (or display-time-mail-file
  365. (getenv "MAIL")
  366. (concat rmail-spool-directory
  367. (user-login-name))))
  368. (mail (cond
  369. (display-time-mail-function
  370. (funcall display-time-mail-function))
  371. (display-time-mail-directory
  372. (display-time-mail-check-directory))
  373. ((and (stringp mail-spool-file)
  374. (or (null display-time-server-down-time)
  375. ;; If have been down for 20 min, try again.
  376. (> (- (nth 1 now) display-time-server-down-time)
  377. 1200)
  378. (and (< (nth 1 now) display-time-server-down-time)
  379. (> (- (nth 1 now)
  380. display-time-server-down-time)
  381. -64336))))
  382. (let ((start-time (current-time)))
  383. (prog1
  384. (display-time-file-nonempty-p mail-spool-file)
  385. (if (> (- (nth 1 (current-time))
  386. (nth 1 start-time))
  387. 20)
  388. ;; Record that mail file is not accessible.
  389. (setq display-time-server-down-time
  390. (nth 1 (current-time)))
  391. ;; Record that mail file is accessible.
  392. (setq display-time-server-down-time nil)))))))
  393. (24-hours (substring time 11 13))
  394. (hour (string-to-number 24-hours))
  395. (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
  396. (am-pm (if (>= hour 12) "pm" "am"))
  397. (minutes (substring time 14 16))
  398. (seconds (substring time 17 19))
  399. (time-zone (car (cdr (current-time-zone now))))
  400. (day (substring time 8 10))
  401. (year (format-time-string "%Y" now))
  402. (monthname (substring time 4 7))
  403. (month
  404. (cdr
  405. (assoc
  406. monthname
  407. '(("Jan" . "1") ("Feb" . "2") ("Mar" . "3") ("Apr" . "4")
  408. ("May" . "5") ("Jun" . "6") ("Jul" . "7") ("Aug" . "8")
  409. ("Sep" . "9") ("Oct" . "10") ("Nov" . "11") ("Dec" . "12")))))
  410. (dayname (substring time 0 3)))
  411. (setq display-time-string
  412. (mapconcat 'eval display-time-string-forms ""))
  413. ;; This is inside the let binding, but we are not going to document
  414. ;; what variables are available.
  415. (run-hooks 'display-time-hook))
  416. (force-mode-line-update 'all))
  417. (defun display-time-file-nonempty-p (file)
  418. (let ((remote-file-name-inhibit-cache (- display-time-interval 5)))
  419. (and (file-exists-p file)
  420. (< 0 (nth 7 (file-attributes (file-chase-links file)))))))
  421. ;;;###autoload
  422. (define-minor-mode display-time-mode
  423. "Toggle display of time, load level, and mail flag in mode lines.
  424. With a prefix argument ARG, enable Display Time mode if ARG is
  425. positive, and disable it otherwise. If called from Lisp, enable
  426. it if ARG is omitted or nil.
  427. When Display Time mode is enabled, it updates every minute (you
  428. can control the number of seconds between updates by customizing
  429. `display-time-interval'). If `display-time-day-and-date' is
  430. non-nil, the current day and date are displayed as well. This
  431. runs the normal hook `display-time-hook' after each update."
  432. :global t :group 'display-time
  433. (and display-time-timer (cancel-timer display-time-timer))
  434. (setq display-time-timer nil)
  435. (setq display-time-string "")
  436. (or global-mode-string (setq global-mode-string '("")))
  437. (setq display-time-load-average display-time-default-load-average)
  438. (if display-time-mode
  439. (progn
  440. (or (memq 'display-time-string global-mode-string)
  441. (setq global-mode-string
  442. (append global-mode-string '(display-time-string))))
  443. ;; Set up the time timer.
  444. (setq display-time-timer
  445. (run-at-time t display-time-interval
  446. 'display-time-event-handler))
  447. ;; Make the time appear right away.
  448. (display-time-update)
  449. ;; When you get new mail, clear "Mail" from the mode line.
  450. (add-hook 'rmail-after-get-new-mail-hook
  451. 'display-time-event-handler))
  452. (remove-hook 'rmail-after-get-new-mail-hook
  453. 'display-time-event-handler)))
  454. (define-derived-mode display-time-world-mode special-mode "World clock"
  455. "Major mode for buffer that displays times in various time zones.
  456. See `display-time-world'."
  457. (setq show-trailing-whitespace nil))
  458. (defun display-time-world-display (alist)
  459. "Replace current buffer text with times in various zones, based on ALIST."
  460. (let ((inhibit-read-only t)
  461. (buffer-undo-list t)
  462. (now (current-time))
  463. (max-width 0)
  464. result fmt)
  465. (erase-buffer)
  466. (dolist (zone alist)
  467. (let* ((label (cadr zone))
  468. (width (string-width label)))
  469. (push (cons label
  470. (format-time-string display-time-world-time-format
  471. now (car zone)))
  472. result)
  473. (when (> width max-width)
  474. (setq max-width width))))
  475. (setq fmt (concat "%-" (int-to-string max-width) "s %s\n"))
  476. (dolist (timedata (nreverse result))
  477. (insert (format fmt (car timedata) (cdr timedata))))
  478. (delete-char -1))
  479. (goto-char (point-min)))
  480. ;;;###autoload
  481. (defun display-time-world ()
  482. "Enable updating display of times in various time zones.
  483. `display-time-world-list' specifies the zones.
  484. To turn off the world time display, go to that window and type `q'."
  485. (interactive)
  486. (when (and display-time-world-timer-enable
  487. (not (get-buffer display-time-world-buffer-name)))
  488. (run-at-time t display-time-world-timer-second 'display-time-world-timer))
  489. (with-current-buffer (get-buffer-create display-time-world-buffer-name)
  490. (display-time-world-display display-time-world-list)
  491. (display-buffer display-time-world-buffer-name
  492. (cons nil '((window-height . fit-window-to-buffer))))
  493. (display-time-world-mode)))
  494. (defun display-time-world-timer ()
  495. (if (get-buffer display-time-world-buffer-name)
  496. (with-current-buffer (get-buffer display-time-world-buffer-name)
  497. (display-time-world-display display-time-world-list))
  498. ;; cancel timer
  499. (let ((list timer-list))
  500. (while list
  501. (let ((elt (pop list)))
  502. (when (equal (symbol-name (timer--function elt))
  503. "display-time-world-timer")
  504. (cancel-timer elt)))))))
  505. ;;;###autoload
  506. (defun emacs-uptime (&optional format)
  507. "Return a string giving the uptime of this instance of Emacs.
  508. FORMAT is a string to format the result, using `format-seconds'.
  509. For example, the Unix uptime command format is \"%D, %z%2h:%.2m\"."
  510. (interactive)
  511. (let ((str
  512. (format-seconds (or format "%Y, %D, %H, %M, %z%S")
  513. (float-time
  514. (time-subtract (current-time) before-init-time)))))
  515. (if (called-interactively-p 'interactive)
  516. (message "%s" str)
  517. str)))
  518. ;;;###autoload
  519. (defun emacs-init-time ()
  520. "Return a string giving the duration of the Emacs initialization."
  521. (interactive)
  522. (let ((str
  523. (format "%.1f seconds"
  524. (float-time
  525. (time-subtract after-init-time before-init-time)))))
  526. (if (called-interactively-p 'interactive)
  527. (message "%s" str)
  528. str)))
  529. (provide 'time)
  530. ;;; time.el ends here