emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Christian Wittern <cwittern@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Should comments break paragraphs?
Date: Tue, 16 Jul 2013 09:46:26 -0600	[thread overview]
Message-ID: <87fvvev771.fsf@gmail.com> (raw)
In-Reply-To: <87ip0byoqg.fsf@gmail.com> (Nicolas Goaziou's message of "Tue, 16 Jul 2013 08:59:19 +0200")

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> Christian Wittern <cwittern@gmail.com> writes:
>
>> Hmm.  In my book, the concept of comments implies that they should be
>> able to appear on any line in the text, without altering the meaning
>> of the context it appears in.  So to me, it would seem necessary to
>> treat comments as special, different from other elements.
>
> I don't think comments make much sense anywhere in Org (e.g., in an
> example block or in a source block). Also Org has no inline comment
> syntax (and I don't think it needs one: it is no programming language).
> So comments do not really fit in paragraphs.
>

When Org-mode is used as a document preparation language inline comments
are very useful.  The use case being notes on the surrounding material
which are not to be published.  Both HTML and LaTeX support comments and
at least in LaTeX they are extensively used (in my experience) and can
be very helpful.

>
> Last, but not least, it is also easier to parse it that way.
>

Stripping lines starting with "^ *#[^+]" is a trivial pre-processing
step, and would support the traditional Org-mode comments which (as I
recall) could previously appear mid paragraph without causing problems.

>
> Now, if you want to improve comments anyway, you can always provide
> patches. There's some non-trivial work involved, though.
>

The attached patch worked on some small example files for me.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-support-inline-comments-w-o-breaking-paragraphs.patch --]
[-- Type: text/x-patch, Size: 1661 bytes --]

From ce4c30ebe56d4cd66810bca48824d8841e7b130d Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Tue, 16 Jul 2013 09:44:59 -0600
Subject: [PATCH] support inline comments w/o breaking paragraphs

* lisp/org-element.el (org-element-parse-buffer): Strip inline comments
  as a pre-processing step before exporting.
---
 lisp/org-element.el | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 8d64657..d69d9ba 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4092,13 +4092,19 @@ or objects within the parse tree.
 
 This function assumes that current major mode is `org-mode'."
   (save-excursion
-    (goto-char (point-min))
-    (org-skip-whitespace)
-    (org-element--parse-elements
-     (point-at-bol) (point-max)
-     ;; Start in `first-section' mode so text before the first
-     ;; headline belongs to a section.
-     'first-section nil granularity visible-only (list 'org-data nil))))
+    (let ((save (buffer-string)))
+      (unwind-protect
+	  (progn
+	    (goto-char (point-min))
+	    (delete-matching-lines "^ *# .[^\n]*\n")
+	    (org-skip-whitespace)
+	    (org-element--parse-elements
+	     (point-at-bol) (point-max)
+	     ;; Start in `first-section' mode so text before the first
+	     ;; headline belongs to a section.
+	     'first-section nil granularity visible-only (list 'org-data nil)))
+	(delete-region (point-min) (point-max))
+	(insert save)))))
 
 (defun org-element-parse-secondary-string (string restriction &optional parent)
   "Recursively parse objects in STRING and return structure.
-- 
1.8.3.2


[-- Attachment #3: Type: text/plain, Size: 71 bytes --]


Cheers,

>
>
> Regards,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

  parent reply	other threads:[~2013-07-16 15:48 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 18:48 Should comments break paragraphs? Kodi Arfer
2013-07-15 18:54 ` Nicolas Goaziou
2013-07-15 22:46   ` Christian Wittern
2013-07-16  6:53     ` Rainer M Krug
2013-07-16  6:59     ` Nicolas Goaziou
2013-07-16  7:09       ` Rainer M Krug
2013-07-16  7:40         ` Nicolas Goaziou
2013-07-16  8:09           ` Rainer M Krug
2013-07-16  8:19             ` Andreas Leha
2013-07-16  8:44               ` Nicolas Goaziou
2013-07-16  8:55                 ` Andreas Leha
2013-07-16 17:08                 ` Eric S Fraga
2013-07-16  8:26             ` Nicolas Goaziou
2013-07-16  8:21           ` Fabrice Popineau
2013-07-16  8:27             ` Fabrice Popineau
2013-07-16 15:46       ` Eric Schulte [this message]
2013-07-16 16:01         ` Nicolas Goaziou
2013-07-16 16:59           ` Eric Schulte
2013-07-16 17:51             ` Nicolas Goaziou
2013-07-17  5:28               ` Bastien
2013-07-17  7:17                 ` Nicolas Goaziou
2013-07-17  8:15                   ` Bastien
2013-07-17  9:00                     ` Nicolas Goaziou
2013-07-17 12:57                       ` Bastien
2013-07-17 13:21                         ` Rainer M Krug
2013-07-17 13:52                           ` Rasmus
2013-07-17 16:10                             ` Eric S Fraga
2013-07-18  7:02                               ` Christian Moe
2013-07-18  8:31                                 ` Eric Abrahamsen
2013-07-18  8:50                                   ` Rasmus
2013-07-18  9:50                                     ` Eric Abrahamsen
2013-07-18  8:47                                 ` Rasmus
2013-07-17 13:28                         ` Eric Schulte
2013-07-17 14:30                           ` Bastien
2013-07-17 13:47                         ` Nicolas Goaziou
2013-07-17 18:48                           ` Eric S Fraga
2013-07-17 19:04                             ` Nicolas Goaziou
2013-07-17 20:18                               ` Eric S Fraga
2013-07-17  7:11               ` Suvayu Ali
2013-07-17 12:54               ` Eric Schulte
2013-07-17 13:52                 ` Nicolas Goaziou
2013-07-17 22:05                 ` Andreas Leha
2013-07-17 22:11                   ` Eric Schulte
2013-07-17 22:34                     ` Andreas Leha
2013-07-18 11:23                     ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvvev771.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=cwittern@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).