From: Dan Davison <davison@stats.ox.ac.uk>
To: emacs org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Allow no stripping of blank lines from code
Date: Tue, 21 Sep 2010 15:24:07 +0100 [thread overview]
Message-ID: <877hif18fs.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <87fwxnn03d.fsf@stats.ox.ac.uk> (Dan Davison's message of "Sun, 05 Sep 2010 21:15:50 -0400")
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 <davison@stats.ox.ac.uk> 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 <davison@stats.ox.ac.uk>
> 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
prev parent reply other threads:[~2010-09-21 14:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 1:15 [PATCH] Allow no stripping of blank lines from code Dan Davison
2010-09-21 14:24 ` Dan Davison [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=877hif18fs.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--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).