help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Comments within Org src block move point unexpectedly


From: excalamus
Subject: Comments within Org src block move point unexpectedly
Date: Fri, 9 Apr 2021 15:13:40 +0200 (CEST)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]