From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Gnus using lexical-binding Date: Mon, 08 Feb 2021 19:10:48 -0500 Message-ID: References: <87sg6iea57.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35058"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 09 01:12:31 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9Gdq-00092P-Q9 for ged-emacs-devel@m.gmane-mx.org; Tue, 09 Feb 2021 01:12:30 +0100 Original-Received: from localhost ([::1]:55644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9Gdp-0008TW-RC for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Feb 2021 19:12:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9GcJ-0006iL-5f for emacs-devel@gnu.org; Mon, 08 Feb 2021 19:10:56 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9GcG-0007wJ-Ai for emacs-devel@gnu.org; Mon, 08 Feb 2021 19:10:54 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 13A971002F2; Mon, 8 Feb 2021 19:10:51 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 75E63100040; Mon, 8 Feb 2021 19:10:49 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612829449; bh=ErYKvm8lAabeuv0kiLlDolkrUzYMILpRZb9CjEwqFPs=; h=From:To:Subject:References:Date:In-Reply-To:From; b=OgPRJHZS9hqm/zKvphVVTtrZNqPy5+lgalOHeugTv+1miLAqWY9Zw+B/sHA7C8xlL xd/4pXLNiw5SN/9QKi61ENcMpousfdhK35dlgYx1tcYM2cgx2CFXvnKTsk/V/qTS49 PRhEIPmCWxkZ0hOCdleeSc6NBAb6gAkIA+GJEot6GGmb0xaaPEgzdlnIn2nHId2h7l SxXxj227fMQN18IEbTffptGike3xUAGg97icVakpToqAyx+AZV0VlYGlr2vlCFKRPJ Y9zE7Qr82/5Q663+8wiXXIe5GEFH+D1CsIaOkzogFUR2A2uosTWbkjot0Kvu8I/dCn 1X04t6sSZc7PQ== Original-Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 22661120278; Mon, 8 Feb 2021 19:10:49 -0500 (EST) In-Reply-To: (Ted Zlatanov's message of "Mon, 08 Feb 2021 19:10:53 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:264195 Archived-At: > Debugger entered--Lisp error: (void-variable total-number-of-articles) > (= 0 total-number-of-articles) > (if (= 0 total-number-of-articles) 'font-lock-comment-face 'font-lock-function-name-face) > (let* ((topic-face (if (= 0 total-number-of-articles) 'font-lock-comment-face 'font-lock-function-name-face)) (h (tzz-frame-font-size))) (propertize (format "%s %s" name (if (and tzz-ungradients (image-type-available-p 'svg)) (tzz-image-from-svg-string (+ 4 h) h total-number-of-articles nil) (tzz-summarize-number total-number-of-articles))) 'face topic-face)) > gnus-user-format-function-topic-line(nil) > (format "%s[ %s ] %s\n" indentation (gnus-user-format-function-topic-line gnus-tmp-header) visible) > (insert (format "%s[ %s ] %s\n" indentation (gnus-user-format-function-topic-line gnus-tmp-header) visible)) > eval((insert (format "%s[ %s ] %s\n" indentation > (gnus-user-format-function-topic-line gnus-tmp-header) visible)) > ((indentation . " ") (visible . "") (name . "comics") (level . 2) > (number-of-groups . 1) (total-number-of-articles . 1) (entries (1 That sucks! > The confusing thing here is that the eval lexical environment > is correct. It's correct but it's lexical, so those vars can't be seen from functions called from `gnus-topic-line-format-spec`. I installed the patch below which should sadly fix it, Stefan Summary: * lisp/gnus/gnus-topic.el: Fix a backward incompatibility (gnus-topic-insert-topic-line): Make the vars used in `gnus-topic-line-format-spec` dynamically scoped since it seems that they're sometimes accessed from functions called by `gnus-topic-line-format-spec` :-( * lisp/gnus/gnus-util.el (gnus--\,@): Move macro to here... * lisp/gnus/gnus-art.el (gnus--\,@): .. from here. * lisp/gnus/gnus.el (gnus-method-to-server): Apply DeMorgan. diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 7ded9e40e9..c9afa3ac94 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -4325,10 +4325,6 @@ article-verify-cancel-lock (if (gnus-buffer-live-p gnus-original-article-buffer) (canlock-verify gnus-original-article-buffer))) -(defmacro gnus--\,@ (exp) - (declare (debug t)) - `(progn ,@(eval exp t))) - (gnus--\,@ (mapcar (lambda (func) `(defun ,(intern (format "gnus-%s" func)) diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el index e7d1cf8616..3253b7853d 100644 --- a/lisp/gnus/gnus-topic.el +++ b/lisp/gnus/gnus-topic.el @@ -627,7 +627,14 @@ gnus-tmp-header (defun gnus-topic-insert-topic-line (name visiblep shownp level entries &optional unread) + (gnus--\,@ + (let ((vars '(indentation visible name level number-of-groups + total-number-of-articles entries))) + `((with-suppressed-warnings ((lexical ,@vars)) + ,@(mapcar (lambda (s) `(defvar ,s)) vars))))) (let* ((visible (if visiblep "" "...")) + (level level) + (name name) (indentation (make-string (* gnus-topic-indent-level level) ? )) (total-number-of-articles unread) (number-of-groups (length entries)) @@ -640,14 +647,7 @@ gnus-topic-insert-topic-line (add-text-properties (point) (prog1 (1+ (point)) - (eval gnus-topic-line-format-spec - `((indentation . ,indentation) - (visible . ,visible) - (name . ,name) - (level . ,level) - (number-of-groups . ,number-of-groups) - (total-number-of-articles . ,total-number-of-articles) - (entries . ,entries)))) + (eval gnus-topic-line-format-spec t)) (list 'gnus-topic name 'gnus-topic-level level 'gnus-topic-unread unread diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index 3c7c948c2b..f80243cfed 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el @@ -1068,6 +1068,11 @@ gnus-run-mode-hooks ;;; Various +(defmacro gnus--\,@ (exp) + "Splice EXP's value (a list of Lisp forms) into the code." + (declare (debug t)) + `(progn ,@(eval exp t))) + (defvar gnus-group-buffer) ; Compiler directive (defun gnus-alive-p () "Say whether Gnus is running or not." diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 98664ac2b4..7b94c64ae7 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -3212,9 +3212,9 @@ gnus-method-to-server (format "%s" (car method)) (format "%s:%s" (car method) (cadr method)))) (name-method (cons name method))) - (when (and (not no-enter-cache) - (not (member name-method gnus-server-method-cache)) - (not (assoc (car name-method) gnus-server-method-cache))) + (unless (or no-enter-cache + (member name-method gnus-server-method-cache) + (assoc (car name-method) gnus-server-method-cache)) (push name-method gnus-server-method-cache)) name)))