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
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
Ideally, I would like point to not move at all (relative to the adjacent characters prior to (un)commenting) but would at least like
comment-line to behave in a source block like it does outside of one.
I've tried a variety of suggested answers. They all move point similarly. It looks like
comment-or-uncomment-region is the typical entry point. This function leads down quite a labyrinth. 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.