[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode c23fb54 127/468: lua-automark: mark only those bu
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode c23fb54 127/468: lua-automark: mark only those buffer parts that may have changed their syntactical meaning |
Date: |
Thu, 5 Aug 2021 04:58:21 -0400 (EDT) |
branch: elpa/lua-mode
commit c23fb54373fd7329ac3612d7b350d7c40df00624
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
lua-automark: mark only those buffer parts that may have changed their
syntactical meaning
---
lua-mode.el | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index a81624d..bbdbe5f 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -438,6 +438,12 @@ This function replaces previous prefix-key binding with a
new one."
(save-excursion (let ((parse-result (syntax-ppss pos)))
(or (elt parse-result 3) (elt parse-result 4)))))
+(defun lua-comment-or-string-start (&optional pos)
+ "Returns start position of string or comment which contains point.
+
+If point is not inside string or comment, return nil."
+ (save-excursion (elt (syntax-ppss pos) 8)))
+
(defun lua-indent-line ()
"Indent current line for Lua mode.
Return the amount the indentation changed by."
@@ -1287,12 +1293,27 @@ If END is nil, stop at `end-of-buffer'."
(lua-mark-multiline-region ml-begin ml-end))))))
(defvar lua-automark-multiline-timer nil
- "Contains idle-timer object used for automatical multiline literal markup
which must be cleaneded up on exit")
+ "Contains idle-timer object used for automatical multiline literal markup
which must be cleaned up on exit.")
+
+(defvar lua-automark-multiline-start-pos nil
+ "Contains position from which automark procedure should start.
+
+Automarking shall start at the point before which no modification has been
+made since last automark. Additionally, if such point is inside string or
+comment, rewind start position to its beginning.
+
+nil means automark is unnecessary because there were no updates.")
+
+(defun lua--automark-update-start-pos (change-begin change-end old-len)
+ "Updates `lua-automark-multiline-start-pos' upon buffer modification."
+ (setq lua-automark-multiline-start-pos
+ (or (lua-comment-or-string-start change-begin) change-begin)))
(defun lua--automark-multiline-update-timer ()
(lua--automark-multiline-cleanup) ;; reset previous timer if it existed
(when lua-automark-multiline-interval
(add-hook 'change-major-mode-hook 'lua--automark-multiline-cleanup nil
'local)
+ (add-hook 'after-change-functions 'lua--automark-update-start-pos nil
'local)
(setq lua-automark-multiline-timer
(run-with-idle-timer lua-automark-multiline-interval 'repeat
'lua--automark-multiline-run))))
@@ -1305,7 +1326,9 @@ If END is nil, stop at `end-of-buffer'."
(defun lua--automark-multiline-run ()
(when (<= (buffer-size) lua-automark-multiline-maxsize)
- (lua-mark-all-multiline-literals)))
+ (when lua-automark-multiline-start-pos
+ (lua-mark-all-multiline-literals lua-automark-multiline-start-pos)
+ (setq lua-automark-multiline-start-pos nil))))
(defun lua--customize-set-automark-multiline-interval (symbol value)
(set symbol value)
- [nongnu] elpa/lua-mode 5953970 101/468: Bump version, (continued)
- [nongnu] elpa/lua-mode 5953970 101/468: Bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c044a1b 109/468: Fix emacs compilation warning in XEmacs-oriented code, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3367502 121/468: Merge pull request #7 from rlph/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9645322 124/468: lua-indent-line: add lua-indent-string-contents custom variable to enable indenting multiline strings if necessary (issue #6), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 99ef499 129/468: Make lua-automark variables buffer local, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2ce253c 133/468: lua-automark: fix multiline comments recognition which was failing when there was a single-line comment previously, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5a81583 140/468: Restore compatibility with Emacs22 and earlier that was broken when patching lua-mode-abbrev-table (should fix #11), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e498788 142/468: lua-calculate-indentation: add comments, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1e61379 111/468: Fix most of compile-time warnings, add couple FIXMEs, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d6232fe 119/468: lua-find-regexp: check if match-beginning should be ignored too, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c23fb54 127/468: lua-automark: mark only those buffer parts that may have changed their syntactical meaning,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode dfdbd85 143/468: lua-cont-eol-regexp: add missing keywords "if", "until" and "elseif", Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 612b1e7 166/468: Fixed misplaced paranthesis., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4a203b9 172/468: add lua-send-defun (a lua-send-proc replacement), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 58da3f9 066/468: Remove comment about setting lua-mode-map: not required anymore, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e3a4390 092/468: lua-mark-all-multiline-literals: add default keybinding "lua-prefix C-; ", Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fa1ef23 107/468: lua-mode-map: dont evaluate at compile-time (fix byte-compilation error), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e9a17ba 120/468: Added autoload for (add-to-list 'interpreter-mode-alist '("lua" . lua-mode)), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 509700f 130/468: lua--automark-update-start-pos: rewind to beginning of line to make sure newly inserted multiline literal delimiters are recognized, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 066d042 139/468: Merge pull request #12 from vhallac/vh-indentation-mods, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 39cf29e 141/468: Whoops! Add missing parenthesis, Philip Kaludercic, 2021/08/05