unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Comments within Org src block move point unexpectedly
@ 2021-04-09 13:13 excalamus--- via Users list for the GNU Emacs text editor
  2021-04-09 13:27 ` excalamus--- via Users list for the GNU Emacs text editor
  2021-04-09 14:27 ` Jean Louis
  0 siblings, 2 replies; 5+ messages in thread
From: excalamus--- via Users list for the GNU Emacs text editor @ 2021-04-09 13:13 UTC (permalink / raw)
  To: Help Gnu Emacs


The usual behavior of comment-line is to move point to the next line.When commenting code within an Org source block, however, the point will jump to some previous line.


For example, say that point is at |:

#+begin_src emacs-lisp  (defun hello ()    "Say hi."    (interactive)|    (message "Hello, world!"))#+end_src

When comment-line is called, the current line is commented, but point also moves to the indent of the previous line:

#+begin_src emacs-lisp  (defun hello ()    |"Say hi."    ;; (interactive)    (message "Hello, world!"))#+end_src
The point will jump near the top of the block when the block contains more code (i.e. will jump entire screen heights).

Ideally, I would like point to stay put (relative to the adjacent characters prior to (un)commenting).  I would at least expect comment-line to behave in a source block like it does outside of one.


I've tried a handful of related solutions (see links below).  They all move point similarly.  It looks like comment-or-uncomment-region is the typical entry point.  AFAIK, it ultimately hinges on the comment-region-function which is comment-region-default-1 by default.  Stepping through, it's not clear to me which part moves point to a previous line.  Does anyone have some insight?

https://stackoverflow.com/questions/9688748/emacs-comment-uncomment-current-line
https://stackoverflow.com/questions/20041904/eclipse-like-line-commenting-in-emacs/20064658#20064658



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

end of thread, other threads:[~2021-04-10 21:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-09 13:13 Comments within Org src block move point unexpectedly excalamus--- via Users list for the GNU Emacs text editor
2021-04-09 13:27 ` excalamus--- via Users list for the GNU Emacs text editor
2021-04-09 14:27 ` Jean Louis
2021-04-10 20:31   ` excalamus--- via Users list for the GNU Emacs text editor
2021-04-10 21:34     ` Jean Louis

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