emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marco Wahl <marcowahlsoft@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [RFC] org-style
Date: Tue, 14 May 2019 00:41:17 +0200	[thread overview]
Message-ID: <847eaudlki.fsf@gmail.com> (raw)
In-Reply-To: 87pnoqpcd4.fsf@len.workgroup

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	other threads:[~2019-05-13 22:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 11:55 [RFC] org-style Marco Wahl
2019-05-10 14:25 ` J. David Boyd
2019-05-10 15:17 ` Gregor Zattler
2019-05-13 22:41   ` Marco Wahl [this message]

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=847eaudlki.fsf@gmail.com \
    --to=marcowahlsoft@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).