home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / eel / lenoil.arc / AUTOSAVE.E next >
Internet Message Format  |  1988-12-09  |  3KB

  1. From:    IN%"lenoil@APPLE.COM"  "Robert Lenoil"  9-DEC-1988 16:24
  2. To:    p150bk19@VB.CC.CMU.EDU
  3. Subj:    AUTOSAVE.E
  4.  
  5. Received: from apple.com by VB.CC.CMU.EDU; Fri, 9 Dec 88 16:23 EST
  6. Received: by apple.com (5.59/25-eef) id AA17206; Fri, 9 Dec 88 13:09:24 PST
  7. Date: Fri, 9 Dec 88 13:09:24 PST
  8. From: Robert Lenoil <lenoil@APPLE.COM>
  9. Subject: AUTOSAVE.E
  10. To: p150bk19@VB.CC.CMU.EDU
  11. Message-Id: <8812092109.AA17206@apple.com>
  12.  
  13. /* The following copyright and trademark notice applies to some of the code
  14.  * herein; all other material is Copyright (c) 1986, 1987 by Robert Lenoil,
  15.  * with free copying allowed for any purpose, provided that this copyright
  16.  * notice is included.
  17.  */
  18.  
  19. /************************************************************************
  20. * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. *
  21. *                                                                       *
  22. *     Copyright (C) 1985 Lugaru Software Ltd.  All rights reserved.     *
  23. *                                                                       *
  24. * Limited permission is hereby granted to reproduce and modify this     *
  25. * copyrighted material provided that the resulting code is used only in *
  26. * conjunction with Lugaru products and that this notice is retained in  *
  27. * any such reproduction or modification.                                *
  28. ************************************************************************/
  29.  
  30. /*
  31.  * My Epsilon customizations
  32.  */
  33.  
  34. #include <eel.h>
  35.  
  36. /* This file modifies the following Epsilon commands/procedures:
  37. COMMAND              SOURCE FROM VERSION
  38. make_mode               3.1
  39. normal_character        3.1
  40.  
  41.    And adds the following commands/procedures:
  42. COMMAND           WRITTEN FOR VERSION
  43. auto_save_mode          3.1
  44.  
  45.    And defines the following globals:
  46. GLOBAL            WRITTEN FOR VERSION
  47. auto_save               3.1
  48. auto_save_interval      3.1
  49. */
  50.  
  51. /* Implement auto-save */
  52. buffer int auto_save = 0;
  53. int auto_save_interval = 200;
  54.  
  55. command auto_save_mode()
  56. {  auto_save = has_arg? (iter != 0) : auto_save? -auto_save : 1;
  57.    make_mode();
  58.    iter = 1;
  59. }
  60.  
  61. /* NORMAL_CHARACTER modified to increment buffer typein count and perform
  62.  * auto-save after auto-save-interval characters.  Modified from version 3.1
  63.  * source.
  64.  */
  65. command normal_character()
  66. {
  67.    if (key >= 256) return;
  68.    if (key == '\n') {
  69.       insert('\n');
  70.       if (auto_indent && indenter)
  71.          (*indenter)();
  72.    } else if (over_mode && point < size() && curchar() != '\n') {
  73.       if (curchar() == '\t')
  74.          tabs_to_spaces(point, point + 1);
  75.       replace(point++, key);
  76.    } else
  77.       insert(key);
  78.    if (auto_save > 0 && ++auto_save > auto_save_interval) {
  79.       char savename[FNAMELEN];
  80.       sayput("Auto saving. . .");
  81.       strcpy(savename, *filename? filename : "autosave");
  82.       strcpy(get_extension(savename), ".sav");
  83.       say( "Auto saving. . . %s",
  84.            file_write(savename, strip_returns)? "failed" : "done" );
  85.       auto_save = modified = 1;
  86.    }
  87. }
  88.  
  89. /* MAKE_MODE modified to include auto-save mode.  Modified from version 3.1
  90.  * source.
  91.  */
  92. make_mode()
  93. {
  94.    strcpy(mode, major_mode);
  95.    if (fill_mode)
  96.       strcat(mode, " Fill");
  97.    if (auto_save > 0)
  98.       strcat(mode, " Save");
  99.    if (over_mode)
  100.       strcat(mode, " Over");
  101.    if (!strip_returns)
  102.       strcat(mode, " NoTrans");
  103. }
  104.