* [PATCH] org-src.el: Unescape source block on edit
@ 2015-05-22 4:49 Kyle Meyer
2015-05-22 19:04 ` Nicolas Goaziou
0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2015-05-22 4:49 UTC (permalink / raw)
To: Org-mode
[-- 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] org-src.el: Unescape source block on edit
2015-05-22 4:49 [PATCH] org-src.el: Unescape source block on edit Kyle Meyer
@ 2015-05-22 19:04 ` Nicolas Goaziou
2015-05-22 20:22 ` Kyle Meyer
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2015-05-22 19:04 UTC (permalink / raw)
To: Kyle Meyer; +Cc: Org-mode
Hello,
Kyle Meyer <kyle@kyleam.com> writes:
> 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.
Thanks. However, this wouldn't work as `org-src--edit-element' is called
on elements that doesn't need escaping, e.g., a footnote definition.
Anyway, it is fixed in 71641bc3a0882bb16fb2b62ebef8ebc98ba0e3d8.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] org-src.el: Unescape source block on edit
2015-05-22 19:04 ` Nicolas Goaziou
@ 2015-05-22 20:22 ` Kyle Meyer
0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2015-05-22 20:22 UTC (permalink / raw)
To: Org-mode
Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
[...]
> Thanks. However, this wouldn't work as `org-src--edit-element' is called
> on elements that doesn't need escaping, e.g., a footnote definition.
I see.
> Anyway, it is fixed in 71641bc3a0882bb16fb2b62ebef8ebc98ba0e3d8.
Yes, this commit fixes the issue I originally reported, and it also
fixes an issue with editing fixed-width blocks.
Before, editing
: abc
would lead to
: : abc
Thank you.
--
Kyle
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-22 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 4:49 [PATCH] org-src.el: Unescape source block on edit Kyle Meyer
2015-05-22 19:04 ` Nicolas Goaziou
2015-05-22 20:22 ` Kyle Meyer
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).