From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: [PATCH] Avoid leaving point inside hidden block Date: Tue, 23 Mar 2010 10:08:40 -0400 Message-ID: <87eijb6sgn.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nu51G-0005NT-Pg for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 10:23:46 -0400 Received: from [140.186.70.92] (port=44788 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu51F-0005Mg-FV for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 10:23:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nu51E-0001q3-18 for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 10:23:45 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:47202) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu4mj-0007ni-Af for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 10:08:46 -0400 Received: from blackcap.stats.ox.ac.uk (blackcap.stats [163.1.210.5]) by markov.stats.ox.ac.uk (8.13.6/8.13.6) with ESMTP id o2NE8igH024007 for ; Tue, 23 Mar 2010 14:08:44 GMT List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs org-mode mailing list 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---