Thursday, April 1, 2010

How to tell your emacs apart

If you, like me, tend to have more than one emacs session running, your OS toolbar will show a bunch of emacs applications running all titled "emacs@". It gets a bit tiring to have to click on the multiple emacs applications to see which one I need to jump to. I discovered that you can easily rename the title for each emacs session and that title change will also appear in your OS toolbar.

The command is...

M-x set-frame-name

... and needs to be run for each emacs session.

I imagine that someone could easily modify the .emacs file to set the frame name based on some environment variable. If anyone does that, please post a comment with the code.

1 comment:

Unknown said...

Hi Alfred, you can modify the *.bat file, which starts your Emacs:

@echo off
REM Ask Emacs Frame ID
:EMACSFRAME
echo .
set emacsframe_tmp=
echo -= Please Enter the Emacs Frame ID =-
set /P emacsframe_tmp="Emacs Frame ID: "
echo.
REM Here we can force it, if nessesary
IF DEFINED emacsframe_tmp goto SET_EMACSFRAME_ID
REM IF NOT DEFINED emacsframe_tmp goto EMACSFRAME

:SET_EMACSFRAME_ID
set EMACS_FRAME_ID=%emacsframe_tmp%
goto START_EMACS

:START_EMACS
set SMALLWORLD_GIS=C:\SW410\product

%SMALLWORLD_GIS%\bin\x86\gis.exe -a %SMALLWORLD_GIS%\config\gis_aliases -e %SMALLWORLD_GIS%\config\environment.bat emacs212

And include this in to your .emacs file:

;; -------------------------------------------------------------
;; This will show full File Path in the
;; -------------------------------------------------------------
(setq emacs-frame-id (or (getenv "EMACS_FRAME_ID") ""))
(setq frame-title-format '("" emacs-frame-id " GNU Emacs " emacs-version " [" (buffer-file-name " %f") "] "))

This will show the ID on the each frame of each Emacs session that you running.

Hope this helps.

Thank you, Igor