all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* adding hook to auto-mode-alist load
@ 2003-08-21 21:09 Todd Wylie
  0 siblings, 0 replies; 4+ messages in thread
From: Todd Wylie @ 2003-08-21 21:09 UTC (permalink / raw)



Greetings-

I recently changed my dot-file to automatically invoke paragraph-indent-text-mode for files of type *.plan like so:

(setq auto-mode-alist (cons '("\.plan$" . paragraph-indent-text-mode) auto-mode-alist))

But, I'd also like to load auto-fill-mode just for this type of file. Can I add a text-mode-hook for this setup?

Kind regards,
TW

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

* Re: adding hook to auto-mode-alist load
       [not found] <mailman.634.1061522029.29551.help-gnu-emacs@gnu.org>
@ 2003-08-22  6:41 ` Lute Kamstra
  2003-08-22 14:40   ` Johan Bockgård
  0 siblings, 1 reply; 4+ messages in thread
From: Lute Kamstra @ 2003-08-22  6:41 UTC (permalink / raw)


Todd Wylie <twylie@watson.wustl.edu> writes:

> I recently changed my dot-file to automatically invoke
> paragraph-indent-text-mode for files of type *.plan like so:
>
> (setq auto-mode-alist (cons '("\.plan$" . paragraph-indent-text-mode)
> auto-mode-alist))
>
> But, I'd also like to load auto-fill-mode just for this type of
> file. Can I add a text-mode-hook for this setup?

auto-mode-alist can be used to associate a certain type of file with a
major mode.  Every major mode has a hook variable that can be used to
customize that major mode.  In this case you can do

(add-hook 'paragraph-indent-text-mode-hook (lambda () (auto-fill-mode 1)))

to automatically start the auto-fill minor mode whenever you start the
paragraph-indent-text major mode.  If you want auto-fill-mode started
only for .plan files and not for other files that are put in
paragraph-indent-text-mode, then you could start auto-fill-mode
conditionally (e.g., write a function to do this and put this function
on paragraph-indent-text-mode-hook).

  Lute.

-- 
(spook) => "Telex ASDIC Vickie Weaver"
(insert-file-contents "~/.signature") => (error "`~/.signature' too rude")

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

* Re: adding hook to auto-mode-alist load
  2003-08-22  6:41 ` adding hook to auto-mode-alist load Lute Kamstra
@ 2003-08-22 14:40   ` Johan Bockgård
  2003-08-22 15:57     ` Lute Kamstra
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Bockgård @ 2003-08-22 14:40 UTC (permalink / raw)


Lute Kamstra <Lute.Kamstra@cwi.nl> writes:

> In this case you can do
>
> (add-hook 'paragraph-indent-text-mode-hook (lambda () (auto-fill-mode 1)))
>
> to automatically start the auto-fill minor mode whenever you start
> the paragraph-indent-text major mode. If you want auto-fill-mode
> started only for .plan files and not for other files that are put in
> paragraph-indent-text-mode, then you could start auto-fill-mode
> conditionally (e.g., write a function to do this and put this
> function on paragraph-indent-text-mode-hook).

AFAICS auto-mode-alist just specifies a function to call. Is there any
reason the following is not a good idea?

(defun foo ()
  (paragraph-indent-text-mode)
  (turn-on-auto-fill))

(setq auto-mode-alist (cons '("\.plan$" . foo) auto-mode-alist))

You could call foo `plan-mode' if you like.

-- 
Johan Bockgård

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

* Re: adding hook to auto-mode-alist load
  2003-08-22 14:40   ` Johan Bockgård
@ 2003-08-22 15:57     ` Lute Kamstra
  0 siblings, 0 replies; 4+ messages in thread
From: Lute Kamstra @ 2003-08-22 15:57 UTC (permalink / raw)


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> AFAICS auto-mode-alist just specifies a function to call. Is there any
> reason the following is not a good idea?
>
> (defun foo ()
>   (paragraph-indent-text-mode)
>   (turn-on-auto-fill))
>
> (setq auto-mode-alist (cons '("\.plan$" . foo) auto-mode-alist))

Apart from the fact that it's better to use 

(add-to-list 'auto-mode-alist '("\.plan$" . foo))

in case you eval your .emacs more than once, this seems like a fine
solution to me.

  Lute.

-- 
(spook) => "supercomputer LABLINK rs9512c"
(insert-file-contents "~/.signature") => (error "`~/.signature' too rude")

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

end of thread, other threads:[~2003-08-22 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.634.1061522029.29551.help-gnu-emacs@gnu.org>
2003-08-22  6:41 ` adding hook to auto-mode-alist load Lute Kamstra
2003-08-22 14:40   ` Johan Bockgård
2003-08-22 15:57     ` Lute Kamstra
2003-08-21 21:09 Todd Wylie

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.