emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
To: Org-mode <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <d8dc0cca-00d9-4349-a123-6ea6776b00cc@vodafonemail.de> (raw)


* 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	other threads:[~2023-10-26 19:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 19:30 Jens Schmidt [this message]
2023-11-06  9:18 ` [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/)] Ihor Radchenko

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8dc0cca-00d9-4349-a123-6ea6776b00cc@vodafonemail.de \
    --to=jschmidt4gnu@vodafonemail.de \
    --cc=emacs-orgmode@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.
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).