emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: emacs org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Saving the *Org Edit Src Example* buffer
Date: Tue, 2 Jun 2009 19:04:56 +0200	[thread overview]
Message-ID: <8216B89D-C718-4604-AAC4-82BFCA967161@gmail.com> (raw)
In-Reply-To: <873aain0f7.fsf@stats.ox.ac.uk>

Hi Dan,

On Jun 2, 2009, at 5:02 PM, Dan Davison wrote:

> 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.


But allowed:  From the Emacs lisp docs, under Major Mode Conventions:

      It is legitimate for a major mode to rebind a standard key
      sequence if it provides a command that does "the same job" in a
      way better suited to the text this mode is used for.

I'd say, your's is a perfect example for this rule.


> I am using the simple-minded approach below; it seems to work fine (I
> 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)))

This is already excellent.  I have changed it only slightly,
in order to get a better message when this command finishes, and
because `push-mark' should be used here instead of `set-mark'.

(defun org-edit-src-save ()
   "Save parent buffer with current state source-code buffer."
   (interactive)
   (let ((p (point)) (m (mark)) msg)
     (org-edit-src-exit)
     (save-buffer)
     (setq msg (current-message))
     (org-edit-src-code)
     (push-mark m 'nomessage)
     (goto-char p)
     (message (or msg ""))))

I have added your code, thanks.

- Carsten

  parent reply	other threads:[~2009-06-02 17:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-02 15:02 Saving the *Org Edit Src Example* buffer Dan Davison
2009-06-02 15:49 ` Dan Davison
2009-06-02 17:12   ` Carsten Dominik
2009-06-09 14:51     ` Dan Davison
2009-06-09 18:20       ` Carsten Dominik
2009-06-02 17:04 ` Carsten Dominik [this message]
2009-08-11 16:44   ` PATCH: proposed improvements to org-src-mode Dan Davison
2009-08-12 12:22     ` Carsten Dominik
2009-08-12 14:58       ` Dan Davison
2009-08-19 11:03         ` Dan Davison
2009-08-24 12:17           ` Carsten Dominik
2009-08-28  2:36             ` Dan Davison
2009-08-28  7:59               ` Carsten Dominik
2009-09-05 17:33                 ` Dan Davison
2009-09-06 11:41                   ` Carsten Dominik

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=8216B89D-C718-4604-AAC4-82BFCA967161@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=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).