emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: emacs org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Adjustment of point in Org-src buffer
Date: Thu, 30 Sep 2010 11:48:16 +0100	[thread overview]
Message-ID: <87sk0rpkwf.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <878w2jr1mg.fsf@stats.ox.ac.uk> (Dan Davison's message of "Thu, 30 Sep 2010 11:01:43 +0100")

Dan Davison <davison@stats.ox.ac.uk> 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

      reply	other threads:[~2010-09-30 10:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-30 10:01 [PATCH] Adjustment of point in Org-src buffer Dan Davison
2010-09-30 10:48 ` Dan Davison [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sk0rpkwf.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).