LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-01-2013, 11:53 PM   #1
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Rep: Reputation: 28
emacs getenv returns nil


I have written several emacs functions which depend on the getenv function. Recently it has been returning 'nil'. There has been no change to the functions.

In the emacs shell buffer, the set command shows that 'EMACS_PATH' has a value, so the environment has been passed to emacs.
Code:
$ echo $EMACS_PATH
/mnt/jim/emacs
Code:
(defun nav ()
"Visit nav.el"
  (interactive)
  (let (emacs-dir)
  (setq emacs-dir (getenv "EMACS_PATH"))
  (find-file (concat emacs-dir "/nav.el"))))
The argument passed to find-file is /nav.el, not /mnt/jim/emacs/nav.el.

/etc/bash.bashrc contains
Code:
set -a
I'm using Kubuntu 12.04.2 regularly updated.

What do I need to do to get getenv working again?
 
Old 04-02-2013, 05:10 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by CollieJim View Post
In the emacs shell buffer, the set command shows that 'EMACS_PATH' has a value, so the environment has been passed to emacs.
Code:
$ echo $EMACS_PATH
/mnt/jim/emacs
It might be just a shell variable and not an environment variable, you should use env to test for environment variables:
Code:
env | grep ^EMACS_PATH=
How does EMACS_PATH get its value? Note that if you set an environment variable from within an emacs shell buffer, emacs doesn't see it because environment variables are only passed to child processes, you have to set it before starting emacs (or use the elisp function setenv).
 
Old 04-04-2013, 06:27 AM   #3
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
env returns the same.

In /etc/bash.bashrc I have
Code:
  EMACS_PATH=/mnt/jim/emacs
 
Old 04-04-2013, 08:59 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
What's the output from
Code:
env | grep ^EMACS_PATH
emacs -Q --batch --eval '(message (getenv "EMACS_PATH"))'
 
Old 04-05-2013, 01:47 AM   #5
CollieJim
Member
 
Registered: Mar 2005
Distribution: Gentoo, Kubuntu
Posts: 582

Original Poster
Rep: Reputation: 28
Using konsole:
Code:
$ env | grep ^EMACS_PATH
EMACS_PATH=/mnt/jim/emacs
123 14:30:48 ~ $ emacs -Q --batch --eval '(message (getenv "EMACS_PATH"))'
/mnt/jim/emacs
In this context getenv is working.
However if I evaluate (getenv "EMACS_PATH") in emacs' *scratch* buffer:
Code:
(getenv "EMACS_PATH")
nil
Very strange.
 
Old 04-05-2013, 09:39 AM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Perhaps something in your .emacs (or .emacs.d/init.el) is unsetting EMACS_PATH or getenv. Does getenv work for other environment variables? Does it work if you run emacs -Q and evaluate (getenv "EMACS_PATH")? Try also emacs --no-site-file and emacs --no-init-file (-Q is equivalent to both of those at once).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getenv Returns different pointers every time it is called? worldgnat Programming 3 08-15-2008 09:58 PM
Problems with putenv and getenv schanuzie Linux - Newbie 0 05-08-2006 06:22 PM
Apache getenv bug? wu1821 Linux - General 1 06-29-2005 10:00 AM
.emacs make-backup-files nil doesn't work eliotstock Linux - Software 0 05-02-2003 06:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration