all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to start shell and rename the buffer
@ 2009-01-15 12:43 Decebal
  2009-01-15 12:48 ` Decebal
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Decebal @ 2009-01-15 12:43 UTC (permalink / raw)
  To: help-gnu-emacs

I sometimes want to start emacs with a shell, but I also want to
rename the default name '*shell*'.
I have:
    emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'

But the buffername is not renamed.
In *Messages* I see:
    (emacs --eval (shell) (rename-buffer "shell"))

And not an error or a warning.
If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
renamed.

What am I doing wrong?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 12:43 How to start shell and rename the buffer Decebal
@ 2009-01-15 12:48 ` Decebal
  2009-01-15 13:49 ` Decebal
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Decebal @ 2009-01-15 12:48 UTC (permalink / raw)
  To: help-gnu-emacs

On 15 jan, 13:43, Decebal <CLDWester...@gmail.com> wrote:
> I sometimes want to start emacs with a shell, but I also want to
> rename the default name '*shell*'.
> I have:
>     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>
> But the buffername is not renamed.
> In *Messages* I see:
>     (emacs --eval (shell) (rename-buffer "shell"))
>
> And not an error or a warning.
> If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
> renamed.
>
> What am I doing wrong?

I am using version 21.3 off Emacs, I can not change that.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 12:43 How to start shell and rename the buffer Decebal
  2009-01-15 12:48 ` Decebal
@ 2009-01-15 13:49 ` Decebal
  2009-01-16  4:52   ` Kevin Rodgers
  2009-01-15 14:23 ` tyler
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Decebal @ 2009-01-15 13:49 UTC (permalink / raw)
  To: help-gnu-emacs

On 15 jan, 13:43, Decebal <CLDWester...@gmail.com> wrote:
> I sometimes want to start emacs with a shell, but I also want to
> rename the default name '*shell*'.
> I have:
>     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>
> But the buffername is not renamed.
> In *Messages* I see:
>     (emacs --eval (shell) (rename-buffer "shell"))
>
> And not an error or a warning.
> If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
> renamed.
>
> What am I doing wrong?

I found a way:
     emacs -title ${TITLE} --eval '(shell "shell")'

The only problem with this is that both the '*scratch*' and the
'shell' buffer are displayed. Not a big problem, but is it possible to
have only the 'shell' buffer displayed?

I found a way around my problem, but I am still interested why the
first way does not work. ;-}


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 12:43 How to start shell and rename the buffer Decebal
  2009-01-15 12:48 ` Decebal
  2009-01-15 13:49 ` Decebal
@ 2009-01-15 14:23 ` tyler
       [not found] ` <mailman.4931.1232029408.26697.help-gnu-emacs@gnu.org>
  2009-01-15 15:34 ` Pascal J. Bourguignon
  4 siblings, 0 replies; 10+ messages in thread
From: tyler @ 2009-01-15 14:23 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal <CLDWesterhof@gmail.com> writes:

> I sometimes want to start emacs with a shell, but I also want to
> rename the default name '*shell*'.
> I have:
>     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>
> But the buffername is not renamed.
> In *Messages* I see:
>     (emacs --eval (shell) (rename-buffer "shell"))
>
> And not an error or a warning.
> If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
> renamed.
>
> What am I doing wrong?
>

This works for me:

emacs -title mytitle --eval '(progn (shell) (rename-buffer "myshell"))'

I guess the --eval flag runs only the first complete command, requiring
the (progn ...) to do both. Just guessing, though.

Tyler

-- 
Tired of spyware? Try Firefox:

www.firefox.com





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
       [not found] ` <mailman.4931.1232029408.26697.help-gnu-emacs@gnu.org>
@ 2009-01-15 14:37   ` Decebal
  2009-01-15 14:40   ` Teemu Likonen
  1 sibling, 0 replies; 10+ messages in thread
From: Decebal @ 2009-01-15 14:37 UTC (permalink / raw)
  To: help-gnu-emacs

On 15 jan, 15:23, tyler <tyler.sm...@mail.mcgill.ca> wrote:
> > I sometimes want to start emacs with a shell, but I also want to
> > rename the default name '*shell*'.
> > I have:
> >     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>
> > But the buffername is not renamed.
> > In *Messages* I see:
> >     (emacs --eval (shell) (rename-buffer "shell"))
>
> > And not an error or a warning.
> > If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
> > renamed.
>
> > What am I doing wrong?
>
> This works for me:
>
> emacs -title mytitle --eval '(progn (shell) (rename-buffer "myshell"))'

Works for me also. Thanks.


> I guess the --eval flag runs only the first complete command, requiring
> the (progn ...) to do both. Just guessing, though.

Souns logical. When I want to do more as one command, I'll use progn.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
       [not found] ` <mailman.4931.1232029408.26697.help-gnu-emacs@gnu.org>
  2009-01-15 14:37   ` Decebal
@ 2009-01-15 14:40   ` Teemu Likonen
  1 sibling, 0 replies; 10+ messages in thread
From: Teemu Likonen @ 2009-01-15 14:40 UTC (permalink / raw)
  To: tyler; +Cc: help-gnu-emacs

tyler (2009-01-15 10:23 -0400) wrote:

> This works for me:
>
> emacs -title mytitle --eval '(progn (shell) (rename-buffer "myshell"))'
>
> I guess the --eval flag runs only the first complete command,
> requiring the (progn ...) to do both. Just guessing, though.

That is true. An example:

    $ emacs --batch -Q --eval '(message "one") (message "two")'
    one

So either wrap the commands inside a form which allows separate commands
(progn, let, ...) or use separate --eval options:

    $ emacs --batch -Q --eval '(progn (message "one") (message "two"))'
    one
    two

    $ emacs --batch -Q --eval '(message "one")' --eval '(message "two")'
    one
    two




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 12:43 How to start shell and rename the buffer Decebal
                   ` (3 preceding siblings ...)
       [not found] ` <mailman.4931.1232029408.26697.help-gnu-emacs@gnu.org>
@ 2009-01-15 15:34 ` Pascal J. Bourguignon
  2009-01-15 16:51   ` Michael Albinus
  2009-01-16 10:58   ` Decebal
  4 siblings, 2 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2009-01-15 15:34 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal <CLDWesterhof@gmail.com> writes:

> I sometimes want to start emacs with a shell, but I also want to
> rename the default name '*shell*'.

http://darcs.informatimago.com/emacs/pjb-shell.el



> I have:
>     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>
> But the buffername is not renamed.
> In *Messages* I see:
>     (emacs --eval (shell) (rename-buffer "shell"))
>
> And not an error or a warning.
> If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
> renamed.
>
> What am I doing wrong?

You're assuming that --eval will loop.  If that had been the case, it
would have been called --eval-loop.  Instead it is called --eval, and
therefore it only does that.

When you want to group several expressionsions in a sequence, you must
use prog1, prog2 or in general, progn:

   emacs  --eval '(progn (shell) (rename-buffer "shell"))'

But since  you don't pass -q, emacs will read your ~/.emacs, so you
can as well put there a function such as:

(defun shell-and-rename (name)
   (interactive "sName: ")
   (shell)
   (rename-buffer name))

and then:

   emacs --eval '(shell-and-rename "shell")'



-- 
__Pascal Bourguignon__


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 15:34 ` Pascal J. Bourguignon
@ 2009-01-15 16:51   ` Michael Albinus
  2009-01-16 10:58   ` Decebal
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Albinus @ 2009-01-15 16:51 UTC (permalink / raw)
  To: help-gnu-emacs

pjb@informatimago.com (Pascal J. Bourguignon) writes:

>    emacs  --eval '(progn (shell) (rename-buffer "shell"))'

What's about

    emacs  --eval '(shell "shell")'

Best regards, Michael.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 13:49 ` Decebal
@ 2009-01-16  4:52   ` Kevin Rodgers
  0 siblings, 0 replies; 10+ messages in thread
From: Kevin Rodgers @ 2009-01-16  4:52 UTC (permalink / raw)
  To: help-gnu-emacs

Decebal wrote:
> On 15 jan, 13:43, Decebal <CLDWester...@gmail.com> wrote:
>> I sometimes want to start emacs with a shell, but I also want to
>> rename the default name '*shell*'.
>> I have:
>>     emacs -title ${TITLE} --eval '(shell) (rename-buffer "shell")'
>>
>> But the buffername is not renamed.
>> In *Messages* I see:
>>     (emacs --eval (shell) (rename-buffer "shell"))
>>
>> And not an error or a warning.
>> If I do 'M-:' and then '(rename-buffer "shell")' the buffer is
>> renamed.
>>
>> What am I doing wrong?
> 
> I found a way:
>      emacs -title ${TITLE} --eval '(shell "shell")'
> 
> The only problem with this is that both the '*scratch*' and the
> 'shell' buffer are displayed. Not a big problem, but is it possible to
> have only the 'shell' buffer displayed?

Because shell calls pop-to-buffer, whose doc string says:

Select buffer buffer in some window, preferably a different one.
...
If `pop-up-windows' is non-nil, windows can be split to do this.

Try:

emacs -title ${TITLE} --eval '(let ((pop-up-windows nil)) (shell "shell"))'

> I found a way around my problem, but I am still interested why the
> first way does not work. ;-}

The --eval command line option calls the eval function, which takes
exactly 1 argument (a lisp form).

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to start shell and rename the buffer
  2009-01-15 15:34 ` Pascal J. Bourguignon
  2009-01-15 16:51   ` Michael Albinus
@ 2009-01-16 10:58   ` Decebal
  1 sibling, 0 replies; 10+ messages in thread
From: Decebal @ 2009-01-16 10:58 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 15, 4:34 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> You're assuming that --eval will loop.  If that had been the case, it
> would have been called --eval-loop.  Instead it is called --eval, and
> therefore it only does that.
>
> When you want to group several expressionsions in a sequence, you must
> use prog1, prog2 or in general, progn:
>
>    emacs  --eval '(progn (shell) (rename-buffer "shell"))'

I allready did this.


> But since  you don't pass -q, emacs will read your ~/.emacs, so you
> can as well put there a function such as:
>
> (defun shell-and-rename (name)
>    (interactive "sName: ")
>    (shell)
>    (rename-buffer name))
>
> and then:
>
>    emacs --eval '(shell-and-rename "shell")'

In principal a good idea, but it is done in a script. At the moment I
am the only one using the script, but you never know, so I like to
keep the dependicies as low as possible.

I am also thinking about:
    emacs  --eval '(shell)' --eval '(rename-buffer "shell")'
or
    emacs  --eval '(shell)'\
           --eval '(rename-buffer "shell")'

I think that is more clear.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-01-16 10:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 12:43 How to start shell and rename the buffer Decebal
2009-01-15 12:48 ` Decebal
2009-01-15 13:49 ` Decebal
2009-01-16  4:52   ` Kevin Rodgers
2009-01-15 14:23 ` tyler
     [not found] ` <mailman.4931.1232029408.26697.help-gnu-emacs@gnu.org>
2009-01-15 14:37   ` Decebal
2009-01-15 14:40   ` Teemu Likonen
2009-01-15 15:34 ` Pascal J. Bourguignon
2009-01-15 16:51   ` Michael Albinus
2009-01-16 10:58   ` Decebal

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.