Function: web-mode-block-tokenize
web-mode-block-tokenize is a natively compiled function defined in
web-mode.el.
Signature
(web-mode-block-tokenize REG-BEG REG-END &optional REGEXP)
Source Code
;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-block-tokenize (reg-beg reg-end &optional regexp)
(unless regexp (setq regexp web-mode-engine-token-regexp))
;;(message "tokenize: reg-beg(%S) reg-end(%S) regexp(%S)" reg-beg reg-end regexp)
;;(message "tokenize: reg-beg(%S) reg-end(%S) command(%S)" reg-beg reg-end this-command)
;;(message "%S>%S : %S" reg-beg reg-end (buffer-substring-no-properties reg-beg reg-end))
(save-excursion
(let ((pos reg-beg) beg char match continue token-type token-end)
(remove-list-of-text-properties reg-beg reg-end '(block-token))
;; TODO : vérifier la cohérence
(put-text-property reg-beg reg-end 'block-side t)
(goto-char reg-beg)
(when (> (point) reg-end)
(message "block-tokenize ** reg-beg(%S) > reg-end(%S) **" reg-beg reg-end))
(while (and (< (point) reg-end) (re-search-forward regexp reg-end t))
(setq beg (match-beginning 0)
match (match-string 0)
continue t
token-type 'comment
token-end (if (< reg-end (line-end-position)) reg-end (line-end-position))
char (aref match 0))
(cond
((and (string= web-mode-engine "asp") (string= match "'"))
(goto-char token-end))
((and (string= web-mode-engine "razor") (eq char ?\'))
(cond
((looking-at-p "\\(.\\|[\\][bfntr]\\|[\\]u....\\)'")
(search-forward "'" reg-end t)
(setq token-type 'string)
)
(t
(re-search-forward "[[:alnum:]_-]+")
(setq token-type 'symbol)
)))
((eq char ?\')
(setq token-type 'string)
(while (and continue (search-forward "'" reg-end t))
(setq continue (web-mode-string-continue-p reg-beg))
))
((eq char ?\")
(setq token-type 'string)
(while (and continue (search-forward "\"" reg-end t))
(setq continue (web-mode-string-continue-p reg-beg))
))
((string= match "//")
(goto-char token-end))
((eq char ?\;)
(goto-char token-end))
((string= match "#|")
(unless (search-forward "|#" reg-end t)
(goto-char token-end)))
((eq char ?\#)
(goto-char token-end))
((string= match "/*")
(unless (search-forward "*/" reg-end t)
(goto-char token-end))
)
((string= match "@*")
(unless (search-forward "*@" reg-end t)
(goto-char token-end)))
((eq char ?\<)
(setq token-type 'string)
(re-search-forward (concat "^[ ]*" (match-string 1)) reg-end t))
(t
(message "block-tokenize ** token end (%S) **" beg)
(setq token-type nil))
) ;cond
(put-text-property beg (point) 'block-token token-type)
(when (eq token-type 'comment)
(put-text-property beg (1+ beg) 'syntax-table (string-to-syntax "<"))
(if (or (< (point) (line-end-position)) (= (point) (point-max)))
(put-text-property (1- (point)) (point) 'syntax-table (string-to-syntax ">")) ;#445 #480
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax ">")) ;#377
)
)
) ;while
(web-mode-block-controls-unset pos)
)))