From eb7a29822f9d96c1dcc8f85994e4a6526cd5c53f Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Tue, 16 Sep 2025 03:25:24 -0700 Subject: [PATCH] deleting ancient docs --- developer/document/RT-code-format.el | 912 ------------------ developer/document/arg1.el | 78 -- developer/document/arg2.el | 102 -- .../document/error_messages_and_logging.txt | 21 - developer/document/schema.txt | 37 - developer/document/see_also.txt | 4 - 6 files changed, 1154 deletions(-) delete mode 100644 developer/document/RT-code-format.el delete mode 100644 developer/document/arg1.el delete mode 100644 developer/document/arg2.el delete mode 100644 developer/document/error_messages_and_logging.txt delete mode 100644 developer/document/schema.txt delete mode 100644 developer/document/see_also.txt diff --git a/developer/document/RT-code-format.el b/developer/document/RT-code-format.el deleted file mode 100644 index de20fd1..0000000 --- a/developer/document/RT-code-format.el +++ /dev/null @@ -1,912 +0,0 @@ -;; rt-format.el -(require 'cl-lib) - -;;-------------------------------------------------------------------------------- -;; basic types -;; - -;; strn:: (string length) -;; interval:: (base length) -;; source-interval:: (source interval) -;; token:: (parser strn) -;; source-token:: (parser source-interval) - -;; source being operated on is stored as an strn - - ;; rt-format.el - - ;; source being operated on is stored as an strn - - ;; strn:: (string length) - ;; interval:: (base length) - ;; source-interval:: (source interval) - ;; token:: (parser strn) - ;; source-token:: (parser source-interval) - - ;; rt-format.el - - ;; Types stored as lists instead of cons pairs - ;; strn:: (string length) - ;; interval:: (base length) - ;; source-interval:: (source interval) - ;; token:: (parser strn) - ;; source-token:: (parser source-interval) - - (defun rt-unsigned-inntegerp (n) - "Return t if N is a non-negative integer." - (and - (integerp n) - (>= n 0) - )) - -(defun rt-args-process (function args arg-specs) - "Process ARGS according to ARG-SPECS. -Returns the processed ARGS list. - -ARG-SPECS is a list where each element is an argument specification: - - For required arguments: (TYPEP MESSAGE) - - For optional arguments: (DEFAULT TYPEP MESSAGE) - -The function validates the arguments, applies defaults for missing optional arguments, -and returns the list of arguments." - (catch 'exit - - (unless args (throw 'exit nil)) - (unless arg-specs (throw 'exit args)) - - (let - ( - (err-flag nil) - (messages '()) - ) - (unless (listp arg-specs) (push messages "rt-args-process usage error, arg-specs must be a list")) - (unless (listp arg) (push messages "rt-args-process usage error, passed in arg must be a list")) - (when messages (error "%s::\n %s" (symbol-name function) (mapconcat #'identity messages "\n "))) - ) - - ;; process required args - (let - ( - (messages '(cons nil nil)) - (type-messages-last messages) - (args-pt args) - ) - - (let - ( - (spec-list-pt (car args-spec)) ; accessing the required args specs - ) - (unless - (listp specs-list-pt) - (error "%s:: arg-specs missing list of required argument specifications" (symbol-name function)) - ) - - (while specs-list-pt - (if - (not args-pt) - (progn - (setq (cdr type-messages-last) (cons "missing required argument" nil)) - (setq type-messages-last (cdr type-messages-last)) - ) - (let - ( - (spec (car specs-list-pt)) - ) - (if - (not (and (listp spec) (= (length spec) 2))) - (error "%s:: arg-spec malformeded %s" (symbol-name function) (prin1-to-string spec)) - (let - ( - (typep (car spec)) - (message (cadr spec)) - ) - (unless - (funcall typep arg) - (progn - (setq (cdr type-messages-last) (cons message nil)) - (setq type-messages-last (cdr type-messages-last)) - ) - ))))) - (when args-pt (setq args-pt (cdr args-pt))) - (setq specs-list-pt (cdr specs-list-pt)) - )) - - ;; process optional args - (when - (>= (length args-specs) 2) - (let - ( - (spec-list-pt (cadr args-spec)) ; accessing the optional args specs - ) - (while - spec-list-pt - (when - args-pt - (let - ( - (spec (car spec-list-pt)) - ) - (if - (not (and (listp spec) (= (length spec) 3))) - (error "%s:: arg-spec malformeded %s" (symbol-name function) (prin1-to-string spec)) - (let - ( - (defult (car spec)) - (typep (cadr spec)) - (message (caddr spec)) - ) - (unless - (funcall typep arg) - (progn - (setq (cdr type-messages-last) (cons message nil)) - (setq type-messages-last (cdr type-messages-last)) - ) - ))))) - (when args-pt (setq args-pt (cdr args-pt))) - (setq specs-list-pt (cdr specs-list-pt)) - ))) - - ;; print type error messages - (when messages (error "%s::\n %s" (symbol-name function) (mapconcat #'identity messages "\n "))) - )) - - - (defun rt-pad-or-truncate (list target-length &optional padding-value) - "Pad or truncate LIST to make it TARGET-LENGTH." - (let - ( - (padding-value (or padding-value nil)) - ) - (cond - ((< (length list) target-length) - (while (< (length list) target-length) - (setq list (append list (list padding-value)))) - list) - - ((> (length list) target-length) - (cl-subseq list 0 target-length)) - - (t - list - ) - ))) - - (when nil - (let* - ( - (list (list 1 2 3)) - (list-longer (rt-pad-or-truncate list 5)) - (list-shorter (rt-pad-or-truncate list 1)) - ) - (message "%s" (prin1-to-string list-longer)) - (message "%s" (prin1-to-string list-shorter)) - ;;(1 2 3 nil nil) - ;;(1) - ) - ) - - - (defun rt-strn-make (&rest args) - - ;; argument guards - (unless (>= (length args) 1) (error "rt-strn-make requires at least a string argument.")) - (let - ( - (arg-types `( - (#'stringp "Argument 0 must be a string.") - (#'rt-unsigned-integerp "Argument 1 must be an unsigned integer.") - ))) - (rt-args-types #'rt-strn-make args arg-types) - ) - - (let - ( - (arg-defaults `( - (length (car args)) - ))) - (setq args (rt-defaults args 1 arg-defaults)) - ) - - ;; processing - (let - ( - (string (nth 0 args)) - (length (nth 1 args)) - ) - (list string length) - ) - ) - - - (when nil - (progn - (rt-strn-make 3 "abc") - ;; if: Wrong type argument: rt-strn-make, ((stringp string) (rt-unsigned-inntegerp length)) - (rt-strn-make "abc" 4 5 6) - (rt-strn-make "abc" 4) - ) - ) - - (defun rt-strnp (strn) - (and - (listp strn) - (= (length strn 2)) - (stringp (car strn)) - (rt-unsigned-inntegerp (cadr strn)) - )) - - - (defun rt-interval-make (base length) - (unless - (and - (rt-unsigned-inntegerp base) - (rt-unsigned-inntegerp length) - ) - (signal 'wrong-type-argument '(rt-interval-make ((rt-unsigned-inntegerp base) (rt-unsigned-inntegerp length)))) - ) - (list base length)) - - (defun rt-source-interval-make (source base length) - (unless - (and - (stringp source) - (rt-unsigned-inntegerp base) - (rt-unsigned-inntegerp length) - ) - (signal 'wrong-type-argument '(rt-source-interval-make ((stringp source) (rt-unsigned-inntegerp base) (rt-unsigned-inntegerp length)))) - ) - (list source (rt-interval-make base length))) - - (defun rt-token-make (parser string length) - (unless - (and - (symbolp parser) - (stringp string) - (rt-unsigned-inntegerp length) - ) - (signal 'wrong-type-argument '(rt-token-make ((symbolp parser) (stringp string) (rt-unsigned-inntegerp length)))) - ) - (list parser (rt-strn-make string length))) - - (defun rt-source-token-make (parser source base length) - (unless - (and - (symbolp parser) - (stringp source) - (rt-unsigned-inntegerp base) - (rt-unsigned-inntegerp length) - ) - (signal 'wrong-type-argument '(rt-source-token-make ((symbolp parser) (stringp source) (rt-unsigned-inntegerp base) (rt-unsigned-inntegerp length)))) - ) - (list parser (rt-source-interval-make source base length))) - - (defmacro rt-strn-deconstruct (args &rest body) - (unless - (and - (listp args) - (= (length args) 3) - ) - (signal 'wrong-number-of-arguments - `(rt-strn-deconstruct - "Expected 3 arguments (strn, string, length), but got: ,args"))) - (let - ( - (strn (nth 0 args)) - (string (nth 1 args)) - (length (nth 2 args)) - ) - `(let - ( - (,string (nth 0 ,strn)) - (,length (nth 1 ,strn)) - ) - ,@body - ))) - - (defmacro rt-interval-deconstruct (args &rest body) - (unless - (and (listp args) (= (length args) 3)) - (signal 'wrong-number-of-arguments - `(rt-interval-deconstruct - "Expected 3 arguments (interval, base, length), but got: ,args"))) - (let - ( - (interval (nth 0 args)) - (base (nth 1 args)) - (length (nth 2 args)) - ) - `(let - ( - (,base (nth 0 ,interval)) - (,length (nth 1 ,interval)) - ) - ,@body - ))) - - (defmacro rt-source-interval-deconstruct (args &rest body) - (unless - (and (listp args) (= (length args) 4)) - (signal 'wrong-number-of-arguments - `(rt-source-interval-deconstruct - "Expected 4 arguments (source-interval, source, base, length), but got: ,args"))) - (let - ( - (source-interval (nth 0 args)) - (source (nth 1 args)) - (base (nth 2 args)) - (length (nth 3 args)) - ) - `(let - ( - (,source (nth 0 ,source-interval)) - ) - (rt-interval-deconstruct ((nth 1 ,source-interval) ,base ,length) - ,@body - ) - ))) - - (defmacro rt-token-deconstruct (args &rest body) - (unless - (and (listp args) (= (length args) 4)) - (signal 'wrong-number-of-arguments - `(rt-token-deconstruct - "Expected 4 arguments (token, parser, string, length), but got: ,args"))) - (let - ( - (token (nth 0 args)) - (parser (nth 1 args)) - (string (nth 2 args)) - (length (nth 3 args)) - ) - `(let - ( - (,parser (nth 0 ,token)) - ) - (rt-strn-deconstruct ((nth 1 ,token) ,string ,length) - ,@body - ) - ))) - - (defmacro rt-source-token-deconstruct (args &rest body) - (unless - (and (listp args) (= (length args) 5)) - (signal 'wrong-number-of-arguments - `(rt-source-token-deconstruct - "Expected 5 arguments (source-token, parser, source, base, length), but got: ,args"))) - (let - ( - (source-token (nth 0 args)) - (parser (nth 1 args)) - (source (nth 2 args)) - (base (nth 3 args)) - (length (nth 4 args)) - ) - `(let - ( - (,parser (nth 0 ,source-token)) - ) - (rt-source-interval-deconstruct ((nth 1 ,source-token) ,source ,base ,length) - ,@body - ) - ))) - - (defun rt-strn-to-string (strn) - (rt-strn-deconstruct (strn string length) - (format - "(rt-strn-make \"%s\" %d)" - string length - ) - )) - - (defun rt-interval-to-string (interval) - (rt-interval-deconstruct (interval base length) - (format - "(rt-interval-make %d %d)" - base length - ) - )) - - (defun rt-source-interval-to-string (source-interval) - (rt-source-interval-deconstruct (source-interval source base length) - (format - "(rt-source-interval-make \"%s\" %d %d)" - source base length - ) - )) - - (defun rt-token-to-string (token) - (rt-token-deconstruct (token parser string length) - (format - "(rt-token-make '%s \"%s\" %d)" - (symbol-name parser) string length - ) - )) - - (defun rt-source-token-to-string (source-token) - (rt-source-token-deconstruct (source-token parser source base length) - (format - "(rt-source-token-make '%s \"%s\" %d %d)" - (symbol-name parser) source base length - ) - )) - - ;; examples - (when nil - - (let - ( - (strn (rt-strn-make "1234" 4)) - ) - (message "strn:: %s" (rt-strn-to-string strn)) - ) - - (let - ( - (interval (rt-interval-make 1 8)) - ) - (message "interval:: %s" (rt-interval-to-string interval)) - ) - - (let - ( - (token (rt-token-make 'token "567" 3)) - ) - (message "token:: %s" (rt-token-to-string token)) - ) - - (let* - ( - (source "now is the time for all good AI to come to the aid of their country") - (source-interval (rt-source-interval-make source 11 15)) - ) - (message "source-interval:: %s" (rt-source-interval-to-string source-interval)) - ) - - (let* - ( - (source "now is the time for all good AI to come to the aid of their country") - (source-token (rt-source-token-make 'source-token source 24 28)) - ) - (message "source-token:: %s" (rt-source-token-to-string source-token)) - ) - - ;; strn:: (rt-strn-make "1234" 4) - ;; interval:: (rt-interval-make 1 8) - ;; token:: (rt-token-make 'token "567" 3) - ;; source-interval:: (rt-source-interval-make "now is the time for all good AI to come to the aid of their country" 11 15) - ;; source-token:: (rt-source-token-make 'source-token "now is the time for all good AI to come to the aid of their country" 24 28) - - ) - -;;--------------------l------------------------------------------------------------ -;; misc -;; - - (defmacro do-strn (args &rest body) - "Iterate over the string in a strn structure. - ARGS should be (strn char index). BODY will be executed for each character in the string. - The index will start at 'start-index' if provided, otherwise from 0." - (unless - (and - (listp args) - (= (length args) 3) - (rt-strnp (car args)) - (symbolp (cadr args)) - (symbolp (caddr args)) - ) - (signal 'wrong-number-of-arguments '(do-strn (rt-strnp symbolp symbolp))) - ) - (let - ( - (strn (car args)) - (char (cadr args)) - (index (caddr args)) - ) - `(rt-strn-deconstruct - (,strn string length) - (let - ( - (,char nil) - (,index (or ,index 0)) - ) - (while (< ,index length) - (setq ,char (aref string ,index)) - ,@body - (setq ,index (1+ ,index)) - ))))) - - - ;; for example - (when nil - - (let - ( - (s (rt-strn-make "Hello" 5)) - ) - (do-strn (s c i) - (message "Character at index %d: %c" i c) - )) - - ) - ;; Character at index 0: H - ;; Character at index 1: e - ;; Character at index 2: l - ;; Character at index 3: l - ;; Character at index 4: o - - - -;;--------------------l------------------------------------------------------------ -;; parsing helpers -;; - - (defun rt-sort-token-list (token-list) - "Sort tokens by their length field, largest first." - (sort token-list (lambda (a b) (> (cdr a) (cdr b)))) - ) - - ;; for example - (when nil - (let - ( - (example-token-list - '( - ((rt-token-make 'type "apple") . 5) - ((rt-token-make 'type "banana") . 6) - ((rt-token-make 'type "cherry") . 6) - ((rt-token-make 'type "fig") . 3) - ) - ) - (sorted-token-list (rt-sort-token-list example-token-list)) - ) - (message "%s" (prin1-to-string sorted-token-list)) - ;; (((rt-token-make 'type "banana") . 6) ((rt-token-make 'type "cherry") . 6) ((rt-token-make 'type "apple") . 5) ((rt-token-make 'type "fig") . 3)) - )) - - (defun rt-assoc-to-token-list (assoc-list access) - "Given an (.token) or (token.) assoc-list, and an access function for the pair, return a sorted token list." - (let - ( - (result-list (cons nil nil)) - (last-cons nil) - ) - (setq last-cons result-list) - (while assoc-list - (let - ( - (token (funcall access (car assoc-list))) - ) - (setcdr last-cons (cons (cons token (length (cdr token))) nil)) - (setq last-cons (cdr last-cons)) - (setq assoc-list (cdr assoc-list)) - )) - (rt-sort-token-list (cdr result-list)) - )) - - (defun rt-key-list (assoc-list) - "Given a (string.) assoc-list, return a sorted strn list of the keys." - (rt-assoc-to-token-list assoc-list #'car) - ) - - (defun rt-value-list (assoc-list) - "Given a (.string) assoc-list, return a sorted strn list of the values." - (rt-assoc-to-token-list assoc-list #'cdr) - ) - - (defun rt-is-one-of (source base-index token-list) - "Return source-token found at base-index, or nil if no match." - (let - ( - (string (car source)) - (length (cdr source)) - ) - (catch 'found - (dolist - (token token-list) - (rt-token-deconstruct token parser strn-string strn-length - (let - ( - ;; each parser returns source-token of a specific type, otherwise nil - (source-token (funcall parser source base-index)) - ) - (when source-token - (throw 'found source-token)))))))) - - (defun rt-search-forward (source start-index is-a-fn) - "return match to #'is-a-fn, otherwise ni." - (let - ( - (index start-index) - (length (cdr source)) - (token-length nil) - ) - (catch 'found - (while - (< index length) - (setq token-length (funcall is-x-fn source index)) - (when token-length (throw 'found (cons index token-length))) - (setq index (1+ index)) - ) - nil - ))) - - - -;;--------------------l------------------------------------------------------------ -;; enclosure tokens -;; - - ;; enclosure delimiters are tokens possibly of multiple characters - (defvar rt-default-enclosure-pairs - '( - ((rt-token-make #'rt-is-a-opening "{") . (rt-token-make #'rt-is-a-closing "}")) - ((rt-token-make #'rt-is-a-opening "(") . (rt-token-make #'rt-is-a-closing ")")) - ((rt-token-make #'rt-is-a-opening "[") . (rt-token-make #'rt-is-a-closing "]")) - ) - "Association list of default enclosure pairs represented as tokens." - ) - - ;; for example - (when nil - (message "%s" (prin1-to-string (rt-key-list rt-default-enclosure-pairs))) - (message "%s" (prin1-to-string (rt-value-list rt-default-enclosure-pairs))) - ) - ;; (((rt-token-make 'open "{") . 2) ((rt-token-make 'open "(") . 2) ((rt-token-make 'open "[") . 2)) - ;; (((rt-token-make 'close "}") . 2) ((rt-token-make 'close ")") . 2) ((rt-token-make 'close "]") . 2)) - - (defvar rt-opening-token-list - (rt-key-list rt-default-enclosure-pairs) - "Default list of opening tokens represented as token pairs." - ) - - (defvar rt-opening-token-list - (rt-value-list rt-default-enclosure-pairs) - "Default list of opening tokens represented as token pairs." - ) - - (defun rt-is-a-opening (source base-index) - "Return interval for matching opening delimiter, otherwise nil." - (rt-is-one-of source base-index rt-opening-list)) - - (defun rt-is-a-closing (source base-index) - "Return interval for matching closing delimiter, otherwise nil." - (rt-is-one-of source base-index rt-closing-list)) - - (defun rt-is-a-enclosure (source base-index) - (or - (rt-is-a-opening source base-index) - (rt-is-a-closing source base-index) - )) - -;;--------------------l------------------------------------------------------------ -;; other tokens -;; - - (defun rt-is-a-blank-char (char) - (char-equal char ?\s) - ) - - - (defun rt-is-a-blank (source start-index) - "Returns source-token of blank characters, otherwise nil." - (let - ( - (string (car source)) - (length (cdr source)) - (start-index-var start-index) - ) - (dostring (string char index) - - (when - (and (>= index start-index-var) (rt-is-a-blank-char char)) - (setq start-index-var (1+ start-index-var)) - )) - (if (> start-index-var start-index) - (rt-token-make #'rt-is-a-blank string (- start-index-var start-index)) - nil - ))) - - - (defun rt-is-a-blank (source start-index) - "Returns source-token of blank characters, otherwise nil." - (let - ( - (index start-index) - (string (car source)) - (length (cdr source)) - ) - (while - (and - (< index length) - (rt-is-a-blank-char (aref string index)) - ) - (setq index (1+ index)) - ) - (if (> index start-index) - (rt-token-make 'blank string (- index start-index)) - nil - ))) - - (defun rt-is-a-prefix (source) - "Given a string, return the non-zero length up to the first opening enclosure, otherwise nil." - (let - ( - (interval (rt-search-forward source 0 #'rt-is-a-opening)) - ) - (when - interval - (let - ( - (prefix-end (car interval)) - ) - (when - (> prefix-end 0) - end - ))))) - - (defun rt-is-a-stuff (string base-index) - "Given a base index into a string, return nonzero length including non-blank and non-enclosure, otherwise nil." - (let ( - (enclosure-interval (rt-search-forward source 0 #'rt-is-a-enclosure)) - (blank-itnerval (rt-search-forward source 0 #'rt-is-a-blank)) - (enclosure-base 0) - (blank-base 0) - (stuff-end 0) - ) - (when enclosure-interval (setq enclosure-base (car enclosure-interval))) - (when blank-interval (setq blank-base (car blank-interval))) - - (when - (and result (> (car result) 0)) - (cdr result)) - )) - - - (defvar rt-token-types - '( - rt-is-a-prefix - rt-is-a-blank - rt-is-a-opening - rt-is-a-closing - rt-is-a-stuff - ) - "List of functions to recognize different token types, excluding prefix." - ) - - (defun rt-parse-line (line token-types) - "Given a LINE and a TOKEN-TYPES list, return a list of tokens." - (let* - ( - (tokens (cons nil nil)) - (last-cons tokens) - (index 0) - (token-length nil) - (prefix-parser (car token-types)) - (other-parsers (cdr token-types)) - ) - ;; Match prefix once - (setq token-length (funcall prefix-parser line index)) - (when token-length - (setcdr last-cons (cons (list prefix-parser (cons index token-length)) nil)) - (setq last-cons (cdr last-cons)) - (setq index token-length) - ) - ;; Match the rest of the tokens repeatedly - (while (< index (length line)) - (let ((matched nil)) - (dolist (parse-fn other-parsers) - (setq token-length (funcall parse-fn line index)) - (when token-length - (setcdr last-cons (cons (list parse-fn (cons index (+ index token-length))) nil)) - (setq last-cons (cdr last-cons)) - (setq index (+ index token-length)) - (setq matched t) - )) - (unless matched - (setq index (1+ index))))) - (cdr tokens) - )) - - (defun rt-token-list-to-string (line token-list) - "Given a LINE and a TOKEN-LIST, assemble a new string based on the strings referenced in TOKEN-LIST and return it." - (let ((result "")) - (dolist (token token-list) - (let - ( - (start (car (cdr token))) - (end (cdr (cdr token))) - ) - (setq result (concat result (substring line start end))))) - result - )) - - (defun rt-format-lines-in-region (start end) - "Format all lines within the selected region, defined by START and END, according to RT code style." - (interactive "r") - (save-excursion - (goto-char start) - (while - (< (point) end) - (let* - ( - (line-start (line-beginning-position)) - (line-end (line-end-position)) - (line (buffer-substring-no-properties line-start line-end)) - (token-list (rt-parse-line line rt-token-types)) - (formatted-line (rt-token-list-to-string line token-list)) - ) - ;;(message "Before formatting: %s" line) ; Message to show the line before formatting - ;;(message "After formatting: %s" formatted-line) ; Message to show the line after formatting - ;; Replace the line with the formatted version - (delete-region line-start line-end) - (insert formatted-line)) - ;; Move to the beginning of the next line - (forward-line 1) - ))) - -;;-------------------------------------------------------------------------------- -;; format commas -;; - - (defun rt-format-comma (start end) - "Format commas to follow RT code style in the selected region. - Move spaces after a comma to before it, unless followed by a newline." - (interactive "r") ; The "r" prefix allows it to get the start and end of the region - (message "Starting comma formatting...") - (save-excursion - (goto-char start) - ;; Step 1: Find commas with spaces before and after, and move spaces before the comma - (while - (re-search-forward "\\( *\\),\\( +\\)\\([^\\n]\\)" end t) - (let - ( - (leading-spaces (match-string 1)) - (trailing-spaces (match-string 2)) - (after (match-string 3)) - ) - (replace-match (concat trailing-spaces leading-spaces "," after)))) - ) - (message "Comma formatting completed.") - ) - -;;-------------------------------------------------------------------------------- -;; bind formatting to minor mode, trigger formatting on tab -;; - -(defun rt-code-indent-and-format () - "Indent the current line or region and apply all RT code formatting rules." - (interactive) - ;; Step 1: Perform indentation first - (indent-for-tab-command) - - ;; Step 2: Format commas in the selected region or line - (if - (use-region-p) ; Check if a region is active - (rt-format-comma (region-beginning) (region-end)) - (rt-format-comma (line-beginning-position) (line-end-position))) - - ;; Step 3: Parse and format enclosures in the selected region or line - (if - (use-region-p) - (rt-format-lines-in-region (region-beginning) (region-end)) - (rt-format-lines-in-region (line-beginning-position) (line-end-position)))) - - (defvar rt-format-hook nil - "Hook called by `rt-format-mode`." - ) - - (define-minor-mode rt-format-mode - "Minor mode for RT code style formatting." - :lighter " RTFmt" - :keymap (let - ( - (map (make-sparse-keymap)) - ) - (define-key map (kbd "TAB") 'rt-code-indent-and-format) ; Bind TAB to run all formatting rules. - map - ) - (if - rt-format-mode - (run-hooks 'rt-format-hook) - )) - diff --git a/developer/document/arg1.el b/developer/document/arg1.el deleted file mode 100644 index 5e4fda8..0000000 --- a/developer/document/arg1.el +++ /dev/null @@ -1,78 +0,0 @@ -(defun rt-args-process (function args arg-specs) - "Process ARGS according to ARG-SPECS. -Returns the processed ARGS list. - -ARG-SPECS is a list where each element is an argument specification: - - For required arguments: (TYPEP MESSAGE) - - For optional arguments: (DEFAULT TYPEP MESSAGE) - -The function validates the arguments, applies defaults for missing optional arguments, -and returns the list of arguments. If any validations fail, it signals an error -with all accumulated messages." - (let ((error-messages '()) - (processed-args nil) - (last-cons nil) ;; Pointer to the last cons cell of processed-args - (arg-specs-pt arg-specs) ;; Pointer into arg-specs list - (args-pt args)) ;; Pointer into args list - ;; Validate that arg-specs and args are lists - (unless (listp arg-specs) - (error "%s:: arg-specs must be a list" (symbol-name function))) - (unless (listp args) - (error "%s:: args must be a list" (symbol-name function))) - - ;; Process each argument specification - (while arg-specs-pt - (let* ((spec (car arg-specs-pt)) - (required (eq (length spec) 2)) ;; If spec has 2 items, it's required - (default (when (not required) (nth 0 spec))) - (typep (if required (nth 0 spec) (nth 1 spec))) - (message (if required (nth 1 spec) (nth 2 spec))) - (arg (if args-pt (car args-pt) nil))) - ;; Determine if we need to use the provided arg or apply default - (if args-pt - ;; Argument is provided - (progn - ;; Validate the provided argument - (unless (funcall typep arg) - (push message error-messages)) - ;; Add the argument to processed-args - (let ((new-cons (cons arg nil))) - (if (null processed-args) - (setq processed-args new-cons) - (setcdr last-cons new-cons)) - (setq last-cons new-cons)) - ;; Advance the args pointer - (setq args-pt (cdr args-pt))) - ;; Argument is not provided - (if required - ;; Missing required argument - (push message error-messages) - ;; Optional argument, apply default - (let ((default-value (if (functionp default) - (funcall default processed-args) - default))) - ;; Validate the default value - (unless (funcall typep default-value) - (push message error-messages)) - ;; Add the default value to processed-args - (let ((new-cons (cons default-value nil))) - (if (null processed-args) - (setq processed-args new-cons) - (setcdr last-cons new-cons)) - (setq last-cons new-cons))))) - ;; Move to the next spec - (setq arg-specs-pt (cdr arg-specs-pt)))) - - ;; Check for extra arguments - (when args-pt - (push "Too many arguments provided." error-messages)) - - ;; Report errors if any - (when error-messages - (error - (concat - "Errors in " (symbol-name function) ":\n" - (mapconcat #'identity (reverse error-messages) "\n")))) - - ;; Return the processed arguments - processed-args)) diff --git a/developer/document/arg2.el b/developer/document/arg2.el deleted file mode 100644 index 4e41b75..0000000 --- a/developer/document/arg2.el +++ /dev/null @@ -1,102 +0,0 @@ -(defun rt-args-process (function args arg-specs) - "Process ARGS according to ARG-SPECS. -Returns the processed ARGS list. - -ARG-SPECS is a list where each element is an argument specification: - - For required arguments: (TYPEP MESSAGE) - - For optional arguments: (DEFAULT TYPEP MESSAGE) - -The function validates the arguments, applies defaults for missing optional arguments, -and returns the list of arguments." - (catch 'exit - - ;; Ensure args and arg-specs are provided - (unless (listp args) (throw 'exit nil)) - (unless arg-specs (throw 'exit args)) - - ;; Check for usage errors - (let ((messages '())) - (unless (listp arg-specs) - (push "rt-args-process usage error: arg-specs must be a list" messages)) - (unless (listp args) - (push "rt-args-process usage error: args must be a list" messages)) - (when messages - (error "%s::\n %s" (symbol-name function) - (mapconcat #'identity messages "\n ")))) - - ;; Initialize variables - (let ((processed-args nil) - (last nil) ; Pointer to the last cons cell in processed-args - (error-messages '()) - (args-pt args)) - - ;; Process required arguments - (let ((required-specs (car arg-specs))) - (unless (listp required-specs) - (error "%s:: arg-specs missing list of required argument specifications" - (symbol-name function))) - (dolist (spec required-specs) - (let ((typep (nth 0 spec)) - (message (nth 1 spec)) - (arg (if args-pt (car args-pt) nil))) - (if arg - (progn - ;; Type check the argument - (unless (funcall typep arg) - (push message error-messages)) - ;; Add to processed-args - (let ((new-cons (cons arg nil))) - (if (null processed-args) - (setq processed-args new-cons) - (setcdr last new-cons)) - (setq last new-cons)) - ;; Move to the next argument - (setq args-pt (cdr args-pt))) - ;; Missing required argument - (push (concat "Missing required argument: " message) error-messages))))) - - ;; Process optional arguments - (let ((optional-specs (cadr arg-specs))) - (dolist (spec optional-specs) - (let ((default (nth 0 spec)) - (typep (nth 1 spec)) - (message (nth 2 spec)) - (arg (if args-pt (car args-pt) nil))) - (if arg - (progn - ;; Type check the argument - (unless (funcall typep arg) - (push message error-messages)) - ;; Add to processed-args - (let ((new-cons (cons arg nil))) - (if (null processed-args) - (setq processed-args new-cons) - (setcdr last new-cons)) - (setq last new-cons)) - ;; Move to the next argument - (setq args-pt (cdr args-pt))) - ;; No argument provided, apply default - (let ((default-value (if (functionp default) - (funcall default processed-args) - default))) - ;; Type check the default value - (unless (funcall typep default-value) - (push (concat "Default value error: " message) error-messages)) - ;; Add to processed-args - (let ((new-cons (cons default-value nil))) - (if (null processed-args) - (setq processed-args new-cons) - (setcdr last new-cons)) - (setq last new-cons))))))) - - ;; Check for extra arguments - (when args-pt - (push "Too many arguments provided." error-messages)) - - ;; Print error messages if any - (when error-messages - (error "%s::\n %s" (symbol-name function) - (mapconcat #'identity (reverse error-messages) "\n "))) - - ;; Return the processed arguments - processed-args))) diff --git a/developer/document/error_messages_and_logging.txt b/developer/document/error_messages_and_logging.txt deleted file mode 100644 index 825730d..0000000 --- a/developer/document/error_messages_and_logging.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Phased Logging and Reporting Plan - -## Build-Up/Initialization Phase -- Minimal functionality is operational during this phase. -- Use `fprintf(stderr, ...)` for all error reporting. - - This method is reliable and independent of external systems like the database or server infrastructure. -- Keep this phase simple and robust to surface critical errors immediately to the developer or administrator. - -## Operational Phase -- Once the system is confirmed to be running: - - **Database-Related Errors**: - - Logged into the database events table to reflect internal operational issues. - - May also generate secondary reports to the application if the issue affects its logic (e.g., query failures). - - **Application-Related Errors**: - - Logged into the application log using `Server·report`. - - Provide user-facing insights about the application state, including database issues reported to the app. - -## Tear-Down Phase -- During shutdown or teardown: - - Revert to `fprintf(stderr, ...)` for simplicity and reliability. - - Avoid relying on the database as its infrastructure may no longer be functional. diff --git a/developer/document/schema.txt b/developer/document/schema.txt deleted file mode 100644 index f4bea44..0000000 --- a/developer/document/schema.txt +++ /dev/null @@ -1,37 +0,0 @@ -We are implementing the subu project. Accordingly, master users can make and -delete subu users. Once a subu is made, a master user can call the 'subu' -command to cause a shell to be logged into it. (We currently have a bash script -for doing this.) There will also be a function for creating the users on a new -system, and various check functions. This database is for supporting this functionality. - -What do you think of this schema design? - -List:: id | text - constant lists: - db_property_list: name major_version minor_version - event_list: schema_loaded server_shutdown .. - shell_list: /sbin/nologin /bin/bash /bin/sh - system_resource_list: sudo audio video - user_type: fixed_id/dynamic_id private/shared - -Data Table:: - db_property: db_property_list(id) | type | property value or NULL - db_event: Z | db_event_list(id) - user: id | login gid | name | home_directory | shell | parent - share: user(id) | other_user(id) | permissions - system_resource: user(id) | system_resource_list(id) - -notes:: - -1. Z type is the date and time given in UTC, accurate to millisecond or whatever - is convenient high resolution for the system. - -2. login gid is the same as uid. - -3. If there are no shares for a given user, there is no group access for the - given user,i.e. g-rwx. If shares are allowed then the given user directory - will have g+rx. Any other sharing permissions are up to the given user to set. - -4. A given user directory is only allowed to be shared among subu brothers. Each - sharer is made a member of the give user's corresponding group. - diff --git a/developer/document/see_also.txt b/developer/document/see_also.txt deleted file mode 100644 index 8236284..0000000 --- a/developer/document/see_also.txt +++ /dev/null @@ -1,4 +0,0 @@ - -See also the documents in the `resource` project `document` directory. - - -- 2.20.1