Skip to content

Commit 5ad5083

Browse files
authored
GREP: avoids tedit-file formatting, font change chars in Lisp source files, adds TGREP (#1513)
* GREP: avoids tedit-file formatting, font change chars in Lisp source files, adds TGREP * Oops, TAB is not a fontchange character * Updated documentation GREP.TEDIT * Avoids EXPORTS.ALL by doing SYSREC1 * Don't change the outcharfn * Make it work on Tedit files * Print out the filename instead of the stream for Tedit files
1 parent 8e07e25 commit 5ad5083

File tree

3 files changed

+67
-35
lines changed

3 files changed

+67
-35
lines changed

lispusers/GREP

Lines changed: 67 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
22

3-
(FILECREATED "19-Jul-2022 22:26:08" 
4-
{DSK}<Users>kaplan>Local>medley3.5>working-medley>lispusers>GREP.;11 4725
3+
(FILECREATED "16-Mar-2024 11:16:38" {WMEDLEY}<lispusers>GREP.;31 6115
54

6-
:CHANGES-TO (FNS DOGREP)
5+
:EDIT-BY rmk
76

8-
:PREVIOUS-DATE "26-Jun-2022 14:36:21"
9-
{DSK}<Users>kaplan>Local>medley3.5>working-medley>lispusers>GREP.;9)
7+
:CHANGES-TO (FNS DOGREP)
108

9+
:PREVIOUS-DATE "15-Mar-2024 16:28:09" {WMEDLEY}<lispusers>GREP.;29)
1110

12-
(* ; "
13-
Copyright (c) 1984-1986 by Xerox Corporation.
14-
")
1511

1612
(PRETTYCOMPRINT GREPCOMS)
1713

18-
(RPAQQ GREPCOMS ((FNS DOGREP GREP PHONE)
19-
(INITVARS (PHONELISTFILES))))
14+
(RPAQQ GREPCOMS [(FNS DOGREP GREP TGREP)
15+
(P (MOVD? 'NILL 'TEDIT.FORMATTEDFILEP))
16+
(COMS (FNS PHONE)
17+
(INITVARS (PHONELISTFILES])
2018
(DEFINEQ
2119

2220
(DOGREP
2321
[LAMBDA (STRS FILES OUTSTREAM)
2422

23+
(* ;; "Edited 16-Mar-2024 11:16 by rmk")
24+
25+
(* ;; "Edited 20-Jan-2024 13:12 by rmk")
26+
2527
(* ;; "Edited 19-Jul-2022 22:26 by rmk")
2628

2729
(* ;; "Edited 26-Jun-2022 14:36 by rmk")
28-
29-
(* ;; "Edited 18-Jun-2022 10:38 by rmk: Search for linebreaks directly, without calling BFILEPOS or FILEPOS just for EOL character. Also now compatible with external formats (if FFILEPOS is), and upgraded to full directory specification")
30+
(* Newman "14-May-86 08:04")
3031
(* Newman "14-May-86 08:04")
3132

3233
(* ;;; "Originally coded by Larry Masinter.")
@@ -46,58 +47,89 @@ Copyright (c) 1984-1986 by Xerox Corporation.
4647
(STREAM (OR (FINDFILE FILES T)
4748
FILES)
4849
:DIRECTION :INPUT)
49-
(bind FOUND for STR inside STRS first (SETFILEINFO STREAM 'ENDOFSTREAMOP
50-
(FUNCTION NILL))
50+
(for STR FOUND FILENAME inside STRS first (SETQ FILENAME (FULLNAME STREAM))
51+
(CL:WHEN (TEDIT.FORMATTEDFILEP STREAM)
52+
[SETQ STREAM (OPENTEXTSTREAM
53+
STREAM NIL NIL NIL
54+
'(OBJECTBYTE 0])
55+
(SETFILEINFO STREAM 'ENDOFSTREAMOP
56+
(FUNCTION NILL))
5157
do (SETFILEPTR STREAM 0)
52-
(bind POS while (SETQ POS (FFILEPOS STR STREAM NIL NIL NIL NIL UPPERCASEARRAY))
53-
do (OR FOUND (PROGN (PRINTOUT OUTSTREAM T .FONT COMMENTFONT "(from "
54-
(FULLNAME STREAM)
55-
")" .FONT DEFAULTFONT T)
56-
(SETQ FOUND T)))
58+
(bind POS STARTPOS while (SETQ POS (FFILEPOS STR STREAM NIL NIL NIL NIL
59+
UPPERCASEARRAY))
60+
do (CL:UNLESS FOUND
61+
(PRINTOUT OUTSTREAM T T .FONT BOLDFONT "(from " FILENAME ")" .FONT
62+
DEFAULTFONT T)
63+
(SETQ FOUND T))
5764

5865
(* ;; "Copying from the beginning of this line. Originally this used BFILEPOS (backwards FILEPOS?), which did repeated calls to forward FFILEPOS in what appears to be a binary set of probes. But FFILEPOS is really SLOW-POS for a single character, and the last line-start is presumaby not that far back. So just walk backwards.")
5966

60-
(COPYCHARS STREAM OUTSTREAM (DO (SELCHARQ (\BACKCCODE.EOLC STREAM
61-
'ANY)
62-
(EOL (\INCCODE.EOLC STREAM)
63-
(RETURN (GETFILEPTR STREAM)))
64-
(NIL (RETURN 0))
65-
NIL))
66-
POS)
67+
(SETQ STARTPOS (DO (SELCHARQ (\BACKCCODE.EOLC STREAM 'ANY)
68+
(EOL (\INCCODE.EOLC STREAM)
69+
(RETURN (GETFILEPTR STREAM)))
70+
(NIL (RETURN 0))
71+
NIL)))
72+
(FOR I C FROM 1 TO (IDIFFERENCE POS STARTPOS)
73+
DO (SETQ C (\INCCODE.EOLC STREAM 'ANY))
74+
(CL:UNLESS (ILESSP C (CHARCODE TAB))
75+
(PRINTCCODE C OUTSTREAM)))
6776
(DSPFONT BOLDFONT OUTSTREAM)
6877
(COPYCHARS STREAM OUTSTREAM POS (ADD POS (NCHARS STR)))
6978
(DSPFONT DEFAULTFONT OUTSTREAM)
7079

7180
(* ;; "Copying to the end of this line (or end of file)")
7281

73-
(BIND C DO (SELCHARQ (SETQ C (\INCCODE.EOLC STREAM 'ANY))
82+
[BIND C DO (SELCHARQ (SETQ C (\INCCODE.EOLC STREAM 'ANY))
7483
((EOL NIL)
7584
(RETURN))
76-
(PRINTCCODE C OUTSTREAM)))
85+
(CL:UNLESS (ILESSP C (CHARCODE TAB))
86+
(PRINTCCODE C OUTSTREAM]
7787
(TERPRI OUTSTREAM])
7888

7989
(GREP
8090
[LAMBDA (STRS FILES OUTSTREAM)
8191

82-
(* ;; "Edited 26-Jun-2022 13:28 by rmk: added OUTSTREAM")
92+
(* ;; "Edited 14-Oct-2023 14:43 by rmk")
8393

84-
(* ;; "Edited 26-Jun-2022 13:25 by rmk")
94+
(* ;; "Edited 1-Sep-2023 00:16 by rmk")
95+
96+
(* ;; "Edited 23-Jul-2023 19:55 by rmk")
8597

86-
(* ;; "Edited 18-Jun-2022 09:50 by rmk")
98+
(* ;; "Edited 26-Jun-2022 13:28 by rmk: added OUTSTREAM")
8799

88-
(CL:UNLESS OUTSTREAM (SETQ OUTSTREAM T)) (* lmm " 1-Apr-85 15:27")
100+
(* ;; "Edited 26-Jun-2022 13:25 by rmk")
101+
(* lmm " 1-Apr-85 15:27")
102+
(* lmm " 1-Apr-85 15:27")
89103
(RESETLST
104+
[SELECTQ OUTSTREAM
105+
(NIL (SETQ OUTSTREAM T))
106+
(T)
107+
(CL:UNLESS (GETSTREAM OUTSTREAM 'OUTPUT T)
108+
[RESETSAVE (SETQ OUTSTREAM (OPENSTREAM OUTSTREAM 'OUTPUT 'NEW))
109+
`(PROGN (CLOSEF? OLDVALUE])]
90110
[RESETSAVE NIL `(PROGN (DSPFONT ,(DSPFONT NIL OUTSTREAM)
91111
,OUTSTREAM]
92-
(DOGREP STRS FILES T OUTSTREAM))])
112+
[RESETSAVE (LINELENGTH T OUTSTREAM)
113+
`(PROGN (LINELENGTH OLDVALUE ,OUTSTREAM]
114+
(DOGREP STRS FILES OUTSTREAM)
115+
OUTSTREAM)])
116+
117+
(TGREP
118+
[LAMBDA (STRS FILES) (* ; "Edited 20-Jan-2024 14:14 by rmk")
119+
(TEXTSTREAM (TEDIT (GREP STRS FILES (OPENTEXTSTREAM))
120+
'TGREP NIL '(READONLY T])
121+
)
122+
123+
(MOVD? 'NILL 'TEDIT.FORMATTEDFILEP)
124+
(DEFINEQ
93125

94126
(PHONE
95127
[LAMBDA (NAME) (* lmm " 5-Mar-86 12:14")
96128
(GREP NAME (OR PHONELISTFILES (PROMPTFORWORD "Name of directory file: "])
97129
)
98130

99131
(RPAQ? PHONELISTFILES )
100-
(PUTPROPS GREP COPYRIGHT ("Xerox Corporation" 1984 1985 1986))
101132
(DECLARE%: DONTCOPY
102-
(FILEMAP (NIL (518 4610 (DOGREP 528 . 3944) (GREP 3946 . 4423) (PHONE 4425 . 4608)))))
133+
(FILEMAP (NIL (496 5830 (DOGREP 506 . 4544) (GREP 4546 . 5596) (TGREP 5598 . 5828)) (5868 6063 (PHONE
134+
5878 . 6061)))))
103135
STOP

lispusers/GREP.LCOM

576 Bytes
Binary file not shown.

lispusers/GREP.TEDIT

326 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)