[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix org-comment-line-break-function
From: |
Tim Cross |
Subject: |
Re: [PATCH] Fix org-comment-line-break-function |
Date: |
Sun, 05 Dec 2021 09:23:18 +1100 |
User-agent: |
mu4e 1.7.5; emacs 28.0.90 |
Given that Nicholas cannot remember the reason for the original function
and suspects it was meant to be an internal only function, I think this
patch is probably the best way forward and should be applied.
Kaushal Modi <kaushal.modi@gmail.com> writes:
> 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