unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix
@ 2015-03-15 18:48 Adam Sjøgren
  2015-03-15 19:12 ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Sjøgren @ 2015-03-15 18:48 UTC (permalink / raw)
  To: 20112

Here is a patch making emacs-uptime insert at point when called with
prefix, similar to what emacs-version does:

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 ()

In GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)
 of 2015-03-07 on trouble, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
System Description:	Debian GNU/Linux 8.0 (jessie)

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.4/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-z,relro'

-- 
 "Och jag vet att allt är falskt och bedrageri                Adam Sjøgren
  Men det struntar jag i                                 asjo@koldfront.dk
  För vi dansar och du har så mjuka läppar"





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix
  2015-03-15 18:48 bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix Adam Sjøgren
@ 2015-03-15 19:12 ` Glenn Morris
  2015-03-15 19:41   ` Adam Sjøgren
  2020-01-15  5:28   ` Stefan Kangas
  0 siblings, 2 replies; 5+ messages in thread
From: Glenn Morris @ 2015-03-15 19:12 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: 20112

Adam Sjøgren wrote:

> Here is a patch making emacs-uptime insert at point when called with
> prefix, similar to what emacs-version does:

Thanks. As I've said before, personally I do not see the point of either.
Should every function that returns a string provide the option to insert
it? If not, what's special about this one?

http://lists.gnu.org/archive/html/emacs-devel/2008-02/msg00932.html





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix
  2015-03-15 19:12 ` Glenn Morris
@ 2015-03-15 19:41   ` Adam Sjøgren
  2020-01-15  5:28   ` Stefan Kangas
  1 sibling, 0 replies; 5+ messages in thread
From: Adam Sjøgren @ 2015-03-15 19:41 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 20112

Glenn writes:

> Adam Sjøgren wrote:

>> Here is a patch making emacs-uptime insert at point when called with
>> prefix, similar to what emacs-version does:
>
> Thanks. As I've said before, personally I do not see the point of either.
> Should every function that returns a string provide the option to insert
> it? If not, what's special about this one?

emacs-version and gnus-version are strings you sometimes want to
communicate to people, via email or news article ("I'm using C-u M-x
emacs-version").

The first thing I tried when I learned that emacs-uptime existed was to
use it in the same way: "Hey, look at me, my Emacs has an uptime of C-u
M-x emacs-uptime!"

Every function that reports a string of information you sometimes want
to communicate, and does nothing but that, I don't see why it should not
support inserting the string. What is the point of not providing that
option?

If you have a good idea for a general solution that avoids these
functions having a HERE argument, I would be interested to hear it.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix
  2015-03-15 19:12 ` Glenn Morris
  2015-03-15 19:41   ` Adam Sjøgren
@ 2020-01-15  5:28   ` Stefan Kangas
       [not found]     ` <87blr5fco5.fsf@tullinup.koldfront.dk>
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2020-01-15  5:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Adam Sjøgren, 20112

Glenn Morris <rgm@gnu.org> writes:

> Adam Sjøgren wrote:
>
>> Here is a patch making emacs-uptime insert at point when called with
>> prefix, similar to what emacs-version does:
>
> Thanks. As I've said before, personally I do not see the point of either.
> Should every function that returns a string provide the option to insert
> it? If not, what's special about this one?
>
> http://lists.gnu.org/archive/html/emacs-devel/2008-02/msg00932.html

I don't see that it would be very useful to have emacs-uptime insert
at point with a prefix argument.  Is there an actual use case for
it?

Otherwise, I would suggest to close this as wontfix.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix
       [not found]     ` <87blr5fco5.fsf@tullinup.koldfront.dk>
@ 2020-01-15 21:09       ` Stefan Kangas
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2020-01-15 21:09 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: 20112

Adam Sjøgren <asjo@koldfront.dk> writes:

> tag 20112 wontfix
> close 20112
> thanks
>
> Stefan writes:
>
>> Is there an actual use case for it?
>
> Beyond what I wrote in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20112#11 ?
>
> No, I don't think so.
>
> I assume nobody wants to remove the functionality from emacs-version, so
> I agree there is nothing to do here.

OK, thanks for clarifying.

Best regards,
Stefan Kangas





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-15 21:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-15 18:48 bug#20112: 24.4; (emacs-uptime): insert at point when called with prefix Adam Sjøgren
2015-03-15 19:12 ` Glenn Morris
2015-03-15 19:41   ` Adam Sjøgren
2020-01-15  5:28   ` Stefan Kangas
     [not found]     ` <87blr5fco5.fsf@tullinup.koldfront.dk>
2020-01-15 21:09       ` Stefan Kangas

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).