From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [PATCH] Allow no stripping of blank lines from code Date: Tue, 21 Sep 2010 15:24:07 +0100 Message-ID: <877hif18fs.fsf@stats.ox.ac.uk> References: <87fwxnn03d.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=52879 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy3mQ-00022A-R0 for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 10:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy3lR-0003FT-JH for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 10:25:08 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:39584) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy3lR-0003FD-BG for emacs-orgmode@gnu.org; Tue, 21 Sep 2010 10:24:09 -0400 Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o8LEO70h026682 for ; Tue, 21 Sep 2010 15:24:07 +0100 (BST) In-Reply-To: <87fwxnn03d.fsf@stats.ox.ac.uk> (Dan Davison's message of "Sun, 05 Sep 2010 21:15:50 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs org-mode mailing list This patch has been applied. Now, if you have set `org-src-tab-acts-natively', then you can enter a new indented blank line at the start/end of a src block using e.g. RET TAB or C-j TAB. It might be nice to make the native indentation happen automatically with C-j but I haven't looked into that. Dan Dan Davison writes: > Now that we can issue TAB in a code block and have it act according to > language [see org-src-tab-acts-natively], the following is a minor > frustration: if you try to insert a blank line at the beginning/end of > the block (perhaps to introduce a new first/last line), then on TAB it > disappears because org-edit-src-exit strips leading and trailing blank > lines. This patch introduces a variable that turns off that behaviour. > > The default is still to strip lines. I am slightly wondering what the > reason for that default was. I can see it could be useful for > artist-mode, but for genuine code blocks should the default be to give > the user responsibility for curating leading/trailing blank lines? > > Dan > > commit 84503c83d143b40bded8122e45ffba703c4035a1 > Author: Dan Davison > Date: Sun Sep 5 18:55:06 2010 -0400 > > Optionally prevent stripping of blank lines from code blocks > > * org-src.el (org-edit-src-exit): Only strip leading and > trailing blank lines if > `org-src-strip-leading-and-trailing-blank-lines' is non-nil > (org-src-strip-leading-and-trailing-blank-lines): New variable > > diff --git a/lisp/org-src.el b/lisp/org-src.el > index f11eec2..d877925 100644 > --- a/lisp/org-src.el > +++ b/lisp/org-src.el > @@ -109,6 +109,12 @@ editing it with \\[org-edit-src-code]. Has no effect if > :group 'org-edit-structure > :type 'integer) > > +(defcustom org-src-strip-leading-and-trailing-blank-lines t > + "If non-nil, blank lines are removed when exiting the code edit > +buffer." > + :group 'org-edit-structure > + :type 'boolean) > + > (defcustom org-edit-src-persistent-message t > "Non-nil means show persistent exit help message while editing src examples. > The message is shown in the header-line, which will be created in the > @@ -577,11 +583,12 @@ the language, a switch telling if the content should be in a single line." > (delta 0) code line col indent) > (when allow-write-back-p > (unless preserve-indentation (untabify (point-min) (point-max))) > - (save-excursion > - (goto-char (point-min)) > - (if (looking-at "[ \t\n]*\n") (replace-match "")) > - (unless macro > - (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))))) > + (if org-src-strip-leading-and-trailing-blank-lines > + (save-excursion > + (goto-char (point-min)) > + (if (looking-at "[ \t\n]*\n") (replace-match "")) > + (unless macro > + (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match "")))))) > (setq line (if (org-bound-and-true-p org-edit-src-force-single-line) > 1 > (org-current-line)) > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode