From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: emacs-uptime - insert text with C-u [patch] Date: Tue, 10 Feb 2015 16:18:08 +0100 Message-ID: References: <871tnnh91b.fsf@topper.koldfront.dk> <87wq5ffqpu.fsf@topper.koldfront.dk> <87fvc33tan.fsf@uwakimon.sk.tsukuba.ac.jp> <87oap1rfa9.fsf@topper.koldfront.dk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1423581529 12670 80.91.229.3 (10 Feb 2015 15:18:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Feb 2015 15:18:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: asjo@koldfront.dk (Adam =?utf-8?Q?Sj=C3=B8gren?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 10 16:18:41 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 1YLCaC-000050-G3 for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 16:18:36 +0100 Original-Received: from localhost ([::1]:40338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLCaA-0006hQ-Ex for ged-emacs-devel@m.gmane.org; Tue, 10 Feb 2015 10:18:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLCZq-0006h1-LL for emacs-devel@gnu.org; Tue, 10 Feb 2015 10:18:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLCZn-0004vm-F5 for emacs-devel@gnu.org; Tue, 10 Feb 2015 10:18:14 -0500 Original-Received: from cantor2.suse.de ([195.135.220.15]:53244 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLCZn-0004vU-4H for emacs-devel@gnu.org; Tue, 10 Feb 2015 10:18:11 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Original-Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6B0B0AB0C; Tue, 10 Feb 2015 15:18:09 +0000 (UTC) X-Yow: Everybody gets free BORSCHT! In-Reply-To: <87oap1rfa9.fsf@topper.koldfront.dk> ("Adam =?utf-8?Q?Sj?= =?utf-8?Q?=C3=B8gren=22's?= message of "Tue, 10 Feb 2015 15:51:10 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." 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:182804 Archived-At: asjo@koldfront.dk (Adam Sj=C3=B8gren) writes: > --- 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))))))) > =20 > ;;;###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-ti= me))))) > - (if (called-interactively-p 'interactive) > - (message "%s" str) > - str))) > + (if here > + (insert str) > + (if (called-interactively-p 'interactive) > + (message "%s" str) > + str)))) It think you should always return the same value, which is str. Andreas. --=20 Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint =3D 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D= 7 "And now for something completely different."