update packages

This commit is contained in:
2021-01-08 19:32:30 +01:00
parent ce8f24d28a
commit f5649dceab
467 changed files with 26642 additions and 22487 deletions

View File

@@ -1,15 +1,15 @@
;;; web-mode.el --- major mode for editing web templates
;;; -*- coding: utf-8; lexical-binding: t; -*-
;; Copyright 2011-2020 François-Xavier Bois
;; Copyright 2011-2021 François-Xavier Bois
;; Version: 17.0.0
;; Package-Version: 20200612.1038
;; Package-Commit: 60ffd878c4371644bd964f00fea38054645e3e47
;; Version: 17.0.4
;; Package-Version: 20201227.1048
;; Package-Commit: a3ce21f795e03c7a5489a24b2b3c4fce2d7a2f59
;; Author: François-Xavier Bois <fxbois AT Google Mail Service>
;; Maintainer: François-Xavier Bois
;; Package-Requires: ((emacs "23.1"))
;; URL: http://web-mode.org
;; URL: https://web-mode.org
;; Repository: http://github.com/fxbois/web-mode
;; Created: July 2011
;; Keywords: languages
@@ -26,7 +26,7 @@
;;---- CONSTS ------------------------------------------------------------------
(defconst web-mode-version "17.0.0"
(defconst web-mode-version "17.0.4"
"Web Mode version.")
;;---- GROUPS ------------------------------------------------------------------
@@ -35,7 +35,7 @@
"Major mode for editing web templates"
:group 'languages
:prefix "web-"
:link '(url-link :tag "Site" "http://web-mode.org")
:link '(url-link :tag "Site" "https://web-mode.org")
:link '(url-link :tag "Repository" "https://github.com/fxbois/web-mode"))
(defgroup web-mode-faces nil
@@ -156,6 +156,11 @@
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-curly-brace-indentation nil
"Indent lines beginning with {."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-control-block-indentation t
"Control blocks increase indentation."
:type 'boolean
@@ -233,6 +238,11 @@ See web-mode-block-face."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-front-matter-block nil
"Enable front matter block (data at the beginning the template between --- and ---)."
:type 'boolean
:group 'web-mode)
(defcustom web-mode-enable-engine-detection nil
"Detect such directive -*- engine: ENGINE -*- at the top of the file."
:type 'boolean
@@ -781,8 +791,8 @@ Must be used in conjunction with web-mode-enable-block-face."
;;---- VARS --------------------------------------------------------------------
;;(defvar font-lock-beg)
;;(defvar font-lock-end)
(defvar font-lock-beg)
(defvar font-lock-end)
(defvar web-mode-auto-pairs nil)
(defvar web-mode-block-regexp nil)
@@ -800,7 +810,7 @@ Must be used in conjunction with web-mode-enable-block-face."
(defvar web-mode-expand-initial-scroll nil)
(defvar web-mode-expand-previous-state "")
;;(defvar web-mode-font-lock-keywords '(web-mode-font-lock-highlight))
(defvar web-mode-fontification-off nil)
(defvar web-mode-skip-fontification nil)
(defvar web-mode-inlay-regexp nil)
(defvar web-mode-is-scratch nil)
(defvar web-mode-jshint-errors 0)
@@ -858,7 +868,7 @@ Must be used in conjunction with web-mode-enable-block-face."
(defvar web-mode-imenu-regexp-list
'(("<\\(h[1-9]\\)\\([^>]*\\)>\\([^<]*\\)" 1 3 ">")
("^[ \t]*<\\([@a-z]+\\)[^>]*>? *$" 1 "id=\"\\([a-zA-Z0-9_]+\\)\"" "#" ">"))
"Regexps to match imenu items (see http://web-mode.org/doc/imenu.txt)")
"Regexps to match imenu items (see https://web-mode.org/doc/imenu.txt)")
;; https://www.gnu.org/software/emacs/manual/html_node/ccmode/Syntactic-Symbols.html
(defvar web-mode-indentation-params
@@ -1283,7 +1293,7 @@ Must be used in conjunction with web-mode-enable-block-face."
(defvar web-mode-engine-token-regexps
(list
'("artanis" . "\"\\|#|\\|;")
'("asp" . "//\\|/\\*\\|\"\\|'")
'("asp" . "//\\|/\\*\\|\"\\|''")
'("ejs" . "//\\|/\\*\\|\"\\|'")
'("erb" . "\"\\|'\\|#\\|<<[-]?['\"]?\\([[:alnum:]_]+\\)['\"]?")
'("lsp" . "\"\\|#|\\|;")
@@ -1306,7 +1316,7 @@ Must be used in conjunction with web-mode-enable-block-face."
'("closure" . "{.\\|/\\*\\| //")
'("clip" . "</?c:[[:alpha:]-]+")
'("ctemplate" . "[$]?{[{~].")
'("django" . "{[#{%]")
'("django" . "{[#{%]\\|^#")
'("dust" . "{.")
'("elixir" . "<%")
'("ejs" . "<%")
@@ -1327,7 +1337,7 @@ Must be used in conjunction with web-mode-enable-block-face."
'("riot" . "{.\\|/// begin script")
'("smarty" . "{[[:alpha:]#$/*\"]")
'("spip" . "\\[(#REM)\\|(\\|#[A-Z0-9_]\\|{\\|<:")
'("template-toolkit" . "\\[%.\\|%%#")
'("template-toolkit" . "\\[%\\(.\\|$\\)\\|%%#")
'("underscore" . "<%")
'("velocity" . "#[[:alpha:]#*]\\|$[[:alpha:]!{]")
'("vue" . "{{\\|[:@][-[:alpha:]]+=\"")
@@ -1943,7 +1953,8 @@ shouldn't be moved back.)")
(defvar web-mode-pug-font-lock-keywords
(list
'("#[[:alnum:]-]+" 0 'web-mode-css-selector-face)
'("^[ \t]*\\(#?[[:alnum:].-]+\\)" 1 'web-mode-css-selector-face)
;;'("^[ \t]*\\(#[[:alnum:]-]+\\)" 0 'web-mode-css-selector-face)
'(" \\([@:]?\\sw+[ ]?=\\)" 1 'web-mode-param-name-face)
))
@@ -2068,8 +2079,8 @@ shouldn't be moved back.)")
(defvar web-mode-django-code-font-lock-keywords
(list
(cons (concat "{%[ ]*\\(" web-mode-django-control-blocks-regexp "\\)[ %]") '(1 'web-mode-block-control-face))
'("{%[ ]*\\(end[[:alpha:]]+\\)\\_>" 1 'web-mode-block-control-face) ;#504
(cons (concat "\\({%\\|#\\)[ ]*\\(" web-mode-django-control-blocks-regexp "\\)[ %]") '(2 'web-mode-block-control-face))
'("\\({%\\|#\\)[ ]*\\(end[[:alpha:]]+\\)\\_>" 2 'web-mode-block-control-face) ;#504
(cons (concat "\\_<\\(" web-mode-django-keywords "\\)\\_>") '(1 'web-mode-keyword-face))
(cons (concat "\\_<\\(" web-mode-django-types "\\)\\_>") '(1 'web-mode-type-face))
'("|[ ]?\\([[:alpha:]_]+\\)\\_>" 1 'web-mode-function-call-face)
@@ -2427,6 +2438,9 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(defvar web-mode-ac-sources-alist nil
"alist mapping language names to ac-sources for that language.")
(defvar web-mode-trace nil
"Activate debug tracing.")
(defvar web-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?- "_" table)
@@ -2688,7 +2702,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(make-local-variable 'web-mode-indentless-attributes)
(make-local-variable 'web-mode-indentless-elements)
(make-local-variable 'web-mode-is-scratch)
(make-local-variable 'web-mode-fontification-off)
(make-local-variable 'web-mode-skip-fontification)
(make-local-variable 'web-mode-jshint-errors)
(make-local-variable 'web-mode-last-enabled-feature)
(make-local-variable 'web-mode-markup-indent-offset)
@@ -2700,9 +2714,10 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(make-local-variable 'web-mode-scan-end)
(make-local-variable 'web-mode-sql-indent-offset)
(make-local-variable 'web-mode-time)
(make-local-variable 'web-mode-trace)
;;(make-local-variable 'font-lock-beg)
;;(make-local-variable 'font-lock-end)
(make-local-variable 'font-lock-beg)
(make-local-variable 'font-lock-end)
(make-local-variable 'comment-end)
(make-local-variable 'comment-region-function)
@@ -2784,19 +2799,61 @@ another auto-completion with different ac-sources (e.g. ac-php)")
((not (buffer-file-name))
)
((string-match-p "web-mode-benchmark.html" (buffer-file-name))
(web-mode-trace "end"))
(web-mode-measure "end"))
) ;cond
)
;;---- INVALIDATION ------------------------------------------------------------
;; 1/ after-change
;; 2/ extend-region
;; 3/ scan
;; 4/ fontify
;; 5/ post-command
(defun web-mode-on-after-change (beg end len)
(when web-mode-trace
(message "after-change: pos(%d) beg(%d) end(%d) len(%d) this-command(%S)"
(point) beg end len this-command))
(when (or (null web-mode-change-beg) (< beg web-mode-change-beg))
(setq web-mode-change-beg beg))
(when (or (null web-mode-change-end) (> end web-mode-change-end))
(setq web-mode-change-end end)))
(defun web-mode-extend-region ()
(when web-mode-trace
(message "extend-region: font-lock-beg(%S) font-lock-end(%S) web-mode-change-beg(%S) web-mode-change-end(%S) web-mode-skip-fontification(%S)"
font-lock-beg font-lock-end web-mode-change-beg web-mode-change-end web-mode-skip-fontification))
(when (and (string= web-mode-engine "php")
(and (>= font-lock-beg 6) (<= font-lock-beg 9))
(or (message (buffer-substring-no-properties 1 6)) t)
(string= (buffer-substring-no-properties 1 6) "<?php"))
(setq font-lock-beg (point-min)
font-lock-end (point-max))
)
(when (or (null web-mode-change-beg) (< font-lock-beg web-mode-change-beg))
(when web-mode-trace (message "extend-region: font-lock-beg(%S) < web-mode-change-beg(%S)" font-lock-beg web-mode-change-beg))
(setq web-mode-change-beg font-lock-beg))
(when (or (null web-mode-change-end) (> font-lock-end web-mode-change-end))
(when web-mode-trace (message "extend-region: font-lock-end(%S) > web-mode-change-end(%S)" font-lock-end web-mode-change-end))
(setq web-mode-change-end font-lock-end))
(let ((region (web-mode-scan web-mode-change-beg web-mode-change-end)))
(when region
;;(message "region: %S" region)
(setq font-lock-beg (car region)
font-lock-end (cdr region))
) ;when
) ;let
nil)
(defun web-mode-scan (&optional beg end)
(when web-mode-trace
(message "scan: beg(%S) end(%S) web-mode-change-beg(%S) web-mode-change-end(%S)"
beg end web-mode-change-beg web-mode-change-end))
(unless beg (setq beg web-mode-change-beg))
(unless end (setq end web-mode-change-end))
;;(message "%S %S" web-mode-content-type (get-text-property beg 'part-side))
;;(message "propertize: beg(%S) end(%S)" web-mode-change-beg web-mode-change-end)
;;(message "%S %S" (get-text-property beg 'part-side) (get-text-property end 'part-side))
;;(message "%S %S %S" web-mode-content-type (get-text-property beg 'part-side) (get-text-property end 'part-side))
(when (and end (> end (point-max)))
(setq end (point-max)))
(setq web-mode-change-beg nil
@@ -2813,8 +2870,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
;;(message "invalidate block (%S > %S)" beg end)
(web-mode-invalidate-block-region beg end))
((and (or (member web-mode-content-type
'("css" "javascript" "json" "jsx" "sass" "stylus"
"typescript"))
'("css" "javascript" "json" "jsx" "sass" "stylus" "typescript"))
(and (get-text-property beg 'part-side)
(get-text-property end 'part-side)
(> beg (point-min))
@@ -2829,12 +2885,146 @@ another auto-completion with different ac-sources (e.g. ac-php)")
)
(defun web-mode-invalidate-region (reg-beg reg-end)
;;(message "%S | reg-beg(%S) reg-end(%S)" (point) reg-beg reg-end)
(when web-mode-trace
(message "invalidate-region: point(%S) reg-beg(%S) reg-end(%S)" (point) reg-beg reg-end))
(setq reg-beg (web-mode-invalidate-region-beginning-position reg-beg)
reg-end (web-mode-invalidate-region-end-position reg-end))
;;(message "invalidate-region: reg-beg(%S) reg-end(%S)" reg-beg reg-end)
(web-mode-scan-region reg-beg reg-end))
(defun web-mode--command-is-self-insert-p ()
"Return non-nil if `this-command' is `self-insert-command'.
Also return non-nil if it is the command `self-insert-command' is remapped to."
(memq this-command (list 'self-insert-command
(key-binding [remap self-insert-command]))))
(defun web-mode-on-post-command ()
(when (and web-mode-trace
(not (member this-command
'(left-char right-char previous-line next-line save-buffer mwheel-scroll end-of-line beginning-of-line))))
(message "post-command: this-command(%S) web-mode-change-beg(%S) web-mode-change-end(%S) previous-state(%S)"
this-command web-mode-change-beg web-mode-change-end web-mode-expand-previous-state))
(let (ctx n char)
(when (and web-mode-expand-previous-state
(not (member this-command web-mode-commands-like-expand-region)))
(when (eq this-command 'keyboard-quit)
(goto-char web-mode-expand-initial-pos))
(deactivate-mark)
(when web-mode-expand-initial-scroll
(set-window-start (selected-window) web-mode-expand-initial-scroll)
)
(setq web-mode-expand-previous-state nil
web-mode-expand-initial-pos nil
web-mode-expand-initial-scroll nil))
(when (member this-command '(yank))
;;(setq web-mode-skip-fontification nil)
(when (and web-mode-scan-beg web-mode-scan-end global-font-lock-mode)
(save-excursion
(font-lock-fontify-region web-mode-scan-beg web-mode-scan-end))
(when web-mode-enable-auto-indentation
(indent-region web-mode-scan-beg web-mode-scan-end))
) ;and
)
(when (and (< (point) 16) web-mode-change-beg web-mode-change-end)
(web-mode-detect-content-type))
(when (and web-mode-change-beg web-mode-change-end
web-mode-enable-engine-detection
(or (null web-mode-engine) (string= web-mode-engine "none"))
(< (point) web-mode-chunk-length)
(web-mode-detect-engine))
(web-mode-on-engine-setted)
(web-mode-buffer-fontify))
(when (> (point) 1)
(setq char (char-before)))
(cond
((null char)
)
((and (>= (point) 3)
(web-mode--command-is-self-insert-p)
(not (member (get-text-property (point) 'part-token) '(comment string)))
(not (eq (get-text-property (point) 'tag-type) 'comment))
)
(setq ctx (web-mode-auto-complete)))
((and web-mode-enable-auto-opening
(member this-command '(newline electric-newline-and-maybe-indent newline-and-indent))
(or (and (not (eobp))
(eq (char-after) ?\<)
(eq (get-text-property (point) 'tag-type) 'end)
(looking-back ">\n[ \t]*" (point-min))
(setq n (length (match-string-no-properties 0)))
(eq (get-text-property (- (point) n) 'tag-type) 'start)
(string= (get-text-property (- (point) n) 'tag-name)
(get-text-property (point) 'tag-name))
)
(and (get-text-property (1- (point)) 'block-side)
(string= web-mode-engine "php")
(looking-back "<\\?php[ ]*\n" (point-min))
(looking-at-p "[ ]*\\?>"))))
(newline-and-indent)
(forward-line -1)
(indent-according-to-mode)
)
) ;cond
(cond
((not web-mode-enable-auto-opening)
)
((and (member this-command '(newline electric-newline-and-maybe-indent newline-and-indent))
(get-text-property (point) 'part-side)
(eq (get-text-property (point) 'part-token) 'string))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
((and (web-mode--command-is-self-insert-p)
(or (and ctx
(or (plist-get ctx :auto-closed)
(plist-get ctx :auto-expanded)))
(and (> (point) (point-min))
(get-text-property (1- (point)) 'tag-end)
(get-text-property (line-beginning-position) 'tag-beg))))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
((and (web-mode--command-is-self-insert-p)
(member (get-text-property (point) 'part-side) '(javascript jsx css))
(looking-back "^[ \t]+[]})]" (point-min)))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
) ; cond web-mode-enable-auto-opening
(when web-mode-enable-current-element-highlight
(web-mode-highlight-current-element))
(when (and web-mode-enable-current-column-highlight
(not (web-mode-buffer-narrowed-p)))
(web-mode-column-show))
(when (and web-mode-trace (not (member this-command
'(left-char right-char previous-line next-line save-buffer mwheel-scroll end-of-line beginning-of-line))))
(when (or web-mode-change-beg web-mode-change-end)
(message "post-command: web-mode-change-beg(%S) web-mode-change-end(%S)"
web-mode-change-end web-mode-change-end))
(message "-------------------------------------------------------------------")
)
))
;; NOTE: il est important d'identifier des caractères en fin de ligne
;; web-mode-block-tokenize travaille en effet sur les fins de lignes pour
;; les commentaires de type //
@@ -2863,17 +3053,19 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when (< code-end end)
(setq end code-end))
;; ?? pas de (web-mode-block-tokenize beg end) ?
(web-mode-block-tokenize beg end)
(cons beg end)
) ;asp
(t
(goto-char pos-beg)
;;(message "pos-beg=%S" pos-beg)
(when (string= web-mode-engine "php")
(cond
((and (looking-back "\*" (point-min))
(looking-at-p "/"))
(search-backward "/*" code-beg))
) ;cond
)
) ;when
(if (web-mode-block-rsb "[;{}(][ ]*\n" code-beg)
(setq beg (match-end 0))
(setq beg code-beg))
@@ -2934,10 +3126,17 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(defun web-mode-invalidate-region-beginning-position (pos)
(save-excursion
(goto-char pos)
(when (and (bolp) (not (bobp)))
(cond
((and (looking-at-p ">") ;#1151
(looking-back "--" (point-min)))
(search-backward "<!--" nil t))
((and (bolp) (not (bobp)))
(backward-char))
)
(beginning-of-line)
;;(message "pos=%S %S" (point) (text-properties-at (point)))
;;(message "pos=%S point=%S %S" pos (point) (text-properties-at (point)))
(setq pos (point-min))
(let ((continue (not (bobp))))
(while continue
@@ -3120,8 +3319,11 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(setq closing-string "%}"
delim-open "{%[+-]?"
delim-close "[-]?%}"))
(t
((string= sub2 "{#")
(setq closing-string "#}"))
(t
(setq closing-string "EOL"
delim-open "#[#]?"))
)
) ;django
@@ -3384,6 +3586,10 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(cond
((string= sub2 "{!")
(setq closing-string "!}"))
((string= sub2 "{}")
(setq closing-string nil
delim-open nil
delim-close nil))
(t
(setq closing-string '("{". "}")
delim-open "{[#/:?@><+^]?"
@@ -4181,7 +4387,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
((and (string= web-mode-engine "asp")
(string= sub2 "<%"))
(setq regexp "//\\|/\\*\\|\"\\|'")
(setq regexp "//\\|/\\*\\|\"\\|''")
) ;asp
((string= web-mode-engine "aspx")
@@ -4332,7 +4538,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
char (aref match 0))
(cond
((and (string= web-mode-engine "asp") (eq char ?\'))
((and (string= web-mode-engine "asp") (string= match "''"))
(goto-char token-end))
((and (string= web-mode-engine "razor") (eq char ?\'))
@@ -6114,39 +6320,12 @@ another auto-completion with different ac-sources (e.g. ac-php)")
;;---- FONTIFICATION -----------------------------------------------------------
;; 1/ after-change
;; 2/ extend-region
;; 3/ scan
;; 4/ fontify
;; 5/ post-command
(defun web-mode-extend-region ()
;;(message "extend-region: flb(%S) fle(%S) wmcb(%S) wmce(%S)" font-lock-beg font-lock-end web-mode-change-beg web-mode-change-end)
(cond
(web-mode-fontification-off
nil)
(t
(when (or (null web-mode-change-beg) (< font-lock-beg web-mode-change-beg))
;;(message "font-lock-beg(%S) < web-mode-change-beg(%S)" font-lock-beg web-mode-change-beg)
(setq web-mode-change-beg font-lock-beg))
(when (or (null web-mode-change-end) (> font-lock-end web-mode-change-end))
;;(message "font-lock-end(%S) > web-mode-change-end(%S)" font-lock-end web-mode-change-end)
(setq web-mode-change-end font-lock-end))
(let ((region (web-mode-scan web-mode-change-beg web-mode-change-end)))
(when region
;;(message "region: %S" region)
(setq font-lock-beg (car region)
font-lock-end (cdr region))
) ;when
) ;let
nil) ;t
))
(defun web-mode-fontify (limit)
;;(message "fontify: point(%S) limit(%S) change-beg(%S) change-end(%S)" (point) limit web-mode-change-beg web-mode-change-end)
(when web-mode-trace
(message "fontify: point(%S) limit(%S)" (point) limit))
(cond
(web-mode-fontification-off
nil)
;;(web-mode-skip-fontification
;; nil)
(t
(web-mode-with-silent-modifications
(save-excursion
@@ -6360,8 +6539,11 @@ another auto-completion with different ac-sources (e.g. ac-php)")
))
(defun web-mode-fontify-block (reg-beg reg-end)
(when web-mode-trace
(message "fontify-block: reg-beg(%S) reg-end(%S) engine(%S) keywords(%S)"
reg-beg reg-end web-mode-engine (not (null web-mode-engine-font-lock-keywords))))
(let (sub1 sub2 sub3 continue char keywords token-type face beg end (buffer (current-buffer)))
;;(message "reg-beg=%S reg-end=%S" reg-beg reg-end)
;; NOTE: required for blocks inside tag attrs
(remove-list-of-text-properties reg-beg reg-end '(font-lock-face))
@@ -6385,8 +6567,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
) ;comment block
(web-mode-engine-font-lock-keywords
(setq keywords web-mode-engine-font-lock-keywords)
)
(setq keywords web-mode-engine-font-lock-keywords))
((string= web-mode-engine "django")
(cond
@@ -6394,6 +6575,8 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(setq keywords web-mode-django-expr-font-lock-keywords))
((string= sub2 "{%")
(setq keywords web-mode-django-code-font-lock-keywords))
((string= sub1 "#")
(setq keywords web-mode-django-code-font-lock-keywords))
)) ;django
((string= web-mode-engine "mako")
@@ -6508,7 +6691,6 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when (and web-mode-enable-heredoc-fontification
(eq char ?\<)
(> (- end beg) 8)
;;(progn (message "%S" (buffer-substring-no-properties beg end)) t)
(string-match-p "JS\\|JAVASCRIPT\\|HTM\\|CSS" (buffer-substring-no-properties beg end)))
(setq keywords
(cond
@@ -6518,8 +6700,8 @@ another auto-completion with different ac-sources (e.g. ac-php)")
web-mode-javascript-font-lock-keywords)
))
(web-mode-fontify-region beg end keywords)
))
;; (message "%S %c %S beg=%S end=%S" web-mode-enable-string-interpolation char web-mode-engine beg end)
)
) ;save-match-data
(when (and web-mode-enable-string-interpolation
(member char '(?\" ?\<))
(member web-mode-engine '("php" "erb"))
@@ -6539,8 +6721,6 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when (and web-mode-enable-sql-detection
(eq token-type 'string)
(> (- end beg) 6)
;;(eq char ?\<)
;;(web-mode-looking-at-p (concat "[ \n]*" web-mode-sql-queries) (1+ beg))
(web-mode-looking-at-p (concat "\\(.\\|<<<[[:alnum:]]+\\)[ \n]*" web-mode-sql-queries) beg)
)
(web-mode-interpolate-sql-string beg end)
@@ -6549,14 +6729,12 @@ another auto-completion with different ac-sources (e.g. ac-php)")
) ;while continue
) ;when keywords
;;(when (and (member web-mode-engine '("jsp" "mako"))
(when (and (member web-mode-engine '("mako"))
(> (- reg-end reg-beg) 12)
(eq ?\< (char-after reg-beg)))
(web-mode-interpolate-block-tag reg-beg reg-end))
(when web-mode-enable-block-face
;; (message "block-face %S %S" reg-beg reg-end)
(font-lock-append-text-property reg-beg reg-end 'face 'web-mode-block-face))
))
@@ -7905,7 +8083,7 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(setq reg-beg (or (web-mode-part-beginning-position pos) (point-min)))
(goto-char reg-beg)
(if (and (string= web-mode-engine "mojolicious")
(looking-back "javascript begin"))
(looking-back "javascript begin" (point-min)))
(search-backward "%" nil t)
(search-backward "<" nil t))
(setq reg-col (current-column))
@@ -8078,6 +8256,14 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when debug (message "I100(%S) first line" pos))
(setq offset 0))
;; #123 #1145
((and web-mode-enable-front-matter-block
(eq (char-after (point-min)) ?\-)
(or (looking-at-p "---")
(search-forward "---" (point-max) t)))
(when debug (message "I108(%S) front-matter-block" pos))
(setq offset nil))
;; #1073
((get-text-property pos 'invisible)
(when debug (message "I110(%S) invible" pos))
@@ -8183,6 +8369,11 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when debug (message "I140(%S) mason" pos))
(setq offset 0))
((and (string= web-mode-engine "django")
(string-match-p "^#" curr-line))
(when debug (message "I144(%S) django line statements" pos))
(setq offset 0))
((and (get-text-property pos 'block-beg)
(or (web-mode-block-is-close pos)
(web-mode-block-is-inside pos)))
@@ -8638,9 +8829,10 @@ another auto-completion with different ac-sources (e.g. ac-php)")
)
((setq tmp (web-mode-part-is-opener prev-pos reg-beg))
;;(message "is-opener")
(if (looking-at-p "{") ;; #1020, #1053
(setq offset tmp)
(setq offset (+ tmp web-mode-code-indent-offset)))
(if (or (not (looking-at-p "{")) ;; #1020, #1053, #1160
web-mode-enable-curly-brace-indentation)
(setq offset (+ tmp web-mode-code-indent-offset))
(setq offset tmp))
)
(t
(setq offset
@@ -9192,7 +9384,10 @@ another auto-completion with different ac-sources (e.g. ac-php)")
(when h
(setq prev-line (car h))
(setq prev-indentation (cdr h))
;;(message "line=%S" line)
(cond
((string-match-p "''" line)
(setq out prev-indentation))
;; ----------------------------------------------------------------------
;; unindent
((string-match-p "\\_<\\(\\(end \\(if\\|function\\|class\\|sub\\|with\\)\\)\\|else\\|elseif\\|next\\|loop\\)\\_>" line)
@@ -10131,50 +10326,55 @@ Pos should be in a tag."
(when mark-active
(let (beg end line-beg line-end pos tag tag-start tag-end)
(save-excursion
(setq tag (read-from-minibuffer "Tag name? ")
tag-start (concat "<" tag ">")
tag-end (concat "</" tag ">")
pos (point)
beg (region-beginning)
end (region-end)
line-beg (web-mode-line-number beg)
line-end (web-mode-line-number end))
(goto-char end)
(unless (bolp)
(insert tag-end)
(back-to-indentation)
(when (> beg (point))
(goto-char beg))
(insert tag-start))
(while (> line-end line-beg)
(forward-line -1)
(setq line-end (1- line-end))
(unless (looking-at-p "[[:space:]]*$")
(end-of-line)
(combine-after-change-calls
(setq tag (read-from-minibuffer "Tag name? ")
tag-start (concat "<" tag ">")
tag-end (concat "</" tag ">")
pos (point)
beg (region-beginning)
end (region-end)
line-beg (web-mode-line-number beg)
line-end (web-mode-line-number end))
(goto-char end)
(unless (bolp)
(insert tag-end)
(back-to-indentation)
(when (> beg (point))
(goto-char beg))
(insert tag-start))
) ;while
(deactivate-mark)
))))
(while (> line-end line-beg)
(forward-line -1)
(setq line-end (1- line-end))
(unless (looking-at-p "[[:space:]]*$")
(end-of-line)
(insert tag-end)
(back-to-indentation)
(when (> beg (point))
(goto-char beg))
(insert tag-start))
) ;while
(deactivate-mark)
) ;combine-after-change-calls
) ;save-excursion
)))
(defun web-mode-lify-region ()
"Transform current REGION in an html list (<li>line1</li>...)"
(interactive)
(let (beg end lines)
(save-excursion
(when mark-active
(setq beg (region-beginning)
end (region-end))
(setq lines (buffer-substring beg end))
(kill-region beg end)
(setq lines (replace-regexp-in-string "^[ \t]*" "<li>" lines))
(setq lines (replace-regexp-in-string "$" "</li>" lines))
(web-mode-insert-and-indent lines)
) ;when
) ; save-excursion
(combine-after-change-calls
(when mark-active
(setq beg (region-beginning)
end (region-end))
(setq lines (buffer-substring beg end))
(kill-region beg end)
(setq lines (replace-regexp-in-string "^[ \t]*" "<li>" lines))
(setq lines (replace-regexp-in-string "$" "</li>" lines))
(web-mode-insert-and-indent lines)
) ;when
) ;combine-after-change-calls
) ;save-excursion
) ;let
)
@@ -10523,6 +10723,10 @@ Prompt user if TAG-NAME isn't provided."
(web-mode-block-skip-blank-forward (point) '(delimiter-beg))
(skip-chars-forward "[:space:]" (line-end-position)))
(cond
;; #1147
((and (get-text-property (point) 'jsx-beg)
(eq (get-text-property (1+ (point)) 'part-token) 'comment))
(web-mode-uncomment (1+ (point))))
((or (eq (get-text-property (point) 'tag-type) 'comment)
(eq (get-text-property (point) 'block-token) 'comment)
(eq (get-text-property (point) 'part-token) 'comment))
@@ -10584,6 +10788,9 @@ Prompt user if TAG-NAME isn't provided."
((looking-at-p ";")
(setq format ";"
prefix ";"))
((looking-at-p "''")
(setq format "''"
prefix "''"))
) ;cond
(list :beg beg :col col :prefix prefix :type type :format format)))))
@@ -10872,8 +11079,11 @@ Prompt user if TAG-NAME isn't provided."
(setq beg (car boundaries))
(setq end (1+ (cdr boundaries)))
(> (- end beg) 4))
(message "%S" boundaries)
;;(message "beg(%S) end(%S)" beg end)
(when (and (eq (get-text-property beg 'part-token) 'comment)
(> beg 1) ;#1158
(get-text-property (1- beg) 'jsx-beg))
(setq beg (1- beg)
end (1+ end)))
(setq comment (buffer-substring-no-properties beg end))
(setq sub2 (substring comment 0 2))
(cond
@@ -10890,6 +11100,8 @@ Prompt user if TAG-NAME isn't provided."
(setq comment (replace-regexp-in-string "\\(^[ \t]*\\*\\)" "" comment))
;;(message "%S" comment)
)
((string= sub2 "''")
(setq comment (replace-regexp-in-string "''" "" comment)))
((string= sub2 "//")
(setq comment (replace-regexp-in-string "^ *//" "" comment)))
) ;cond
@@ -11517,146 +11729,6 @@ Prompt user if TAG-NAME isn't provided."
))
(defun web-mode--command-is-self-insert-p ()
"Return non-nil if `this-command' is `self-insert-command'.
Also return non-nil if it is the command `self-insert-command' is remapped to."
(memq this-command (list 'self-insert-command
(key-binding [remap self-insert-command]))))
;; NOTE: after-change triggered before post-command
(defun web-mode-on-after-change (beg end len)
;;(message "after-change: pos=%d, beg=%d, end=%d, len=%d, ocmd=%S, cmd=%S" (point) beg end len this-original-command this-command)
;;(backtrace)
(when (eq this-original-command 'yank)
(setq web-mode-fontification-off t))
(when (or (null web-mode-change-beg) (< beg web-mode-change-beg))
(setq web-mode-change-beg beg))
(when (or (null web-mode-change-end) (> end web-mode-change-end))
(setq web-mode-change-end end))
;;(message "on-after-change: fontification-off(%S) change-beg(%S) change-end(%S)" web-mode-fontification-off web-mode-change-beg web-mode-change-end)
)
(defun web-mode-on-post-command ()
;;(message "post-command: cmd=%S, state=%S, beg=%S, end=%S" this-command web-mode-expand-previous-state web-mode-change-beg web-mode-change-end)
(let (ctx n char)
(when (and web-mode-expand-previous-state
(not (member this-command web-mode-commands-like-expand-region)))
(when (eq this-command 'keyboard-quit)
(goto-char web-mode-expand-initial-pos))
(deactivate-mark)
(when web-mode-expand-initial-scroll
(set-window-start (selected-window) web-mode-expand-initial-scroll)
)
(setq web-mode-expand-previous-state nil
web-mode-expand-initial-pos nil
web-mode-expand-initial-scroll nil))
(when (member this-command '(yank))
(setq web-mode-fontification-off nil)
(when (and web-mode-scan-beg web-mode-scan-end global-font-lock-mode)
(save-excursion
(font-lock-fontify-region web-mode-scan-beg web-mode-scan-end))
(when web-mode-enable-auto-indentation
(indent-region web-mode-scan-beg web-mode-scan-end))
) ;and
)
(when (and (< (point) 16) web-mode-change-beg web-mode-change-end)
(web-mode-detect-content-type))
(when (and web-mode-change-beg web-mode-change-end
web-mode-enable-engine-detection
(or (null web-mode-engine) (string= web-mode-engine "none"))
(< (point) web-mode-chunk-length)
(web-mode-detect-engine))
(web-mode-on-engine-setted)
(web-mode-buffer-fontify))
(when (> (point) 1)
(setq char (char-before)))
(cond
((null char)
)
((and (>= (point) 3)
(web-mode--command-is-self-insert-p)
(not (member (get-text-property (point) 'part-token) '(comment string)))
(not (eq (get-text-property (point) 'tag-type) 'comment))
)
(setq ctx (web-mode-auto-complete)))
((and web-mode-enable-auto-opening
(member this-command '(newline electric-newline-and-maybe-indent newline-and-indent))
(or (and (not (eobp))
(eq (char-after) ?\<)
(eq (get-text-property (point) 'tag-type) 'end)
(looking-back ">\n[ \t]*" (point-min))
(setq n (length (match-string-no-properties 0)))
(eq (get-text-property (- (point) n) 'tag-type) 'start)
(string= (get-text-property (- (point) n) 'tag-name)
(get-text-property (point) 'tag-name))
)
(and (get-text-property (1- (point)) 'block-side)
(string= web-mode-engine "php")
(looking-back "<\\?php[ ]*\n" (point-min))
(looking-at-p "[ ]*\\?>"))))
(newline-and-indent)
(forward-line -1)
(indent-according-to-mode)
)
) ;cond
(cond
((not web-mode-enable-auto-opening)
)
((and (member this-command '(newline electric-newline-and-maybe-indent newline-and-indent))
(get-text-property (point) 'part-side)
(eq (get-text-property (point) 'part-token) 'string))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
((and (web-mode--command-is-self-insert-p)
(or (and ctx
(or (plist-get ctx :auto-closed)
(plist-get ctx :auto-expanded)))
(and (> (point) (point-min))
(get-text-property (1- (point)) 'tag-end)
(get-text-property (line-beginning-position) 'tag-beg))))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
((and (web-mode--command-is-self-insert-p)
(member (get-text-property (point) 'part-side) '(javascript jsx css))
(looking-back "^[ \t]+[]})]" (point-min)))
(indent-according-to-mode)
(when (and web-mode-change-end (> web-mode-change-end (point-max)))
(message "post-command: enlarge web-mode-change-end")
(setq web-mode-change-end (point-max))
)
)
) ; cond web-mode-enable-auto-opening
(when web-mode-enable-current-element-highlight
(web-mode-highlight-current-element))
(when (and web-mode-enable-current-column-highlight
(not (web-mode-buffer-narrowed-p)))
(web-mode-column-show))
;;(message "post-command (%S) (%S)" web-mode-change-end web-mode-change-end)
))
(defun web-mode-dom-xpath (&optional pos)
"Display html path."
(interactive)
@@ -14230,7 +14302,7 @@ extended to support more filetypes by customizing
(web-mode)
))
(defun web-mode-trace (msg)
(defun web-mode-measure (msg)
(let (sub)
(when (null web-mode-time) (setq web-mode-time (current-time)))
(setq sub (time-subtract (current-time) web-mode-time))
@@ -14266,6 +14338,15 @@ extended to support more filetypes by customizing
;;(message "syntax-class=%S" (syntax-class (syntax-after (point))))
(message nil)))
(defun web-mode-toggle-tracing ()
"Toggle tracing."
(interactive)
(if web-mode-trace
(setq web-mode-trace nil)
(message "** tracing on ** point(%S) web-mode-change-beg(%S) web-mode-change-end(%S) web-mode-skip-fontification(%S)"
(point) web-mode-change-beg web-mode-change-end web-mode-skip-fontification)
(setq web-mode-trace t)))
(defun web-mode-debug ()
"Display informations useful for debugging."
(interactive)