From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: If clause depending on name of the day Date: Tue, 3 Apr 2012 12:57:34 -0700 Message-ID: <3A406D54F6394D3D8A88F0E3017F6DD6@us.oracle.com> References: <87d37ovd60.fsf@gmx.ch> <87limc6289.fsf@kvarnholmen.matholka.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1333483074 22857 80.91.229.3 (3 Apr 2012 19:57:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 3 Apr 2012 19:57:54 +0000 (UTC) To: "'Lars Ljung'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 03 21:57:53 2012 Return-path: Envelope-to: geh-help-gnu-emacs@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 1SF9rU-0003u3-SF for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Apr 2012 21:57:53 +0200 Original-Received: from localhost ([::1]:41664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF9rU-0003lG-2v for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Apr 2012 15:57:52 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF9rP-0003l0-7J for help-gnu-emacs@gnu.org; Tue, 03 Apr 2012 15:57:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SF9rN-0006fi-Ip for help-gnu-emacs@gnu.org; Tue, 03 Apr 2012 15:57:46 -0400 Original-Received: from acsinet15.oracle.com ([141.146.126.227]:35923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF9rN-0006fI-CQ for help-gnu-emacs@gnu.org; Tue, 03 Apr 2012 15:57:45 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q33JvdBd000366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Apr 2012 19:57:40 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q33JvdRo017615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Apr 2012 19:57:39 GMT Original-Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q33JvcBD024178; Tue, 3 Apr 2012 14:57:38 -0500 Original-Received: from dradamslap1 (/10.159.53.212) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Apr 2012 12:57:38 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87limc6289.fsf@kvarnholmen.matholka.se> Thread-Index: Ac0R0IjSW+s+zRnDQhibTvkzGwxVJQAApn2w X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090203.4F7B5634.00A3,ss=1,re=0.000,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 141.146.126.227 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84300 Archived-At: > > 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.)