* uncommnet-region behavior in org-src blocks
@ 2016-03-19 16:44 John Kitchin
2016-03-19 17:20 ` Eric S Fraga
0 siblings, 1 reply; 10+ messages in thread
From: John Kitchin @ 2016-03-19 16:44 UTC (permalink / raw)
To: Org-Mode mailing list
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?
--
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
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 18:07 ` Ken Mankoff
0 siblings, 2 replies; 10+ messages in thread
From: Eric S Fraga @ 2016-03-19 17:20 UTC (permalink / raw)
To: John Kitchin; +Cc: Org-Mode mailing list
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...
--
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.91.1, Org release_8.3.4-626-gb62d55
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
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
1 sibling, 1 reply; 10+ messages in thread
From: John Kitchin @ 2016-03-19 18:03 UTC (permalink / raw)
To: John Kitchin, Org-Mode mailing list
[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]
sure, that is true. I am still surprised that "uncommenting" adds a # which
in org is a comment. actually that seems to happen everywhere in the
org-file!
John
-----------------------------------
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
On Sat, Mar 19, 2016 at 1:20 PM, 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...
> --
> : Eric S Fraga (0xFFFCF67D), Emacs 25.0.91.1, Org release_8.3.4-626-gb62d55
>
[-- Attachment #2: Type: text/html, Size: 1870 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-19 17:20 ` Eric S Fraga
2016-03-19 18:03 ` John Kitchin
@ 2016-03-19 18:07 ` Ken Mankoff
2016-03-19 23:27 ` John Kitchin
2016-04-03 20:36 ` Adam Porter
1 sibling, 2 replies; 10+ messages in thread
From: Ken Mankoff @ 2016-03-19 18:07 UTC (permalink / raw)
To: Eric S Fraga; +Cc: Org-Mode mailing list, John Kitchin
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-19 18:03 ` John Kitchin
@ 2016-03-19 19:39 ` Eric S Fraga
0 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2016-03-19 19:39 UTC (permalink / raw)
To: John Kitchin; +Cc: Org-Mode mailing list
On Saturday, 19 Mar 2016 at 14:03, John Kitchin wrote:
> sure, that is true. I am still surprised that "uncommenting" adds a # which
> in org is a comment. actually that seems to happen everywhere in the
> org-file!
Ah, yes, sorry: I'm so used to commenting doing the right thing (comment
if not already commented, uncomment if commented) that I missed that. I
have a feeling that all the code from newcomment.el works this way...
--
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.91.1, Org release_8.3.4-626-gb62d55
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-19 18:07 ` Ken Mankoff
@ 2016-03-19 23:27 ` John Kitchin
2016-03-20 0:15 ` Ken Mankoff
2016-04-03 20:36 ` Adam Porter
1 sibling, 1 reply; 10+ messages in thread
From: John Kitchin @ 2016-03-19 23:27 UTC (permalink / raw)
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 "<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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-19 23:27 ` John Kitchin
@ 2016-03-20 0:15 ` Ken Mankoff
2016-03-20 15:17 ` John Kitchin
0 siblings, 1 reply; 10+ messages in thread
From: Ken Mankoff @ 2016-03-20 0:15 UTC (permalink / raw)
To: John Kitchin; +Cc: Org-Mode mailing list
On 2016-03-19 at 19:27, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Thanks! That is a nice function.
>
> I adapted it to make Tab work in python mode blocks.
This might already do that:
(setq org-src-tab-acts-natively nil)
-k.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-20 0:15 ` Ken Mankoff
@ 2016-03-20 15:17 ` John Kitchin
2016-03-20 15:53 ` Ken Mankoff
0 siblings, 1 reply; 10+ messages in thread
From: John Kitchin @ 2016-03-20 15:17 UTC (permalink / raw)
To: Ken Mankoff; +Cc: Org-Mode mailing list
[-- Attachment #1: Type: text/plain, Size: 760 bytes --]
I think you mean (setq org-src-tab-acts-natively t) right?
It looks like the function I made basically does the same thing, by another
mechanism!
I still wonder why it doesn't work with RET though.
John
-----------------------------------
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
On Sat, Mar 19, 2016 at 8:15 PM, Ken Mankoff <mankoff@gmail.com> wrote:
>
> On 2016-03-19 at 19:27, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> > Thanks! That is a nice function.
> >
> > I adapted it to make Tab work in python mode blocks.
>
> This might already do that:
>
> (setq org-src-tab-acts-natively nil)
>
> -k.
>
[-- Attachment #2: Type: text/html, Size: 1707 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-20 15:17 ` John Kitchin
@ 2016-03-20 15:53 ` Ken Mankoff
0 siblings, 0 replies; 10+ messages in thread
From: Ken Mankoff @ 2016-03-20 15:53 UTC (permalink / raw)
To: John Kitchin; +Cc: Org-Mode mailing list
On 2016-03-20 at 11:17, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> I think you mean (setq org-src-tab-acts-natively t) right?
Yes. I think I may have disabled it due to Yasnippet conflicts.
-k.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: uncommnet-region behavior in org-src blocks
2016-03-19 18:07 ` Ken Mankoff
2016-03-19 23:27 ` John Kitchin
@ 2016-04-03 20:36 ` Adam Porter
1 sibling, 0 replies; 10+ messages in thread
From: Adam Porter @ 2016-04-03 20:36 UTC (permalink / raw)
To: emacs-orgmode
Ken, just wanted to say thanks for sharing this. I noticed this recently
and wondered about fixing it, and this does it!
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-04-03 20:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).