home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / mail / elm / 2238 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  2.9 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!login.dkuug.dk!shj
  2. From: shj@login.dkuug.dk (Stig Jacobsen)
  3. Newsgroups: comp.mail.elm
  4. Subject: Unofficial patch - "lastread" pointers
  5. Keywords: patch,lastread
  6. Message-ID: <shj.714951852@login.dkuug.dk>
  7. Date: 27 Aug 92 21:44:12 GMT
  8. Sender: news@slyrf.dkuug.dk
  9. Organization: Asis Electronic Intl., Copenhagen, Denmark
  10. Lines: 94
  11.  
  12. Crude patch for elm 2.3pl11.. Add -DSHJ=1 to the compiler
  13. commandline or zap the #if/#endif's to activate after patching.
  14.  
  15. The patch adds a "lastread" pointer to your alternate folders
  16. (~/Mail/*), so that when you quit such a folder, elm will record the
  17. current message in a file and the next time you enter the folder, the
  18. current message will be set back to the the saved position..
  19.  
  20. If you are on a couple of mailinglists (I am) and on a bunch of
  21. aliases (I am!), the "lastread" mechanism avoids the "I can't
  22. remember how much I've read of this folder, so I'll just read it
  23. backwards, until I recognize something" cycle.
  24.  
  25. Also included - your bonus for having read this far - is a
  26. smallish Perl-script, that lists those folders in which you have
  27. unread mail (according to the lastread pointer). 
  28. Usage: checklr Mail/*
  29.  
  30. Enjoy!
  31.  
  32.  
  33. *** leavembox.c.org    Thu Aug 27 22:55:14 1992
  34. --- leavembox.c    Thu Aug 27 23:06:13 1992
  35. ***************
  36. *** 318,323 ****
  37. --- 318,338 ----
  38.         if(headers[i]->status_chgd == TRUE)
  39.           num_chgd_status++;
  40.       
  41. + #if SHJ
  42. +         if (folder_type == NON_SPOOL) {
  43. +            int  h;
  44. +            char tmpname[SLEN];
  45. +            sprintf(tmpname, "%s.lr", cur_folder);
  46. +            if ((h = creat(tmpname, 0600)) < 0) {
  47. +               error1("Can't create %s", tmpname);
  48. +               leave();
  49. +               }
  50. +            write(h, ¤t, sizeof(current));
  51. +            close(h);
  52. +            }
  53. + #endif
  54. +     
  55.       if(!to_delete && !to_store && !num_chgd_status && !resyncing) {
  56.         dprint(3, (debugfile, "Folder keep as is!\n"));
  57.         error("Folder unchanged.");
  58. *** newmbox.c.org    Thu Aug 27 22:55:21 1992
  59. --- newmbox.c    Thu Aug 27 23:27:09 1992
  60. ***************
  61. *** 775,780 ****
  62. --- 775,798 ----
  63.           }
  64.         }
  65.       }
  66. + #if SHJ
  67. +         if (folder_type == NON_SPOOL) {
  68. +            int  h;
  69. +            char tmpname[SLEN];
  70. +            sprintf(tmpname, "%s.lr", cur_folder);
  71. +            if ((h = open(tmpname, O_RDONLY)) >= 0) {
  72. +               int new_curr;
  73. +               read(h, &new_curr, sizeof(new_curr));
  74. +               close(h);
  75. +               if (new_curr <= count)
  76. +                  current = new_curr;
  77. +               }
  78. +            }
  79. + #endif
  80.           get_page(current);
  81.       return(count);
  82.   }
  83.  
  84.  
  85. checklr.pl:
  86.  
  87. #!/usr/local/bin/perl
  88. foreach $nm (@ARGV) {
  89.    if (open(LR, "$nm" . ".lr")) {
  90.       read(LR, $s, 8);
  91.       $lrpos = unpack("i", $s);
  92.       $n_msgs = `grep -c '^From ' $nm`;
  93.       $n_msgs -= $lrpos;
  94.       printf("%s: %d unread messages.\n", 
  95.          substr($nm, rindex($nm, "/")+1), $n_msgs) if ($n_msgs > 0);
  96.       }
  97.    }
  98. --
  99. Stig Jacobsen
  100. shj@login.dkuug.dk
  101.