help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: minor mode problem


From: Johan Bockgård
Subject: Re: minor mode problem
Date: Sat, 05 Jul 2008 13:25:06 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/23.0.60 (gnu/linux)

Stephen Berman <address@hidden> writes:

> 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)))

[...]

> (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.

    (defun print-font-lock-mode-1 ()
      (message "FONT-LOCK-MODE: %s" font-lock-mode)
      (remove-hook 'post-command-hook 'print-font-lock-mode-1))

    (defun print-font-lock-mode-2 ()
      (message "FONT-LOCK-MODE: %s" font-lock-mode)
      (remove-hook 'post-command-hook 'print-font-lock-mode-2))

    (defun srb-mode-test3 ()
      "Turn on Emacs Lisp mode and enable srb-mode."
      (interactive)
      (emacs-lisp-mode)
      (srb-mode 1)
      (add-hook 'post-command-hook 'print-font-lock-mode-1)
      (add-hook 'post-command-hook 'print-font-lock-mode-2 t))

M-x srb-mode-test3 RET

  =>

font-lock-mode: t
font-lock-mode: nil
FONT-LOCK-MODE: nil
FONT-LOCK-MODE: t


See define-globalized-minor-mode (MODE-cmhh, MODE-check-buffers,
MODE-enable-in-buffers).

-- 
Johan Bockgård


reply via email to

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