unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Why didn't setq work here?
@ 2011-01-07  2:05 Eric Lilja
  2011-01-07  3:40 ` Deniz Dogan
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Lilja @ 2011-01-07  2:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hello, I'm running "GNU Emacs 24.0.50.1 (i386-mingw-nt6.1.7600) of 
2011-01-03 on 3249CTO" (a build provided by Mr Sean Sieger) under 
Windows 7 x64.

I don't really know how to configure emacs so please excuse any 
stupidity found below and improper use terminology.

For LaTeX buffers, I wanted to turn on the minor mode auto-fill-mode, 
with a fill-column of 76.

After a bit of investigating, I found that I could run "commands" (if 
that's what they're called) when major mode latex is loaded/activated 
for a buffer by using hooks, like this:

(defun my-latex-hook ()
   (message "Running my-latex-hook")
)
(add-hook 'latex-mode-hook 'my-latex-hook)

I added the statement above and launched emacs like this:
$ emacs foo.tex&
and I could see from the message output that my hook was indeed working. 
Good. Just what I wanted.

So now I just need to turn on the minor mode auto-fill-mode with 
fill-column set to 76 when this hook is "executed".

In my naivety, I tried this:

(defun my-latex-hook ()
   (message "Running my-latex-hook")
   (setq auto-fill-mode 1)
   (setq fill-column 76)
)
(add-hook 'latex-mode-hook 'my-latex-hook)

I saw a warning when I byte-compiled my .emacs:
In my-latex-hook:
.emacs:42:9:Warning: assignment to free variable `auto-fill-mode'

but tried anyway. Closed emacs and restarted as I did above ($ emacs 
foo.tex&)

I noticed straight away that the minor mode auto-fill-mode had not been 
turned on.
However, C-h v fill-column showed that my fill-column had been set 
though since its value was now the desired 76 instead of the default 70.

In order to solve the problem of auto-fill-mode not being turned on and 
getting rid of the byte compiler warning, I rewrote my hook like this:

(defun my-latex-hook ()
   (message "Running my-latex-hook")
   (auto-fill-mode 1)
   (set-fill-column 76)
)
(add-hook 'latex-mode-hook 'my-latex-hook)

Now auto-fill-mode is indeed turned on and I don't get a warning by the 
byte compiler when I set fill column. Ok, so I am happy. Problem solved! :)

But here's my question: Why didn't setq work as I thought it would? By 
not work I meant I the minor mode auto-fill-mode was not turned on and 
even though the fill column was set as I desired, the statement produced 
a warning as I showed above.

Thanks for any replies! :)

- EL




^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <mailman.23.1294365997.1330.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2011-01-08 17:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07  2:05 Why didn't setq work here? Eric Lilja
2011-01-07  3:40 ` Deniz Dogan
2011-01-07 12:43   ` Eric Lilja
2011-01-07 14:26     ` Tassilo Horn
2011-01-07 16:05       ` Eric Lilja
2011-01-07 16:59       ` Peter Dyballa
2011-01-08 17:29         ` Tassilo Horn
     [not found]       ` <mailman.6.1294416372.29236.help-gnu-emacs@gnu.org>
2011-01-07 22:50         ` Tim X
     [not found] <mailman.23.1294365997.1330.help-gnu-emacs@gnu.org>
2011-01-07  2:54 ` Pascal J. Bourguignon
2011-01-07  3:50 ` rusi

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