* progmodes/asm-mode.el (asm-mode-map):
[bpt/emacs.git] / lisp / progmodes / asm-mode.el
index 17cb7c7..167f851 100644 (file)
@@ -1,6 +1,7 @@
 ;;; asm-mode.el --- mode for editing assembler code
 
-;; Copyright (C) 1991, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;; Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Maintainer: FSF
@@ -10,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -20,8 +21,8 @@
 
 ;; 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, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -51,6 +52,7 @@
 
 (defgroup asm nil
   "Mode for editing assembler code."
+  :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
   :group 'languages)
 
 (defcustom asm-comment-char ?\;
@@ -60,9 +62,9 @@
 
 (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)
+    (modify-syntax-entry ?\n "> b" st)
+    (modify-syntax-entry ?/  ". 124b" st)
+    (modify-syntax-entry ?*  ". 23" st)
     st)
   "Syntax table used while in Asm mode.")
 
     (define-key map "\C-c;"    'comment-region)
     (define-key map "\C-j"     'newline-and-indent)
     (define-key map "\C-m"     'newline-and-indent)
+    (define-key map [menu-bar] (make-sparse-keymap))
+    (define-key map [menu-bar asm-mode] (cons "Asm" map))
+    (define-key map [comment-region]
+      '(menu-item "Comment Region" comment-region
+                 :help "Comment or uncomment each line in the region"))
+    (define-key map [newline-and-indent]
+      '(menu-item "Insert Newline and Indent" newline-and-indent
+                 :help "Insert a newline, then indent according to major mode"))
+    (define-key map [asm-colon]
+      '(menu-item "Insert Colon" asm-colon
+                 :help "Insert a colon; if it follows a label, delete the label's indentation"))
     map)
   "Keymap for Asm mode.")
 
 (defconst asm-font-lock-keywords
- '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?"
-    (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
-   ;; label started from ".".
-   ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>:"
-    1 font-lock-function-name-face)
-   ("^\\((\\sw+)\\)?\\s +\\(\\(\\.?\\sw\\|\\s_\\)+\\(\\.\\sw+\\)*\\)"
-    2 font-lock-keyword-face)
-   ;; directive started from ".".
-   ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>[^:]?"
-    1 font-lock-keyword-face)
-   ;; %register
-   ("%\\sw+" . font-lock-variable-name-face))
- "Additional expressions to highlight in Assembler mode.")
+  (append 
+   '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.\\sw+\\)*\\)?"
+      (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
+     ;; label started from ".".
+     ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>:"
+      1 font-lock-function-name-face)
+     ("^\\((\\sw+)\\)?\\s +\\(\\(\\.?\\sw\\|\\s_\\)+\\(\\.\\sw+\\)*\\)"
+      2 font-lock-keyword-face)
+     ;; directive started from ".".
+     ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>[^:]?"
+      1 font-lock-keyword-face)
+     ;; %register
+     ("%\\sw+" . font-lock-variable-name-face))
+   cpp-font-lock-keywords)
+  "Additional expressions to highlight in Assembler mode.")
 
 ;;;###autoload
 (defun asm-mode ()
@@ -132,14 +147,14 @@ Special commands:
   (use-local-map (nconc (make-sparse-keymap) asm-mode-map))
   (local-set-key (vector asm-comment-char) 'asm-comment)
   (set-syntax-table (make-syntax-table asm-mode-syntax-table))
-  (modify-syntax-entry asm-comment-char "<")
+  (modify-syntax-entry asm-comment-char "< b")
 
   (make-local-variable 'comment-start)
   (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]*")
+  (setq comment-start-skip "\\(?:\\s<+\\|/[/*]+\\)[ \t]*")
   (make-local-variable 'comment-end-skip)
   (setq comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
   (make-local-variable 'comment-end)
@@ -186,7 +201,7 @@ Special commands:
       (delete-horizontal-space)
       (tab-to-tab-stop))))
 
-;; Obsolete since Emacs-21.4.
+;; Obsolete since Emacs-22.1.
 (defalias 'asm-newline 'newline-and-indent)
 
 (defun asm-comment ()
@@ -204,7 +219,8 @@ repeatedly until you are satisfied with the kind of comment."
   (let (comempty comment)
     (save-excursion
       (beginning-of-line)
-      (setq comment (comment-search-forward (line-end-position) t))
+      (with-no-warnings
+       (setq comment (comment-search-forward (line-end-position) t)))
       (setq comempty (looking-at "[ \t]*$")))
 
   (cond
@@ -240,5 +256,5 @@ repeatedly until you are satisfied with the kind of comment."
 
 (provide 'asm-mode)
 
-;;; arch-tag: 210e695f-f338-4376-8913-a4c5c72ac848
+;; arch-tag: 210e695f-f338-4376-8913-a4c5c72ac848
 ;;; asm-mode.el ends here