From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Avoid leaving point inside hidden block Date: Tue, 23 Mar 2010 16:01:26 +0100 Message-ID: References: <87eijb6sgn.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nu5bx-0007gM-3h for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 11:01:41 -0400 Received: from [140.186.70.92] (port=38695 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nu5bs-0007UW-Jq for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 11:01:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nu5bp-00061h-1E for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 11:01:36 -0400 Received: from mail-fx0-f213.google.com ([209.85.220.213]:61336) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nu5bo-00061a-Qs for emacs-orgmode@gnu.org; Tue, 23 Mar 2010 11:01:33 -0400 Received: by fxm5 with SMTP id 5so2858396fxm.9 for ; Tue, 23 Mar 2010 08:01:31 -0700 (PDT) In-Reply-To: <87eijb6sgn.fsf@stats.ox.ac.uk> 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: Dan Davison Cc: emacs org-mode mailing list Hi Dan, please go ahead and apply it to the master branch. Thanks - Carsten On Mar 23, 2010, at 3:08 PM, Dan Davison wrote: > 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--- > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten