* org-src.el (ob-comint): require 'ob-comint
(org-src-babel-info): define variable
Also, reposition `org-src-do-at-code-block' and
`org-src-do-key-sequence-at-code-block' function definitions within
the file.
* ob.el (org-babel-do-in-edit-buffer): New macro to
evaluate lisp in the language major mode edit buffer.
(org-babel-do-key-sequence-in-edit-buffer): New function to call
an arbitrary key sequence in the language major mode edit
buffer
* org-src.el (org-src-switch-to-buffer): Add new allowed value
'switch-invisibly for `org-src-window-setup'.
* ob-keys.el (org-babel-key-bindings): Bind
`org-babel-do-key-sequence-in-edit-buffer' to x and C-x in
`org-babel-map'
* org-src.el (ob-keys): Require ob-keys, because
`org-babel-map' is used.
(org-src-do-at-code-block): New macro to evaluate lisp with
point at the start of the Org code block containing the code
in this edit buffer.
(org-src-do-key-sequence-at-code-block): New function to
execute command bound to key at the Org code block containing
the code in this edit buffer.
* org-src.el (org-edit-src-code): If at src block, store babel
info as buffer local variable.
(org-src-associate-babel-session): New function to associate
code edit buffer with comint session. Does nothing
unless a language-specific function named
`org-babel-LANG-associate-session' exists.
(org-src-babel-configure-edit-buffer): New function to be
called in `org-src-mode-hook'.
(org-src-mode-hook): add `org-src-babel-configure-edit-buffer'
to hook.
This is the fifth patch in a series that makes some straightforward
corrections to a number of docstrings. Each change is normally to:
- correct a typo, or
- fix up hyperlinks to function or variable names, or
- ensure slightly better conformance with the documentation guidelines
and tips given in the Elisp manual
No attempt is made to provide missing docstrings or document arguments.
Cheers,
Phil
Carsten Dominik <dominik@uva.nl> writes:
> Hi Dan,
>
> after a long time, I tried to edit a fixed width region today.
> So I entered
>
> : a
> : b
> : c
>
> and pressed "C-c '" in there. The edit buffer came up in
> read-only mode, which should not be so.
>
> Also, when I do "C-c '" in an empty line, it used to be the case
> that I get an empty artist buffer which I can then edit. Also this
> buffer comes up as read-only.
>
> I suspect that this has to do with the changes you made for read-only
> view buffers. Before I dive into this issue myself, maybe it will be
> much
> easier if you do this?
Hi Carsten,
You're right that it dates from then. Here's the fix I suggest. I've
tested that this results in writable fixed-width edit buffers, writable
src edit buffers, and non-writable babel preview buffers.
Dan
--8<---------------cut here---------------start------------->8---
commit ed4eb9d150
Author: Dan Davison <davison@stats.ox.ac.uk>
Date: Sat Jun 5 12:35:19 2010 +0100
* lisp/org-src.el: Prevent fixed-width region edit buffers
being created as read-only.
Modified lisp/org-src.el
org-edit-src-code gains extra optional arguments `code' and
`edit-buffer-name'. If `code' is supplied, then this code forms the
contents of the edit buffer, which is made read-only. In this case,
the mechanisms for writing back to the org buffer on save are
disabled.
Optional argument `edit-buffer-name' allows a name for the edit buffer
to be supplied.
This support was totally broken. It works now again. Unfortunately
it is not possible to edit the table directly in the org-mode buffer
anymore - to edit such a table, you have to use C-c '
Saving the edit buffer is achieved by calling org-edit-src-exit,
saving the org buffer and returning to the edit buffer with
org-edit-src-code. When those two functions are used in this context,
they should not attempt to restore the saved window configuration, nor
alter the saved window configuration.
These changes provides frame / window management preferences for the
edit buffer generated using C-c ' on a source code block. Preferences
are specified by a new variable org-src-window-setup, which is based
on org-agenda-window-setup and has the same four options:
current-window, other-window, reorganize-frame, other-frame. These
behave as follows:
* current-window
The edit buffer appears in the current window.
* other-window
`switch-to-buffer-other-window' is used to switch to the edit buffer
in the same frame.
* reorganize-frame [default]
The current frame is reorganized so that it is split between the
source code edit buffer and the parent org buffer.
* other-frame
The edit buffer appears in a new frame. That frame is deleted when
exiting the edit buffer with C-c '.
In org-edit-src-save, point and mark were being restored inside the
save-window-excursion. As it happens, although mark is lost, point
nevertheless retained its position with switch-to-buffer being used to
switch between org and edit buffers, as is currently the
case. However, the failure to restore point correctly is exposed if
more complex options controlling window and frame management are
provided for the edit buffer.
If an active edit buffer exists for a source block, and this variable
is non-nil, then org-edit-src-code will not ask before returning to
the edit buffer, and future saves will overwrite the source block's
contents.
New customizable variable org-src-preserve-indentation, if non-nil,
prevents automatic removal of rectangular blocks of leading whitespace
in source code blocks. This is necessary when embedding python code in
an org file with a view to extracting all python blocks into a single
file (because whitespace indentation is critical in python code). The
changes in this commit also fix two bugs:
- Setting org-edit-src-content-indentation to zero resulted in an
infinite loop in org-edit-src-exit.
- Fixed width regions are defined by lines starting with a colon, with
optional leading whitespace. However, if there was any leading
whitespace, org-edit-src-exit behaved incorrectly, causing the leading
whitespace to grow.
Eric Schulte writes:
> Attached is a small patch for a small issue.
>
> Sometimes a language uses a major mode which can't be guessed
> from it's name. This patch introduces the `org-src-lang-modes'
> variable which can be used to map language names to major modes
> when this is the case. This is used when editing a source-code
> block, or when exporting fontified source-code with htmlize.
>
> So far the only instance of this that I know of is ocaml and
> tuareg-mode, so that's the only thing that `org-src-lang-modes'
> is pre-populated with. Maybe there are other instances as well?
Allow whitespace in code references. Allow the -r switch to remove the
references in the source code even when the lines are not numbered: the
labels can be explicit enough. Note that "-r -k" is the same than no
switch - as expected.
Thanks to Ulf Stegemann for bring this up.
This commit adds a new hook `org-src-mode-hook'.
The Hook run after Org switched a source code snippet to
its Emacs mode. This hook will run
- when editing a source code snippet with \"C-c '\".
- When formatting a source code snippet for export with htmlize.
You may want to use this hook for example to turn off `outline-minor-mode'
or similar things which you want to have when editing a source code file,
but which mess up the display of a snippet in Org exported files.