home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / emacs / 3051 < prev    next >
Encoding:
Text File  |  1992-09-08  |  3.5 KB  |  86 lines

  1. Path: sparky!uunet!airgun!airgun.wg.waii.com!jct
  2. From: jct@se33.wg2.waii.com (Jim Thompson)
  3. Newsgroups: comp.emacs
  4. Subject: Re: shell command and macro completion
  5. Message-ID: <JCT.92Sep8091931@se33.wg2.waii.com>
  6. Date: 8 Sep 92 13:19:31 GMT
  7. References: <1992Sep3.171417.21110@TorreyPinesCA.ncr.com>
  8. Sender: news@airgun.wg.waii.com
  9. Reply-To: thompson@wg2.waii.com
  10. Organization: Western Geophysical Exploration Products
  11. Lines: 71
  12. Nntp-Posting-Host: se33.wg2.waii.com
  13. In-reply-to: garye@TorreyPinesCA.ncr.com's message of 3 Sep 92 17:14:17 GMT
  14.  
  15. In article <1992Sep3.171417.21110@TorreyPinesCA.ncr.com> garye@TorreyPinesCA.ncr.com (Gary Engebretson 3793) writes:
  16.  
  17. > 1. I use csh and have a large .cshrc file. This means that when I do 'M-x shell'
  18. > I have to wait while .cshrc is executed. No problem there. But when I do 'ESC !'
  19. > .cshrc is also executed which takes a lot of time for no real purpose. The
  20. > question is : how can I get 'M-x shell' to execute .cshrc but 'ESC !' to NOT
  21. > execute .cshrc?
  22. > Ideas that didn't work :
  23. >     1. setting SHELL to '/bin/csh -f'
  24. >     2. setting SHELL to '/home/ccsh' where /home/ccsh contained
  25. >        '/bin/csh -f'
  26. >     3. fooling around with env. variables and then checking for specific
  27. >        values of this variable within .cshrc. This 'kinda' works but
  28. >        it is very kludgey.
  29. >         4. turn on/off protections on .cshrc -- works but annoying
  30.  
  31. I think the best solution is to determine why your .cshrc takes so
  32. long and do something to make it quicker.  I once had this problem,
  33. because I was setting my PATH and MANPATH inside of .cshrc; I had
  34. about twenty directories to search, and I added them to PATH one at a
  35. time.  It took forever.
  36.  
  37. Finally it occurred to me that PATH and all environment variables are
  38. inherited, so they can go in .login.  I moved ALL my environment setup
  39. to .login and kept in .cshrc only the few aliases and sets I use.
  40. This sped things up tremendously.
  41.  
  42. Your attempt #3 sounds like the best solution to me;  an environment
  43. variable is appropriate because the buffer in which your shell runs
  44. (*shell* vs. *Shell Command Output*) is part of that shell's
  45. environment.   That's how I would do it.
  46.  
  47. There is another way, but it assumes that your shell-mode uses ptys
  48. rather than pipes to communicate with your shell (this is the default).
  49. If so, then you can put the following construct in your .cshrc:
  50.  
  51. if ("`/bin/tty`" != "not a tty") then
  52.    # everything your .cshrc does for shell-mode goes here.
  53. else
  54.    # everything your .cshrc does for M-! goes here
  55. endif
  56.  
  57. This works because M-! uses a pipe to communicate with the shell, and
  58. the tty command will return the string "not a tty" when called from a
  59. shell that's running on a pipe.  The string might be different on your
  60. system; to find out what it is, do the following:
  61.  
  62.   1. Switch to the *scratch* buffer and type
  63.  
  64.        (setq process-connection-type nil) C-j
  65.  
  66.      where C-j is control-j or the linefeed key.
  67.  
  68.   2. M-x shell
  69.  
  70.   3. (In *shell* buffer) tty
  71.  
  72.      The string that `tty` spits out is the string you want to put in
  73.      the if statement at the beginning of your .cshrc.
  74.  
  75. One warning though: this solution will also apply outside of Emacs, so
  76. that if you type "csh some-script < some-file" outside of Emacs, the
  77. shell that you start is going to take the M-! path through your .cshrc!
  78.  
  79. Jim
  80. --
  81.    _    Jim Thompson           |  Wanted:
  82.  _| ~-  thompson@wg2.waii.com  |    Nick Park's "Grand Day Out"
  83.  \,  _} Western Geophysical    |    on VHS-format videotape
  84.    \(   Houston, Texas         |  Email me if you know where I can buy it.
  85.