From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id AO6KE3RIf2KGTgAAbAwnHQ (envelope-from ) for ; Sat, 14 May 2022 08:13:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id uH17EnRIf2KJVAAAG6o9tA (envelope-from ) for ; Sat, 14 May 2022 08:13:08 +0200 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 aspmx1.migadu.com (Postfix) with ESMTPS id D74DCAF92 for ; Sat, 14 May 2022 08:13:07 +0200 (CEST) Received: from localhost ([::1]:52026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1npl1X-0001N7-3I for larch@yhetil.org; Sat, 14 May 2022 02:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1npkuD-0005si-PN for emacs-orgmode@gnu.org; Sat, 14 May 2022 02:05:34 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:42722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1npkuB-0007AS-TA for emacs-orgmode@gnu.org; Sat, 14 May 2022 02:05:33 -0400 Received: by mail-pf1-x42a.google.com with SMTP id x23so9467995pff.9 for ; Fri, 13 May 2022 23:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=Z5fWvf9yAqJ6MtHB6r9M1CcS2ipdSJk9Mg+ysc/VSlI=; b=e4mwARk/tbWolEcn19ucIShk/6c4ymuDBexUEYs160brXYyGI8KCjabZPIPEqO6cVr 2FDQ89OHyKZs2oa1JqYOomhAubSFjxsWeg4imYsJfsJ8QSdMiZN07WJvq5DTCVpQ7pds kwJA7MIFmOLWd6DYBphD1NGBnHsf27Xms/MWKcSaWLyId9Q8fpv+B2QrJPeTdERyhf2u h3B740GfvdWpIlDnyC8OG5n0VzopW3BJ4Jtdm5QOzfRNVNpHqnRNDVsYsjX6MvQ8HTyz tSyPqb632L13Z2BHDicaxOdUABiIbprkPvzOPQI+nOJ+mu5vNl6Ia1ipoNtpqPGs4kjr DZww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=Z5fWvf9yAqJ6MtHB6r9M1CcS2ipdSJk9Mg+ysc/VSlI=; b=PbiTVKMIDhhAIeouHPx+U7INsSh6RRYIFU0FZF4Tt5uBxrVFupxhPKquG95vD3lJdM VhrZkM64ePA2yVyp8ncR1ylX3vXvElSNf7Rgy8d6DGwxJikT1BfhubHG6tXjjx2pxxqD lywNmWy5Howvwk4cl9l65gpEMCaSAJ6oQCN/cgHxKXkWLWROQq+6dR9xzgqSTX7qh2A1 aCYPGgzO2zl3hMVFloud8dB2TI7wXSaN0Qmke7R2ZYPprwA0+kRysxf3bKevtu7Ckrh0 siiSCIf47S3yRVqVzUZJhITODL1ooCA9B+aTxPePJpyvUt2Qgoy+c/9kB6+5fLZonvOu iZzg== X-Gm-Message-State: AOAM5302RTyBiwopambMGfz5dU4uVST9KRRUe1ME3rhaQJill2CaOlbx RPgq5YeHJpvLLRBOMaWoCNI= X-Google-Smtp-Source: ABdhPJx7kW4kee9aocGV0CgtebIsX8Rg/54Ioy0wIkMJVA2vvP5NlEZuEjwmZw1m29YQC1ggwqUVTw== X-Received: by 2002:a63:8842:0:b0:3da:f7d6:dbf5 with SMTP id l63-20020a638842000000b003daf7d6dbf5mr6944794pgd.498.1652508330369; Fri, 13 May 2022 23:05:30 -0700 (PDT) Received: from localhost (61-216-157-181.hinet-ip.hinet.net. [61.216.157.181]) by smtp.gmail.com with ESMTPSA id k205-20020a6284d6000000b0050dc76281eesm2724814pfd.200.2022.05.13.23.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 23:05:29 -0700 (PDT) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org, Paul Eggert Subject: Re: [PATCH v4] org-encode-time compatibility and convenience helper In-Reply-To: References: <7f4ea652-7d22-fb61-f873-5e92f078c9e6@gmail.com> <87mtgcmckj.fsf@localhost> <875ymwus9p.fsf@localhost> <8735hpk4ef.fsf@localhost> <2661a0c6-a6a3-6934-16fe-7c987a6a1684@gmail.com> <874k1wjjd8.fsf@localhost> Date: Sat, 14 May 2022 14:06:12 +0800 Message-ID: <87lev4bqcr.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=yantar92@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652508787; 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=Z5fWvf9yAqJ6MtHB6r9M1CcS2ipdSJk9Mg+ysc/VSlI=; b=VXUF9wqhJZwaijZHI3ARz9iaubUJGyTkdr+jraluLtk7vk31QnG1ZbSVJgO7DleXCZMnVz v2PMvHDwOnVQvM/6F5E1hbOLMT7bEeWTamVo6IhJ+HGcMuHjOkhmsTdZ+VzhxB9QQ1NJ7V igoq9BpEpzUWunlw2Zkxa+L8UPwvucekAKOlOyNfNDvmORJPf36GipCxby7w4zLjtbebzk GbdGSPElTIi8mJjl70C9I0Q40EDjJQGdViyzZqcl+mZ8cU66DhyOi+NZFFc1AnqKjUUlxK jYJl0cXWMpEB3j3Zakby9q9GL3i6xiu0goqpcYL/nNv+g10Un8BLXIXn2DqbKg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652508787; a=rsa-sha256; cv=none; b=A/3gG8Rstp16bdx/Uqr1O+KyN28MI52wTeTX9L+k686Nes1CGc0nc0U+W9tQnmH4Ak7Ex8 f6/eUW2y1zRcepDGU4jiHD4AsvaCUXcgRKFVRg0ZXYuEIsVKzA4RS91B00ojz6m7m2PNRa bhn69VMJOq8N5xHm9+q7F/i6dsYW6Qm1nMl6a1kvMhprlgprDCMn9cd6v/8NnIFKXIh7Xb HouT+weL37jtRBmc3UWAxgbFZ+Z59eijJX7dklkk7qd0XIVPvoKwl1sthFJUFNNf/u44RZ f3L7LWT7svhin0uTpk7UVlr3hBtE71tUvGDaEOSxGhwhHJncXJQ6VFq+u2Nq5A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="e4mwARk/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.53 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="e4mwARk/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D74DCAF92 X-Spam-Score: -3.53 X-Migadu-Scanner: scn1.migadu.com X-TUID: tnsKRW7t6Kh8 Max Nikulin writes: >>> I do not like repeating of `org-encode-time' but do not see another way >>> till Emacs-29 will become the lowest supported version. >> >> This is fine. AFAIK, other parts of time handling code is full of conds >> and pcases. > > I mean that before my patch there was single `encode-time' outside of > `pcase', I replace `list' by `org-encode-time' inside each pattern. I do not see it is a big deal. At least, readability of the code did not degrade, IMHO. >>>> + (org-encode-time >>>> + (apply #'list >>>> + (or (car time0) 0) >>>> + (+ (if (eq timestamp? 'minute) n 0) (nth 1 time0)) >>>> + (+ (if (eq timestamp? 'hour) n 0) (nth 2 time0)) >>>> + (+ (if (eq timestamp? 'day) n 0) (nth 3 time0)) >>>> + (+ (if (eq timestamp? 'month) n 0) (nth 4 time0)) >>>> + (+ (if (eq timestamp? 'year) n 0) (nth 5 time0)) >>>> + (nthcdr 6 time0)))) >>>> (when (and (memq timestamp? '(hour minute)) >>>> extra >>>> (string-match "-\\([012][0-9]\\):\\([0-5][0-9]\\)" extra)) > > From my point of view > > (cl-mapcar > (lambda (value part) > (if (and part (eq part timestamp?)) > (+ n value) > value)) > time0 '(second minute hour day month year nil nil nil)) > > is better than the original code, but... > > Nicolas Goaziou to emacs-orgmode. [Patch] to correctly sort the items > with emphasis marks in a list. Mon, 19 Apr 2021 18:08:17 +0200. > https://list.orgmode.org/87r1j6b6ku.fsf@nicolasgoaziou.fr > > >> I stay away from CL as much as possible, otherwise newcomers will have >> to learn two languages to start contributing, Elisp and CL (cl-loop, >> ewww). CL is still necessary however, as we cannot use `seq' yet. I think that Nicolas was mostly referring to things like cl-loop, which introduce a whole new piece of language concepts into Elisp. cl-mapcar is merely a convenience function. Just as any other Elisp function. It behaves without surprises within the general Elisp programming concepts. I do not see why we should not use it if it improves the code clarity. Best, Ihor