[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] [PATCH] Avoid leaving point inside hidden block
From: |
Dan Davison |
Subject: |
[Orgmode] [PATCH] Avoid leaving point inside hidden block |
Date: |
Tue, 23 Mar 2010 10:08:40 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
If you
1. fold a code block
2. place point at the beginning of the #begin_src line
3. switch to the edit buffer using C-c '
4. exit the edit buffer with C-c '
point will not return to where it started but instead be by the ...,
reflecting the fact that it returned to a buffer position that is not
visible. This patch returns point to the beginning of the begin_src line
when the block is folded. (overlay-querying code borrowed from
org-hide-block-toggle)
Dan
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 0cebcd1..bc71a92 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -592,8 +592,15 @@ the language, a switch telling if the content should be in
a single line."
(insert code)
(goto-char beg)
(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 end nil))
(unless (eq context 'save)
--8<---------------cut here---------------end--------------->8---
- [Orgmode] [PATCH] Avoid leaving point inside hidden block,
Dan Davison <=