emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: [PATCH] Allow no stripping of blank lines from code


From: Dan Davison
Subject: [Orgmode] Re: [PATCH] Allow no stripping of blank lines from code
Date: Tue, 21 Sep 2010 15:24:07 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

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 <address@hidden> 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 <address@hidden>
> 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.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

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