From xemacs-m  Tue Feb  4 04:28:44 1997
Received: from mgate.uni-hannover.de (mgate.uni-hannover.de [130.75.2.3])
	by xemacs.org (8.8.5/8.8.5) with SMTP id EAA28797
	for <xemacs-beta@xemacs.org>; Tue, 4 Feb 1997 04:28:43 -0600 (CST)
Received: from helios (actually helios.tnt.uni-hannover.de) by mgate 
          with SMTP (PP); Tue, 4 Feb 1997 11:27:05 +0100
Received: from daedalus.tnt.uni-hannover.de by helios (SMI-8.6/SMI-SVR4) 
          id LAA16614; Tue, 4 Feb 1997 11:26:11 +0100
Received: by daedalus.tnt.uni-hannover.de (SMI-8.6/SMI-SVR4) id LAA15185;
          Tue, 4 Feb 1997 11:26:09 +0100
Date: Tue, 4 Feb 1997 11:26:09 +0100
Message-Id: <199702041026.LAA15185@daedalus.tnt.uni-hannover.de>
From: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
To: jmiller@bay1.bayserve.net
Cc: xemacs-beta@xemacs.org, duthen@cegelec-red.fr
Subject: Re: Updates to print menu under Options
In-Reply-To: <Pine.SUN.3.95.970203221652.10440A-100000@bay1.bayserve.net>
References: <Pine.SUN.3.95.970203221652.10440A-100000@bay1.bayserve.net>
X-Face: n}R'l6CHRf>pi&bj7[x0CW3:kmXm@1)7m+l*9[fp;-Ow4Xe~=5E;skf?2> 
        y]f{HzB|Q(\V9+y$PP~.4G[2n4W7{6Ilm[AMY9B:0kj.K_$-d%p4YIF*bX;=ADp6{ 
        HS@NEv9c.VII+9PgXHASx}K(jy^t=q%qzZ72q1e4E;O!$A$`&wgtLk"1%p.nC_G!] 
        4d1!+J4Q#YD_iXeEy`1x)d\r$1Qn\'23n|[8Y_xzuXJJ7W(EGqnzB]`]aq??;+z=) 
        DW~\'Vq&F'g%QU[Mv2:}nS>SdZFTEC2GsgB=Q,:~H<R5S[:ZN%B:s0;|v1x"Jb
Mime-Version: 1.0 (generated by tm-edit 7.90)
Content-Type: text/plain; charset=US-ASCII

>>>>> "Jeff" == Jeff Miller <jmiller@bay1.bayserve.net> writes:

    Jeff> Added to XEmacs 20.0 but probably the same for 19.15

    Jeff> Does anybody else think these are useful?  I'd like to see
    Jeff> an option to specify a printer.  I can always hard code
    Jeff> something in but something automagically built from a
    Jeff> printcap file or an alist type thing would really be nice.
    Jeff> That would be a bit more that my lisp abilities can handle
    Jeff> though.

I've already such a menu, which is build from an alist. I've added the
code at the end of this mail. Note: This is a part of a file which I'm
using to install a menu with other usefull entries. Therefore I'm not
sure, if this part is working without the rest of the file. But I'll
send the whole file if there's any interest. I'm also able to develope
a patch, if Steven want's to integrate it in the Options menu.

Any interest?



;;;;
;;;;  Print submenu 
;;;;

(defvar ps-lpr-switches nil ; defined in the package ps-print.el
  "A list of extra switches to pass to ps-lpr-command.")

(defvar hm-print-menu nil "*List with the print menu.")

(setq hm-print-menu
      '("Print"
	["Ps Print Buffer" ps-print-buffer t]
	["Ps Print Buffer With Faces" ps-print-buffer-with-faces t]
	["Ps Print Region" ps-print-region t]
	["Ps Print Region With Faces" ps-print-region-with-faces t]
	"----"
	)
      )

(defvar hm-print-main-menu "Misc  "
  "Main menu, in which the print menu will be added.")

(delete-menu-item (list hm-print-main-menu "Print"))

(add-submenu (list hm-print-main-menu)
;	  "Print" 
	     hm-print-menu
	     "Customize")

(setq hm-print-menu-prefix (list hm-print-main-menu))

(defun hm-remove-printer (lpr-switches)
  "Removes the the printer option from the list LPR-SWITCHES"
  (cond ((not lpr-switches) ())
	((string-match "-P *[^ ]*" (car lpr-switches))
	 (if (eq (length (car lpr-switches)) 
		 (- (match-end 0) (match-beginning 0)))
	     (cdr lpr-switches)
	   (cons (concat (substring (car lpr-switches) 0 (match-beginning 0))
			 (substring (car lpr-switches) (match-end 0)))
		 (cdr lpr-switches))))
	(t (hm-remove-printer (cdr lpr-switches)))))

(defun hm-change-printer (printer lpr-switches)
  "Changes the printer in the list LPR-SWIRCHES to PRINTER."
  (cons (concat "-P" printer) (hm-remove-printer lpr-switches))
  )

(defvar hm-ps-printer-alist
  '(("schiller")("goethe")("lipi")("dali_color")("dali_mono"))
  "*An alist with available postscript printers.
Eg: ((\"schiller\")(\"goethe\")(\"lipi\"))")

(defvar hm-current-ps-printer (car (car hm-ps-printer-alist))
  "The current Postscript printer.
This is only an internal variable.")

(defun hm-select-new-ps-printer (printer)
  "Selects and sets a new ps printer."
  (interactive (list (completing-read "Name of the printer: "
				      hm-ps-printer-alist
				      nil
				      nil
				      hm-current-ps-printer)))
  (setq hm-current-ps-printer printer)
  (setq ps-lpr-switches (hm-change-printer printer ps-lpr-switches))
; (hm-add-select-ps-printer-submenu))
  )

;(defun hm-construct-select-printer-submenu (printer-alist 
;					    select-printer-function
;					    current-printer)
;  "Constructs a menu from the PRINTER-ALIST."
;  (cond ((not printer-alist) nil)
;	(t (cons (vector (if (string= current-printer
;				      (car (car printer-alist)))
;			     (car (car printer-alist))
;			   (car (car printer-alist)))
;			 (list select-printer-function
;			       (car (car printer-alist)))
;			 t)
;		 (hm-construct-select-printer-submenu (cdr printer-alist)
;						      select-printer-function
;						      current-printer)
;		 ))))

;(defun hm-add-select-ps-printer-submenu ()
;  "Adds the Postscript printer submenu."
;  (add-menu (list hm-print-main-menu "Print") 
;	    "Set Postscript Printer"
;	    (hm-construct-select-printer-submenu hm-ps-printer-alist
;						 'hm-select-new-ps-printer
;						 hm-current-ps-printer)
;	    ))

(defun hm-add-select-ps-printer-submenu ()
  "Adds the Postscript printer submenu."
  (add-submenu 
   (list hm-print-main-menu "Print")
   (cons "Set Postscript Printer"
	 (mapcar '(lambda (printer)
		    (vector (car printer)
			    (list 'hm-select-new-ps-printer 
				  (car printer))
			    :style 'radio
			    :selected (list 'string= 
					    'hm-current-ps-printer 
					    (car printer))))
		 hm-ps-printer-alist))))

(hm-add-select-ps-printer-submenu)

