milkypostman / powerline

emacs powerline

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get loop list warning when doing native compilation

rayw000 opened this issue · comments

commented

I'm trying to native compile powerline.el on Emacs 28.0.50, this warning

/path/to/elpa/powerline-20210313.1621/powerline.el: Error: List contains a loop ("22", . #0)

makes powerline failed to compile.

Currently I add regexp powerline into comp-deferred-compilation-deny-list to walk around this issue.

(setq comp-deferred-compilation-deny-list '("powerline"))

any idea what's causing this? I've not got the time to maintain this package right now but there are others lurking that will hopefully help out.

commented

any idea what's causing this? I've not got the time to maintain this package right now but there are others lurking that will hopefully help out.

I'd like to take a look when I have time. 😃

commented

I found that some of the pl/* functions in pl/memoize called with different arguments may complain about the "loop list", such as (pl/bar right) and (pl/brace left), but not all.

powerline/powerline.el

Lines 218 to 257 in cfff1cf

(defun powerline-reset ()
"Reset memoized functions."
(interactive)
(pl/memoize (pl/alternate left))
(pl/memoize (pl/alternate right))
(pl/memoize (pl/arrow left))
(pl/memoize (pl/arrow right))
(pl/memoize (pl/arrow-fade left))
(pl/memoize (pl/arrow-fade right))
(pl/memoize (pl/bar left))
(pl/memoize (pl/bar right))
(pl/memoize (pl/box left))
(pl/memoize (pl/box right))
(pl/memoize (pl/brace left))
(pl/memoize (pl/brace right))
(pl/memoize (pl/butt left))
(pl/memoize (pl/butt right))
(pl/memoize (pl/chamfer left))
(pl/memoize (pl/chamfer right))
(pl/memoize (pl/contour left))
(pl/memoize (pl/contour right))
(pl/memoize (pl/curve left))
(pl/memoize (pl/curve right))
(pl/memoize (pl/rounded left))
(pl/memoize (pl/rounded right))
(pl/memoize (pl/roundstub left))
(pl/memoize (pl/roundstub right))
(pl/memoize (pl/slant left))
(pl/memoize (pl/slant right))
(pl/memoize (pl/wave left))
(pl/memoize (pl/wave right))
(pl/memoize (pl/zigzag left))
(pl/memoize (pl/zigzag right))
(pl/memoize (pl/nil left))
(pl/memoize (pl/nil right))
(pl/utf-8 left)
(pl/utf-8 right)
(pl/reset-cache))
(powerline-reset)

Seems that these functions are all invoking pl/pattern-defun. I'll do some further job when I have time.
(defun pl/pattern-defun (name dir width &rest patterns)
"Create a powerline function of NAME in DIR with WIDTH for PATTERNS.
PATTERNS is of the form (PATTERN HEADER FOOTER SECOND-PATTERN CENTER
PATTERN-2X HEADER-2X FOOTER-2X SECOND-PATTERN-2X CENTER-2X).
PATTERN is required, all other components are optional.
The first 5 components are for the standard resolution image.
The remaining ones are for the high resolution image where both
width and height are doubled. If PATTERN-2X is nil or not given,
then the remaining components are ignored and the standard
resolution image with magnification and interpolation will be
used in high resolution environments
All generated functions generate the form:
HEADER
PATTERN ...
CENTER
SECOND-PATTERN ...
FOOTER
PATTERN and SECOND-PATTERN repeat infinitely to fill the space needed to generate a full height XPM.
PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the form ((COLOR ...) (COLOR ...) ...).
COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is the
destination color, and 2 is the interpolated color between 0 and 1."
(when (eq dir 'right)
(setq patterns (mapcar 'pl/reverse-pattern patterns)))
(let ((bindings-body (pl/pattern-bindings-body patterns
'height
'pattern-height
'second-pattern-height))
(bindings-body-2x (pl/pattern-bindings-body (nthcdr 5 patterns)
'(* height 2)
'pattern-height-2x
'second-pattern-height-2x)))
(pl/wrap-defun name dir width
(append (car bindings-body) (car bindings-body-2x))
(cdr bindings-body) (cdr bindings-body-2x))))

@rayw000 This appears to be the culprit

(setcdr (last pattern) pattern))))

It looks intentional though. It's a warning, I'm not sure if it's worth getting rid of?

I'll leave it up to the people involved in this bug to send a PR if they feel it necessary to remove.

It's an error, it's preventing the gcc jit from compiling powerline, if any package needs a speed boost, powerline is definitely it as it's one of the major bottlenecks during scrolling.

oh my bad. well I am not really maintaining this anymore. if there are a lot of people upset I guess I'd come out of retirement but prefer a patch. just being honest about my time.

I'd send you a PR if I understand what this code is doing, but I don't, and have no idea how to provide equivalent functionality without a circular list.

Relevant code:

(let* ((pattern (pl/pattern (mapcar 'pl/pattern-to-string (car patterns))))
(header (mapcar 'pl/pattern-to-string (nth 1 patterns)))
(footer (mapcar 'pl/pattern-to-string (nth 2 patterns)))
(second-pattern (pl/pattern (mapcar 'pl/pattern-to-string (nth 3 patterns))))
(center (mapcar 'pl/pattern-to-string (nth 4 patterns)))
(reserve (+ (length header) (length footer) (length center))))
(when pattern
(cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0))
(,second-pattern-height-sym (/ ,pattern-height-sym 2))
(,pattern-height-sym ,(if second-pattern `(ceiling ,pattern-height-sym 2) `,pattern-height-sym)))
(list (when header `(mapconcat 'identity ',header ""))
`(mapconcat 'identity
(cl-subseq ',pattern 0 ,pattern-height-sym) "")
(when center `(mapconcat 'identity ',center ""))
(when second-pattern
`(mapconcat 'identity
(cl-subseq ',second-pattern
0 ,second-pattern-height-sym) ""))
(when footer `(mapconcat 'identity ',footer "")))))))

The idea is that patterns have up to 5 lines,

  • pattern
  • header
  • footer
  • second pattern
  • center

this allows one to generate glyphs in the powerline using pixels like,

header pixels
pattern pixels
pattern pixels
pattern pixels
pattern pixels
center pixels
second pattern pixels
second pattern pixels
second pattern pixels
second pattern pixels
footer pixels

This, even though pattern pixels only needs to specified once, it may need to be printed multiple times. The "hack" in the code I linked makes it so the list is infinite so it can keep getting printed pattern-height-sym times using cl-subseq.

So the fix is to either put a loop in there, or generate the list after you already know pattern-height-sym.

I'm happy to keep helping with this and review the code but it's the testing I don't really have time for.