Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-16 Thread Nicolas Goaziou
Hello,

Vladimir Lomov  writes:

> This works fine, though at first I thought it would be enough to add
> only following code
> #+BEGIN_SRC emacs-lisp
>   (define-key org-src-mode-map [f2] 'org-edit-src-save)
> #+END_SRC
> into emacs init file. Of course, this don't work and emacs complains about
> ~org-src-mode-map~. Only one thing bother me: is it normal to add such
> hook into ~org-src-mode-hook~ ?

I think so. I also add keybindings through mode hooks.

Another way to achieve this it to use `with-eval-after-load'.

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-15 Thread Vladimir Lomov
Hello,
** Nicolas Goaziou [2016-05-15 19:03:57 +0200]:

> Hello,
> 
> Vladimir Lomov  writes:
> 
>> Correct me if I understand you wrong, but you suggest to bind ~F2~ key
>> to ~org-edit-src-save~. But then this will work only in Org buffer, and
>> how about LaTeX mode then. Or I should bind ~F2~ to something like that:
>> (global-set-key [f2]
>>   (if (functionp org-edit-src-save) org-edit-src-save save-buffer))
> 
> Actually, I meant to bind F2 to `org-edit-src-save' in
> `org-src-mode-map'.

With your advice I came to following code for my init file:
#+BEGIN_SRC emacs-lisp
  (add-hook 'org-src-mode-hook
(lambda ()
  (define-key org-src-mode-map [f2] 'org-edit-src-save)
)
  )
#+END_SRC

This works fine, though at first I thought it would be enough to add
only following code
#+BEGIN_SRC emacs-lisp
  (define-key org-src-mode-map [f2] 'org-edit-src-save)
#+END_SRC
into emacs init file. Of course, this don't work and emacs complains about
~org-src-mode-map~. Only one thing bother me: is it normal to add such
hook into ~org-src-mode-hook~ ?

>> On second thought, I considered org-src buffer as auxiliary buffer,
>> depending on (main) Org document buffer, so saving org-src buffer should
>> save Org document buffer.
> 
> This is the case already with C-x C-s, not for `save-buffer'.
> 
> Regards,
> 
> -- 
> Nicolas Goaziou

-- 
"If you can, help others.  If you can't, at least don't hurt others."
-- the Dalai Lama



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-15 Thread Nicolas Goaziou
Hello,

Vladimir Lomov  writes:

> Correct me if I understand you wrong, but you suggest to bind ~F2~ key
> to ~org-edit-src-save~. But then this will work only in Org buffer, and
> how about LaTeX mode then. Or I should bind ~F2~ to something like that:
> (global-set-key [f2]
>   (if (functionp org-edit-src-save) org-edit-src-save save-buffer))

Actually, I meant to bind F2 to `org-edit-src-save' in
`org-src-mode-map'.

> On second thought, I considered org-src buffer as auxiliary buffer,
> depending on (main) Org document buffer, so saving org-src buffer should
> save Org document buffer.

This is the case already with C-x C-s, not for `save-buffer'.

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-15 Thread Vladimir Lomov
Hello,
** Nicolas Goaziou [2016-05-15 09:40:03 +0200]:

> Hello,
> 
> Vladimir Lomov  writes:
> 
>> I have small example that worked before the commit, please see attached
>> Org document.
> 
> While it's true this worked before, I don't consider it to be
> a regression. There was no guarantee that `save-buffer' would save the
> source buffer. In fact, I think instrumenting `save-buffer' is not
> a good idea, because it is surprising. Usually, minor modes change
> bindings instead of altering functions.
> 
> You can bind `org-edit-src-save' to F2 in this case.

Correct me if I understand you wrong, but you suggest to bind ~F2~ key
to ~org-edit-src-save~. But then this will work only in Org buffer, and
how about LaTeX mode then. Or I should bind ~F2~ to something like that:
(global-set-key [f2]
  (if (functionp org-edit-src-save) org-edit-src-save save-buffer))

(don't test this code, just idea, may be this code won't work or even
there is more elegant code and idea).

On second thought, I considered org-src buffer as auxiliary buffer,
depending on (main) Org document buffer, so saving org-src buffer should
save Org document buffer. I agree that there should be possibility to
save org-src buffer and if ~write-buffer~ works it is Ok and it is Ok to
call it manually. This is just my thoughts.

> 
> Regards,
> 
> -- 
> Nicolas Goaziou

---
WBR, Vladimir Lomov

-- 
Q:  Why does Washington have the most lawyers per capita and
New Jersey the most toxic waste dumps?
A:  God gave New Jersey first choice.



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-15 Thread Nicolas Goaziou
Hello,

Vladimir Lomov  writes:

> I have small example that worked before the commit, please see attached
> Org document.

While it's true this worked before, I don't consider it to be
a regression. There was no guarantee that `save-buffer' would save the
source buffer. In fact, I think instrumenting `save-buffer' is not
a good idea, because it is surprising. Usually, minor modes change
bindings instead of altering functions.

You can bind `org-edit-src-save' to F2 in this case.

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-14 Thread Vladimir Lomov
Hello,
** Nicolas Goaziou [2016-05-13 14:12:20 +0200]:

> Hello,
> 
> Aaron Ecay  writes:
> 
>> Is this a correct change?  Previously, C-x C-s in the org-src buffer
>> would save the underlying .org file, which was useful.  AFAICS this now
>> would not work.
> 
> Why do you think so ? C-x C-s is still bound to `org-edit-src-save'. Do
> you have an ECM demonstrating the issue?

I have small example that worked before the commit, please see attached
Org document.

>> I also wonder whether autosave will work correctly from
>> the org-src buffer.
> 
> Again, why wouldn't it work? It calls `org-edit-src-save'.
> 
>> I think the other suggestion in this thread (to use write-region) is
>> a better solution.
> 
> The problem is about `write-file' (C-x C-w). If this function is not
> behaving as expected, it should be fixed, if possible.
> 
> In any case, I think the lines of code I removed were useless anyway. Do
> you have any use case in mind for them?
> 
> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

---
WBR, Vladimir Lomov

-- 
Economists are still trying to figure out why the girls with the least
principle draw the most interest.


ex.org
Description: Lotus Organizer
(global-set-key [f2] 'save-buffer)
(add-to-list 'load-path "/usr/share/emacs/site-lisp/org")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/org_contrib")


Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-13 Thread Aaron Ecay
Hi Nicolas, hi all,

2016ko maiatzak 13an, Nicolas Goaziou-ek idatzi zuen:
> 
> Hello,
> 
> Aaron Ecay  writes:
> 
>> Is this a correct change?  Previously, C-x C-s in the org-src buffer
>> would save the underlying .org file, which was useful.  AFAICS this now
>> would not work.
> 
> Why do you think so ? C-x C-s is still bound to `org-edit-src-save'. 

You’re right – I misunderstood the change.  Sorry for the noise.

-- 
Aaron Ecay



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-13 Thread Nicolas Goaziou
Hello,

Aaron Ecay  writes:

> Is this a correct change?  Previously, C-x C-s in the org-src buffer
> would save the underlying .org file, which was useful.  AFAICS this now
> would not work.

Why do you think so ? C-x C-s is still bound to `org-edit-src-save'. Do
you have an ECM demonstrating the issue?

> I also wonder whether autosave will work correctly from
> the org-src buffer.

Again, why wouldn't it work? It calls `org-edit-src-save'.

> I think the other suggestion in this thread (to use write-region) is
> a better solution.

The problem is about `write-file' (C-x C-w). If this function is not
behaving as expected, it should be fixed, if possible.

In any case, I think the lines of code I removed were useless anyway. Do
you have any use case in mind for them?


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-12 Thread Aaron Ecay
Hi Nicolas,

2016ko maiatzak 11an, Nicolas Goaziou-ek idatzi zuen:

> I changed this in developement version. If you get any chance to test
> it, Please tell me if it behaves as expected. Thank you.

Is this a correct change?  Previously, C-x C-s in the org-src buffer
would save the underlying .org file, which was useful.  AFAICS this now
would not work.  I also wonder whether autosave will work correctly from
the org-src buffer.  I think the other suggestion in this thread (to use
write-region) is a better solution.

-- 
Aaron Ecay



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-11 Thread Nicolas Goaziou
Hello,

David Dynerman  writes:

> When visiting an org-babel code block in a dedicated window (C-c ' in
> the block), I would like to manually save the buffer to a file by calling
> write-file (C-x C-w) 
>
> However, this doesn't work - it prompts you for a filename, as expected,
> but no matter what filename you enter it always just re-saves the .org
> file that contains the babel block you are editing.
>
> Is this expected? If it's not possible to have this functionality, some
> kind of error message would be helpful.

I changed this in developement version. If you get any chance to test
it, Please tell me if it behaves as expected. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-11 Thread Phil Hudson
On Wed, 11 May 2016 at 12:44:17 am BST, David Dynerman  
wrote:

> I would like to manually save the buffer to a file by calling
> write-file (C-x C-w) 

Would `write-region' not be what you want?

-- 
Phil Hudson   http://hudson-it.ddns.net
@UWascalWabbit PGP/GnuPG ID: 0x887DCA63



[O] Bug: Write file while editing babel code block doesn't work as expected [8.3.4 (release_8.3.4-778-g8127b3 @ /usr/local/share/emacs/site-lisp/org/)]

2016-05-10 Thread David Dynerman
When visiting an org-babel code block in a dedicated window (C-c ' in
the block), I would like to manually save the buffer to a file by calling
write-file (C-x C-w) 

However, this doesn't work - it prompts you for a filename, as expected,
but no matter what filename you enter it always just re-saves the .org
file that contains the babel block you are editing.

Is this expected? If it's not possible to have this functionality, some
kind of error message would be helpful.

Emacs  : GNU Emacs 25.1.50.1 (x86_64-apple-darwin15.4.0, NS appkit-1404.46 
Version 10.11.4 (Build 15E65))
 of 2016-03-24
Package: Org-mode version 8.3.4 (release_8.3.4-778-g8127b3 @ 
/usr/local/share/emacs/site-lisp/org/)