[comp.mail.mh] Default editor switches in .mh_profile

eo@ansa.co.UK (Ed Oskiewicz) (03/12/91)

Does anyone know of a way to provide startup arguments to the Editor:
specified in your .mh_profile?

For instance,I use the following:
Editor: emacs

and would like it to start up in text mode automatically. If I put
Editor: emacs -f text-mode

Then I get the following error msg from csh

unable to exec emacs -f text-mode: No such file or directory

I guess that its trying to start an editor called "emacs -f text-mode". The
same sort of error happens if I sprinkle quotes around any of these 3 tokens.
Is there any way to achieve this effect?

I'm running on a Sun4 with SunOS 4.03 (UK) and the following configuration:

version: MH 6.7.1 #12[UCI] (caligula) of Fri Feb 22 16:46:13 GMT 1991
options: [BSD42] [BSD43] [SUN40] [TYPESIG=void] [BIND] [BERK] [UK]
         [DUMB] [RPATHS] [MHE] [SBACKUP='"#"'] [MSGPROT='"0600"']
         [FOLDPROT='"0700"'] [SENDMTS] [SMTP]

Cheers,

Ed Oskiewicz

email:	eo@ansa.co.uk (...ukc!ansa!eo)		ANSA,
tel:	+44 223 323 010				Poseidon House,
fax:	+44 223 359 779				Castle Park,
						Cambridge CB3 0RD, UK

gildea@EXPO.LCS.MIT.EDU (Stephen Gildea) (03/13/91)

    Does anyone know of a way to provide startup arguments to the Editor:
    specified in your .mh_profile?
    
    For instance,I use the following:
    Editor: emacs
    
    and would like it to start up in text mode automatically. If I put
    Editor: emacs -f text-mode


As an alternative approach, you could have Emacs use Text mode when it
sees a file that probably came from MH.  Something like this might do
it for you:

(setq auto-mode-alist
      (append '(("/[0-9]+$" . text-mode))
	      auto-mode-alist))

This uses Text mode for files with names composed entirely of digits.
I use this test, but you can change the template to suit you.

 < Stephen
   MIT X Consortium

matt@ODDJOB.UCHICAGO.EDU (Matt Crawford) (03/14/91)

There are at least two ways to do the job.  One is to create,
somewhere in your path, a file called emacs-text-mode, mode 755,
which contains:

#!/bin/sh
exec emacs -f text-mode $*

Then use "Editor: emacs-text-mode" in .mh_profile.


The other way is to put this into your .emacs file:

(setq auto-mode-alist (nconc '(("draft$" . text-mode)
			       ("Mail/drafts/[0-9]+$" . text-mode))
			     auto-mode-alist))

and continue to use "Editor: emacs".  See C-H v auto-mode-alist to
understand this.
________________________________________________________
Matt Crawford	     		matt@oddjob.uchicago.edu

jromine@buckaroo.ics.uci.edu (John Romine) (03/14/91)

eo@ansa.co.UK (Ed Oskiewicz) writes:
>Does anyone know of a way to provide startup arguments to the Editor:
>specified in your .mh_profile?  [For example]:
>
>Editor: emacs -f text-mode

I've been thinking about changing the parser to allow stuff like this.
If the changes are simple, it'll be out in a patch soon.
--
John Romine

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (03/18/91)

As quoted from <9103111635.AA03682%caligula@ansa.co.uk> by eo@ansa.co.UK (Ed Oskiewicz):
+---------------
| Does anyone know of a way to provide startup arguments to the Editor:
| specified in your .mh_profile?
+---------------

You can't.  You can sometimes play other tricks, however:  run a shell script
for your editor, which passes arguments (emacs) or sets $EXINIT (vi).

+---------------
| Then I get the following error msg from csh
| unable to exec emacs -f text-mode: No such file or directory
+---------------

MH doesn't use csh, it uses the exec?p system call.  ("?" because I haven't
checked to see if it uses execl or execv.)  Since the exec() doesn't do
argument splitting, the whole string is taken as the editor name.

+---------------
| I guess that its trying to start an editor called "emacs -f text-mode". The
| same sort of error happens if I sprinkle quotes around any of these 3 tokens.
+---------------

Correct.  The man page mh-profile(5) says this.

You can use the trick I mentioned above to do this.  But if you're just trying
to force text mode on a buffer, what you're doing may not work anyway, most
likely.  (I don't remember if -f executes in the previous file's buffer or
not.)  Better is to put this in your .emacs:

  (setq auto-mode-alist (append auto-mode-alist
			        '(("/Mail/draft$" . text-mode))))

(Approximate; I rarely get the (append) vs. (list) right.  I've got the actual
code at work, but the modems are screwed up so I can't grab it....)  If you
use a draft folder, you can hardcode that into the regexp or you can write
code to extract it from .mh_profile.

Hope this helps a little,
++Brandon
-- 
Me: Brandon S. Allbery			    Ham: KB8JRR on 2m, 220, 440, 1200
Internet: allbery@NCoast.ORG		(QRT on HF until local problems fixed)
America OnLine: KB8JRR // Delphi: ALLBERY   AMPR: kb8jrr.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery          KB8JRR @ WA8BXN.OH