help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding switch to *scratch* buffer after creating new frame with


From: Thien-Thi Nguyen
Subject: Re: Overriding switch to *scratch* buffer after creating new frame with 'emacsclient -c'
Date: Fri, 21 Dec 2012 14:10:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

() Stefan Monnier <monnier@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

-- 
Thien-Thi Nguyen ..................................... GPG key: 4C807502
.                  NB: ttn at glug dot org is not me                   .
.                 (and has not been since 2007 or so)                  .
.                        ACCEPT NO SUBSTITUTES                         .
........... please send technical questions to mailing lists ...........

Attachment: pgpzIPZzSRTxM.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]