emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: font-lock in machine mode of gdba


From: Masatake YAMATO
Subject: Re: font-lock in machine mode of gdba
Date: Tue, 19 Oct 2004 11:26:47 +0900 (JST)

>  > I've defined font-lock keywords for `gdb-assembler-mode'.  Please,
>  > review the patch. I'm afraid the it is too decorative.
>  > 
>  > 2004-10-18  Masatake YAMATO  <address@hidden>
>  > 
>  >    * progmodes/gdb-ui.el (gdb-ann3): Define a key which toggles
>  >    source view and assembler view.
>  >    (gdb-assembler-font-lock-keywords): New font lock keywords
>  >    definition.
>  >    (gdb-assembler-mode): Use 'gdb-assembler-font-lock-keywords'.
>  >... 
> 
> I think it should at least be consistent with asm-mode where keywords like
> movl, andl, etc are fontified with font-lock-keyword-face and operands and
> registers are left unfontified.

I have changed both gdb-ui.el and asm-mode.el; and used the same face in the
both mode for the same object. Do you think operand fontification is too 
decorative?

Now font-lock-mode is turn-on in gdb-assembler-mode when global-font-lock-mode 
is 
true. gdb-assembler-mode-hook is also provided. See the comments at the tail of
font-core.el.

Index: lisp/progmodes/gdb-ui.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/gdb-ui.el,v
retrieving revision 1.24
diff -u -r1.24 gdb-ui.el
--- lisp/progmodes/gdb-ui.el    6 Oct 2004 07:20:53 -0000       1.24
+++ lisp/progmodes/gdb-ui.el    19 Oct 2004 02:20:41 -0000
@@ -1939,6 +1960,19 @@
     (suppress-keymap map)
     map))
 
+(defvar gdb-assembler-font-lock-keywords
+  '(("[^\$]0x[0-9a-f]+" . font-lock-constant-face)
+    ("^\\(0x*[0-9a-f]+\\) ?\\(<\\(\\sw+\\)\\+[0-9]+>\\)?:[ \t]+\\(\\sw+\\)"
+     (1 font-lock-constant-face) 
+     (3 font-lock-function-name-face) 
+     (4 font-lock-keyword-face))
+    ("%\\sw+" . font-lock-variable-name-face)
+    ("^\\(Dump of assembler code for function\\) \\(.+\\):" 
+     (1 font-lock-comment-face)
+     (2 font-lock-function-name-face))
+    ("^\\(End of assembler dump\\.\\)" . font-lock-comment-face))
+  "Font lock keywords used in `gdb-assembler-mode'.")
+
 (defun gdb-assembler-mode ()
   "Major mode for viewing code assembler.
 
@@ -1951,7 +1985,12 @@
   (setq fringes-outside-margins t)
   (setq buffer-read-only t)
   (use-local-map gdb-assembler-mode-map)
-  (gdb-invalidate-assembler))
+  (set (make-local-variable 'font-lock-defaults)
+       '(gdb-assembler-font-lock-keywords))
+  (when global-font-lock-mode
+    (font-lock-mode 1))
+  (gdb-invalidate-assembler)
+  (run-hooks 'gdb-assembler-mode-hook))
 
 (defun gdb-assembler-buffer-name ()
   (with-current-buffer gud-comint-buffer
Index: lisp/progmodes/asm-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/asm-mode.el,v
retrieving revision 1.28
diff -u -r1.28 asm-mode.el
--- lisp/progmodes/asm-mode.el  1 Sep 2003 15:45:34 -0000       1.28
+++ lisp/progmodes/asm-mode.el  19 Oct 2004 02:20:41 -0000
@@ -90,7 +90,10 @@
     2 font-lock-keyword-face)
    ;; directive started from ".".
    ("^\\(\\.\\(\\sw\\|\\s_\\)+\\)\\>[^:]?"
-    1 font-lock-keyword-face))
+    1 font-lock-keyword-face)
+   ;; %register
+   ("%\\sw+" . font-lock-variable-name-face)
+   )
  "Additional expressions to highlight in Assembler mode.")
 
 ;;;###autoload




reply via email to

[Prev in Thread] Current Thread [Next in Thread]