emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Tim Cross <theophilusx@gmail.com>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Richard Lawrence <richard.lawrence@uni-tuebingen.de>,
	Marco Wahl <marcowahlsoft@gmail.com>,
	emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fix org-comment-line-break-function
Date: Tue, 30 Nov 2021 20:44:36 -0500	[thread overview]
Message-ID: <CAFyQvY3gjSa17W_bDMjmLpX1aH15i9DxQ6ZHpW+1uXCW8Te9cQ@mail.gmail.com> (raw)
In-Reply-To: <87zgpli5nc.fsf@gmail.com>

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

On Tue, Nov 30, 2021 at 6:29 PM Tim Cross <theophilusx@gmail.com> wrote:

>
> It would be good to get Nicholas' input here as I think he wrote the
> original function back in 2012.
>

Just to see what happens, I tried this:

M-: (setq-local comment-line-break-function #'comment-indent-new-line)

.. and then M-j started working perfectly! It worked fine both: in Org
comment lines and out of comment lines.

I see that comment-indent-new-line was added to emacs in newcomment.el back
in 2000. So I don't know why org-comment-line-break-function was added. May
be Nicolas can comment more on that.

So would this patch work?

=====

From 1a9187b82ed8d4e8d54ddd369a44d34295281fc3 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Tue, 30 Nov 2021 20:37:10 -0500
Subject: [PATCH] org: Remove `org-comment-line-break-function'

* lisp/org.el: Remove `org-comment-line-break-function' and let
`comment-line-break-function' be the default value.

This fixes the `M-j' binding issue reported by Richard Lawrence in
<https://lists.gnu.org/r/emacs-orgmode/2021-11/msg00639.html>.
---
 lisp/org.el | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ec59ddf44..ee8ca1f03 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19624,8 +19624,7 @@ assumed to be significant there."

 ;; `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.
+;; `org-adaptive-fill-function' value.

 ;; `org-setup-filling' installs filling and auto-filling related
 ;; variables during `org-mode' initialization.
@@ -19647,8 +19646,7 @@ assumed to be significant there."
   (setq-local fill-paragraph-function 'org-fill-paragraph)
   (setq-local auto-fill-inhibit-regexp nil)
   (setq-local adaptive-fill-function 'org-adaptive-fill-function)
-  (setq-local normal-auto-fill-function 'org-auto-fill-function)
-  (setq-local comment-line-break-function
'org-comment-line-break-function))
+  (setq-local normal-auto-fill-function 'org-auto-fill-function))

 (defun org-fill-line-break-nobreak-p ()
   "Non-nil when a new line at point would create an Org line break."
@@ -19903,17 +19901,6 @@ filling the current element."
      (adaptive-fill-mode (not (equal fill-prefix ""))))
  (when fill-prefix (do-auto-fill))))))

-(defun org-comment-line-break-function (&optional soft)
-  "Break line at point and indent, continuing comment if within one.
-The inserted newline is marked hard if variable
-`use-hard-newlines' is true, unless optional argument SOFT is
-non-nil."
-  (if soft (insert-and-inherit ?\n) (newline 1))
-  (save-excursion (forward-char -1) (delete-horizontal-space))
-  (delete-horizontal-space)
-  (indent-to-left-margin)
-  (insert-before-markers-and-inherit fill-prefix))
-

 ;;; Fixed Width Areas

-- 
2.34.0

=====

[-- Attachment #2: Type: text/html, Size: 4033 bytes --]

  parent reply	other threads:[~2021-12-01  1:46 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 [this message]
2021-12-01  6:17                     ` Tim Cross
2021-12-01  8:16                       ` Richard Lawrence
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=CAFyQvY3gjSa17W_bDMjmLpX1aH15i9DxQ6ZHpW+1uXCW8Te9cQ@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=marcowahlsoft@gmail.com \
    --cc=richard.lawrence@uni-tuebingen.de \
    --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).