emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH] org-src.el: Unescape source block on edit
Date: Fri, 22 May 2015 00:49:34 -0400	[thread overview]
Message-ID: <87617lgqsh.fsf@kmlap.domain.org> (raw)

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

org-edit-src-code doesn't seem to be unescaping correctly.  For
example, calling org-edit-src-code on

#+begin_src org
  ,* h
#+end_src

puts ",* h", not "* h", in the source buffer.  When exiting, ",*" is
escaped again, resulting in

#+begin_src org
  ,,* h
#+end_src

The attached patch moves the unescaping call from org-edit-src-code to
org-src--edit-element so that the source string is unescaped
regardless of whether it was passed as an argument or extracted
directly from the buffer.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src.el-Unescape-source-block-on-edit.patch --]
[-- Type: text/x-diff, Size: 1505 bytes --]

From a78db0610f769517a146b0a9fc58f81d0381d511 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <kyle@kyleam.com>
Date: Thu, 21 May 2015 23:18:37 -0400
Subject: [PATCH] org-src.el: Unescape source block on edit

* lisp/org-src.el (org-src--edit-element): Unescape code string.
  (org-edit-src-code): Let org-src--edit-element handle unescaping of
  code string.
---
 lisp/org-src.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index d82068d..8fcb7aa 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -380,7 +380,8 @@ (defun org-src--edit-element
 	 (beg (copy-marker (car area)))
 	 (end (copy-marker (cdr area) t))
 	 (old-edit-buffer (org-src--edit-buffer beg end))
-	 (contents (or contents (buffer-substring-no-properties beg end))))
+	 (contents (org-unescape-code-in-string
+		    (or contents (buffer-substring-no-properties beg end)))))
     (if (and old-edit-buffer
 	     (or (not org-src-ask-before-returning-to-edit-buffer)
 		 (y-or-n-p "Return to existing edit buffer ([n] will revert changes)? ")))
@@ -833,7 +834,7 @@ (defun org-edit-src-code (&optional code edit-buffer-name)
 		      (unless (looking-at "[ \t]*$") (insert ind))
 		      (forward-line)))))
 	      (org-escape-code-in-region (point-min) (point-max))))
-       (and code (org-unescape-code-in-string code)))
+       code)
       ;; Finalize buffer.
       (org-set-local 'org-coderef-label-format
 		     (or (org-element-property :label-fmt element)
-- 
2.4.1


[-- Attachment #3: Type: text/plain, Size: 9 bytes --]


--
Kyle

             reply	other threads:[~2015-05-22  4:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22  4:49 Kyle Meyer [this message]
2015-05-22 19:04 ` [PATCH] org-src.el: Unescape source block on edit Nicolas Goaziou
2015-05-22 20:22   ` Kyle Meyer

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=87617lgqsh.fsf@kmlap.domain.org \
    --to=kyle@kyleam.com \
    --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).