aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-04-01 23:09:13 +0000
committerStefan Monnier2003-04-01 23:09:13 +0000
commitc7d565f4dcc8d231d9c12825efebe419d6c06495 (patch)
tree590e46d27de1aa86bc18450e64cdadcac0321324
parent8064e321d002385ebc110f9a400db975c526537e (diff)
downloademacs-c7d565f4dcc8d231d9c12825efebe419d6c06495.tar.gz
emacs-c7d565f4dcc8d231d9c12825efebe419d6c06495.zip
(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.
-rw-r--r--lisp/progmodes/asm-mode.el78
1 files changed, 31 insertions, 47 deletions
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index 48ca22ce259..483ac4ea2cb 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -58,27 +58,29 @@
58 :type 'character 58 :type 'character
59 :group 'asm) 59 :group 'asm)
60 60
61(defvar asm-mode-syntax-table nil 61(defvar asm-mode-syntax-table
62 (let ((st (make-syntax-table)))
63 (modify-syntax-entry ?\n ">" st)
64 (modify-syntax-entry ?/ ". 14b" st)
65 (modify-syntax-entry ?* ". 23b" st)
66 st)
62 "Syntax table used while in Asm mode.") 67 "Syntax table used while in Asm mode.")
63 68
64(defvar asm-mode-abbrev-table nil 69(defvar asm-mode-abbrev-table nil
65 "Abbrev table used while in Asm mode.") 70 "Abbrev table used while in Asm mode.")
66(define-abbrev-table 'asm-mode-abbrev-table ()) 71(define-abbrev-table 'asm-mode-abbrev-table ())
67 72
68(defvar asm-mode-map nil 73(defvar asm-mode-map
74 (let ((map (make-sparse-keymap)))
75 ;; Note that the comment character isn't set up until asm-mode is called.
76 (define-key map ":" 'asm-colon)
77 (define-key map "\C-c;" 'comment-region)
78 (define-key map "\C-i" 'tab-to-tab-stop)
79 (define-key map "\C-j" 'asm-newline)
80 (define-key map "\C-m" 'asm-newline)
81 map)
69 "Keymap for Asm mode.") 82 "Keymap for Asm mode.")
70 83
71(if asm-mode-map
72 nil
73 (setq asm-mode-map (make-sparse-keymap))
74 ;; Note that the comment character isn't set up until asm-mode is called.
75 (define-key asm-mode-map ":" 'asm-colon)
76 (define-key asm-mode-map "\C-c;" 'comment-region)
77 (define-key asm-mode-map "\C-i" 'tab-to-tab-stop)
78 (define-key asm-mode-map "\C-j" 'asm-newline)
79 (define-key asm-mode-map "\C-m" 'asm-newline)
80 )
81
82(defconst asm-font-lock-keywords 84(defconst asm-font-lock-keywords
83 '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?" 85 '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?"
84 (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) 86 (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
@@ -86,9 +88,9 @@
86 2 font-lock-keyword-face)) 88 2 font-lock-keyword-face))
87 "Additional expressions to highlight in Assembler mode.") 89 "Additional expressions to highlight in Assembler mode.")
88 90
89(defvar asm-code-level-empty-comment-pattern nil) 91(defconst asm-code-level-empty-comment-pattern "^[\t ]+\\s<\\s< *$")
90(defvar asm-flush-left-empty-comment-pattern nil) 92(defconst asm-flush-left-empty-comment-pattern "^\\s<\\s<\\s< *$")
91(defvar asm-inline-empty-comment-pattern nil) 93(defconst asm-inline-empty-comment-pattern "^.+\\s<+ *$")
92 94
93;;;###autoload 95;;;###autoload
94(defun asm-mode () 96(defun asm-mode ()
@@ -109,8 +111,7 @@ which is called near the beginning of mode initialization.
109Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization. 111Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.
110 112
111Special commands: 113Special commands:
112\\{asm-mode-map} 114\\{asm-mode-map}"
113"
114 (interactive) 115 (interactive)
115 (kill-all-local-variables) 116 (kill-all-local-variables)
116 (setq mode-name "Assembler") 117 (setq mode-name "Assembler")
@@ -118,35 +119,21 @@ Special commands:
118 (setq local-abbrev-table asm-mode-abbrev-table) 119 (setq local-abbrev-table asm-mode-abbrev-table)
119 (make-local-variable 'font-lock-defaults) 120 (make-local-variable 'font-lock-defaults)
120 (setq font-lock-defaults '(asm-font-lock-keywords)) 121 (setq font-lock-defaults '(asm-font-lock-keywords))
121 (make-local-variable 'asm-mode-syntax-table)
122 (setq asm-mode-syntax-table (make-syntax-table))
123 (set-syntax-table asm-mode-syntax-table)
124 122
125 (run-hooks 'asm-mode-set-comment-hook) 123 (run-hooks 'asm-mode-set-comment-hook)
126 ;; Make our own local child of asm-mode-map 124 ;; Make our own local child of asm-mode-map
127 ;; so we can define our own comment character. 125 ;; so we can define our own comment character.
128 (use-local-map (nconc (make-sparse-keymap) asm-mode-map)) 126 (use-local-map (nconc (make-sparse-keymap) asm-mode-map))
129 (local-set-key (vector asm-comment-char) 'asm-comment) 127 (local-set-key (vector asm-comment-char) 'asm-comment)
130 128 (set-syntax-table (make-syntax-table asm-mode-syntax-table))
131 (modify-syntax-entry asm-comment-char 129 (modify-syntax-entry asm-comment-char "<")
132 "< b" asm-mode-syntax-table) 130
133 (modify-syntax-entry ?\n 131 (make-local-variable 'comment-start)
134 "> b" asm-mode-syntax-table) 132 (setq comment-start (string asm-comment-char ?\ ))
135 133 (make-local-variable 'comment-start-skip)
136 (modify-syntax-entry ?/ ". 14" asm-mode-syntax-table) 134 (setq comment-start-skip "\\(?:\\s<+\\|/\\*+\\)[ \t]*")
137 (modify-syntax-entry ?* ". 23" asm-mode-syntax-table) 135 (make-local-variable 'comment-end-skip)
138 136 (setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
139 (let ((cs (regexp-quote (char-to-string asm-comment-char))))
140 (make-local-variable 'comment-start)
141 (setq comment-start (concat (char-to-string asm-comment-char) " "))
142 (make-local-variable 'comment-start-skip)
143 (setq comment-start-skip (concat cs "+[ \t]*" "\\|" "/\\*+ *"))
144 (make-local-variable 'comment-end-skip)
145 (setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
146 (setq asm-inline-empty-comment-pattern (concat "^.+" cs "+ *$"))
147 (setq asm-code-level-empty-comment-pattern (concat "^[\t ]+" cs cs " *$"))
148 (setq asm-flush-left-empty-comment-pattern (concat "^" cs cs cs " *$"))
149 )
150 (make-local-variable 'comment-end) 137 (make-local-variable 'comment-end)
151 (setq comment-end "") 138 (setq comment-end "")
152 (setq fill-prefix "\t") 139 (setq fill-prefix "\t")
@@ -171,7 +158,7 @@ Special commands:
171 (tab-to-tab-stop) 158 (tab-to-tab-stop)
172 ) 159 )
173 160
174(defun asm-line-matches (pattern &optional withcomment) 161(defun asm-line-matches (pattern)
175 (save-excursion 162 (save-excursion
176 (beginning-of-line) 163 (beginning-of-line)
177 (looking-at pattern))) 164 (looking-at pattern)))
@@ -187,8 +174,7 @@ Special commands:
187 (if (bolp) 174 (if (bolp)
188 nil 175 nil
189 (beginning-of-line) 176 (beginning-of-line)
190 (open-line 1)) 177 (open-line 1)))
191 )
192 178
193 179
194(defun asm-comment () 180(defun asm-comment ()
@@ -234,9 +220,7 @@ repeatedly until you are satisfied with the kind of comment."
234 220
235 ;; If all else fails, insert character 221 ;; If all else fails, insert character
236 (t 222 (t
237 (insert asm-comment-char)) 223 (insert asm-comment-char)))
238
239 )
240 (end-of-line)) 224 (end-of-line))
241 225
242(provide 'asm-mode) 226(provide 'asm-mode)