branch: externals/indent-bars commit c244aef2a064a300c529028e940d2b6b49a1eb18 Author: JD Smith <93749+jdtsm...@users.noreply.github.com> Commit: JD Smith <93749+jdtsm...@users.noreply.github.com>
if/when-let -> if/when-let* Adapt to language churn. --- indent-bars-ts.el | 58 +++++++++++++++++++++++++++---------------------------- indent-bars.el | 38 ++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/indent-bars-ts.el b/indent-bars-ts.el index b072672ddb..fea439e3f2 100644 --- a/indent-bars-ts.el +++ b/indent-bars-ts.el @@ -203,10 +203,10 @@ that many newlines. E.g. MIN-NEWLINES=1 demands a two line node (or larger). If no spanning node is found, nil is returned." - (when-let ((start (treesit-node-start node)) - (end (if start-only start (treesit-node-end node))) - (nodes (treesit-query-capture indent-bars-ts--parser query - start end t))) + (when-let* ((start (treesit-node-start node)) + (end (if start-only start (treesit-node-end node))) + (nodes (treesit-query-capture indent-bars-ts--parser query + start end t))) (cond ((eq spanning 'innermost) (cl-loop for n in (nreverse nodes) if (and (or (eq n node) @@ -217,11 +217,11 @@ If no spanning node is found, nil is returned." min-newlines))) return n)) (spanning ; check first node, if it doesn't span, none will - (when-let ((n (indent-bars-ts--node-spans-p (car nodes) start end)) - ((or (not min-newlines) - (>= (count-lines - (treesit-node-start n) (treesit-node-end n)) - min-newlines)))) + (when-let* ((n (indent-bars-ts--node-spans-p (car nodes) start end)) + ((or (not min-newlines) + (>= (count-lines + (treesit-node-start n) (treesit-node-end n)) + min-newlines)))) n)) (t nodes)))) @@ -243,20 +243,20 @@ enclosing string and marks indent depth no deeper than one more than the indentation depth at string start. This reduces depth inside strings, and for wrapping contexts (e.g. function arguments)." - (if-let (((not (bobp))) - (node (treesit-node-on (1- (point)) (point) indent-bars-ts--parser)) - (dnew - (if (and indent-bars-ts--string-query - (indent-bars-ts--node-query - node indent-bars-ts--string-query t)) - ;; A string: do not descend - (1+ (indent-bars--depth (indent-bars--indent-at-node node))) - ;; Check wrap context - (when-let (( indent-bars-ts--wrap-query) - (ctx (indent-bars-ts--node-query - node indent-bars-ts--wrap-query nil t))) - (1+ (indent-bars--depth - (indent-bars--indent-at-node ctx))))))) + (if-let* (((not (bobp))) + (node (treesit-node-on (1- (point)) (point) indent-bars-ts--parser)) + (dnew + (if (and indent-bars-ts--string-query + (indent-bars-ts--node-query + node indent-bars-ts--string-query t)) + ;; A string: do not descend + (1+ (indent-bars--depth (indent-bars--indent-at-node node))) + ;; Check wrap context + (when-let* ((indent-bars-ts--wrap-query) + (ctx (indent-bars-ts--node-query + node indent-bars-ts--wrap-query nil t))) + (1+ (indent-bars--depth + (indent-bars--indent-at-node ctx))))))) (if dnew (min dnew d) d) d)) @@ -268,7 +268,7 @@ Blank lines to ignore are those within nodes of the types mentioned in `indent-bars-treesit-ignore-blank-lines-types'." (and indent-bars-ts--parser indent-bars-treesit-ignore-blank-lines-types - (when-let ((n (treesit-node-on beg beg))) + (when-let* ((n (treesit-node-on beg beg))) (seq-contains-p indent-bars-treesit-ignore-blank-lines-types (treesit-node-type n))))) @@ -489,7 +489,7 @@ due to edits or contextual fontification." (cl-find lang (treesit-parser-list) :key #'treesit-parser-language)) ;; Wrap: prevent additional bars inside wrapped entities - (when-let ((types (alist-get lang indent-bars-treesit-wrap))) + (when-let* ((types (alist-get lang indent-bars-treesit-wrap))) (setq indent-bars-ts--wrap-query (treesit-query-compile lang `([,@(mapcar #'list types)] @ctx)) indent-bars--update-depth-function @@ -513,7 +513,7 @@ due to edits or contextual fontification." #'indent-bars-ts--update-indentation-depth))))) ;; Emphasis Scope: use alternate styling outside(/inside) current scope - (when-let ((types (alist-get lang indent-bars-treesit-scope))) + (when-let* ((types (alist-get lang indent-bars-treesit-scope))) (indent-bars-ts--init-scope) (setq ibtcs (ibts/create)) (setq-local @@ -552,9 +552,9 @@ To be set in `indent-bars--teardown-functions'." (cond (indent-bars--ts-mode (add-hook 'indent-bars--teardown-functions 'indent-bars-ts--disable nil t) - (if-let (((fboundp #'treesit-available-p)) - ((treesit-available-p)) - (lang (treesit-language-at (point-min)))) + (if-let* (((fboundp #'treesit-available-p)) + ((treesit-available-p)) + (lang (treesit-language-at (point-min)))) (indent-bars-ts--setup lang) (setq indent-bars--ts-mode nil))) (t (indent-bars-ts--teardown)))) diff --git a/indent-bars.el b/indent-bars.el index a2dbb88b23..5142678a6f 100644 --- a/indent-bars.el +++ b/indent-bars.el @@ -658,7 +658,7 @@ instead of the :blend factor in `indent-bars-color'." If BLEND-OVERRIDE is set, the main color's :blend will be ignored and this value will be used instead, for blending into the frame background color. See `indent-bars-color-by-depth'." - (when-let ((cbd (indent-bars--style style "color-by-depth"))) + (when-let* ((cbd (indent-bars--style style "color-by-depth"))) (cl-destructuring-bind (&key regexp face-bg palette blend) cbd (let ((colors (cond @@ -678,7 +678,7 @@ background color. See `indent-bars-color-by-depth'." A color or palette (vector) of colors is returned, which may be nil, in which case no special current depth-coloring is used. See `indent-bars-highlight-current-depth' for configuration." - (when-let ((hcd (indent-bars--style style "highlight-current-depth"))) + (when-let* ((hcd (indent-bars--style style "highlight-current-depth"))) (cl-destructuring-bind (&key color face face-bg blend palette &allow-other-keys) hcd @@ -698,7 +698,8 @@ See `indent-bars-highlight-current-depth' for configuration." (if (string= color "unspecified-fg") (setq color indent-bars-unspecified-fg-color)) (if blend - (if-let ((palette (indent-bars--depth-palette style))) ; blend into normal depth palette + (if-let* ((palette (indent-bars--depth-palette style))) + ;; blend into normal depth palette (vconcat (mapcar (lambda (c) (indent-bars--blend-colors color c blend)) @@ -829,7 +830,7 @@ Additional `defcustom` keyword arguments can be given as R." type)) (t (setq type `(choice ,type)))))) ;; Add an unspecified choice - (when-let ((tag-pos (member :tag choice))) + (when-let* ((tag-pos (member :tag choice))) (setq choice (cdr tag-pos))) ;after tag (setcdr choice (push @@ -951,7 +952,7 @@ Useful for calling after theme changes." ;; Current depth highlight faces/stipple (setf (ibs/current-bg-color style) (indent-bars--current-bg-color style)) - (when-let ((stipple (indent-bars--current-depth-stipple nil nil nil style))) + (when-let* ((stipple (indent-bars--current-depth-stipple nil nil nil style))) (setf (ibs/current-stipple-face style) (indent-bars--tag "indent-bars%s-current-face" style)) (face-spec-set (ibs/current-stipple-face style) nil))) @@ -1016,7 +1017,7 @@ and can return an updated depth." (forward-line 0) (let* ((ppss (syntax-ppss)) ; moves point! (string-start (and indent-bars-no-descend-string (nth 8 ppss))) - (list-start (when-let + (list-start (when-let* ((ndl indent-bars-no-descend-lists) (open (nth 1 ppss)) ((or (not (consp ndl)) (memq (char-after open) ndl)))) @@ -1283,8 +1284,7 @@ used to change the current depth highlight (aside from stipple changes).") (defun indent-bars--current-bg-color (style) "Return the current bar background color appropriate for STYLE." - (when-let ((hcd - (indent-bars--style style "highlight-current-depth"))) + (when-let* ((hcd (indent-bars--style style "highlight-current-depth"))) (plist-get hcd :background))) (defun indent-bars--current-depth-stipple (&optional w h rot style) @@ -1306,7 +1306,7 @@ Works by remapping the appropriate indent-bars[-tag]-N face for all styles in the `indent-bars--styles' list. DEPTH should be greater than or equal to zero (zero meaning: no highlight)." (dolist (s indent-bars--styles) - (when-let ((c (alist-get (ibs/tag s) indent-bars--remaps))) ; out with the old + (when-let* ((c (alist-get (ibs/tag s) indent-bars--remaps))) ; out with the old (face-remap-remove-relative c)) (when (> depth 0) (let* ((face (indent-bars--face s depth)) @@ -1561,22 +1561,22 @@ WIN defaults to the selected window. To be set as a local (cur-whr (window-parameter win 'indent-bars-whr))) (unless (eq cur-whr whr) (set-window-parameter win 'indent-bars-whr whr)) - (when-let ((buf (window-buffer win)) - (ht (buffer-local-value 'indent-bars--stipple-remaps buf)) - ((null (gethash whr ht)))) + (when-let* ((buf (window-buffer win)) + (ht (buffer-local-value 'indent-bars--stipple-remaps buf)) + ((null (gethash whr ht)))) (with-current-buffer buf ; we may be called from an arbitrary buffer (indent-bars--create-stipple-remaps w h rot) (indent-bars--schedule-remap-cleanup))))) (defun indent-bars--cleanup-stipple-remaps (buf) "Clean up unused stipple face remaps for buffer BUF." - (when-let (((buffer-live-p buf)) - (wins (get-buffer-window-list buf nil t)) - (whrs (cl-loop for win in wins - collect (window-parameter win 'indent-bars-whr))) - (rmp-hsh (buffer-local-value 'indent-bars--stipple-remaps buf)) - (rkeys (hash-table-keys rmp-hsh)) - (unneeded (seq-difference rkeys whrs))) + (when-let* (((buffer-live-p buf)) + (wins (get-buffer-window-list buf nil t)) + (whrs (cl-loop for win in wins + collect (window-parameter win 'indent-bars-whr))) + (rmp-hsh (buffer-local-value 'indent-bars--stipple-remaps buf)) + (rkeys (hash-table-keys rmp-hsh)) + (unneeded (seq-difference rkeys whrs))) (with-current-buffer buf ;N.B. face-remapping-alist is buffer-local (dolist (rk unneeded) (indent-bars--remove-plist-remaps (gethash rk rmp-hsh))