From: Nick Roberts <nickrob@snap.net.nz>
Cc: Masatake YAMATO <jet@gyve.org>, emacs-devel@gnu.org
Subject: Re: font-lock in machine mode of gdba
Date: Thu, 21 Oct 2004 23:53:28 +1300 [thread overview]
Message-ID: <16759.38184.430010.735486@farnswood.snap.net.nz> (raw)
In-Reply-To: <jwvvfd6j2ul.fsf-monnier+emacs@gnu.org>
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
next prev parent reply other threads:[~2004-10-21 10:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-17 15:29 font-lock in machine mode of gdba Masatake YAMATO
2004-10-17 16:55 ` Stefan Monnier
2004-10-18 2:14 ` Nick Roberts
2004-10-18 2:25 ` Nick Roberts
2004-10-19 2:26 ` Masatake YAMATO
2004-10-19 12:45 ` Stefan Monnier
2004-10-21 10:53 ` Nick Roberts [this message]
2004-10-19 13:28 ` Nick Roberts
2004-10-19 13:54 ` Stefan Monnier
2004-10-19 14:27 ` Masatake YAMATO
2004-10-19 16:38 ` Masatake YAMATO
2004-10-23 22:09 ` Nick Roberts
2004-10-23 23:49 ` Masatake YAMATO
2004-10-23 23:59 ` Nick Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16759.38184.430010.735486@farnswood.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=emacs-devel@gnu.org \
--cc=jet@gyve.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.