aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-04-02 16:48:11 +0000
committerStefan Monnier2003-04-02 16:48:11 +0000
commitdfc42f38c1d0d3ff0ea55f671d8bf207c90c9efa (patch)
treee3fbe3db7915238f44e7efcc224302910b22ebd3
parent6d91a595e02c8fc4d29daf6caf2dceb3a6018163 (diff)
downloademacs-dfc42f38c1d0d3ff0ea55f671d8bf207c90c9efa.tar.gz
emacs-dfc42f38c1d0d3ff0ea55f671d8bf207c90c9efa.zip
(asm-calculate-indentation, asm-indent-line): New functions.
(asm-mode): Use them in indent-line-function. Set tab-always-indent to nil to stay closer to previous tab behavior. Set comment-add. Remove space at end of comment-add. (asm-newline): Obsolete. Use newline-and-indent instead. (asm-mode-map): Remove TAB binding. (asm-code-level-empty-comment-pattern) (asm-flush-left-empty-comment-pattern) (asm-inline-empty-comment-pattern): Remove. (asm-comment): Use newcomment functions instead. (asm-colon): Don't tab if colon is not after a label. (asm-line-matches, asm-pop-comment-level): Remove.
-rw-r--r--lisp/ChangeLog53
-rw-r--r--lisp/progmodes/asm-mode.el147
2 files changed, 119 insertions, 81 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index aa138bc6e68..3837bb7aebf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12003-04-02 Stefan Monnier <monnier@cs.yale.edu>
2
3 * progmodes/asm-mode.el (asm-calculate-indentation, asm-indent-line):
4 New functions.
5 (asm-mode): Use them in indent-line-function.
6 Set tab-always-indent to nil to stay closer to previous tab behavior.
7 Set comment-add. Remove space at end of comment-add.
8 (asm-newline): Obsolete. Use newline-and-indent instead.
9 (asm-mode-map): Remove TAB binding.
10 (asm-code-level-empty-comment-pattern)
11 (asm-flush-left-empty-comment-pattern)
12 (asm-inline-empty-comment-pattern): Remove.
13 (asm-comment): Use newcomment functions instead.
14 (asm-colon): Don't tab if colon is not after a label.
15 (asm-line-matches, asm-pop-comment-level): Remove.
16
12003-04-02 Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net> 172003-04-02 Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
2 18
3 * emulation/crisp.el (top-level): Quote second arg to 19 * emulation/crisp.el (top-level): Quote second arg to
@@ -7,14 +23,26 @@
7 23
8 * scroll-bar.el (scroll-bar-mode): Correctly specify `nil' choice. 24 * scroll-bar.el (scroll-bar-mode): Correctly specify `nil' choice.
9 25
262003-04-01 Stefan Monnier <monnier@cs.yale.edu>
27
28 * progmodes/asm-mode.el (asm-mode-syntax-table): Setup entries
29 that do not depend on asm-comment-char.
30 (asm-mode-map): Declare and init at the same time.
31 (asm-code-level-empty-comment-pattern)
32 (asm-flush-left-empty-comment-pattern)
33 (asm-inline-empty-comment-pattern): Use \s< so they do not depend
34 on asm-comment-char. Turn them into constants.
35 (asm-mode): Simplify.
36 (asm-line-matches): Remove unused arg.
37
102003-04-01 Dave Love <fx@gnu.org> 382003-04-01 Dave Love <fx@gnu.org>
11 39
12 * time.el: Doc fixes. 40 * time.el: Doc fixes.
13 (display-time-mail-face): Change :type and default to nil. 41 (display-time-mail-face): Change :type and default to nil.
14 (display-time-mail-icon): Use pbm, not xbm. 42 (display-time-mail-icon): Use pbm, not xbm.
15 (display-time-mail-string): New. 43 (display-time-mail-string): New.
16 (display-time-string-forms): Use display-time-mail-string. Add 44 (display-time-string-forms): Use display-time-mail-string.
17 checks in display property. 45 Add checks in display property.
18 46
192003-04-01 Kenichi Handa <handa@m17n.org> 472003-04-01 Kenichi Handa <handa@m17n.org>
20 48
@@ -30,6 +58,10 @@
30 * emulation/cua-base.el (cua-set-mark): Unconditionally repeat 58 * emulation/cua-base.el (cua-set-mark): Unconditionally repeat
31 pop-global-mark without C-x prefix. Fix doc. 59 pop-global-mark without C-x prefix. Fix doc.
32 60
612003-03-31 Stefan Monnier <monnier@cs.yale.edu>
62
63 * reveal.el (reveal-post-command): Better error handling.
64
332003-03-31 Nick Roberts <nick@nick.uklinux.net> 652003-03-31 Nick Roberts <nick@nick.uklinux.net>
34 * gdb-ui.el (gdb-inferior-io-mode): Remove Unix pathname for cat 66 * gdb-ui.el (gdb-inferior-io-mode): Remove Unix pathname for cat
35 so that it can run on NT also. 67 so that it can run on NT also.
@@ -56,8 +88,8 @@
56 88
572003-03-31 Kenichi Handa <handa@m17n.org> 892003-03-31 Kenichi Handa <handa@m17n.org>
58 90
59 * international/utf-16.el (ccl-decode-mule-utf-16-le): Don't 91 * international/utf-16.el (ccl-decode-mule-utf-16-le):
60 assume the signature bytes. 92 Don't assume the signature bytes.
61 (ccl-decode-mule-utf-16-be): Likewise. 93 (ccl-decode-mule-utf-16-be): Likewise.
62 (ccl-encode-mule-utf-16-le): Don't produce the signature bytes. 94 (ccl-encode-mule-utf-16-le): Don't produce the signature bytes.
63 (ccl-encode-mule-utf-16-be): Likewise. 95 (ccl-encode-mule-utf-16-be): Likewise.
@@ -88,12 +120,11 @@
88 120
892003-03-29 Michael Albinus <Michael.Albinus@alcatel.de> 1212003-03-29 Michael Albinus <Michael.Albinus@alcatel.de>
90 122
91 * trampver.el: New file, to support Autoconf in Tramp CVS 123 * trampver.el: New file, to support Autoconf in Tramp CVS repository.
92 repository. 124 * tramp.el (tramp-version, tramp-bug-report-address): Move to
93 * tramp.el (tramp-version, tramp-bug-report-address): Moved to
94 trampver.el, which is required now. 125 trampver.el, which is required now.
95 (tramp-chunksize): Type can be nil as well. Reported 126 (tramp-chunksize): Type can be nil as well.
96 by Markus Rost <rost@math.ohio-state.edu>. 127 Reported by Markus Rost <rost@math.ohio-state.edu>.
97 * tramp-smb.el (tramp-smb-read-file-entry): Make reading size of a 128 * tramp-smb.el (tramp-smb-read-file-entry): Make reading size of a
98 listing entry more robust. Ranges from 10 chars (Samba 1) to 7-9 129 listing entry more robust. Ranges from 10 chars (Samba 1) to 7-9
99 chars (Samba 2). 130 chars (Samba 2).
@@ -116,8 +147,8 @@
116 147
1172003-03-28 Lute Kamstra <Lute.Kamstra@cwi.nl> 1482003-03-28 Lute Kamstra <Lute.Kamstra@cwi.nl>
118 149
119 * emacs-lisp/checkdoc.el (checkdoc-display-status-buffer): Fix 150 * emacs-lisp/checkdoc.el (checkdoc-display-status-buffer):
120 docstring. 151 Fix docstring.
121 (checkdoc-interactive, checkdoc-message-interactive): Make them 152 (checkdoc-interactive, checkdoc-message-interactive): Make them
122 perform spell checking when appropriate. 153 perform spell checking when appropriate.
123 (checkdoc-interactive-loop): Fix docstring and a few typos. 154 (checkdoc-interactive-loop): Fix docstring and a few typos.
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index 483ac4ea2cb..862a89e80b7 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -75,9 +75,8 @@
75 ;; Note that the comment character isn't set up until asm-mode is called. 75 ;; Note that the comment character isn't set up until asm-mode is called.
76 (define-key map ":" 'asm-colon) 76 (define-key map ":" 'asm-colon)
77 (define-key map "\C-c;" 'comment-region) 77 (define-key map "\C-c;" 'comment-region)
78 (define-key map "\C-i" 'tab-to-tab-stop) 78 (define-key map "\C-j" 'newline-and-indent)
79 (define-key map "\C-j" 'asm-newline) 79 (define-key map "\C-m" 'newline-and-indent)
80 (define-key map "\C-m" 'asm-newline)
81 map) 80 map)
82 "Keymap for Asm mode.") 81 "Keymap for Asm mode.")
83 82
@@ -88,10 +87,6 @@
88 2 font-lock-keyword-face)) 87 2 font-lock-keyword-face))
89 "Additional expressions to highlight in Assembler mode.") 88 "Additional expressions to highlight in Assembler mode.")
90 89
91(defconst asm-code-level-empty-comment-pattern "^[\t ]+\\s<\\s< *$")
92(defconst asm-flush-left-empty-comment-pattern "^\\s<\\s<\\s< *$")
93(defconst asm-inline-empty-comment-pattern "^.+\\s<+ *$")
94
95;;;###autoload 90;;;###autoload
96(defun asm-mode () 91(defun asm-mode ()
97 "Major mode for editing typical assembler code. 92 "Major mode for editing typical assembler code.
@@ -119,6 +114,9 @@ Special commands:
119 (setq local-abbrev-table asm-mode-abbrev-table) 114 (setq local-abbrev-table asm-mode-abbrev-table)
120 (make-local-variable 'font-lock-defaults) 115 (make-local-variable 'font-lock-defaults)
121 (setq font-lock-defaults '(asm-font-lock-keywords)) 116 (setq font-lock-defaults '(asm-font-lock-keywords))
117 (set (make-local-variable 'indent-line-function) 'asm-indent-line)
118 ;; Stay closer to the old TAB behavior (was tab-to-tab-stop).
119 (set (make-local-variable 'tab-always-indent) nil)
122 120
123 (run-hooks 'asm-mode-set-comment-hook) 121 (run-hooks 'asm-mode-set-comment-hook)
124 ;; Make our own local child of asm-mode-map 122 ;; Make our own local child of asm-mode-map
@@ -129,53 +127,59 @@ Special commands:
129 (modify-syntax-entry asm-comment-char "<") 127 (modify-syntax-entry asm-comment-char "<")
130 128
131 (make-local-variable 'comment-start) 129 (make-local-variable 'comment-start)
132 (setq comment-start (string asm-comment-char ?\ )) 130 (setq comment-start (string asm-comment-char))
131 (make-local-variable 'comment-add)
132 (setq comment-add 1)
133 (make-local-variable 'comment-start-skip) 133 (make-local-variable 'comment-start-skip)
134 (setq comment-start-skip "\\(?:\\s<+\\|/\\*+\\)[ \t]*") 134 (setq comment-start-skip "\\(?:\\s<+\\|/\\*+\\)[ \t]*")
135 (make-local-variable 'comment-end-skip) 135 (make-local-variable 'comment-end-skip)
136 (setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)") 136 (setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
137 (make-local-variable 'comment-end) 137 (make-local-variable 'comment-end)
138 (setq comment-end "") 138 (setq comment-end "")
139 (setq fill-prefix "\t") 139 (setq fill-prefix "\t")
140 (run-hooks 'asm-mode-hook)) 140 (run-mode-hooks 'asm-mode-hook))
141 141
142(defun asm-indent-line ()
143 "Auto-indent the current line."
144 (interactive)
145 (let* ((savep (point))
146 (indent (condition-case nil
147 (save-excursion
148 (forward-line 0)
149 (skip-chars-forward " \t")
150 (if (>= (point) savep) (setq savep nil))
151 (max (asm-calculate-indentation) 0))
152 (error 0))))
153 (if savep
154 (save-excursion (indent-line-to indent))
155 (indent-line-to indent))))
156
157(defun asm-calculate-indentation ()
158 (or
159 ;; Flush labels to the left margin.
160 (and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
161 ;; Same thing for `;;;' comments.
162 (and (looking-at "\\s<\\s<\\s<") 0)
163 ;; Simple `;' comments go to the comment-column.
164 (and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
165 ;; The rest goes at the first tab stop.
166 (or (car tab-stop-list) tab-width)))
167
142(defun asm-colon () 168(defun asm-colon ()
143 "Insert a colon; if it follows a label, delete the label's indentation." 169 "Insert a colon; if it follows a label, delete the label's indentation."
144 (interactive) 170 (interactive)
145 (save-excursion 171 (let ((labelp nil))
146 (beginning-of-line) 172 (save-excursion
147 (if (looking-at "[ \t]+\\(\\sw\\|\\s_\\)+$") 173 (skip-syntax-backward "w_")
148 (delete-horizontal-space))) 174 (skip-syntax-backward " ")
149 (insert ":") 175 (if (setq labelp (bolp)) (delete-horizontal-space)))
150 (tab-to-tab-stop) 176 (call-interactively 'self-insert-command)
151 ) 177 (when labelp
152 178 (delete-horizontal-space)
153(defun asm-newline () 179 (tab-to-tab-stop))))
154 "Insert LFD + fill-prefix, to bring us back to code-indent level." 180
155 (interactive) 181;; Obsolete since Emacs-21.4.
156 (if (eolp) (delete-horizontal-space)) 182(defalias 'asm-newline 'newline-and-indent)
157 (insert "\n")
158 (tab-to-tab-stop)
159 )
160
161(defun asm-line-matches (pattern)
162 (save-excursion
163 (beginning-of-line)
164 (looking-at pattern)))
165
166(defun asm-pop-comment-level ()
167 ;; Delete an empty comment ending current line. Then set up for a new one,
168 ;; on the current line if it was all comment, otherwise above it
169 (end-of-line)
170 (delete-horizontal-space)
171 (while (= (preceding-char) asm-comment-char)
172 (delete-backward-char 1))
173 (delete-horizontal-space)
174 (if (bolp)
175 nil
176 (beginning-of-line)
177 (open-line 1)))
178
179 183
180(defun asm-comment () 184(defun asm-comment ()
181 "Convert an empty comment to a `larger' kind, or start a new one. 185 "Convert an empty comment to a `larger' kind, or start a new one.
@@ -188,40 +192,43 @@ These are the known comment classes:
188Suggested usage: while writing your code, trigger asm-comment 192Suggested usage: while writing your code, trigger asm-comment
189repeatedly until you are satisfied with the kind of comment." 193repeatedly until you are satisfied with the kind of comment."
190 (interactive) 194 (interactive)
195 (comment-normalize-vars)
196 (let (comempty comment)
197 (save-excursion
198 (beginning-of-line)
199 (setq comment (comment-search-forward (line-end-position) t))
200 (setq comempty (looking-at "[ \t]*$")))
201
191 (cond 202 (cond
192 203
193 ;; Blank line? Then start comment at code indent level. 204 ;; Blank line? Then start comment at code indent level.
194 ((asm-line-matches "^[ \t]*$") 205 ;; Just like `comment-dwim'. -stef
195 (delete-horizontal-space) 206 ((save-excursion (beginning-of-line) (looking-at "^[ \t]*$"))
196 (tab-to-tab-stop) 207 (indent-according-to-mode)
197 (insert asm-comment-char comment-start)) 208 (insert asm-comment-char asm-comment-char ?\ ))
198 209
199 ;; Nonblank line with no comment chars in it? 210 ;; Nonblank line w/o comment => start a comment at comment-column.
200 ;; Then start a comment at the current comment column 211 ;; Also: point before the comment => jump inside.
201 ((asm-line-matches (format "^[^%c\n]+$" asm-comment-char)) 212 ((or (null comment) (< (point) comment))
202 (indent-for-comment)) 213 (indent-for-comment))
203 214
204 ;; Flush-left comment present? Just insert character. 215 ;; Flush-left or non-empty comment present => just insert character.
205 ((asm-line-matches asm-flush-left-empty-comment-pattern) 216 ((or (not comempty) (save-excursion (goto-char comment) (bolp)))
206 (insert asm-comment-char)) 217 (insert asm-comment-char))
207 218
208 ;; Empty code-level comment already present? 219 ;; Empty code-level comment => upgrade to next comment level.
209 ;; Then start flush-left comment, on line above if this one is nonempty. 220 ((save-excursion (goto-char comment) (skip-chars-backward " \t") (bolp))
210 ((asm-line-matches asm-code-level-empty-comment-pattern) 221 (goto-char comment)
211 (asm-pop-comment-level) 222 (insert asm-comment-char)
212 (insert asm-comment-char asm-comment-char comment-start)) 223 (indent-for-comment))
213
214 ;; Empty comment ends line?
215 ;; Then make code-level comment, on line above if this one is nonempty.
216 ((asm-line-matches asm-inline-empty-comment-pattern)
217 (asm-pop-comment-level)
218 (tab-to-tab-stop)
219 (insert asm-comment-char comment-start))
220 224
221 ;; If all else fails, insert character 225 ;; Empty comment ends non-empty code line => new comment above.
222 (t 226 (t
223 (insert asm-comment-char))) 227 (goto-char comment)
224 (end-of-line)) 228 (skip-chars-backward " \t")
229 (delete-region (point) (line-end-position))
230 (beginning-of-line) (insert "\n") (backward-char)
231 (asm-comment)))))
225 232
226(provide 'asm-mode) 233(provide 'asm-mode)
227 234