Use when where else case returns nil

* lisp/net/dictionary-connection.el (dictionary-connection-status,
dictionary-connection-close): Instead of returning nil in the else case
of the if just use when.

Was suggested by Stefan Kangas.
This commit is contained in:
Torsten Hilbrich 2020-12-14 09:48:26 +01:00
parent d30618cbc1
commit a25a12ddaf

View file

@ -85,31 +85,29 @@ nil: argument is no connection object
'up: connection is open and buffer is existing 'up: connection is open and buffer is existing
'down: connection is closed 'down: connection is closed
'alone: connection is not associated with a buffer" 'alone: connection is not associated with a buffer"
(if (dictionary-connection-p connection) (when (dictionary-connection-p connection)
(let ((process (dictionary-connection-process connection)) (let ((process (dictionary-connection-process connection))
(buffer (dictionary-connection-buffer connection))) (buffer (dictionary-connection-buffer connection)))
(if (not process) (if (not process)
'none 'none
(if (not (buffer-live-p buffer)) (if (not (buffer-live-p buffer))
'alone 'alone
(if (not (eq (process-status process) 'open)) (if (not (eq (process-status process) 'open))
'down 'down
'up)))) 'up))))))
nil))
(defun dictionary-connection-close (connection) (defun dictionary-connection-close (connection)
"Force closing of the connection." "Force closing of the connection."
(if (dictionary-connection-p connection) (when (dictionary-connection-p connection)
(progn (let ((buffer (dictionary-connection-buffer connection))
(let ((buffer (dictionary-connection-buffer connection)) (process (dictionary-connection-process connection)))
(process (dictionary-connection-process connection))) (if process
(if process (delete-process process))
(delete-process process)) (if buffer
(if buffer (kill-buffer buffer))
(kill-buffer buffer))
(dictionary-connection-set-process connection nil) (dictionary-connection-set-process connection nil)
(dictionary-connection-set-buffer connection nil))))) (dictionary-connection-set-buffer connection nil))))
(defun dictionary-connection-send (connection data) (defun dictionary-connection-send (connection data)
"Send `data' to the process." "Send `data' to the process."