aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-10-21 18:44:07 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2015-10-21 18:44:07 +0300
commite1094653a4c742d9498100afaf66fadbf70dc207 (patch)
treeda8dcd70ad7d2f48995af675b15625356ce692f4
parente217607915ae4d3a486a4b4e0fafeb34b8247d0f (diff)
downloadvcl-mode-e1094653a4c742d9498100afaf66fadbf70dc207.tar.gz
vcl-mode-e1094653a4c742d9498100afaf66fadbf70dc207.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.
-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 @@
40 40
41(defvar vcl-mode-syntax-table 41(defvar vcl-mode-syntax-table
42 (let ((st (make-syntax-table))) 42 (let ((st (make-syntax-table)))
43 (modify-syntax-entry ?\n "> b" st)
44 (modify-syntax-entry ?\r "> " st)
45 (modify-syntax-entry ?\f "> " st)
46; (modify-syntax-entry ?\# "<" st)
47 (modify-syntax-entry ?/ ". 124b" st)
48 (modify-syntax-entry ?* ". 23" st)
49 (modify-syntax-entry ?+ "." st)
50 (modify-syntax-entry ?- "." st)
51 (modify-syntax-entry ?~ "." st)
52 (modify-syntax-entry ?= "." st)
53 (modify-syntax-entry ?% "." st)
54 (modify-syntax-entry ?< "." st)
55 (modify-syntax-entry ?> "." st)
56 (modify-syntax-entry ?& "." st)
57 (modify-syntax-entry ?| "." st)
58 (modify-syntax-entry ?_ "_" st)
59 (modify-syntax-entry ?\' "." st) 43 (modify-syntax-entry ?\' "." st)
60 (modify-syntax-entry ?\" "." st) 44 ;; (modify-syntax-entry ?\" "." st)
61 (modify-syntax-entry ?{ "." st) 45 ;; (modify-syntax-entry ?{ "." st)
62 (modify-syntax-entry ?} "." st) 46 ;; (modify-syntax-entry ?} "." st)
63 st) 47 st)
64 "Syntax table in use in VCL Mode buffers.") 48 "Syntax table in use in VCL Mode buffers.")
65 49
@@ -322,44 +306,75 @@
322 (put-text-property (point) (+ (point) 1) 306 (put-text-property (point) (+ (point) 1)
323 'syntax-table (string-to-syntax ">"))))))) 307 'syntax-table (string-to-syntax ">")))))))
324 308
325(defconst vcl-syntax-propertize-function 309(cond
326 (syntax-propertize-rules 310 ((and (>= emacs-major-version 24) (>= emacs-minor-version 1))
327 ("\\({\\)\"" 311 (defconst vcl-syntax-propertize-function
328 (1 "|")) 312 (syntax-propertize-rules
329 ("\\({\\)[^\"]" 313 ("\\({\\)\""
330 (1 "(}")) 314 (1 "|"))
331 ("\"\\(}\\)" 315 ("\\({\\)[^\"]"
332 (1 "|")) 316 (1 "(}"))
333 ("\\(^\\|[^\"]\\)\\(}\\)" 317 ("\"\\(}\\)"
334 (2 "){")) 318 (1 "|"))
335 ("\\(\"\\)[^}]" 319 ("\\(^\\|[^\"]\\)\\(}\\)"
336 (1 (let ((syntax (save-match-data (syntax-ppss)))) 320 (2 "){"))
337 (string-to-syntax 321 ("\\(\"\\)[^}]"
338 (cond ((nth 4 syntax) 322 (1 (let ((syntax (save-match-data (syntax-ppss))))
339 ".") 323 (string-to-syntax
340 ((eq (nth 3 syntax) t) 324 (cond ((nth 4 syntax)
341 (backward-char) 325 ".")
342 ".") 326 ((eq (nth 3 syntax) t)
343 (t 327 (backward-char)
344 (backward-char) 328 ".")
345 "\"")))))) 329 (t
346 ("\\(#\\)" 330 (backward-char)
347 (1 (ignore (vcl-sharp-comment-syntax)))) 331 "\""))))))
348 )) 332 ("\\(#\\)"
333 (1 (ignore (vcl-sharp-comment-syntax)))) )))
334 (t
335 (defconst vcl-font-lock-syntactic-keywords
336 '(("\\({\\)\""
337 1 "|")
338 ("\\({\\)[^\"]"
339 1 "(}")
340 ("\"\\(}\\)"
341 1 "|")
342 ("\\(^\\|[^\"]\\)\\(}\\)"
343 2 "){")
344 ("\\(\"\\)[^}]"
345 1 (let ((syntax (save-match-data (syntax-ppss))))
346 (string-to-syntax
347 (cond ((nth 4 syntax)
348 ".")
349 ((eq (nth 3 syntax) t)
350 (backward-char)
351 ".")
352 (t
353 (backward-char)
354 "\"")))))
355 ("\\(#\\)"
356 (1 (ignore (vcl-sharp-comment-syntax)))) ))) )
349 357
350;;;###autoload 358;;;###autoload
351(add-to-list 'auto-mode-alist (cons (purecopy "\\.vcl\\'") 'vcl-mode)) 359(add-to-list 'auto-mode-alist (cons (purecopy "\\.vcl\\'") 'vcl-mode))
352 360
353;;;###autoload 361;;;###autoload
354(define-derived-mode vcl-mode prog-mode "VCL" 362(define-derived-mode vcl-mode c-mode "VCL"
355 "Major mode for editing VCL code. 363 "Major mode for editing VCL code.
356 364
357Key bindings: 365Key bindings:
358\\{vcl-mode-map}" 366\\{vcl-mode-map}"
359 367
360 (set (make-local-variable 'syntax-propertize-function) 368 (cond
361 vcl-syntax-propertize-function) 369 ((and (>= emacs-major-version 24) (>= emacs-minor-version 1))
370 (set (make-local-variable 'syntax-propertize-function)
371 vcl-syntax-propertize-function))
372 (t
373 (set (make-local-variable 'font-lock-syntactic-keywords)
374 vcl-font-lock-syntactic-keywords)))
375
362 (set (make-local-variable 'parse-sexp-lookup-properties) t) 376 (set (make-local-variable 'parse-sexp-lookup-properties) t)
377 (set (make-local-variable 'parse-sexp-ignore-comments) t)
363 (set (make-local-variable 'comment-start) "# ") 378 (set (make-local-variable 'comment-start) "# ")
364 379
365 (c-initialize-cc-mode t) 380 (c-initialize-cc-mode t)

Return to:

Send suggestions and report system problems to the System administrator.