From f91d194d4fe4644de9cac94a807a08c220ab521d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 2 Jun 2015 17:17:17 +0200 Subject: [PATCH] org-src: Fix `org-(un)escape-code-in-region' * lisp/org-src.el (org-escape-code-in-region): (org-unescape-code-in-region): Fix functions. Reported-by: Daimrod --- lisp/org-src.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index c9a45179d..2cceea5e4 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -519,9 +519,9 @@ Escaping happens when a line starts with \"*\", \"#+\", \",*\" or \",#+\" by appending a comma to it." (interactive "r") (save-excursion - (goto-char beg) - (while (re-search-forward "^[ \t]*,?\\(\\*\\|#\\+\\)" end t) - (replace-match ",\\1" nil nil nil 1)))) + (goto-char end) + (while (re-search-backward "^[ \t]*,?\\(\\*\\|#\\+\\)" beg t) + (save-excursion (replace-match ",\\1" nil nil nil 1))))) (defun org-escape-code-in-string (s) "Escape lines in string S. @@ -535,9 +535,9 @@ Un-escaping happens by removing the first comma on lines starting with \",*\", \",#+\", \",,*\" and \",,#+\"." (interactive "r") (save-excursion - (goto-char beg) - (while (re-search-forward "^[ \t]*,?\\(,\\)\\(?:\\*\\|#\\+\\)" end t) - (replace-match "" nil nil nil 1)))) + (goto-char end) + (while (re-search-backward "^[ \t]*,?\\(,\\)\\(?:\\*\\|#\\+\\)" beg t) + (save-excursion (replace-match "" nil nil nil 1))))) (defun org-unescape-code-in-string (s) "Un-escape lines in string S. -- 2.11.4.GIT