From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Nick Roberts Newsgroups: gmane.emacs.devel Subject: Re: font-lock in machine mode of gdba Date: Thu, 21 Oct 2004 23:53:28 +1300 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <16759.38184.430010.735486@farnswood.snap.net.nz> References: <20041018.002930.45492341.jet@gyve.org> <16755.10649.857644.666785@farnswood.snap.net.nz> <20041019.112647.212948122.jet@gyve.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1098356435 6952 80.91.229.6 (21 Oct 2004 11:00:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Oct 2004 11:00:35 +0000 (UTC) Cc: Masatake YAMATO , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 21 13:00:29 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CKagG-00045P-00 for ; Thu, 21 Oct 2004 13:00:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CKanh-0001il-DT for ged-emacs-devel@m.gmane.org; Thu, 21 Oct 2004 07:08:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CKamy-0001f4-OB for emacs-devel@gnu.org; Thu, 21 Oct 2004 07:07:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CKamx-0001eD-3R for emacs-devel@gnu.org; Thu, 21 Oct 2004 07:07:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CKamw-0001dr-Sn for emacs-devel@gnu.org; Thu, 21 Oct 2004 07:07:23 -0400 Original-Received: from [202.124.108.209] (helo=farnswood.snap.net.nz) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CKaf5-0004vr-LO for emacs-devel@gnu.org; Thu, 21 Oct 2004 06:59:17 -0400 Original-Received: by farnswood.snap.net.nz (Postfix, from userid 501) id 64F0B62F9D; Thu, 21 Oct 2004 11:53:29 +0100 (BST) Original-To: Stefan Monnier In-Reply-To: X-Mailer: VM 6.97 under Emacs 21.2.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:28693 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28693 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