[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode de12f4b 086/468: lua-mark-all-multiline-literals:
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode de12f4b 086/468: lua-mark-all-multiline-literals: also handle multiline comments |
Date: |
Thu, 5 Aug 2021 04:58:13 -0400 (EDT) |
branch: elpa/lua-mode
commit de12f4b0bed0c81e9c9e928a0a7319d924e0d078
Author: immerrr <immerrr@gmail.com>
Commit: immerrr <immerrr@gmail.com>
lua-mark-all-multiline-literals: also handle multiline comments
---
lua-mode.el | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 4530610..9a9a7da 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1209,14 +1209,28 @@ If END is nil, stop at `end-of-buffer'."
(interactive)
(lua-clear-multiline-delims begin end)
(save-excursion
- (if begin (goto-char begin))
- (while (re-search-forward "\\[\\(=*\\)\\[" end 'noerror)
- (unless (lua-comment-or-string-p)
- (message "found %s" (match-string 0))
- (lua-mark-char-multiline-delim (match-beginning 0) 'string)
- (when (re-search-forward (format "\\]%s\\]" (or (match-string 1) ""))
end 'noerror)
- (message "found match %s" (match-string 0))
- (lua-mark-char-multiline-delim (1- (match-end 0)) 'string))))))
+ (goto-char (or begin 1))
+ ;; look for
+ ;; 1. (optional) two or more dashes followed by
+ ;; 2. lua multiline delimiter [[
+
+ (while (re-search-forward "\\(?2:--\\)?\\[\\(?1:=*\\)\\[" end 'noerror)
+ ;; match-start + 1 is considered instead of match-start, because
+ ;; such approach handles '---[[' situation correctly: Emacs
+ ;; thinks 2nd dash (i.e. match-start) is not yet a comment, but
+ ;; the third one is, hence the +1. In all the other situations,
+ ;; '+1' is safe to use because it bears the same syntactic
+ ;; properties, i.e. if match-start is inside string-or-comment,
+ ;; then '+1' is too and vice versa.
+ ;;
+ ;; PS. ping me if you find a situation in which this is not true
+ (unless (lua-comment-or-string-p (1+ (match-beginning 0)))
+ (let ((type (if (match-beginning 2) 'comment 'string)))
+ (message "found %s" (match-string 0))
+ (lua-mark-char-multiline-delim (match-beginning 0) type)
+ (when (re-search-forward (format "\\]%s\\]" (or (match-string 1)
"")) end 'noerror)
+ (message "found match %s" (match-string 0))
+ (lua-mark-char-multiline-delim (1- (match-end 0)) type)))))))
(provide 'lua-mode)
- [nongnu] elpa/lua-mode dfc3b78 083/468: Preserve buffer-modified-p state when (un-)marking multiline delimiters, (continued)
- [nongnu] elpa/lua-mode dfc3b78 083/468: Preserve buffer-modified-p state when (un-)marking multiline delimiters, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 7920d17 087/468: lua-mark-all-multiline-literals: if region is active, limit to region boundaries, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4a22b3c 100/468: Allow lua-start-process to be called interactively., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a3ed448 106/468: Make dist with git-archive, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 742180e 125/468: lua-automark-multiline: add lua-automark-multiline-maxsize variable to prevent long waits on big files, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 0b3df35 135/468: Fix string content indentation: it's now indented by indent-level relative to indentation of the line where string/comment literal starts (issue #6), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5aa6f9e 042/468: Patch from Reuben: fix long string colouring problem, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode eb5d301 055/468: Bump version., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d66ec8e 080/468: Remove broken multiline literal font-locking, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d142ed1 084/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode de12f4b 086/468: lua-mark-all-multiline-literals: also handle multiline comments,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 46683e7 052/468: Make lua-indent-level customizable., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 3c89a0a 054/468: Reorder customizations better., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 158f267 058/468: Merge lua-goto-nonblank-* funcs into one, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c5f37b0 088/468: lua-mark-all-multiline-literals: look for multiline ending beyond specified bounds to improve integrity, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 96658a0 089/468: Move actual marking of multiline construct into lua-mark-multiline-region, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode da22ef7 094/468: Rename lua-clear-multiline-delims -> lua-unmark-multiline-literals, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5607327 096/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2b91610 098/468: Bump contact information, Philip Kaludercic, 2021/08/05
- [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