emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Ken Mankoff <mankoff@gmail.com>
Cc: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: uncommnet-region behavior in org-src blocks
Date: Sat, 19 Mar 2016 19:27:14 -0400	[thread overview]
Message-ID: <m2mvpu2gml.fsf@Johns-MacBook-Air.local> (raw)
In-Reply-To: <m2zitugx44.fsf@gmail.com>

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 _)
                        (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 <e.fraga@ucl.ac.uk> 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

  reply	other threads:[~2016-03-19 23:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-19 16:44 uncommnet-region behavior in org-src blocks John Kitchin
2016-03-19 17:20 ` Eric S Fraga
2016-03-19 18:03   ` John Kitchin
2016-03-19 19:39     ` Eric S Fraga
2016-03-19 18:07   ` Ken Mankoff
2016-03-19 23:27     ` John Kitchin [this message]
2016-03-20  0:15       ` Ken Mankoff
2016-03-20 15:17         ` John Kitchin
2016-03-20 15:53           ` Ken Mankoff
2016-04-03 20:36     ` Adam Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2mvpu2gml.fsf@Johns-MacBook-Air.local \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=mankoff@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).