From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KLaDL1cJR2CLQgAA0tVLHw (envelope-from ) for ; Tue, 09 Mar 2021 05:36:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KPcuKlcJR2CnRAAA1q6Kng (envelope-from ) for ; Tue, 09 Mar 2021 05:36:23 +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 aspmx1.migadu.com (Postfix) with ESMTPS id EBA6F11B53 for ; Tue, 9 Mar 2021 06:36:22 +0100 (CET) Received: from localhost ([::1]:60180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJV2b-000847-Lf for larch@yhetil.org; Tue, 09 Mar 2021 00:36:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJV1n-00082R-1A for emacs-orgmode@gnu.org; Tue, 09 Mar 2021 00:35:31 -0500 Received: from out1.migadu.com ([2001:41d0:2:863f::]:39370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJV1e-00057u-24 for emacs-orgmode@gnu.org; Tue, 09 Mar 2021 00:35:30 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1615268114; h=from:from: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; bh=J6Na6QnDL9DTC9HCdz5QSIbqUY0hshAEn/OV7Yrqcb8=; b=Bw9jqygnQd1mv4F06DejIgDXmU1FxivYEYbTxaItCMXuA+z8RG6ofgwPmPkvDrz6eGdZAb YRhIQ9G2tr6JDYShgLfss4VUhWGfpm59ONsomHnfHLxBDZ0vrH/iYPLwE8FzLt9/ajHs/x +AvW91VgmZtDlrciCcDG6qivQZ87YsqvZNpGnUUnG1Hva7IsjxuNB1XLDUpEa3/tP/yWQt b7u6em25Gb3lTOWZ+jZcdGVske1VBNBa980v8e39et6OybUQl8BSL3H0PoyhfDJfdRUAdg sHIbZ87U6wwqtfzqpRca5WXrinZlf7RlphzsKIPV0bfvBuojFJFiOuP47dfb3g== From: Kyle Meyer To: Stefan Monnier Subject: Re: Using lexical-binding In-Reply-To: References: <87a6rsg0vb.fsf@kyleam.com> <87a6rjcv5w.fsf@kyleam.com> <87r1ks9plr.fsf@kyleam.com> Date: Tue, 09 Mar 2021 00:35:06 -0500 Message-ID: <8735x4c2k5.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Auth-User: kyle@kyleam.com Received-SPF: pass client-ip=2001:41d0:2:863f::; envelope-from=kyle@kyleam.com; helo=out1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Marco Wahl , emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1615268183; 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=J6Na6QnDL9DTC9HCdz5QSIbqUY0hshAEn/OV7Yrqcb8=; b=Ir8/0kdNtIJFZfaEjpbwNc9Dw7dnfnBh5CVkTJoGYyt+cf5XOuDGOpbYVdZPBsi9Pre7N0 qtqLakvrcLmyTtp4qcBk+x9N2q8Z1B0AezHji6CjSyRjdul3/wXy0Yn8ERzC8BJ1e/vmRH 7HMwlal3M2C0o7CMO98pVUKhx1sYDT31ldBCrNKjxkBYFMEPIthz5UW+Bfa8cqf2FDVXAq fXNTHOYESSYMlbx8xcswjMGAdrUQpz9cELzu0owwkpbLv5vufoHBp+77INZItbEpfvm7Vh mgv8PLhYAECZU1alTdJs8kGRPh3FkkOlp+QNI6L6KEqXzew92jXu2Og1glSutA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615268183; a=rsa-sha256; cv=none; b=DeqvF8ygq1kuC3Ygk7TFqotTSorBqvWZRhrXKKJUF4H/kvmBirFD2yDJ3NLjxkQGpdhZbp gD+j1i0xomrulVwxHUzVIkTh7qs2N2JsoKPsxEPbNxqnbZanDGPK034g8P2DSVMjl40D1T hteak96tjSZEDmdCf/kUN+UFg5GuQSvTOI4vUq+W9zCESXgugVkwba96IUbmTzlIiDvvsG ECexYK8VKI669E9P+NZu6gz1DBrkKoLBoDR2TclFXswiH9R2OgwzIxmXlbzrUZmxHvULNW acOYbnn0fj4UhLmWgreA59BL5VwqmnopoIAi7IxYnnmNRlYULDeBOG6ffVggww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=Bw9jqygn; dmarc=none; spf=pass (aspmx1.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-Migadu-Spam-Score: -1.38 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=Bw9jqygn; dmarc=none; spf=pass (aspmx1.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-Migadu-Queue-Id: EBA6F11B53 X-Spam-Score: -1.38 X-Migadu-Scanner: scn0.migadu.com X-TUID: WuOEH8PQhRfB Looking at this one more time before applying, I noticed a couple of backward compatibility issues. Stefan Monnier writes: > Subject: [PATCH] * lisp/org-agenda.el: Use lexical-binding [...] > + (pcase type > + ('agenda > + (org-agenda-list current-prefix-arg)) Unfortunately Org's minimum Emacs version is still Emacs 24.3. I'd like to drop Emacs 24 support soon, but that hasn't been discussed or announced. And... > + (let* ((gprops (nth 1 series)) > + (gvars (mapcar #'car gprops)) > + (gvals (mapcar (lambda (binding) (eval (cadr binding) t)) gprops))) > + (cl-progv gvars gvals (org-agenda-prepare name)) > + ;; We need to reset agenda markers here, because when constructing a > + ;; block agenda, the individual blocks do not do that. > + (org-agenda-reset-markers) > + (with-suppressed-warnings ((lexical match)) ... I believe with-suppressed-warnings isn't available until Emacs 27.1, right? Any objections to me squashing the below changes into your patch? diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 001ca4b1b..d08cab061 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2938,30 +2938,30 @@ (defun org-agenda (&optional arg keys restriction) (mapcar #'car lprops) (mapcar (lambda (binding) (eval (cadr binding) t)) lprops) (pcase type - ('agenda + (`agenda (org-agenda-list current-prefix-arg)) - ('agenda* + (`agenda* (org-agenda-list current-prefix-arg nil nil t)) - ('alltodo + (`alltodo (org-todo-list current-prefix-arg)) - ('search + (`search (org-search-view current-prefix-arg org-match nil)) - ('stuck + (`stuck (org-agenda-list-stuck-projects current-prefix-arg)) - ('tags + (`tags (org-tags-view current-prefix-arg org-match)) - ('tags-todo + (`tags-todo (org-tags-view '(4) org-match)) - ('todo + (`todo (org-todo-list org-match)) - ('tags-tree + (`tags-tree (org-check-for-org-mode) (org-match-sparse-tree current-prefix-arg org-match)) - ('todo-tree + (`todo-tree (org-check-for-org-mode) (org-occur (concat "^" org-outline-regexp "[ \t]*" (regexp-quote org-match) "\\>"))) - ('occur-tree + (`occur-tree (org-check-for-org-mode) (org-occur org-match)) ((pred functionp) @@ -3263,7 +3263,7 @@ (defun org-agenda-run-series (name series) ;; We need to reset agenda markers here, because when constructing a ;; block agenda, the individual blocks do not do that. (org-agenda-reset-markers) - (with-suppressed-warnings ((lexical match)) + (org-with-suppressed-warnings ((lexical match)) (defvar match)) ;Used via the `eval' below. (let* ((org-agenda-multi t) ;; FIXME: Redo should contain lists of (FUNS . ARGS) rather @@ -3285,21 +3285,21 @@ (defun org-agenda-run-series (name series) (lvals (mapcar (lambda (binding) (eval (cadr binding) t)) lprops))) (cl-progv (append gvars lvars) (append gvals lvals) (pcase type - ('agenda + (`agenda (call-interactively 'org-agenda-list)) - ('agenda* + (`agenda* (funcall 'org-agenda-list nil nil t)) - ('alltodo + (`alltodo (call-interactively 'org-todo-list)) - ('search + (`search (org-search-view current-prefix-arg match nil)) - ('stuck + (`stuck (call-interactively 'org-agenda-list-stuck-projects)) - ('tags + (`tags (org-tags-view current-prefix-arg match)) - ('tags-todo + (`tags-todo (org-tags-view '(4) match)) - ('todo + (`todo (org-todo-list match)) ((pred fboundp) (funcall type match)) @@ -5363,7 +5363,7 @@ (defun org-diary (&rest args) The function expects the lisp variables `entry' and `date' to be provided by the caller, because this is how the calendar works. Don't use this function from a program - use `org-agenda-get-day-entries' instead." - (with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) + (org-with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) (when (> (- (float-time) org-agenda-last-marker-time) 5) @@ -5678,7 +5678,7 @@ (defun org-agenda-get-timestamps (&optional deadlines) "Return the date stamp information for agenda display. Optional argument DEADLINES is a list of deadline items to be displayed in agenda view." - (with-suppressed-warnings ((lexical date)) (defvar date)) + (org-with-suppressed-warnings ((lexical date)) (defvar date)) (let* ((props (list 'face 'org-agenda-calendar-event 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp @@ -5821,7 +5821,7 @@ (defun org-agenda-get-timestamps (&optional deadlines) (defun org-agenda-get-sexps () "Return the sexp information for agenda display." (require 'diary-lib) - (with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) + (org-with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) (let* ((props (list 'face 'org-agenda-calendar-sexp 'mouse-face 'highlight 'help-echo @@ -5910,7 +5910,7 @@ (defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks) `holidays', then any date that is known by the Emacs calendar to be a holiday will also be skipped. If SKIP-WEEKS arguments are holiday strings, then those holidays will be skipped." - (with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) + (org-with-suppressed-warnings ((lexical date entry)) (defvar date) (defvar entry)) (let* ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1))) (date2 (calendar-absolute-from-gregorian (list m2 d2 y2))) (d (calendar-absolute-from-gregorian date)) @@ -5930,7 +5930,7 @@ (defun org-class (y1 m1 d1 y2 m2 d2 dayname &rest skip-weeks) (defalias 'org-get-closed #'org-agenda-get-progress) (defun org-agenda-get-progress () "Return the logged TODO entries for agenda display." - (with-suppressed-warnings ((lexical date)) (defvar date)) + (org-with-suppressed-warnings ((lexical date)) (defvar date)) (let* ((props (list 'mouse-face 'highlight 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp @@ -6162,7 +6162,7 @@ (defun org-agenda-get-deadlines (&optional with-hour) "Return the deadline information for agenda display. When WITH-HOUR is non-nil, only return deadlines with an hour specification like [h]h:mm." - (with-suppressed-warnings ((lexical date)) (defvar date)) + (org-with-suppressed-warnings ((lexical date)) (defvar date)) (let* ((props (list 'mouse-face 'highlight 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp @@ -6321,7 +6321,7 @@ (defun org-agenda-get-scheduled (&optional deadlines with-hour) Optional argument DEADLINES is a list of deadline items to be displayed in agenda view. When WITH-HOUR is non-nil, only return scheduled items with an hour specification like [h]h:mm." - (with-suppressed-warnings ((lexical date)) (defvar date)) + (org-with-suppressed-warnings ((lexical date)) (defvar date)) (let* ((props (list 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp 'org-complex-heading-regexp org-complex-heading-regexp @@ -6522,7 +6522,7 @@ (defun org-agenda-get-scheduled (&optional deadlines with-hour) (defun org-agenda-get-blocks () "Return the date-range information for agenda display." - (with-suppressed-warnings ((lexical date)) (defvar date)) + (org-with-suppressed-warnings ((lexical date)) (defvar date)) (let* ((props (list 'face nil 'org-not-done-regexp org-not-done-regexp 'org-todo-regexp org-todo-regexp @@ -6691,7 +6691,7 @@ (defun org-agenda-format-item (extra txt &optional level category tags dotime org-agenda-show-inherited-tags org-agenda-hide-tags-regexp)) - (with-suppressed-warnings + (org-with-suppressed-warnings ((lexical breadcrumbs category category-icon effort extra level tag time)) ;; `time', `tag', `effort' are needed for the eval of the prefix format. diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 63f0a0acb..92fdef0a0 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -629,6 +629,12 @@ (defun org-unlogged-message (&rest args) (let ((message-log-max nil)) (apply #'message args))) +(if (fboundp 'with-suppressed-warnings) ; Introduced in Emacs 27.1. + (defalias 'org-with-suppressed-warnings 'with-suppressed-warnings) + (defmacro org-with-suppressed-warnings (_warnings &rest body) + (declare (debug (sexp &optional body)) (indent 1)) + `(progn ,@body))) + (defmacro org-dlet (binders &rest body) "Like `let*' but using dynamic scoping." (declare (indent 1) (debug let)) @@ -636,7 +642,7 @@ (defmacro org-dlet (binders &rest body) (if (consp binder) (car binder) binder)) binders))) `(progn - (with-suppressed-warnings ((lexical ,@vars)) + (org-with-suppressed-warnings ((lexical ,@vars)) ,@(mapcar (lambda (var) `(defvar ,var)) vars)) (let* ,binders ,@body))))