unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Machine-dependent elisp
@ 2010-04-21 20:46 pocmatos
  2010-04-21 21:41 ` Suvayu Ali
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: pocmatos @ 2010-04-21 20:46 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I have some code which I would like to make dependent on the machine I
am currently working on. I have a single .emacs shared between my work
machine and my home machine. I thought about making dependent on the ip
address (or hostname) but then I need a way to get the ip address (or
hostname) of my current machine.

Any suggestions on the best way to do this?

(I don't think it matters but the code I need to change is mostly the
loading of certain libraries and the setting of the smtp server for
gnus)

tia,

--
PMatos





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Machine-dependent elisp
  2010-04-21 20:46 Machine-dependent elisp pocmatos
@ 2010-04-21 21:41 ` Suvayu Ali
  2010-04-24  1:32 ` Steve Revilak
  2010-04-27 15:00 ` Alex Bennee
  2 siblings, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2010-04-21 21:41 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday 21 April 2010 01:46 PM, pocmatos@gmail.com wrote:
> Hi all,
>
> I have some code which I would like to make dependent on the machine I
> am currently working on. I have a single .emacs shared between my work
> machine and my home machine. I thought about making dependent on the ip
> address (or hostname) but then I need a way to get the ip address (or
> hostname) of my current machine.
>
> Any suggestions on the best way to do this?
>

I use something very crude, but it works. If the usernames are different 
on the two hosts, then you could try enclosing the host dependent lines 
with something like this,

> (if (string= (getenv "USER") "username")
>     ;; do stuff
>         )

> --
> PMatos
>

-- 
Suvayu

Open source is the future. It sets us free.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Machine-dependent elisp
  2010-04-21 20:46 Machine-dependent elisp pocmatos
  2010-04-21 21:41 ` Suvayu Ali
@ 2010-04-24  1:32 ` Steve Revilak
  2010-04-26 17:08   ` Paulo J. Matos
  2010-04-27 15:00 ` Alex Bennee
  2 siblings, 1 reply; 6+ messages in thread
From: Steve Revilak @ 2010-04-24  1:32 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

>From: pocmatos@gmail.com

>I have some code which I would like to make dependent on the machine I
>am currently working on. I have a single .emacs shared between my work
>machine and my home machine. I thought about making dependent on the ip
>address (or hostname) but then I need a way to get the ip address (or
>hostname) of my current machine.
>
>Any suggestions on the best way to do this?
>
>(I don't think it matters but the code I need to change is mostly the
>loading of certain libraries and the setting of the smtp server for
>gnus)


I can offer one possible solution.  

I use the same ~/.emacs on several machines, but there are slight
differences in the way that each machine is configured.  To give a
concrete example, I'd like to use "ant -find build.xml" as the default
compile command at work, and "make" as the default compile command at
home.

To achieve this, my ~/.emacs has

   (if (file-exists-p "~/.elisp/machine-local.el")
       (load "~/.elisp/machine-local.el"))  

machine-local.el has the machine-specific settings.

The Emacs manual has a similar example, which uses custom-file.

   http://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html#Saving-Customizations

Steve

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Machine-dependent elisp
  2010-04-24  1:32 ` Steve Revilak
@ 2010-04-26 17:08   ` Paulo J. Matos
  0 siblings, 0 replies; 6+ messages in thread
From: Paulo J. Matos @ 2010-04-26 17:08 UTC (permalink / raw)
  To: Steve Revilak; +Cc: help-gnu-emacs

On Sat, Apr 24, 2010 at 2:32 AM, Steve Revilak <steve@srevilak.net> wrote:
>
> To achieve this, my ~/.emacs has
>
>  (if (file-exists-p "~/.elisp/machine-local.el")
>      (load "~/.elisp/machine-local.el"))
> machine-local.el has the machine-specific settings.
>
> The Emacs manual has a similar example, which uses custom-file.
>
>  http://www.gnu.org/software/emacs/manual/html_node/emacs/Saving-Customizations.html#Saving-Customizations
>
> Steve
>

That's a solution I hadn't thought about before

Thanks for the ref,
-- 
PMatos




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Machine-dependent elisp
  2010-04-21 20:46 Machine-dependent elisp pocmatos
  2010-04-21 21:41 ` Suvayu Ali
  2010-04-24  1:32 ` Steve Revilak
@ 2010-04-27 15:00 ` Alex Bennee
  2010-04-28  3:34   ` Kevin Rodgers
  2 siblings, 1 reply; 6+ messages in thread
From: Alex Bennee @ 2010-04-27 15:00 UTC (permalink / raw)
  To: pocmatos; +Cc: help-gnu-emacs

On 21 April 2010 21:46,  <pocmatos@gmail.com> wrote:
> Hi all,
>
> I have some code which I would like to make dependent on the machine I
> am currently working on. I have a single .emacs shared between my work
> machine and my home machine. I thought about making dependent on the ip
> address (or hostname) but then I need a way to get the ip address (or
> hostname) of my current machine.

I do exactly this with (system-name), e.g.:

(defvar I-am-at-work (string-match "workdomain" (system-name)))
(defvar I-am-at-home (string-match "danny" (system-name)))
(defvar I-am-on-netbook (string-match "trent" (system-name)))

And then later on in my .emacs I have stanzas like:

(cond
 ((eval I-am-on-netbook)
  ;; With menu bars 86x24
  ;; Full screen 92x26
  (message "setting default frame for netbook")
  (setq default-frame-alist '((menu-bar-lines . 0)
			      (tool-bar-lines . 0)
			      (width . 90)
			      (height . 24)
			      (left . 0)
			      (top . 0)
			      (background-color . "DarkSlateGrey")
			      (foreground-color . "wheat")
			      (vertical-scroll-bars . left)))
  (setq normal-width 90)
  (setq normal-height 24)
  (setq fullscreen-width 92)
  (setq fullscreen-height 26))

 ((eval I-am-at-work)
  (setq default-frame-alist '((menu-bar-lines . 0)
			      (tool-bar-lines . 0)
			      (width . 167)
			      (height . 50)
			      (left . 1200) ; right hand monitor
			      (background-color . "DarkSlateGrey")
			      (foreground-color . "wheat")
			      (vertical-scroll-bars . right))))

					; different screens at home
 ((eval I-am-at-home)
  (setq default-frame-alist '((menu-bar-lines . 0)
			      (tool-bar-lines . 0)
			      (top . 0)
			      (left . 0)
			      (width . 120)
			      (height . 50)
			      (background-color . "DarkSlateGrey")
			      (foreground-color . "wheat")
			      (vertical-scroll-bars . right)))))

Hope that helps.
			
-- 
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Machine-dependent elisp
  2010-04-27 15:00 ` Alex Bennee
@ 2010-04-28  3:34   ` Kevin Rodgers
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2010-04-28  3:34 UTC (permalink / raw)
  To: help-gnu-emacs

Alex Bennee wrote:
> On 21 April 2010 21:46,  <pocmatos@gmail.com> wrote:
>> Hi all,
>>
>> I have some code which I would like to make dependent on the machine I
>> am currently working on. I have a single .emacs shared between my work
>> machine and my home machine. I thought about making dependent on the ip
>> address (or hostname) but then I need a way to get the ip address (or
>> hostname) of my current machine.
> 
> I do exactly this with (system-name), e.g.:
> 
> (defvar I-am-at-work (string-match "workdomain" (system-name)))
> (defvar I-am-at-home (string-match "danny" (system-name)))
> (defvar I-am-on-netbook (string-match "trent" (system-name)))
> 
> And then later on in my .emacs I have stanzas like:
> 
> (cond
>  ((eval I-am-on-netbook)

Nix the eval.

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-04-28  3:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-21 20:46 Machine-dependent elisp pocmatos
2010-04-21 21:41 ` Suvayu Ali
2010-04-24  1:32 ` Steve Revilak
2010-04-26 17:08   ` Paulo J. Matos
2010-04-27 15:00 ` Alex Bennee
2010-04-28  3:34   ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).