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

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

Re: buffer-read-only is always t at text-mode-hook time


From: Kevin Rodgers
Subject: Re: buffer-read-only is always t at text-mode-hook time
Date: Wed, 11 Aug 2004 09:33:50 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Dan Jacobson wrote:
> Perhaps this would work:
> (add-hook 'text-mode-hook (lambda ()
>    (or buffer-read-only (and(turn-on-auto-fill)(flyspell-mode 1)))))
> But buffer-read-only is always true when text-mode-hook is evaluated
> apparently.

I can't replicate that on GNU Emacs 21.3.1 (i386-pc-solaris2.7, X toolkit).

I started emacs with the -q --no-site-file switches and evaluated this
in the *scratch* buffer:

(add-hook 'text-mode-hook
          (lambda () (message "buffer-read-only is %s" buffer-read-only)))

Then I invoked text mode several different ways (via M-x, via
default-major-mode, and via auto-mode-alist on both new and existing
files), and each time the echo area said "buffer-read-only is nil".

> While a fix is being made, any workarounds?
>
> You see I don't want to turn on flyspell-mode for files I have no hope
> of editing.

Your code above ought to work, except that you depend on the result of
turn-on-auto-fill, whose return value is not documented.  Use progn
instead of `and'.

> flyspell.el might add an example of how not to turn on flyspell-mode
> for files one has no hope of editing.

But you figured it out easily enough, no?

> P.S. the Info, the first hooks example
>      (add-hook 'text-mode-hook 'turn-on-auto-fill)
> should also show how to not turn it on for files one has no hope of editing.

Why?  auto-fill is only invoked if they make a change (insert a space
at the end of a line), and if that's what the user wants it should
work if they M-x toggle-read-only.

> While there, tell folks how also to set a hook just in case they need
> to override. Don't only mention just add-hook.

Bad idea.

> BTW, I also don't want to turn on flyspell-mode for files that are
> real big.

C-h f buffer-size

--
Kevin Rodgers





reply via email to

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