Skip to content

Commit 993bdb2

Browse files
authored
Maintaining old edit dates #359 (#599)
* PRINTFN: Allow suppression of gratuitous TERPRI in PFCOPYBYTES An odd feature of PFCOPYBYTES is that it was outputting a gratuitous EOL just in the case of copying a whole file, so copy-all+1. Don't know who depends on it as is, so I added an extra argument NOTERPRI to allow clients to suppress it. * Keep old editdates #359 Rework of the editdate capability, centralizing in EDITINTERFACE and removing the pieces that were also on FILEPKG. Also added a new capability--edit dates can include change-log-type information. See issue
1 parent 7a27c26 commit 993bdb2

File tree

6 files changed

+324
-292
lines changed

6 files changed

+324
-292
lines changed

sources/EDITINTERFACE

+230-65
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
22

3-
(FILECREATED "27-Nov-2021 13:28:18" 
4-
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>EDITINTERFACE.;2 37858
3+
(FILECREATED " 3-Dec-2021 15:45:20" 
4+
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>EDITINTERFACE.;19 45997
55

6-
previous date%: " 7-Nov-91 18:15:13"
7-
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>EDITINTERFACE.;1)
6+
changes to%: (VARS EDITINTERFACECOMS)
7+
(FNS FIXEDITDATE EDITDATE? EDITDATE)
8+
9+
previous date%: " 2-Dec-2021 23:20:07"
10+
{DSK}<Users>kaplan>Local>medley3.5>my-medley>sources>EDITINTERFACE.;7)
811

912

1013
(* ; "
@@ -34,7 +37,7 @@ Copyright (c) 1986-1988, 1990-1991 by Venue & Xerox Corporation.
3437
(FUNCTIONS ED INSTALL-PROTOTYPE-DEFN)
3538
(FNS EDITDEF.FNS EDITF EDITFB EDITFNS EDITLOADFNS? EDITMODE EDITP EDITV DC DF DP DV EDITPROP
3639
EF EP EV EDITE EDITL)
37-
[COMS
40+
(COMS
3841
(* ;; "Time stamp on functions when edited")
3942

4043

@@ -44,8 +47,12 @@ Copyright (c) 1986-1988, 1990-1991 by Venue & Xerox Corporation.
4447
(INITVARS (INITIALS)
4548
(INITIALSLST)
4649
(DEFAULTINITIALS T))
47-
(VARIABLES *REPLACE-OLD-EDIT-DATES*)
48-
(P (MOVD? 'EDITDATE 'TTY/EDITDATE]
50+
(INITVARS (*REPLACE-OLD-EDIT-DATES* NIL))
51+
(P (MOVD? 'EDITDATE 'TTY/EDITDATE))
52+
(COMS (* ; "Moved from FILEPKG")
53+
[VARS (EDITDATE-ARGLIST-DEFINERS '(FUNCTIONS TYPES))
54+
(EDITDATE-NAME-DEFINERS '(STRUCTURES VARIABLES]
55+
(GLOBALVARS EDITDATE-ARGLIST-DEFINERS EDITDATE-NAME-DEFINERS)))
4956
[INITVARS (COMMON-SOURCE-MANAGER-TYPES '(FUNCTIONS VARIABLES STRUCTURES TYPES SETFS
5057
OPTIMIZERS]
5158
(PROP FILETYPE EDITINTERFACE)
@@ -621,61 +628,207 @@ Copyright (c) 1986-1988, 1990-1991 by Venue & Xerox Corporation.
621628
OLDATE INITLS])
622629

623630
(FIXEDITDATE
624-
[LAMBDA (EXPR) (* NOBIND "18-JUL-78 21:11")
625-
(* ;
626-
 "Inserts or replaces previous edit date")
627-
(AND INITIALS (LISTP EXPR)
628-
(FMEMB (CAR EXPR)
629-
LAMBDASPLST)
630-
(LISTP (CDR EXPR))
631-
(PROG ((E (CDDR EXPR)))
632-
RETRY
633-
[COND
634-
((NLISTP E)
635-
(RETURN))
636-
((LISTP (CAR E))
637-
(SELECTQ (CAAR E)
638-
((CLISP%: DECLARE)
639-
(SETQ E (CDR E))
640-
(GO RETRY))
641-
(BREAK1 (COND
642-
((EQ (CAR (CADAR E))
643-
'PROGN)
644-
(SETQ E (CDR (CADAR E)))
645-
(GO RETRY))))
646-
(ADV-PROG (* ;
647-
 "No easy way to mark cleanly the date of an advised function")
648-
(RETURN))
649-
(COND
650-
((AND (EQ (CAAR E)
651-
COMMENTFLG)
652-
(EQ (CADAR E)
653-
'DECLARATIONS%:))
631+
[LAMBDA (EXPR)
632+
633+
(* ;; "Edited 3-Dec-2021 15:35 by rmk: Updated to add dates to the initial undated comments that begins with current-editor initials, to provide a kind of dated change-log capability.")
634+
 (* ; "Edited 3-Dec-2021 15:03 by rmk")
635+
(* ; "Edited 22-Oct-2021 16:58 by rmk:")
636+
(* ; "Edited 27-Sep-2018 22:04 by rmk:")
637+
(* ; "Edited 31-Mar-2000 17:13 by rmk:")
638+
(* ; "Edited 17-Jul-89 11:13 by jtm:")
639+
(* ; "18-JUL-78 21:11")
640+
641+
(* ;; "Inserts or replaces previous edit date. This retains multiple edits (at least one day apart or by different editor) unless *REPLACE-OLD-EDIT-DATES*. Note that the new date doesn't show up within the current SEDIT session, you have to exit and re-edit to see it.")
642+
643+
(CL:WHEN (AND INITIALS (LISTP EXPR)
644+
(LISTP (CDR EXPR)))
645+
(PROG (E)
646+
647+
(* ;; "Normalize out the colon, add it back if needed.")
648+
649+
(COND
650+
((FMEMB (CAR EXPR)
651+
LAMBDASPLST)
652+
653+
(* ;; "insert the edit date after the argument list")
654+
655+
(SETQ E (CDDR EXPR)))
656+
[(FMEMB (GETPROP (CAR EXPR)
657+
':DEFINER-FOR)
658+
EDITDATE-ARGLIST-DEFINERS)
659+
660+
(* ;; "insert the edit date after the argument list")
661+
662+
(SETQ E (CDDR EXPR))
663+
(while (NOT (CL:LISTP (CAR E))) do (SETQ E (CDR E)) finally (SETQ E (CDR E]
664+
((FMEMB (GETPROP (CAR EXPR)
665+
':DEFINER- FOR)
666+
EDITDATE-NAME-DEFINERS)
667+
668+
(* ;; "insert the edit date after the name")
669+
670+
(SETQ E (CDDR EXPR)))
671+
(T (RETURN)))
672+
RETRY
673+
[COND
674+
((NLISTP E)
675+
(RETURN))
676+
((LISTP (CAR E))
677+
(SELECTQ (CAAR E)
678+
((CLISP%: DECLARE)
654679
(SETQ E (CDR E))
655-
(GO RETRY]
656-
(COND
657-
((AND (LISTP (CDR E))
658-
(EDITDATE? (CAR E)))
659-
(/RPLACA E (EDITDATE (CAR E)
660-
INITIALS)))
661-
(T (/ATTACH (EDITDATE NIL INITIALS)
662-
E)))
663-
(RETURN EXPR])
680+
(GO RETRY))
681+
(BREAK1 (COND
682+
((EQ (CAR (CADAR E))
683+
'PROGN)
684+
(SETQ E (CDR (CADAR E)))
685+
(GO RETRY))))
686+
(ADV-PROG (* ;
687+
 "No easy way to mark cleanly the date of an advised function")
688+
(RETURN))
689+
(COND
690+
((AND (EQ (CAAR E)
691+
COMMENTFLG)
692+
(EQ (CADAR E)
693+
'DECLARATIONS%:))
694+
(SETQ E (CDR E))
695+
(GO RETRY]
696+
697+
(* ;; "E is now the cell that the date will attach to or whose CAR will be updated.")
698+
699+
(LET (PARSE (INITLS (CL:IF (EQ (CHARCODE %:)
700+
(NTHCHARCODE INITIALS -1))
701+
(SUBSTRING INITIALS 1 -2)
702+
INITIALS)))
703+
(IF *REPLACE-OLD-EDIT-DATES*
704+
THEN
705+
(* ;; "Strip out all previous modern-format edit dates. Since EDITDATE? only recognizes that format, hand editing is needed if prehistoric dates are really not desired. We don't strip out anything with a further comment.")
706+
707+
(BIND (TAIL _ E) WHILE (AND (LISTP TAIL)
708+
(EDITDATE? (CAR TAIL)))
709+
DO (SETQ TAIL (CDR TAIL)) FINALLY (CL:UNLESS (EQ E TAIL)
710+
(/RPLACD E TAIL)))
711+
712+
(* ;;
713+
 "Now (CAR E) may or may not be a (no-REST) editdate, but there are none afterwards.")
714+
715+
(IF (SETQ PARSE (EDITDATE? (CAR E)
716+
T))
717+
THEN (* ; "Smash it")
718+
(EDITDATE (CAR E)
719+
INITLS
720+
(CADDR PARSE))
721+
ELSE (/ATTACH (EDITDATE NIL INITLS)
722+
E))
723+
ELSEIF (SETQ PARSE (EDITDATE? (CAR E)
724+
T))
725+
THEN
726+
(* ;; "Attach the new timestamp at the beginning of E, provided the new date is either more than a day later than the previous one or by a different editor.")
727+
728+
(* ;; "If edited by the same editor within a day, then update the previous timestamp rather than just leaving the original time. Presumably this is the next event in the same longer editing session, and it avoids stacking up uninformative dates from in-and-out editing during a session. ")
729+
730+
(IF (STRING.EQUAL INITLS (CADR PARSE))
731+
THEN
732+
733+
(* ;; "This is a previous date with this author. If more than a day later, add a new date. If less than a day, assume we are in essentially the same session, and update (CAR E) to the current time.")
734+
735+
[IF (OR (NULL (CAR PARSE))
736+
(IGREATERP (IDIFFERENCE (IDATE)
737+
(IDATE (CAR PARSE)))
738+
(TIMES 24 3600)))
739+
THEN
740+
(* ;; "If no date, must have been %"INITIALS: xxx%" and we definitely want to upgraded to the Edited... format")
741+
742+
(/ATTACH (EDITDATE NIL INITLS (CADDR PARSE))
743+
E)
744+
ELSE
745+
(* ;; "Same author, within a day. ")
746+
747+
(/RPLACA E (EDITDATE NIL INITLS (CADDR PARSE]
748+
ELSE
749+
(* ;;
750+
 "Not a previous date, or not one with this author. Add a new one.")
751+
752+
(/ATTACH (EDITDATE NIL INITLS (CADDR PARSE))
753+
E))
754+
ELSE
755+
(* ;; "Need a new date, didn't even see %"<initials: xxx%"")
756+
757+
(/ATTACH (EDITDATE NIL INITLS)
758+
E)))
759+
(RETURN EXPR)))])
664760

665761
(EDITDATE?
666-
(LAMBDA (COMMENT) (* ; "Edited 29-Oct-87 16:41 by drc:") (* ;;; "Tests to see if a given common is in fact an edit date -- this has to be general enough to recognize the most comment comment forms while specific enough to not recognize things that are not edit dates. We settle for the conservative form of (* initials date-string), since only truly ancient edit dates look any different from that") (DECLARE (LOCALVARS . T)) (AND *REPLACE-OLD-EDIT-DATES* (LISTP COMMENT) (EQMEMB (CAR COMMENT) COMMENTFLG) (LISTP (CDR COMMENT)) (LISTP (CDDR COMMENT)) (NULL (CDDDR COMMENT)) (STRINGP (CADDR COMMENT)) (LET ((INITIALS? (CADR COMMENT))) (AND (NOT (EQMEMB INITIALS? COMMENTFLG)) (OR (EQ INITIALS? INITIALS) (if (LITATOM INITIALS?) then (if (for I from 1 to (NCHARS INITIALS?) always (EQ (NTHCHARCODE INITIALS? I) (CHARCODE ";"))) then (* ; " an sedit comment") (AND (EQ INITIALS? (QUOTE ;)) (STRPOS "Edited " (CADDR COMMENT) 1 NIL T) (>= (CL:LENGTH (CADDR COMMENT)) (CL:LENGTH "Edited 01-jan-86 00:00 by "))) else (* ; "an old-style comment") T) elseif (STRINGP INITIALS?) then (* ; "make sure it's not a string-body comment.") (ILESSP (NCHARS INITIALS?) 12)))))))
667-
)
762+
[LAMBDA (COMMENT RESTOK) (* ; "Edited 3-Dec-2021 14:35 by rmk")
763+
764+
(* ;;; "This determines whether this is a dated or initialed comment that is potentially reusable in the current context. Unless RESTOK, this only recognizes modern-format configurations of the form %"Edited <date> by <initials>%", and returns a parsed pair (DATE INITIALS).")
765+
766+
(* ;;; "If RESTOK, this also parses strings with additional stuff after the <initials> (%"Edited by <initials>: xxx%") and strings that appear to begin with initials but don't have a date (<initials>: xxx). In those cases the return is a triple (DATE INITIALS REST), where DATE may be NIL. ")
767+
768+
(* ;;; "")
769+
770+
(* ;;;
771+
"The caller can compare against current time and current user to decide whether to smash or add.")
772+
773+
(* ;;; "There is no harm in not recognizing prehistoric formats, new dates will always be added on.")
774+
775+
(LET ((TAIL COMMENT)
776+
STRING POS DATE I RESTPOS)
777+
(CL:WHEN [AND (EQ COMMENTFLG (CAR (LISTP TAIL)))
778+
(MEMB [CAR (LISTP (SETQ TAIL (CDR TAIL]
779+
'(; ;; ;;;))
780+
(STRINGP (SETQ STRING (CAR (SETQ TAIL (CDR TAIL]
781+
(SETQ STRING (CL:STRING-TRIM `(#\Space)
782+
STRING))
783+
(CL:UNLESS [AND [STREQUAL "Edited " (SUBSTRING STRING 1 8 (CONSTANT (CONCAT]
784+
(SETQ POS (STRPOS " by " STRING 9))
785+
[IDATE (SETQ DATE (SUBSTRING STRING 9 (SUB1 POS]
786+
(SETQ I (SUBSTRING STRING (IPLUS POS 4)
787+
(OR (SETQ RESTPOS (STRPOS " " STRING (IPLUS POS 4)))
788+
-1]
789+
790+
(* ;; "Could be %"<INITIALS>: abc%" to be upgraded with a date")
791+
792+
(SETQ RESTPOS (STRPOS " " STRING))
793+
(SETQ I (SUBSTRING STRING 1 (SUB1 RESTPOS))))
794+
(CL:WHEN (AND I (ILESSP (NCHARS I)
795+
12)) (* ;
796+
 "Sanity check: Initials should be short.")
797+
(CL:WHEN (EQ (CHARCODE %:)
798+
(NTHCHARCODE I -1)) (* ;
799+
 "Normalize out the colon in the return")
800+
(SETQ I (SUBSTRING I 1 -2)))
801+
(IF RESTOK
802+
THEN (LIST DATE I (AND RESTPOS (SUBSTRING STRING RESTPOS)))
803+
ELSEIF (AND DATE (NOT RESTPOS))
804+
THEN (LIST DATE I))))])
668805

669806
(EDITDATE
670-
[LAMBDA (OLDATE INITLS) (* ; "Edited 20-Nov-86 23:23 by Masinter")
671-
(* ;;
672-
 "Generates a new date from an old one")
673-
(LET [(NEWDATE (LIST '; (CONCAT "Edited " (DATE (DATEFORMAT NO.SECONDS))
674-
" by " INITLS]
807+
[LAMBDA (OLDDATE INITLS REST)
808+
809+
(* ;; "Edited 3-Dec-2021 13:17 by rmk: Upgraded to make sure that the comment includes REST")
810+
(* ; " 20-Nov-86 23:23 by Masinter")
811+
812+
(* ;; "Generates a new date from an old one. Packs : onto INITLS if there is a REST. In the REST case we upgrade a singe semicolon to a double.")
813+
814+
(LET ((EDITSTRING (CONCAT "Edited " (DATE (DATEFORMAT NO.SECONDS))
815+
" by " INITLS))
816+
NEWDATE OLDSEMI)
817+
(CL:WHEN REST
818+
(SETQ EDITSTRING (CONCAT EDITSTRING ":" REST)))
819+
(CL:WHEN OLDDATE
820+
(SETQ OLDSEMI (CADR OLDDATE)))
821+
(SETQ NEWDATE (LIST (CL:IF REST
822+
(OR OLDSEMI ';;)
823+
';)
824+
EDITSTRING))
675825
(COND
676-
((EQMEMB (CAR (LISTP OLDATE))
677-
COMMENTFLG) (* ;; "Destructively alter old date. This is for benefit of DEDIT being able to find the old form to reprint")
678-
(/RPLACD OLDATE NEWDATE))
826+
((EQMEMB (CAR (LISTP OLDDATE))
827+
COMMENTFLG)
828+
829+
(* ;; "Destructively alter old date. This is for benefit of DEDIT being able to find the old form to reprint")
830+
831+
(/RPLACD OLDDATE NEWDATE))
679832
(T (CONS (OR (CAR (LISTP COMMENTFLG))
680833
COMMENTFLG)
681834
NEWDATE])
@@ -718,11 +871,23 @@ Copyright (c) 1986-1988, 1990-1991 by Venue & Xerox Corporation.
718871

719872
(RPAQ? DEFAULTINITIALS T)
720873

721-
(CL:DEFVAR *REPLACE-OLD-EDIT-DATES* T
722-
"NIL or T; if NIL, old edit dates will not be replaced")
874+
(RPAQ? *REPLACE-OLD-EDIT-DATES* NIL)
723875

724876
(MOVD? 'EDITDATE 'TTY/EDITDATE)
725877

878+
879+
880+
(* ; "Moved from FILEPKG")
881+
882+
883+
(RPAQQ EDITDATE-ARGLIST-DEFINERS (FUNCTIONS TYPES))
884+
885+
(RPAQQ EDITDATE-NAME-DEFINERS (STRUCTURES VARIABLES))
886+
(DECLARE%: DOEVAL@COMPILE DONTCOPY
887+
888+
(GLOBALVARS EDITDATE-ARGLIST-DEFINERS EDITDATE-NAME-DEFINERS)
889+
)
890+
726891
(RPAQ? COMMON-SOURCE-MANAGER-TYPES '(FUNCTIONS VARIABLES STRUCTURES TYPES SETFS OPTIMIZERS))
727892

728893
(PUTPROPS EDITINTERFACE FILETYPE CL:COMPILE-FILE)
@@ -736,11 +901,11 @@ Copyright (c) 1986-1988, 1990-1991 by Venue & Xerox Corporation.
736901
)
737902
(PUTPROPS EDITINTERFACE COPYRIGHT ("Venue & Xerox Corporation" 1986 1987 1988 1990 1991))
738903
(DECLARE%: DONTCOPY
739-
(FILEMAP (NIL (3710 10009 (ED 3710 . 10009)) (10011 13987 (INSTALL-PROTOTYPE-DEFN 10011 . 13987)) (
740-
13988 30771 (EDITDEF.FNS 13998 . 15334) (EDITF 15336 . 16216) (EDITFB 16218 . 17066) (EDITFNS 17068 .
741-
18388) (EDITLOADFNS? 18390 . 22190) (EDITMODE 22192 . 24202) (EDITP 24204 . 24715) (EDITV 24717 .
742-
25356) (DC 25358 . 26039) (DF 26041 . 27083) (DP 27085 . 28169) (DV 28171 . 28743) (EDITPROP 28745 .
743-
28964) (EF 28966 . 29295) (EP 29297 . 29480) (EV 29482 . 29661) (EDITE 29663 . 30541) (EDITL 30543 .
744-
30769)) (31121 37193 (NEW/EDITDATE 31131 . 31353) (FIXEDITDATE 31355 . 33197) (EDITDATE? 33199 . 34377
745-
) (EDITDATE 34379 . 35196) (SETINITIALS 35198 . 37191)))))
904+
(FILEMAP (NIL (4145 10444 (ED 4145 . 10444)) (10446 14422 (INSTALL-PROTOTYPE-DEFN 10446 . 14422)) (
905+
14423 31206 (EDITDEF.FNS 14433 . 15769) (EDITF 15771 . 16651) (EDITFB 16653 . 17501) (EDITFNS 17503 .
906+
18823) (EDITLOADFNS? 18825 . 22625) (EDITMODE 22627 . 24637) (EDITP 24639 . 25150) (EDITV 25152 .
907+
25791) (DC 25793 . 26474) (DF 26476 . 27518) (DP 27520 . 28604) (DV 28606 . 29178) (EDITPROP 29180 .
908+
29399) (EF 29401 . 29730) (EP 29732 . 29915) (EV 29917 . 30096) (EDITE 30098 . 30976) (EDITL 30978 .
909+
31204)) (31556 45142 (NEW/EDITDATE 31566 . 31788) (FIXEDITDATE 31790 . 39177) (EDITDATE? 39179 . 41888
910+
) (EDITDATE 41890 . 43145) (SETINITIALS 43147 . 45140)))))
746911
STOP

sources/EDITINTERFACE.LCOM

924 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)