* [BUG] Incorrect application of 'comment-region' in code blocks
@ 2024-07-13 7:32 the_wurfkreuz
2024-07-13 13:29 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: the_wurfkreuz @ 2024-07-13 7:32 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 3942 bytes --]
Reproduction:
1. emacs -Q
2. Enable org-mode in the scratch buffer (M-x org-mode)
3. Paste this code:
#+begin_src emacs-lisp
(with-eval-after-load 'evil
(define-key evil-insert-state-map (kbd "C-S-v") 'yank)
(define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
(define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
(define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
(define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
(define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
(define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
(define-key evil-normal-state-map (kbd "gq") 'FormatToThreshold)
(define-key evil-visual-state-map (kbd "gq") 'FormatToThreshold))
(defun my-move-beginning-of-line ()
"Move point to the first non-whitespace character of the line and enter insert mode."
(interactive)
(evil-first-non-blank)
(evil-insert-state))
#+end_src
(with-eval-after-load 'evil
(define-key evil-insert-state-map (kbd "C-S-v") 'yank)
(define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
(define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
(define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
(define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
(define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
(define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
(define-key evil-normal-state-map (kbd "gq") 'FormatToThreshold)
(define-key evil-visual-state-map (kbd "gq") 'FormatToThreshold))
(defun my-move-beginning-of-line ()
"Move point to the first non-whitespace character of the line and enter insert mode."
(interactive)
(evil-first-non-blank)
(evil-insert-state))
4. Highlight the first code paragrapth in the org code block:
(with-eval-after-load 'evil
(define-key evil-insert-state-map (kbd "C-S-v") 'yank)
(define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
(define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
(define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
(define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
(define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
(define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
5. Execute 'comment-region'. It will apply partial commenting on the
next line like this:
;; (with-eval-after-load 'evil
;; (define-key evil-insert-state-map (kbd "C-S-v") 'yank)
;; (define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
;; (define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
;; (define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
;; (define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
;; (define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
;; (define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
;; (define-key e
vil-normal-state-map (kbd "gq") 'FormatToThreshold)
6. Now apply highlighting and comment the same code, but outside of the
org code block, and the end result will be correct:
# (with-eval-after-load 'evil
# (define-key evil-insert-state-map (kbd "C-S-v") 'yank)
# (define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
# (define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
# (define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
# (define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
# (define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
# (define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
Emacs : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0)
of 2024-04-23
Package: Org mode version 9.8-pre (release_9.7.6-101-g4f6aab @ /home/wurfkreuz/.emacs.d/straight/build/org/)
[-- Attachment #1.2: Type: text/html, Size: 6773 bytes --]
[-- Attachment #2: emacs1.png --]
[-- Type: image/png, Size: 48674 bytes --]
[-- Attachment #3: emacs2.png --]
[-- Type: image/png, Size: 46624 bytes --]
[-- Attachment #4: emacs3.png --]
[-- Type: image/png, Size: 102469 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] Incorrect application of 'comment-region' in code blocks
2024-07-13 7:32 [BUG] Incorrect application of 'comment-region' in code blocks the_wurfkreuz
@ 2024-07-13 13:29 ` Ihor Radchenko
[not found] ` <HCkTNlq00DJCqKYbN1PPA5smHPuiAmGGuHdg_PffhnW1JiIddRvs976pxnd2Sp2cVBE__yeAKlhzUTGuIUU-jubuN7Yb-rf54EAxPuouJ78=@proton.me>
0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2024-07-13 13:29 UTC (permalink / raw)
To: the_wurfkreuz; +Cc: emacs-orgmode@gnu.org
the_wurfkreuz <the_wurfkreuz@proton.me> writes:
> Reproduction:
>
> 1. emacs -Q
> 2. Enable org-mode in the scratch buffer (M-x org-mode)
> 3. Paste this code:
> ...
> ...
> 4. Highlight the first code paragrapth in the org code block:
> ...
> 5. Execute 'comment-region'. It will apply partial commenting on the
> next line like this:
I am unable to reproduce.
May you try your recipe using "make repro" as described in
https://orgmode.org/manual/Feedback.html#Feedback
If you do it in freshly cloned Org code directory, it will use the
latest Org version I used on my side.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BUG] Incorrect application of 'comment-region' in code blocks
[not found] ` <HCkTNlq00DJCqKYbN1PPA5smHPuiAmGGuHdg_PffhnW1JiIddRvs976pxnd2Sp2cVBE__yeAKlhzUTGuIUU-jubuN7Yb-rf54EAxPuouJ78=@proton.me>
@ 2024-07-13 16:15 ` Ihor Radchenko
0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2024-07-13 16:15 UTC (permalink / raw)
To: the_wurfkreuz; +Cc: emacs-orgmode
the_wurfkreuz <the_wurfkreuz@proton.me> writes:
> I don't really know for sure what exactly i should do.
> I cloned the repo 'git clone https://git.savannah.gnu.org/git/emacs/org-mode.git'.
> Created minimal config ~/minimal_config.el:
>
> (require 'org)
> (setq initial-major-mode 'org-mode)
>
> Created the repro file /tmp/bug.org.
> Then from the cloned directory i did this:
>
> make repro REPRO_ARGS="-l ~/minimal_config.el /tmp/bug.org"
>
> Then i made the action that produces the bug and i got it.
Confirmed.
It was important that src block code should be indented.
The culprit is that `org-comment-or-uncomment-region' assumes that the
region size will remain unchanged when in Org src buffer. It is not true
when the code in Org mode is indented.
> #+begin_src emacs-lisp
>
> ;; (with-eval-after-load 'evil
> ;; (define-key evil-insert-state-map (kbd "C-S-v") 'yank)
> ;; (define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
> ;; (define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
> ;; (define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
> ;; (define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
> ;; (define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
> ;; (define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
>
> ;; (define-key e
> vil-normal-state-map (kbd "gq") 'FormatToThreshold)
> (define-key evil-visual-state-map (kbd "gq") 'FormatToThreshold))
>
> (defun my-move-beginning-of-line ()
> "Move point to the first non-whitespace character of the line and enter insert mode."
> (interactive)
> (evil-first-non-blank)
> (evil-insert-state))
>
> #+end_src
>
> (with-eval-after-load 'evil
> (define-key evil-insert-state-map (kbd "C-S-v") 'yank)
> (define-key evil-visual-state-map (kbd "{") 'evil-backward-paragraph)
> (define-key evil-visual-state-map (kbd "}") 'evil-forward-paragraph)
> (define-key evil-insert-state-map (kbd "M-w") 'evil-forward-word-begin)
> (define-key evil-insert-state-map (kbd "M-b") 'evil-backward-word-begin)
> (define-key evil-insert-state-map (kbd "M-W") 'evil-forward-WORD-begin)
> (define-key evil-insert-state-map (kbd "M-B") 'evil-backward-WORD-begin)
>
> (define-key evil-normal-state-map (kbd "gq") 'FormatToThreshold)
> (define-key evil-visual-state-map (kbd "gq") 'FormatToThreshold))
>
> (defun my-move-beginning-of-line ()
> "Move point to the first non-whitespace character of the line and enter insert mode."
> (interactive)
> (evil-first-non-blank)
> (evil-insert-state))
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-13 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-13 7:32 [BUG] Incorrect application of 'comment-region' in code blocks the_wurfkreuz
2024-07-13 13:29 ` Ihor Radchenko
[not found] ` <HCkTNlq00DJCqKYbN1PPA5smHPuiAmGGuHdg_PffhnW1JiIddRvs976pxnd2Sp2cVBE__yeAKlhzUTGuIUU-jubuN7Yb-rf54EAxPuouJ78=@proton.me>
2024-07-13 16:15 ` Ihor Radchenko
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).