changeset 50397:a3e1934e4ead

(asm-mode-syntax-table): Setup entries that do not depend on asm-comment-char. (asm-mode-map): Declare and init at the same time. (asm-code-level-empty-comment-pattern) (asm-flush-left-empty-comment-pattern) (asm-inline-empty-comment-pattern): Use \s< so they do not depend on asm-comment-char. Turn them into constants. (asm-mode): Simplify. (asm-line-matches): Remove unused arg.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 01 Apr 2003 23:09:13 +0000
parents 20c113076e20
children 1b58100e624c
files lisp/progmodes/asm-mode.el
diffstat 1 files changed, 30 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/asm-mode.el	Tue Apr 01 18:08:13 2003 +0000
+++ b/lisp/progmodes/asm-mode.el	Tue Apr 01 23:09:13 2003 +0000
@@ -58,27 +58,29 @@
   :type 'character
   :group 'asm)
 
-(defvar asm-mode-syntax-table nil
+(defvar asm-mode-syntax-table
+  (let ((st (make-syntax-table)))
+    (modify-syntax-entry ?\n ">" st)
+    (modify-syntax-entry ?/  ". 14b" st)
+    (modify-syntax-entry ?*  ". 23b" st)
+    st)
   "Syntax table used while in Asm mode.")
 
 (defvar asm-mode-abbrev-table nil
   "Abbrev table used while in Asm mode.")
 (define-abbrev-table 'asm-mode-abbrev-table ())
 
-(defvar asm-mode-map nil
+(defvar asm-mode-map
+  (let ((map (make-sparse-keymap)))
+    ;; Note that the comment character isn't set up until asm-mode is called.
+    (define-key map ":"		'asm-colon)
+    (define-key map "\C-c;"	'comment-region)
+    (define-key map "\C-i"	'tab-to-tab-stop)
+    (define-key map "\C-j"	'asm-newline)
+    (define-key map "\C-m"	'asm-newline)
+    map)
   "Keymap for Asm mode.")
 
-(if asm-mode-map
-    nil
-  (setq asm-mode-map (make-sparse-keymap))
-  ;; Note that the comment character isn't set up until asm-mode is called.
-  (define-key asm-mode-map ":"		'asm-colon)
-  (define-key asm-mode-map "\C-c;"      'comment-region)
-  (define-key asm-mode-map "\C-i"	'tab-to-tab-stop)
-  (define-key asm-mode-map "\C-j"	'asm-newline)
-  (define-key asm-mode-map "\C-m"	'asm-newline)
-  )
-
 (defconst asm-font-lock-keywords
  '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?"
     (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
@@ -86,9 +88,9 @@
     2 font-lock-keyword-face))
  "Additional expressions to highlight in Assembler mode.")
 
-(defvar asm-code-level-empty-comment-pattern nil)
-(defvar asm-flush-left-empty-comment-pattern nil)
-(defvar asm-inline-empty-comment-pattern nil)
+(defconst asm-code-level-empty-comment-pattern "^[\t ]+\\s<\\s< *$")
+(defconst asm-flush-left-empty-comment-pattern "^\\s<\\s<\\s< *$")
+(defconst asm-inline-empty-comment-pattern "^.+\\s<+ *$")
 
 ;;;###autoload
 (defun asm-mode ()
@@ -109,8 +111,7 @@
 Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.
 
 Special commands:
-\\{asm-mode-map}
-"
+\\{asm-mode-map}"
   (interactive)
   (kill-all-local-variables)
   (setq mode-name "Assembler")
@@ -118,35 +119,21 @@
   (setq local-abbrev-table asm-mode-abbrev-table)
   (make-local-variable 'font-lock-defaults)
   (setq font-lock-defaults '(asm-font-lock-keywords))
-  (make-local-variable 'asm-mode-syntax-table)
-  (setq asm-mode-syntax-table (make-syntax-table))
-  (set-syntax-table asm-mode-syntax-table)
 
   (run-hooks 'asm-mode-set-comment-hook)
   ;; Make our own local child of asm-mode-map
   ;; so we can define our own comment character.
   (use-local-map (nconc (make-sparse-keymap) asm-mode-map))
   (local-set-key (vector asm-comment-char) 'asm-comment)
-
-  (modify-syntax-entry	asm-comment-char
-			"< b" asm-mode-syntax-table)
-  (modify-syntax-entry	?\n
-			 "> b" asm-mode-syntax-table)
-
-  (modify-syntax-entry ?/  ". 14" asm-mode-syntax-table)
-  (modify-syntax-entry ?*  ". 23" asm-mode-syntax-table)
+  (set-syntax-table (make-syntax-table asm-mode-syntax-table))
+  (modify-syntax-entry	asm-comment-char "<")
 
-  (let ((cs (regexp-quote (char-to-string asm-comment-char))))
-    (make-local-variable 'comment-start)
-    (setq comment-start (concat (char-to-string asm-comment-char) " "))
-    (make-local-variable 'comment-start-skip)
-    (setq comment-start-skip (concat cs "+[ \t]*" "\\|" "/\\*+ *"))
-    (make-local-variable 'comment-end-skip)
-    (setq comment-end-skip  "[ \t]*\\(\\s>\\|\\*+/\\)")
-    (setq asm-inline-empty-comment-pattern (concat "^.+" cs "+ *$"))
-    (setq asm-code-level-empty-comment-pattern (concat "^[\t ]+" cs cs " *$"))
-    (setq asm-flush-left-empty-comment-pattern (concat "^" cs cs cs " *$"))
-    )
+  (make-local-variable 'comment-start)
+  (setq comment-start (string asm-comment-char ?\ ))
+  (make-local-variable 'comment-start-skip)
+  (setq comment-start-skip "\\(?:\\s<+\\|/\\*+\\)[ \t]*")
+  (make-local-variable 'comment-end-skip)
+  (setq comment-end-skip  "[ \t]*\\(\\s>\\|\\*+/\\)")
   (make-local-variable 'comment-end)
   (setq comment-end "")
   (setq fill-prefix "\t")
@@ -171,7 +158,7 @@
   (tab-to-tab-stop)
   )
 
-(defun asm-line-matches (pattern &optional withcomment)
+(defun asm-line-matches (pattern)
   (save-excursion
     (beginning-of-line)
     (looking-at pattern)))
@@ -187,8 +174,7 @@
   (if (bolp)
       nil
     (beginning-of-line)
-    (open-line 1))
-  )
+    (open-line 1)))
 
 
 (defun asm-comment ()
@@ -234,9 +220,7 @@
 
    ;; If all else fails, insert character
    (t
-    (insert asm-comment-char))
-
-   )
+    (insert asm-comment-char)))
   (end-of-line))
 
 (provide 'asm-mode)