all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* mode-aware fill-column?
@ 2002-09-16 20:45 mike hardy
  2002-09-16 23:47 ` Oliver Scholz
  0 siblings, 1 reply; 3+ messages in thread
From: mike hardy @ 2002-09-16 20:45 UTC (permalink / raw)



Howdy -

Using Emacs for personal editing I like text columns to wrap around 84
chars.  But (some) ppl prefer to see 72-ish for posting to Usenet.  I'd
like to accomodate them if there is some automatic way of changing
fill-column's value between the two.  Say somehow using ~/.gnus.el to
change it to 72 but all other times use 84 (and when exiting Gnus it
reverts to 84 automatically)?  Or maybe only use 84 when a buffer causes
text-mode to start and at all other times use 72?  Is this something I can
use ~/.gnus.el to change?
    
In poking around Info I see "set-fill-column" but I don't know anything
about using LISP to detect the mode, execute "*fill*", etc., when I visit
a buffer.  It looks like I could just use "set-fill-column" when entering
text-mode I could leave the fill* default at 72 and change it to 84 for
text-mode (which Info intimates would be good only while in text-mode?).
But I don't know how to pass a value to a function (or invoke the
function) upon starting text-mode.

This is what I'm using right now if it matters (~/.emacs):

(setq-default major-mode 'text-mode)
;; turn on auto-fill:
(add-hook 'text-mode-hook 'auto-fill-mode)
(setq-default fill-column 74)
;(setq-default fill-column 82)


Thanks...

Mike
-- 



------------------------
mhardy_mail@NO_SPAM@yahoo.com

  Help Wanted: Psychic.  You know where to apply.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mode-aware fill-column?
  2002-09-16 20:45 mode-aware fill-column? mike hardy
@ 2002-09-16 23:47 ` Oliver Scholz
  2002-09-17  4:48   ` mike hardy
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Scholz @ 2002-09-16 23:47 UTC (permalink / raw)


mike hardy <no_sp@m.for_me.org> writes:
[...]
> Using Emacs for personal editing I like text columns to wrap around 84
> chars.  But (some) ppl prefer to see 72-ish for posting to Usenet.  I'd
> like to accomodate them if there is some automatic way of changing
> fill-column's value between the two.  Say somehow using ~/.gnus.el to
> change it to 72 but all other times use 84 (and when exiting Gnus it
> reverts to 84 automatically)?

The usual way for a task like this in Emacs is to use a hook (See in
the manual: ==> Customization ==> Variables ==> Hooks). Almost every
major mode is supposed to provide at least one hook: the
<mode-name>-mode-hook. Since you use Gnus, you write messages in
`message-mode', so this would be `message-mode-hook'.

The variable `fill-column' becomes automatically a local variable if
you set it to a different value in a buffer. So all you have to do is
to put a `(setq fill-column 72)' in the `message-mode-hook'. But you
have to wrap this into an anonymous function via `lambda':

(add-hook 'message-mode-hook (lambda () (setq fill-column 72)))

    -- Oliver

-- 
Jour de la Vertu de l'Année 210 de la Révolution
Liberté, Egalité, Fraternité!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mode-aware fill-column?
  2002-09-16 23:47 ` Oliver Scholz
@ 2002-09-17  4:48   ` mike hardy
  0 siblings, 0 replies; 3+ messages in thread
From: mike hardy @ 2002-09-17  4:48 UTC (permalink / raw)



Nostradamus foretold that on Tue Sep 17 2002, Oliver Scholz would write:

> mike hardy <no_sp@m.for_me.org> writes:
> [...]
> > Using Emacs for personal editing I like text columns to wrap around 84
> > chars.  But (some) ppl prefer to see 72-ish for posting to Usenet.  I'd
> > like to accomodate them if there is some automatic way of changing
> > fill-column's value between the two.  Say somehow using ~/.gnus.el to
> > change it to 72 but all other times use 84 (and when exiting Gnus it
> > reverts to 84 automatically)?
> 
> The usual way for a task like this in Emacs is to use a hook (See in
> the manual: ==> Customization ==> Variables ==> Hooks). Almost every
> major mode is supposed to provide at least one hook: the
> <mode-name>-mode-hook. Since you use Gnus, you write messages in
> `message-mode', so this would be `message-mode-hook'.
> 
> The variable `fill-column' becomes automatically a local variable if
> you set it to a different value in a buffer. So all you have to do is
> to put a `(setq fill-column 72)' in the `message-mode-hook'. But you
> have to wrap this into an anonymous function via `lambda':
> 
> (add-hook 'message-mode-hook (lambda () (setq fill-column 72)))
> 
>     -- Oliver


Excellent - works great!!  Thanks both for the info/code.  

I did try (before posting) using text-mode-hook (copied the format from
somewhere else) but I kept getting an error which I see on occasion
(don't recall what it was but it's a common one for me when
experimenting :->).  I bet it was for lack of this lamdba reference.

Thanks...

Mike
-- 



------------------------
mhardy_mail@NO_SPAM@yahoo.com

  Help Wanted: Psychic.  You know where to apply.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-17  4:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-16 20:45 mode-aware fill-column? mike hardy
2002-09-16 23:47 ` Oliver Scholz
2002-09-17  4:48   ` mike hardy

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.