* 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 23:44 David Dynerman
2016-05-11 9:20 ` Phil Hudson
2016-05-11 21:26 ` Nicolas Goaziou
0 siblings, 2 replies; 12+ messages in thread
From: David Dynerman @ 2016-05-10 23:44 UTC (permalink / raw)
To: emacs-orgmode
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/)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 23:44 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/)] David Dynerman
@ 2016-05-11 9:20 ` Phil Hudson
2016-05-11 21:26 ` Nicolas Goaziou
1 sibling, 0 replies; 12+ messages in thread
From: Phil Hudson @ 2016-05-11 9:20 UTC (permalink / raw)
To: David Dynerman; +Cc: emacs-orgmode
On Wed, 11 May 2016 at 12:44:17 am BST, David Dynerman <david@block-party.net> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 23:44 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/)] David Dynerman
2016-05-11 9:20 ` Phil Hudson
@ 2016-05-11 21:26 ` Nicolas Goaziou
2016-05-13 0:00 ` Aaron Ecay
1 sibling, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2016-05-11 21:26 UTC (permalink / raw)
To: David Dynerman; +Cc: emacs-orgmode
Hello,
David Dynerman <david@block-party.net> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 21:26 ` Nicolas Goaziou
@ 2016-05-13 0:00 ` Aaron Ecay
2016-05-13 12:12 ` Nicolas Goaziou
0 siblings, 1 reply; 12+ messages in thread
From: Aaron Ecay @ 2016-05-13 0:00 UTC (permalink / raw)
To: Nicolas Goaziou, David Dynerman; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 0:00 ` Aaron Ecay
@ 2016-05-13 12:12 ` Nicolas Goaziou
2016-05-13 19:05 ` Aaron Ecay
2016-05-15 4:11 ` Vladimir Lomov
0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Goaziou @ 2016-05-13 12:12 UTC (permalink / raw)
To: David Dynerman; +Cc: emacs-orgmode
Hello,
Aaron Ecay <aaronecay@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 12:12 ` Nicolas Goaziou
@ 2016-05-13 19:05 ` Aaron Ecay
2016-05-15 4:11 ` Vladimir Lomov
1 sibling, 0 replies; 12+ messages in thread
From: Aaron Ecay @ 2016-05-13 19:05 UTC (permalink / raw)
To: Nicolas Goaziou, David Dynerman; +Cc: emacs-orgmode
Hi Nicolas, hi all,
2016ko maiatzak 13an, Nicolas Goaziou-ek idatzi zuen:
>
> Hello,
>
> Aaron Ecay <aaronecay@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 12:12 ` Nicolas Goaziou
2016-05-13 19:05 ` Aaron Ecay
@ 2016-05-15 4:11 ` Vladimir Lomov
2016-05-15 7:40 ` Nicolas Goaziou
1 sibling, 1 reply; 12+ messages in thread
From: Vladimir Lomov @ 2016-05-15 4:11 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]
Hello,
** Nicolas Goaziou [2016-05-13 14:12:20 +0200]:
> Hello,
>
> Aaron Ecay <aaronecay@gmail.com> 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.
[-- Attachment #2: ex.org --]
[-- Type: application/vnd.lotus-organizer, Size: 947 bytes --]
[-- Attachment #3: min-wc-org.el --]
[-- Type: text/plain, Size: 159 bytes --]
(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")
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 4:11 ` Vladimir Lomov
@ 2016-05-15 7:40 ` Nicolas Goaziou
2016-05-15 11:00 ` Vladimir Lomov
0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2016-05-15 7:40 UTC (permalink / raw)
To: Vladimir Lomov; +Cc: emacs-orgmode
Hello,
Vladimir Lomov <lomov.vl@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 7:40 ` Nicolas Goaziou
@ 2016-05-15 11:00 ` Vladimir Lomov
2016-05-15 17:03 ` Nicolas Goaziou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Lomov @ 2016-05-15 11:00 UTC (permalink / raw)
To: emacs-orgmode
Hello,
** Nicolas Goaziou [2016-05-15 09:40:03 +0200]:
> Hello,
>
> Vladimir Lomov <lomov.vl@gmail.com> 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 11:00 ` Vladimir Lomov
@ 2016-05-15 17:03 ` Nicolas Goaziou
2016-05-16 2:48 ` Vladimir Lomov
0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2016-05-15 17:03 UTC (permalink / raw)
To: Vladimir Lomov; +Cc: emacs-orgmode
Hello,
Vladimir Lomov <lomov.vl@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 17:03 ` Nicolas Goaziou
@ 2016-05-16 2:48 ` Vladimir Lomov
2016-05-16 9:29 ` Nicolas Goaziou
0 siblings, 1 reply; 12+ messages in thread
From: Vladimir Lomov @ 2016-05-16 2:48 UTC (permalink / raw)
To: emacs-orgmode
Hello,
** Nicolas Goaziou [2016-05-15 19:03:57 +0200]:
> Hello,
>
> Vladimir Lomov <lomov.vl@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: 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 2:48 ` Vladimir Lomov
@ 2016-05-16 9:29 ` Nicolas Goaziou
0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Goaziou @ 2016-05-16 9:29 UTC (permalink / raw)
To: Vladimir Lomov; +Cc: emacs-orgmode
Hello,
Vladimir Lomov <lomov.vl@gmail.com> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-05-16 9:40 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10 23:44 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/)] David Dynerman
2016-05-11 9:20 ` Phil Hudson
2016-05-11 21:26 ` Nicolas Goaziou
2016-05-13 0:00 ` Aaron Ecay
2016-05-13 12:12 ` Nicolas Goaziou
2016-05-13 19:05 ` Aaron Ecay
2016-05-15 4:11 ` Vladimir Lomov
2016-05-15 7:40 ` Nicolas Goaziou
2016-05-15 11:00 ` Vladimir Lomov
2016-05-15 17:03 ` Nicolas Goaziou
2016-05-16 2:48 ` Vladimir Lomov
2016-05-16 9:29 ` Nicolas Goaziou
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).