unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Minibuffer tray to display current time and date
@ 2015-04-22 16:07 Alexander Shukaev
  2015-04-22 16:11 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Alexander Shukaev @ 2015-04-22 16:07 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I was wondering if there is a possibility to display current time and date
on the right side (right-aligned) of the minibuffer (similarly to how trays
do on desktops)?  I'm OK with the fact that it can disappear when one uses
minibuffer (for `M-x' or whatever), but it should appear again as soon as
minibuffer is idle.  I'm also aware of
http://www.emacswiki.org/emacs/MiniBufferTray, but that seems too
heavyweight for this simple goal (I'm not interested in line/column
information as well).  Does anybody have some pure Emacs Lisp snippets to
implement this?  Thanks in advance.

Kind regards,
Alexander


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

* Re: Minibuffer tray to display current time and date
  2015-04-22 16:07 Minibuffer tray to display current time and date Alexander Shukaev
@ 2015-04-22 16:11 ` Eli Zaretskii
  2015-04-22 16:17   ` Alexander Shukaev
  2015-04-22 17:05 ` Stefan Monnier
       [not found] ` <mailman.1379.1429722347.904.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-22 16:11 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 22 Apr 2015 18:07:43 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> 
> I was wondering if there is a possibility to display current time and date
> on the right side (right-aligned) of the minibuffer (similarly to how trays
> do on desktops)?

You specifically want to avoid having that in the mode line, as turned
on by display-time-mode?



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

* Re: Minibuffer tray to display current time and date
  2015-04-22 16:11 ` Eli Zaretskii
@ 2015-04-22 16:17   ` Alexander Shukaev
  2015-04-22 16:57     ` Michael Heerdegen
  0 siblings, 1 reply; 37+ messages in thread
From: Alexander Shukaev @ 2015-04-22 16:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

>
> You specifically want to avoid having that in the mode line, as turned
> on by display-time-mode?
>

​That's the thing, mode line would be too cluttered then.  In particular,
when splits are used, there is no reason to duplicate such global
information as current time and date.  That's why I think placing them into
minibuffer might be a good idea.​


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

* Re: Minibuffer tray to display current time and date
  2015-04-22 16:17   ` Alexander Shukaev
@ 2015-04-22 16:57     ` Michael Heerdegen
  0 siblings, 0 replies; 37+ messages in thread
From: Michael Heerdegen @ 2015-04-22 16:57 UTC (permalink / raw)
  To: help-gnu-emacs

Alexander Shukaev <haroogan@gmail.com> writes:

> ​That's the thing, mode line would be too cluttered then.  In
> particular, when splits are used, there is no reason to duplicate such
> global information as current time and date.  That's why I think
> placing them into minibuffer might be a good idea.​

From what you were saying, I think you mean to display the time in the
echo area, not the minibuffer.

That could simply be done using `message'.  One should take care of not
cluttering *Messages* and avoid erasing other messages.

I would try starting like this:

--8<---------------cut here---------------start------------->8---
(progn
  (defvar current-time-string "")
  (run-with-timer
   1 1
   (lambda ()
     (let ((message-log-max nil))
       (unless (minibuffer-window-active-p (minibuffer-window))
         (when (member (current-message)
                       (list current-time-string nil))
           (message "%s" (setq current-time-string
                               (current-time-string)))))))))
--8<---------------cut here---------------end--------------->8---

Alignment and combining with other messages could be done too.

Just an idea, admittedly this code is not super elegant.


Michael.




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

* Re: Minibuffer tray to display current time and date
  2015-04-22 16:07 Minibuffer tray to display current time and date Alexander Shukaev
  2015-04-22 16:11 ` Eli Zaretskii
@ 2015-04-22 17:05 ` Stefan Monnier
       [not found] ` <mailman.1379.1429722347.904.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 37+ messages in thread
From: Stefan Monnier @ 2015-04-22 17:05 UTC (permalink / raw)
  To: help-gnu-emacs

> I was wondering if there is a possibility to display current time and date
> on the right side (right-aligned) of the minibuffer (similarly to how trays
> do on desktops)?  I'm OK with the fact that it can disappear when one uses
> minibuffer (for `M-x' or whatever), but it should appear again as soon as
> minibuffer is idle.  I'm also aware of

I'd welcome a package that lets you display such info in the minibuffer.
This has been requested several times already.

Basically, the situation is that what you call the "minibuffer" is
actually a mini-window.  Those windows can display normal buffers.
Among the buffers they display, are the so-called minibuffers, which are
normal buffers, named like " *Minibuf-N*", used during minibuffer input.
There are also echo-area buffers (2 of them, named " *Echo Area 0/1*")
which are used to display "message"s.

IIUC, the "idle minibuffer" AFAIK is actually displaying the buffer
" *Minibuf-0*", so if you put the data you want into that buffer, it
should be displayed where/when you want it.
E.g. try:

   M-: (with-current-buffer " *Minibuf-0*" (insert "I'm Idle!")) RET

*BUT*, IIRC there is somewhere in the C code where we sometimes just
"clear" the mini-window (under the assumption that the buffer it
displays doesn't contain anything) instead of actually displaying its
content, so in order for such a package to work reliably, we may need to
patch the C code.  But it might work well enough to be usable without
such a patch.


        Stefan




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

* Re: Minibuffer tray to display current time and date
       [not found] ` <mailman.1379.1429722347.904.help-gnu-emacs@gnu.org>
@ 2015-04-23  0:59   ` Emanuel Berg
  2015-04-23 15:15     ` Jorge A. Alfaro-Murillo
       [not found]     ` <mailman.1461.1429802140.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 37+ messages in thread
From: Emanuel Berg @ 2015-04-23  0:59 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>    M-: (with-current-buffer " *Minibuf-0*" (insert
> "I'm Idle!")) RET

So then it should be as simple as:

    (with-current-buffer " *Minibuf-0*"
      (insert (format-time-string "%H:%M")))

Do you then use the idle-timer or how do you update it
so it won't freeze time and make everything stop
around you?

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-04-23  0:59   ` Emanuel Berg
@ 2015-04-23 15:15     ` Jorge A. Alfaro-Murillo
       [not found]     ` <mailman.1461.1429802140.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 37+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-04-23 15:15 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes: 
> 
>>    M-: (with-current-buffer " *Minibuf-0*" (insert 
>> "I'm Idle!")) RET 
> 
> So then it should be as simple as: 
> 
>     (with-current-buffer " *Minibuf-0*" 
>       (insert (format-time-string "%H:%M")))

You should also delete the content of the mini-buffer before 
inserting. 
 
> Do you then use the idle-timer or how do you update it so it 
> won't freeze time and make everything stop around you?

This works:

#+BEGIN_SRC emacs-lisp
  (run-at-time nil 60
               (lambda ()
               	 (with-current-buffer " *Minibuf-0*"
                   (erase-buffer)
                   (insert (format-time-string "%H:%M")))))
#+END_SRC

Or you could have it on the right bottom:

#+BEGIN_SRC emacs-lisp
  (run-at-time
   nil 60
   (lambda ()
     (with-current-buffer " *Minibuf-0*"
       (erase-buffer)
       (dotimes (spaces (- (frame-width) 5))
         (insert " "))
       (insert (format-time-string "%H:%M")))))
#+END_SRC

Best,
-- 
Jorge.




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

* Re: Minibuffer tray to display current time and date
       [not found]     ` <mailman.1461.1429802140.904.help-gnu-emacs@gnu.org>
@ 2015-04-23 15:43       ` Emanuel Berg
  2015-04-23 18:11         ` Jorge A. Alfaro-Murillo
       [not found]         ` <mailman.1474.1429812715.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 37+ messages in thread
From: Emanuel Berg @ 2015-04-23 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

jorge.alfaro-murillo@yale.edu (Jorge A.
Alfaro-Murillo) writes:

>   (run-at-time nil 60
>                (lambda ()
>                	 (with-current-buffer " *Minibuf-0*"
>                    (erase-buffer)
>                    (insert (format-time-string "%H:%M")))))

I think one can afford to be a bit more generous with
updates than once every minute, so it will be (more)
in synch with the system time.

>   (run-at-time
>    nil 60
>    (lambda ()
>      (with-current-buffer " *Minibuf-0*"
>        (erase-buffer)
>        (dotimes (spaces (- (frame-width) 5))
>          (insert " "))
>        (insert (format-time-string "%H:%M")))))

I need to subtract 6 for it to fit. (The time string
itself is five chars.)

Possibly, Instead of the `dotimes' loop, examine if
`make-string' is more efficient, e.g.:

    (make-string 10 ? ) ; 10 spaces

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-04-23 15:43       ` Emanuel Berg
@ 2015-04-23 18:11         ` Jorge A. Alfaro-Murillo
       [not found]         ` <mailman.1474.1429812715.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 37+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-04-23 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg writes:

> Jorge A. Alfaro-Murillo writes: 
> 
>>   (run-at-time nil 60 
>>                (lambda () (with-current-buffer " *Minibuf-0*" 
>>                    (erase-buffer) (insert (format-time-string 
>>                    "%H:%M"))))) 
> 
> I think one can afford to be a bit more generous with updates 
> than once every minute, so it will be (more) in synch with the 
> system time.

Optimal would be to run now, and then
(run-at-time NEXT-TIME-MINUTE-CHANGES nil (lambda () (run-at-time 
t 60 ...

but I don't know how to get NEXT-TIME-MINUTE-CHANGES

>>   (run-at-time 
>>    nil 60 (lambda () 
>>      (with-current-buffer " *Minibuf-0*" 
>>        (erase-buffer) (dotimes (spaces (- (frame-width) 5)) 
>>          (insert " ")) 
>>        (insert (format-time-string "%H:%M"))))) 
> 
> I need to subtract 6 for it to fit. (The time string itself is 
> five chars.)

It works with 5 for me, the last character is at the last column.

> Possibly, Instead of the `dotimes' loop, examine if 
> `make-string' is more efficient, e.g.: 
> 
>     (make-string 10 ? ) ; 10 spaces

True.

-- 
Jorge.




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

* Re: Minibuffer tray to display current time and date
       [not found]         ` <mailman.1474.1429812715.904.help-gnu-emacs@gnu.org>
@ 2015-04-23 22:46           ` Emanuel Berg
  2015-04-24 14:13             ` tomas
  0 siblings, 1 reply; 37+ messages in thread
From: Emanuel Berg @ 2015-04-23 22:46 UTC (permalink / raw)
  To: help-gnu-emacs

jorge.alfaro-murillo@yale.edu (Jorge A.
Alfaro-Murillo) writes:

> Optimal would be to run now, and then (run-at-time
> NEXT-TIME-MINUTE-CHANGES nil (lambda () (run-at-time
> t 60 ...

Are you thinking like this: "The granularity of the
clock is 1 minute. So it should be updated once every
minute, i.e. every 60 seconds."

That sounds a bit risky to me, so I'd recommend setting
it so that it will be set somewhere around three times
per minute - and not set evenly so, but for example
every 22 seconds:

    0, 22, 44, 6 (66), 28, 50, ...

>>>   (run-at-time nil 60 (lambda ()
>>>   (with-current-buffer " *Minibuf-0*"
>>>   (erase-buffer) (dotimes (spaces (- (frame-width)
>>>   5)) (insert " ")) (insert (format-time-string
>>>   "%H:%M")))))
>>
>> I need to subtract 6 for it to fit. (The time
>> string itself is five chars.)
>
> It works with 5 for me, the last character is at the
> last column.

In X it works with 5. In the Linux VTs and in xterm
with '-nw' it needs 6.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-04-23 22:46           ` Emanuel Berg
@ 2015-04-24 14:13             ` tomas
  2015-04-24 14:41               ` Eli Zaretskii
  0 siblings, 1 reply; 37+ messages in thread
From: tomas @ 2015-04-24 14:13 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Apr 24, 2015 at 12:46:10AM +0200, Emanuel Berg wrote:
> jorge.alfaro-murillo@yale.edu (Jorge A.
> Alfaro-Murillo) writes:
> 
> > Optimal would be to run now, and then (run-at-time
> > NEXT-TIME-MINUTE-CHANGES nil (lambda () (run-at-time
> > t 60 ...
> 
> Are you thinking like this: "The granularity of the
> clock is 1 minute. So it should be updated once every
> minute, i.e. every 60 seconds."
> 
> That sounds a bit risky to me, so I'd recommend setting
> it so that it will be set somewhere around three times
> per minute - and not set evenly so, but for example
> every 22 seconds:
> 
>     0, 22, 44, 6 (66), 28, 50, ...

This sounds a bit roundabout: why not run-at-time? Do you fear
that it gets out of sync?

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlU6T38ACgkQBcgs9XrR2kZ1UwCaA8qCltmKECaI3v+Ytyg0kjCk
eWUAn1OPn7/n/xOpHq6zIB4dJztEDIZW
=I6Cv
-----END PGP SIGNATURE-----



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

* Re: Minibuffer tray to display current time and date
  2015-04-24 14:13             ` tomas
@ 2015-04-24 14:41               ` Eli Zaretskii
  2015-04-24 14:57                 ` Jorge A. Alfaro-Murillo
       [not found]                 ` <mailman.1537.1429888188.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-24 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Fri, 24 Apr 2015 16:13:19 +0200
> From: <tomas@tuxteam.de>
> Cc: help-gnu-emacs@gnu.org
> 
> > > Optimal would be to run now, and then (run-at-time
> > > NEXT-TIME-MINUTE-CHANGES nil (lambda () (run-at-time
> > > t 60 ...
> > 
> > Are you thinking like this: "The granularity of the
> > clock is 1 minute. So it should be updated once every
> > minute, i.e. every 60 seconds."
> > 
> > That sounds a bit risky to me, so I'd recommend setting
> > it so that it will be set somewhere around three times
> > per minute - and not set evenly so, but for example
> > every 22 seconds:
> > 
> >     0, 22, 44, 6 (66), 28, 50, ...
> 
> This sounds a bit roundabout: why not run-at-time? Do you fear
> that it gets out of sync?

Instead of arguing, just look at how display-time-mode does it, this
problem is already solved there.



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

* Re: Minibuffer tray to display current time and date
  2015-04-24 14:41               ` Eli Zaretskii
@ 2015-04-24 14:57                 ` Jorge A. Alfaro-Murillo
  2015-04-24 16:48                   ` Eli Zaretskii
       [not found]                 ` <mailman.1537.1429888188.904.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 37+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-04-24 14:57 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii writes:

>> Date: Fri, 24 Apr 2015 16:13:19 +0200 From: <tomas@tuxteam.de> 
>> Cc: help-gnu-emacs@gnu.org  
>> > > Optimal would be to run now, and then (run-at-time 
>> > > NEXT-TIME-MINUTE-CHANGES nil (lambda () (run-at-time t 60 
>> > > ... 
>> >  Are you thinking like this: "The granularity of the clock is 
>> > 1 minute. So it should be updated once every minute, i.e. 
>> > every 60 seconds."   That sounds a bit risky to me, so I'd 
>> > recommend setting it so that it will be set somewhere around 
>> > three times per minute - and not set evenly so, but for 
>> > example every 22 seconds:  
>> >     0, 22, 44, 6 (66), 28, 50, ... 
>>  This sounds a bit roundabout: why not run-at-time? Do you fear 
>> that it gets out of sync? 
> 
> Instead of arguing, just look at how display-time-mode does it, 
> this problem is already solved there.

It does it exactly as I had proposed at the beginning (run-at-time 
t 60 ...)

But the clock might be off by at most 59 seconds, which is why it 
would be better to run once and then wait for the next time the 
minute changes to set the (run-at-time t 60 ...). Running every 22 
seconds is very inefficient, two out three calls will not change 
anything.

-- 
Jorge.




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

* Re: Minibuffer tray to display current time and date
  2015-04-24 14:57                 ` Jorge A. Alfaro-Murillo
@ 2015-04-24 16:48                   ` Eli Zaretskii
  2015-04-24 20:18                     ` Jorge A. Alfaro-Murillo
       [not found]                     ` <mailman.1562.1429906736.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-24 16:48 UTC (permalink / raw)
  To: help-gnu-emacs

> From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo)
> Date: Fri, 24 Apr 2015 10:57:42 -0400
> 
> Eli Zaretskii writes:
> 
> > Instead of arguing, just look at how display-time-mode does it, 
> > this problem is already solved there.
> 
> It does it exactly as I had proposed at the beginning (run-at-time 
> t 60 ...)

You are missing the call to timer-set-time, I think.



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

* Re: Minibuffer tray to display current time and date
  2015-04-24 16:48                   ` Eli Zaretskii
@ 2015-04-24 20:18                     ` Jorge A. Alfaro-Murillo
       [not found]                     ` <mailman.1562.1429906736.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 37+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-04-24 20:18 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii writes:

>> From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) 
>> Date: Fri, 24 Apr 2015 10:57:42 -0400  Eli Zaretskii writes:  
>> > Instead of arguing, just look at how display-time-mode does 
>> > it,  this problem is already solved there. 
>>  It does it exactly as I had proposed at the beginning 
>> (run-at-time  t 60 ...) 
> 
> You are missing the call to timer-set-time, I think.

Thanks... I see, it seems like every time that the display-timer 
runs it updates its interval. That doesn't seem very efficient, 
but there could be a good reason why they did it that way.

For the time in the minibuffer, this seems to work:

#+BEGIN_SRC emacs-lisp
  (with-current-buffer " *Minibuf-0*" (insert (format-time-string 
  "%H:%M")))

  (run-at-time (timer-next-integral-multiple-of-time 
  (current-time) 60)
               60
               (lambda ()
                 (with-current-buffer " *Minibuf-0*"
                   (erase-buffer)
                   (insert (format-time-string "%H:%M")))))
#+END_SRC 

Best,

-- 
Jorge.




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

* Re: Minibuffer tray to display current time and date
       [not found]                     ` <mailman.1562.1429906736.904.help-gnu-emacs@gnu.org>
@ 2015-04-25  1:11                       ` Dan Espen
  2015-04-26  2:38                         ` Jorge A. Alfaro-Murillo
  0 siblings, 1 reply; 37+ messages in thread
From: Dan Espen @ 2015-04-25  1:11 UTC (permalink / raw)
  To: help-gnu-emacs

jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes:

> Eli Zaretskii writes:
>
>>> From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) 
>>> Date: Fri, 24 Apr 2015 10:57:42 -0400  Eli Zaretskii writes:  
>>> > Instead of arguing, just look at how display-time-mode does 
>>> > it,  this problem is already solved there. 
>>>  It does it exactly as I had proposed at the beginning 
>>> (run-at-time  t 60 ...) 
>> 
>> You are missing the call to timer-set-time, I think.
>
> Thanks... I see, it seems like every time that the display-timer 
> runs it updates its interval. That doesn't seem very efficient, 
> but there could be a good reason why they did it that way.

How is that not efficient?

That's exactly the way I did it about 30 years ago
on an IBM mainframe.  Works for anything you want running
at a regular interval.  First pop is 60 seconds.
Odds are, it will pop at 61, or even 62 depending on system load, etc.
So, the next wait should be 60, 59, or 58.

-- 
Dan Espen


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

* Re: Minibuffer tray to display current time and date
       [not found]                 ` <mailman.1537.1429888188.904.help-gnu-emacs@gnu.org>
@ 2015-04-25  1:16                   ` Emanuel Berg
  0 siblings, 0 replies; 37+ messages in thread
From: Emanuel Berg @ 2015-04-25  1:16 UTC (permalink / raw)
  To: help-gnu-emacs

jorge.alfaro-murillo@yale.edu (Jorge A.
Alfaro-Murillo) writes:

> Running every 22 seconds is very inefficient, two
> out three calls will not change anything.

It is like the highway system.

Let's say there is a road that is 1 km, i.e.
1000 meter. A traditional pickup truck is about 17
feet, i.e. ~5 meters.

So the most efficient way to use that road is - let's
see - to drive there simultaneously with 1000/5 = 200
trucks! Right?

No - redundancy of resources is your friend - even
more so in computing, where it can be automatized.

But I'm just saying as a matter of principle and my
gut feeling. I didn't study this problem in detail and
it is your code. So keep it up.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-04-25  1:11                       ` Dan Espen
@ 2015-04-26  2:38                         ` Jorge A. Alfaro-Murillo
  2015-04-26 14:48                           ` Eli Zaretskii
  0 siblings, 1 reply; 37+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-04-26  2:38 UTC (permalink / raw)
  To: help-gnu-emacs

Dan Espen writes:

> jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes: 
> 
>> Thanks... I see, it seems like every time that the 
>> display-timer  runs it updates its interval. That doesn't seem 
>> very efficient,  but there could be a good reason why they did 
>> it that way. 
> 
> How is that not efficient? 
> 
> That's exactly the way I did it about 30 years ago on an IBM 
> mainframe. Works for anything you want running at a regular 
> interval.  First pop is 60 seconds. Odds are, it will pop at 61, 
> or even 62 depending on system load, etc. So, the next wait 
> should be 60, 59, or 58.

Well, I think that (run-at-time time repeat ...) already schedules 
the times to run at the correct times even if one is late, so 
there is no need to reschedule again even if the system load is 
high and misses one timing or more. The documentation in (info 
"(elisp) Timers") seems to imply so:

"A repeating timer nominally ought to run every REPEAT seconds, 
but remember that any invocation of a timer can be late.  Lateness 
of one repetition has no effect on the scheduled time of the next 
repetition.  For instance, if Emacs is busy computing for long 
enough to cover three scheduled repetitions of the timer, and then 
starts to wait, it will immediately call the timer function three 
times in immediate succession (presuming no other timers trigger 
before or between them)." 

Now the last part could be problematic if emacs is stopped or the 
systems goes into hibernation (?). But `timer-max-repeats' takes 
care of that. Am I missing something?

Best,
-- 
Jorge.




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

* Re: Minibuffer tray to display current time and date
  2015-04-26  2:38                         ` Jorge A. Alfaro-Murillo
@ 2015-04-26 14:48                           ` Eli Zaretskii
  2015-04-26 15:52                             ` tomas
  2015-04-27  0:36                             ` Stefan Monnier
  0 siblings, 2 replies; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-26 14:48 UTC (permalink / raw)
  To: help-gnu-emacs

> From: jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo)
> Date: Sat, 25 Apr 2015 22:38:48 -0400
> 
> Dan Espen writes:
> 
> > jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes: 
> > 
> >> Thanks... I see, it seems like every time that the 
> >> display-timer  runs it updates its interval. That doesn't seem 
> >> very efficient,  but there could be a good reason why they did 
> >> it that way. 
> > 
> > How is that not efficient? 
> > 
> > That's exactly the way I did it about 30 years ago on an IBM 
> > mainframe. Works for anything you want running at a regular 
> > interval.  First pop is 60 seconds. Odds are, it will pop at 61, 
> > or even 62 depending on system load, etc. So, the next wait 
> > should be 60, 59, or 58.
> 
> Well, I think that (run-at-time time repeat ...) already schedules 
> the times to run at the correct times even if one is late, so 
> there is no need to reschedule again even if the system load is 
> high and misses one timing or more.

It's not a problem with system load, it's a problem with _when_ within
the minute does the timer run.  Scheduling it to run every 60 sec
doesn't guarantee that it will run exactly when the minutes advance.
So, if you are unlucky, your time shown in the echo area can be 59 sec
late.



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

* Re: Minibuffer tray to display current time and date
  2015-04-26 14:48                           ` Eli Zaretskii
@ 2015-04-26 15:52                             ` tomas
  2015-04-26 16:05                               ` Eli Zaretskii
  2015-04-27  0:36                             ` Stefan Monnier
  1 sibling, 1 reply; 37+ messages in thread
From: tomas @ 2015-04-26 15:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Apr 26, 2015 at 05:48:13PM +0300, Eli Zaretskii wrote:

> It's not a problem with system load, it's a problem with _when_ within
> the minute does the timer run.  Scheduling it to run every 60 sec
> doesn't guarantee that it will run exactly when the minutes advance.
> So, if you are unlucky, your time shown in the echo area can be 59 sec
> late.

I'd expected that a first argument of t for run-at-time would take care
of that. From the Elisp doc:

  "-- Command: run-at-time time repeat function &rest args
      [...]
      In most cases, REPEAT has no effect on when _first_ call takes
      place--TIME alone specifies that.  There is one exception: if TIME
      is `t', then the timer runs whenever the time is a multiple of
     REPEAT seconds after the epoch.  This is useful for functions like
     `display-time'."

So if run-at-time does resync, calling (run-at-time t 60) should do the
job all by itself? For anxious people, just displaying the current time
rounded to the next full minute should be the equivalent of
belt-and-suspenders?

I mean, some moral equivalent of:

  (format-time-string "%H:%M"
     (seconds-to-time
       (* 60 (round (/ (float-time) 60)))))

Regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlU9CcQACgkQBcgs9XrR2kb0JgCfVTqCTWJmbZe7zj2VAwq8a5Op
hlkAn0NKfGyhYel+5/93fSeU0KWvnOau
=jVAB
-----END PGP SIGNATURE-----



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

* Re: Minibuffer tray to display current time and date
  2015-04-26 15:52                             ` tomas
@ 2015-04-26 16:05                               ` Eli Zaretskii
  0 siblings, 0 replies; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-26 16:05 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 26 Apr 2015 17:52:36 +0200
> Cc: help-gnu-emacs@gnu.org
> From:  <tomas@tuxteam.de>
> 
> On Sun, Apr 26, 2015 at 05:48:13PM +0300, Eli Zaretskii wrote:
> 
> > It's not a problem with system load, it's a problem with _when_ within
> > the minute does the timer run.  Scheduling it to run every 60 sec
> > doesn't guarantee that it will run exactly when the minutes advance.
> > So, if you are unlucky, your time shown in the echo area can be 59 sec
> > late.
> 
> I'd expected that a first argument of t for run-at-time would take care
> of that.

Only if you have a single timer that needs to run at that time.  And
what are the chances of that in any decent Emacs session?



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

* Re: Minibuffer tray to display current time and date
  2015-04-26 14:48                           ` Eli Zaretskii
  2015-04-26 15:52                             ` tomas
@ 2015-04-27  0:36                             ` Stefan Monnier
  2015-04-28 17:27                               ` Alexander Shukaev
       [not found]                               ` <mailman.1824.1430242034.904.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 37+ messages in thread
From: Stefan Monnier @ 2015-04-27  0:36 UTC (permalink / raw)
  To: help-gnu-emacs

BTW, I've just pushed a new `minibuffer-line' package to elpa.git which
provides a new `minibuffer-line-mode' controlled by
`minibuffer-line-format'.  It defaults to displaying the hostname, date,
and time.


        Stefan




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

* Re: Minibuffer tray to display current time and date
  2015-04-27  0:36                             ` Stefan Monnier
@ 2015-04-28 17:27                               ` Alexander Shukaev
  2015-04-28 17:30                                 ` Eli Zaretskii
  2015-04-29  0:53                                 ` Stefan Monnier
       [not found]                               ` <mailman.1824.1430242034.904.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 37+ messages in thread
From: Alexander Shukaev @ 2015-04-28 17:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

​Sweet, Stefan.  Thanks a lot.  I've just installed it, and even though
it's that simple, yet does the job.

One feature I thought about is justifying it to the right.  This function
should do the job:

(defun minibuffer-line-right-justified
    (string)
  (format (format "%d %%s" (- (window-width (minibuffer-window)) (length
string))) string))


and then:

(setq-default minibuffer-line-format
              '((:eval (minibuffer-line-right-justified
                        (format-time-string "%R %F")))))


The problem occurs when Emacs frame is resized, for example.  So probably
`minibuffer-line--update' would have to be installed as a hook or
post--advice to resizing routines.  Unfortunately, I'm not sure how to do
that correctly.  What do you think?

Also, it would be nice to have an ability to highlight only certain parts
of this minibuffer line.  For instance, I've tried:

(setq-default minibuffer-line-format
             '((:eval (propertize (format-time-string "%R")
                                   'font-lock-face
                                   'minibuffer-line-time))
               " "
                (:eval (format-time-string "%F"))))


Where `minibuffer-line-time' was my custom face, but it did not work.  I
assume that this is due to the `(format-mode-line minibuffer-line-format
'minibuffer-line)' call.

Lastly,

(defgroup minibuffer-line ()
  "Use the idle minibuffer window to display status information."
  :group 'mode-line)


what about a new separate group `minibuffer-line'?

Kind regards,
Alexander


On Mon, Apr 27, 2015 at 2:36 AM, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> BTW, I've just pushed a new `minibuffer-line' package to elpa.git which
> provides a new `minibuffer-line-mode' controlled by
> `minibuffer-line-format'.  It defaults to displaying the hostname, date,
> and time.
>
>
>         Stefan
>
>
>


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

* Re: Minibuffer tray to display current time and date
  2015-04-28 17:27                               ` Alexander Shukaev
@ 2015-04-28 17:30                                 ` Eli Zaretskii
  2015-04-28 17:32                                   ` Alexander Shukaev
  2015-04-29  0:53                                 ` Stefan Monnier
  1 sibling, 1 reply; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-28 17:30 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 28 Apr 2015 19:27:05 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> One feature I thought about is justifying it to the right.  This function
> should do the job:
> 
> (defun minibuffer-line-right-justified
>     (string)
>   (format (format "%d %%s" (- (window-width (minibuffer-window)) (length
> string))) string))

Why not use :align-to instead?



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

* Re: Minibuffer tray to display current time and date
  2015-04-28 17:30                                 ` Eli Zaretskii
@ 2015-04-28 17:32                                   ` Alexander Shukaev
  2015-04-28 17:55                                     ` Eli Zaretskii
  0 siblings, 1 reply; 37+ messages in thread
From: Alexander Shukaev @ 2015-04-28 17:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

​Interesting, Eli, could you elaborate?​

On Tue, Apr 28, 2015 at 7:30 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Tue, 28 Apr 2015 19:27:05 +0200
> > From: Alexander Shukaev <haroogan@gmail.com>
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > One feature I thought about is justifying it to the right.  This function
> > should do the job:
> >
> > (defun minibuffer-line-right-justified
> >     (string)
> >   (format (format "%d %%s" (- (window-width (minibuffer-window)) (length
> > string))) string))
>
> Why not use :align-to instead?
>
>


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

* Re: Minibuffer tray to display current time and date
  2015-04-28 17:32                                   ` Alexander Shukaev
@ 2015-04-28 17:55                                     ` Eli Zaretskii
  0 siblings, 0 replies; 37+ messages in thread
From: Eli Zaretskii @ 2015-04-28 17:55 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 28 Apr 2015 19:32:16 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> 
> ​Interesting, Eli, could you elaborate?​

It's a display property.  You can read about that in the ELisp manual,
in the node called Specified Space.




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

* Re: Minibuffer tray to display current time and date
       [not found]                               ` <mailman.1824.1430242034.904.help-gnu-emacs@gnu.org>
@ 2015-04-28 17:58                                 ` Emanuel Berg
  2015-04-29  0:55                                   ` Stefan Monnier
  0 siblings, 1 reply; 37+ messages in thread
From: Emanuel Berg @ 2015-04-28 17:58 UTC (permalink / raw)
  To: help-gnu-emacs

Alexander Shukaev <haroogan@gmail.com> writes:

> Sweet, Stefan. ... even though it's that simple, yet
> does the job.

You mean BECAUSE it is that simple :)

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-04-28 17:27                               ` Alexander Shukaev
  2015-04-28 17:30                                 ` Eli Zaretskii
@ 2015-04-29  0:53                                 ` Stefan Monnier
  1 sibling, 0 replies; 37+ messages in thread
From: Stefan Monnier @ 2015-04-29  0:53 UTC (permalink / raw)
  To: help-gnu-emacs

> (setq-default minibuffer-line-format
>              '((:eval (propertize (format-time-string "%R")
>                                    'font-lock-face
>                                    'minibuffer-line-time))
>                " "
>                 (:eval (format-time-string "%F"))))

You want to use `face' rather than `font-lock-face', because
font-lock-mode is not enabled in " *Minibuf-0*".

> (defgroup minibuffer-line ()
>   "Use the idle minibuffer window to display status information."
>   :group 'mode-line)

> what about a new separate group `minibuffer-line'?

I don't understand: the above quoted code defines a new separate group
`minibuffer-line', so what is it you're asking?


        Stefan




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

* Re: Minibuffer tray to display current time and date
  2015-04-28 17:58                                 ` Emanuel Berg
@ 2015-04-29  0:55                                   ` Stefan Monnier
  2015-05-01  4:49                                     ` Alexander Shukaev
  0 siblings, 1 reply; 37+ messages in thread
From: Stefan Monnier @ 2015-04-29  0:55 UTC (permalink / raw)
  To: help-gnu-emacs

>> Sweet, Stefan. ... even though it's that simple, yet
>> does the job.
> You mean BECAUSE it is that simple :)

FWIW, in my setup (i.e. with a separate minibuffer-only frame), the
minibuffer-line is not always displayed when it should.
There's probably some code somewhere in the C code of Emacs which just
clears the minibuffer instead of actually displaying the contents of
*Minibuf-0* as it should.


        Stefan




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

* Re: Minibuffer tray to display current time and date
  2015-04-29  0:55                                   ` Stefan Monnier
@ 2015-05-01  4:49                                     ` Alexander Shukaev
  2015-05-01  4:54                                       ` Alexander Shukaev
  2015-05-06 12:49                                       ` Stefan Monnier
  0 siblings, 2 replies; 37+ messages in thread
From: Alexander Shukaev @ 2015-05-01  4:49 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: help-gnu-emacs

I came up with the following code to right-justify:

​  (setq-default minibuffer-line-format
                `((:eval
                   (let ((string (concat
                                  (propertize (format-time-string
"%Y.%m.%d")
                                              'face
                                              'minibuffer-line-date)
                                  " "
                                  (propertize (format-time-string "%A")
                                              'face
                                              'minibuffer-line-weekday)
                                  " "
                                  (propertize (format-time-string "%R")
                                              'face
                                              'minibuffer-line-time))))
                     (concat (propertize " "
                                         'display
                                         `((space :align-to
                                                  (- right
                                                     (length ,string)))))
                             string)))))
​
But it does not do what it should do.  Faces are not propagated and
alignment too.  What's wrong with this code?


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

* Re: Minibuffer tray to display current time and date
  2015-05-01  4:49                                     ` Alexander Shukaev
@ 2015-05-01  4:54                                       ` Alexander Shukaev
  2015-05-06 10:31                                         ` Alexander Shukaev
  2015-05-06 12:49                                       ` Stefan Monnier
  1 sibling, 1 reply; 37+ messages in thread
From: Alexander Shukaev @ 2015-05-01  4:54 UTC (permalink / raw)
  To: Stefan Monnier, Eli Zaretskii; +Cc: help-gnu-emacs

The only stanza that works properly so far is this simple one:

  (setq-default minibuffer-line-format
                '((:eval (propertize (format-time-string "%Y.%m.%d")
                                     'face
                                     'minibuffer-line-date))
                  " "
                  (:eval (propertize (format-time-string "%A")
                                     'face
                                     'minibuffer-line-weekday))
                  " "
                  (:eval (propertize (format-time-string "%R")
                                     'face
                                     'minibuffer-line-time))))

So how do I actually right justify that now?

On Fri, May 1, 2015 at 6:49 AM, Alexander Shukaev <haroogan@gmail.com>
wrote:

> I came up with the following code to right-justify:
>
> ​  (setq-default minibuffer-line-format
>                 `((:eval
>                    (let ((string (concat
>                                   (propertize (format-time-string
> "%Y.%m.%d")
>                                               'face
>                                               'minibuffer-line-date)
>                                   " "
>                                   (propertize (format-time-string "%A")
>                                               'face
>                                               'minibuffer-line-weekday)
>                                   " "
>                                   (propertize (format-time-string "%R")
>                                               'face
>                                               'minibuffer-line-time))))
>                      (concat (propertize " "
>                                          'display
>                                          `((space :align-to
>                                                   (- right
>                                                      (length ,string)))))
>                              string)))))
> ​
> But it does not do what it should do.  Faces are not propagated and
> alignment too.  What's wrong with this code?
>


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

* Re: Minibuffer tray to display current time and date
  2015-05-01  4:54                                       ` Alexander Shukaev
@ 2015-05-06 10:31                                         ` Alexander Shukaev
  0 siblings, 0 replies; 37+ messages in thread
From: Alexander Shukaev @ 2015-05-06 10:31 UTC (permalink / raw)
  To: help-gnu-emacs

I don't like bumping personally, but maybe somebody else (except Eli and
Stefan) knows the answer?  Thanks in advance.

Regards,
Alexander


On Fri, May 1, 2015 at 6:54 AM, Alexander Shukaev <haroogan@gmail.com>
wrote:

> The only stanza that works properly so far is this simple one:
>
>   (setq-default minibuffer-line-format
>                 '((:eval (propertize (format-time-string "%Y.%m.%d")
>                                      'face
>                                      'minibuffer-line-date))
>                   " "
>                   (:eval (propertize (format-time-string "%A")
>                                      'face
>                                      'minibuffer-line-weekday))
>                   " "
>                   (:eval (propertize (format-time-string "%R")
>                                      'face
>                                      'minibuffer-line-time))))
>
> So how do I actually right justify that now?
>
> On Fri, May 1, 2015 at 6:49 AM, Alexander Shukaev <haroogan@gmail.com>
> wrote:
>
>> I came up with the following code to right-justify:
>>
>> ​  (setq-default minibuffer-line-format
>>                 `((:eval
>>                    (let ((string (concat
>>                                   (propertize (format-time-string
>> "%Y.%m.%d")
>>                                               'face
>>                                               'minibuffer-line-date)
>>                                   " "
>>                                   (propertize (format-time-string "%A")
>>                                               'face
>>                                               'minibuffer-line-weekday)
>>                                   " "
>>                                   (propertize (format-time-string "%R")
>>                                               'face
>>                                               'minibuffer-line-time))))
>>                      (concat (propertize " "
>>                                          'display
>>                                          `((space :align-to
>>                                                   (- right
>>                                                      (length ,string)))))
>>                              string)))))
>> ​
>> But it does not do what it should do.  Faces are not propagated and
>> alignment too.  What's wrong with this code?
>>
>
>


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

* Re: Minibuffer tray to display current time and date
  2015-05-01  4:49                                     ` Alexander Shukaev
  2015-05-01  4:54                                       ` Alexander Shukaev
@ 2015-05-06 12:49                                       ` Stefan Monnier
  2015-05-12 11:34                                         ` Alexander Shukaev
       [not found]                                         ` <mailman.2858.1431430470.904.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 37+ messages in thread
From: Stefan Monnier @ 2015-05-06 12:49 UTC (permalink / raw)
  To: help-gnu-emacs

>                                          `((space :align-to
>                                                   (- right
>                                                      (length ,string)))))

If you look at the documentation for the display property, and more
specifically for the `space' specifications, you'll see that the HPOS
element can be of the form:

       EXPR ::= NUM | (NUM) | UNIT | ELEM | POS | IMAGE | FORM
       NUM  ::= INTEGER | FLOAT | SYMBOL
       UNIT ::= in | mm | cm | width | height
       ELEM ::= left-fringe | right-fringe | left-margin | right-margin
             |  scroll-bar | text
       POS  ::= left | center | right
       FORM ::= (NUM . EXPR) | (OP EXPR ...)
       OP   ::= + | -

So, as you can see, there is no "(length EXP)" form in there.So you need
to use

   ,(length string)

instead of

   (length ,string)


-- Stefan




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

* Re: Minibuffer tray to display current time and date
  2015-05-06 12:49                                       ` Stefan Monnier
@ 2015-05-12 11:34                                         ` Alexander Shukaev
  2015-05-14 19:44                                           ` Stefan Monnier
       [not found]                                         ` <mailman.2858.1431430470.904.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 37+ messages in thread
From: Alexander Shukaev @ 2015-05-12 11:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

On Wed, May 6, 2015 at 2:49 PM, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >                                          `((space :align-to
> >                                                   (- right
> >                                                      (length ,string)))))
>
> If you look at the documentation for the display property, and more
> specifically for the `space' specifications, you'll see that the HPOS
> element can be of the form:
>
>        EXPR ::= NUM | (NUM) | UNIT | ELEM | POS | IMAGE | FORM
>        NUM  ::= INTEGER | FLOAT | SYMBOL
>        UNIT ::= in | mm | cm | width | height
>        ELEM ::= left-fringe | right-fringe | left-margin | right-margin
>              |  scroll-bar | text
>        POS  ::= left | center | right
>        FORM ::= (NUM . EXPR) | (OP EXPR ...)
>        OP   ::= + | -
>
> So, as you can see, there is no "(length EXP)" form in there.So you need
> to use
>
>    ,(length string)
>
> instead of
>
>    (length ,string)
>
>
> -- Stefan
>

​
Thanks for this remark, Stefan.  I've modified the code and it looks
​now ​
as follows:

  (setq-default minibuffer-line-format
                `((:eval
                   (let ((string (concat
                                  (propertize (format-time-string
"%Y.%m.%d")
                                              'face
                                              'minibuffer-line-date)
                                  " "
                                  (propertize (format-time-string "%A")
                                              'face
                                              'minibuffer-line-weekday)
                                  " "
                                  (propertize (format-time-string "%R")
                                              'face
                                              'minibuffer-line-time))))
                     (concat (propertize " "
                                         'display
                                         `((space :align-to
                                                  (- right
                                                     right-fringe
                                                     ,(length string)))))
                             string)))))

It is aligned correctly now, but the faces are still not propagated, or
rather only the first one is (the default one from `display' alignment).  I
feel like I don't understand something fundamental about `eval:' or maybe
there is a bug here?  I'd be grateful if you could explain this problem.
Thank you.

Regards,
Alexander


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

* Re: Minibuffer tray to display current time and date
       [not found]                                         ` <mailman.2858.1431430470.904.help-gnu-emacs@gnu.org>
@ 2015-05-12 17:24                                           ` Emanuel Berg
  0 siblings, 0 replies; 37+ messages in thread
From: Emanuel Berg @ 2015-05-12 17:24 UTC (permalink / raw)
  To: help-gnu-emacs

Alexander Shukaev <haroogan@gmail.com> writes:

>   (setq-default minibuffer-line-format
>                 `((:eval
>                    (let ((string (concat
>                                   (propertize (format-time-string
> "%Y.%m.%d")
>                                               'face
>                                               'minibuffer-line-date)
>                                   " "
>                                   (propertize (format-time-string "%A")
>                                               'face
>                                               'minibuffer-line-weekday)
>                                   " "
>                                   (propertize (format-time-string "%R")
>                                               'face
>                                               'minibuffer-line-time))))
>                      (concat (propertize " "
>                                          'display
>                                          `((space :align-to
>                                                   (- right
>                                                      right-fringe
>                                                      ,(length string)))))
>                              string)))))
>
> It is aligned correctly now, but the faces are still
> not propagated, or rather only the first one is (the
> default one from `display' alignment). I feel like
> I don't understand something fundamental about
> `eval:' or maybe there is a bug here? I'd be
> grateful if you could explain this problem.
> Thank you.

Try 'font-lock-face instead of 'face:

    (insert
       (propertize "Type'd up" 'font-lock-face 'font-lock-type-face))

As for :eval that doesn't do anything. It is just
a marker that says this should be evaluated (each
time) but this has to be implemented in each case (or
"somewhere else" if this is a convention - its in
`mode-line-format' as well).

The reason you can't do it with a backtick and commas
is if so that would evaluate only once (when you
`setq' the variable) but as time (sadly) flies, you
want it to be set each time and this has to be
implemented, and :eval is one way to do so.

-- 
underground experts united
http://user.it.uu.se/~embe8573


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

* Re: Minibuffer tray to display current time and date
  2015-05-12 11:34                                         ` Alexander Shukaev
@ 2015-05-14 19:44                                           ` Stefan Monnier
  2015-06-25 19:18                                             ` Alexander Shukaev
  0 siblings, 1 reply; 37+ messages in thread
From: Stefan Monnier @ 2015-05-14 19:44 UTC (permalink / raw)
  To: help-gnu-emacs

> It is aligned correctly now, but the faces are still not propagated, or
> rather only the first one is (the default one from `display' alignment).  I

I think this is simply a bug in the redisplay code.  Please report it
with M-x report-emacs-bug.


        Stefan




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

* Re: Minibuffer tray to display current time and date
  2015-05-14 19:44                                           ` Stefan Monnier
@ 2015-06-25 19:18                                             ` Alexander Shukaev
  0 siblings, 0 replies; 37+ messages in thread
From: Alexander Shukaev @ 2015-06-25 19:18 UTC (permalink / raw)
  To: help-gnu-emacs

I've finally managed to tailor a solution that finally works as expected
(and without code duplication):

  (setq-default minibuffer-line-format
                '((:eval
                   (let* ((date-string
                           (propertize (format-time-string "%Y.%m.%d")
                                       'face
                                       'minibuffer-line-date))
                          (weekday-string
                           (propertize (format-time-string "%A")
                                       'face
                                       'minibuffer-line-weekday))
                          (time-string
                           (propertize (format-time-string "%R")
                                       'face
                                       'minibuffer-line-time))
                          (right-string-list
                           (list date-string
                                 " "
                                 weekday-string
                                 " "
                                 time-string))
                          (right-string
                           (apply #'concat right-string-list))
                          (pad-string
                           (propertize " "
                                       'display
                                       `((space :align-to
                                                (- right
                                                   right-fringe
                                                   ,(length
right-string)))))))
                     (list pad-string
                           right-string-list)))))


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

end of thread, other threads:[~2015-06-25 19:18 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 16:07 Minibuffer tray to display current time and date Alexander Shukaev
2015-04-22 16:11 ` Eli Zaretskii
2015-04-22 16:17   ` Alexander Shukaev
2015-04-22 16:57     ` Michael Heerdegen
2015-04-22 17:05 ` Stefan Monnier
     [not found] ` <mailman.1379.1429722347.904.help-gnu-emacs@gnu.org>
2015-04-23  0:59   ` Emanuel Berg
2015-04-23 15:15     ` Jorge A. Alfaro-Murillo
     [not found]     ` <mailman.1461.1429802140.904.help-gnu-emacs@gnu.org>
2015-04-23 15:43       ` Emanuel Berg
2015-04-23 18:11         ` Jorge A. Alfaro-Murillo
     [not found]         ` <mailman.1474.1429812715.904.help-gnu-emacs@gnu.org>
2015-04-23 22:46           ` Emanuel Berg
2015-04-24 14:13             ` tomas
2015-04-24 14:41               ` Eli Zaretskii
2015-04-24 14:57                 ` Jorge A. Alfaro-Murillo
2015-04-24 16:48                   ` Eli Zaretskii
2015-04-24 20:18                     ` Jorge A. Alfaro-Murillo
     [not found]                     ` <mailman.1562.1429906736.904.help-gnu-emacs@gnu.org>
2015-04-25  1:11                       ` Dan Espen
2015-04-26  2:38                         ` Jorge A. Alfaro-Murillo
2015-04-26 14:48                           ` Eli Zaretskii
2015-04-26 15:52                             ` tomas
2015-04-26 16:05                               ` Eli Zaretskii
2015-04-27  0:36                             ` Stefan Monnier
2015-04-28 17:27                               ` Alexander Shukaev
2015-04-28 17:30                                 ` Eli Zaretskii
2015-04-28 17:32                                   ` Alexander Shukaev
2015-04-28 17:55                                     ` Eli Zaretskii
2015-04-29  0:53                                 ` Stefan Monnier
     [not found]                               ` <mailman.1824.1430242034.904.help-gnu-emacs@gnu.org>
2015-04-28 17:58                                 ` Emanuel Berg
2015-04-29  0:55                                   ` Stefan Monnier
2015-05-01  4:49                                     ` Alexander Shukaev
2015-05-01  4:54                                       ` Alexander Shukaev
2015-05-06 10:31                                         ` Alexander Shukaev
2015-05-06 12:49                                       ` Stefan Monnier
2015-05-12 11:34                                         ` Alexander Shukaev
2015-05-14 19:44                                           ` Stefan Monnier
2015-06-25 19:18                                             ` Alexander Shukaev
     [not found]                                         ` <mailman.2858.1431430470.904.help-gnu-emacs@gnu.org>
2015-05-12 17:24                                           ` Emanuel Berg
     [not found]                 ` <mailman.1537.1429888188.904.help-gnu-emacs@gnu.org>
2015-04-25  1:16                   ` Emanuel Berg

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