[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 35f3f8d 080/184: Avoid having text syntax-property
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 35f3f8d 080/184: Avoid having text syntax-property changes mark buffer as modified |
Date: |
Sun, 29 Aug 2021 11:03:19 -0400 (EDT) |
branch: elpa/gnuplot
commit 35f3f8d195b5d92f16b24fbaabfa772ee63ab6d0
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 | 129 ++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 77 insertions(+), 52 deletions(-)
diff --git a/gnuplot.el b/gnuplot.el
index 9740fd7..73ba8d8 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -407,6 +407,29 @@ real work."
(funcall fun)
(add-hook 'gnuplot-load-hook fun)))
+;; 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)))
@@ -1782,8 +1805,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))))
@@ -1797,56 +1821,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 1488629 174/184: Fix font-lock not loading., (continued)
- [nongnu] elpa/gnuplot 1488629 174/184: Fix font-lock not loading., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 5fd785c 178/184: Fix test runner, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 65b58b2 175/184: Fix cl deprecation (#68), ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 6a192ef 176/184: Fix more deprecated functions., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 58a1cf5 024/184: Fixed horrible bug in gnuplot-in-string/gnuplot-in-comment, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0d9c0af 025/184: Better method for scanning strings/comments., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 84933f0 029/184: Allow single quoted strings to include '' as an escape for ', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot c97f028 078/184: use a defsubst instead of defmacro in debug-context, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f710394 057/184: Add keys C-M-x (evaluate region) and C-j (evaluate line and newline), ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 54f3882 070/184: Silence another compiler warning by using with-current-buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 35f3f8d 080/184: Avoid having text syntax-property changes mark buffer as modified,
ELPA Syncer <=
- [nongnu] elpa/gnuplot fdd3e1e 101/184: * README.org: update installation section for el-get users., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 35a8a19 108/184: Check for `syntax-propertize-function' when defining syntax-table, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4cd89ab 109/184: Replace ad-hoc scanning with syntax-propertize-rules, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 09ff207 131/184: Remove un-needed `gnuplot-context-mode-p` function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d6f8598 121/184: Cleanup inline-image mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a885233 124/184: Cleanup workaround for window-full-height-p, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 99c3855 130/184: Move gnuplot-context-sensitive-mode into gnuplot.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2ec49e9 139/184: Update GitHub url, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4b267b8 146/184: Merge pull request #44 from conao3/change-license, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 4d04c86 150/184: remove weird char, ELPA Syncer, 2021/08/29