Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 66 additions & 25 deletions library/tedit/TEDIT-ABBREV
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)

(FILECREATED " 5-Sep-2025 18:50:19" 
{DSK}<Users>kaplan>Local>medley3.5>working-medley>library>tedit>TEDIT-ABBREV.;29 17935
(FILECREATED " 1-Dec-2025 20:26:49" {DSK}<home>matt>Interlisp>medley>library>tedit>TEDIT-ABBREV.;4 20152

:EDIT-BY rmk
:EDIT-BY "mth"

:CHANGES-TO (VARS TEDIT-ABBREVCOMS)
:CHANGES-TO (FNS \TEDIT.ABBREV.EXPAND \TEDIT.ABBREV.PARSE \TEDIT.EXPAND.DATE \TEDIT.TRY.ABBREV)

:PREVIOUS-DATE " 5-Sep-2025 12:24:55"
{DSK}<Users>kaplan>Local>medley3.5>working-medley>library>tedit>TEDIT-ABBREV.;28)
:PREVIOUS-DATE " 1-Dec-2025 12:27:11"
{DSK}<home>matt>Interlisp>medley>library>tedit>TEDIT-ABBREV.;3)


(PRETTYCOMPRINT TEDIT-ABBREVCOMS)
Expand Down Expand Up @@ -47,7 +46,9 @@
("+" "0,261" PlusMinus)
("x" "0,264" Times)
("/" "0,270" Divide)
("=" "357,121")
("lra" "357,121" (* ;
 "U+21C6 Leftwards Arrow Over Rightwards Arrow (%"lra%" is %"left-right-arrow%")")
)
("p" "0,266" Paragraph)
("r" "0,322" Register)
("t" "0,324" Trademark)
Expand All @@ -68,15 +69,21 @@
("exist" "357,264")
("def" "357,162")
("compose" "357,147")
("!" "0,241" (* ; "Inverted !"))
("?" "0,277" (* ; "Inverted ?"))
("u" "0,265" MicroSign)
("<<" "0,253" (* ; "Left double guillemet"))
(">>" "0,273" (* ; "Right double guillemet"))
("DATE" \TEDIT.EXPAND.DATE)
(">>DATE<<" \TEDIT.EXPAND.DATE])
(DEFINEQ

(\TEDIT.ABBREV.EXPAND
[LAMBDA (TSTREAM TEXTOBJ SEL) (* ; "Edited 20-Apr-2025 23:30 by rmk")
[LAMBDA (TSTREAM TEXTOBJ SEL) (* ; "Edited 1-Dec-2025 20:14 by mth")
(* ; "Edited 20-Apr-2025 23:30 by rmk")
(* ; "Edited 20-Mar-2025 21:52 by rmk")
(* ; "Edited 30-May-91 19:27 by jds")
(* ; "Expand an abbvreviation")
(* ; "Expand an abbreviation")
(LET ((CANDIDATES (\TEDIT.ABBREV.PARSE TSTREAM SEL))
CAND EXPANSION)

Expand All @@ -96,7 +103,12 @@
(L-CASE (CAR C))
TSTREAM]
(if EXPANSION
then (\TEDIT.UPDATE.SEL SEL (CADR CAND)
then
(* ;;
 "First, remove any old messages, e.g., previous %"No abbreviation to expand%" errors")

(TEDIT.PROMPTPRINT TSTREAM "" T)
(\TEDIT.UPDATE.SEL SEL (CADR CAND)
(CADDR CAND)
'RIGHT
'NORMAL) (* ; "Set the target")
Expand All @@ -107,7 +119,8 @@
else (TEDIT.PROMPTPRINT TSTREAM "No abbreviation to expand" T])

(\TEDIT.ABBREV.PARSE
[LAMBDA (TSTREAM SEL) (* ; "Edited 11-Aug-2025 14:40 by rmk")
[LAMBDA (TSTREAM SEL) (* ; "Edited 1-Dec-2025 20:18 by mth")
(* ; "Edited 11-Aug-2025 14:40 by rmk")
(* ; "Edited 7-Aug-2025 12:50 by rmk")
(* ; "Edited 24-Apr-2025 23:45 by rmk")
(* ; "Edited 28-Mar-2025 10:11 by rmk")
Expand All @@ -117,15 +130,15 @@
(* ;; "This produces candidate abbreviation-strings by parsing the characters around the point. Each candidate is returned as a list (KEY STARTCH# LEN).")

(* ;;
 "It first backs up over any spaces to find the anchor position. The candidates then include")
 "It first backs up over any spaces to find the anchor position. The candidates then include")

(* ;; " The immediately preceding singleton character, if a point selection")

(* ;; " The remaining (after backing up) characters of the selection.")

(* ;; " The word that contains the caret (backwards and forwards)")

(* ;; " If the character before a candidate C is a comma, then the word before W before the comma (without or without \) is extracted, and W,C is is added to the list (a possible charname).")
(* ;; "If the character before a candidate C is a comma, then the word before W before the comma (without or without \) is extracted, and W,C is is added to the list (a possible charname).")

(* ;; "If the character before a candidate C is \, the \ is included in the replacement span, and \C is also added to the list (Tex style)")

Expand Down Expand Up @@ -173,7 +186,10 @@
FIRST# LEN))) (* ; "Extend if a ,")
[for C KEY END in CANDIDATES
do
(* ;; "Comma for MCCS character names, - and / - for internal punctuation (3/4 EMDASH). Adjacent character must be text")
(* ;;
 "Comma for MCCS character names, - and / - for internal punctuation (3/4 EMDASH). ")

(* ;; "Adjacent character must be text")

(if [AND (MEMB (\TEDIT.NTHCHARCODE TSTREAM (SUB1 (CADR C)))
(CHARCODE (%, / -)))
Expand Down Expand Up @@ -234,14 +250,23 @@
" " DAY ", " YEAR])

(\TEDIT.TRY.ABBREV
[LAMBDA (KEY TSTREAM) (* ; "Edited 5-Sep-2025 12:24 by rmk")
[LAMBDA (KEY TSTREAM) (* ; "Edited 1-Dec-2025 20:26 by mth")
(* ; "Edited 5-Sep-2025 12:24 by rmk")
(* ; "Edited 20-Mar-2025 21:52 by rmk")
(* ; "Edited 6-Aug-2020 14:41 by rmk:")
(* jds "11-Jul-85 12:46")
(* ; "jds %"11-Jul-85 12:46%"")

(* ;; "Decode the expansion. ")

(* ;; "A string may be a character name, otherwise itself. ")

(* ;;
 "A litatom may be a character name, otherwise, it is a function (if has GETD) to be applied.")

(* ;; "Decode the expansion. A string may be a character name, otherwise itself. A litatom is a function to be applied, anything else is evaled. ")
(* ;; "Anything else is EVALed. ")

(LET [(ABBREV (CDR (SASSOC KEY TEDIT.ABBREVS]
(LET ((ABBREV (CDR (SASSOC KEY TEDIT.ABBREVS)))
CH)
(CL:WHEN (LISTP ABBREV) (* ; "Originally stored in the CDR")
(SETQ ABBREV (CAR ABBREV)))
(if (NULL ABBREV)
Expand All @@ -251,21 +276,30 @@
then
(* ;; "Could be a character code")

(LET ((CH (CHARCODE.DECODE ABBREV T)))
(CL:IF CH
(CHARACTER CH)
ABBREV))
(SETQ CH (CHARCODE.DECODE ABBREV T))
(CL:IF CH
(CHARACTER CH)
ABBREV)
elseif (SMALLP ABBREV)
then
(* ;; "Treat a number as a character code.")

(CHARACTER ABBREV)
elseif (AND (LITATOM ABBREV)
(SETQ CH (CHARCODE.DECODE ABBREV T)))
then
(* ;; "A LITATOM character %"code%" (i.e., on CHARACTERNAMES)")

(CHARACTER CH)
elseif (AND (LITATOM ABBREV)
(GETD ABBREV))
then (* ; " A function to be applied.")
(APPLY* ABBREV TSTREAM KEY)
elseif (LISTP ABBREV)
then (* ; "Form in the CADR, now")

(* ;; "Should this have checked (GETD (CAR ABBREV))?")

(EVAL ABBREV)
elseif (AND (SETQ ABBREV (CDR (SASSOC KEY TEDIT.ABBREVS)))
(LITATOM (CAR ABBREV))
Expand Down Expand Up @@ -312,7 +346,9 @@
("+" "0,261" PlusMinus)
("x" "0,264" Times)
("/" "0,270" Divide)
("=" "357,121")
("lra" "357,121" (* ;
 "U+21C6 Leftwards Arrow Over Rightwards Arrow (%"lra%" is %"left-right-arrow%")")
)
("p" "0,266" Paragraph)
("r" "0,322" Register)
("t" "0,324" Trademark)
Expand All @@ -333,9 +369,14 @@
("exist" "357,264")
("def" "357,162")
("compose" "357,147")
("!" "0,241" (* ; "Inverted !"))
("?" "0,277" (* ; "Inverted ?"))
("u" "0,265" MicroSign)
("<<" "0,253" (* ; "Left double guillemet"))
(">>" "0,273" (* ; "Right double guillemet"))
("DATE" \TEDIT.EXPAND.DATE)
(">>DATE<<" \TEDIT.EXPAND.DATE)))
(DECLARE%: DONTCOPY
(FILEMAP (NIL (3630 16182 (\TEDIT.ABBREV.EXPAND 3640 . 5860) (\TEDIT.ABBREV.PARSE 5862 . 13472) (
\TEDIT.EXPAND.DATE 13474 . 14107) (\TEDIT.TRY.ABBREV 14109 . 16180)))))
(FILEMAP (NIL (4248 17832 (\TEDIT.ABBREV.EXPAND 4258 . 6793) (\TEDIT.ABBREV.PARSE 6795 . 14564) (
\TEDIT.EXPAND.DATE 14566 . 15199) (\TEDIT.TRY.ABBREV 15201 . 17830)))))
STOP
Binary file modified library/tedit/TEDIT-ABBREV.LCOM
Binary file not shown.