[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/adoc-mode 65794ce2da 188/199: Addresses #33. Reduce format
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/adoc-mode 65794ce2da 188/199: Addresses #33. Reduce formatting lag by `adoc-kwf-search` |
Date: |
Sun, 3 Sep 2023 06:59:45 -0400 (EDT) |
branch: elpa/adoc-mode
commit 65794ce2da5c3611f6d2194d0b4d19fbfc94e57f
Author: Tobias Zawada <TOZ@esi-group.com>
Commit: TobiasZawada <i@tn-home.de>
Addresses #33. Reduce formatting lag by `adoc-kwf-search`
Replace `re-search-forward` by `adoc-kwf-search` in font-lock keywords.
`adoc-kwf-search` continues search if the adoc-code-block text property
is set at the matching position.
---
adoc-mode.el | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/adoc-mode.el b/adoc-mode.el
index 4d114bf88f..fa1fa11b2d 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -1556,6 +1556,19 @@ Subgroups of returned regexp:
;;;; font lock keywords
+(defsubst adoc-kwf-search (regexp &optional bound noerror count)
+ "Keyword search for Adoc.
+Like `re-search-forward' with the same arguments
+REGEXP, BOUND, NOERROR and COUNT.
+If a match for REGEXP is found where the text property
+`adoc-code-block' is non-nil continue the search."
+ (let (ret)
+ (while (and
+ (setq ret (re-search-forward regexp bound noerror count))
+ (get-text-property (point) 'adoc-code-block)
+ (null (eobp))))
+ ret))
+
(defun adoc-kwf-std (end regexp &optional must-free-groups no-block-del-groups)
"Standard function for keywords
Intendent to be called from font lock keyword functions. END is
@@ -1567,7 +1580,7 @@ text having adoc-reserved set to symbol `block-del'."
(let ((found t) (prevented t) saved-point)
(while (and found prevented (<= (point) end) (not (eobp)))
(setq saved-point (point))
- (setq found (re-search-forward regexp end t))
+ (setq found (adoc-kwf-search regexp end t))
(setq prevented
(and found
(or
@@ -1679,7 +1692,7 @@ text having adoc-reserved set to symbol `block-del'."
;; matcher function
`(lambda (end)
(and adoc-enable-two-line-title
- (re-search-forward ,(adoc-re-two-line-title del) end t)
+ (adoc-kwf-search ,(adoc-re-two-line-title del) end t)
(< (abs (- (length (match-string 2)) (length (match-string 3)))) 3)
(or (not (numberp adoc-enable-two-line-title))
(not (equal adoc-enable-two-line-title (length (match-string
2)))))
@@ -1754,7 +1767,7 @@ Concerning TYPE, LEVEL and SUB-TYPE see `adoc-re-llisti'."
`(list
;; matcher function
(lambda (end)
- (and (re-search-forward "^[
\t]*\\(\\(?:CAUTION\\|WARNING\\|IMPORTANT\\|TIP\\|NOTE\\):\\)\\([ \t]+\\)" end
t)
+ (and (adoc-kwf-search "^[
\t]*\\(\\(?:CAUTION\\|WARNING\\|IMPORTANT\\|TIP\\|NOTE\\):\\)\\([ \t]+\\)" end
t)
(not (text-property-not-all (match-beginning 0) (match-end 0)
'adoc-reserved nil))))
;; highlighers
'(1 '(face adoc-complex-replacement-face adoc-reserved t))
@@ -1765,7 +1778,7 @@ Concerning TYPE, LEVEL and SUB-TYPE see `adoc-re-llisti'."
(list
;; matcher function
`(lambda (end)
- (and (re-search-forward ,(adoc-re-verbatim-paragraph-sequence) end t)
+ (and (adoc-kwf-search ,(adoc-re-verbatim-paragraph-sequence) end t)
(not (text-property-not-all (match-beginning 0) (match-end 0)
'adoc-reserved nil))))
;; highlighers
'(1 '(face adoc-typewriter-face adoc-reserved t font-lock-multiline t))))
@@ -1893,7 +1906,7 @@ meta characters."
(while (and found prevented)
(setq saved-point (point))
(setq found
- (re-search-forward ,regexp end t))
+ (adoc-kwf-search ,regexp end t))
(setq prevented ; prevented is only meaningful wenn found is non-nil
(or
(not found) ; the following is only needed when found
@@ -1931,7 +1944,7 @@ meta characters."
;; line beginning would also be underlined, which looks akward.
(defun adoc-flf-first-whites-fixed-width(end)
;; it makes no sense to do something with a blank line, so require at least
one non blank char.
- (and (re-search-forward "\\(^[ \t]+\\)[^ \t\n]" end t)
+ (and (adoc-kwf-search "\\(^[ \t]+\\)[^ \t\n]" end t)
;; don't replace a face with with adoc-align-face which already is a
fixed with
;; font (most probably), because then it also won't look aligned
(text-property-not-all (match-beginning 1) (match-end 1) 'face
'adoc-typewriter-face)
@@ -2120,7 +2133,7 @@ Use this function as matching function MATCHER in
`font-lock-keywords'."
(font-lock-append-text-property
start-src end-src+nl 'face 'adoc-native-code-face)
(add-text-properties
- start-src end-src+nl '(font-lock-fontified t font-lock-multiline
t))
+ start-src end-src+nl '(font-lock-fontified t font-lock-multiline
t adoc-code-block t))
)))
t)))
@@ -2154,9 +2167,7 @@ Use this function as matching function MATCHER in
`font-lock-keywords'."
(defun adoc-get-font-lock-keywords ()
"Return list of keywords for `adoc-mode'."
(list
- ;; Fontify code blocks first to mark these regions as fontified.
- '(adoc-fontify-code-blocks)
-
+ '(adoc-fontify-code-blocks) ; listing
;; Asciidoc BUG: Lex.next has a different order than the following extract
;; from the documentation states.
@@ -2292,7 +2303,6 @@ Use this function as matching function MATCHER in
`font-lock-keywords'."
;; ------------------------------
(adoc-kw-delimited-block 0 adoc-comment-face) ; comment
(adoc-kw-delimited-block 1 adoc-passthrough-face) ; passthrough
- (adoc-kw-delimited-block 2 adoc-code-face) ; listing
(adoc-kw-delimited-block 3 adoc-verbatim-face) ; literal
(adoc-kw-delimited-block 4 nil t) ; quote
(adoc-kw-delimited-block 5 nil t) ; example
- [nongnu] elpa/adoc-mode 27bf57f6fd 095/199: in commentary section, fixed wrong recipe how to use autoload, (continued)
- [nongnu] elpa/adoc-mode 27bf57f6fd 095/199: in commentary section, fixed wrong recipe how to use autoload, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 1b3a175861 100/199: renamings and improved comments in field of macros, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode fc590439b0 110/199: attribute list of macros can now spawn more than two lines, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 745884359a 117/199: added imenu support, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode fceae4560c 133/199: Kill all tabs, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 92da496f3d 151/199: Tweak the test command, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode e6b8e69843 090/199: bugfix: empty AsciiDoc attributes (e.g. [, ]) caused adoc-mode to enter infinite loop, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 976794ddc2 171/199: Update the changelog, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode cd2da9591a 172/199: Fix function name, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 07ac0c12d3 176/199: Tweak the README, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 65794ce2da 188/199: Addresses #33. Reduce formatting lag by `adoc-kwf-search`,
ELPA Syncer <=
- [nongnu] elpa/adoc-mode 9e1ea49b09 196/199: Listing blocks and literal blocks can have source style., ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 0348f96d72 101/199: local refactoring in field of attribute list, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 576d724330 114/199: 'caption' of http/... inline macros can now contain commas, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 2682662c96 118/199: Use mode-* to set var require-final-newline, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode db6c51c8e7 128/199: Restructure the README, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 46e8ea4126 129/199: Add Eldev and a GHA workflow based on it, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 7fdddd54f7 132/199: Require Emacs 26, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode bded623e3d 139/199: [Fix #8] Add a changelog, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 00c59c8d95 145/199: [Fix #7] Convert readme to AsciiDoc (#10), ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 893daa395c 152/199: Move the syntax-table out of the mode definition, ELPA Syncer, 2023/09/03