all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Overriding switch to *scratch* buffer after creating new frame with 'emacsclient -c'
Date: Fri, 21 Dec 2012 14:10:31 +0100	[thread overview]
Message-ID: <87y5grmtyw.fsf@zigzag.favinet> (raw)
In-Reply-To: <jwvr4mkr76w.fsf-monnier+gmane.emacs.help@gnu.org> (Stefan Monnier's message of "Thu, 20 Dec 2012 12:06:54 -0500")

[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]

() 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 #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2012-12-21 13:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAFkz2yroLhknptDnWyC9B1fbZKEwTCV-T0VttHQiwZoaAW-j6A@mail.gmail.com>
2012-12-20  8:36 ` Константин Куликов
2012-12-20 11:05   ` Overriding switch to *scratch* buffer after creating new frame with 'emacsclient -c' martin rudalics
2012-12-20 12:13     ` Константин Куликов
     [not found]     ` <CAFkz2ypcP-fmRH7jJWdhYRaRVB-VEtn0=5qWYQ_S+QCTmZ=TRQ@mail.gmail.com>
2012-12-20 13:52       ` martin rudalics
2012-12-20 14:46         ` Thien-Thi Nguyen
2012-12-20 17:06           ` Stefan Monnier
2012-12-21 13:10             ` Thien-Thi Nguyen [this message]
2012-12-21 15:43               ` Constantin Kulikov
2012-12-22 17:46               ` Stefan Monnier
2012-12-20  9:59 martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2012-12-19 13:14 Константин Куликов
2012-12-20  0:43 ` Константин Куликов

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y5grmtyw.fsf@zigzag.favinet \
    --to=ttn@gnuvola.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.