LISTING FOR >spec>install>1136>emacs-macro-compile COMPILED BY Multics LISP Compiler, Version 2.13c, July 11, 1983 ON 08/20/86 2255.7 mst Wed IN BEHALF OF Martinson.SysMaint.a ;;; *********************************************************** ;;; * * ;;; * Copyright, (C) Honeywell Information Systems Inc., 1982 * ;;; * * ;;; * Copyright (c) 1978 by Massachusetts Institute of * ;;; * Technology and Honeywell Information Systems, Inc. * ;;; * * ;;; *********************************************************** ;;; ;;; ;;; A hairy toy all for show. ;;; The Emacs keyboard macro compiler. ;;; BSG 2/18,24-25/78 (%include e-macros) (declare (special comment-column)) ;;; ;;; Interim grinder. ;;; (defun macomp-output-to-buffer (x) (macomp-bufout-r x nil) ;recurse (new-line)) (defun macomp-bufout-r (x indent) (if (null indent)(setq indent (cur-hpos)) else (whitespace-to-hpos indent)) (cond ((fixp x)(insert-string (decimal-rep x))(insert-string ".")) ((atom x)(insert-string (maknam (explode x)))) ((memq (car x) '(if if-at if-back-at lambda cond let)) (insert-string "(") (insert-string (car x)) (insert-string " ") (macomp-bufout-finish-form (cdr x)(cur-hpos))) ((eq (car x) 'defun) (insert-string "(defun ") (let ((hp (cur-hpos))) (macomp-bufout-r (cadr x) hp) (insert-string " ") (if (null (caddr x)) ;null lambda list (insert-string "()") else (macomp-bufout-r (caddr x) nil)) (new-line) (macomp-bufout-finish-form (cdddr x) hp))) ((and (eq (car x) 'quote)(null (cddr x))) (insert-string "'") (macomp-bufout-r (cadr x)(1+ indent))) ((eq (car x) 'do-forever) (insert-string "(do-forever ") (new-line) (macomp-bufout-finish-form (cdr x)(+ 2 indent))) ((memq (car x) '(prog2 progn)) (insert-string "(") (insert-string (car x)) (insert-string " ") (macomp-bufout-finish-form (cdr x)(cur-hpos))) ((eq (car x) 'prog) (insert-string "(prog ") (let ((hp (cur-hpos))) (macomp-bufout-r (cadr x) hp) (new-line) (do l (cddr x)(cdr l)(null l) (if (atom (car l)) (macomp-bufout-r (car l) 0) (if (> (cur-hpos)(1+ hp))(insert-string " ")) (setq l (cdr l))) (macomp-bufout-r (car l) hp) (if (not (null (cdr l)))(new-line))) (insert-string ")"))) (t (macomp-bufout-random-list (car x)(cdr x) indent)))) (defun macomp-bufout-random-list (the-car the-cdr indent) (insert-string "(") (macomp-bufout-r the-car (1+ indent)) (if (> (+ (cur-hpos) 4) comment-column) (setq indent (if (atom the-car)(+ 2 indent) else (+ 1 indent))) else (if (atom the-car))(setq indent (1+ (cur-hpos))) else (setq indent (1+ indent))) (do l the-cdr (cdr l) nil (if (null l)(insert-string ")")(stop-doing)) (if (atom l) (insert-string " . ") (macomp-bufout-r l nil) (insert-string ")") (stop-doing)) (if (and (> (+ (cur-hpos) 4) comment-column) (or (not (atom (cdr l))) (not (atom (car l))))) (new-line) (whitespace-to-hpos indent) else (if (not (and (back-at '/) )(not (atom (car l))))) (insert-string " "))) (macomp-bufout-r (car l) nil))) (defun macomp-bufout-finish-form (x hp) (do l x (cdr l)(null l) (macomp-bufout-r (car l) hp) (if (not (null (cdr l)))(new-line))) (insert-string ")")) ;;; ;;; The actual displaylist-keyboard-macro to Lisp compiler. ;;; (declare (special macomp-last-cmd macomp-prog-needed-p macomp-default-search-string)) (defun macomp-compile-to-expr (name interp) (setq macomp-last-cmd 'noop macomp-prog-needed-p nil macomp-default-search-string nil) (do ((outl nil)(inl (map 'macomp-preoptimize interp)(cdr inl)) (thisform)(thisfun)(lastfun '@) (thisct)(lastct -1)) ((null inl) (setq outl (nreverse outl)) (if macomp-prog-needed-p (setq outl (list (cons 'prog (cons '() outl))))) (append (list 'defun name '()) outl)) (setq thisform (macomp-term-compile inl)) (if (not (null thisform)) (setq thisfun (cond ((eq (car thisform) 'do-times) (setq thisct (cadr thisform)) (caddr thisform)) (t (setq thisct 1) thisform))) (if (equal thisfun lastfun) (setq outl (cons (list 'do-times (setq thisct (+ thisct lastct)) thisfun) (cdr outl))) else (if (and (eq (car thisfun) 'insert-string) (eq (car lastfun) 'insert-string)) (setq outl (cons (list 'insert-string (catenate (cadr lastfun) (cadr thisfun))) (cdr outl))) else (setq outl (cons thisform outl)))) (setq lastct thisct lastfun thisfun)))) (defun macomp-preoptimize (term) (let ((fun (cdar term))) (cond ((eq fun 'quote-char) (cond ((eq (cdadr term) 'String) (rplacd (cadr term) 'Input/ Characters))) (cond ((eq (cdadr term) 'Input/ Characters) ;;cant happen from macro edit buffer (cond ((samepnamep (caadr term) (ascii 15)) (rplaca (cadr term)(get_pname NL)))) (rplaca term (cons (get_pname (maknam (explode (caadr term)))) 'String)) (rplacd term (cddr term))) (t (rplaca term '("Quote-char saw no input" . %macomp-ierr))))) ((eq fun 're-execute-command) (rplacd (car term) macomp-last-cmd)) ((not (memq fun '(noop Numeric/ argument multiplier noop))) (setq macomp-last-cmd fun))))) (defun macomp-term-compile (term) (let ((sym (caar term))(fun (cdar term))) (cond ((eq fun 'noop) nil) ((eq fun '%macomp-ierr) (list 'error sym)) ((eq fun 'String) (setq sym (read-from-string sym)) (do-forever ;Reduce strings. (or (memq (cdadr term) '(rubout-char String))(stop-doing)) (if (eq (cdadr term) 'rubout-char) (if (not (> (stringlength sym) 0))(stop-doing)) (rplacd term (cddr term)) (setq sym (substr sym 1 (1- (stringlength sym))))) (if (eq (cdadr term) 'String) (setq sym (catenate sym (read-from-string (caadr term)))) (rplacd term (cddr term)))) (if (> (stringlength sym) 0) (list 'insert-string sym))) ((eq (cdadr term) 'Numeric/ argument) (macomp-comp-multipliers term)) ((eq fun 'multiplier) (macomp-comp-multipliers term)) ((let ((prop (get fun 'search-command))) (and prop (macomp-comp-searches prop term)))) ((memq fun '(next-line-command prev-line-command)) (let ((template (cond ((eq fun 'prev-line-command) '(if (firstlinep)(command-quit) else (prev-line))) (t '(if (lastlinep)(command-quit) else (next-line)))))) (if (get (cdadr term) 'linepos-insensitive) template else (list fun)))) ((eq fun 'macro-query) (setq macomp-prog-needed-p t) '(if (not (macro-query-get-answer))(return nil))) (t (list fun))))) (mapc '(lambda (x)(putprop x t 'linepos-insensitive)) '(go-to-beginning-of-line go-to-end-of-line skip-over-indentation indent-to-lisp indent-relative prev-line-command next-line-command)) (defun macomp-comp-searches (prop term) (prog (string cmd strterm escterm) (setq cmd (car prop) strterm (cdr term) escterm (cdr strterm)) (if (memq (cdar strterm) '(escape new-line)) ;null string (setq escterm strterm strterm '(("""""" . String)))) (if (and (eq (cdar strterm) 'String) (memq (cdar escterm) '(new-line escape))) (setq string (read-from-string (caar strterm))) (or (stringp (setq string (macomp-search-defaultify string))) (go sdf-err)) (setq cmd (list cmd string)) (if (eq (car cmd) 'regexp-search) (setq cmd (list 'let (list (list 'm cmd)) '(and m (progn (release-mark m) t))))) (return (prog2 0 (list 'if (list 'not cmd) '(search-failure-annunciator)) (rplacd term (cdr escterm)))) else (setq string (caar strterm)) (if (and (eq (cdar strterm) 'Input/ characters) (= (getcharn string (stringlength string)) 33)) (setq string (substr string 1 (1- (stringlength string)))) (or (stringp (setq string (macomp-search-defaultify string))) (progn (setq escterm strterm) (go sdf-err))) (return (prog2 0 (list 'if (list 'not (list cmd string)) '(search-failure-annunciator)) (rplacd term (cdr strterm)))))) (return '(error "Search string too complex. Edit the macro first.")) sdf-err (rplacd term (cdr escterm)) (return '(error "Default search string may not be assumed in extension.")))) (defun macomp-search-defaultify (s) (cond ((nullstringp s) macomp-default-search-string) (t (setq macomp-default-search-string s)))) (mapc '(lambda (x)(putprop (car x)(cdr x) 'search-command)) '((string-search forward-search) (reverse-string-search reverse-search) (regexp-search-command regexp-search) (incremental-search forward-search) (reverse-incremental-search reverse-search) (multi-word-search WORD-SEARCH-FRAMMIS))) (defun macomp-stfix-to-fixnum (x) (let ((ibase 10.))(read-from-string x))) (defun macomp-comp-multipliers (term) (let ((rest term)(num 1)) (do-forever (cond ((eq (cdadr rest) 'Numeric/ argument) (setq num (macomp-stfix-to-fixnum (caadr rest))) (setq rest (cddr rest))) ((eq (cdar rest) 'multiplier) (setq num (* 4 num)) (setq rest (cdr rest))) (t (stop-doing)))) (prog2 0 (let ((fun (cdar rest)) (data (caar rest))) ;look at function (cond ((eq fun 'String) (setq data (read-from-string data)) (rplaca (car rest) (maknam (explode (catenate (do ((l nil (cons c l)) (x 0 (1+ x)) (c (getchar data 1))) ((= x num) (get_pname (maknam l)))) (substr data 2))))) nil) ((get fun 'argwants) (setq rest (cdr rest)) (list 'do-times num (list fun))) (t (setq rest (cdr rest)) (list 'let (list (list 'numarg num))(list fun))))) (rplacd term rest)))) INCLUDE FILE >spec>install>1136>executable>e-macros.incl.lisp ;;; BEGIN INCLUDE FILE e-macros.incl.lisp ;;; Declares for use by Emacs programs and extenstions. Also loads ;;; in e_macros_, which contains macro definitions. ;;; HISTORY COMMENTS: ;;; 1) change(85-01-01,Margolin), approve(86-02-24,MCR7186), ;;; audit(86-08-12,Harvey), install(86-08-20,MR12.0-1136): ;;; Written: New Year's Day 1985, by excerpting the old e-macros.incl.lisp ;;; and leaving out all the definitions and qwerty junk (don't ask). ;;; 2) change(86-02-24,Margolin), approve(86-02-24,MCR7325), ;;; audit(86-08-12,Harvey), install(86-08-20,MR12.0-1136): ;;; Alphabetized declarations, and added more declarations for documented ;;; functions, and also for some undocumented functions. ;;; END HISTORY COMMENTS (%include backquote) (declare ;basic editor stuff (*expr apply-catenate assert-minor-mode backward-char backward-n-chars charlisten charset-member command-abort command-quit copy-region cur-hpos curline-as-string curbuf-as-string curchar curline-as-string delete-char delete-word destroy-buffer-contents dont-notice-modified-buffer e_cline_ e_lap_$reverse-search-string e_lap_$trim empty-buffer-p error_table_ establish-local-var exchange-point-and-mark firstlinep forward-char forward-n-chars forward-regexp-search-in-line forward-search forward-search-in-line get-char get-search-string go-to-beginning-of-buffer go-to-beginning-of-line go-to-buffer go-to-end-of-buffer go-to-end-of-line go-to-hpos go-to-mark go-to-or-create-buffer insert-char insert-string kill-backwards-to-mark kill-forward-to-mark kill-pop kill-to-end-of-line killsave-string lastlinep loadfile looking-at lowercase map-over-emacs-commands mark-on-current-line-p mark-reached merge-kills-forward merge-kills-reverse move-mark minibuf-response minibuffer-clear negate-minor-mode new-line next-line nullstringp pathname_ pathname_$component point-mark-to-string point>markp prev-line printable process-char produce-named-mark-list read-in-file release-mark reverse-search register-local-var reverse-search-in-line search-back-first-charset-line search-back-first-not-charset-line search-failure-annunciator search-for-first-charset-line search-for-first-not-charset-line set-emacs-epilogue-handler set-buffer-self-destruct set-key set-mark-here set-mark set-perm-key set-the-mark set-the-mark-here skip-to-whitespace skip-to-whitespace-in-line wipe-point-mark wipe-region write-out-file trim-minibuf-response yesp yank) (*fexpr define-autoload-lib)) (declare ;redisplay stuff (*expr end-local-displays init-local-displays ring-tty-bell local-display-generator local-display-generator-nnl next-screen prev-screen local-display-current-line find-buffer-in-window select-buffer-window window-info select-buffer-find-window select-other-window select-window buffer-on-display-in-window redisplay full-redisplay)) (declare ;extended stuff (*expr forward-word backward-word skip-over-whitespace skip-back-whitespace skip-over-whitespace-in-line skip-back-whitespace-in-line skip-back-to-whitespace skip-to-whitespace rubout-char date display-buffer-as-printout delete-white-sides lefthand-char format-to-col whitespace-to-hpos line-is-blank decimal-rep register-option minibuffer-clear)) (declare (*lexpr display-error display-com-error display-error-noabort display-error-remark comout-get-output display-com-error-noabort minibuffer-print minibuffer-response trim-minibuffer-response intern-minibuffer-response minibuffer-remark minibuffer-print-noclear report-error report-error-noabort)) (declare (special TAB NL SPACE ESC curpointpos current-buffer dont-stash numarg der-wahrer-mark fpathname fill-column completion-list curlinel BACKSPACE read-only-flag buffer-modified-flag previous-buffer current-buffer-mode env-dir process-dir minibuffer-end-string NLCHARSTRING undo null-pointer)) ;;; Load in macro packages (eval-when (eval compile) (or (status feature e-defcom) (progn (load (catenate (car (namelist (truename infile))) ">e_define_command_")) (sstatus feature e-defcom))) (or (status feature e-macros) (load (catenate (car (namelist (truename infile))) ">e_macros_")))) ;;; END INCLUDE FILE e-macros.incl.lisp INCLUDE FILE >ldd>include>backquote.incl.lisp ;;; ;;; backquote.incl.lisp - BSG 10/9/79 ;;; Loads lisp_backquote_ into either the compiler or interpreter ;;; environment. ;;; ;;; Modified 10/30/82 by Richard Lamson to use eval-when and ;;; (status feature backquote) ;;; (eval-when (eval compile) (or (status feature backquote) (load (catenate (car (namelist (truename infile))) ">lisp_backquote_")))) Functions Defined Name Offset Offset Name macomp-bufout-finish-form 563 0 macomp-output-to-buffer macomp-bufout-r 11 11 macomp-bufout-r macomp-bufout-random-list 420 420 macomp-bufout-random-list macomp-comp-multipliers 2040 563 macomp-bufout-finish-form macomp-comp-searches 1515 616 macomp-compile-to-expr macomp-compile-to-expr 616 1056 macomp-preoptimize macomp-output-to-buffer 0 1212 macomp-term-compile macomp-preoptimize 1056 1515 macomp-comp-searches macomp-search-defaultify 2010 2010 macomp-search-defaultify macomp-stfix-to-fixnum 2024 2024 macomp-stfix-to-fixnum macomp-term-compile 1212 2040 macomp-comp-multipliers Functions Referenced append lefthand-char maknam catenate macomp-bufout-finish-form new-line cur-hpos macomp-bufout-r nreverse decimal-rep macomp-bufout-random-list nullstringp equal macomp-comp-multipliers read-from-string explode macomp-comp-searches samepnamep get macomp-preoptimize stringlength get_pname macomp-search-defaultify substr getchar macomp-stfix-to-fixnum substr getcharn macomp-term-compile whitespace-to-hpos insert-string ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group BULL including BULL HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell BULL Inc., Groupe BULL and BULL HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, BULL or BULL HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by BULL HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved