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-;=)?

--8<---------------cut here---------------start------------->8---
;; 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)
--8<---------------cut here---------------end--------------->8---

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

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to