[comp.emacs] Getting hostname on status line.

mazumdar@fredonia.UUCP (Jin Mazumdar) (10/04/89)

	Is there a simple way to have the hostname show up on the
status line in Gnu-Emacs?  By simple I am thinking of a hook or some
code that can be put in .emacsrc.  Yes we have Berkeley UNIX.

tale@pawl.rpi.edu (David C Lawrence) (10/04/89)

(IcK.  UUCP bounce messages.)

In <1612@fredonia.UUCP> mazumdar@fredonia.UUCP (Jin Mazumdar) writes:
Jin> 	Is there a simple way to have the hostname show up on the
Jin> status line in Gnu-Emacs?  By simple I am thinking of a hook or some
Jin> code that can be put in .emacsrc.  

Well, where you want it and how much of it you want is all pretty much
a matter of taste, but something of the sort

(setq global-mode-string (list "" (system-name)))

would be a bare start.  It would be a good idea to check on the
documentation for the variables mode-line-format and
global-mode-string; if you also start display-time you would want to
make the above expression more robust, especially if it starts after
display time.  By more robust, you would need to basically check the
list structure and append to it appropriately rather then just replace
it.   Also check on the documentation for string-match if you want to
drop some domain names from the string (system-name) is returning.

Dave
--
 (setq mail '("tale@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))

lih@CUNIXC.CC.COLUMBIA.EDU (Andrew Lih) (10/04/89)

> Date: 3 Oct 89 20:46:46 GMT From: Jin Mazumdar
> <rpi!leah!bingvaxu!sunybcs!fredonia!mazumdar@bbn.com>
> Sender: arpa-unix-emacs-request@bbn.com
> 
> 	Is there a simple way to have the hostname show up on the
> status line in Gnu-Emacs?  By simple I am thinking of a hook or some
> code that can be put in .emacsrc.  Yes we have Berkeley UNIX.

On our EMACS version 18.52.24, you can just use the following:

(setq host (system-name))

(setq default-mode-line-format (quote (" " host " -%*- " "%b " global-mode-string mode-line-time-string " [" (-3 . "%p") "]" " %[(" mode-name minor-mode-alist mode-line-process ") %]")))
                 ___________________________________________________________
""""""""""     /							    \
|  @  @  |     | Andrew "Fuz" Lih	Columbia University Center           |
<    >   > ___/   Academic Computing	 for Computing Activities            |
 \ \__/ / <___                                                               /
  \____/      \    lih@cunixc.cc.columbia.edu    AJLUS@CUVMB.BITNET         /
	       \    lih@cs.columbia.edu     ...rutgers!columbia!cunixc!lih |
                \__________________________________________________________/

michael@uni-paderborn.de (Michael Schmidt) (10/23/89)

In article <8910032315.AA10699@cunixc.cc.columbia.edu>, lih@CUNIXC (Andrew Lih) writes:
>On our EMACS version 18.52.24, you can just use the following:
>
>(setq host (system-name))
>
>(setq default-mode-line-format (quote (" " host " -%*- " "%b " global-mode-string mode-line-time-string " [" (-3 . "%p") "]" " %[(" mode-name minor-mode-alist mode-line-process ") %]")))

But that doesn't work from within .emacs. Could anybody comment how to
get the hostname in the status line from .emacs?
-- 
    Michael Schmidt, Universitaet-GH Paderborn, FB 17, Warburger Str.100,
                     D-4790 Paderborn, West Germany
Mail:   michael@pbinfo.UUCP         or          michael@pbinfo.uni-paderborn.de

louie@haven.umd.edu (Louis Mamakos) (10/23/89)

Here's what I do in my .emacs go get the hostname in the status line:

(setq short-hostname
      (substring (system-name) 0 (string-match "\\." (system-name))))

(setq-default mode-line-format
  '("--%1*%1*-" mode-line-buffer-identification "   " global-mode-string
    "   %[("
    mode-name minor-mode-alist "%n" mode-line-process
    ")%]----"
    (-3 . "%p") 
    "----<"
    short-hostname
    ">-%-")
  )


which seem wo work just fine.  short-hostname is the name of the host with any
domain suffix stripped off.

My mode line right now looks like this:

--**-Emacs: .article               (Text)----All----<sayshell>-----------------

where my hostname is 'sayshell.umd.edu'.

louie

sksircar@phoenix.Princeton.EDU (Subrata Kumar Sircar) (10/24/89)

In article <688@corona.pb> michael@uni-paderborn.de (Michael Schmidt) writes:
>But that doesn't work from within .emacs. Could anybody comment how to
>get the hostname in the status line from .emacs?

Actually, how does one use a .emacs file?  Is there an option to invoke
emacs with?  I tried using 'emacs -l .emacs' which is what my local man
page tells me but that didn't work...

Please reply by mail as I'm sure most people are sneering at my inexperience.

Subrata K. Sircar, Prophet    | Disclaimer:  My Opinions, Of course,
Charter Member of SPAMIT(tm)  | reflect the will of this entire multiverse.
sksircar@phoenix.princeton.edu| "Boy, your adolence and childhood expenses
SKSIRCAR@PUCC.BITNET	      | are on the house!"  "Imagine my relief."