From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bala Ramadurai Subject: help with sexp in org-capture-template Date: Wed, 1 Apr 2020 10:40:50 +0530 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e8986d05a233b57c" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:58837) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJVeb-00053T-S0 for emacs-orgmode@gnu.org; Wed, 01 Apr 2020 01:11:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJVea-0002xt-Nx for emacs-orgmode@gnu.org; Wed, 01 Apr 2020 01:11:05 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:36617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJVea-0002vc-Iy for emacs-orgmode@gnu.org; Wed, 01 Apr 2020 01:11:04 -0400 Received: by mail-qt1-x833.google.com with SMTP id m33so20652923qtb.3 for ; Tue, 31 Mar 2020 22:11:04 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --000000000000e8986d05a233b57c Content-Type: text/plain; charset="UTF-8" Hello All, Hope everyone's safe. I am working on a org-capture-template and one of the entries is a date (30 days later) I want in European format. My solution is this: | *Due Date*: %(concat (substring (org-read-date nil nil "+30d") 8 10) "-" (substring(org-read-date nil nil "+30d") 5 7) "-" (substring(org-read-date nil nil "+30d") 0 4)) | Although this does the job, it is extremely inelegant and only reflects my poor knowledge in elisp. Can any of you please help me in making this code better? Thanks and have a safe day! Bala http://balaramadurai.net --000000000000e8986d05a233b57c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello All,
=C2=A0 H= ope everyone's safe.

I= am working on a org-capture-template and one of the entries is a date (30 = days later) I want in European format.

My solution is this:
| *Due Date*: %(con= cat (substring (org-read-date nil nil "+30d") 8 10) "-"= (substring(org-read-date nil nil "+30d") 5 7) "-" (sub= string(org-read-date nil nil "+30d") 0 4)) |

Although this does the job, it is extremely inelega= nt and only reflects my poor knowledge in elisp.

C= an any of you please help me in making this code better?

Thanks and have a safe day!
Bala
--000000000000e8986d05a233b57c-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1 with LMTPS id 8Nk/EwVCil75UwAAk0OIDg (envelope-from ) for ; Sun, 05 Apr 2020 20:39:33 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yIT8LgNCil4HMQAAB5/wlQ (envelope-from ) for ; Sun, 05 Apr 2020 20:39:31 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 09C03682E61 for ; Sun, 5 Apr 2020 20:37:09 +0000 (UTC) Received: from localhost ([::1]:51562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLC0w-0006DF-2y for larch@yhetil.org; Sun, 05 Apr 2020 16:37:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49870) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLC0T-0006D8-Ly for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 16:36:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLC0S-0004aj-O9 for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 16:36:37 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:51435) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLC0S-0004Ze-C5 for emacs-orgmode@gnu.org; Sun, 05 Apr 2020 16:36:36 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 76F944428C; Sun, 5 Apr 2020 16:36:33 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=+pRJ+B3CY1b8NT7JAV2XqquU+6I=; b=c3hE/J Q06He18kIn1joLupCVXY6uY0UOOZ3r5YCYnwEK0mkzAsONnDmzRlTfBGETNLercT qOMIcBIidkVjzoDc4wrieauPgGvwpKV17NM+Flfiuy1zfOA6JQeu6h69aLjWbnsx b0/Bqei9m0MBxG17FFiQDHMmfOeeEnxTOBzd0= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 6E2724428B; Sun, 5 Apr 2020 16:36:33 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=+R2KoHVSW76mPfIu28Npr+J0TrshSmqaZ4QLwFHAZdE=; b=hl1QAZlYlun5Com2EYBL+L4Te3IfzVndrPPr0bXiWHQQBrmxgSmZk1zxgW9EeOgL+ztxr2+7kHUU/vlGgPqWrsUqLKbnvH8JAhumzI+1iizKY0pAbNgjrbZAE8+nEqMJKBqi0XU40P04g+Z/QfoOjGIFeWx1P6N6L47AinQz2ak= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id DC0C64428A; Sun, 5 Apr 2020 16:36:32 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Bala Ramadurai Subject: Re: help with sexp in org-capture-template In-Reply-To: References: Date: Sun, 05 Apr 2020 20:36:32 +0000 Message-ID: <87pncl1xgv.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 22F34F46-777D-11EA-ACBC-C28CBED8090B-24757444!pb-smtp1.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.108.70 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=default; t=1586119030; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xKbW+evrjre5AODy/8rkzqtU/n8UxauJynrSTWbvXfk=; b=c++suDTOse/DBS6fXjTzk90hD8FSCwSogDV660SZCFWnPeacBKF20LffTfLsjSUAcBcmQd OJapUDuLDj0jZkaq9nOy/VhJAmhRPwGkjEYeOLrzCnLpNraP2nCR2opW3WTel7eDlEQOPC V1pIe+p4ZcWSu8/VBSvhrRsT6veYZEE= ARC-Seal: i=1; s=default; d=yhetil.org; t=1586119030; a=rsa-sha256; cv=none; b=H0uXBzUljoAzLsK/1gOHRGHXPJRydEYpHQN6e2HyTmHrRoGufWRDQoQXiRqw5dB2A+WQKX xKVdkz9K0xCWk7U8zubeniWQpYlV0LZ2Fknc0stCn7SARLgkyDIdmOUIDhPfTSQcbdYjvC PX4toPrCS713T6mNqkmv3T24xxXWFK4= ARC-Authentication-Results: i=1; aspmx2.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=c3hE/J Q; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=hl1QAZlY; dmarc=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scanner: scn0 X-Spam-Score: -1.21 Authentication-Results: aspmx2.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=c3hE/J Q; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=hl1QAZlY; dmarc=none; spf=pass (aspmx2.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [-1.21 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.58503748707874]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.33), country: US(-0.01), ip: 209.51.188.17(-0.59)]; ARC_SIGNED(0.00)[i=1]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[pobox.com:+,kyleam.com:+]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[kyle@kyleam.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[pobox.com:s=sasl,kyleam.com:s=mesmtp]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[kyleam.com]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: EBATNw3/trro Hi Bala, Bala Ramadurai writes: > I am working on a org-capture-template and one of the entries is a date (30 > days later) I want in European format. > > My solution is this: > | *Due Date*: %(concat (substring (org-read-date nil nil "+30d") 8 10) "-" > (substring(org-read-date nil nil "+30d") 5 7) "-" (substring(org-read-date > nil nil "+30d") 0 4)) | > > Although this does the job, it is extremely inelegant and only reflects my > poor knowledge in elisp. > > Can any of you please help me in making this code better? Does the job is the important part :) One thing you could do that'd make it a little nicer to my eyes is let-binding (org-read-date nil nil "+30d") result to avoid calling it three times. Here's another approach: (format-time-string "%d-%m-%Y" (time-add (days-to-time 30) nil))