emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gnus using lexical-binding


From: Stefan Monnier
Subject: Re: Gnus using lexical-binding
Date: Mon, 08 Feb 2021 19:10:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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)))
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]