emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] org-style


From: Marco Wahl
Subject: Re: [O] [RFC] org-style
Date: Tue, 14 May 2019 00:41:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Ciao Gregor,

>> What do you think about this?  Is this worth to merge into org mode?
>
> This is nice, I played with it and see it's merit, but I think
> this should not be enabled by default.
>
> Even if the user had to enable it first via customization, this
> version of the code has another drawback: if it actually touches
> the buffer in order to change the number of blank lines it at the
> same time removes the indentation of the first non blank line.
> This might not be what the user wishes and should either not be
> the case or also disabled per default:

Thanks for the feedback.

I fully agree to just offer this styling as an option.

The other issue, i.e. accidential deletion of leading whitespace and
thanks for pointing that out, can be solved by using the following code
AFAICS.

#v+
(defun org-style-blanklines-assure (num)
  "Assure exactly NUM blanklines and set point to the end of those.
The buffer remains unchanged when the blanklines are already
there and empty."
  (skip-chars-backward "\t \n")
  (let ((numplusone-newlines (make-string (1+ num) ?\n)))
    (if (looking-at (concat numplusone-newlines  "[^\n]"))
        (goto-char (1- (match-end 0)))
      (when (looking-at "\\(\\(\t\\| \\)*\n\\)+")
        (delete-region (match-beginning 0) (match-end 0)))
      (insert numplusone-newlines))))
#v-


Ciao,  Marco




reply via email to

[Prev in Thread] Current Thread [Next in Thread]