[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode ded7566 151/468: Add lua-with-silent-modification
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode ded7566 151/468: Add lua-with-silent-modifications macro, use it to fix the undo history issue (#21) |
Date: |
Thu, 5 Aug 2021 04:58:26 -0400 (EDT) |
branch: elpa/lua-mode
commit ded75663e0a4599467c8a5f7061d5d7e3f90103d
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Add lua-with-silent-modifications macro, use it to fix the undo history
issue (#21)
Previously, multiline literal colorization operation could get into undo
history.
---
lua-mode.el | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index bc9c716..60199c2 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1323,10 +1323,29 @@ left out."
(define-key lua-mode-menu [search-documentation]
'("Search Documentation" . lua-search-documentation))
+;; Emacs 23.3 introduced with-silent-modifications macro
+;; use it if it's available, otherwise define a replacement for that
+(if (fboundp 'with-silent-modifications)
+ (defalias 'lua-with-silent-modifications 'with-silent-modifications)
+
+ (defmacro lua-with-silent-modifications (body)
+ "Execute BODY, pretending it does not modifies the buffer.
+
+This is a reimplementation of macro `with-silent-modifications'
+for Emacsen that doesn't contain one (pre-23.3)."
+ (let ((old-modified-p (buffer-modified-p))
+ (inhibit-modification-hooks t)
+ (buffer-undo-list t))
+
+ (unwind-protect
+ ,@body
+ (set-buffer-modified-p old-modified-p)))))
+
(defsubst lua-put-char-property (pos property value &optional object)
- (if value
- (put-text-property pos (1+ pos) property value object)
- (remove-text-properties pos (1+ pos) (list property nil))))
+ (lua-with-silent-modifications
+ (if value
+ (put-text-property pos (1+ pos) property value object)
+ (remove-text-properties pos (1+ pos) (list property nil)))))
(defsubst lua-put-char-syntax-table (pos value &optional object)
(lua-put-char-property pos 'syntax-table value object))
@@ -1341,10 +1360,7 @@ left out."
If TYPE is string, mark char as string delimiter. If TYPE is comment,
mark char as comment delimiter. Otherwise, remove the mark if any."
- (let ((old-modified-p (buffer-modified-p)) (inhibit-modification-hooks t))
- (unwind-protect
- (lua-put-char-syntax-table pos (lua-get-multiline-delim-syntax type))
- (set-buffer-modified-p old-modified-p))))
+ (lua-put-char-syntax-table pos (lua-get-multiline-delim-syntax type)))
(defsubst lua-inside-multiline-p (&optional pos)
(let ((status (syntax-ppss pos)))
@@ -1362,10 +1378,8 @@ mark char as comment delimiter. Otherwise, remove the
mark if any."
If BEGIN is nil, start from `beginning-of-buffer'.
If END is nil, stop at `end-of-buffer'."
(interactive)
- (let ((old-modified-p (buffer-modified-p)) (inhibit-modification-hooks t))
- (unwind-protect
- (remove-text-properties (or begin (point-min)) (or end (point-max))
'(syntax-table ()))
- (set-buffer-modified-p old-modified-p)))
+ (lua-with-silent-modifications
+ (remove-text-properties (or begin (point-min)) (or end (point-max))
'(syntax-table ())))
(font-lock-fontify-buffer))
(defun lua-mark-multiline-region (begin end)
- [nongnu] elpa/lua-mode 0f6048d 082/468: Implement lua-mark-all-multiline-literals function, (continued)
- [nongnu] elpa/lua-mode 0f6048d 082/468: Implement lua-mark-all-multiline-literals function, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 96eba74 085/468: lua-(comment/string)-p: add optional pos parameter, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode aef55a6 091/468: Update contact info in README; bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8c28ed5 095/468: Add utility funcs lua-inside-multiline-p and lua-get-multiline-start, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 79ff5d0 110/468: lua-postprocess-output-buffer: replace save-excursion/set-buffer with with-current-buffer, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9b929d4 115/468: Reorder operations in release target so that no pushing/sending is done if master differs from remotes/origin/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9c94413 118/468: lua-comment/-string-p funcs: wrap into save-excursion because syntax-ppss alters point position, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e470943 131/468: lua-mode-abbrev-table: mark abbreviations as :system so that they're not counted as user-defined and are not saved automatically (issue #8), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f4ab885 144/468: lua-cont-eol-regexp: add "return" keyword too, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 01d0f38 146/468: Bump thanks section, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ded7566 151/468: Add lua-with-silent-modifications macro, use it to fix the undo history issue (#21),
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 37f51cb 152/468: Fix multiline literal highlighting for long strings (#20), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b33f255 154/468: Make lua-mode-hook customizable., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ec26ea4 155/468: Fix: Single-line conditionals can confuse indenting (#22), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fa3470e 157/468: Merge pull request #28 from rrthomas/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ced5226 161/468: lua-with-silent-modifications: fix old style backquotes in fallback implementation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bba7fc0 163/468: Fix byte-compilation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d128a74 170/468: Add initial version of test/indentation/README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4399254 177/468: Merge pull request #39, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 08ff6ea 183/468: Merge remote-tracking branch 'origin/master', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8aa98ae 185/468: Non-functional refactoring, Philip Kaludercic, 2021/08/05