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

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

Re: Problem setting frame title on startup


From: Ian van der Neut
Subject: Re: Problem setting frame title on startup
Date: Sat, 16 Mar 2013 12:04:51 +0100




On Sat, Mar 16, 2013 at 11:24 AM, Mark Skilbeck <m@iammark.us> wrote:
On Sat, Mar 16, 2013 at 10:47:54AM +0100, Ian van der Neut wrote:
> On Fri, Mar 15, 2013 at 8:51 PM, Mark Skilbeck <m@iammark.us> wrote:
>
> > Use modify-frame-parameters:
> >
> >     (modify-frame-parameters nil '((title . "test")))
> >
> >
> Hi, thank you for your reply.
>
> After some searching and reading docs I changed the code to
>
> (defun set-project-in-frame-title ()
>   (interactive)
>   ;;(select-frame frame)
>   (setq projectname (getenv "project"))
>   (message "Project: %s" projectname)
>   (if projectname
>       (modify-frame-parameters nil (list (cons 'title (concat
> (buffer-name) " [" projectname "]"))))
>     (modify-frame-parameters frame (list (cons 'title (buffer-name))))
>     ) ;; if projectname
> )
>
> But it doesn't really make any difference. I figured out however, that I
> probably need a hook to be executed when a frame is opened:
>
> (add-hook 'after-make-frame-functions 'set-project-in-frame-title)
>
>
> But, this doesn't work exactly right either. I get the buffer-name of the
> previous buffer. E.g. when I start emacs:
>
> export projectname="myproject"
> emacs myfile
>
> The frame title has:
>
> *scratch* [myproject]

Hum. I suppose this is because when a frame is created, the hook
is run before the new buffer (i.e., myfile) is created, and therefore
(current-buffer) points to the default buffer (in your case, *scratch*).
I'm not sure how to remedy this as my Emacs hacking isn't much good.

One thought would be to hook into the buffer change event, and update the
title that way; but, of course, that will change the title whenever you
change buffers, which may or may not be desirable.


That would be desirable, the buffer name in the title should reflect the buffer in the frame.
 

>
> I get an error:
> Wrong number of arguments: (lambda (frame) (interactive) (select-frame
> frame) (setq projectname (getenv project)) (message Project: %s
> projectname) (if projectname (modify-frame-parameters frame (list (cons
> (quote title) (concat (buffer-name)  [ projectname ]))))
> (modify-frame-parameters frame (list (cons (quote title)
> (buffer-name)))))), 0


Argh... my bad. Somewhere in my ~/.emacs there was still a call to set-project-in-frame-title without any argument.


Also note that you have "project" rather than "projectname" in your
GETENV call; but that may just be a typo.

Yes, it was a typo in the email :)
 
Thank you so far. Not quite there yet though... :)

Ian.

reply via email to

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