[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-lock in machine mode of gdba
From: |
Nick Roberts |
Subject: |
Re: font-lock in machine mode of gdba |
Date: |
Thu, 21 Oct 2004 23:53:28 +1300 |
Stefan Monnier writes:
> > 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.
>
> This is still wrong (well, maybe not "wrong", but...). Your patch should
> only set font-lock-defaults and nothing more. It should be all
> that's needed. If it's not enough, then there's a bug elsewhere (typically
> an omission to call `kill-all-local-variables).
Currently these modes can't run kill-all-local-variables. See the FIXME in
gdb-get-create-buffer (which I think you put there a long while ago):
;; FIXME: This should be set after calling the function, since the
;; function should run kill-all-local-variables.
In gdb-get-create-buffer, gdb-buffer-type must currently be set *before*
the mode function because it (the mode function) runs a trigger (like
gdb-invalidate-assembler). This trigger needs to be moved out of the
mode function and into gdb-get-create-buffer. To do this gdb-get-create-buffer
needs to know the name of the trigger. How about something like this:
(defun gdb-get-create-buffer (key)
"Create a new gdb buffer of the type specified by KEY.
The key should be one of the cars in `gdb-buffer-rules-assoc'."
(or (gdb-get-buffer key)
(let* ((rules (assoc key gdb-buffer-rules-assoc))
(name (funcall (gdb-rules-name-maker rules)))
(new (get-buffer-create name)))
(with-current-buffer new
(let ((trigger))
(if (cdr (cdr rules))
(setq trigger (funcall (car (cdr (cdr rules))))))
(set (make-local-variable 'gdb-buffer-type) key)
(set (make-local-variable 'gud-minor-mode)
(with-current-buffer gud-comint-buffer gud-minor-mode))
(set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
(if trigger (funcall trigger)))
new))))
So that gdb-assembler-mode would look like:
(defun gdb-assembler-mode ()
"Major mode for viewing code assembler.
\\{gdb-assembler-mode-map}"
(kill-all-local-variables)
(setq major-mode 'gdb-assembler-mode)
(setq mode-name "Machine")
(setq gdb-overlay-arrow-position nil)
(add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
(put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>")
(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))
(run-mode-hooks 'gdb-assembler-mode-hook)
'gdb-invalidate-assembler)
and similarly for the other mode functions. This appears to work and so
does font-lock in the assembler buffer. I'm not looking for points for style,
just confirmation that I'm making sense and that run-mode-hooks doesn't
have to be the last item in the mode function.
Nick
- font-lock in machine mode of gdba, Masatake YAMATO, 2004/10/17
- Re: font-lock in machine mode of gdba, Stefan Monnier, 2004/10/17
- font-lock in machine mode of gdba, Nick Roberts, 2004/10/17
- Re: font-lock in machine mode of gdba, Masatake YAMATO, 2004/10/19
- Re: font-lock in machine mode of gdba, Nick Roberts, 2004/10/23
- Re: font-lock in machine mode of gdba, Masatake YAMATO, 2004/10/23
- Re: font-lock in machine mode of gdba, Nick Roberts, 2004/10/23