help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: If clause depending on name of the day


From: Drew Adams
Subject: RE: If clause depending on name of the day
Date: Tue, 3 Apr 2012 12:57:34 -0700

> > Is it possible to have an if-condition that looks for the 
> > current day?  So that the then-expression does something
> > different on Tuesday than on Friday? This is not working:
> >
> > (if (string-equal 'current-time-string ".*Tue.*")
         ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
> >    (delete-other-windows)
> >  (split-window-horizontally))
> 
> (nth 6 (decode-time)) returns 0-6 for Sunday-Saturday.

Plus, to address the code originally suggested:

1. `current-time-string' is a function that returns the time string when
invoked.  To invoke it you would use: (current-time-string), not
'current-time-string.

2. You are trying to match a regexp against a literal string, but you are using
the wrong function (`string-equal') to do it.  Use `string-match-p' for matching
(or `string-match' if that's not available).  (`string-equal' does literal
comparison.)

(But Lars's answer provides a better solution than formatting a time string and
then matching it.)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]