From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: asjo@koldfront.dk (Adam =?utf-8?Q?Sj=C3=B8gren?=) Newsgroups: gmane.emacs.devel Subject: Re: emacs-uptime - insert text with C-u [patch] Date: Tue, 10 Feb 2015 15:51:10 +0100 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87oap1rfa9.fsf@topper.koldfront.dk> References: <871tnnh91b.fsf@topper.koldfront.dk> <87wq5ffqpu.fsf@topper.koldfront.dk> <87fvc33tan.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1423579899 16048 80.91.229.3 (10 Feb 2015 14:51:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2015 14:51:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 10 15:51:30 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YLC9y-0004NY-7G for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 15:51:30 +0100 Original-Received: from localhost ([::1]:40214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLC9x-0001JO-KS for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 09:51:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLC9u-0001JJ-Td for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:51:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLC9p-00040g-UR for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:51:26 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:37526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLC9p-00040Z-O4 for emacs-devel@gnu.org; Tue, 10 Feb 2015 09:51:21 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YLC9k-0004Hm-Px for emacs-devel@gnu.org; Tue, 10 Feb 2015 15:51:16 +0100 Original-Received: from 2505ds5-by.0.fullrate.dk ([89.150.142.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Feb 2015 15:51:16 +0100 Original-Received: from asjo by 2505ds5-by.0.fullrate.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Feb 2015 15:51:16 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2505ds5-by.0.fullrate.dk OpenPGP: id=49D0746121BDE416; url=http://asjo.koldfront.dk/gpg.asc X-Now-Playing: Lords Of The Atlas, No Fuel Left For The Pilgrims (US version) (D-A-D) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97, Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182802 Archived-At: 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 * 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