(FILECREATED " 8-Jul-86 12:37:19" {ERIS}<LISPUSERS>KOTO>SETDEFAULTPRINTER.;1 5599 changes to: (FNS \sdp.set.printer) previous date: "24-Mar-86 16:35:53" {ERIS}<LISP>KOTO>LISPUSERS>SETDEFAULTPRINTER.;1) (* Copyright (c) 1985, 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT SETDEFAULTPRINTERCOMS) (RPAQQ SETDEFAULTPRINTERCOMS ((* * the regular DEFAULTSUBITEMFN modified to recognize EVAL as a key to EVAL the CADR of the list to get the subitems) (FILES DEFAULTSUBITEMFN) (* * the setdefaultprinter functions) (FNS \sdp.get.printer \sdp.menu.subitems \sdp.set.printer) (* * SDP.PRINTERINFO is the place to look up things like printer location, it also looks on the name of the printer for a LOCATION property) [INITVARS (SDP.PRINTERINFO NIL) (\\sdp.read.table (COPYREADTABLE (QUOTE ORIG] (* * the variables that signal recreating the menu subitems) (VARS (\\sdp.known.printers) (\\sdp.menu.subitems)) (* * insinuate self into background menu) [ADDVARS (BackgroundMenuCommands ("Set Default Printer" (\sdp.set.printer (\sdp.get.printer )) "Asks for (new) default printer name. <cr> without entering name aborts change." (EVAL (\sdp.menu.subitems] (* * reset the background menu so our change takes effect, and remove space from the separators when reading printer names) (P (SETQ BackgroundMenu) (SETSYNTAX 32 (QUOTE OTHER) \\sdp.read.table)))) (* * the regular DEFAULTSUBITEMFN modified to recognize EVAL as a key to EVAL the CADR of the list to get the subitems) (FILESLOAD DEFAULTSUBITEMFN) (* * the setdefaultprinter functions) (DEFINEQ (\sdp.get.printer [LAMBDA NIL (* N.H.Briggs "24-Mar-86 16:24") (* TBigham " 2-Dec-85 07:48") (DECLARE (GLOBALVARS LASTMOUSEX LASTMOUSEY \\sdp.read.table)) (LET* ((font (DEFAULTFONT (QUOTE DISPLAY))) (prompt "Enter printer name: ") (window (CREATEW [MAKEWITHINREGION (CREATEREGION LASTMOUSEX LASTMOUSEY [WIDTHIFWINDOW (IPLUS (STRINGWIDTH prompt font) (ITIMES 40 (CHARWIDTH (CHARCODE M) font] (HEIGHTIFWINDOW (FONTPROP font (QUOTE HEIGHT] NIL NIL T))) (RESETLST (RESETSAVE (OPENW window) (BQUOTE (CLOSEW , window))) (SETQ input (PROMPTFORWORD prompt NIL NIL window NIL NIL (CHARCODE EOL))) (AND input (CAR (NLSETQ (READ (OPENSTRINGSTREAM input (QUOTE INPUT)) \\sdp.read.table]) (\sdp.menu.subitems [LAMBDA NIL (* N.H.Briggs "24-Mar-86 16:09") (if (AND \\sdp.menu.subitems (EQUAL \\sdp.known.printers DEFAULTPRINTINGHOST)) then \\sdp.menu.subitems else (SETQ \\sdp.known.printers (COPY DEFAULTPRINTINGHOST)) (SETQ \\sdp.menu.subitems (NCONC1 [for printer inside \\sdp.known.printers collect (LIST printer (LIST (QUOTE \sdp.set.printer) (KWOTE printer)) (OR (GETPROP (U-CASE printer) (QUOTE LOCATION)) (CDR (ASSOC (U-CASE printer) SDP.PRINTERINFO] (LIST "Other..." (QUOTE (\sdp.set.printer (\sdp.get.printer)) ) "Asks for (new) default printer name. <cr> without entering name aborts change."]) (\sdp.set.printer [LAMBDA (printer) (* N.H.Briggs " 8-Jul-86 12:29") (LET ((canonicalprintername (CANONICAL.HOSTNAME printer))) (if [AND printer (NOT (STRING-EQUAL canonicalprintername (CANONICAL.HOSTNAME (CAR (SETQ DEFAULTPRINTINGHOST (MKLIST DEFAULTPRINTINGHOST] then [SETQ DEFAULTPRINTINGHOST (CONS printer (SUBSET DEFAULTPRINTINGHOST (FUNCTION (LAMBDA (x) (NOT (STRING-EQUAL (CANONICAL.HOSTNAME x) canonicalprintername] (PROMPTPRINT "default printer set to " printer) else (PROMPTPRINT "default printer not changed"))) NIL]) ) (* * SDP.PRINTERINFO is the place to look up things like printer location, it also looks on the name of the printer for a LOCATION property) (RPAQ? SDP.PRINTERINFO NIL) (RPAQ? \\sdp.read.table (COPYREADTABLE (QUOTE ORIG))) (* * the variables that signal recreating the menu subitems) (RPAQQ \\sdp.known.printers NIL) (RPAQQ \\sdp.menu.subitems NIL) (* * insinuate self into background menu) (ADDTOVAR BackgroundMenuCommands ("Set Default Printer" (\sdp.set.printer (\sdp.get.printer)) "Asks for (new) default printer name. <cr> without entering name aborts change." (EVAL (\sdp.menu.subitems)))) (* * reset the background menu so our change takes effect, and remove space from the separators when reading printer names) (SETQ BackgroundMenu) (SETSYNTAX 32 (QUOTE OTHER) \\sdp.read.table) (PUTPROPS SETDEFAULTPRINTER COPYRIGHT ("Xerox Corporation" 1985 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (1757 4641 (\sdp.get.printer 1767 . 2847) (\sdp.menu.subitems 2849 . 3814) ( \sdp.set.printer 3816 . 4639))))) STOP