From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian van der Neut Newsgroups: gmane.emacs.help Subject: Re: Problem setting frame title on startup Date: Sat, 16 Mar 2013 12:04:51 +0100 Message-ID: References: <20130315195145.GA18986@earth> <20130316102434.GA3320@earth> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d04016be1999ceb04d808b99d X-Trace: ger.gmane.org 1363431912 18976 80.91.229.3 (16 Mar 2013 11:05:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Mar 2013 11:05:12 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Mark Skilbeck Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 16 12:05:36 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UGove-00027Y-ED for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Mar 2013 12:05:34 +0100 Original-Received: from localhost ([::1]:44531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGovH-0001L8-7y for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Mar 2013 07:05:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGov3-0001Ks-NB for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 07:05:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGouz-0002gL-KM for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 07:04:57 -0400 Original-Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]:54010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGouz-0002g7-8m for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 07:04:53 -0400 Original-Received: by mail-la0-f41.google.com with SMTP id fo12so4634193lab.0 for ; Sat, 16 Mar 2013 04:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=V+TXXNmnm9RWB/EfCBVlaVwuaXdPTDFtOwvNtWFZuvg=; b=J/zfZplKN4gXZCZzw5L2G789j8u23pouc3henxCUJgUvj5bkaTfW/Jx0bWD3uRJAkw EeyrgvcG1QDzLU5Q5cyaf2+68EikuoSC8g0lUoKEhsR+IVzCDuQANGl0+xNgWL1un3V0 iLV5buPxu0rjK8DE1YRcYdKx86Ww7rXTaNsqO+ho7BgR5xd4XcQzMZYHNenQiytbE/d/ iMfrpV+qpd53jAFfNYWp7v8It2wFehHuRQTdFzciLoRttwtbpDqsvhGRcYQX86iaml2O JDyKrPbWh+gNK6EJJHN5v8jrjETZC7YRok0W9q0f2QwDKjdHuPnFyyPeIUiWK/mTz488 EzXA== X-Received: by 10.112.88.9 with SMTP id bc9mr3900515lbb.22.1363431892029; Sat, 16 Mar 2013 04:04:52 -0700 (PDT) Original-Received: by 10.112.42.226 with HTTP; Sat, 16 Mar 2013 04:04:51 -0700 (PDT) In-Reply-To: <20130316102434.GA3320@earth> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::229 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89553 Archived-At: --f46d04016be1999ceb04d808b99d Content-Type: text/plain; charset=ISO-8859-1 On Sat, Mar 16, 2013 at 11:24 AM, Mark Skilbeck 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 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. --f46d04016be1999ceb04d808b99d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Sat, Mar 16, 2013 at 11:24 AM, Mark Skilbeck &= lt;m@iammark.us> wrote:
On S= at, 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:
> >
> > =A0 =A0 (modify-frame-parameters nil '((title . "test&qu= ot;)))
> >
> >
> Hi, thank you for your reply.
>
> After some searching and reading docs I changed the code to
>
> (defun set-project-in-frame-title ()
> =A0 (interactive)
> =A0 ;;(select-frame frame)
> =A0 (setq projectname (getenv "project"))
> =A0 (message "Project: %s" projectname)
> =A0 (if projectname
> =A0 =A0 =A0 (modify-frame-parameters nil (list (cons 'title (conca= t
> (buffer-name) " [" projectname "]"))))
> =A0 =A0 (modify-frame-parameters frame (list (cons 'title (buffer-= name))))
> =A0 =A0 ) ;; 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-ti= tle)
>
>
> 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=3D"myproject"
> emacs myfile
>
> The frame title has:
>
> *scratch* [myproject]

Hum. I suppose this is because when a frame is created, the hoo= k
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 shoul= d reflect the buffer in the frame.
=A0

>
> 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 (con= s
> (quote title) (concat (buffer-name) =A0[ projectname ]))))
> (modify-frame-parameters frame (list (cons (quote title)
> (buffer-name)))))), 0


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

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

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

Ian.
--f46d04016be1999ceb04d808b99d--