[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/gnuplot 7350c9d 107/184: Use the syntax-propertize mechani
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/gnuplot 7350c9d 107/184: Use the syntax-propertize mechanism instead of after-change-functions |
Date: |
Sun, 29 Aug 2021 11:03:26 -0400 (EDT) |
branch: elpa/gnuplot
commit 7350c9dbd18edfb01212564089187cd60ec17183
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Use the syntax-propertize mechanism instead of after-change-functions
Apparently fixes #19, but not tested extensively yet.
---
gnuplot.el | 53 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/gnuplot.el b/gnuplot.el
index d789986..3af5f31 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -1825,26 +1825,34 @@ These are highlighted using `font-lock-constant-face'.")
;; Trying to write a regexp to match these rules is horrible, so we
;; use this matching function instead (in GNU Emacs - I can't figure out
;; how to do this in XEmacs.)
-(defun gnuplot-scan-after-change (begin end &optional unused)
+(defun gnuplot-syntax-propertize (begin end)
"Scan a gnuplot script buffer for strings and comments.
-This is called once on the whole buffer when gnuplot-mode is turned on,
-and installed as a hook in `after-change-functions'."
- (save-excursion
- (setq end (progn
- (goto-char end)
- (gnuplot-point-at-end-of-continuation))
- begin (progn
- (goto-char begin)
- (gnuplot-beginning-of-continuation)
- (point)))
-
- (gnuplot-with-silent-modifications
- (remove-text-properties begin (min (1+ end) (point-max))
- '(syntax-table nil)))
+This function is set as the value of `syntax-propertize-function'
+in gnuplot-mode buffers."
+ (gnuplot-with-silent-modifications
+ (remove-text-properties begin (min (1+ end) (point-max))
+ '(syntax-table nil)))
+ (save-excursion
+ (goto-char begin)
(while (gnuplot-scan-next-string-or-comment end))))
+(defun gnuplot-syntax-propertize-extend-region (start end)
+ "Expand the region to syntax-propertize for strings and comments.
+
+This function is added to
+`syntax-propertize-extend-region-functions' in gnuplot-mode
+buffers."
+ (let ((continuation-start
+ (gnuplot-point-at-beginning-of-continuation start))
+ (continuation-end
+ (gnuplot-point-at-end-of-continuation end)))
+ (if (and (= continuation-start start)
+ (= continuation-end end))
+ nil
+ (cons continuation-start continuation-end))))
+
(defun gnuplot-scan-next-string-or-comment (limit)
"Put appropriate syntax-table text properties on the next comment or string.
@@ -2653,19 +2661,21 @@ If there are no continuation lines, move point to
end-of-line."
;; Save-excursion wrappers for the above to return point at beginning
;; or end of continuation
-(defun gnuplot-point-at-beginning-of-continuation ()
+(defun gnuplot-point-at-beginning-of-continuation (&optional pos)
"Return value of point at beginning of the continued block containing point.
If there are no continuation lines, returns point-at-bol."
(save-excursion
+ (when pos (goto-char pos))
(gnuplot-beginning-of-continuation)
(point)))
-(defun gnuplot-point-at-end-of-continuation ()
+(defun gnuplot-point-at-end-of-continuation (&optional pos)
"Return value of point at the end of the continued block containing point.
If there are no continuation lines, returns point-at-eol."
(save-excursion
+ (when pos (goto-char pos))
(gnuplot-end-of-continuation)
(point)))
@@ -3181,13 +3191,16 @@ a list:
(when (fboundp 'turn-on-font-lock)
(turn-on-font-lock))
(progn
- (gnuplot-scan-after-change (point-min) (point-max))
- (add-hook 'after-change-functions 'gnuplot-scan-after-change nil t)
+ ;; Add syntax-propertizing functions to search for strings and comments
+ (setq-local syntax-propertize-function #'gnuplot-scan-after-change)
+ (add-hook 'syntax-propertize-extend-region-functions
+ #'gnuplot-syntax-propertize-extend-region nil t)
+
+ ;; Set up font-lock
(setq font-lock-defaults gnuplot-font-lock-defaults)
(set (make-local-variable 'font-lock-multiline) t)
(set (make-local-variable 'parse-sexp-lookup-properties) t)))
-
(if (fboundp 'widget-create) ; gnuplot-gui
(condition-case ()
(require 'gnuplot-gui)
- [nongnu] elpa/gnuplot c827a90 090/184: Load gnuplot-eldoc only if needed, (continued)
- [nongnu] elpa/gnuplot c827a90 090/184: Load gnuplot-eldoc only if needed, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot cabfc6c 088/184: fix annoying delay in indentation with blinking paren mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 327d564 091/184: Fix indentation: only outdent a maximum of one closing brace per line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7046fe1 092/184: Misc cleanup and documentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot a25b290 094/184: Update README for new release., ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 0134457 098/184: Add configure scripts, etc. back to repository for easier building, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 1b8e0e3 095/184: Update included info file for Gnuplot 4.6, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot d5eb309 102/184: Merge pull request #17 from yyr/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ae7c4b4 104/184: readme tweaks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 483a71f 103/184: Update documentation on installing, and tweak Makefile.dst, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7350c9d 107/184: Use the syntax-propertize mechanism instead of after-change-functions,
ELPA Syncer <=
- [nongnu] elpa/gnuplot 4c5092a 115/184: Merge branch 'syntax-propertize', ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot edd779a 114/184: Fix context tests for syntax-propertize, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 156d6a9 120/184: Add option to send plot output to a dedicated buffer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot ba3728a 113/184: Fix syntax-propertize rules for empty strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 08fe8e0 117/184: Try to make tests runnable on older Emacs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 7f53432 132/184: Clarify `gnuplot-comint-complete` docstring, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 2442835 127/184: Use completion-at-point in comint buffers in recent Emacs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot f3734b6 136/184: Add Jon as author, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 3f28986 134/184: Fix compiler warnings, comments and docstrings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/gnuplot 21f9046 135/184: Bind appropriate completion command in comint mode, ELPA Syncer, 2021/08/29