1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

; (elisp-scope-if-let): Fix case where bindings entry is a symbol

* lisp/emacs-lisp/elisp-scope.el (elisp-scope-if-let): Fix
handling of a plain symbol as one the bindings in an
'if-let*' form, as in (if-let* (foo) 'bar).

* test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
Test it.
This commit is contained in:
Eshel Yaron 2025-10-08 17:58:58 +02:00
parent 240bf0679c
commit e7df895c2e
No known key found for this signature in database
GPG key ID: EF3EE9CA35D78618
2 changed files with 12 additions and 6 deletions

View file

@ -2270,14 +2270,18 @@ property, or if the current buffer is trusted (see `trusted-content-p')."
(defun elisp-scope-if-let (bindings then else outspec)
(if (consp bindings)
(let* ((binding (car bindings))
(sym (when (cdr binding) (car binding)))
(form (if (cdr binding) (cadr binding) (car binding)))
(bare (bare-symbol sym))
(sym (if (consp binding)
(when (cdr binding) (car binding))
binding))
(form (when (consp binding)
(if (cdr binding) (cadr binding) (car binding))))
(bare (elisp-scope-sym-bare sym))
(len (length (symbol-name bare)))
(beg (elisp-scope-sym-pos sym)))
(when beg (elisp-scope-binding bare beg len))
(elisp-scope-1 form)
(let ((elisp-scope-local-bindings (elisp-scope-local-new bare beg elisp-scope-local-bindings)))
(when form (elisp-scope-1 form))
(let ((elisp-scope-local-bindings
(elisp-scope-local-new bare beg elisp-scope-local-bindings)))
(elisp-scope-if-let (cdr bindings) then else outspec)))
(elisp-scope-1 then outspec)
(elisp-scope-n else outspec)))