[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
minor mode problem
From: |
Stephen Berman |
Subject: |
minor mode problem |
Date: |
Fri, 27 Jun 2008 01:06:33 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
In GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version 2.12.0) of
2008-06-25 on escher I start with -Q and evaluate the following minor
mode definition:
(define-minor-mode srb-mode
"Toggle srb mode."
:lighter " srb"
(if srb-mode
(progn
(message "font-lock-mode: %s" font-lock-mode)
(sit-for 1)
(if font-lock-mode (font-lock-mode -1))
(message "font-lock-mode: %s" font-lock-mode))
(unless font-lock-mode (font-lock-mode 1))
(message "font-lock-mode: %s" font-lock-mode)))
I write the following files to disk:
,----[ /tmp/srb-test1.el ]
| ;; blah
`----
,----[ /tmp/srb-test1 ]
| ;; blah
|
| ;; Local Variables:
| ;; mode: emacs-lisp
| ;; End:
`----
,----[ /tmp/srb-test2 ]
| ;; blah
`----
Now I evaluate the following function definitions:
(defun srb-mode-test (file)
"Enable srb-mode."
(interactive "fFile: ")
(find-file file)
(srb-mode 1))
(defun srb-mode-test2 ()
"Put a file in Emacs Lisp mode and enable srb-mode."
(interactive)
(find-file "/tmp/srb-test2")
(emacs-lisp-mode)
(srb-mode 1))
(1) I then call srb-mode-test twice, passing it first the file
/tmp/srb-test1.el and then the file /tmp/srb-test1. In both cases I
first see the buffer text fontified with font-lock-comment-face, then
after a second the fontification turns off. This is as I expect.
(2) Then I call srb-mode-test2: I see the text in font-lock-comment-face
and the message "font-lock-mode: t", then a second later the message
"font-lock-mode: nil", but the text remains fontified, and `C-h v
font-lock-mode' in that buffer says its value is t, although it was nil
according to the last message. This I did not expect and do not
understand.
(3) Next I try edebugging srb-mode-test2.
(a) When I execute each sexp (with `f'), after (emacs-lisp-mode) I see
the buffer text become fontified with font-lock-comment-face, and after
(srb-mode 1) it loses fontification. This is what I expect but, again,
not what happens when I execute the whole function outside of edebug.
(b) However, when I step into rather than over (emacs-lisp-mode) (`i'
instead of `f') and then execute each sexp of that function, the buffer
text never displays font-lock-comment-face.
(c) And finally, when I instrument srb-mode but not srb-mode-test2, then
when edebug stops execution at srb-mode, the buffer text displays
font-lock-comment-face, and when I step through srb-mode, I see the
buffer text lose fontification at the end of the progn, but when I then
continue stepping through to the end of srb-mode, the fontification
returns, so the result is as in (2) above.
(4) As a last case, I write the following file to disk:
,----[ /tmp/srb-test3 ]
| ;; blah
|
| ;; Local Variables:
| ;; mode: emacs-lisp
| ;; mode: srb
| ;; End:
`----
(a) When I do `C-x C-f /tmp/srb-test3', the result is as in (2).
(b) When I instrument emacs-lisp-mode, and after typing `C-x C-f
/tmp/srb-test3' step over it in edebug, the result is as in (3b).
(c) When I instrument srb-mode, and after typing `C-x C-f
/tmp/srb-test3' step over it in edebug, the result is as in (3a) (not as
in (3c)).
Can anyone explain what's happening in (2)-(4) (especially cases (2) and
(4a)), or at least offer some advice about how to debug them better?
Thanks.
Steve Berman
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- minor mode problem,
Stephen Berman <=