Article View: news.software.nn
Article #4765Re: How to change default directory for insert-file?
From: epstein
Date: Mon, 06 Sep 1993 22:57
Date: Mon, 06 Sep 1993 22:57
83 lines
3994 bytes
3994 bytes
This didn't work the first time I tried to post it (perhaps because of
the inclusion of the newsgroup nyx.help, which I've removed), so I'm
giving it another try.
In <1993Sep2.170731.17402@mnemosyne.cs.du.edu> mrosen@nyx.cs.du.edu (Michael Rosen) writes:
>When I try to insert-file the default directory is /usr/tmp and not my
>home directory.
>
>How can I change this so that it will prompt for my home or my home/tmp
>directory each time I go to insert-file?
>
>I looked in the variables section of the man file but couldn't find
>anything related to "insert."
I assume you're talking about when you go to edit a response from
within nn.
I imagine that since the files for the response are temporary, nn uses
one of the tmp directories (in this case /usr/tmp). Since the file
being edited is in this directory, that becomes the default directory
for your editor. I'm not sure you can control which directory nn uses
(from within nn).
However, since this behavior is in some sense an interaction with your
editor, you may be able to control it from the editor end. From the
terminology you use, I'm guessing you're using emacs. I've attached
below some code for emacs that I use for something along these lines.
Basically, what it does is when it sees that an nn or mail file is
being edited (judging from the filename), it turns off backups, and
cd's to the directory where I was previously (as indicated by the PWD
environment variable, which csh is supposed to update; this obviously
won't work for all uers; the commented line is for cd'ing to my home
directory).
I also have some simple code to remove the mail header from a mail
response (i.e. if you have included the message you're responding to,
as I often do); that's not necessarily relevant here, but I'll leave
it in there. Caveat: This code works fine for me, but I'm sure it
could be improved.
(setq find-file-hooks
(cons '(lambda ()
(cond ((or (string-match "^/usr/tmp/nn" (buffer-file-name))
(string-match "^/tmp/Re" (buffer-file-name)))
(setq make-backup-files nil)
;(cd "~")
(cd (getenv "PWD"))
(if (not (re-search-forward "^\n" nil t))
(goto-char (point-max)))))
(if (string-match "^/tmp/Re" (buffer-file-name))
(remove-mail-header)))
find-file-hooks))
(defun remove-mail-header ()
"Remove mail header from mail reply. Header is \"killed\", so that
it can be \"yanked\"."
(interactive)
(cond ((looking-at ">From ")
(remove-mail-header-aux t))
((looking-at "From ")
(remove-mail-header-aux))))
;;; QUOTEDP means all lines begin with a ">"
(defun remove-mail-header-aux (&optional quoted-p)
(let ( (end-line-string (if quoted-p
"^>\n"
"^\n"))
(start (point))
end )
(re-search-forward end-line-string)
(backward-char)
(setq end (point))
(kill-region start end)))
--
Milt Epstein
Department of Computer Science
University of Illinois
epstein@cs.uiuc.edu
Technical Details
Message-ID:
<CCyFrz.Ix2@sparc0a.cs.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!cs.uiuc.edu!gooshie!ta9.cs.uiuc.edu!epsteinReferences:
<1993Sep2.170731.17402@mnemosyne.cs.du.edu>Show Full Headers
Complete Article Headers
Message-ID: <CCyFrz.Ix2@sparc0a.cs.uiuc.edu> Subject: Re: How to change default directory for insert-file? Date: Mon, 6 Sep 1993 22:57:34 GMT From: epstein@ta9.cs.uiuc.edu (epstein) References: <1993Sep2.170731.17402@mnemosyne.cs.du.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!cs.uiuc.edu!gooshie!ta9.cs.uiuc.edu!epstein Newsgroups: news.software.nn Sender: news@sparc0a.cs.uiuc.edu Reply-To: epstein@cs.uiuc.edu Organization: University of Illinois at Urbana-Champaign Lines: 83