comparison lisp/printing.el @ 73827:985f3831f360

Fix Print submenu creation
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Wed, 08 Nov 2006 14:04:09 +0000
parents 81ee79a96310
children 8c9e156de392 dbe3f29e61d6
comparison
equal deleted inserted replaced
73826:1d5a66a8dd30 73827:985f3831f360
3 ;; Copyright (C) 2000, 2001, 2003, 2004, 2005, 3 ;; Copyright (C) 2000, 2001, 2003, 2004, 2005,
4 ;; 2006 Free Software Foundation, Inc. 4 ;; 2006 Free Software Foundation, Inc.
5 5
6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> 6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> 7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8 ;; Time-stamp: <2006/09/15 18:53:14 vinicius> 8 ;; Time-stamp: <2006/11/08 12:01:50 vinicius>
9 ;; Keywords: wp, print, PostScript 9 ;; Keywords: wp, print, PostScript
10 ;; Version: 6.8.4 10 ;; Version: 6.8.4
11 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre 11 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
12 12
13 (defconst pr-version "6.8.4" 13 (defconst pr-version "6.8.4"
66 ;; `printing' depends on ps-print package to generate PostScript files, to 66 ;; `printing' depends on ps-print package to generate PostScript files, to
67 ;; spool and to despool PostScript buffer. So, `printing' provides an 67 ;; spool and to despool PostScript buffer. So, `printing' provides an
68 ;; interface to ps-print package and it also provides some extra stuff. 68 ;; interface to ps-print package and it also provides some extra stuff.
69 ;; 69 ;;
70 ;; To download the latest ps-print package see 70 ;; To download the latest ps-print package see
71 ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'. 71 ;; `http://www.emacswiki.org/cgi-bin/emacs/download/ps-print.tar.gz'.
72 ;; Please, see README file for ps-print installation instructions. 72 ;; Please, see README file for ps-print installation instructions.
73 ;; 73 ;;
74 ;; `printing' was inspired on: 74 ;; `printing' was inspired on:
75 ;; 75 ;;
76 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr> 76 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr>
956 ;; 956 ;;
957 ;; Below are some URL where you can find good utilities. 957 ;; Below are some URL where you can find good utilities.
958 ;; 958 ;;
959 ;; * For `printing' package: 959 ;; * For `printing' package:
960 ;; 960 ;;
961 ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz' 961 ;; printing `http://www.emacswiki.org/cgi-bin/emacs/download/printing.el'
962 ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz' 962 ;; ps-print `http://www.emacswiki.org/cgi-bin/emacs/download/ps-print.tar.gz'
963 ;; 963 ;;
964 ;; * For GNU or Unix system: 964 ;; * For GNU or Unix system:
965 ;; 965 ;;
966 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html' 966 ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html'
967 ;; enscript `http://people.ssh.fi/mtr/genscript/' 967 ;; enscript `http://people.ssh.fi/mtr/genscript/'
1142 1142
1143 (defun pr-alist-custom-set (symbol value) 1143 (defun pr-alist-custom-set (symbol value)
1144 "Set the value of custom variables for printer & utility selection." 1144 "Set the value of custom variables for printer & utility selection."
1145 (set symbol value) 1145 (set symbol value)
1146 (and (featurep 'printing) ; update only after printing is loaded 1146 (and (featurep 'printing) ; update only after printing is loaded
1147 (not pr-menu-print-item)
1148 (pr-update-menus t))) 1147 (pr-update-menus t)))
1149 1148
1150 1149
1151 (defun pr-ps-utility-custom-set (symbol value) 1150 (defun pr-ps-utility-custom-set (symbol value)
1152 "Update utility menu entry." 1151 "Update utility menu entry."
1153 (set symbol value) 1152 (set symbol value)
1154 (and (featurep 'printing) ; update only after printing is loaded 1153 (and (featurep 'printing) ; update only after printing is loaded
1155 (not pr-menu-print-item)
1156 (pr-menu-set-utility-title value))) 1154 (pr-menu-set-utility-title value)))
1157 1155
1158 1156
1159 (defun pr-ps-name-custom-set (symbol value) 1157 (defun pr-ps-name-custom-set (symbol value)
1160 "Update `PostScript Printer:' menu entry." 1158 "Update `PostScript Printer:' menu entry."
1161 (set symbol value) 1159 (set symbol value)
1162 (and (featurep 'printing) ; update only after printing is loaded 1160 (and (featurep 'printing) ; update only after printing is loaded
1163 (not pr-menu-print-item)
1164 (pr-menu-set-ps-title value))) 1161 (pr-menu-set-ps-title value)))
1165 1162
1166 1163
1167 (defun pr-txt-name-custom-set (symbol value) 1164 (defun pr-txt-name-custom-set (symbol value)
1168 "Update `Text Printer:' menu entry." 1165 "Update `Text Printer:' menu entry."
1169 (set symbol value) 1166 (set symbol value)
1170 (and (featurep 'printing) ; update only after printing is loaded 1167 (and (featurep 'printing) ; update only after printing is loaded
1171 (not pr-menu-print-item)
1172 (pr-menu-set-txt-title value))) 1168 (pr-menu-set-txt-title value)))
1173 1169
1174 1170
1175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1171 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1176 ;; User Interface (I) 1172 ;; User Interface (I)
3089 ;; Replace existing "print" item by "Printing" item. 3085 ;; Replace existing "print" item by "Printing" item.
3090 ;; If you're changing this file, you'll load it a second, 3086 ;; If you're changing this file, you'll load it a second,
3091 ;; third... time, but "print" item exists only in the first load. 3087 ;; third... time, but "print" item exists only in the first load.
3092 (cond 3088 (cond
3093 ;; Emacs 20 3089 ;; Emacs 20
3094 ((string< emacs-version "21.") 3090 ((< emacs-major-version 21)
3095 (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item) 3091 (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item)
3096 (when pr-menu-print-item 3092 (when pr-menu-print-item
3097 (easy-menu-remove-item nil '("tools") pr-menu-print-item) 3093 (easy-menu-remove-item nil '("tools") pr-menu-print-item)
3098 (setq pr-menu-print-item nil 3094 (setq pr-menu-print-item nil
3099 pr-menu-bar (vector 'menu-bar 'tools 3095 pr-menu-bar (vector 'menu-bar 'tools
3100 (pr-get-symbol "Printing"))))) 3096 (pr-get-symbol "Printing")))))
3101 ;; Emacs 21 & 22 3097 ;; Emacs 21 & 22
3102 (t 3098 (t
3103 (cond 3099 (let ((menu-file (if (= emacs-major-version 21)
3104 (pr-menu-print-item 3100 '("menu-bar" "files") ; Emacs 21
3105 (easy-menu-add-item menu-bar-file-menu nil 3101 '("menu-bar" "file")))) ; Emacs 22 or higher
3106 (easy-menu-create-menu "Print" pr-menu-spec) 3102 (cond
3107 "print-buffer") 3103 (pr-menu-print-item
3108 (dolist (item '("print-buffer" "print-region" 3104 (easy-menu-add-item global-map menu-file
3109 "ps-print-buffer-faces" "ps-print-region-faces" 3105 (easy-menu-create-menu "Print" pr-menu-spec)
3110 "ps-print-buffer" "ps-print-region")) 3106 "print-buffer")
3111 (easy-menu-remove-item menu-bar-file-menu nil item)) 3107 (dolist (item '("print-buffer" "print-region"
3112 (setq pr-menu-print-item nil 3108 "ps-print-buffer-faces" "ps-print-region-faces"
3113 pr-menu-bar (vector 'menu-bar 3109 "ps-print-buffer" "ps-print-region"))
3114 'file 3110 (easy-menu-remove-item global-map menu-file item))
3115 (pr-get-symbol "Print")))) 3111 (setq pr-menu-print-item nil
3116 (t 3112 pr-menu-bar (vector 'menu-bar
3117 (easy-menu-change '("file") "Print" pr-menu-spec))))))) 3113 (pr-get-symbol (nth 1 menu-file))
3114 (pr-get-symbol "Print"))))
3115 (t
3116 (easy-menu-change (cdr menu-file) "Print" pr-menu-spec))))))))
3118 (pr-update-menus t)) 3117 (pr-update-menus t))
3119 3118
3120 3119
3121 ;; Key binding 3120 ;; Key binding
3122 (let ((pr-print-key (if (featurep 'xemacs) 3121 (let ((pr-print-key (if (featurep 'xemacs)
6054 (switch-to-buffer (get-buffer-create pr-buffer-name)) 6053 (switch-to-buffer (get-buffer-create pr-buffer-name))
6055 6054
6056 ;; header 6055 ;; header
6057 (let ((versions (concat "printing v" pr-version 6056 (let ((versions (concat "printing v" pr-version
6058 " ps-print v" ps-print-version))) 6057 " ps-print v" ps-print-version)))
6059 (widget-insert (make-string (- 79 (length versions)) ?\s) versions)) 6058 ;; to keep compatibility with Emacs 20 & 21:
6059 ;; DO NOT REPLACE `?\ ' BY `?\s'
6060 (widget-insert (make-string (- 79 (length versions)) ?\ ) versions))
6060 (pr-insert-italic "\nCurrent Directory : " 1) 6061 (pr-insert-italic "\nCurrent Directory : " 1)
6061 (pr-insert-italic default-directory) 6062 (pr-insert-italic default-directory)
6062 6063
6063 (pr-insert-section-1) ; 1. Print 6064 (pr-insert-section-1) ; 1. Print
6064 (pr-insert-section-2) ; 2. PostScript Printer 6065 (pr-insert-section-2) ; 2. PostScript Printer