From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marco Wahl Subject: Re: [RFC] org-style Date: Tue, 14 May 2019 00:41:17 +0200 Message-ID: <847eaudlki.fsf@gmail.com> References: <84k1eyv80z.fsf@gmail.com> <87pnoqpcd4.fsf@len.workgroup> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:56566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQJdR-0004bk-Tf for emacs-orgmode@gnu.org; Mon, 13 May 2019 18:41:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQJdP-0001jY-Jc for emacs-orgmode@gnu.org; Mon, 13 May 2019 18:41:29 -0400 Received: from [195.159.176.226] (port=50232 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQJdO-0001e0-PI for emacs-orgmode@gnu.org; Mon, 13 May 2019 18:41:27 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hQJdL-0005mp-N1 for emacs-orgmode@gnu.org; Tue, 14 May 2019 00:41:23 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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