emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [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
  0 siblings, 1 reply; 2+ 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] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2023-11-06  9:18 UTC | newest]

Thread overview: 2+ 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

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).