kill-whole-line: Honor visibility; fix kill-ring when read-only (bug#65734)
* lisp/simple.el (kill-whole-line): Use visibility state before
performing any edits as reference instead of expecting that visibility
cannot change. First of the two calls to `kill-region' may trigger
`after-change-functions' that might alter the visibility state.
Make sure that we populate the `kill-ring' with the contents of the
whole line when buffer is in `read-only-mode'.
(cherry picked from commit
058bb4ca25adb8f4bf78cc0f09a65d730dbd797d)