Bug 498956

Summary: Klipper applet interferes with Emacs lost-selection-mode
Product: [Plasma] plasmashell Reporter: Jonathan Marten <jjm>
Component: Clipboard widget & pop-upAssignee: Plasma Bugs List <plasma-bugs-null>
Status: REOPENED ---    
Severity: normal CC: kde, qydwhotmail
Priority: NOR    
Version First Reported In: master   
Target Milestone: 1.0   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Jonathan Marten 2025-01-21 12:03:16 UTC
SUMMARY

GNU Emacs implements lost-selection-mode which, when enabled, causes the selection within Emacs to be cleared if another application makes a primary selection.  IMHO this is good behaviour which I would like other applications to also implement, but that is a personal preference and a separate issue.  The problem is that, when the Plasma clipboartd applet is active and this mode is enabled, every time a selection is made in Emacs (by any means) somehow it is immediately cleared.  Disabling the clipboard applet restores Emacs to normal.

STEPS TO REPRODUCE
1.  Enable the Klipper applet in Plasma, and start Emacs.
2.  Ensure that Emacs' transient-mark-mode is enabled (this enables marked region highlighting).
2.  Make a text selection in Emacs by any means: by dragging the mouse, Shift-arrow keys, or double or triple clicking.
3.  Observe that the selection in Emacs is highlighted as expected, and that it is added to Klipper's history.
4.  Enable lost-selection-mode in Emacs.
5.  Make a text selection again, and observe that as soon as the selection action is finished (e.g. the mouse button is released at the end of a drag), the highlighting disappears but the selected text is still added to Klipper's history.
6.  Without changing anything in Emacs, disable the Klipper applet.  Observe that selecting works and is highlighted as expected.

OBSERVED RESULT
In step 5 the selection highlighting in Emacs disappears.

EXPECTED RESULT
In step 5 the highlighting should remain.

ADDITIONAL INFORMATION
Klipper settings:  Save history across desktop sessions = on
Keep selection and clipboard the same = on
Text selection = Always save in history
Non-text selection = Never save in history

SOFTWARE/OS VERSIONS
Operating System: Gentoo 2.17
KDE Plasma Version: 6.3.80
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.1
Kernel Version: 6.6.47-gentoo-x86_64 (64-bit)
Graphics Platform: X11
Processors: 3 × AMD Phenom(tm) II X3 705e Processor
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GT 730
Comment 1 David Redondo 2025-01-21 12:56:08 UTC
What are your klipper settings?
Comment 2 Jonathan Marten 2025-01-21 13:22:40 UTC
Complete Klipper settings:

Save history across desktop sessions = on
Keep selection and clipboard the same = on
Text selection = Always save in history
Non-text selection = Never save in history

Show popup immediately on selection = off
Show popup for item chosen from history = off
Exclude windows = Klipper default
Trim whitespace from selection = on
Include MIME actions = off
Comment 3 Jonathan Marten 2025-01-21 17:29:26 UTC
Also in case it is relevant:

GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.33,
cairo version 1.18.2) of 2025-01-09
Comment 4 Jonathan Marten 2025-01-25 21:17:56 UTC
Git bisection identifies the problem commit as:

Current HEAD:          c4c47a5cde045a49e8b3b315f81d0bb9fc855aba
Current tag:           v6.1.90-413-gc4c47a5c
Last commit author:    Fushan Wen <qydwhotmail@gmail.com>
Last commit date:      Fri Aug 23 23:05:48 2024 +0800
Last commit title:     klipper: port database to SQLite
Comment 5 Fushan Wen 2025-04-11 04:57:44 UTC
Should be fixed in 6.3.4
Comment 6 Jonathan Marten 2025-05-29 16:59:18 UTC
Problem still seems to be present in

Operating System: Gentoo 2.17
KDE Plasma Version: 6.3.80
KDE Frameworks Version: 6.14.0
Qt Version: 6.8.3
Kernel Version: 6.6.47-gentoo-x86_64 (64-bit)
Graphics Platform: X11