all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-edit-src-code outside of org
@ 2014-05-13 20:49 Jorge A. Alfaro-Murillo
  2014-05-13 20:58 ` Ken Mankoff
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2014-05-13 20:49 UTC (permalink / raw)
  To: emacs-orgmode

Hi, I would like to use org-edit-src-code outside of org, I think it
would be very handy in Message mode, to send messages that contain code
and edit that code in the proper mode.

I put something like this

     #+BEGIN_SRC emacs-lisp
       (defun mm-org-try-structure-completion ()
         (interactive)
         (if (not (org-try-structure-completion))
             (message-tab)))
       (eval-after-load "message"
         '(progn
            (define-key message-mode-map (kbd "<tab>")
            'mm-org-try-structure-completion)))
     #+END_SRC

which allows me now to do <'a letter' and hit <tab> and get a the proper
source block just as in org.

I can enter the editing of the source block without problems with
org-edit-src-code (which I plan to bind to C-c ', just as in org),
however when I am want to close the editing and go back to the message
buffer it fails, specifically the part of org-edit-src-exit that says:

     #+BEGIN_SRC emacs-lisp
       (unless (org-bound-and-true-p org-edit-src-from-org-mode)
          (error "This is not a sub-editing buffer, something is wrong"))
     #+END_SRC
          
Is there a particular reason why the code has to check to see if it is
coming from org-mode? Shouldn't it be enough that already the
org-in-block-p was passed?

If I evaluate the function definition of org-edit-src-exit without the
last part everything works as expect, I can exit with C-c ' and the code
is there. Even doing C-x C-s before exiting works as well.

Best,

Jorge.

PS: What is the alternative when you write messages with code, do you
guys first write it in org and then copy and yank it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-13 20:49 org-edit-src-code outside of org Jorge A. Alfaro-Murillo
@ 2014-05-13 20:58 ` Ken Mankoff
  2014-05-13 21:12   ` Jorge A. Alfaro-Murillo
  2014-05-14 13:44 ` Hubert Chathi
  2014-05-27  8:32 ` Thorsten Jolitz
  2 siblings, 1 reply; 7+ messages in thread
From: Ken Mankoff @ 2014-05-13 20:58 UTC (permalink / raw)
  To: Jorge A. Alfaro-Murillo; +Cc: emacs-orgmode

Hi Jorge,

mu4e has an option to edit mail messages in Org mode. You can insert and
execute code blocks, etc. See example at bottom of this blog post:
http://www.brool.com/index.php/using-mu4e

  -k.

On 2014-05-13 at 14:49, Jorge A. Alfaro-Murillo <jorge.a.alfaro@gmail.com> wrote:
> Hi, I would like to use org-edit-src-code outside of org, I think it
> would be very handy in Message mode, to send messages that contain code
> and edit that code in the proper mode.
>
> I put something like this
>
>      #+BEGIN_SRC emacs-lisp
>        (defun mm-org-try-structure-completion ()
>          (interactive)
>          (if (not (org-try-structure-completion))
>              (message-tab)))
>        (eval-after-load "message"
>          '(progn
>             (define-key message-mode-map (kbd "<tab>")
>             'mm-org-try-structure-completion)))
>      #+END_SRC
>
> which allows me now to do <'a letter' and hit <tab> and get a the proper
> source block just as in org.
>
> I can enter the editing of the source block without problems with
> org-edit-src-code (which I plan to bind to C-c ', just as in org),
> however when I am want to close the editing and go back to the message
> buffer it fails, specifically the part of org-edit-src-exit that says:
>
>      #+BEGIN_SRC emacs-lisp
>        (unless (org-bound-and-true-p org-edit-src-from-org-mode)
>           (error "This is not a sub-editing buffer, something is wrong"))
>      #+END_SRC
>           
> Is there a particular reason why the code has to check to see if it is
> coming from org-mode? Shouldn't it be enough that already the
> org-in-block-p was passed?
>
> If I evaluate the function definition of org-edit-src-exit without the
> last part everything works as expect, I can exit with C-c ' and the code
> is there. Even doing C-x C-s before exiting works as well.
>
> Best,
>
> Jorge.
>
> PS: What is the alternative when you write messages with code, do you
> guys first write it in org and then copy and yank it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-13 20:58 ` Ken Mankoff
@ 2014-05-13 21:12   ` Jorge A. Alfaro-Murillo
  0 siblings, 0 replies; 7+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2014-05-13 21:12 UTC (permalink / raw)
  To: emacs-orgmode

Thanks Ken, I wonder if there is already something like that in Message
mode. I like gnus a lot, so I do not think that I am going to change to
mu4e just for that =)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-13 20:49 org-edit-src-code outside of org Jorge A. Alfaro-Murillo
  2014-05-13 20:58 ` Ken Mankoff
@ 2014-05-14 13:44 ` Hubert Chathi
  2014-05-17  6:33   ` Jorge A. Alfaro-Murillo
  2014-05-27  8:32 ` Thorsten Jolitz
  2 siblings, 1 reply; 7+ messages in thread
From: Hubert Chathi @ 2014-05-14 13:44 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, 13 May 2014 16:49:57 -0400, jorge.a.alfaro@gmail.com (Jorge A. Alfaro-Murillo) said:

> Hi, I would like to use org-edit-src-code outside of org, I think it
> would be very handy in Message mode, to send messages that contain
> code and edit that code in the proper mode.

[...]

I've been thinking that something like org-edit-src-code might be a
useful alternative to some of the multiple-major-modes tools.

-- 
Hubert Chathi - Email/Jabber: hubert@uhoreg.ca - http://www.uhoreg.ca/
PGP/GnuPG key: 4096R/113A1368 (Key available at pool.sks-keyservers.net)
Fingerprint: F24C F749 6C73 DDB8 DCB8  72DE B2DE 88D3 113A 1368

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-14 13:44 ` Hubert Chathi
@ 2014-05-17  6:33   ` Jorge A. Alfaro-Murillo
  2014-05-17  8:23     ` Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2014-05-17  6:33 UTC (permalink / raw)
  To: emacs-orgmode

I figure it out, I am updating the variable that causes problems and it
is working very well so in case you want to use org-edit-src-code in
Message mode all is needed is:

#+BEGIN_SRC emacs-lisp
  (eval-after-load "message"
    '(progn
       (define-key message-mode-map (kbd "<tab>")
         (lambda ()
           (interactive)
           (if (not (org-try-structure-completion))
               (message-tab))))
       (define-key message-mode-map (kbd "C-c '")
         (lambda ()
           (interactive)
           (org-edit-src-code)
           (setq-local org-edit-src-from-org-mode t)))))
#+END_SRC

I just used it right now =)

Jorge.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-17  6:33   ` Jorge A. Alfaro-Murillo
@ 2014-05-17  8:23     ` Alexander Baier
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Baier @ 2014-05-17  8:23 UTC (permalink / raw)
  To: Jorge A. Alfaro-Murillo; +Cc: emacs-orgmode

On 2014-05-17 08:33 Jorge A. Alfaro-Murillo wrote:
> I figure it out, I am updating the variable that causes problems and it
> is working very well so in case you want to use org-edit-src-code in
> Message mode all is needed is:
>
> #+BEGIN_SRC emacs-lisp
>   (eval-after-load "message"
>     '(progn
>        (define-key message-mode-map (kbd "<tab>")
>          (lambda ()
>            (interactive)
>            (if (not (org-try-structure-completion))
>                (message-tab))))
>        (define-key message-mode-map (kbd "C-c '")
>          (lambda ()
>            (interactive)
>            (org-edit-src-code)
>            (setq-local org-edit-src-from-org-mode t)))))
> #+END_SRC
>
> I just used it right now =)

This has been bugging me for quite some time now, thank you very much
for this, it works like it's supposed to! :)

Regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: org-edit-src-code outside of org
  2014-05-13 20:49 org-edit-src-code outside of org Jorge A. Alfaro-Murillo
  2014-05-13 20:58 ` Ken Mankoff
  2014-05-14 13:44 ` Hubert Chathi
@ 2014-05-27  8:32 ` Thorsten Jolitz
  2 siblings, 0 replies; 7+ messages in thread
From: Thorsten Jolitz @ 2014-05-27  8:32 UTC (permalink / raw)
  To: emacs-orgmode

jorge.a.alfaro@gmail.com (Jorge A. Alfaro-Murillo) writes:

> Hi, I would like to use org-edit-src-code outside of org, I think it
> would be very handy in Message mode, to send messages that contain code
> and edit that code in the proper mode.

This can be done with outshine.el and outorg.el. 
Install them as described in the docs and then add

,------------------------------------------------------------
| (when (require 'outline nil t)
| (add-hook 'message-mode-hook 'outline-minor-mode))
| 
| (require 'outshine nil t)
| (add-hook 'outline-minor-mode-hook 'outshine-hook-function)
| 
| (setq outshine-use-speed-commands t)
`------------------------------------------------------------

M-# M-# will then convert your message-mode buffer to full Org-mode, M-#
will copy the changes back to message-mode. As a proof of concept, I
attach this mail exported to ASCII by evaluating the following
source-block directly in the outorg-edit-buffer:

#+begin_src emacs-lisp
 (org-export-as 'ascii)
#+end_src

#+results:
			   _________________

				  745

			    Thorsten Jolitz
			   _________________


Table of Contents
_________________

1 --text follows this line--


1 --text follows this line--
============================

  jorge.a.alfaro@gmail.com (Jorge A. Alfaro-Murillo) writes:

  > Hi, I would like to use org-edit-src-code outside of org, I think it
  > would be very handy in Message mode, to send messages that contain
  > code and edit that code in the proper mode.

  This can be done with outshine.el and outorg.el.  Install them as
  described in the docs and then add

  ,------------------------------------------------------------
   (when (require 'outline nil t)                              
   (add-hook 'message-mode-hook 'outline-minor-mode))          

   (require 'outshine nil t)                                   
   (add-hook 'outline-minor-mode-hook 'outshine-hook-function) 

   (setq outshine-use-speed-commands t)                        
  `------------------------------------------------------------

  M-# M-# will then convert your message-mode buffer to full Org-mode,
  M-# will copy the changes back to message-mode. As a proof of concept,
  I attach this mail exported to ASCII.


  ,----
  | (org-export-as 'ascii)
  `----

  -- cheers, Thorsten

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-27  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13 20:49 org-edit-src-code outside of org Jorge A. Alfaro-Murillo
2014-05-13 20:58 ` Ken Mankoff
2014-05-13 21:12   ` Jorge A. Alfaro-Murillo
2014-05-14 13:44 ` Hubert Chathi
2014-05-17  6:33   ` Jorge A. Alfaro-Murillo
2014-05-17  8:23     ` Alexander Baier
2014-05-27  8:32 ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.