GNU bug report logs - #56530
29.0.50; mouse-2 cut selected text when cua-mode is enabled

Previous Next

Package: emacs;

Reported by: David Ponce <da_vid <at> orange.fr>

Date: Wed, 13 Jul 2022 09:23:02 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #73 received at 56530 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: David Ponce <da_vid <at> orange.fr>, 56530 <at> debbugs.gnu.org,
 Visuwesh <visuweshm <at> gmail.com>
Subject: Re: bug#56530: 29.0.50; mouse-2 cut selected text when cua-mode is
 enabled
Date: Sun, 24 Jul 2022 19:52:19 +0300
>> All affected mouse commands mouse-yank-from-menu, mouse-yank-at-click,
>> mouse-yank-primary, mouse-yank-secondary have the same line:
>>
>>   (or mouse-yank-at-point (mouse-set-point event))
>>
>> So when the region is deleted by delete-selection-pre-hook
>> `mouse-set-point' tries to set point using outdated information
>> of the event's position in the deleted region.
>>
>> Maybe delete-selection-pre-hook could directly modify the event?
>> Everything works fine with this:
>>
>>             ((eq type 'yank-on-region)
>>              (let ((pos (posn-point (event-end last-nonmenu-event))))
>>                (when (and (>= pos (region-beginning))
>>                           (<= pos (region-end)))
>>                  (delete-selection-helper 'yank)
>>                  (setf (nth 5 (nth 1 last-nonmenu-event)) (region-beginning)))))
>>
>> But is this a good idea?
>
> It sounds kinda gross.  Would it be possible to rewrite these commands
> to that point is set before the deletion is done, or is that unfeasible?

delete-selection-mode deletes the region in pre-command-hook
before running the command.

Maybe then these commands could have special handling of delete-selection-mode?
They already contain special handling of select-active-regions:

  ;; Without this, confusing things happen upon e.g. inserting into
  ;; the middle of an active region.
  (when select-active-regions
    (let (select-active-regions)
      (deactivate-mark)))




This bug report was last modified 2 years and 356 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.