unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: bojohan+news@dd.chalmers.se (Johan Bockgård)
To: help-gnu-emacs@gnu.org
Subject: Re: minor mode problem
Date: Sat, 05 Jul 2008 13:25:06 +0200	[thread overview]
Message-ID: <yoijy74gefot.fsf@remote5.student.chalmers.se> (raw)
In-Reply-To: mailman.13882.1214521609.18990.help-gnu-emacs@gnu.org

Stephen Berman <stephen.berman@gmx.net> 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	other threads:[~2008-07-05 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.13882.1214521609.18990.help-gnu-emacs@gnu.org>
2008-07-05 11:25 ` Johan Bockgård [this message]
2008-06-26 23:06 minor mode problem Stephen Berman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yoijy74gefot.fsf@remote5.student.chalmers.se \
    --to=bojohan+news@dd.chalmers.se \
    --cc=help-gnu-emacs@gnu.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).