bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#30852: 27.0.50; infinite loop in internal-get-lisp-face-attribute


From: Aaron Jensen
Subject: bug#30852: 27.0.50; infinite loop in internal-get-lisp-face-attribute
Date: Mon, 19 Mar 2018 07:56:10 -0700

On Sun, Mar 18, 2018 at 11:54 PM, Eli Zaretskii <address@hidden> wrote:
> Are you that saying eterm-256color causes Emacs to create a face alist
> that is a circular list?

No, the problem, which I do not fully understand, is here:

https://github.com/dieggsy/eterm-256color/blob/a43f38a7d78364c34efde10dfce0d518f9f4df62/eterm-256color.el#L126-L156

(defun eterm-256color-handle-ansi-escape (handle-fun &rest args)
  (pcase-let
      (((or ;; Parameters from Emacs 27.
         `(,proc ,params ,char)
         ;; Parameters up to Emacs 26.
         (and
          `(,proc ,char)
          (let params
            ;; Hack the dynamic vars into a list.
            (delq nil
                  (delq -1
                        (list
                         (bound-and-true-p term-terminal-previous-parameter-4)
                         (bound-and-true-p term-terminal-previous-parameter-3)
                         (bound-and-true-p term-terminal-previous-parameter-2)
                         (bound-and-true-p term-terminal-previous-parameter)
                         (bound-and-true-p term-terminal-parameter)))))))
        args))
    (if (eq char '?m)
        (while params
          (pcase params
            (`(38 5 ,color256 . ,_)
             (eterm-256color-handle-colors color256 'fg)
             (setq params (nthcdr 3 params)))
            (`(48 5 ,color256 . ,_)
             (eterm-256color-handle-colors color256 'bg)
             (setq params (nthcdr 3 params)))
            (`(,x . ,_)
             (eterm-256color-handle-colors x)
             (setq params (cdr params)))))
      (apply handle-fun args))))

Specifically, what happens is that the `(setq params ...)` are
ineffective. `params` is always bound to what it is bound to via the
pcase-let. This only happens the first time this function is run--I'm
guessing if `params` is already bound as a variable (as it would be
the second time) then the `setq` and the `let` affect the same thing.

Changing the while loop to this fixes the bug:

(setq my-params params)
(while my-params
  (pcase my-params
    (`(38 5 ,color256 . ,_)
     (eterm-256color-handle-colors color256 'fg)
     (setq my-params (nthcdr 3 my-params)))
    (`(48 5 ,color256 . ,_)
     (eterm-256color-handle-colors color256 'bg)
     (setq my-params (nthcdr 3 my-params)))
    (`(,x . ,_)
     (eterm-256color-handle-colors x)
     (setq my-params (cdr my-params)))))





reply via email to

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