Variable: lost-selection-mode

lost-selection-mode is a customizable variable defined in select.el.gz.

Value

nil

Documentation

Non-nil if Lost-Selection mode is enabled.

See the lost-selection-mode(var)/lost-selection-mode(fun) command for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node (emacs)Easy Customization) or call the function lost-selection-mode(var)/lost-selection-mode(fun).

Probably introduced at or before Emacs version 29.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/select.el.gz
(define-minor-mode lost-selection-mode
  "Toggle `lost-selection-mode'.

When this is enabled, selecting some text in another program will
cause the mark to be deactivated in all buffers, mimicking the
behavior of most X Windows programs.

Selecting text in a buffer that ends up changing the primary
selection will also cause the mark to be deactivated in all other
buffers."
  :global t
  :group 'x
  (if lost-selection-mode
      (progn
        (cond ((featurep 'x) (add-hook 'x-lost-selection-functions
                                       #'lost-selection-function))
              ((featurep 'pgtk) (add-hook 'pgtk-lost-selection-functions
                                          #'lost-selection-function))
              ((featurep 'haiku) (add-hook 'haiku-lost-selection-functions
                                           #'lost-selection-function)))
        (add-hook 'post-select-region-hook
                  #'lost-selection-post-select-region-function))
    (cond ((featurep 'x) (remove-hook 'x-lost-selection-functions
                                      #'lost-selection-function))
          ((featurep 'pgtk) (remove-hook 'pgtk-lost-selection-functions
                                         #'lost-selection-function))
          ((featurep 'haiku) (remove-hook 'haiku-lost-selection-functions
                                          #'lost-selection-function)))
    (remove-hook 'post-select-region-hook
                 #'lost-selection-post-select-region-function)
    (setq lost-selection-last-region-buffer nil)))