[comp.mail.elm] Fixing the "builtin" editor

epsilon@wet.UUCP (Eric P. Scott) (07/16/90)

(This has already been mailed to the elm coordinator)

We are looking to use elm as a replacement for mailx/BSD Mail for
new users who have not yet learned to use an external editor.
As distributed, elm only works as advertised if configured to use
vi as the default editor; we want to use "builtin" instead.  Some
minor changes make this viable.

These changes are UNOFFICIAL.  You will have to back them out
before applying patch #6.


The following context diffs to ELM 2.3PL5

	. Fix ~v to properly invoke vi when elm is configured to
	  use "builtin" or "none" as the default editor
	. Even if already_has_text is true, if the alternate_editor
	  is "builtin" or "none" don't try to shell to it
	. Avoid creating extraneous process from ~! shell escape

					-=EPS=-
-------
*** hdrs/sysdefs.SH.orig
--- hdrs/sysdefs.SH
***************
*** 92,97 ****
--- 92,98 ----
  #define readmsg_file	".elm/readmsg"
  
  #define emacs_editor	"$emacs"
+ #define vi_editor	"$vi"
  
  #define default_editor	"$defeditor"
  #define mailhome	"$maildir/"
*** src/editmsg.c.orig
--- src/editmsg.c
***************
*** 72,78 ****
  	buffer[0] = '\0';
  
  	if (strcmp(editor, "builtin") == 0 || strcmp(editor, "none") == 0) {
! 	  if (already_has_text) 
  	    sprintf(buffer, "%s %s", alternative_editor, filename);
  	  else
  	    return(no_editor_edit_the_message(filename));
--- 72,79 ----
  	buffer[0] = '\0';
  
  	if (strcmp(editor, "builtin") == 0 || strcmp(editor, "none") == 0) {
! 	  if (already_has_text && strcmp(alternative_editor, "builtin") &&
! 	    strcmp(alternative_editor, "none")) 
  	    sprintf(buffer, "%s %s", alternative_editor, filename);
  	  else
  	    return(no_editor_edit_the_message(filename));
***************
*** 249,255 ****
  
  	       case 'v' : NewLine();
  			  strcpy(buffer, editor);
! 			  strcpy(editor, default_editor);
  			  fclose(edit_fd);
  			  (void) edit_the_message(filename,0);
  			  strcpy(editor, buffer);
--- 250,256 ----
  
  	       case 'v' : NewLine();
  			  strcpy(buffer, editor);
! 			  strcpy(editor, vi_editor);
  			  fclose(edit_fd);
  			  (void) edit_the_message(filename,0);
  			  strcpy(editor, buffer);
***************
*** 299,305 ****
  			   if (( old_raw = RawState()) == ON)
  			     Raw(OFF);
  			   if (strlen(buffer) < 3) 
! 			     (void) system_call(shell, USER_SHELL, TRUE, TRUE);
  			   else
  	                     (void) system_call((char *) buffer+2, USER_SHELL, TRUE, TRUE);
  			   if (old_raw == ON)
--- 300,306 ----
  			   if (( old_raw = RawState()) == ON)
  			     Raw(OFF);
  			   if (strlen(buffer) < 3) 
! 			     (void) system_call((char *)NULL, USER_SHELL, TRUE, TRUE);
  			   else
  	                     (void) system_call((char *) buffer+2, USER_SHELL, TRUE, TRUE);
  			   if (old_raw == ON)
*** src/syscall.c.orig
--- src/syscall.c
***************
*** 218,224 ****
  #endif
  
  	  /* Go for it. */
! 	  execl(sh, argv_zero(sh), "-c", string, (char *) 0);
  
  	  /* If exec fails, we write a byte to the pipe before exiting. */
  	  perror(sh);
--- 218,225 ----
  #endif
  
  	  /* Go for it. */
! 	  if (string) execl(sh, argv_zero(sh), "-c", string, (char *) 0);
! 	  else execl(sh, argv_zero(sh), (char *) 0);
  
  	  /* If exec fails, we write a byte to the pipe before exiting. */
  	  perror(sh);

john@hopf.math.nwu.edu (John Franks) (07/17/90)

In article <1334@wet.UUCP> eps@sutro.SFSU.EDU (Eric P. Scott) writes:
>We are looking to use elm as a replacement for mailx/BSD Mail for
>new users who have not yet learned to use an external editor.
>As distributed, elm only works as advertised if configured to use
>vi as the default editor; we want to use "builtin" instead.  Some
>minor changes make this viable.
>

%%%% context diffs omitted  %%%%%%

I strongly second the need for these changes.  I made comparable 
changes to our local elm some months ago, but it is a pain redoing
them after every new patch.  Could we get this or something like it
in PL6 or in 2.4 at the latest?  It makes elm elm usable for users
who can't use an editor.



John Franks 	Dept of Math. Northwestern University
		john@math.nwu.edu