From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyle Meyer Subject: [PATCH] org-src.el: Unescape source block on edit Date: Fri, 22 May 2015 00:49:34 -0400 Message-ID: <87617lgqsh.fsf@kmlap.domain.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvety-0000kz-0L for emacs-orgmode@gnu.org; Fri, 22 May 2015 00:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yvett-0003Bp-0X for emacs-orgmode@gnu.org; Fri, 22 May 2015 00:49:41 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:36536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yvets-0003Bi-T1 for emacs-orgmode@gnu.org; Fri, 22 May 2015 00:49:36 -0400 Received: by qkx62 with SMTP id 62so4947828qkx.3 for ; Thu, 21 May 2015 21:49:36 -0700 (PDT) Received: from localhost ([2601:6:5480:1e5:9e4e:36ff:fe3d:ae9c]) by mx.google.com with ESMTPSA id 79sm656813qkz.30.2015.05.21.21.49.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 21:49:35 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-mode --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-src.el-Unescape-source-block-on-edit.patch >From a78db0610f769517a146b0a9fc58f81d0381d511 Mon Sep 17 00:00:00 2001 From: Kyle Meyer 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 --=-=-= Content-Type: text/plain -- Kyle --=-=-=--