all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* mode-specific paragraph-start
@ 2007-12-11 16:31 Tyler Smith
  2007-12-11 19:00 ` Peter Dyballa
  0 siblings, 1 reply; 4+ messages in thread
From: Tyler Smith @ 2007-12-11 16:31 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I want Emacs to recognise ".* wrote:$" as the end of a paragraph, so
that I can autofill email messages and not have the body of a message
get mixed in with the intro i.e., "Tyler wrote:".

I use the following hook to do this (among other things):

(defun my-mail-mode-hook ()
  (auto-fill-mode 1)
  (abbrev-mode 1)
  (fortune-to-signature)
  (setq paragraph-separate (concat paragraph-separate "\\|.* wrote:$"))
  (setq paragraph-start (concat paragraph-start "\\|.* wrote:$"))
  (set-fill-column 70))
(add-hook 'mail-mode-hook 'my-mail-mode-hook)

What I now notice is that my regexp gets added every time I send an
email, so that by the end of the day it's several lines long.
Currently it's: \f\|[ 	]*$\|.* wrote:$\|.* wrote:$

How do I set this variable so that it doesn't continuously grow?

Thanks,

Tyler

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

* Re: mode-specific paragraph-start
  2007-12-11 16:31 mode-specific paragraph-start Tyler Smith
@ 2007-12-11 19:00 ` Peter Dyballa
  2007-12-12  0:24   ` tyler
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Dyballa @ 2007-12-11 19:00 UTC (permalink / raw)
  To: Tyler Smith; +Cc: help-gnu-emacs


Am 11.12.2007 um 17:31 schrieb Tyler Smith:

> How do I set this variable so that it doesn't continuously grow?


(if (not (exists your_new_variable))
     (setq your_new_variable to_your_desired_value)
     (setq paragraph-separate 'your_new_variable)
     (setq paragraph-start 'your_new_variable)
)

If you feel uncertain whether your settings of paragraph-* are reset  
anywhere, put them outside the if clause so that are set right every  
time.

--
Greetings

   Pete

To be is to do.
			– I. Kant
To do is to be.
			– A. Sartre
Yabba-Dabba-Doo!
			– F. Flintstone

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

* Re: mode-specific paragraph-start
  2007-12-12  0:24   ` tyler
@ 2007-12-11 21:01     ` Peter Dyballa
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2007-12-11 21:01 UTC (permalink / raw)
  To: tyler; +Cc: help-gnu-emacs


Am 12.12.2007 um 01:24 schrieb tyler:

> That didn't quite work, as exists is not a recognized function

Of course! For me it was obvious that I only wrote pseudo code.  
Sorry, that I did not express this more clearly. Instead of exists:  
(fboundp SYMBOL) ? (symbol-value SYMBOL) throws an error if not  
existing ...

The idea is to create a semaphore that shows that you've already done  
this initialisation, that doing it again can be prevented when the  
semaphore is queried – common to a few programming languages. I am no  
Lisp programmer, so I cannot tell what the right approach is. Could  
be it's best to just check whether the variable already contains  
(matches) your addition?

--
Greetings

   Pete

A child of five could understand this!  Fetch me a child of five.

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

* Re: mode-specific paragraph-start
  2007-12-11 19:00 ` Peter Dyballa
@ 2007-12-12  0:24   ` tyler
  2007-12-11 21:01     ` Peter Dyballa
  0 siblings, 1 reply; 4+ messages in thread
From: tyler @ 2007-12-12  0:24 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

On Tue, Dec 11, 2007 at 08:00:22PM +0100, Peter Dyballa wrote:
> Am 11.12.2007 um 17:31 schrieb Tyler Smith:
>> How do I set this variable so that it doesn't continuously grow?

> (if (not (exists your_new_variable))
>     (setq your_new_variable to_your_desired_value)
>     (setq paragraph-separate 'your_new_variable)
>     (setq paragraph-start 'your_new_variable)
> )
>

Thanks. That didn't quite work, as exists is not a recognized function
for me. Also, I noticed that paragraph-start is global for mail-mode,
so any changes were 'permanent'. So this is what I have, which seems
to work so far:

(defun my-mail-mode-hook ()
  (auto-fill-mode 1)
  (abbrev-mode 1)
  (fortune-to-signature)
  (make-local-variable 'paragraph-start)
  (if (not (boundp 'my_mail_paragraph))
      (setq my_mail_paragraph (concat paragraph-separate "\\|.* wrote:$")))
  (setq paragraph-separate my_mail_paragraph)
  (setq paragraph-start my_mail_paragraph)
  (set-fill-column 70))
(add-hook 'mail-mode-hook 'my-mail-mode-hook)

Any further suggestions welcome!

Cheers,

Tyler


-- 
Friends don't let friends send Word documents

http://www.nothingisreal.com/dfki/no-word

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

end of thread, other threads:[~2007-12-12  0:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 16:31 mode-specific paragraph-start Tyler Smith
2007-12-11 19:00 ` Peter Dyballa
2007-12-12  0:24   ` tyler
2007-12-11 21:01     ` Peter Dyballa

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.