emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [patch] change indentation logic for edit-src
@ 2012-08-17 15:27 Ken Williams
  2012-08-17 15:47 ` Nick Dokos
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Williams @ 2012-08-17 15:27 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I know Bastien's out of touch for a few days, but could someone say whether a patch to the mailing list is the right place to put it, or should I put it on GitHub or somewhere else?  Thanks.

 -Ken

> From: Ken Williams
> Sent: Thursday, August 16, 2012 2:30 PM
> To: emacs-orgmode@gnu.org
> Subject: [patch] change indentation logic for edit-src
>
> Following on a message from a few days ago, I've prepared a patch (attached) that alters the behavior of 'org-edit-src-exit' ...

CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] change indentation logic for edit-src
  2012-08-17 15:27 [patch] change indentation logic for edit-src Ken Williams
@ 2012-08-17 15:47 ` Nick Dokos
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Dokos @ 2012-08-17 15:47 UTC (permalink / raw)
  To: Ken Williams; +Cc: emacs-orgmode

Ken Williams <Ken.Williams@windlogics.com> wrote:

> Hi,
> 
> I know Bastien's out of touch for a few days, but could someone say whether a patch to the mailing list is the right place to put it, or should I put it on GitHub or somewhere else?  Thanks.
> 
>  -Ken
> 
> > From: Ken Williams
> > Sent: Thursday, August 16, 2012 2:30 PM
> > To: emacs-orgmode@gnu.org
> > Subject: [patch] change indentation logic for edit-src
> >
> > Following on a message from a few days ago, I've prepared a patch (attached) that alters the behavior of 'org-edit-src-exit' ...
> 

The mailing list: see the guidelines at

    http://orgmode.org/worg/org-contribute.html#sec-4

Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] change indentation logic for edit-src
  2012-08-22 13:58   ` Ken Williams
@ 2012-08-22 14:32     ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2012-08-22 14:32 UTC (permalink / raw)
  To: Ken Williams; +Cc: emacs-orgmode

Hi Ken,

In Emacs, I have the same behavior when editing a table.el table before
and after I apply your patch, with both org-src-preserve-indentation set
to nil or to t.

I must be missing something here.

Do you have an idea?

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] change indentation logic for edit-src
  2012-08-21 23:13 ` Bastien
@ 2012-08-22 13:58   ` Ken Williams
  2012-08-22 14:32     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Williams @ 2012-08-22 13:58 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode



> -----Original Message-----
> From: Bastien Guerry [mailto:bastienguerry@gmail.com]
> Sent: Tuesday, August 21, 2012 6:14 PM
>
> Mh... for me there is no change.  There are always 2 spaces added before
> table.el tables.

The prior behavior I've been seeing is that there are 2 spaces added *every time the table.el table is edited*.  No matter what settings the user has, that seems like unhelpful behavior.

 -Ken


CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] change indentation logic for edit-src
  2012-08-16 19:30 Ken Williams
@ 2012-08-21 23:13 ` Bastien
  2012-08-22 13:58   ` Ken Williams
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2012-08-21 23:13 UTC (permalink / raw)
  To: Ken Williams; +Cc: emacs-orgmode

Hi Ken,

Ken Williams <Ken.Williams@windlogics.com> writes:

> Following on a message from a few days ago, I’ve prepared a patch
> (attached) that alters the behavior of ‘org-edit-src-exit’ so that it
> no longer adds an extra 2 spaces of indentation each time a source
> block (or a table.el table) is edited.  Previously a workaround was
> to set ‘org-src-preserve-indentation’, but without that set, you’d
> get the undesirable behavior.

I tested the patch.

> There’s probably some stuff wrong with this approach – let me know. 

Mh... for me there is no change.  There are always 2 spaces 
added before table.el tables.

Anyway, I'll let Eric look at this one as I think
̀org-src-preserve-indentation' is enough here.

Thanks for the patch anyway!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [patch] change indentation logic for edit-src
@ 2012-08-16 19:30 Ken Williams
  2012-08-21 23:13 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Williams @ 2012-08-16 19:30 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1314 bytes --]

Following on a message from a few days ago, I've prepared a patch (attached) that alters the behavior of 'org-edit-src-exit' so that it no longer adds an extra 2 spaces of indentation each time a source block (or a table.el table) is edited.  Previously a workaround was to set 'org-src-preserve-indentation', but without that set, you'd get the undesirable behavior.

There's probably some stuff wrong with this approach - let me know.  I'm new to both elisp programming and the org-mode code.

I also created a little utility function 'org-prefixify', not sure whether that's kosher or not.  One change that would be nice to make to it is to avoid prefixing the final line if it's blank, but I couldn't get that to work.  Also - could that essentially be replaced by a call to string-insert-rectangle?

--
Ken Williams, Senior Research Scientist
WindLogics
http://windlogics.com


________________________________
CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.

[-- Attachment #1.2: Type: text/html, Size: 3600 bytes --]

[-- Attachment #2: 0001-Change-the-edit-src-save-code-so-that-it-either-pres.txt --]
[-- Type: text/plain, Size: 2564 bytes --]

From d80b7726402a39b4c8a630a86614b0ba9d7eca6a Mon Sep 17 00:00:00 2001
From: Ken Williams <Ken.Williams@WindLogics.com>
Date: Thu, 16 Aug 2012 13:26:44 -0500
Subject: [PATCH] Change the edit-src-save code so that it either preserves
 original formatting, or imposes its new indentation, but
 not both.

---
 lisp/org-src.el |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index c110f32..61b800f 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -601,11 +601,9 @@ the language, a switch telling if the content should be in a single line."
 	 (buffer (current-buffer))
 	 (single (org-bound-and-true-p org-edit-src-force-single-line))
 	 (macro (eq single 'macro-definition))
-	 (total-nindent (+ (or org-edit-src-block-indentation 0)
-			   org-edit-src-content-indentation))
 	 (preserve-indentation org-src-preserve-indentation)
 	 (allow-write-back-p (org-bound-and-true-p org-edit-src-allow-write-back-p))
-	 (delta 0) code line col indent)
+	 (delta 0) code line col indent total-nindent)
     (when allow-write-back-p
       (unless preserve-indentation (untabify (point-min) (point-max)))
       (if org-src-strip-leading-and-trailing-blank-lines
@@ -640,14 +638,10 @@ the language, a switch telling if the content should be in a single line."
       (when (org-bound-and-true-p org-edit-src-picture)
 	(setq preserve-indentation nil)
 	(untabify (point-min) (point-max))
-	(goto-char (point-min))
-	(while (re-search-forward "^" nil t)
-	  (replace-match ": ")))
-      (unless (or single preserve-indentation (= total-nindent 0))
-	(setq indent (make-string total-nindent ?\ ))
-	(goto-char (point-min))
-	(while (re-search-forward "^" nil t)
-	  (replace-match indent)))
+	(org-prefixify ": "))
+      (setq total-nindent (if preserve-indentation (or org-edit-src-block-indentation 0)
+			    org-edit-src-content-indentation ))
+      (org-prefixify (make-string total-nindent ?\ ))
       (if (org-bound-and-true-p org-edit-src-picture)
 	  (setq total-nindent (+ total-nindent 2)))
       (setq code (buffer-string))
@@ -692,6 +686,12 @@ the language, a switch telling if the content should be in a single line."
      (message (or msg ""))))
 (def-edebug-spec org-src-in-org-buffer (body))
 
+(defun org-prefixify (s)
+  (unless (string= "" s)
+    (goto-char (point-min))
+    (while (re-search-forward "^" nil t)
+      (replace-match s))))
+
 (defun org-edit-src-save ()
   "Save parent buffer with current state source-code buffer."
   (interactive)
-- 
1.7.9


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-22 14:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 15:27 [patch] change indentation logic for edit-src Ken Williams
2012-08-17 15:47 ` Nick Dokos
  -- strict thread matches above, loose matches on Subject: below --
2012-08-16 19:30 Ken Williams
2012-08-21 23:13 ` Bastien
2012-08-22 13:58   ` Ken Williams
2012-08-22 14:32     ` Bastien

Code repositories for project(s) associated with this 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).