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 10:47:54 +0100 Message-ID: References: <20130315195145.GA18986@earth> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f22c5555ac9c404d807a6d9 X-Trace: ger.gmane.org 1363427304 15632 80.91.229.3 (16 Mar 2013 09:48:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Mar 2013 09:48:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 16 10:48:50 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 1UGnjL-0005ob-7m for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Mar 2013 10:48:47 +0100 Original-Received: from localhost ([::1]:35342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGniy-0004uP-K2 for geh-help-gnu-emacs@m.gmane.org; Sat, 16 Mar 2013 05:48:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGnie-0004sP-B7 for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 05:48:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGniV-0004m8-QV for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 05:48:04 -0400 Original-Received: from mail-la0-x231.google.com ([2a00:1450:4010:c03::231]:51342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGniV-0004lf-Cq for help-gnu-emacs@gnu.org; Sat, 16 Mar 2013 05:47:55 -0400 Original-Received: by mail-la0-f49.google.com with SMTP id fs13so4575728lab.36 for ; Sat, 16 Mar 2013 02:47:54 -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:content-type; bh=zOIdSWEJRsq9CVykMZFj0IlUQZ4aMrUCqGGx0CKR880=; b=d92aefiuQliUdj0MU0XHUvWh5/rUZWzTzjGb6zp758ycdytWkA9zmnEIxLkYWUtZKY bkTKuczuhuJcSu8BvnfS+nGulM97sFLXcWETpL1c0bwsZeJF0TJr1EwX7u7ftgaDTJzG 60TFMMldwyDov0Ugu227k6oK9LwhGTzUy5N1+zS/sVarMzS1GtsDF3WcpWSgE6MWNOE5 dFKKSgr54YiJuKcYJx4CF4zSrY2qmv8xmX1BPnpDghzOqxjoF8DR+ypcziktQbRjhcdQ YkeTvbZGvSDvf+SfMP9On3YWBREzkS1UTZ1pgTR/cQqjiYOxM2Xrn6EyaDYgoj23Q77h DPWw== X-Received: by 10.152.146.199 with SMTP id te7mr8357555lab.23.1363427274179; Sat, 16 Mar 2013 02:47:54 -0700 (PDT) Original-Received: by 10.112.42.226 with HTTP; Sat, 16 Mar 2013 02:47:54 -0700 (PDT) In-Reply-To: <20130315195145.GA18986@earth> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::231 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:89551 Archived-At: --e89a8f22c5555ac9c404d807a6d9 Content-Type: text/plain; charset=ISO-8859-1 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] In the documentation of after-make-frame-functions it is claimed that the new frame is passed as an argument, but when I do: (defun set-project-in-frame-title (frame) (interactive) (select-frame frame) (setq projectname (getenv "project")) (message "Project: %s" projectname) (if projectname (modify-frame-parameters frame (list (cons 'title (concat (buffer-name) " [" projectname "]")))) (modify-frame-parameters frame (list (cons 'title (buffer-name)))) ) ;; if projectname ) 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 Thank you very much for any help, Ian. > On Fri, Mar 15, 2013 at 08:24:20PM +0100, Ian van der Neut wrote: > > Hello all, > > > > rather a lisp newbie and been searching all over, but can't figure it > out. > > I have the code below: > > > > (provide 'ian-project) > > ;; Based on the presence of the 'project' environment variable, > > ;; display the project name in the frame title and the mode line. > > (defun set-project-in-frame-title () > > (interactive) > > (setq projectname (getenv "project")) > > (message "Project: %s" projectname) > > (if projectname > > (setq-default frame-title-format (concat "%b (%*) [" projectname "] > > ")) > > (setq frame-title-format (concat "%b (%*)")) > > ) ;; if projectname > > ) > > > > And in my ~/.emacs I have: > > > > (require 'ian-project) > > (set-project-in-frame-title) > > > > The message "Project: " is displayed in the *Messages* > buffer > > on startup, however, the project name does not end up in the frame title, > > unless I execute the function by hand: > > M-x set-project-in-frame-title() > > > > My emacs version is: > > GNU Emacs 24.2.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.6.4) > > of 2013-02-02 on buildvm-04.phx2.fedoraproject.org > > > > Thank you very much in advance for any pointers as to what I may be > missing. > > > > Ian. > > -- > > One man's "magic" is another man's engineering. "Supernatural" is a null > > word. > > -- Excerpt from the notebooks of Lazarus Long, from Robert Heinlein's > "Time > > Enough for Love" > -- One man's "magic" is another man's engineering. "Supernatural" is a null word. -- Excerpt from the notebooks of Lazarus Long, from Robert Heinlein's "Time Enough for Love" --e89a8f22c5555ac9c404d807a6d9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Fri, Mar 15, 2013 at 8:51 PM, Mark Skilbeck &l= t;m@iammark.us> wrote:
Use modify-frame-paramete= rs:

=A0 =A0 (modify-frame-parameters nil '((title . "test")))


Hi, thank you for your reply.

After some searching and readi= ng docs I changed the code to

(defun set-project-in-frame-title ()<= br> =A0 (interactive)
=A0 ;;(select-frame frame)
=A0 (setq projectname (g= etenv "project"))
=A0 (message "Project: %s" project= name)
=A0 (if projectname
=A0=A0=A0=A0=A0 (modify-frame-parameters ni= l (list (cons 'title (concat=A0 (buffer-name) " [" projectnam= e "]"))))
=A0=A0=A0 (modify-frame-parameters frame (list (cons 'title (buffer-nam= e))))
=A0=A0=A0 ) ;; if projectname
)

But it doesn&= #39;t really make any difference. I figured out however, that I probably ne= ed a hook to be executed when a frame is opened:

(add-hook 'after-make-frame-functions 'set-project-in-frame-tit= le)


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"
ema= cs myfile

The frame title has:

*scratch= * [myproject]

In the documentation of after-make-frame-fu= nctions it is claimed that the new frame is passed as an argument, but when= I do:
(defun set-project-in-frame-title (frame)
=A0 (interactive)
=A0 (sele= ct-frame frame)
=A0 (setq projectname (getenv "project"))
= =A0 (message "Project: %s" projectname)
=A0 (if projectname=A0=A0=A0=A0=A0 (modify-frame-parameters frame (list (cons 'title (con= cat=A0 (buffer-name) " [" projectname "]"))))
=A0=A0=A0 (modify-frame-parameters frame (list (cons 'title (buffer-nam= e))))
=A0=A0=A0 ) ;; if projectname
)

I get an erro= r:
Wrong number of arguments: (lambda (frame) (interactive) (select-fram= e frame) (setq projectname (getenv project)) (message Project: %s projectna= me) (if projectname (modify-frame-parameters frame (list (cons (quote title= ) (concat (buffer-name)=A0 [ projectname ])))) (modify-frame-parameters fra= me (list (cons (quote title) (buffer-name)))))), 0

Thank you very much for any help,

Ian.
=


=A0
On Fri, Mar 15, 2013 at 08:24:20PM +0100, Ian van der Neut wrote:
> Hello all,
>
> rather a lisp newbie and been searching all over, but can't figure= it out.
> I have the code below:
>
> (provide 'ian-project)
> ;; Based on the presence of the 'project' environment variable= ,
> ;; display the project name in the frame title and the mode line.
> (defun set-project-in-frame-title ()
> =A0 (interactive)
> =A0 (setq projectname (getenv "project"))
> =A0 (message "Project: %s" projectname)
> =A0 (if projectname
> =A0 =A0 =A0 (setq-default frame-title-format (concat "%b (%*) [&q= uot; projectname "]
> "))
> =A0 =A0 (setq frame-title-format (concat "%b (%*)"))
> =A0 =A0 ) ;; if projectname
> )
>
> And in my ~/.emacs I have:
>
> (require 'ian-project)
> (set-project-in-frame-title)
>
> The message "Project: <projectname>" is displayed in t= he *Messages* buffer
> on startup, however, the project name does not end up in the frame tit= le,
> unless I execute the function by hand:
> M-x set-project-in-frame-title()
>
> My emacs version is:
> GNU Emacs 24.2.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.6.4)
> =A0of 2013-02-02 on buildvm-04.phx2.fedoraproject.org
>
> Thank you very much in advance for any pointers as to what I may be mi= ssing.
>
> Ian.
> --
> One man's "magic" is another man's engineering. &quo= t;Supernatural" is a null
> word.
> -- Excerpt from the notebooks of Lazarus Long, from Robert Heinlein= 9;s "Time
> Enough for Love"



--
One ma= n's "magic" is another man's engineering. "Supernatu= ral" is a null word.
-- Excerpt from the notebooks of Lazaru= s Long, from Robert Heinlein's "Time Enough for Love"
--e89a8f22c5555ac9c404d807a6d9--