diff options
| author | Mark Oteiza | 2017-04-08 11:34:17 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2017-04-08 11:36:56 -0400 |
| commit | c5f319eb3a2e0ad97867c8dc61bfc140333fb11d (patch) | |
| tree | 02ced46f490e0246ec9c2c8fa2b2fe72ee8edd23 | |
| parent | fd4b83ca7c20a68060772ec13aadbe29db612b3f (diff) | |
| download | emacs-c5f319eb3a2e0ad97867c8dc61bfc140333fb11d.tar.gz emacs-c5f319eb3a2e0ad97867c8dc61bfc140333fb11d.zip | |
Replace more nested ifs with cond
This is a continuation of d526047 "Replace more nested ifs with cond".
* lisp/play/dunnet.el (dun-firstword, dun-firstwordl, dun-cat): Use
when and cond where appropriate.
| -rw-r--r-- | lisp/play/dunnet.el | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el index 8f013bb09f2..6acdf36d72c 100644 --- a/lisp/play/dunnet.el +++ b/lisp/play/dunnet.el | |||
| @@ -2199,16 +2199,14 @@ for a moment, then straighten yourself up.\n") | |||
| 2199 | ;;; Get the first non-ignored word from a list. | 2199 | ;;; Get the first non-ignored word from a list. |
| 2200 | 2200 | ||
| 2201 | (defun dun-firstword (list) | 2201 | (defun dun-firstword (list) |
| 2202 | (if (not (car list)) | 2202 | (when (car list) |
| 2203 | nil | 2203 | (while (and list (memq (intern (car list)) dun-ignore)) |
| 2204 | (while (and list (member (intern (car list)) dun-ignore)) | ||
| 2205 | (setq list (cdr list))) | 2204 | (setq list (cdr list))) |
| 2206 | (car list))) | 2205 | (car list))) |
| 2207 | 2206 | ||
| 2208 | (defun dun-firstwordl (list) | 2207 | (defun dun-firstwordl (list) |
| 2209 | (if (not (car list)) | 2208 | (when (car list) |
| 2210 | nil | 2209 | (while (and list (memq (intern (car list)) dun-ignore)) |
| 2211 | (while (and list (member (intern (car list)) dun-ignore)) | ||
| 2212 | (setq list (cdr list))) | 2210 | (setq list (cdr list))) |
| 2213 | list)) | 2211 | list)) |
| 2214 | 2212 | ||
| @@ -2820,28 +2818,25 @@ drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..") | |||
| 2820 | (setq dun-badcd t)) | 2818 | (setq dun-badcd t)) |
| 2821 | 2819 | ||
| 2822 | (defun dun-cat (args) | 2820 | (defun dun-cat (args) |
| 2823 | (let (doto checklist) | 2821 | (cond |
| 2824 | (if (not (setq args (car args))) | 2822 | ((null (setq args (car args))) |
| 2825 | (dun-mprincl "Usage: cat <ascii-file-name>") | 2823 | (dun-mprincl "Usage: cat <ascii-file-name>")) |
| 2826 | (if (string-match "/" args) | 2824 | ((string-match-p "/" args) |
| 2827 | (dun-mprincl "cat: only files in current directory allowed.") | 2825 | (dun-mprincl "cat: only files in current directory allowed.")) |
| 2828 | (if (and (> dun-cdroom 0) (string= args "description")) | 2826 | ((and (> dun-cdroom 0) (string= args "description")) |
| 2829 | (dun-mprincl (car (nth dun-cdroom dun-rooms))) | 2827 | (dun-mprincl (car (nth dun-cdroom dun-rooms)))) |
| 2830 | (if (setq doto (string-match "\\.o" args)) | 2828 | ((string-match "\\.o" args) |
| 2831 | (progn | 2829 | (let ((doto (match-beginning 0)) checklist) |
| 2832 | (if (= dun-cdroom -10) | 2830 | (if (= dun-cdroom -10) |
| 2833 | (setq checklist dun-inventory) | 2831 | (setq checklist dun-inventory) |
| 2834 | (setq checklist (nth dun-cdroom dun-room-objects))) | 2832 | (setq checklist (nth dun-cdroom dun-room-objects))) |
| 2835 | (if (not (member (cdr | 2833 | (if (member (cdr (assq (intern (substring args 0 doto)) dun-objnames)) |
| 2836 | (assq (intern | 2834 | checklist) |
| 2837 | (substring args 0 doto)) | 2835 | (dun-mprincl "Ascii files only.") |
| 2838 | dun-objnames)) | 2836 | (dun-mprincl "File not found.")))) |
| 2839 | checklist)) | 2837 | ((assq (intern args) dun-unix-verbs) |
| 2840 | (dun-mprincl "File not found.") | 2838 | (dun-mprincl "Ascii files only.")) |
| 2841 | (dun-mprincl "Ascii files only."))) | 2839 | (t (dun-mprincl "File not found.")))) |
| 2842 | (if (assq (intern args) dun-unix-verbs) | ||
| 2843 | (dun-mprincl "Ascii files only.") | ||
| 2844 | (dun-mprincl "File not found.")))))))) | ||
| 2845 | 2840 | ||
| 2846 | (defun dun-rlogin-endgame () | 2841 | (defun dun-rlogin-endgame () |
| 2847 | (if (not (= (dun-score nil) 90)) | 2842 | (if (not (= (dun-score nil) 90)) |