Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!mcdchg!heiby From: heiby@mcdchg.chg.mcd.mot.com (Ron Heiby) Newsgroups: comp.emacs Subject: Re: Why can't I set default-directory ? Message-ID: <43447@mcdchg.chg.mcd.mot.com> Date: 17 Aug 90 23:15:37 GMT References: <1990Aug16.142822.8259@unx.sas.com> Organization: Motorola Microcomputer, Schaumburg, IL Lines: 30 I found that I was constantly annoyed when editing an outgoing news or email message, which was being stored temporarily in /tmp or /usr/tmp, that whenever I tried to include a file, like with 'CTRL-x i', it would start out with a default of that /tmp or /usr/tmp directory. Most often, the file I wanted to include in the outgoing message was somewhere under my current directory, so I added the following hack to my .emacs to change the default directory for a buffer to be my current directory if the current default would be /tmp or /usr/tmp. I use the Korn Shell, which keeps $PWD set to the current directory. I suppose users of other shells could execute the pwd command to get the same information. If someone has any suggestions on improvements, I'd be glad to hear about them. ;;-------- (defun rwh-find-file-hooker () "Make sure we're not set up with /tmp as default-directory." (if (or (equal default-directory "/tmp/") (equal default-directory "/usr/tmp/") ) (setq default-directory (file-name-as-directory (getenv "PWD"))) ) ) (defvar find-file-hooks nil) (or (memq 'rwh-find-file-hooker find-file-hooks) (setq find-file-hooks (cons 'rwh-find-file-hooker find-file-hooks))) ;;-------- -- Ron Heiby, heiby@chg.mcd.mot.com Moderator: comp.newprod "Mandatory Drug Testing? Just Say NO!!!"