Subject: Re: bug#69097: [PATCH] Add 'kill-region-or-word' command

From: Robert Pluim <[email-masked]>
Date: Tue, 03 Sep 2024 16:55:29 +0200

>>>>> On Tue, 03 Sep 2024 17:27:59 +0300, Eli Zaretskii <[email-masked]> said:
    >> >> +  "Behaviour when `kill-region' is invoked without an active region.
    >> >> +If set to nil (default), then an error occurs and nothing is killed.  If
    >> >> +set to `emacs-word', then kill a the last word as defined by the current
    >> >> +major mode.  If set to `unix-word', then kill the last word in the style
    >> >> +of a shell like Bash, disregarding the major mode."
    >> >> +  :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word)
    >> >> +                 (const :tag "Kill a word like Bash would" unix-word)
    >> >> +                 (const :tag "Do not kill anything" nil))
    >> >> +  :group 'killing)
    >> 
    Eli> :version tag is missing.
    >> 
    >> Is it worth allowing a user-specified function?

    Eli> I don't understand what you are asking, sorry.  Allow a function where
    Eli> and to do what?

The current proposal offers three fixed behaviours. Iʼm wondering if
it makes sense for the user option to be allowed to be a user-defined
function, in case someone wants a different behaviour, ie

+(defcustom kill-word-if-no-region nil
+  "Behaviour when `kill-region' is invoked without an active region.
+If set to nil (default), then an error occurs and nothing is killed.  If
+set to `emacs-word', then kill a the last word as defined by the current
+major mode.  If set to `unix-word', then kill the last word in the style
+of a shell like Bash, disregarding the major mode.  If set to a
+function, call that function."
+  :type '(choice (const :tag "Kill a word like `backward-kill-word'" emacs-word)
+                 (const :tag "Kill a word like Bash would" unix-word)
+                 (const :tag "Do not kill anything" nil)
+                 (symbol :tag "User function")
+  :group 'killing)

Robert
--