+;; from https://unix.stackexchange.com/questions/26360/emacs-deleting-a-line-without-sending-it-to-the-kill-ring
+;; better than https://www.emacswiki.org/emacs/ElispCookbook#toc13
+(defun delete-line (&optional arg)
+ "Delete the rest of the current line; if no nonblanks there, delete thru newline.
+With prefix argument ARG, delete that many lines from point.
+Negative arguments delete lines backward.
+With zero argument, delete the text before point on the current line.
+
+When calling from a program, nil means \"no arg\",
+a number counts as a prefix arg.
+
+If `show-trailing-whitespace' is non-nil, this command will just
+delete the rest of the current line, even if there are no nonblanks
+there.
+
+If option `kill-whole-line' is non-nil, then this command deletes the whole line
+including its terminating newline, when used at the beginning of a line
+with no argument.
+
+If the buffer is read-only, Emacs will beep and refrain from deleting
+the line."
+ (interactive "P")
+ (delete-region
+ (point)
+ (progn
+ (if arg
+ (forward-visible-line (prefix-numeric-value arg))
+ (if (eobp)
+ (signal 'end-of-buffer nil))
+ (let ((end
+ (save-excursion
+ (end-of-visible-line) (point))))
+ (if (or (save-excursion
+ ;; If trailing whitespace is visible,
+ ;; don't treat it as nothing.
+ (unless show-trailing-whitespace
+ (skip-chars-forward " \t" end))
+ (= (point) end))
+ (and kill-whole-line (bolp)))
+ (forward-visible-line 1)
+ (goto-char end))))
+ (point))))
+