From: Jean Louis <bugs@gnu.support>
To: excalamus@tutanota.com
Cc: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Comments within Org src block move point unexpectedly
Date: Fri, 9 Apr 2021 17:27:30 +0300 [thread overview]
Message-ID: <YHBkUshxZKkBhC8m@protected.localdomain> (raw)
In-Reply-To: <MXql3Rv--3-2@tutanota.com>
* excalamus--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-04-09 16:14]:
>
> 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
Well, isn't your formatting somehow misaligned?
I have placed this in Org:
#+begin_src emacs-lisp
(defun hello ()
"Say hi."
(interactive)
(message "Hello, world!"))
#+end_src
Then I have marked the Lisp inside and have press TAB, here is what I get:
#+begin_src emacs-lisp
(defun hello ()
"Say hi."
(interactive)
(message "Hello, world!"))
#+end_src
Then if I wish to comment out some line I mark it first, like on (interactive) and press M-;
#+begin_src emacs-lisp
(defun hello ()
"Say hi."
;; (interactive)
(message "Hello, world!"))
#+end_src
And if I call M-x comment-line with cursor after (interactive), cursor jumps up on the "S" in Say hi.
#+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:
But if I put cursor after () and do M-x comment-line, it jumps down to first quote of "Say".
#+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).
That I cannot replicate.
> 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.
Try this:
(defun my-comment-line ()
(interactive)
(let ((point (point)))
(comment-region (point-at-bol) (point-at-eol))))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/
next prev parent reply other threads:[~2021-04-09 14:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-04-10 20:31 ` excalamus--- via Users list for the GNU Emacs text editor
2021-04-10 21:34 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YHBkUshxZKkBhC8m@protected.localdomain \
--to=bugs@gnu.support \
--cc=excalamus@tutanota.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).