purcell / whole-line-or-region

In Emacs, operate on current line if no region is active
114 stars 12 forks source link

rest-of-the-line-or-region #20

Closed drzraf closed 3 years ago

drzraf commented 3 years ago

Killing the rest of the line (if nothing is selected) or the region otherwise is the behavior I would like to have (using C-k). Do you think I should consider trying to use this package for such a purpose or do you know of a better way?

purcell commented 3 years ago

It sounds like in neither of those cases would you want the command to act on the whole line, so I'd say you should just roll that command yourself. Something like this (completely untested):

(defun my-kill-line ()
   (interactive)
   (if (use-region-p)
       (kill-region (region-beginning) (region-end))
     (kill-line)))