From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: filebat Mark Newsgroups: gmane.emacs.help Subject: Re: Postfixing ' emacs' to all frame titles. Date: Sat, 31 Jul 2010 17:40:59 +0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd18162da6b70048cabc3f8 X-Trace: dough.gmane.org 1280569322 7738 80.91.229.12 (31 Jul 2010 09:42:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 31 Jul 2010 09:42:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Wang Lei Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 31 11:42:00 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Of8Zr-0002I9-QS for geh-help-gnu-emacs@m.gmane.org; Sat, 31 Jul 2010 11:42:00 +0200 Original-Received: from localhost ([127.0.0.1]:32831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Of8Zr-0008Ov-6p for geh-help-gnu-emacs@m.gmane.org; Sat, 31 Jul 2010 05:41:59 -0400 Original-Received: from [140.186.70.92] (port=56294 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Of8Yy-0008OX-UZ for help-gnu-emacs@gnu.org; Sat, 31 Jul 2010 05:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Of8Yx-0004wB-C4 for help-gnu-emacs@gnu.org; Sat, 31 Jul 2010 05:41:04 -0400 Original-Received: from mail-pv0-f169.google.com ([74.125.83.169]:36230) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Of8Yx-0004w1-4q for help-gnu-emacs@gnu.org; Sat, 31 Jul 2010 05:41:03 -0400 Original-Received: by pvc30 with SMTP id 30so1664790pvc.0 for ; Sat, 31 Jul 2010 02:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=4goaiuyb5u0PHcAuCnNhdhK1KtElM0r6d3M3MCczqEw=; b=UI0Ui2RXk5fFqrrwkFtbfhC/eZbUcXJEQATdFia+hLZs4OSx+mqDA0LtZ9YFH4fuaA v0/9OXl/A9PqMmyOGaB+rZyQ5xCf0N45ONlbLW56zLIfMGIyUhr6tSvA9P7hqp5EFZCe KltFSlZY96IVcL6aQaVHqTkhJRsxaCzExhr20= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=CbBIoStHG22/ZyZUQ9NTwhqZKLZt0pjlbN43oWgOtDAcH7YJs7QZ28sSz8KOgYMFJT A2V4nrzHpI880CuahDk/ULr0UOBdrbvjM/vUAflUKlGCF4PSeG+Ryb4m5MSA/dU1V5Lx OFs/5c4dtgCxoDrYUhR/bo7n/eTDT0qkGDJUQ= Original-Received: by 10.142.156.14 with SMTP id d14mr2798611wfe.248.1280569260009; Sat, 31 Jul 2010 02:41:00 -0700 (PDT) Original-Received: by 10.142.209.12 with HTTP; Sat, 31 Jul 2010 02:40:59 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:74368 Archived-At: --000e0cd18162da6b70048cabc3f8 Content-Type: text/plain; charset=ISO-8859-1 Thanks, Lei, your code works. And I has extended it to a lisp codesnnipet, which is exactly what I want. I post it here, in case others need it. Notice: There is an enhancement here, which is replacing setq with local variables. I tried to do this, but has failed, due to my poor lisp. Since this is a minor issue for me, so I keep lazy here. ^-^ ;; -------------------------- separator -------------------------- (setq frame-title-format '(:eval (concat "Ask 5 why, Denny! -- " (buffer-name) " -- " (progn (if buffer-file-name (setq buffer_name_str buffer-file-name) (setq buffer_name_str "")) (if (< (length buffer_name_str) 50) buffer_name_str (concat (substring buffer_name_str 0 20) "..." (substring buffer_name_str (- (length buffer_name_str) 30) (length buffer_name_str)) )))))) ;; -------------------------- separator -------------------------- Regards, Denny On Sat, Jul 31, 2010 at 3:30 PM, Wang Lei wrote: > On 7/31/10, filebat Mark wrote: > > Hi Lennart > > > > I tried (setq frame-title-format "%f - Emacs"), it's cool. > > > > However, the full filename of "%f" is usually too long. > > Can I truncate the string with fixed length? > > > > Regards, > > Denny > You can try this. > (setq frame-title-format '(:eval (concat (if (< 10 (length > buffer-file-name)) > (concat (substring > buffer-file-name 0 6) "...") > buffer-file-name) > "- Emacs"))) > > I assume 10 is the max length of filename than you want to. > > > > > > On 7/28/10, Lennart Borgman wrote: > >> > >> On Wed, Jul 28, 2010 at 3:14 PM, Kevin Rodgers > >> wrote: > >> > > >> > Tim Visher wrote: > >> >> > >> >> Hi everyone, > >> >> > >> >> I'm wondering if there's a simple way to postfix ' emacs' to all > frame > >> >> titles without resorting to [elisp from the web][1]. Couldn't find > >> >> anything in Chapter 25 but I didn't search much harder than that. > >> >> > >> >> [1]: http://www.emacswiki.org/emacs/FrameTitle > >> > > >> > No, you need to use Emacs Lisp: that is the "format" of customizations > >> > in ~/.emacs (M-x customize notwithstanding). > >> > > >> > Here's what I use: > >> > > >> > (setq frame-title-format > >> > '("" invocation-name "-" emacs-version "@" system-name ":" > >> > (buffer-file-name "%f" "%b"))) > >> > >> > >> > >> In EmacsW32 I use > >> > >> (setq frame-title-format "%b - Emacs") > >> > >> This is probably what people on ms windows expect. Is that what people > >> on other GUI systems expect as well? > >> > >> > > > > > > -- > > Thanks & Regards > > > > Denny Zhang > > > > > -- > Regards, > Lei > -- Thanks & Regards Denny Zhang --000e0cd18162da6b70048cabc3f8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks, Lei, your code works. And I has extended it to a lisp codesnnipet, = which is exactly what I want.

I post it here, in case others need it= .

Notice: There is an enhancement here, which is replacing setq with= local variables.
I tried to do this, but has failed, due to my poor lisp.
Since this is = a minor issue for me, so I keep lazy here. ^-^

;; ------------------= -------- separator --------------------------
(setq frame-title-format =A0=A0=A0=A0=A0 '(:eval (concat "Ask 5 why, Denny! -- " (buff= er-name) " -- "
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 (progn
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 (if buffer-file-name
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq buffer_name= _str buffer-file-name)
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= (setq buffer_name_str ""))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if (< (length buffer_name_str) 50)=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 buffer_name_str
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (concat (substring buffer_name_str 0 20) = "..."
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 (substring buffer_name_str
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (- (length buffer_name_str) 30)
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (length buffer_na= me_str))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 ))))))

;; -------------------------- separator --------------------------
<= br>Regards,
Denny


On Sat, Jul 31, = 2010 at 3:30 PM, Wang Lei <f3d27b@gmail.com> wrote:
On 7/31/10, filebat Mark <fil= ebat.mark@gmail.com> wrote:
> Hi Lennart
>
> I tried =A0(setq frame-title-format "%f - Emacs"), it's = cool.
>
> However, the full filename of "%f" is usually too long.
> Can I truncate the string with fixed length?
>
> Regards,
> Denny
You can try this.
(setq frame-title-format '(:eval (concat (if (< 10 (length buffer-fi= le-name))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 (concat (substring buffer-file-name 0 6) "...") =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 buffer-file-name)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 "- Emacs")))

I assume 10 is the max length of filename than you want to.


>
> On 7/28/10, Lennart Borgman <lennart.borgman@gmail.com> wrote:
>>
>> On Wed, Jul 28, 2010 at 3:14 PM, Kevin Rodgers
>> <kevin.d.rodgers@g= mail.com> wrote:
>> >
>> > Tim Visher wrote:
>> >>
>> >> Hi everyone,
>> >>
>> >> I'm wondering if there's a simple way to postfix = ' emacs' to all frame
>> >> titles without resorting to [elisp from the web][1]. =A0C= ouldn't find
>> >> anything in Chapter 25 but I didn't search much harde= r than that.
>> >>
>> >> [1]: http://www.emacswiki.org/emacs/FrameTitle
>> >
>> > No, you need to use Emacs Lisp: that is the "format"= ; of customizations
>> > in ~/.emacs (M-x customize notwithstanding).
>> >
>> > Here's what I use:
>> >
>> > (setq frame-title-format
>> > =A0 =A0 =A0'("" invocation-name "-" e= macs-version "@" system-name ":"
>> > =A0 =A0 =A0 =A0(buffer-file-name "%f" "%b"= ;)))
>>
>>
>>
>> In EmacsW32 I use
>>
>> =A0 (setq frame-title-format "%b - Emacs")
>>
>> This is probably what people on ms windows expect. Is that what pe= ople
>> on other GUI systems expect as well?
>>
>>
>
>
> --
> Thanks & Regards
>
> Denny Zhang
>


--
Regards,
Lei



--
Thanks & Reg= ards

Denny Zhang

--000e0cd18162da6b70048cabc3f8--