1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 22:50:59 -08:00

(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.
This commit is contained in:
Stefan Monnier 2003-04-02 16:48:11 +00:00
parent 6d91a595e0
commit dfc42f38c1
2 changed files with 117 additions and 79 deletions

View file

@ -1,3 +1,19 @@
2003-04-02 Stefan Monnier <monnier@cs.yale.edu>
* progmodes/asm-mode.el (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.
2003-04-02 Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
* emulation/crisp.el (top-level): Quote second arg to
@ -7,14 +23,26 @@
* scroll-bar.el (scroll-bar-mode): Correctly specify `nil' choice.
2003-04-01 Stefan Monnier <monnier@cs.yale.edu>
* progmodes/asm-mode.el (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.
2003-04-01 Dave Love <fx@gnu.org>
* time.el: Doc fixes.
(display-time-mail-face): Change :type and default to nil.
(display-time-mail-icon): Use pbm, not xbm.
(display-time-mail-string): New.
(display-time-string-forms): Use display-time-mail-string. Add
checks in display property.
(display-time-string-forms): Use display-time-mail-string.
Add checks in display property.
2003-04-01 Kenichi Handa <handa@m17n.org>
@ -30,6 +58,10 @@
* emulation/cua-base.el (cua-set-mark): Unconditionally repeat
pop-global-mark without C-x prefix. Fix doc.
2003-03-31 Stefan Monnier <monnier@cs.yale.edu>
* reveal.el (reveal-post-command): Better error handling.
2003-03-31 Nick Roberts <nick@nick.uklinux.net>
* gdb-ui.el (gdb-inferior-io-mode): Remove Unix pathname for cat
so that it can run on NT also.
@ -56,8 +88,8 @@
2003-03-31 Kenichi Handa <handa@m17n.org>
* international/utf-16.el (ccl-decode-mule-utf-16-le): Don't
assume the signature bytes.
* international/utf-16.el (ccl-decode-mule-utf-16-le):
Don't assume the signature bytes.
(ccl-decode-mule-utf-16-be): Likewise.
(ccl-encode-mule-utf-16-le): Don't produce the signature bytes.
(ccl-encode-mule-utf-16-be): Likewise.
@ -88,12 +120,11 @@
2003-03-29 Michael Albinus <Michael.Albinus@alcatel.de>
* trampver.el: New file, to support Autoconf in Tramp CVS
repository.
* tramp.el (tramp-version, tramp-bug-report-address): Moved to
* trampver.el: New file, to support Autoconf in Tramp CVS repository.
* tramp.el (tramp-version, tramp-bug-report-address): Move to
trampver.el, which is required now.
(tramp-chunksize): Type can be nil as well. Reported
by Markus Rost <rost@math.ohio-state.edu>.
(tramp-chunksize): Type can be nil as well.
Reported by Markus Rost <rost@math.ohio-state.edu>.
* tramp-smb.el (tramp-smb-read-file-entry): Make reading size of a
listing entry more robust. Ranges from 10 chars (Samba 1) to 7-9
chars (Samba 2).
@ -116,8 +147,8 @@
2003-03-28 Lute Kamstra <Lute.Kamstra@cwi.nl>
* emacs-lisp/checkdoc.el (checkdoc-display-status-buffer): Fix
docstring.
* emacs-lisp/checkdoc.el (checkdoc-display-status-buffer):
Fix docstring.
(checkdoc-interactive, checkdoc-message-interactive): Make them
perform spell checking when appropriate.
(checkdoc-interactive-loop): Fix docstring and a few typos.

View file

@ -75,9 +75,8 @@
;; 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)
(define-key map "\C-j" 'newline-and-indent)
(define-key map "\C-m" 'newline-and-indent)
map)
"Keymap for Asm mode.")
@ -88,10 +87,6 @@
2 font-lock-keyword-face))
"Additional expressions to highlight in Assembler mode.")
(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 ()
"Major mode for editing typical assembler code.
@ -119,6 +114,9 @@ Special commands:
(setq local-abbrev-table asm-mode-abbrev-table)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(asm-font-lock-keywords))
(set (make-local-variable 'indent-line-function) 'asm-indent-line)
;; Stay closer to the old TAB behavior (was tab-to-tab-stop).
(set (make-local-variable 'tab-always-indent) nil)
(run-hooks 'asm-mode-set-comment-hook)
;; Make our own local child of asm-mode-map
@ -129,53 +127,59 @@ Special commands:
(modify-syntax-entry asm-comment-char "<")
(make-local-variable 'comment-start)
(setq comment-start (string asm-comment-char ?\ ))
(setq comment-start (string asm-comment-char))
(make-local-variable 'comment-add)
(setq comment-add 1)
(make-local-variable 'comment-start-skip)
(setq comment-start-skip "\\(?:\\s<+\\|/\\*+\\)[ \t]*")
(make-local-variable 'comment-end-skip)
(setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
(setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
(make-local-variable 'comment-end)
(setq comment-end "")
(setq fill-prefix "\t")
(run-hooks 'asm-mode-hook))
(run-mode-hooks 'asm-mode-hook))
(defun asm-indent-line ()
"Auto-indent the current line."
(interactive)
(let* ((savep (point))
(indent (condition-case nil
(save-excursion
(forward-line 0)
(skip-chars-forward " \t")
(if (>= (point) savep) (setq savep nil))
(max (asm-calculate-indentation) 0))
(error 0))))
(if savep
(save-excursion (indent-line-to indent))
(indent-line-to indent))))
(defun asm-calculate-indentation ()
(or
;; Flush labels to the left margin.
(and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
;; Same thing for `;;;' comments.
(and (looking-at "\\s<\\s<\\s<") 0)
;; Simple `;' comments go to the comment-column.
(and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
;; The rest goes at the first tab stop.
(or (car tab-stop-list) tab-width)))
(defun asm-colon ()
"Insert a colon; if it follows a label, delete the label's indentation."
(interactive)
(save-excursion
(beginning-of-line)
(if (looking-at "[ \t]+\\(\\sw\\|\\s_\\)+$")
(delete-horizontal-space)))
(insert ":")
(tab-to-tab-stop)
)
(defun asm-newline ()
"Insert LFD + fill-prefix, to bring us back to code-indent level."
(interactive)
(if (eolp) (delete-horizontal-space))
(insert "\n")
(tab-to-tab-stop)
)
(defun asm-line-matches (pattern)
(save-excursion
(beginning-of-line)
(looking-at pattern)))
(defun asm-pop-comment-level ()
;; Delete an empty comment ending current line. Then set up for a new one,
;; on the current line if it was all comment, otherwise above it
(end-of-line)
(delete-horizontal-space)
(while (= (preceding-char) asm-comment-char)
(delete-backward-char 1))
(delete-horizontal-space)
(if (bolp)
nil
(beginning-of-line)
(open-line 1)))
(let ((labelp nil))
(save-excursion
(skip-syntax-backward "w_")
(skip-syntax-backward " ")
(if (setq labelp (bolp)) (delete-horizontal-space)))
(call-interactively 'self-insert-command)
(when labelp
(delete-horizontal-space)
(tab-to-tab-stop))))
;; Obsolete since Emacs-21.4.
(defalias 'asm-newline 'newline-and-indent)
(defun asm-comment ()
"Convert an empty comment to a `larger' kind, or start a new one.
@ -188,40 +192,43 @@ These are the known comment classes:
Suggested usage: while writing your code, trigger asm-comment
repeatedly until you are satisfied with the kind of comment."
(interactive)
(comment-normalize-vars)
(let (comempty comment)
(save-excursion
(beginning-of-line)
(setq comment (comment-search-forward (line-end-position) t))
(setq comempty (looking-at "[ \t]*$")))
(cond
;; Blank line? Then start comment at code indent level.
((asm-line-matches "^[ \t]*$")
(delete-horizontal-space)
(tab-to-tab-stop)
(insert asm-comment-char comment-start))
;; Just like `comment-dwim'. -stef
((save-excursion (beginning-of-line) (looking-at "^[ \t]*$"))
(indent-according-to-mode)
(insert asm-comment-char asm-comment-char ?\ ))
;; Nonblank line with no comment chars in it?
;; Then start a comment at the current comment column
((asm-line-matches (format "^[^%c\n]+$" asm-comment-char))
;; Nonblank line w/o comment => start a comment at comment-column.
;; Also: point before the comment => jump inside.
((or (null comment) (< (point) comment))
(indent-for-comment))
;; Flush-left comment present? Just insert character.
((asm-line-matches asm-flush-left-empty-comment-pattern)
;; Flush-left or non-empty comment present => just insert character.
((or (not comempty) (save-excursion (goto-char comment) (bolp)))
(insert asm-comment-char))
;; Empty code-level comment already present?
;; Then start flush-left comment, on line above if this one is nonempty.
((asm-line-matches asm-code-level-empty-comment-pattern)
(asm-pop-comment-level)
(insert asm-comment-char asm-comment-char comment-start))
;; Empty code-level comment => upgrade to next comment level.
((save-excursion (goto-char comment) (skip-chars-backward " \t") (bolp))
(goto-char comment)
(insert asm-comment-char)
(indent-for-comment))
;; Empty comment ends line?
;; Then make code-level comment, on line above if this one is nonempty.
((asm-line-matches asm-inline-empty-comment-pattern)
(asm-pop-comment-level)
(tab-to-tab-stop)
(insert asm-comment-char comment-start))
;; If all else fails, insert character
;; Empty comment ends non-empty code line => new comment above.
(t
(insert asm-comment-char)))
(end-of-line))
(goto-char comment)
(skip-chars-backward " \t")
(delete-region (point) (line-end-position))
(beginning-of-line) (insert "\n") (backward-char)
(asm-comment)))))
(provide 'asm-mode)