emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Lawrence <richard.lawrence@uni-tuebingen.de>
To: Tim Cross <theophilusx@gmail.com>, Kaushal Modi <kaushal.modi@gmail.com>
Cc: Marco Wahl <marcowahlsoft@gmail.com>,
	emacs-org list <emacs-orgmode@gnu.org>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: [PATCH] Fix org-comment-line-break-function
Date: Wed, 01 Dec 2021 09:16:49 +0100	[thread overview]
Message-ID: <874k7s91u6.fsf@aquinas.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <87lf14j0t4.fsf@gmail.com>

Tim Cross <theophilusx@gmail.com> writes:

> Well, that is the big question - why was
> org-comment-line-break-function added instead of just using the
> default comment-indent-new-line?

Looking back at commit d58d40f0c864ae3a6d7c66df34769619ad2486c1, I see
this comment was added by Nicolas (still in org.el):

;; `org-auto-fill-function' takes care of auto-filling. It calls
;; `do-auto-fill' only on valid areas with `fill-prefix' shadowed with
;; `org-adaptive-fill-function' value. Internally,
;; `org-comment-line-break-function' breaks the line.

which at least suggests ("Internally, ...") that
org-comment-line-break-function was never intended to be called to break
a comment via a user command like M-j, and was only intended to be
called during filling, in a context where fill-prefix would be set correctly.

In that case, the problem might be that org-setup-filling sets
comment-line-break-function to 'org-comment-line-break-function
(overriding the default value of 'comment-indent-new-line) "globally" in
Org buffers, causing it to be called even when fill-prefix is not
set correctly.

The documentation for (the variable) comment-line-break-function is a
bit confusing:

"Mode-specific function that line breaks and continues a comment.
This function is called during auto-filling when a comment syntax
is defined."

which also suggests that this function will only be called during
filling. But that is clearly not true (even if it once was), since
default-indent-new-line calls it directly.

So maybe org-comment-line-break-function was written under assumptions
that no longer hold?

It might also be worth pointing out here that
org-comment-line-break-function is *almost* a line-for-line copy of part of
default-indent-new-line, except the latter is more careful about
checking that fill-prefix is not nil before calling insert-* on it.

> Until this is determined, I think the only 'safe' approach would be to
> just advise those who are impacted by the M-j issue to set
> comment-line-break-function to comment-indent-new-line and then wait
> to see if someone who has more historical context to comment. 

This is a bit trickier than it sounds, because in Org buffers,
org-setup-filling calls

(setq-local comment-line-break-function 'org-comment-line-break-function)

which will override any global value for comment-line-break-function
(e.g. in your init file).  So you'd have to reset it in Org
buffers locally, via a hook that runs after org-setup-filling.

-- 
Best,
Richard


  reply	other threads:[~2021-12-01  8:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28 10:26 Is M-j broken for you in Org on Emacs 27 and 28? Richard Lawrence
2021-11-28 14:37 ` Greg Minshall
2021-11-28 14:45 ` Colin Baxter 😺
2021-11-28 20:17   ` Richard Lawrence
2021-11-29  1:18     ` Tim Cross
2021-11-29  8:09       ` Richard Lawrence
2021-11-29 13:35         ` Tim Cross
2021-11-29 15:49           ` Richard Lawrence
2021-11-29 14:31         ` Colin Baxter 😺
2021-11-30  1:10         ` Tim Cross
2021-11-30 17:03           ` [PATCH] Fix org-comment-line-break-function (was: Is M-j broken for you in Org on Emacs 27 and 28?) Richard Lawrence
2021-11-30 20:18             ` [PATCH] Fix org-comment-line-break-function Marco Wahl
2021-11-30 22:06               ` Tim Cross
2021-12-01  8:36                 ` Marco Wahl
2021-11-30 22:08               ` Kaushal Modi
2021-11-30 23:15                 ` Tim Cross
2021-11-30 23:53                   ` Kaushal Modi
2021-12-01  1:44                   ` Kaushal Modi
2021-12-01  6:17                     ` Tim Cross
2021-12-01  8:16                       ` Richard Lawrence [this message]
2021-12-01 13:02                     ` Nicolas Goaziou
2021-12-04 22:23                     ` Tim Cross
2021-12-05  3:36                       ` Kaushal Modi
2021-12-05  9:14                         ` Nicolas Goaziou
2021-12-06 13:17                         ` Richard Lawrence
2021-12-06 13:51                           ` Kaushal Modi
2021-12-11 15:47                             ` Nicolas Goaziou
2022-09-29  5:11                             ` Ihor Radchenko
     [not found]                               ` <871qro5e4w.fsf@aquinas.mail-host-address-is-not-set>
2022-10-04 11:55                                 ` Ihor Radchenko
2021-11-30 17:16           ` Is M-j broken for you in Org on Emacs 27 and 28? Morgan Willcock
2021-11-29  8:22       ` Richard Lawrence

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=874k7s91u6.fsf@aquinas.i-did-not-set--mail-host-address--so-tickle-me \
    --to=richard.lawrence@uni-tuebingen.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=kaushal.modi@gmail.com \
    --cc=mail@nicolasgoaziou.fr \
    --cc=marcowahlsoft@gmail.com \
    --cc=theophilusx@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).