[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jinja2-mode eda4eedd49 08/57: Add keyword specific closure
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jinja2-mode eda4eedd49 08/57: Add keyword specific closure |
Date: |
Mon, 17 Jan 2022 05:58:23 -0500 (EST) |
branch: elpa/jinja2-mode
commit eda4eedd4945ac88793ccba36888a21ea281160c
Author: Florian Mounier <florian.mounier@kozea.fr>
Commit: Florian Mounier <florian.mounier@kozea.fr>
Add keyword specific closure
---
jinja2.el | 59 +++++++++++++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 26 deletions(-)
diff --git a/jinja2.el b/jinja2.el
index 0cf9fcf8ea..39e4239f9e 100644
--- a/jinja2.el
+++ b/jinja2.el
@@ -26,14 +26,18 @@
(require 'sgml-mode)
-(defconst jinja2-font-lock-indenting-keywords
+(defconst jinja2-closing-keywords
'(
- "if" "else" "elif" "for" "block" "filter" "with"
+ "if" "for" "block" "filter" "with"
"raw" "macro" "autoescape" "trans" "call"
;; Hydra specific
"auth" "showonmatch" "errorproof"))
-(defconst jinja2-font-lock-builtin-keywords
+(defconst jinja2-indenting-keywords
+ (append jinja2-closing-keywords
+ '("else" "elif" )))
+
+(defconst jinja2-builtin-keywords
'(
"as" "autoescape" "debug" "extends"
"firstof" "in" "include" "load"
@@ -46,7 +50,7 @@
"context" "with" "without" "ignore"
"missing" "scoped"))
-(defconst jinja2-font-lock-functions-keywords
+(defconst jinja2-functions-keywords
'(
"abs" "attr" "batch" "capitalize"
"center" "default" "dictsort"
@@ -67,20 +71,23 @@
(defun jinja2-find-open-tag ()
(if (search-backward-regexp
- (rx "{%"
- (* whitespace)
- (? (group
- "end"))
- (group
- (* word))
- (group
- (*? anything))
- (* whitespace)
- "%}") nil t)
- (if (match-string 1) ;; End tag, going on
- (jinja2-find-open-tag)
- (match-data))
- nil))
+ (rx-to-string
+ `(and "{%"
+ (* whitespace)
+ (? (group
+ "end"))
+ (group
+ ,(append '(or)
+ jinja2-closing-keywords
+ ))
+ (group
+ (*? anything))
+ (* whitespace)
+ "%}")) nil t)
+ (if (match-string 1) ;; End tag, going on
+ (jinja2-find-open-tag)
+ (match-data))
+ nil))
(defun jinja2-close-tag ()
"Close the previously opened template tag."
@@ -140,7 +147,7 @@
(,(rx-to-string `(and (group "|" (* whitespace))
(group
,(append '(or)
- jinja2-font-lock-functions-keywords
+ jinja2-functions-keywords
))))
(1 font-lock-keyword-face t)
(2 font-lock-function-name-face t)
@@ -148,12 +155,12 @@
(,(rx-to-string `(and word-start
(? "end")
,(append '(or)
- jinja2-font-lock-indenting-keywords
+ jinja2-indenting-keywords
)
word-end)) (0 font-lock-keyword-face))
(,(rx-to-string `(and word-start
,(append '(or)
- jinja2-font-lock-builtin-keywords
+ jinja2-builtin-keywords
)
word-end)) (0 font-lock-builtin-face))
@@ -198,12 +205,12 @@
(progn
(save-excursion
(forward-line -1)
- (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
jinja2-font-lock-indenting-keywords)))
+ (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
jinja2-indenting-keywords)))
(progn
(setq cur-indent (current-indentation))
;; (message (format "Jinja_No1] jinja : %d sgml : %d"
cur-indent html-indentation ))
)
- (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
jinja2-font-lock-indenting-keywords)))
+ (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
jinja2-indenting-keywords)))
(setq cur-indent (current-indentation))
(setq cur-indent (- (current-indentation) indent-width)))
;; (message (format "Jinja_end1] jinja : %d sgml : %d" cur-indent
html-indentation ))
@@ -224,12 +231,12 @@
(setq cur-indent (current-indentation))
;; (message (format "Jinja_end2] jinja : %d sgml : %d"
cur-indent html-indentation ))
(setq not-indented nil))
- (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
jinja2-font-lock-indenting-keywords)))
+ (if (looking-at (concat "^[ \t]*{% *.*?{% *end" (regexp-opt
jinja2-indenting-keywords)))
(progn
(setq cur-indent (current-indentation))
;; (message (format "Jinja_No] jinja : %d sgml : %d"
cur-indent html-indentation ))
(setq not-indented nil))
- (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
jinja2-font-lock-indenting-keywords))) ; Check start tag
+ (if (looking-at (concat "^[ \t]*{% *" (regexp-opt
jinja2-indenting-keywords))) ; Check start tag
(progn
(setq cur-indent (+ (current-indentation) indent-width))
;; (message (format "Jinja_open] jinja : %d sgml : %d"
cur-indent html-indentation ))
@@ -261,7 +268,7 @@
. sgml-font-lock-syntactic-keywords)))
(set (make-local-variable 'indent-line-function) 'jinja2-indent-line))
-(define-key jinja2-mode-map (kbd "C-à") 'jinja2-close-tag)
+(define-key jinja2-mode-map (kbd "C-c c") 'jinja2-close-tag)
(add-to-list 'auto-mode-alist '("\\.jinja2\\'" . jinja2-mode))
(provide 'jinja2-mode)
- [nongnu] elpa/jinja2-mode 29b492f175 49/57: Merge pull request #14 from mmckinst/j2_extension, (continued)
- [nongnu] elpa/jinja2-mode 29b492f175 49/57: Merge pull request #14 from mmckinst/j2_extension, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 4540f99a3e 53/57: Merge pull request #19 from daviderestivo/master, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode cfaa7bbe7b 44/57: v0.2, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 556ed3b80b 03/57: Remove messages, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 9a87875833 05/57: Handle elif, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 5a16074830 04/57: Capitalization of mode, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode fc3fd64758 10/57: Remove debug message, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 06771de3e8 22/57: Merge pull request #2 from amirouche/HEAD, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode ecd19a40b7 55/57: Merge pull request #20 from sdwolfz/indent-on-save, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode bc0a925b9a 52/57: Add 'make-it-local flag to after-save-hook, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode eda4eedd49 08/57: Add keyword specific closure,
ELPA Syncer <=
- [nongnu] elpa/jinja2-mode 6ac5cf29fb 42/57: Derive from html-mode instead of sgml-mode, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode f72c9d74ae 39/57: Fix indentation + disable ' as string quote syntax, fixes #7, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 4fc7d6deb9 38/57: Merge branch 'master' of github.com:paradoxxxzero/jinja2-mode, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 61c00ff7f9 32/57: Merge pull request #4 from tarsius/master, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 7ec3b81f7a 33/57: The convention of TAB indents not altering (point) is really neat - allows it to become a subconscious reflex mid flow., ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 2f3f9dff89 27/57: Fix in line insert, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode e3ddbb6933 47/57: Merge pull request #1 from yafeunteun/indent-whole-buffer-on-save, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode a598357069 56/57: Bump version to 0.3, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 03e5430a7e 57/57: Merge pull request #23 from skangas/bump-version, ELPA Syncer, 2022/01/17
- [nongnu] elpa/jinja2-mode 5ac022d688 51/57: Merge pull request #17 from yafeunteun/master, ELPA Syncer, 2022/01/17