]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/asm-mode.el
Changed version to 1.2.1.
[gnu-emacs] / lisp / progmodes / asm-mode.el
index cdf83d9fd5eec51c085cda523cab2deffc5e8ea7..7a2d74343fa575251c46c0e5f86cb08d9bedb5fa 100644 (file)
@@ -3,11 +3,9 @@
 ;; Copyright (C) 1991 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
-;; Last-Modified: 14 Jul 1992
+;; Maintainer: FSF
 ;; Keywords: tools, languages
 
-;;     @(#)asm-mode.el 1.7
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -21,8 +19,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
 ;;
 ;;     TAB             tab to next tab stop
 ;;     :               outdent preceding label, tab to tab stop
-;;     ;               place or move comment
+;;     comment char    place or move comment
+;;                     asm-comment-char specifies which character this is;
+;;                     you can use a different character in different
+;;                     Asm mode buffers.
 ;;     C-j, C-m        newline and tab to tab stop
 ;;
 ;; Code is indented to the first tab stop level.
-;; The ; key inserts copies of the value of asm-comment-char at an
-;; appropriate spot.
 
 ;; This mode runs two hooks:
-;;   1) An asm-set-comment-hook before the part of the initialization
+;;   1) An asm-mode-set-comment-hook before the part of the initialization
 ;; depending on asm-comment-char, and
 ;;   2) an asm-mode-hook at the end of initialization.
 
 ;;; Code:
 
-(defvar asm-comment-char ?;
-  "*The comment-start character assumed by Asm mode.")
+(defgroup asm nil
+  "Mode for editing assembler code."
+  :group 'languages)
+
+(defcustom asm-comment-char ?\;
+  "*The comment-start character assumed by Asm mode."
+  :type 'character
+  :group 'asm)
 
 (defvar asm-mode-syntax-table nil
   "Syntax table used while in Asm mode.")
@@ -65,8 +71,9 @@
 (if asm-mode-map
     nil
   (setq asm-mode-map (make-sparse-keymap))
-  (define-key asm-mode-map ";"         'asm-comment)
+  ;; 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)
@@ -93,10 +100,10 @@ Features a private abbrev table and the following bindings:
 \\[asm-comment]\tsmart placement of assembler comments.
 
 The character used for making comments is set by the variable
-`asm-comment-char' (which defaults to `?;').
+`asm-comment-char' (which defaults to `?\\;').
 
-Alternatively, you may set this variable in `asm-set-comment-hook', which is
-called near the beginning of mode initialization.
+Alternatively, you may set this variable in `asm-mode-set-comment-hook',
+which is called near the beginning of mode initialization.
 
 Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.
 
@@ -105,7 +112,6 @@ Special commands:
 "
   (interactive)
   (kill-all-local-variables)
-  (use-local-map asm-mode-map)
   (setq mode-name "Assembler")
   (setq major-mode 'asm-mode)
   (setq local-abbrev-table asm-mode-abbrev-table)
@@ -114,7 +120,13 @@ Special commands:
   (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
                        "<" asm-mode-syntax-table)
   (modify-syntax-entry ?\n
@@ -133,9 +145,7 @@ Special commands:
   (make-local-variable 'comment-column)
   (setq comment-column 32)
   (setq fill-prefix "\t")
-  (run-hooks 'asm-mode-hook)
-  )
-
+  (run-hooks 'asm-mode-hook))
 \f
 (defun asm-colon ()
   "Insert a colon; if it follows a label, delete the label's indentation."
@@ -224,4 +234,6 @@ repeatedly until you are satisfied with the kind of comment."
    )
   (end-of-line))
 
+(provide 'asm-mode)
+
 ;;; asm-mode.el ends here