emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org minor mode in mail-mode
@ 2011-03-09 13:56 René
  2011-03-20 13:53 ` Matt Lundin
  2011-09-10  2:12 ` Rene
  0 siblings, 2 replies; 7+ messages in thread
From: René @ 2011-03-09 13:56 UTC (permalink / raw)
  To: emacs-orgmode

Here is the the configuration I run

   (defun turn-on-full-org-mailing ()
     (turn-on-orgstruct++)
     (turn-on-orgtbl)
     (load "org-html-mail"))

   (add-hook 'mail-mode-hook 'turn-on-full-org-mailing)

in order make use of Org minor mode (struct, tbl) within mail-mode.

Unfortunately with this, calling M-q (fill-paragraph) right after the
header separator ("--text follows this line--") leads to filling the
header along with the first paragraph of my mail.

It turns out that the org minor mode rebinds M-q to
`orgstruct-hijacker-command-22' :

,----
| M-q runs the command orgstruct-hijacker-command-22, which is an
| interactive Lisp function.
|
| It is bound to M-q.
|
| (orgstruct-hijacker-command-22 arg)
|
| In Structure, run `fill-paragraph'.
| Outside of structure, run the binding of `\361'.
`----

Any idea on how to make use of org minor mode in mail-mode and still
be able to fill-paragraph without impacting mail headers? 

--
René

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

* Re: Org minor mode in mail-mode
  2011-03-09 13:56 Org minor mode in mail-mode René
@ 2011-03-20 13:53 ` Matt Lundin
  2011-03-20 14:59   ` Nicolas
  2011-09-10  2:12 ` Rene
  1 sibling, 1 reply; 7+ messages in thread
From: Matt Lundin @ 2011-03-20 13:53 UTC (permalink / raw)
  To: René; +Cc: emacs-orgmode

René <jlr_0@yahoo.com> writes:

> Here is the the configuration I run
>
>    (defun turn-on-full-org-mailing ()
>      (turn-on-orgstruct++)
>      (turn-on-orgtbl)
>      (load "org-html-mail"))
>
>    (add-hook 'mail-mode-hook 'turn-on-full-org-mailing)
>
> Unfortunately with this, calling M-q (fill-paragraph) right after the
> header separator ("--text follows this line--") leads to filling the
> header along with the first paragraph of my mail.
>

[...]

>
> Any idea on how to make use of org minor mode in mail-mode and still
> be able to fill-paragraph without impacting mail headers? 

The org minor modes set the local value of fill-paragraph-function to
org-fill-paragraph. You can override this by adding a line to your hook
function:

    (defun turn-on-full-org-mailing ()
      (turn-on-orgstruct++)
      (turn-on-orgtbl)
      (load "org-html-mail")
      (setq fill-paragraph-function 'message-fill-paragraph))

I'm not sure how this will affect calling fill on lists or tables,
however.

A proper fix would probably add a test to org-fill-paragraph to see if
we are in message mode.

Best,
Matt

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

* Re: Org minor mode in mail-mode
  2011-03-20 13:53 ` Matt Lundin
@ 2011-03-20 14:59   ` Nicolas
  2011-05-02 13:33     ` Rene
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas @ 2011-03-20 14:59 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, René

Hello,

Matt Lundin <mdl@imapmail.org> writes:

>> Any idea on how to make use of org minor mode in mail-mode and still
>> be able to fill-paragraph without impacting mail headers?
>
> The org minor modes set the local value of fill-paragraph-function to
> org-fill-paragraph. You can override this by adding a line to your hook
> function:
>
>     (defun turn-on-full-org-mailing ()
>       (turn-on-orgstruct++)
>       (turn-on-orgtbl)
>       (load "org-html-mail")
>       (setq fill-paragraph-function 'message-fill-paragraph))
>
> I'm not sure how this will affect calling fill on lists or tables,
> however.

It will break list and tables filling.

> A proper fix would probably add a test to org-fill-paragraph to see if
> we are in message mode.

Another idea would be to change `paragraph-start' and
`paragraph-separate' values when turning on orgstruct and orgtbl.

#+begin_src emacs-lisp
(setq paragraph-start
      (concat
       (regexp-quote mail-header-separator) "$\\|"
       "-- $\\|"			 ; signature delimiter
       "---+$\\|"		         ; delimiters for forwarded messages
       page-delimiter "$\\|"	         ; spoiler warnings
       ".*wrote:$\\|"		         ; attribution lines
       message-cite-prefix-regexp "$\\|" ; empty lines in quoted text
					 ; mml tags
       "<#!*/?\\(multipart\\|part\\|external\\|mml\\|secure\\)"
       paragraph-start))

(setq paragraph-separate paragraph-start)
#+end_src

Regards,

-- 
Nicolas

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

* Re: Org minor mode in mail-mode
  2011-03-20 14:59   ` Nicolas
@ 2011-05-02 13:33     ` Rene
  0 siblings, 0 replies; 7+ messages in thread
From: Rene @ 2011-05-02 13:33 UTC (permalink / raw)
  To: emacs-orgmode

> >> Any idea on how to make use of org minor mode in mail-mode and still
> >> be able to fill-paragraph without impacting mail headers?
> >
> > The org minor modes set the local value of fill-paragraph-function to
> > org-fill-paragraph. You can override this by adding a line to your hook
> > function:
> >
> >     (defun turn-on-full-org-mailing ()
> >       (turn-on-orgstruct++)
> >       (turn-on-orgtbl)
> >       (load "org-html-mail")
> >       (setq fill-paragraph-function 'message-fill-paragraph))
> >
> > I'm not sure how this will affect calling fill on lists or tables,
> > however.

As matter of fact, the trouble comes from `turn-on-orgstruct++'.  

Using `turn-on-orgstruct' instead is alright.  When called `fill-paragraph'
operates without interfering with the mail header.

> Another idea would be to change `paragraph-start' and
> `paragraph-separate' values when turning on orgstruct and orgtbl.

Does not seem to work for me.

--
Rene

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

* Re: Org minor mode in mail-mode
  2011-03-09 13:56 Org minor mode in mail-mode René
  2011-03-20 13:53 ` Matt Lundin
@ 2011-09-10  2:12 ` Rene
  2011-09-10  5:03   ` Eric Abrahamsen
  1 sibling, 1 reply; 7+ messages in thread
From: Rene @ 2011-09-10  2:12 UTC (permalink / raw)
  To: emacs-orgmode

René <jlr_0 <at> yahoo.com> writes:

> Here is the the configuration I run
> 
>    (defun turn-on-full-org-mailing ()
>      (turn-on-orgstruct++)
>      (turn-on-orgtbl)
>      (load "org-html-mail"))
> 
>    (add-hook 'mail-mode-hook 'turn-on-full-org-mailing)
> 
> in order make use of Org minor mode (struct, tbl) within mail-mode.
> 
> Unfortunately with this, calling M-q (fill-paragraph) right after the
> header separator ("--text follows this line--") leads to filling the
> header along with the first paragraph of my mail.

I found the right solution.  I just needed to toggle Filladapt minor mode.
This way `auto-fill-mode' and the `fill-paragraph' command are both smarter
about guessing a proper fill-prefix and finding paragraph boundaries when
indented lines and paragraphs are used.

  (require 'filladapt)
  (setq-default filladapt-mode t)

--
Rene

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

* Re: Org minor mode in mail-mode
  2011-09-10  2:12 ` Rene
@ 2011-09-10  5:03   ` Eric Abrahamsen
  2011-09-14 11:07     ` Rene
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2011-09-10  5:03 UTC (permalink / raw)
  To: emacs-orgmode

On Sat, Sep 10 2011, Rene wrote:

> René <jlr_0 <at> yahoo.com> writes:
>
>> Here is the the configuration I run
>> 
>>    (defun turn-on-full-org-mailing ()
>>      (turn-on-orgstruct++)
>>      (turn-on-orgtbl)
>>      (load "org-html-mail"))
>> 
>>    (add-hook 'mail-mode-hook 'turn-on-full-org-mailing)
>> 
>> in order make use of Org minor mode (struct, tbl) within mail-mode.
>> 
>> Unfortunately with this, calling M-q (fill-paragraph) right after the
>> header separator ("--text follows this line--") leads to filling the
>> header along with the first paragraph of my mail.
>
> I found the right solution.  I just needed to toggle Filladapt minor mode.
> This way `auto-fill-mode' and the `fill-paragraph' command are both smarter
> about guessing a proper fill-prefix and finding paragraph boundaries when
> indented lines and paragraphs are used.
>
>   (require 'filladapt)
>   (setq-default filladapt-mode t)

Thanks for this hint! I had been advising fill-paragraph, this seems
like a more comprehensive solution.

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

* Re: Org minor mode in mail-mode
  2011-09-10  5:03   ` Eric Abrahamsen
@ 2011-09-14 11:07     ` Rene
  0 siblings, 0 replies; 7+ messages in thread
From: Rene @ 2011-09-14 11:07 UTC (permalink / raw)
  To: emacs-orgmode

Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> 
> Thanks for this hint! I had been advising fill-paragraph, this seems
> like a more comprehensive solution.

What is strange though is that (turn-on-orgstruct++) messes up with the header
separator ("--text follows this line--") when calling M-q (fill-paragraph);
whereas (turn-on-orgstruct) doesn't pose any problem.

Why such a different behavior between turn-on-orgstruct++ and turn-on-orgstruct?

Is that a feature or a bug?

--
Rene

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

end of thread, other threads:[~2011-09-14 11:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-09 13:56 Org minor mode in mail-mode René
2011-03-20 13:53 ` Matt Lundin
2011-03-20 14:59   ` Nicolas
2011-05-02 13:33     ` Rene
2011-09-10  2:12 ` Rene
2011-09-10  5:03   ` Eric Abrahamsen
2011-09-14 11:07     ` Rene

Code repositories for project(s) associated with this public inbox

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

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