emacs-orgmode
[Top][All Lists]
Advanced

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

[BUG] org-comment-dwim does not work with temporary Transient Mark mode


From: Jens Schmidt
Subject: [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/)]
Date: Thu, 26 Oct 2023 21:30:36 +0200
User-agent: Mozilla Thunderbird

* 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/)



reply via email to

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