[Top][All Lists]

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

Re: [O] uncommnet-region behavior in org-src blocks

From: John Kitchin
Subject: Re: [O] uncommnet-region behavior in org-src blocks
Date: Sat, 19 Mar 2016 19:27:14 -0400
User-agent: mu4e 0.9.16; emacs

Thanks! That is a nice function.

I adapted it to make Tab work in python mode blocks.

Curiously though, this:

(define-key org-mode-map (kbd "<return>")
  '(menu-item "org-mode-ret" nil
              :filter (lambda (&optional _)
                             (org-in-src-block-p t)
                             (string= "python"
                           (kbd ""))))))

doesn't do exactly what I would have expected, it seems to put an extra
line in and move the point past what (newline-and-indent) would do in
python-mode. I tried a few variations of this, and they all seem to do
that. One day I will have to learn how to get multiple modes active in
one buffer ;)

Ken Mankoff writes:

> On 2016-03-19 at 13:20, Eric S Fraga <address@hidden> wrote:
>> On Saturday, 19 Mar 2016 at 12:44, John Kitchin wrote:
>>> I noticed that you try to uncomment a region in a src block a # gets
>>> inserted!
>>> #+BEGIN_SRC emacs-lisp
>>> ; test
>>> #+END_SRC
>>> If you select ; test and run uncomment-region you get this:
>>> #+BEGIN_SRC emacs-lisp
>>> # ; test
>>> #+END_SRC
>>> It also does that in Python. Any ideas why?
>> Because you're in org mode, not emacs-lisp or python?  If you want to
>> comment/uncomment codes within a src block, my guess is you would need
>> to open up the blocks (C-c ') and then comment/uncomment...
> https://lists.gnu.org/archive/html/emacs-orgmode/2013-11/msg00318.html
> #+BEGIN_SRC emacs-lisp :results none
>     ;; 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)))
>     ;; make `C-c C-v C-x M-;' more convenient
>     (define-key org-mode-map
>       (kbd "M-;") 'my-org-comment-dwim)
>   -k.

Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213

reply via email to

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