Browse Source

Don't leave point in hidden region after exiting code buffer.

Dan Davison 15 years ago
parent
commit
c0707b1f31
2 changed files with 15 additions and 2 deletions
  1. 6 0
      lisp/ChangeLog
  2. 9 2
      lisp/org-src.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2010-03-23  Dan Davison  <davison@stats.ox.ac.uk>
+
+	* org-src.el (org-edit-src-exit): When returning from code edit
+	buffer, if code block is hidden, leave point at start of
+	#+begin_src line
+
 2010-03-23  Carsten Dominik  <carsten.dominik@gmail.com>
 2010-03-23  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.el (org-insert-heading): Do not remove all spaces if the
 	* org.el (org-insert-heading): Do not remove all spaces if the

+ 9 - 2
lisp/org-src.el

@@ -592,8 +592,15 @@ the language, a switch telling if the content should be in a single line."
     (insert code)
     (insert code)
     (goto-char beg)
     (goto-char beg)
     (if single (just-one-space))
     (if single (just-one-space))
-    (org-goto-line (1- (+ (org-current-line) line)))
-    (org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))
+    (if (memq t (mapcar (lambda (overlay)
+			  (eq (org-overlay-get overlay 'invisible)
+			      'org-hide-block))
+			(org-overlays-at (point))))
+	;; Block is hidden; put point at start of block
+	(beginning-of-line 0)
+      ;; Block is visible, put point where it was in the code buffer
+      (org-goto-line (1- (+ (org-current-line) line)))
+      (org-move-to-column (if preserve-indentation col (+ col total-nindent delta))))
     (move-marker beg nil)
     (move-marker beg nil)
     (move-marker end nil))
     (move-marker end nil))
   (unless (eq context 'save)
   (unless (eq context 'save)