() Stefan Monnier <
mon...@iro.umontreal.ca>
() Thu, 20 Dec 2012 12:06:54 -0500
You mean like
(unless (or files commands)
(let ((buf
(cond
((stringp initial-buffer-choice)
(find-file-noselect initial-buffer-choice))
((buffer-live-p initial-buffer-choice) initial-buffer-choice)
(t "*scratch*"))))
(switch-to-buffer (get-buffer-create buf) 'norecord)))
Almost. To rid ourselves of the last local var:
(unless (or files commands)
(switch-to-buffer
(get-buffer-create
(cond ((stringp initial-buffer-choice)
(find-file-noselect initial-buffer-choice))
((buffer-live-p initial-buffer-choice)
initial-buffer-choice)
(t "*scratch*")))
'norecord))
or (hewing closer to OP approach):
(unless (or files commands)
(switch-to-buffer
(get-buffer-create
(or (case (type-of initial-buffer-choice)
(string (find-file-noselect initial-buffer-choice))
(buffer (when (buffer-live-p initial-buffer-choice)
initial-buffer-choice)))
"*scratch*"))
'norecord))
Same difference; more stack, less state... Since we're talking style,
i'd say the most important thing is sane indentation, but luckily we
have Emacs for that. :-D