emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* src block: 'C-c C-c can do nothing useful here' if cursor on blank line
@ 2017-01-27 18:44 John Hendy
  2017-01-27 20:35 ` John Kitchin
  0 siblings, 1 reply; 6+ messages in thread
From: John Hendy @ 2017-01-27 18:44 UTC (permalink / raw)
  To: emacs-orgmode

Perhaps this is the intended behavior, but I noticed that I go to
execute a code block and get the message "C-c C-c can do nothing
useful here" if I'm not on the actual src block definition or a line
of code. If I'm on a blank line inside it, it doesn't execute. Here
was my test:

#+begin min_config

(add-to-list 'load-path "~/.elisp/org/lisp/")
(add-to-list 'load-path "~/.elisp/org/contrib/lisp")

(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)))

#+end

Start with =emacs -Q= and then =M-x load-file RET
~/path/to/min-config=, then use this test file:

* heading

#+begin_src R
^
x <- 1:10
x

#+end_src

With the cursor at ^ it won't run. I would understand if this were in
interactive mode using =C-c '=, but the behavior of C-c C-c is to run
the whole block anyway. It seems like Org doesn't know I'm in a src
block. Since blank lines are common, I'd expect not to have to make
*sure* I'm on an actual line of code and that being anywhere in a src
block should work.

Thoughts?


Thanks,
John

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: src block: 'C-c C-c can do nothing useful here' if cursor on blank line
       [not found] <dfb1983ec7384aec9ca2172a9b27a66c@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2017-01-27 20:17 ` Eric S Fraga
  2017-01-27 21:00   ` Kyle Meyer
  0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2017-01-27 20:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

On Friday, 27 Jan 2017 at 18:44, John Hendy wrote:
> Perhaps this is the intended behavior, but I noticed that I go to
> execute a code block and get the message "C-c C-c can do nothing
> useful here" if I'm not on the actual src block definition or a line
> of code. If I'm on a blank line inside it, it doesn't execute. Here
> was my test:

I have noticed this recently as well.  Not sure if it was always the
case, mind you, but it would be nice if C-c C-c would work even when the
cursor is on a blank line (within a src block, that is).

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-241-gc3d67b

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: src block: 'C-c C-c can do nothing useful here' if cursor on blank line
  2017-01-27 18:44 John Hendy
@ 2017-01-27 20:35 ` John Kitchin
  0 siblings, 0 replies; 6+ messages in thread
From: John Kitchin @ 2017-01-27 20:35 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

I get this all the time too. It would be nice if it went away, I also
find it annoying.

John Hendy writes:

> Perhaps this is the intended behavior, but I noticed that I go to
> execute a code block and get the message "C-c C-c can do nothing
> useful here" if I'm not on the actual src block definition or a line
> of code. If I'm on a blank line inside it, it doesn't execute. Here
> was my test:
>
> #+begin min_config
>
> (add-to-list 'load-path "~/.elisp/org/lisp/")
> (add-to-list 'load-path "~/.elisp/org/contrib/lisp")
>
> (org-babel-do-load-languages
>  'org-babel-load-languages
>  '((R . t)))
>
> #+end
>
> Start with =emacs -Q= and then =M-x load-file RET
> ~/path/to/min-config=, then use this test file:
>
> * heading
>
> #+begin_src R
> ^
> x <- 1:10
> x
>
> #+end_src
>
> With the cursor at ^ it won't run. I would understand if this were in
> interactive mode using =C-c '=, but the behavior of C-c C-c is to run
> the whole block anyway. It seems like Org doesn't know I'm in a src
> block. Since blank lines are common, I'd expect not to have to make
> *sure* I'm on an actual line of code and that being anywhere in a src
> block should work.
>
> Thoughts?
>
>
> Thanks,
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: src block: 'C-c C-c can do nothing useful here' if cursor on blank line
  2017-01-27 20:17 ` src block: 'C-c C-c can do nothing useful here' if cursor on blank line Eric S Fraga
@ 2017-01-27 21:00   ` Kyle Meyer
  2017-01-27 22:29     ` Charles C. Berry
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2017-01-27 21:00 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Friday, 27 Jan 2017 at 18:44, John Hendy wrote:
>> Perhaps this is the intended behavior, but I noticed that I go to
>> execute a code block and get the message "C-c C-c can do nothing
>> useful here" if I'm not on the actual src block definition or a line
>> of code. If I'm on a blank line inside it, it doesn't execute. Here
>> was my test:
>
> I have noticed this recently as well.  Not sure if it was always the
> case, mind you, but it would be nice if C-c C-c would work even when the
> cursor is on a blank line (within a src block, that is).

I think this changed with 0b6a2e241 (C-c C-c does nothing when at a
blank line, 2013-02-15).  I wasn't able to figure out the motivation for
that change.

-- 
Kyle

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: src block: 'C-c C-c can do nothing useful here' if cursor on blank line
  2017-01-27 21:00   ` Kyle Meyer
@ 2017-01-27 22:29     ` Charles C. Berry
  2017-01-27 23:00       ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2017-01-27 22:29 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

On Fri, 27 Jan 2017, Kyle Meyer wrote:

> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> On Friday, 27 Jan 2017 at 18:44, John Hendy wrote:
>>> Perhaps this is the intended behavior, but I noticed that I go to
>>> execute a code block and get the message "C-c C-c can do nothing
>>> useful here" if I'm not on the actual src block definition or a line
>>> of code. If I'm on a blank line inside it, it doesn't execute. Here
>>> was my test:
>>
>> I have noticed this recently as well.  Not sure if it was always the
>> case, mind you, but it would be nice if C-c C-c would work even when the
>> cursor is on a blank line (within a src block, that is).
>
> I think this changed with 0b6a2e241 (C-c C-c does nothing when at a
> blank line, 2013-02-15).  I wasn't able to figure out the motivation for
> that change.

Nor I. Perhaps it was just an oversight.

FWIW, in `org-ctrl-c-ctrl-c'

:    (looking-at-p "[ \t]*$")

could be

#+BEGIN_SRC emacs-lisp
   (and
    (looking-at-p "[ \t]*$")
    (not (eq 'src-block (org-element-type (org-element-context))))))
#+END_SRC

without causing a lot of grief. I think `src-block' is the only
relevant case.

Chuck

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: src block: 'C-c C-c can do nothing useful here' if cursor on blank line
  2017-01-27 22:29     ` Charles C. Berry
@ 2017-01-27 23:00       ` Nicolas Goaziou
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2017-01-27 23:00 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Kyle Meyer, emacs-orgmode

Hello,

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> Nor I. Perhaps it was just an oversight.
>
> FWIW, in `org-ctrl-c-ctrl-c'
>
> :    (looking-at-p "[ \t]*$")
>
> could be
>
> #+BEGIN_SRC emacs-lisp
>    (and
>     (looking-at-p "[ \t]*$")
>     (not (eq 'src-block (org-element-type (org-element-context))))))
> #+END_SRC
>
> without causing a lot of grief. I think `src-block' is the only
> relevant case.

In almost all cases, you don't want C-c C-c to do anything on a blank
line. Commit 0b6a2e2416b0acc28469661d7013f92f82a34267 pointed out before
was pushed because calling C-c C-c on the blank lines right after
a blank line would call `org-set-tags'.

What you suggest is sub-optimal, tho. The point of this quick check is
to eschew `org-element-context' call a few lines below. This would make
two calls instead of one.

I think a proper solution is to bite the bullet and make the check after
calling `org-element-context', in a pcase branch. This is what I did in
ebb9da0d0.

Please let me know if it doesn't solve the issue.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-27 23:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <dfb1983ec7384aec9ca2172a9b27a66c@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-01-27 20:17 ` src block: 'C-c C-c can do nothing useful here' if cursor on blank line Eric S Fraga
2017-01-27 21:00   ` Kyle Meyer
2017-01-27 22:29     ` Charles C. Berry
2017-01-27 23:00       ` Nicolas Goaziou
2017-01-27 18:44 John Hendy
2017-01-27 20:35 ` John Kitchin

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).