* [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)]
@ 2023-10-26 19:30 Jens Schmidt
2023-11-06 9:18 ` Ihor Radchenko
2024-09-30 12:41 ` Steven Lin
0 siblings, 2 replies; 4+ messages in thread
From: Jens Schmidt @ 2023-10-26 19:30 UTC (permalink / raw)
To: Org-mode
* Reproducer
Save the following files:
------------------------- /tmp/test.org -------------------------
#+begin_src bash
foo
bar
baz
#+end_src
------------------------- /tmp/test.org -------------------------
------------------------- /tmp/test.el -------------------------
(transient-mark-mode -1)
(setq org-support-shift-select t)
------------------------- /tmp/test.el -------------------------
Then start Emacs as
emacs -Q -l /tmp/test.el +2 /tmp/test.org
Select the three lines of the source block with `C-3 S-<down>', then
press `M-;'.
For me the resulting buffer looks like:
------------------------- /tmp/test.org -------------------------
#+begin_src bash
foo
bar
baz # (point)
#+end_src
------------------------- /tmp/test.org -------------------------
where I would have expected:
------------------------- /tmp/test.org -------------------------
#+begin_src bash
# foo
# bar
# baz(point)
#+end_src
------------------------- /tmp/test.org -------------------------
The latter result you get when Transient Mark mode is permanently on.
* My Educated Guess
In the following snippet from `org-comment-dwim'
(org-babel-do-in-edit-buffer (call-interactively #'comment-dwim)))
the buffer-local setting of `transient-mark-mode' (having value `(only)'
when a region is shift-selected) from buffer test.org does not get
transferred to the intermediate source buffer. However, function
`comment-dwim' relies on that to decide whether to operate on point or
on region:
comment-dwim is an interactive native-compiled Lisp function in
‘newcomment.el’.
Call the comment command you want (Do What I Mean).
If the region is active and ‘transient-mark-mode’ is on, call
‘comment-region’ (unless it only consists of comments, in which
case it calls ‘uncomment-region’); [...]
So probably somewhere in `org-babel-do-in-edit-buffer' the value of
`transient-mark-mode', if it is buffer-local and differs from the
default value, should be transferred to the intermediate source buffer.
Emacs : GNU Emacs 30.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
of 2023-10-26
Package: Org mode version 9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)]
2023-10-26 19:30 [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)] Jens Schmidt
@ 2023-11-06 9:18 ` Ihor Radchenko
2024-09-30 12:41 ` Steven Lin
1 sibling, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-11-06 9:18 UTC (permalink / raw)
To: Jens Schmidt; +Cc: Org-mode
Jens Schmidt <jschmidt4gnu@vodafonemail.de> writes:
> * Reproducer
> ...
> where I would have expected:
>
> ------------------------- /tmp/test.org -------------------------
> #+begin_src bash
> # foo
> # bar
> # baz(point)
> #+end_src
> ------------------------- /tmp/test.org -------------------------
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=101429634
Thanks for reporting!
--
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] 4+ messages in thread
* Re: [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)]
2023-10-26 19:30 [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)] Jens Schmidt
2023-11-06 9:18 ` Ihor Radchenko
@ 2024-09-30 12:41 ` Steven Lin
2024-10-12 8:57 ` Ihor Radchenko
1 sibling, 1 reply; 4+ messages in thread
From: Steven Lin @ 2024-09-30 12:41 UTC (permalink / raw)
To: jschmidt4gnu; +Cc: emacs-orgmode
I found that current bugfix (commit
1014296344a75fa08e0a8814e4fbbd767e7eba4c) brought new bugs.
Step to reproduce:
1. Set these variables.
(setq org-src-content-indentation 4)
(setq org-src-preserve-indentation nil)
2. Try to comment some lines in a source block. For example, line foo
and bar.
#+begin_src emacs-lisp
(setq foo 1)
(setq bar 2)
(setq buz 3)
#+end_src
Expected:
#+begin_src emacs-lisp
;; (setq foo 1)
;; (setq bar 2)
(setq buz 3)
#+end_src
Got:
#+begin_src emacs-lisp
;; (setq foo 1)
;; (setq bar 2)
;; (setq bu
z 3)
#+end_src
Then I found that there is a problem in function
`org-comment-or-uncomment-region` in lisp/org.el.
in func `org-comment-or-uncomment-region` :
#+begin_src emacs-lisp
(let ((offset (- end beg)))
(save-excursion
(goto-char beg)
(org-babel-do-in-edit-buffer
(comment-or-uncomment-region (point) (+ offset (point))))))
#+end_src
the value of `offset` is wrong, it became `Expected_Value +
Org_Src_Indent * Lines_To_Comment`, in the example which is 8 chars more
than expected.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)]
2024-09-30 12:41 ` Steven Lin
@ 2024-10-12 8:57 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-10-12 8:57 UTC (permalink / raw)
To: Steven Lin; +Cc: jschmidt4gnu, emacs-orgmode
Steven Lin <linjt267@outlook.com> writes:
> I found that current bugfix (commit
> 1014296344a75fa08e0a8814e4fbbd767e7eba4c) brought new bugs.
> ...
Duplicate of
https://orgmode.org/list/CAHqtn=fWq6E5_pm72AB9vFxwjS0a8ma=UvVjMrgeivE9pa13ZQ@mail.gmail.com
--
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] 4+ messages in thread
end of thread, other threads:[~2024-10-12 8:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26 19:30 [BUG] org-comment-dwim does not work with temporary Transient Mark mode [9.7-pre (release_9.6.10-902-g41ff56 @ /home/jschmidt/work/org-mode/lisp/)] Jens Schmidt
2023-11-06 9:18 ` Ihor Radchenko
2024-09-30 12:41 ` Steven Lin
2024-10-12 8:57 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.