emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-faq.org: Inline comments
Date: Wed, 28 Jun 2023 22:51:11 +0700	[thread overview]
Message-ID: <u7hktf$pki$1@ciao.gmane.io> (raw)
In-Reply-To: <u709dm$6q8$1@ciao.gmane.io>

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

On 22/06/2023 08:50, Max Nikulin wrote:
> On 22/06/2023 07:04, ypuntot wrote:
>>
>> Could it be possible to make inline comments (# something like this) ?
...
> Previous discussion:
...

I think, it is time to add a FAQ entry, see the attachment.

To my taste FAQ is rather long already. If you have an idea of another 
place on Worg where such tricks may be added then, please, share it.

[-- Attachment #2: 0001-org-faq.org-Inline-comments.patch --]
[-- Type: text/x-patch, Size: 3414 bytes --]

From a8dd1797588bdab7f63628579414c65d7444f387 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 28 Jun 2023 22:40:40 +0700
Subject: [PATCH] org-faq.org: Inline comments

* org-faq.org (Export): New heading describing workarounds
for inline comments.
---
 org-faq.org | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/org-faq.org b/org-faq.org
index ab661395..7048ab2d 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -4492,6 +4492,59 @@ ** How can I suppress the page number in the footer of an exported PDF?
 
 : #+LATEX: \thispagestyle{empty}
 
+** Is it possible to add inline comments?
+:PROPERTIES:
+:CUSTOM_ID: inline-comments
+:END:
+
+Unfortunately [[https://orgmode.org/manual/Comment-Lines.html][comments]]
+in Org are block-level elements, so they break paragraphs.
+However some workarounds are possible.
+
+Choose a non-standard export backend name and use it in
+[[https://orgmode.org/worg/org-syntax.html#Export_Snippets][export snippets]]:
+=@@comment: rewrite it @@=  or even =@@c: be concise@@=.
+
+Define a [[https://orgmode.org/manual/Macro-Replacement.html][macro]]
+that expands to nothing
+: #+MACRO: comment
+an use it as ={{{comment( not ideal )}}}=.
+A downside of this approach is warnings issued by ~org-lint~.
+
+Define a [[https://orgmode.org/manual/Adding-Hyperlink-Types.html][custom link type]]
+#+begin_src elisp :exports code :eval never-export
+  (org-link-set-parameters "rem" :export (lambda (&rest _) ""))
+#+end_src
+A bonus is that you may create a
+=[[rem: hidden part of comment][...]]= try =C-h .= (~display-local-help~)
+or =C-c C-l= (~org-insert-link~) to read first part of the comment.
+Another link syntax is =<rem: comment>=.  Beware of patterns that may
+appear in plain text and be recognized as links even without
+enclosing brackets like =rem:10=.  Use a unique sequence of letters
+as the link type.
+
+Use inline [[https://orgmode.org/manual/Structure-of-Code-Blocks.html][source code blocks]]
+for a programming language that does not appear in your text.
+Just suppress export
+: #+header-args:csh :exports none :eval never-export
+and =src_csh{code}= becomes indistinguishable from comments.
+Perhaps with a custom ~org-babel~ backend that evaluates
+code to the same string you may control whether comments
+should appear in exported file.
+
+It is safer to avoid lines that have no text besides comments.
+They may be treated as paragraph separators.
+
+Unfortunately never approach suggested above works on sites for
+hosting of open source code projects. Literal markup
+(or broken links) will appear in e.g. formatted =README.org= files.
+
+Discussions on the mailing list:
+- [[https://list.orgmode.org/5210ac1c-ed73-4b82-a296-41cf90b9f0a7@gmail.com/][Inline comments. Thu, 22 Jun 2023 02:04:15 +0200]]
+- [[https://list.orgmode.org/mid:87zg8jwp26.fsf@localhost/][Re: [BUG] No space after footnote with org-export-with-footnotes set to nil. Sat, 11 Mar 2023 10:38:25 +0000]]
+- [[https://list.orgmode.org/87618398-cf6d-86b4-ba59-144f70d0f96e@7d.nz/][[PATCH] ox: fix comment exported as a blank line. Wed, 1 Jun 2022 07:30:01 +0200]]
+- [[https://list.orgmode.org/alpine.DEB.2.22.394.2107161156080.74845@shell3.miskatonic.org/][Comments break up a paragraph when writing one-setence-per-line. Fri, 16 Jul 2021 12:06:54 -0400]]
+
 * Backup
 
 #+index: Backup
-- 
2.25.1


  reply	other threads:[~2023-06-28 15:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22  0:04 Inline comments ypuntot
2023-06-22  1:50 ` Max Nikulin
2023-06-28 15:51   ` Max Nikulin [this message]
2023-06-29 10:47     ` [PATCH] org-faq.org: " Ihor Radchenko
2023-06-30 10:34       ` Max Nikulin
2023-07-01 10:48         ` Ihor Radchenko
2023-08-06 18:34           ` Bastien Guerry
2023-07-01 15:24         ` Ihor Radchenko
2023-07-02  5:46           ` Org FAQ design (Re: [PATCH] org-faq.org: Inline comments) Max Nikulin
2023-07-08  5:48       ` [PATCH v2] org-faq.org: Inline comments Max Nikulin
2023-07-08  9:31         ` Ihor Radchenko
2023-07-10 16:09           ` Max Nikulin
2023-09-01 11:28             ` Ihor Radchenko
2024-04-15 12:17               ` Ihor Radchenko
2024-04-17 14:44                 ` Max Nikulin
2024-04-20 11:14                   ` Trailing whitespace after export snippets without a transcoder (was: [PATCH v2] org-faq.org: Inline comments) Ihor Radchenko
2024-04-20 15:02                     ` Trailing whitespace after export snippets without a transcoder Max Nikulin
2024-04-21 13:00                       ` Ihor Radchenko
2024-04-22 10:45                         ` Max Nikulin
2024-04-22 19:01                           ` Ihor Radchenko
2024-04-25 10:54                             ` Max Nikulin
2024-04-28 11:19                               ` Ihor Radchenko
2024-05-19 10:04                                 ` Ihor Radchenko

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='u7hktf$pki$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).