0

I have the following code and wonder whether I can define the variable brace-stxcode in the let* part rather than I currently do (make a new let).

  (let* ( (last-ppss-pos (point))
          (ppss (syntax-ppss)) )
(while (> end (progn (skip-syntax-forward "^()" end)
                     (point) ))

  (let* ( (brace-pos (point))
          (brace-stx (syntax-after brace-pos)) )

    (setq ppss
          (parse-partial-sexp last-ppss-pos brace-pos nil nil ppss))
    (setq last-ppss-pos brace-pos)

    (forward-char)

    (let ( (brace-stxcode (car brace-stx)) )  ; <= from here to let*

      (cond
       ((conshine-ignore brace-pos ppss brace-stxcode)
           nil)

       ((= 4 (logand #xFFFF brace-stxcode))
           (conshine-colourise brace-pos (1+ (nth 0 ppss)) t))

       (t
           (let ( (matches-p
                   (eq (cdr brace-stx) (char-after (nth 1 ppss)))) )
             (conshine-colourise brace-pos (nth 0 ppss) matches-p)) ))) )))

Dilna
  • 1
  • 3
  • 11

1 Answers1

0

Yes, why not?

(let* ((last-ppss-pos (point))
       (ppss (syntax-ppss)))
  (while (> end (progn (skip-syntax-forward "^()" end) (point)))
    (let* ((brace-pos     (point))
           (brace-stx     (syntax-after brace-pos))
           (brace-stxcode (car brace-stx)))
      (setq ppss (parse-partial-sexp last-ppss-pos brace-pos nil nil ppss))
      (setq last-ppss-pos brace-pos)
      (forward-char)
      (cond ((conshine-ignore brace-pos ppss brace-stxcode)
             nil)
            ((= 4 (logand #xFFFF brace-stxcode))
             (conshine-colourise brace-pos (1+ (nth 0 ppss)) t))
            (t
             (let ((matches-p (eq (cdr brace-stx) (char-after (nth 1 ppss)))))
               (conshine-colourise brace-pos (nth 0 ppss) matches-p)))))))
Drew
  • 77,472
  • 10
  • 114
  • 243
  • No, that's all. I am refactoring a large code base and could benefit from advice in case I do something dumb without realising. – Dilna Jul 21 '22 at 03:54