[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Saving the *Org Edit Src Example* buffer
From: |
Dan Davison |
Subject: |
Re: [Orgmode] Saving the *Org Edit Src Example* buffer |
Date: |
Tue, 02 Jun 2009 11:49:07 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.91 (gnu/linux) |
Dan Davison <address@hidden> writes:
> Following on from the recent improvements to the *Org Edit Src Example*
> buffer, I have one more proposal: I have remapped C-x C-s so that it
> saves the code in the org buffer, rather than offering to save the Edit
> buffer itself (as it used to be with the indirect edit buffer). I find
> this essential, although I recognise that remapping C-x C-s is a rather
> radical thing to do to an emacs buffer.
>
> I am using the simple-minded approach below; it seems to work fine (I
Hmm, well I had used that for at least a week before posting, but I have
now noticed a problem. It's a bit of a corner case. If you create extra
blank lines at the end of the source code edit buffer and leave point
down there, then do org-edit-src-exit, now back in the org buffer point
is outside the source code block. In that case, the code that I just
posted doesn't work. I suggest that org-edit-src-exit should in this
situation place point at the end of the source code block, for example
like this:
diff --git a/lisp/org.el b/lisp/org.el
index 659dfad..be459b5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6757,7 +6757,9 @@ the language, a switch telling of the content should be
in a single line."
code)
(goto-char (point-min))
(if (looking-at "[ \t\n]*\n") (replace-match ""))
- (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))
+ (when (re-search-forward "\n[ \t\n]*\\'" nil t)
+ (replace-match "")
+ (setq line (min line (org-current-line))))
(when (org-bound-and-true-p org-edit-src-force-single-line)
(goto-char (point-min))
(while (re-search-forward "\n" nil t)
Dan
> don't even notice a flicker -- should I be surprised at that?), but if
> someone can suggest an improved implementation I'd be happy to learn how
> it should be done (perhaps there are buffer variables other than point
> and mark that I should restore? Is there a general mechanism I should
> use for this?).
>
> Dan
>
> (defun org-edit-src-save ()
> "Update the parent org buffer with the edited source code, save
> the parent org-buffer, and return to the source code edit
> buffer."
> (interactive)
> (let ((p (point))
> (m (mark)))
> (org-edit-src-exit)
> (save-buffer)
> (org-edit-src-code)
> (set-mark m)
> (goto-char p)))
>
> (define-key org-exit-edit-mode-map "\C-x\C-s" 'org-edit-src-save)
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode