emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to add comments in a plain list
@ 2009-09-22  2:37 René
  2009-09-22  4:16 ` Bernt Hansen
  0 siblings, 1 reply; 13+ messages in thread
From: René @ 2009-09-22  2:37 UTC (permalink / raw)
  To: emacs-orgmode

Is there a way to insert comments in a plain list without breaking it into two
distinct lists?

Such a list:

 1. first
 2. second
 # comment about second item
 3. third
 4. fourth

is actually considered as

 1. first
 2. second
 # comment about second item
 1. third
 2. fourth

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

* Re: How to add comments in a plain list
  2009-09-22  2:37 How to add comments in a plain list René
@ 2009-09-22  4:16 ` Bernt Hansen
  2009-09-22 11:20   ` Eric S Fraga
  2009-09-22 11:32   ` René
  0 siblings, 2 replies; 13+ messages in thread
From: Bernt Hansen @ 2009-09-22  4:16 UTC (permalink / raw)
  To: René; +Cc: emacs-orgmode

René <jlr_0@yahoo.com> writes:

> Is there a way to insert comments in a plain list without breaking it into two
> distinct lists?
>
> Such a list:
>
>  1. first
>  2. second
>  # comment about second item
>  3. third
>  4. fourth
>
> is actually considered as
>
>  1. first
>  2. second
>  # comment about second item
>  1. third
>  2. fourth

You can ident the comment like this

 1. first
 2. second

    # comment about second item

 3. third
 4. fourth

-Bernt

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

* Re: Re: How to add comments in a plain list
  2009-09-22  4:16 ` Bernt Hansen
@ 2009-09-22 11:20   ` Eric S Fraga
  2009-09-22 12:52     ` Bernt Hansen
  2009-09-22 11:32   ` René
  1 sibling, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2009-09-22 11:20 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode, René

At Tue, 22 Sep 2009 00:16:14 -0400, Bernt Hansen wrote:
> René <jlr_0@yahoo.com> writes:
> > Is there a way to insert comments in a plain list without breaking it into two
> > distinct lists?

I've run into exactly this problem in the past few days, preparing a
document, intended for export to a variety of formats, containing a
number of enumerated lists.

> You can ident the comment like this
> 
>  1. first
>  2. second
> 
>     # comment about second item
> 
>  3. third
>  4. fourth
> 
> -Bernt

I had already tried this but the export breaks.  At least for me,
indented comments come out in ascii, latex and html exports.  Is there
an option that turns off that behaviour?  I haven't seen one...

Thanks,
eric

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

* Re: How to add comments in a plain list
  2009-09-22  4:16 ` Bernt Hansen
  2009-09-22 11:20   ` Eric S Fraga
@ 2009-09-22 11:32   ` René
  2009-09-22 12:10     ` Carsten Dominik
  1 sibling, 1 reply; 13+ messages in thread
From: René @ 2009-09-22 11:32 UTC (permalink / raw)
  To: emacs-orgmode

Bernt Hansen <bernt <at> norang.ca> writes:
> You can ident the comment like this
> 
>  1. first
>  2. second
> 
>     # comment about second item
> 
>  3. third
>  4. fourth

Unfortunately in this case your comment gets exported since the `#' is indented.

Of course one doesn't want the comments to appear in the html version of the
document. 

Is there a way to easily solve this issue?

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

* Re: Re: How to add comments in a plain list
  2009-09-22 11:32   ` René
@ 2009-09-22 12:10     ` Carsten Dominik
  0 siblings, 0 replies; 13+ messages in thread
From: Carsten Dominik @ 2009-09-22 12:10 UTC (permalink / raw)
  To: René; +Cc: emacs-orgmode


On Sep 22, 2009, at 12:32 PM, René wrote:

> Bernt Hansen <bernt <at> norang.ca> writes:
>> You can ident the comment like this
>>
>> 1. first
>> 2. second
>>
>>    # comment about second item
>>
>> 3. third
>> 4. fourth
>
> Unfortunately in this case your comment gets exported since the `#'  
> is indented.
>
> Of course one doesn't want the comments to appear in the html  
> version of the
> document.
>
> Is there a way to easily solve this issue?

You can always add a function to one of the org-export-preprocess-...  
hooks.
However, if you are not careful, you might remove something like

    #!/bin/sh

    in a source code block, or some normal text where,
    #25 starts a new line by accident.

It may be relatively safe to look for # followed by space, or
lines that have only "#" ad the only nonwhite character on a line.

Something like this might work (untested)

(add-hook
  'org-export-preprocess-before-backend-specifics-hook
  (lambda ()
    (goto-char (point-min))
    (while (re-search-forward "^[ \t]+#\\([ \t]*$\\| .*$\\)\n?" nil t)
      (org-if-unprotected-at (match-beginning 1)
       (replace-match "")))))


HTH

- Carsten

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

* Re: Re: How to add comments in a plain list
  2009-09-22 11:20   ` Eric S Fraga
@ 2009-09-22 12:52     ` Bernt Hansen
  2009-09-22 13:20       ` Eric S Fraga
  0 siblings, 1 reply; 13+ messages in thread
From: Bernt Hansen @ 2009-09-22 12:52 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode, René

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

> At Tue, 22 Sep 2009 00:16:14 -0400, Bernt Hansen wrote:
>> René <jlr_0@yahoo.com> writes:
>> > Is there a way to insert comments in a plain list without breaking it into two
>> > distinct lists?
>
> I've run into exactly this problem in the past few days, preparing a
> document, intended for export to a variety of formats, containing a
> number of enumerated lists.
>
>> You can ident the comment like this
>> 
>>  1. first
>>  2. second
>> 
>>     # comment about second item
>> 
>>  3. third
>>  4. fourth
>> 
>> -Bernt
>
> I had already tried this but the export breaks.  At least for me,
> indented comments come out in ascii, latex and html exports.  Is there
> an option that turns off that behaviour?  I haven't seen one...

If you're actually trying to make the comment not export this seems to
work for me

 1. first
 2. second
 #+ comment about second item
 3. third
 4. fourth

-Bernt

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

* Re: Re: How to add comments in a plain list
  2009-09-22 12:52     ` Bernt Hansen
@ 2009-09-22 13:20       ` Eric S Fraga
  2009-09-22 14:10         ` Bernt Hansen
  0 siblings, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2009-09-22 13:20 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode, René

At Tue, 22 Sep 2009 08:52:13 -0400, Bernt Hansen wrote:
> If you're actually trying to make the comment not export this seems to
> work for me
> 
>  1. first
>  2. second
>  #+ comment about second item
>  3. third
>  4. fourth
> 
> -Bernt

and in fact it works without the + sign and that's what I was using
initial, as was the OP (René I guess).  however, we're going around in
circles here because comments at column 0 cause org-mode to consider
the next item to start a new list so your fourth item (if you hit C-c
C-c on it) will be renumbered to 1, as indicated by the OP!

Basically, we wish to have comments which don't interrupt the list
numbering *and* are not exported either.  Is this possible?

thanks,
eric

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

* Re: Re: How to add comments in a plain list
  2009-09-22 13:20       ` Eric S Fraga
@ 2009-09-22 14:10         ` Bernt Hansen
  2009-09-22 15:53           ` Eric S Fraga
  0 siblings, 1 reply; 13+ messages in thread
From: Bernt Hansen @ 2009-09-22 14:10 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode, René

Eric S Fraga <ucecesf@ucl.ac.uk> writes:

> At Tue, 22 Sep 2009 08:52:13 -0400, Bernt Hansen wrote:
>> If you're actually trying to make the comment not export this seems to
>> work for me
>> 
>>  1. first
>>  2. second
>>  #+ comment about second item
>>  3. third
>>  4. fourth
>> 
>> -Bernt
>
> and in fact it works without the + sign and that's what I was using
> initial, as was the OP (René I guess).  however, we're going around in
> circles here because comments at column 0 cause org-mode to consider
> the next item to start a new list so your fourth item (if you hit C-c
> C-c on it) will be renumbered to 1, as indicated by the OP!
>
> Basically, we wish to have comments which don't interrupt the list
> numbering *and* are not exported either.  Is this possible?

At column 0 - probably not.

 1. first
 2. second
    #+ comment about second item
    #+ Another comment goes here
 3. third
 4. fourth

The #+ comment probably isn't officially supported either... it just
happens to work.  Sorry about the run-around :)

-Bernt

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

* Re: Re: How to add comments in a plain list
  2009-09-22 14:10         ` Bernt Hansen
@ 2009-09-22 15:53           ` Eric S Fraga
  2009-09-22 18:30             ` René
  0 siblings, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2009-09-22 15:53 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode, René

At Tue, 22 Sep 2009 10:10:41 -0400,
Bernt Hansen wrote:
> At column 0 - probably not.
> 
>  1. first
>  2. second
>     #+ comment about second item
>     #+ Another comment goes here
>  3. third
>  4. fourth
> 
> The #+ comment probably isn't officially supported either... it just
> happens to work.  Sorry about the run-around :)
> 
> -Bernt

Ah ha!  Of the four combinations (# versus #+ and column 0 or not),
this one works perfectly!  Thanks.

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

* Re: How to add comments in a plain list
  2009-09-22 15:53           ` Eric S Fraga
@ 2009-09-22 18:30             ` René
  2009-09-24  9:27               ` Carsten Dominik
  0 siblings, 1 reply; 13+ messages in thread
From: René @ 2009-09-22 18:30 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <ucecesf <at> ucl.ac.uk> writes:
> At Tue, 22 Sep 2009 10:10:41 -0400, Bernt Hansen wrote:
> > At column 0 - probably not.
> > 
> >  1. first
> >  2. second
> >     #+ comment about second item
> >     #+ Another comment goes here
> >  3. third
> >  4. fourth
> > 
> > The #+ comment probably isn't officially supported either... it just
> > happens to work.  Sorry about the run-around :)

Unfortunately, in this case Emacs doesn't fontify those lines as if they were
comments.

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

* Re: Re: How to add comments in a plain list
  2009-09-22 18:30             ` René
@ 2009-09-24  9:27               ` Carsten Dominik
  2009-09-25 10:10                 ` Eric S Fraga
  0 siblings, 1 reply; 13+ messages in thread
From: Carsten Dominik @ 2009-09-24  9:27 UTC (permalink / raw)
  To: René; +Cc: emacs-orgmode


On Sep 22, 2009, at 7:30 PM, René wrote:

> Eric S Fraga <ucecesf <at> ucl.ac.uk> writes:
>> At Tue, 22 Sep 2009 10:10:41 -0400, Bernt Hansen wrote:
>>> At column 0 - probably not.
>>>
>>> 1. first
>>> 2. second
>>>    #+ comment about second item
>>>    #+ Another comment goes here
>>> 3. third
>>> 4. fourth
>>>
>>> The #+ comment probably isn't officially supported either... it just
>>> happens to work.  Sorry about the run-around :)
>
> Unfortunately, in this case Emacs doesn't fontify those lines as if  
> they were
> comments.

It does now.

- Carsten

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

* Re: Re: How to add comments in a plain list
  2009-09-24  9:27               ` Carsten Dominik
@ 2009-09-25 10:10                 ` Eric S Fraga
  2009-09-28  7:21                   ` Carsten Dominik
  0 siblings, 1 reply; 13+ messages in thread
From: Eric S Fraga @ 2009-09-25 10:10 UTC (permalink / raw)
  To: emacs-orgmode

At Thu, 24 Sep 2009 10:27:57 +0100, Carsten Dominik wrote:
> On Sep 22, 2009, at 7:30 PM, René wrote:
> > Unfortunately, in this case Emacs doesn't fontify those lines as if
> > they were comments.
> 
> It does now.
> 
> - Carsten

Carsten, thanks for this.  It works perfectly.

But this leads to me a more general question for all of you emacs
experts: comments in my org files typically consist of /less
important/ text and so I like to de-emphasise the text by changing the
face used (to a light gray, in my case, compared with the default of
firebrick).  However, for programming, I prefer the default.  Can
somebody suggest how I can have a different font-lock-comment-face for
org-mode files without making a global change?  Should I put something
in the org-mode hook?

Or even on a per-file basis?  I've tried using Emacs local variables
but haven't found the right incantation... :(

Any suggestions more than welcome!

Thanks,
eric

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

* Re: Re: How to add comments in a plain list
  2009-09-25 10:10                 ` Eric S Fraga
@ 2009-09-28  7:21                   ` Carsten Dominik
  0 siblings, 0 replies; 13+ messages in thread
From: Carsten Dominik @ 2009-09-28  7:21 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode


On Sep 25, 2009, at 11:10 AM, Eric S Fraga wrote:

> At Thu, 24 Sep 2009 10:27:57 +0100, Carsten Dominik wrote:
>> On Sep 22, 2009, at 7:30 PM, René wrote:
>>> Unfortunately, in this case Emacs doesn't fontify those lines as if
>>> they were comments.
>>
>> It does now.
>>
>> - Carsten
>
> Carsten, thanks for this.  It works perfectly.
>
> But this leads to me a more general question for all of you emacs
> experts: comments in my org files typically consist of /less
> important/ text and so I like to de-emphasise the text by changing the
> face used (to a light gray, in my case, compared with the default of
> firebrick).  However, for programming, I prefer the default.  Can
> somebody suggest how I can have a different font-lock-comment-face for
> org-mode files without making a global change?  Should I put something
> in the org-mode hook?
>
> Or even on a per-file basis?  I've tried using Emacs local variables
> but haven't found the right incantation... :(
>
> Any suggestions more than welcome!

Hi Eric,

I don't know how to change `font-lock-comment-face' on a per-buffer  
level.

What you can do though (I think) is use the function `font-lock-add- 
keywords'
to add your own regular expression for matching comments and specify
an arbitrary font for this match.  For example (untested):

  (font-lock-add-keywords 'org-mode
   '(("^[ \t]*#.*" 0 my-org-comment-face prepend)))

- Carsten

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

end of thread, other threads:[~2009-09-28  7:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-22  2:37 How to add comments in a plain list René
2009-09-22  4:16 ` Bernt Hansen
2009-09-22 11:20   ` Eric S Fraga
2009-09-22 12:52     ` Bernt Hansen
2009-09-22 13:20       ` Eric S Fraga
2009-09-22 14:10         ` Bernt Hansen
2009-09-22 15:53           ` Eric S Fraga
2009-09-22 18:30             ` René
2009-09-24  9:27               ` Carsten Dominik
2009-09-25 10:10                 ` Eric S Fraga
2009-09-28  7:21                   ` Carsten Dominik
2009-09-22 11:32   ` René
2009-09-22 12:10     ` Carsten Dominik

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