Subject: bug#73782: [PATCH] Add `delete-selection-local-mode'.

From: Stefan Monnier <[email-masked]>
Date: Thu, 24 Oct 2024 10:01:36 -0400

> Do you think that disabling the local mode should remove the
> buffer-local version of `delete-selection-mode` via
> `kill-local-variable`? It seems that once the variable is made buffer
> local, the global mode can't take effect in the buffer, even when the
> local mode is disabled.

In `electric-indent-local-mode` I faced the same question and wasn't
completely sure but I opted somewhat arbitrarily to do the
`kill-local-variable` whenever applicable.
I still don't know if it's the better choice, but FWIW, nobody's
complained about it:

      (cond
       ((eq electric-indent-mode (default-value 'electric-indent-mode))
        (kill-local-variable 'electric-indent-mode))

> * lisp/delsel.el (delete-selection-pre-hook): Check whether local mode
> is active.

AFAICT you don't change `delete-selection-pre-hook` any more.

> * doc/emacs/mark.texi (Using Region): Describe
> delete-selection-local-mode.
> +;;;###autoload
> +(define-minor-mode delete-selection-local-mode
> +  "Toggle Delete Selection mode in the current buffer.
> +
> +See the command `delete-selection-mode'.

FWIW, for `electric-indent-local-mode` I went for something shorter:

   "Toggle `electric-indent-mode' only in this buffer."

- Stefan