From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: uncommnet-region behavior in org-src blocks Date: Sat, 19 Mar 2016 19:27:14 -0400 Message-ID: References: <87k2ky8jwd.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahQHB-0006qw-Tz for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 19:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahQH7-00058S-NE for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 19:27:21 -0400 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]:33315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahQH7-00058N-IW for emacs-orgmode@gnu.org; Sat, 19 Mar 2016 19:27:17 -0400 Received: by mail-qk0-x22f.google.com with SMTP id s5so63671802qkd.0 for ; Sat, 19 Mar 2016 16:27:17 -0700 (PDT) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Ken Mankoff Cc: Org-Mode mailing list 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 "") '(menu-item "org-mode-ret" nil :filter (lambda (&optional _) (when (and (org-in-src-block-p t) (string= "python" (org-element-property :language (org-element-context)))) (org-babel-do-key-sequence-in-edit-buffer (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 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) > #+END_SRC > > -k. -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu