summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2015-10-21 15:44:07 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-10-21 15:44:07 (GMT)
commite1094653a4c742d9498100afaf66fadbf70dc207 (patch) (side-by-side diff)
treeda8dcd70ad7d2f48995af675b15625356ce692f4
parente217607915ae4d3a486a4b4e0fafeb34b8247d0f (diff)
downloadvcl-mode-emacs23.tar.gz
vcl-mode-emacs23.tar.bz2
Support for emacs23emacs23
It contains some provisions for switching between 23 and 24, but cannot (at least yet) be used pn both without changes. I doubt if that's needed anyway. Emacs 23 does not have syntax-propertize-function, so # comment and {" "} strings are recognized using font-lock-syntactic-keywords. In other words, font-lock-mode must be on for them to be recognized properly.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--vcl-mode.el107
1 files changed, 61 insertions, 46 deletions
diff --git a/vcl-mode.el b/vcl-mode.el
index c6ea5e1..b3e8a26 100644
--- a/vcl-mode.el
+++ b/vcl-mode.el
@@ -40,26 +40,10 @@
(defvar vcl-mode-syntax-table
(let ((st (make-syntax-table)))
- (modify-syntax-entry ?\n "> b" st)
- (modify-syntax-entry ?\r "> " st)
- (modify-syntax-entry ?\f "> " st)
-; (modify-syntax-entry ?\# "<" st)
- (modify-syntax-entry ?/ ". 124b" st)
- (modify-syntax-entry ?* ". 23" st)
- (modify-syntax-entry ?+ "." st)
- (modify-syntax-entry ?- "." st)
- (modify-syntax-entry ?~ "." st)
- (modify-syntax-entry ?= "." st)
- (modify-syntax-entry ?% "." st)
- (modify-syntax-entry ?< "." st)
- (modify-syntax-entry ?> "." st)
- (modify-syntax-entry ?& "." st)
- (modify-syntax-entry ?| "." st)
- (modify-syntax-entry ?_ "_" st)
(modify-syntax-entry ?\' "." st)
- (modify-syntax-entry ?\" "." st)
- (modify-syntax-entry ?{ "." st)
- (modify-syntax-entry ?} "." st)
+ ;; (modify-syntax-entry ?\" "." st)
+ ;; (modify-syntax-entry ?{ "." st)
+ ;; (modify-syntax-entry ?} "." st)
st)
"Syntax table in use in VCL Mode buffers.")
@@ -322,44 +306,75 @@
(put-text-property (point) (+ (point) 1)
'syntax-table (string-to-syntax ">")))))))
-(defconst vcl-syntax-propertize-function
- (syntax-propertize-rules
- ("\\({\\)\""
- (1 "|"))
- ("\\({\\)[^\"]"
- (1 "(}"))
- ("\"\\(}\\)"
- (1 "|"))
- ("\\(^\\|[^\"]\\)\\(}\\)"
- (2 "){"))
- ("\\(\"\\)[^}]"
- (1 (let ((syntax (save-match-data (syntax-ppss))))
- (string-to-syntax
- (cond ((nth 4 syntax)
- ".")
- ((eq (nth 3 syntax) t)
- (backward-char)
- ".")
- (t
- (backward-char)
- "\""))))))
- ("\\(#\\)"
- (1 (ignore (vcl-sharp-comment-syntax))))
- ))
+(cond
+ ((and (>= emacs-major-version 24) (>= emacs-minor-version 1))
+ (defconst vcl-syntax-propertize-function
+ (syntax-propertize-rules
+ ("\\({\\)\""
+ (1 "|"))
+ ("\\({\\)[^\"]"
+ (1 "(}"))
+ ("\"\\(}\\)"
+ (1 "|"))
+ ("\\(^\\|[^\"]\\)\\(}\\)"
+ (2 "){"))
+ ("\\(\"\\)[^}]"
+ (1 (let ((syntax (save-match-data (syntax-ppss))))
+ (string-to-syntax
+ (cond ((nth 4 syntax)
+ ".")
+ ((eq (nth 3 syntax) t)
+ (backward-char)
+ ".")
+ (t
+ (backward-char)
+ "\""))))))
+ ("\\(#\\)"
+ (1 (ignore (vcl-sharp-comment-syntax)))) )))
+ (t
+ (defconst vcl-font-lock-syntactic-keywords
+ '(("\\({\\)\""
+ 1 "|")
+ ("\\({\\)[^\"]"
+ 1 "(}")
+ ("\"\\(}\\)"
+ 1 "|")
+ ("\\(^\\|[^\"]\\)\\(}\\)"
+ 2 "){")
+ ("\\(\"\\)[^}]"
+ 1 (let ((syntax (save-match-data (syntax-ppss))))
+ (string-to-syntax
+ (cond ((nth 4 syntax)
+ ".")
+ ((eq (nth 3 syntax) t)
+ (backward-char)
+ ".")
+ (t
+ (backward-char)
+ "\"")))))
+ ("\\(#\\)"
+ (1 (ignore (vcl-sharp-comment-syntax)))) ))) )
;;;###autoload
(add-to-list 'auto-mode-alist (cons (purecopy "\\.vcl\\'") 'vcl-mode))
;;;###autoload
-(define-derived-mode vcl-mode prog-mode "VCL"
+(define-derived-mode vcl-mode c-mode "VCL"
"Major mode for editing VCL code.
Key bindings:
\\{vcl-mode-map}"
- (set (make-local-variable 'syntax-propertize-function)
- vcl-syntax-propertize-function)
+ (cond
+ ((and (>= emacs-major-version 24) (>= emacs-minor-version 1))
+ (set (make-local-variable 'syntax-propertize-function)
+ vcl-syntax-propertize-function))
+ (t
+ (set (make-local-variable 'font-lock-syntactic-keywords)
+ vcl-font-lock-syntactic-keywords)))
+
(set (make-local-variable 'parse-sexp-lookup-properties) t)
+ (set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'comment-start) "# ")
(c-initialize-cc-mode t)

Return to:

Send suggestions and report system problems to the System administrator.