[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Overriding switch to *scratch* buffer after creating new frame with
From: |
martin rudalics |
Subject: |
Re: Overriding switch to *scratch* buffer after creating new frame with 'emacsclient -c' |
Date: |
Thu, 20 Dec 2012 14:52:31 +0100 |
>> add an appropriate customization type for `initial-buffer-choice'
> I don't think that it's will be useful for users to customise, but who
> knows...
`initial-buffer-choice' _is_ an option specified via `defcustom' in
startup.el. We cannot implicitly ignore this fact in `command-line-1'.
But we could, for example, allow a function here and you could specify a
function to provide the buffer of your choice here.
> Here the scenario:
> I want new frames to switch to some buffer so I added hook to
> `after-make-frame-functions'.
> Inside this hook I do `(switch-to-buffer <some-buffer>)' the window on this
> frame is switched to that <some-buffer> at first, but after a short time
> it's
> switched to *scratch*. So as I think it would be better that
> `after-make-frame-functions' will be called after this 'default switching to
> *scratch* behaviour' is performed.
I'm afraid that this would mean a quite intrusive change to the sequence
of operations performed by the startup code. Are there any reasons why
you can't use `emacs-startup-hook' or `term-setup-hook' instead?
> And than will be no need for me to
> add code to server.el.
> // New version:
> (unless (or files commands)
> (let ((type (type-of initial-buffer-choice))
> (buf "*scratch*"))
> (cond
> ((eq 'string type) (setq buf (find-file-noselect
> initial-buffer-choice)))
> ((eq 'buffer type) (when (buffer-live-p
> initial-buffer-choice)
> (setq buf initial-buffer-choice))))
> (switch-to-buffer (get-buffer-create buf) 'norecord)))
Looks good to me.
martin
- Re: Overriding switch to *scratch* buffer after creating new frame with 'emacsclient -c',
martin rudalics <=