all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nick Helm <nick@tenpoint.co.nz>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: Quotes do not display correctly
Date: Fri, 15 Apr 2016 04:05:12 +0000	[thread overview]
Message-ID: <19A83736-82FF-4BA5-8365-2DFCC715751D@tenpoint.co.nz> (raw)
In-Reply-To: <20160407212604514803951@bob.proulx.com>

> How are you setting LANG?  In a ~/.bashrc file?  I don't know anything
> about Apple OS X but in regular X11 settings in ~/.bashrc files only
> affect interactive shells and not other programs that are not
> interactive bash shells.  

I have LANG set in my ~/.bash_profile. As I understand it, OSX runs a new
login shell each for each Terminal.app instance, so I have never bothered
to create a ~/.bashrc file on Macs.

> In order to set the environment in X Windows for example one way would be in
> a .xsessionrc file which is specifically loaded by the window system. I
> would guess it is similar with other systems.

I think that's pretty much how it works on OSX too, as I understand it.
Although there seems to be several ways to do it, including setting variables
in /etc/launchd.conf (the global config file for OSX's service manager/process
launcher), or creating ~/Library/LaunchAgents/environment.plist, which seems
to be an XML script that launchd uses to configure the environment when
launching an app.

> That line break and indent seems unintentional.  Mailer problem?  I
> assume it was meant to be this.  Which I am going to comment upon.

Yes, a problem manually introduced by me. Sorry about that.

> I wanted to comment upon the way you set the variable.  That works,
> obviously.  But it isn't very idiomatic.  It is possible that the
> inclusion of a ';' shell metacharacter in the string will require a
> "/bin/sh -c" to be invoked in order to interpret the script.  Often
> programs optimize the /bin/sh call out if there are no shell
> meta-characters.  But the above requires it.
>  
> Better would be to use the "env" command to run something in a
> modified environment.  It is one of the POSIX standard commands and
> very portably found on systems.  This avoids the need for shell
> meta-characters, may allow the system to optimize the shell out, and
> allows very fine control of the environment.  With that it would be:
> 
>  env LANG=en_NZ.UTF-8 /Applications/Emacs.app/Contents/MacOS/Emacs -Q --daemon

Thank you, this is good advice. At the time, I was convinced my script was at
fault, so I was attempting to use export as a way to force an environment
change within each "do shell script" to test what was going on. I didn't
know I could use env in this way.

> Having said all of the above I am not sure this is the best solution.
> This is simply the first environment variable you have set somewhere
> (~/.bashrc ?) and you may run into other problems.  It might be better
> to figure out how to get your environment set somewhere, such as in
> the X11 ~/.xsessionrc file case, rather than play the wack-a-mole game
> hitting individual environment variables one by one as you run into
> problems not having them.

I agree, this not ideal, so I removed the export commands in my script and
tweaked my ~/Library/LaunchAgents/environemt.plist to include the 
following (XML omitted):

   launchctl setenv LANG en_NZ.UTF-8 
   launchctl setenv TERM xterm-256color
   launchctl setenv HOME /Users/nick 
   launchctl setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin 

This also fixes my quoting problem and I can interrogate LANG and the other
variables from within Emacs with `getenv' and get the values I expect. As a
bonus, it now looks like Emacs is getting the correct PATH, which, up until
now, I’ve had to fudge with this ancient tweak in my init.el:

   (setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH"))) 
   (setq exec-path (append '("/usr/local/bin") exec-path))

Which suggests I've played whack-a-mole before, so thanks for the prompt to
sort this out.



  reply	other threads:[~2016-04-15  4:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07  9:20 Quotes do not display correctly Nick Helm
2016-04-07 14:15 ` Kaushal Modi
2016-04-07 14:16 ` Drew Adams
2016-04-07 15:22 ` Eli Zaretskii
2016-04-08  2:20   ` Nick Helm
2016-04-08  3:38     ` Bob Proulx
2016-04-15  4:05       ` Nick Helm [this message]
2016-04-15 17:34         ` Pascal J. Bourguignon
2016-04-08  7:21     ` Eli Zaretskii
     [not found]     ` <mailman.17.1460086713.7477.help-gnu-emacs@gnu.org>
2016-04-08 18:35       ` Pascal J. Bourguignon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19A83736-82FF-4BA5-8365-2DFCC715751D@tenpoint.co.nz \
    --to=nick@tenpoint.co.nz \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.