emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [PATCH] Allow code edit buffer to inherit active region


From: Dan Davison
Subject: [Orgmode] Re: [PATCH] Allow code edit buffer to inherit active region
Date: Thu, 30 Sep 2010 10:53:15 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)


Sébastien Vauban <address@hidden>
writes:

> Hi Dan,
>
> Dan Davison wrote:
>> Now, if the region is contained within a src block, then it will be
>> inherited by the language major mode edit buffer. One consequence is that
>> commands like M-; (comment-region) and C-M-\ (indent-region) can be called
>> with their native effects from a src block in the Org buffer.
>
> Am I right assuming we still need such a code in order to get the wanted
> effect with the native keys (I mean, for example, =M-;= instead of =C-c C-v
> C-x M-;=)?

Hi Séb,

Yes. If people think it is worthwhile, we could make it so that these
are controlled by variables `org-src-comment-natively' and
`org-src-indent-natively'. However, currently that is not the case. The
only such variable currently is `org-src-tab-acts-natively'.

By the way, please note that there is a minor wrinkle: if you place
point in the #+end_src line in the Org buffer, then it goes to the
beginning of the last line of code in the edit buffer, and the region
will not contain what you were intending (all the code). I'm going to
submit a patch so that point goes to the end of the code in this case.

Dan

>
> ;; allow comment region in the code edit buffer (according to language)
> (defun my/org-comment-dwim (&optional arg)
>   (interactive "P")
>   (or (org-babel-do-key-sequence-in-edit-buffer (kbd "M-;"))
>       (comment-dwim arg)))
>
> (define-key org-mode-map (kbd "M-;") 'my/org-comment-dwim)
>
> ;; allow indent region in the code edit buffer (according to language)
> (defun my/org-indent-region (&optional arg)
>   (interactive "P")
>   (or (org-babel-do-key-sequence-in-edit-buffer (kbd "C-M-\\"))
>       (indent-region arg)))
>
> (define-key org-mode-map (kbd "C-M-\\") 'my/org-indent-region)
>
> BTW, note that I make use of =kbd= to have a more intuitive writing of the key
> bindings (just copy what =C-h k= shows, except for the =\= that has to be
> escaped). Isn't this more portable (other versions of Emacs, or XEmacs)?
>
> Best regards,
>   Seb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]