emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: [BUG] R src blocks untabify literal constant TABs
Date: Fri, 25 Sep 2015 12:25:38 -0700	[thread overview]
Message-ID: <alpine.OSX.2.20.1509251207140.2073@charles-berrys-macbook.local> (raw)
In-Reply-To: <87r3low81u.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]

On Thu, 24 Sep 2015, Nicolas Goaziou wrote:

> Hello,
>
> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> On Tue, 22 Sep 2015, Charles C. Berry wrote:
>>
>> Just to tie this up, this is an issue with `org-src-preserve-indentation',
>> see
>>
>>  	(info "(org) Editing source code")
>>
>> for the best documentation. I found the "replace sequences of spaces with
>> tab characters" for nil values confusing. The opposite is happening in
>> this example.
>
> Would you want to write a documentation patch about it?
>

Attached is a patch.

I think it is an improvement, but `org-src-preserve-indentation' behaves 
differently according to context, which makes it hard to document 
succinctly.

In brief:

Setting to `t' or `nil' will keep or allow removal of tabs in these 
functions:

org-babel-parse-src-block-match
org-babel-haskell-export-to-lhs
org-babel-spec-to-string
org-src--edit-element
org-edit-src-code

but have no effect on embedded tabs in

org-babel-exp-process-buffer
org-export-unravel-code
org-element-src-block-interpreter
org-element-example-block-interpreter
org-fixup-indentation

Also, as briefly noted in the doc/org.texi part of the patch global 
indent/outdent operations (e.g. org-metaright on a heading) are affected.
This might make sense but sometimes the results surprise me.

HTH,

Chuck

[-- Attachment #2: org-src-preserve-indentation docs patch --]
[-- Type: text/plain, Size: 3700 bytes --]

From 12a912e9cbc1b2b475632dd724ca55af54b56236 Mon Sep 17 00:00:00 2001
From: Charles Berry <ccberry@ucsd.edu>
Date: Fri, 25 Sep 2015 12:02:32 -0700
Subject: [PATCH] org-src-preserve-indentation: docstring and info fixes

doc/org.texi: The `Literal examples' node mentions the effect of the
	      `-i' switch on embedded tabs.

	      The `Editing source code' node correctly states that
	      setting `org-src-preserve-indentation' to `t' prevents
	      converting tabs to spaces.  Also, its effect on
	      indentation operations is noted. A mention of the `-i'
	      switch is given.

lisp/org-src.el: The `org-src-preserve-indentation' docstring mentions
		 the effect of setting its value to `t' is to protect
		 conversion of tabs to spaces.
---
 doc/org.texi    | 17 ++++++++++-------
 lisp/org-src.el |  7 ++++---
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 8de8efc..62c39e3 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10053,8 +10053,8 @@ jumps to point-min.
 @end example
 
 @cindex indentation, in source blocks
-Finally, you can use @code{-i} to preserve the indentation of a specific code
-block (@pxref{Editing source code}).
+Finally, you can use @code{-i} to preserve the indentation and tab
+characters of a specific code block (@pxref{Editing source code}).
 
 @vindex org-coderef-label-format
 If the syntax for the label format conflicts with the language syntax, use a
@@ -14826,11 +14826,14 @@ Controls the way Emacs windows are rearranged when the edit buffer is created.
 @cindex indentation, in source blocks
 By default, the value is @code{nil}, which means that when code blocks are
 evaluated during export or tangled, they are re-inserted into the code block,
-which may replace sequences of spaces with tab characters.  When non-@code{nil},
-whitespace in code blocks will be preserved during export or tangling,
-exactly as it appears.  This variable is especially useful for tangling
-languages such as Python, in which whitespace indentation in the output is
-critical.
+which may replace tab characters with sequences of spaces.  When
+non-@code{nil}, whitespace in code blocks will be preserved during export or
+tangling, exactly as it appears.  This variable is especially useful for
+tangling languages such as Python, in which whitespace indentation in the
+output is critical.  A value of @code{t} prevents global indent/outdent
+operations from moving source or example block contents. The @code{-i} switch
+has a similar effect on a single source or example block (@pxref{Literal
+examples}).
 @item org-src-ask-before-returning-to-edit-buffer
 By default, Org will ask before returning to an open edit buffer.  Set this
 variable to @code{nil} to switch without asking.
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9c205e1..394633d 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -108,9 +108,10 @@ These are the regions where each line starts with a colon."
 
 (defcustom org-src-preserve-indentation nil
   "If non-nil preserve leading whitespace characters on export.
-If non-nil leading whitespace characters in source code blocks
-are preserved on export, and when switching between the org
-buffer and the language mode edit buffer.
+If non-nil leading whitespace characters and embedded tab
+characters in source code blocks are preserved on export, and
+when switching between the org buffer and the language mode edit
+buffer.
 
 When this variable is nil, after editing with \\[org-edit-src-code],
 the minimum (across-lines) number of leading whitespace characters
-- 
2.3.8 (Apple Git-58)


  parent reply	other threads:[~2015-09-25 19:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 22:04 [BUG] R src blocks untabify literal constant TABs Charles C. Berry
2015-09-22 23:48 ` Grant Rettke
2015-09-23  0:05   ` Charles C. Berry
2015-09-23  0:14     ` Charles C. Berry
2015-09-23  1:32       ` Charles C. Berry
2015-09-24  8:11         ` Nicolas Goaziou
2015-09-24 16:18           ` Charles C. Berry
2015-09-25 19:25           ` Charles C. Berry [this message]
2015-10-07 20:06             ` Nicolas Goaziou
2015-10-07 21:49               ` Charles C. Berry
2015-10-08 15:19                 ` Nicolas Goaziou
2015-10-08 16:39                   ` Charles C. Berry
2015-10-08 17:04                     ` Nicolas Goaziou
2015-10-08 17:51                       ` Charles C. Berry
2015-10-11  8:04                         ` Nicolas Goaziou
2015-10-11 17:06                           ` Charles C. Berry
2015-10-11 21:29                             ` Nicolas Goaziou

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=alpine.OSX.2.20.1509251207140.2073@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).