From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [PATCH] Adjustment of point in Org-src buffer Date: Thu, 30 Sep 2010 11:48:16 +0100 Message-ID: <87sk0rpkwf.fsf@stats.ox.ac.uk> References: <878w2jr1mg.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=38424 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P1GgW-0008VZ-F9 for emacs-orgmode@gnu.org; Thu, 30 Sep 2010 06:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P1GgV-0002vz-3K for emacs-orgmode@gnu.org; Thu, 30 Sep 2010 06:48:20 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:34197) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P1GgU-0002vl-Qw for emacs-orgmode@gnu.org; Thu, 30 Sep 2010 06:48:19 -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 o8UAmHZt024886 for ; Thu, 30 Sep 2010 11:48:17 +0100 (BST) In-Reply-To: <878w2jr1mg.fsf@stats.ox.ac.uk> (Dan Davison's message of "Thu, 30 Sep 2010 11:01:43 +0100") 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 Dan Davison writes: > Currently, if point is in the #+end_src line, then in the org-src edit > buffer it goes to the beginning of the last line. There are two patches > below. Patch 1 changes this so that point goes to the end of the last > line of code. This gives nicer behaviour when creating an active region > in the edit buffer. Patch 2 places a save-excursion round this, and gets > rid of an org-goto-line, so that point in the Org buffer is not affected > by generating the edit buffer. These patches have been applied. > > > Patch 1: Adjustment of location of point when generating org-src edit buffer > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > diff --git a/lisp/org-src.el b/lisp/org-src.el > index 6c4c464..05580d9 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 > > > > Patch 2: Don't move point when generating org-src edit buffer > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > diff --git a/lisp/org-src.el b/lisp/org-src.el > index 05580d9..c1d579c 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)) > > Dan > > _______________________________________________ > 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