branch: elpa/web-mode
commit 1e7694aee87722f9e51b6e39c35d175d83a1fb2c
Merge: 1eb0abb1a9b 49844207fb1
Author: fxbois <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #1332 from jasalt/master
add wildcard support for `web-mode-indentless-attributes`
---
web-mode.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/web-mode.el b/web-mode.el
index 391a60a5dc3..069857a1f28 100644
--- a/web-mode.el
+++ b/web-mode.el
@@ -5675,6 +5675,17 @@ Also return non-nil if it is the command
`self-insert-command' is remapped to."
;; (6)value-uq (7)value-sq (8)value-dq (9)value-bq : jsx attr={}
;; (10)value-block
+(defun web-mode--indentless-attribute-p (attr)
+ "Return t if ATTR is in `web-mode-indentless-attributes'.
+ Handles wildcards where '*' matches any suffix."
+ (let ((found nil))
+ (dolist (pattern web-mode-indentless-attributes found)
+ (if (string-suffix-p "*" pattern)
+ (when (string-prefix-p (substring pattern 0 -1) attr)
+ (setq found t))
+ (when (string= pattern attr)
+ (setq found t))))))
+
(defun web-mode-attr-skip (limit)
(let ((tag-flags 0) (attr-flags 0) (continue t) (attrs 0) (brace-depth 0)
@@ -5766,7 +5777,7 @@ Also return non-nil if it is the command
`self-insert-command' is remapped to."
name-end (1- pos))
(setq state 4)
(setq attr (buffer-substring-no-properties name-beg (1+ name-end)))
- (when (and web-mode-indentless-attributes (member (downcase attr)
web-mode-indentless-attributes))
+ (when (and web-mode-indentless-attributes
(web-mode--indentless-attribute-p (downcase attr)))
(setq attr-flags (logior attr-flags 8)))
)