[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 9dd0e15 096/184: Avoid having text syntax-property
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 9dd0e15 096/184: Avoid having text syntax-property changes mark buffer as modified |
Date: |
Sun, 29 Aug 2021 11:03:23 -0400 (EDT) |
branch: elpa/gnuplot
commit 9dd0e153908a9edad3a730d2c7a9e915d19c77cf
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Avoid having text syntax-property changes mark buffer as modified
Old Emacsen don't have `with-silent-modifications', so copy the
definition of that in from subr.el for them.
---
gnuplot.el | 132 +++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 80 insertions(+), 52 deletions(-)
diff --git a/gnuplot.el b/gnuplot.el
index 1ead637..4dad5fb 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -373,6 +373,32 @@
;; (defalias 'hilit-set-mode-patterns 'gnuplot-dummy))
+;; Workaround missing with-silent-modifications: taken from subr.el in
+;; GNU Emacs 24
+(eval-when-compile
+ (if (not (fboundp 'with-silent-modifications))
+ (defmacro gnuplot-with-silent-modifications (&rest body)
+ "Execute BODY, pretending it does not modify the buffer."
+ (declare (debug t) (indent 0))
+ (let ((modified (make-symbol "modified")))
+ `(let* ((,modified (buffer-modified-p))
+ (buffer-undo-list t)
+ (inhibit-read-only t)
+ (inhibit-modification-hooks t)
+ deactivate-mark
+ ;; Avoid setting and removing file locks and checking
+ ;; buffer's uptodate-ness w.r.t the underlying file.
+ buffer-file-name
+ buffer-file-truename)
+ (unwind-protect
+ (progn
+ ,@body)
+ (unless ,modified
+ (restore-buffer-modified-p nil))))))
+ (defalias 'gnuplot-with-silent-modifications 'with-silent-modifications)))
+
+
+;;;;
(defconst gnuplot-xemacs-p (string-match "XEmacs" (emacs-version)))
(defconst gnuplot-ntemacs-p (string-match "msvc" (emacs-version)))
(defvar gnuplot-three-eight-p "")
@@ -1682,8 +1708,9 @@ and installed as a hook in `after-change-functions'."
(gnuplot-beginning-of-continuation)
(point)))
- (remove-text-properties begin (min (1+ end) (point-max))
- '(syntax-table nil))
+ (gnuplot-with-silent-modifications
+ (remove-text-properties begin (min (1+ end) (point-max))
+ '(syntax-table nil)))
(while (gnuplot-scan-next-string-or-comment end))))
@@ -1697,56 +1724,57 @@ string was found, otherwise nil."
(let ((begin (search-forward-regexp "[#'\"]" limit 'go-to-limit)))
(if (not begin)
nil
- (let* ((begin (1- begin))
- (end nil)
- (opener (match-string 0))
- (limit (point-at-eol))
- (end-at-eob-p nil)
- (re
- (cond ((string= opener "#") nil)
- ((string= opener "'") "''?")
- ((string= opener "\"") "\\\\\"\\|\\\\\\\\\\|\""))))
- (while (not end)
- (if (and (not (eobp)) (bolp) (eolp)) ; Empty continuation line:
- (setq end (point)) ; end at newline
- (if re
- (setq end (search-forward-regexp re limit 'go-to-limit))
- (end-of-line)) ; Comments end only at end-of-line
-
- (if end
- (when (and re
- (let ((m (match-string 0)))
- (or (string= m "\\\"")
- (string= m "\\\\")
- (string= m "''"))))
- (setq end nil)) ; Skip over escapes and look again
-
- ;; We got to EOL without finding an ending delimiter
- (if (eobp)
- (setq end (point)
- end-at-eob-p t) ; string/comment ends at EOB
- ;; Otherwise see if the line is continued with a backslash
- (if (save-excursion (backward-char) (looking-at "\\\\"))
- (progn ; yes, check out next line
- (beginning-of-line 2)
- (setq limit (point-at-eol)))
- (setq end (1+ (point-at-eol)))))))) ; no, string ends at EOL
-
- ;; Set the syntax properties
- (let ((begin-marker (copy-marker begin))
- (begin-quote-marker (copy-marker (1+ begin)))
- (end-quote-marker (copy-marker (1- end)))
- (end-marker (copy-marker end)))
-
- (let ((syntax (if (string= opener "#")
- '(syntax-table (14)) ; 'comment fence'
- '(syntax-table (15))))) ; 'string fence'
- (add-text-properties begin-marker begin-quote-marker syntax)
- (unless end-at-eob-p
- (add-text-properties end-quote-marker end-marker syntax)))
-
- ;; Mark multiline constructs for font-lock
- (add-text-properties begin-marker end-marker '(font-lock-multiline
t))))
+ (gnuplot-with-silent-modifications
+ (let* ((begin (1- begin))
+ (end nil)
+ (opener (match-string 0))
+ (limit (point-at-eol))
+ (end-at-eob-p nil)
+ (re
+ (cond ((string= opener "#") nil)
+ ((string= opener "'") "''?")
+ ((string= opener "\"") "\\\\\"\\|\\\\\\\\\\|\""))))
+ (while (not end)
+ (if (and (not (eobp)) (bolp) (eolp)) ; Empty continuation line:
+ (setq end (point)) ; end at newline
+ (if re
+ (setq end (search-forward-regexp re limit 'go-to-limit))
+ (end-of-line)) ; Comments end only at end-of-line
+
+ (if end
+ (when (and re
+ (let ((m (match-string 0)))
+ (or (string= m "\\\"")
+ (string= m "\\\\")
+ (string= m "''"))))
+ (setq end nil)) ; Skip over escapes and look again
+
+ ;; We got to EOL without finding an ending delimiter
+ (if (eobp)
+ (setq end (point)
+ end-at-eob-p t) ; string/comment ends at EOB
+ ;; Otherwise see if the line is continued with a backslash
+ (if (save-excursion (backward-char) (looking-at "\\\\"))
+ (progn ; yes, check out next line
+ (beginning-of-line 2)
+ (setq limit (point-at-eol)))
+ (setq end (1+ (point-at-eol)))))))) ; no, string ends at EOL
+
+ ;; Set the syntax properties
+ (let ((begin-marker (copy-marker begin))
+ (begin-quote-marker (copy-marker (1+ begin)))
+ (end-quote-marker (copy-marker (1- end)))
+ (end-marker (copy-marker end)))
+
+ (let ((syntax (if (string= opener "#")
+ '(syntax-table (14)) ; 'comment fence'
+ '(syntax-table (15))))) ; 'string fence'
+ (add-text-properties begin-marker begin-quote-marker syntax)
+ (unless end-at-eob-p
+ (add-text-properties end-quote-marker end-marker syntax)))
+
+ ;; Mark multiline constructs for font-lock
+ (add-text-properties begin-marker end-marker '(font-lock-multiline
t)))))
;; We found something
t)))
- [nongnu] elpa/gnuplot a70749e 054/184: Fix "replot" command in grammar., (continued)
- [nongnu] elpa/gnuplot a70749e 054/184: Fix "replot" command in grammar., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0ff395e 071/184: Compatibility hacks for pre-23 emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c3e13f0 076/184: change version number to 0.7beta to avoid any confusion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 319a176 072/184: clean up tests a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e9447f0 048/184: More consistent keys between gnuplot.el and gnuplot-context.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ea83e14 081/184: cleanup parsing tests some more, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot b618811 069/184: Silence some compiler warnings about obsolete font-lock faces, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c520e94 075/184: Remove a redundant check for gnuplot-keywords-pending, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6792a81 083/184: Simple indentation fix for new block-structured do and if, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7e33d0d 087/184: three fixes: indentation, require cl macros, fix defc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 9dd0e15 096/184: Avoid having text syntax-property changes mark buffer as modified,
ELPA Syncer <=
- [nongnu] elpa/gnuplot c52bb6c 089/184: grammar fixes for new-style if statement and blocks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e457287 099/184: Add aclocal.m4 into repository, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f5c4437 100/184: Reduce autotools dependency to version 2.61, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot e1ee092 097/184: Merge branch 'devel' containing 0.7 release candidate., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d9ed05b 105/184: remove broken link from readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot aefd4f6 106/184: Cleanup version numbers and copyright dates, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4858b0d 110/184: Set syntax table in comint buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c2aedf8 111/184: Add ERT tests to check comment and string syntax., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 5efb8a9 112/184: Add Makefile targets to run all tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ed930f3 116/184: Fix compile errors when testing from command line, ELPA Syncer, 2021/08/29