Emacs: Deleting a line without sending it to the kill ring

(defun delete-line (&optional arg)
  (interactive "P")
  (flet ((kill-region (begin end)
                      (delete-region begin end)))
    (kill-line arg)))

Maybe this is not the best solution, but it seems works. You may need to bind `delete-line' to some global key, such as

(global-set-key [(control shift ?k)] 'delete-line)

cinsk answer did not work for me on emacs 24.

But this did:

;; Ctrl-K with no kill
(defun delete-line-no-kill ()
  (interactive)
  (delete-region
   (point)
   (save-excursion (move-end-of-line 1) (point)))
  (delete-char 1)
)
(global-set-key (kbd "C-k") 'delete-line-no-kill)

Tags:

Emacs