* [PATCH] Adjustment of point in Org-src buffer
@ 2010-09-30 10:01 Dan Davison
2010-09-30 10:48 ` Dan Davison
0 siblings, 1 reply; 2+ messages in thread
From: Dan Davison @ 2010-09-30 10:01 UTC (permalink / raw)
To: emacs org-mode mailing list
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.
Patch 1: Adjustment of location of point when generating org-src edit buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--8<---------------cut here---------------start------------->8---
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
--8<---------------cut here---------------end--------------->8---
Patch 2: Don't move point when generating org-src edit buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--8<---------------cut here---------------start------------->8---
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))
--8<---------------cut here---------------end--------------->8---
Dan
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Adjustment of point in Org-src buffer
2010-09-30 10:01 [PATCH] Adjustment of point in Org-src buffer Dan Davison
@ 2010-09-30 10:48 ` Dan Davison
0 siblings, 0 replies; 2+ messages in thread
From: Dan Davison @ 2010-09-30 10:48 UTC (permalink / raw)
To: emacs org-mode mailing list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-30 10:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-30 10:01 [PATCH] Adjustment of point in Org-src buffer Dan Davison
2010-09-30 10:48 ` Dan Davison
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).