From 940ab32aa8c5cd07539580525b196372097ebf59 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 30 Sep 2010 10:34:49 +0100 Subject: [PATCH 1/2] Adjustment of location of point when generating org-src edit buffer * org-src.el (org-edit-src-code): Deal with point being in #+end_src line --- lisp/org-src.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 6c4c464f1..05580d943 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -211,9 +211,7 @@ buffer." (interactive) (unless (eq context 'save) (setq org-edit-src-saved-temp-window-config (current-window-configuration))) - (let ((line (org-current-line)) - (col (current-column)) - (mark (and (use-region-p) (mark))) + (let ((mark (and (use-region-p) (mark))) (case-fold-search t) (info (org-edit-src-find-region-and-lang)) (babel-info (org-babel-get-src-block-info)) @@ -223,7 +221,7 @@ buffer." (preserve-indentation org-src-preserve-indentation) (allow-write-back-p (null code)) block-nindent total-nindent ovl lang lang-f single lfmt buffer msg - begline markline markcol) + begline markline markcol line col) (if (not info) nil (setq beg (move-marker beg (nth 0 info)) @@ -254,6 +252,9 @@ buffer." (org-set-local 'org-edit-src-content-indentation 0)))) (unless (functionp lang-f) (error "No such language mode: %s" lang-f)) + (if (> (point) end) (goto-char end)) + (setq line (org-current-line) + col (current-column)) (org-goto-line line) (if (and (setq buffer (org-edit-src-find-buffer beg end)) (if org-src-ask-before-returning-to-edit-buffer From 9c211df6ae2d31f70444cc9573f17707129d700f Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 30 Sep 2010 10:39:49 +0100 Subject: [PATCH 2/2] Don't move point when generating org-src edit buffer * org-src.el (org-edit-src-code): Don't move point when generating edit buffer --- lisp/org-src.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 05580d943..c1d579cab 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -252,10 +252,10 @@ buffer." (org-set-local 'org-edit-src-content-indentation 0)))) (unless (functionp lang-f) (error "No such language mode: %s" lang-f)) - (if (> (point) end) (goto-char end)) - (setq line (org-current-line) - col (current-column)) - (org-goto-line line) + (save-excursion + (if (> (point) end) (goto-char end)) + (setq line (org-current-line) + col (current-column))) (if (and (setq buffer (org-edit-src-find-buffer beg end)) (if org-src-ask-before-returning-to-edit-buffer (y-or-n-p "Return to existing edit buffer? [n] will revert changes: ") t))