[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f0f960050b 3/3: Normalize some syntax table definitions
From: |
Stefan Kangas |
Subject: |
master f0f960050b 3/3: Normalize some syntax table definitions |
Date: |
Fri, 4 Nov 2022 10:16:22 -0400 (EDT) |
branch: master
commit f0f960050b1d3931331bf0ce42d2e106f8c7832b
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
Normalize some syntax table definitions
* lisp/nxml/rng-cmpct.el (rng-c-syntax-table):
* lisp/progmodes/cperl-mode.el (cperl-mode-syntax-table)
(cperl-string-syntax-table2):
* lisp/progmodes/dcl-mode.el (dcl-mode-syntax-table): Normalize
definitions to better follow modern ELisp conventions.
---
lisp/nxml/rng-cmpct.el | 22 +++++++--------
lisp/progmodes/cperl-mode.el | 66 +++++++++++++++++++++-----------------------
lisp/progmodes/dcl-mode.el | 18 ++++++------
3 files changed, 50 insertions(+), 56 deletions(-)
diff --git a/lisp/nxml/rng-cmpct.el b/lisp/nxml/rng-cmpct.el
index 453c2b736d..85db33b9a9 100644
--- a/lisp/nxml/rng-cmpct.el
+++ b/lisp/nxml/rng-cmpct.el
@@ -1,6 +1,6 @@
;;; rng-cmpct.el --- parsing of RELAX NG Compact Syntax schemas -*-
lexical-binding:t -*-
-;; Copyright (C) 2003, 2007-2022 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2022 Free Software Foundation, Inc.
;; Author: James Clark
;; Keywords: wp, hypermedia, languages, XML, RelaxNG
@@ -82,19 +82,17 @@ Return a pattern."
(concat "\\`\\(" (regexp-opt rng-c-keywords) "\\)\\'")
"Regular expression to match a keyword in the compact syntax.")
-(defvar rng-c-syntax-table nil
+(defvar rng-c-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?# "<" st)
+ (modify-syntax-entry ?\n ">" st)
+ (modify-syntax-entry ?- "w" st)
+ (modify-syntax-entry ?. "w" st)
+ (modify-syntax-entry ?_ "w" st)
+ (modify-syntax-entry ?: "_" st)
+ st)
"Syntax table for parsing the compact syntax.")
-(if rng-c-syntax-table
- ()
- (setq rng-c-syntax-table (make-syntax-table))
- (modify-syntax-entry ?# "<" rng-c-syntax-table)
- (modify-syntax-entry ?\n ">" rng-c-syntax-table)
- (modify-syntax-entry ?- "w" rng-c-syntax-table)
- (modify-syntax-entry ?. "w" rng-c-syntax-table)
- (modify-syntax-entry ?_ "w" rng-c-syntax-table)
- (modify-syntax-entry ?: "_" rng-c-syntax-table))
-
(defconst rng-c-literal-1-re
"'\\(''\\([^']\\|'[^']\\|''[^']\\)*''\\|[^'\n]*\\)'"
"Regular expression to match a single-quoted literal.")
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index 539b277149..b36896ae7c 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1429,10 +1429,40 @@ the last)."
(rx (sequence line-start (0+ blank) (eval cperl--imenu-entries-rx)))
"The regular expression used for `outline-minor-mode'.")
-(defvar cperl-mode-syntax-table nil
+(defvar cperl-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ (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 ?\n ">" st)
+ (modify-syntax-entry ?# "<" st)
+ (modify-syntax-entry ?' "\"" st)
+ (modify-syntax-entry ?` "\"" st)
+ (if cperl-under-as-char
+ (modify-syntax-entry ?_ "w" st))
+ (modify-syntax-entry ?: "_" st)
+ (modify-syntax-entry ?| "." st)
+ st)
"Syntax table in use in CPerl mode buffers.")
-(defvar cperl-string-syntax-table nil
+(defvar cperl-string-syntax-table
+ (let ((st (copy-syntax-table cperl-mode-syntax-table)))
+ (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) ; (?# comment )
+ st)
"Syntax table in use in CPerl mode string-like chunks.")
(defsubst cperl-1- (p)
@@ -1441,38 +1471,6 @@ the last)."
(defsubst cperl-1+ (p)
(min (point-max) (1+ p)))
-(if cperl-mode-syntax-table
- ()
- (setq cperl-mode-syntax-table (make-syntax-table))
- (modify-syntax-entry ?\\ "\\" cperl-mode-syntax-table)
- (modify-syntax-entry ?/ "." cperl-mode-syntax-table)
- (modify-syntax-entry ?* "." cperl-mode-syntax-table)
- (modify-syntax-entry ?+ "." cperl-mode-syntax-table)
- (modify-syntax-entry ?- "." cperl-mode-syntax-table)
- (modify-syntax-entry ?= "." cperl-mode-syntax-table)
- (modify-syntax-entry ?% "." cperl-mode-syntax-table)
- (modify-syntax-entry ?< "." cperl-mode-syntax-table)
- (modify-syntax-entry ?> "." cperl-mode-syntax-table)
- (modify-syntax-entry ?& "." cperl-mode-syntax-table)
- (modify-syntax-entry ?$ "\\" cperl-mode-syntax-table)
- (modify-syntax-entry ?\n ">" cperl-mode-syntax-table)
- (modify-syntax-entry ?# "<" cperl-mode-syntax-table)
- (modify-syntax-entry ?' "\"" cperl-mode-syntax-table)
- (modify-syntax-entry ?` "\"" cperl-mode-syntax-table)
- (if cperl-under-as-char
- (modify-syntax-entry ?_ "w" cperl-mode-syntax-table))
- (modify-syntax-entry ?: "_" cperl-mode-syntax-table)
- (modify-syntax-entry ?| "." cperl-mode-syntax-table)
- (setq cperl-string-syntax-table (copy-syntax-table cperl-mode-syntax-table))
- (modify-syntax-entry ?$ "." cperl-string-syntax-table)
- (modify-syntax-entry ?\{ "." cperl-string-syntax-table)
- (modify-syntax-entry ?\} "." cperl-string-syntax-table)
- (modify-syntax-entry ?\" "." cperl-string-syntax-table)
- (modify-syntax-entry ?' "." cperl-string-syntax-table)
- (modify-syntax-entry ?` "." cperl-string-syntax-table)
- (modify-syntax-entry ?# "." cperl-string-syntax-table)) ; (?# comment )
-
-
(defvar cperl-faces-init nil)
;; Fix for msb.el
diff --git a/lisp/progmodes/dcl-mode.el b/lisp/progmodes/dcl-mode.el
index 1f363931b3..f1d7f236b9 100644
--- a/lisp/progmodes/dcl-mode.el
+++ b/lisp/progmodes/dcl-mode.el
@@ -258,17 +258,15 @@ See `imenu-generic-expression' for details."
;;; *** Global variables ****************************************************
-(defvar dcl-mode-syntax-table nil
+(defvar dcl-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?! "<" st) ; comment start
+ (modify-syntax-entry ?\n ">" st) ; comment end
+ (modify-syntax-entry ?< "(>" st) ; < and ...
+ (modify-syntax-entry ?> ")<" st) ; > is a matching pair
+ (modify-syntax-entry ?\\ "_" st) ; not an escape
+ st)
"Syntax table used in DCL-buffers.")
-(unless dcl-mode-syntax-table
- (setq dcl-mode-syntax-table (make-syntax-table))
- (modify-syntax-entry ?! "<" dcl-mode-syntax-table) ; comment start
- (modify-syntax-entry ?\n ">" dcl-mode-syntax-table) ; comment end
- (modify-syntax-entry ?< "(>" dcl-mode-syntax-table) ; < and ...
- (modify-syntax-entry ?> ")<" dcl-mode-syntax-table) ; > is a matching pair
- (modify-syntax-entry ?\\ "_" dcl-mode-syntax-table) ; not an escape
-)
-
(defvar-keymap dcl-mode-map
:doc "Keymap used in DCL-mode buffers."