summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-05-22 18:59:31 (GMT)
committer Nicolas Goaziou <mail@nicolasgoaziou.fr>2015-05-22 18:59:31 (GMT)
commit71641bc3a0882bb16fb2b62ebef8ebc98ba0e3d8 (patch)
treea17d4585755d5963febb365613edca2a2c491ad7
parent275bb10d76c53c7cb2600e9f7338de3f8c86f7d9 (diff)
downloadorg-mode-master.zip
org-mode-master.tar.gz
org-src: Fix escaping in remote editingHEADmaster
* lisp/org-src.el (org-src--contents-area): Include contents to be inserted in the edit buffer in return value. (org-src--edit-element): Apply change above. Reported-by: Kyle Meyer <kyle@kyleam.com> <http://permalink.gmane.org/gmane.emacs.orgmode/97784>
-rw-r--r--lisp/org-src.el39
1 files changed, 23 insertions, 16 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el
index d82068d..5201dca 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -268,32 +268,39 @@ which see. BEG and END are buffer positions."
(defun org-src--contents-area (datum)
"Return contents boundaries of DATUM.
-DATUM is an element or object. Return a pair (BEG . END) where
-BEG and END are buffer positions."
+DATUM is an element or object. Return a list (BEG END CONTENTS)
+where BEG and END are buffer positions and CONTENTS is a string."
(let ((type (org-element-type datum)))
(cond
((eq type 'footnote-definition)
(let ((beg (org-with-wide-buffer
(goto-char (org-element-property :post-affiliated datum))
- (search-forward "]"))))
- (cons beg (or (org-element-property :contents-end datum) beg))))
+ (search-forward "]")))
+ (end (or (org-element-property :contents-end datum) beg)))
+ (list beg end (buffer-substring-no-properties beg end))))
((org-element-property :contents-begin datum)
- (cons (org-element-property :contents-begin datum)
- (org-element-property :contents-end datum)))
+ (list (org-element-property :contents-begin datum)
+ (org-element-property :contents-end datum)
+ (buffer-substring-no-properties beg end)))
((memq type '(example-block export-block src-block))
- (cons (org-with-wide-buffer
+ (list (org-with-wide-buffer
(goto-char (org-element-property :post-affiliated datum))
(line-beginning-position 2))
(org-with-wide-buffer
(goto-char (org-element-property :end datum))
(skip-chars-backward " \r\t\n")
- (line-beginning-position 1))))
+ (line-beginning-position 1))
+ (org-element-property :value datum)))
((memq type '(fixed-width table))
- (cons (org-element-property :post-affiliated datum)
- (org-with-wide-buffer
- (goto-char (org-element-property :end datum))
- (skip-chars-backward " \r\t\n")
- (line-beginning-position 2))))
+ (let ((beg (org-element-property :post-affiliated datum))
+ (end (org-with-wide-buffer
+ (goto-char (org-element-property :end datum))
+ (skip-chars-backward " \r\t\n")
+ (line-beginning-position 2))))
+ (list beg
+ end
+ (if (eq type 'fixed-width) (org-element-property :value datum)
+ (buffer-substring-no-properties beg end)))))
(t (error "Unsupported element or object: %s" type)))))
(defun org-src--make-source-overlay (beg end edit-buffer)
@@ -377,10 +384,10 @@ moving from the edit area to the source.
Leave point in edit buffer."
(setq org-src--saved-temp-window-config (current-window-configuration))
(let* ((area (org-src--contents-area datum))
- (beg (copy-marker (car area)))
- (end (copy-marker (cdr area) t))
+ (beg (copy-marker (nth 0 area)))
+ (end (copy-marker (nth 1 area) t))
(old-edit-buffer (org-src--edit-buffer beg end))
- (contents (or contents (buffer-substring-no-properties beg end))))
+ (contents (or contents (nth 2 area))))
(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)? ")))