diff options
| author | Vinicius Jose Latorre | 2007-10-27 00:25:43 +0000 |
|---|---|---|
| committer | Vinicius Jose Latorre | 2007-10-27 00:25:43 +0000 |
| commit | ebe4c71027cd6ec8583631e895e7fdd3decfc099 (patch) | |
| tree | 7c59c4a29326bc69ce617b6cd70e4d279169a75c | |
| parent | 3fe5c37a0c6236ec34781d956ad9b7c764906999 (diff) | |
| download | emacs-ebe4c71027cd6ec8583631e895e7fdd3decfc099.tar.gz emacs-ebe4c71027cd6ec8583631e895e7fdd3decfc099.zip | |
Pacify byte compiler
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/printing.el | 1134 |
2 files changed, 598 insertions, 555 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7da5bb702fb..ab892e88e8e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2007-10-26 Vinicius Jose Latorre <viniciusjl@ig.com.br> | ||
| 2 | |||
| 3 | * printing.el: Pacify byte compiler, that is, no compiler warnings. | ||
| 4 | Move (again) some variable definitions before use, define some fun | ||
| 5 | aliases, no code change. | ||
| 6 | (pr-version): New version 6.9.2. | ||
| 7 | (pr-path-style, pr-auto-region, pr-menu-char-height) | ||
| 8 | (pr-menu-char-width, pr-menu-lock, pr-ps-printer-alist) | ||
| 9 | (pr-txt-printer-alist, pr-ps-utility-alist): Options declaration | ||
| 10 | via (defvar VAR). | ||
| 11 | (pr-menu-lookup, pr-menu-lock, pr-menu-alist, pr-even-or-odd-pages) | ||
| 12 | (pr-menu-get-item, pr-menu-set-item-name, pr-menu-set-utility-title) | ||
| 13 | (pr-menu-set-ps-title, pr-menu-set-txt-title, pr-region-active-p) | ||
| 14 | (pr-do-update-menus, pr-update-mode-line, pr-f-read-string) | ||
| 15 | (pr-f-set-keymap-parents, pr-keep-region-active): Fun aliases. | ||
| 16 | (defvar pr-menu-print-item, pr-ps-printer-menu-modified) | ||
| 17 | (pr-txt-printer-menu-modified, pr-ps-utility-menu-modified) | ||
| 18 | (pr-even-or-odd-alist): Vars definition moved. | ||
| 19 | |||
| 1 | 2007-10-26 Dan Nicolaescu <dann@ics.uci.edu> | 20 | 2007-10-26 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 21 | ||
| 3 | * emulation/pc-select.el (next-line-mark, next-line-nomark) | 22 | * emulation/pc-select.el (next-line-mark, next-line-nomark) |
diff --git a/lisp/printing.el b/lisp/printing.el index fcb69b0f7ad..245d21d7de5 100644 --- a/lisp/printing.el +++ b/lisp/printing.el | |||
| @@ -6,11 +6,11 @@ | |||
| 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 | ;; Keywords: wp, print, PostScript | 8 | ;; Keywords: wp, print, PostScript |
| 9 | ;; Version: 6.9.1 | 9 | ;; Version: 6.9.2 |
| 10 | ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre | 10 | ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre |
| 11 | 11 | ||
| 12 | (defconst pr-version "6.9.1" | 12 | (defconst pr-version "6.9.2" |
| 13 | "printing.el, v 6.9.1 <2007/08/02 vinicius> | 13 | "printing.el, v 6.9.2 <2007/10/26 vinicius> |
| 14 | 14 | ||
| 15 | Please send all bug fixes and enhancements to | 15 | Please send all bug fixes and enhancements to |
| 16 | Vinicius Jose Latorre <viniciusjl@ig.com.br> | 16 | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| @@ -1093,71 +1093,515 @@ If SUFFIX is non-nil, add that at the end of the file name." | |||
| 1093 | (set-default-file-modes umask))))) | 1093 | (set-default-file-modes umask))))) |
| 1094 | 1094 | ||
| 1095 | 1095 | ||
| 1096 | (eval-when-compile | ||
| 1097 | ;; User Interface --- declared here to avoid compiler warnings | ||
| 1098 | (defvar pr-path-style) | ||
| 1099 | (defvar pr-auto-region) | ||
| 1100 | (defvar pr-menu-char-height) | ||
| 1101 | (defvar pr-menu-char-width) | ||
| 1102 | (defvar pr-menu-lock) | ||
| 1103 | (defvar pr-ps-printer-alist) | ||
| 1104 | (defvar pr-txt-printer-alist) | ||
| 1105 | (defvar pr-ps-utility-alist) | ||
| 1106 | |||
| 1107 | |||
| 1108 | ;; Internal fun alias to avoid compilation gripes | ||
| 1109 | (defalias 'pr-menu-lookup 'ignore) | ||
| 1110 | (defalias 'pr-menu-lock 'ignore) | ||
| 1111 | (defalias 'pr-menu-alist 'ignore) | ||
| 1112 | (defalias 'pr-even-or-odd-pages 'ignore) | ||
| 1113 | (defalias 'pr-menu-get-item 'ignore) | ||
| 1114 | (defalias 'pr-menu-set-item-name 'ignore) | ||
| 1115 | (defalias 'pr-menu-set-utility-title 'ignore) | ||
| 1116 | (defalias 'pr-menu-set-ps-title 'ignore) | ||
| 1117 | (defalias 'pr-menu-set-txt-title 'ignore) | ||
| 1118 | (defalias 'pr-region-active-p 'ignore) | ||
| 1119 | (defalias 'pr-do-update-menus 'ignore) | ||
| 1120 | (defalias 'pr-update-mode-line 'ignore) | ||
| 1121 | (defalias 'pr-f-read-string 'ignore) | ||
| 1122 | (defalias 'pr-f-set-keymap-parents 'ignore) | ||
| 1123 | (defalias 'pr-keep-region-active 'ignore)) | ||
| 1124 | |||
| 1125 | |||
| 1126 | ;; Internal Vars --- defined here to avoid compiler warnings | ||
| 1127 | (defvar pr-menu-print-item "print" | ||
| 1128 | "Non-nil means that menu binding was not done. | ||
| 1129 | |||
| 1130 | Used by `pr-menu-bind' and `pr-update-menus'.") | ||
| 1131 | |||
| 1132 | (defvar pr-ps-printer-menu-modified t | ||
| 1133 | "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.") | ||
| 1134 | |||
| 1135 | (defvar pr-txt-printer-menu-modified t | ||
| 1136 | "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.") | ||
| 1137 | |||
| 1138 | (defvar pr-ps-utility-menu-modified t | ||
| 1139 | "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.") | ||
| 1140 | |||
| 1141 | (defconst pr-even-or-odd-alist | ||
| 1142 | '((nil . "Print All Pages") | ||
| 1143 | (even-page . "Print Even Pages") | ||
| 1144 | (odd-page . "Print Odd Pages") | ||
| 1145 | (even-sheet . "Print Even Sheets") | ||
| 1146 | (odd-sheet . "Print Odd Sheets"))) | ||
| 1147 | |||
| 1096 | 1148 | ||
| 1097 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1149 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1098 | ;; User Interface (I) | 1150 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1151 | ;; XEmacs Definitions | ||
| 1099 | 1152 | ||
| 1100 | 1153 | ||
| 1101 | (defgroup printing nil | 1154 | (cond |
| 1102 | "Printing Utilities group." | 1155 | ((featurep 'xemacs) ; XEmacs |
| 1103 | :tag "Printing Utilities" | 1156 | ;; XEmacs |
| 1104 | :link '(emacs-library-link :tag "Source Lisp File" "printing.el") | 1157 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) |
| 1105 | :prefix "pr-" | 1158 | (defalias 'pr-f-set-keymap-name 'set-keymap-name) |
| 1106 | :version "20" | ||
| 1107 | :group 'wp | ||
| 1108 | :group 'postscript) | ||
| 1109 | 1159 | ||
| 1160 | ;; XEmacs | ||
| 1161 | (defun pr-f-read-string (prompt initial history default) | ||
| 1162 | (let ((str (read-string prompt initial))) | ||
| 1163 | (if (and str (not (string= str ""))) | ||
| 1164 | str | ||
| 1165 | default))) | ||
| 1110 | 1166 | ||
| 1111 | (defcustom pr-path-style | 1167 | ;; XEmacs |
| 1112 | (if (and (not pr-cygwin-system) | 1168 | (defvar zmacs-region-stays nil) |
| 1113 | ps-windows-system) | ||
| 1114 | 'windows | ||
| 1115 | 'unix) | ||
| 1116 | "*Specify which path style to use for external commands. | ||
| 1117 | 1169 | ||
| 1118 | Valid values are: | 1170 | ;; XEmacs |
| 1171 | (defun pr-keep-region-active () | ||
| 1172 | (setq zmacs-region-stays t)) | ||
| 1119 | 1173 | ||
| 1120 | windows Windows 9x/NT style (\\) | 1174 | ;; XEmacs |
| 1175 | (defun pr-region-active-p () | ||
| 1176 | (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))) | ||
| 1121 | 1177 | ||
| 1122 | unix Unix style (/)" | 1178 | ;; XEmacs |
| 1123 | :type '(choice :tag "Path style" | 1179 | (defun pr-menu-char-height () |
| 1124 | (const :tag "Windows 9x/NT Style (\\)" :value windows) | 1180 | (font-height (face-font 'default))) |
| 1125 | (const :tag "Unix Style (/)" :value unix)) | ||
| 1126 | :version "20" | ||
| 1127 | :group 'printing) | ||
| 1128 | 1181 | ||
| 1182 | ;; XEmacs | ||
| 1183 | (defun pr-menu-char-width () | ||
| 1184 | (font-width (face-font 'default))) | ||
| 1129 | 1185 | ||
| 1186 | ;; XEmacs | ||
| 1187 | (defmacro pr-xemacs-global-menubar (&rest body) | ||
| 1188 | `(save-excursion | ||
| 1189 | (let ((temp (get-buffer-create (make-temp-name " *Temp")))) | ||
| 1190 | ;; be sure to access global menubar | ||
| 1191 | (set-buffer temp) | ||
| 1192 | ,@body | ||
| 1193 | (kill-buffer temp)))) | ||
| 1130 | 1194 | ||
| 1131 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1195 | ;; XEmacs |
| 1132 | ;; Customization Functions | 1196 | (defun pr-global-menubar (pr-menu-spec) |
| 1197 | ;; Menu binding | ||
| 1198 | (pr-xemacs-global-menubar | ||
| 1199 | (add-submenu nil (cons "Printing" pr-menu-spec) "Apps")) | ||
| 1200 | (setq pr-menu-print-item nil)) | ||
| 1133 | 1201 | ||
| 1202 | ;; XEmacs | ||
| 1203 | (defvar current-mouse-event nil) | ||
| 1204 | (defun pr-menu-position (entry index horizontal) | ||
| 1205 | (make-event | ||
| 1206 | 'button-release | ||
| 1207 | (list 'button 1 | ||
| 1208 | 'x (- (event-x-pixel current-mouse-event) ; X | ||
| 1209 | (* horizontal pr-menu-char-width)) | ||
| 1210 | 'y (- (event-y-pixel current-mouse-event) ; Y | ||
| 1211 | (* (pr-menu-index entry index) pr-menu-char-height))))) | ||
| 1134 | 1212 | ||
| 1135 | (defun pr-alist-custom-set (symbol value) | 1213 | (defvar pr-menu-position nil) |
| 1136 | "Set the value of custom variables for printer & utility selection." | 1214 | (defvar pr-menu-state nil) |
| 1137 | (set symbol value) | ||
| 1138 | (and (featurep 'printing) ; update only after printing is loaded | ||
| 1139 | (pr-update-menus t))) | ||
| 1140 | 1215 | ||
| 1216 | ;; XEmacs | ||
| 1217 | (defvar current-menubar nil) ; to avoid compilation gripes | ||
| 1218 | (defun pr-menu-lookup (path) | ||
| 1219 | (car (find-menu-item current-menubar (cons "Printing" path)))) | ||
| 1141 | 1220 | ||
| 1142 | (defun pr-ps-utility-custom-set (symbol value) | 1221 | ;; XEmacs |
| 1143 | "Update utility menu entry." | 1222 | (defun pr-menu-lock (entry index horizontal state path) |
| 1144 | (set symbol value) | 1223 | (when pr-menu-lock |
| 1145 | (and (featurep 'printing) ; update only after printing is loaded | 1224 | (or (and pr-menu-position (eq state pr-menu-state)) |
| 1146 | (pr-menu-set-utility-title value))) | 1225 | (setq pr-menu-position (pr-menu-position entry index horizontal) |
| 1226 | pr-menu-state state)) | ||
| 1227 | (let* ((menu (pr-menu-lookup path)) | ||
| 1228 | (result (get-popup-menu-response menu pr-menu-position))) | ||
| 1229 | (and (misc-user-event-p result) | ||
| 1230 | (funcall (event-function result) | ||
| 1231 | (event-object result)))) | ||
| 1232 | (setq pr-menu-position nil))) | ||
| 1147 | 1233 | ||
| 1234 | ;; XEmacs | ||
| 1235 | (defalias 'pr-update-mode-line 'set-menubar-dirty-flag) | ||
| 1148 | 1236 | ||
| 1149 | (defun pr-ps-name-custom-set (symbol value) | 1237 | ;; XEmacs |
| 1150 | "Update `PostScript Printer:' menu entry." | 1238 | (defvar pr-ps-name-old "PostScript Printers") |
| 1151 | (set symbol value) | 1239 | (defvar pr-txt-name-old "Text Printers") |
| 1152 | (and (featurep 'printing) ; update only after printing is loaded | 1240 | (defvar pr-ps-utility-old "PostScript Utility") |
| 1153 | (pr-menu-set-ps-title value))) | 1241 | (defvar pr-even-or-odd-old "Print All Pages") |
| 1242 | |||
| 1243 | ;; XEmacs | ||
| 1244 | (defun pr-do-update-menus (&optional force) | ||
| 1245 | (pr-menu-alist pr-ps-printer-alist | ||
| 1246 | 'pr-ps-name | ||
| 1247 | 'pr-menu-set-ps-title | ||
| 1248 | '("Printing") | ||
| 1249 | 'pr-ps-printer-menu-modified | ||
| 1250 | force | ||
| 1251 | pr-ps-name-old | ||
| 1252 | 'postscript 2) | ||
| 1253 | (pr-menu-alist pr-txt-printer-alist | ||
| 1254 | 'pr-txt-name | ||
| 1255 | 'pr-menu-set-txt-title | ||
| 1256 | '("Printing") | ||
| 1257 | 'pr-txt-printer-menu-modified | ||
| 1258 | force | ||
| 1259 | pr-txt-name-old | ||
| 1260 | 'text 2) | ||
| 1261 | (let ((save-var pr-ps-utility-menu-modified)) | ||
| 1262 | (pr-menu-alist pr-ps-utility-alist | ||
| 1263 | 'pr-ps-utility | ||
| 1264 | 'pr-menu-set-utility-title | ||
| 1265 | '("Printing" "PostScript Print" "File") | ||
| 1266 | 'save-var | ||
| 1267 | force | ||
| 1268 | pr-ps-utility-old | ||
| 1269 | nil 1)) | ||
| 1270 | (pr-menu-alist pr-ps-utility-alist | ||
| 1271 | 'pr-ps-utility | ||
| 1272 | 'pr-menu-set-utility-title | ||
| 1273 | '("Printing" "PostScript Preview" "File") | ||
| 1274 | 'pr-ps-utility-menu-modified | ||
| 1275 | force | ||
| 1276 | pr-ps-utility-old | ||
| 1277 | nil 1) | ||
| 1278 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | ||
| 1154 | 1279 | ||
| 1280 | ;; XEmacs | ||
| 1281 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | ||
| 1282 | entry index) | ||
| 1283 | (when (and alist (or force (symbol-value modified-sym))) | ||
| 1284 | (pr-xemacs-global-menubar | ||
| 1285 | (add-submenu menu-path | ||
| 1286 | (pr-menu-create name alist var-sym | ||
| 1287 | fun entry index))) | ||
| 1288 | (funcall fun (symbol-value var-sym)) | ||
| 1289 | (set modified-sym nil))) | ||
| 1155 | 1290 | ||
| 1156 | (defun pr-txt-name-custom-set (symbol value) | 1291 | ;; XEmacs |
| 1157 | "Update `Text Printer:' menu entry." | 1292 | (defun pr-relabel-menu-item (newname var-sym) |
| 1158 | (set symbol value) | 1293 | (pr-xemacs-global-menubar |
| 1159 | (and (featurep 'printing) ; update only after printing is loaded | 1294 | (relabel-menu-item |
| 1160 | (pr-menu-set-txt-title value))) | 1295 | (list "Printing" (symbol-value var-sym)) |
| 1296 | newname) | ||
| 1297 | (set var-sym newname))) | ||
| 1298 | |||
| 1299 | ;; XEmacs | ||
| 1300 | (defun pr-menu-set-ps-title (value &optional item entry index) | ||
| 1301 | (pr-relabel-menu-item (format "PostScript Printer: %s" value) | ||
| 1302 | 'pr-ps-name-old) | ||
| 1303 | (pr-ps-set-printer value) | ||
| 1304 | (and index | ||
| 1305 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 1306 | |||
| 1307 | ;; XEmacs | ||
| 1308 | (defun pr-menu-set-txt-title (value &optional item entry index) | ||
| 1309 | (pr-relabel-menu-item (format "Text Printer: %s" value) | ||
| 1310 | 'pr-txt-name-old) | ||
| 1311 | (pr-txt-set-printer value) | ||
| 1312 | (and index | ||
| 1313 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 1314 | |||
| 1315 | ;; XEmacs | ||
| 1316 | (defun pr-menu-set-utility-title (value &optional item entry index) | ||
| 1317 | (pr-xemacs-global-menubar | ||
| 1318 | (let ((newname (format "%s" value))) | ||
| 1319 | (relabel-menu-item | ||
| 1320 | (list "Printing" "PostScript Print" "File" pr-ps-utility-old) | ||
| 1321 | newname) | ||
| 1322 | (relabel-menu-item | ||
| 1323 | (list "Printing" "PostScript Preview" "File" pr-ps-utility-old) | ||
| 1324 | newname) | ||
| 1325 | (setq pr-ps-utility-old newname))) | ||
| 1326 | (pr-ps-set-utility value) | ||
| 1327 | (and index | ||
| 1328 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | ||
| 1329 | |||
| 1330 | ;; XEmacs | ||
| 1331 | (defun pr-even-or-odd-pages (value &optional no-lock) | ||
| 1332 | (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist)) | ||
| 1333 | 'pr-even-or-odd-old) | ||
| 1334 | (setq ps-even-or-odd-pages value) | ||
| 1335 | (or no-lock | ||
| 1336 | (pr-menu-lock 'postscript-options 8 12 'toggle nil))) | ||
| 1337 | |||
| 1338 | ) | ||
| 1339 | (t ; GNU Emacs | ||
| 1340 | ;; Do nothing | ||
| 1341 | )) ; end cond featurep | ||
| 1342 | |||
| 1343 | |||
| 1344 | |||
| 1345 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1346 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1347 | ;; GNU Emacs Definitions | ||
| 1348 | |||
| 1349 | |||
| 1350 | (cond | ||
| 1351 | ((featurep 'xemacs) ; XEmacs | ||
| 1352 | ;; Do nothing | ||
| 1353 | ) | ||
| 1354 | (t ; GNU Emacs | ||
| 1355 | ;; GNU Emacs | ||
| 1356 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) | ||
| 1357 | (defalias 'pr-f-set-keymap-name 'ignore) | ||
| 1358 | (defalias 'pr-f-read-string 'read-string) | ||
| 1359 | |||
| 1360 | ;; GNU Emacs | ||
| 1361 | (defvar deactivate-mark) | ||
| 1362 | |||
| 1363 | ;; GNU Emacs | ||
| 1364 | (defun pr-keep-region-active () | ||
| 1365 | (setq deactivate-mark nil)) | ||
| 1366 | |||
| 1367 | ;; GNU Emacs | ||
| 1368 | (defun pr-region-active-p () | ||
| 1369 | (and pr-auto-region transient-mark-mode mark-active)) | ||
| 1370 | |||
| 1371 | ;; GNU Emacs | ||
| 1372 | (defun pr-menu-char-height () | ||
| 1373 | (frame-char-height)) | ||
| 1374 | |||
| 1375 | ;; GNU Emacs | ||
| 1376 | (defun pr-menu-char-width () | ||
| 1377 | (frame-char-width)) | ||
| 1378 | |||
| 1379 | (defvar pr-menu-bar nil | ||
| 1380 | "Specify Printing menu-bar entry.") | ||
| 1381 | |||
| 1382 | ;; GNU Emacs | ||
| 1383 | ;; Menu binding | ||
| 1384 | ;; Replace existing "print" item by "Printing" item. | ||
| 1385 | ;; If you're changing this file, you'll load it a second, | ||
| 1386 | ;; third... time, but "print" item exists only in the first load. | ||
| 1387 | (eval-when-compile | ||
| 1388 | (require 'easymenu)) ; to avoid compilation gripes | ||
| 1389 | |||
| 1390 | (eval-and-compile | ||
| 1391 | (cond | ||
| 1392 | ;; GNU Emacs 20 | ||
| 1393 | ((< emacs-major-version 21) | ||
| 1394 | (defun pr-global-menubar (pr-menu-spec) | ||
| 1395 | (require 'easymenu) | ||
| 1396 | (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item) | ||
| 1397 | (when pr-menu-print-item | ||
| 1398 | (easy-menu-remove-item nil '("tools") pr-menu-print-item) | ||
| 1399 | (setq pr-menu-print-item nil | ||
| 1400 | pr-menu-bar (vector 'menu-bar 'tools | ||
| 1401 | (pr-get-symbol "Printing"))))) | ||
| 1402 | ) | ||
| 1403 | ;; GNU Emacs 21 & 22 | ||
| 1404 | (t | ||
| 1405 | (defun pr-global-menubar (pr-menu-spec) | ||
| 1406 | (require 'easymenu) | ||
| 1407 | (let ((menu-file (if (= emacs-major-version 21) | ||
| 1408 | '("menu-bar" "files") ; GNU Emacs 21 | ||
| 1409 | '("menu-bar" "file")))) ; GNU Emacs 22 or higher | ||
| 1410 | (cond | ||
| 1411 | (pr-menu-print-item | ||
| 1412 | (easy-menu-add-item global-map menu-file | ||
| 1413 | (easy-menu-create-menu "Print" pr-menu-spec) | ||
| 1414 | "print-buffer") | ||
| 1415 | (dolist (item '("print-buffer" "print-region" | ||
| 1416 | "ps-print-buffer-faces" "ps-print-region-faces" | ||
| 1417 | "ps-print-buffer" "ps-print-region")) | ||
| 1418 | (easy-menu-remove-item global-map menu-file item)) | ||
| 1419 | (setq pr-menu-print-item nil | ||
| 1420 | pr-menu-bar (vector 'menu-bar | ||
| 1421 | (pr-get-symbol (nth 1 menu-file)) | ||
| 1422 | (pr-get-symbol "Print")))) | ||
| 1423 | (t | ||
| 1424 | (easy-menu-add-item global-map menu-file | ||
| 1425 | (easy-menu-create-menu "Print" pr-menu-spec))) | ||
| 1426 | ))) | ||
| 1427 | ))) | ||
| 1428 | |||
| 1429 | (eval-and-compile | ||
| 1430 | (cond | ||
| 1431 | (ps-windows-system | ||
| 1432 | ;; GNU Emacs for Windows 9x/NT | ||
| 1433 | (defun pr-menu-position (entry index horizontal) | ||
| 1434 | (let ((pos (cdr (mouse-pixel-position)))) | ||
| 1435 | (list | ||
| 1436 | (list (or (car pos) 0) ; X | ||
| 1437 | (- (or (cdr pos) 0) ; Y | ||
| 1438 | (* (pr-menu-index entry index) pr-menu-char-height))) | ||
| 1439 | (selected-frame)))) ; frame | ||
| 1440 | ) | ||
| 1441 | (t | ||
| 1442 | ;; GNU Emacs | ||
| 1443 | (defun pr-menu-position (entry index horizontal) | ||
| 1444 | (let ((pos (cdr (mouse-pixel-position)))) | ||
| 1445 | (list | ||
| 1446 | (list (- (or (car pos) 0) ; X | ||
| 1447 | (* horizontal pr-menu-char-width)) | ||
| 1448 | (- (or (cdr pos) 0) ; Y | ||
| 1449 | (* (pr-menu-index entry index) pr-menu-char-height))) | ||
| 1450 | (selected-frame)))) ; frame | ||
| 1451 | ))) | ||
| 1452 | |||
| 1453 | (defvar pr-menu-position nil) | ||
| 1454 | (defvar pr-menu-state nil) | ||
| 1455 | |||
| 1456 | ;; GNU Emacs | ||
| 1457 | (defun pr-menu-lookup (path) | ||
| 1458 | (lookup-key global-map | ||
| 1459 | (if path | ||
| 1460 | (vconcat pr-menu-bar | ||
| 1461 | (mapcar 'pr-get-symbol | ||
| 1462 | (if (listp path) | ||
| 1463 | path | ||
| 1464 | (list path)))) | ||
| 1465 | pr-menu-bar))) | ||
| 1466 | |||
| 1467 | ;; GNU Emacs | ||
| 1468 | (defun pr-menu-lock (entry index horizontal state path) | ||
| 1469 | (when pr-menu-lock | ||
| 1470 | (or (and pr-menu-position (eq state pr-menu-state)) | ||
| 1471 | (setq pr-menu-position (pr-menu-position entry index horizontal) | ||
| 1472 | pr-menu-state state)) | ||
| 1473 | (let* ((menu (pr-menu-lookup path)) | ||
| 1474 | (result (x-popup-menu pr-menu-position menu))) | ||
| 1475 | (and result | ||
| 1476 | (let ((command (lookup-key menu (vconcat result)))) | ||
| 1477 | (if (fboundp command) | ||
| 1478 | (funcall command) | ||
| 1479 | (eval command))))) | ||
| 1480 | (setq pr-menu-position nil))) | ||
| 1481 | |||
| 1482 | ;; GNU Emacs | ||
| 1483 | (defalias 'pr-update-mode-line 'force-mode-line-update) | ||
| 1484 | |||
| 1485 | ;; GNU Emacs | ||
| 1486 | (defun pr-do-update-menus (&optional force) | ||
| 1487 | (pr-menu-alist pr-ps-printer-alist | ||
| 1488 | 'pr-ps-name | ||
| 1489 | 'pr-menu-set-ps-title | ||
| 1490 | "PostScript Printers" | ||
| 1491 | 'pr-ps-printer-menu-modified | ||
| 1492 | force | ||
| 1493 | "PostScript Printers" | ||
| 1494 | 'postscript 2) | ||
| 1495 | (pr-menu-alist pr-txt-printer-alist | ||
| 1496 | 'pr-txt-name | ||
| 1497 | 'pr-menu-set-txt-title | ||
| 1498 | "Text Printers" | ||
| 1499 | 'pr-txt-printer-menu-modified | ||
| 1500 | force | ||
| 1501 | "Text Printers" | ||
| 1502 | 'text 2) | ||
| 1503 | (let ((save-var pr-ps-utility-menu-modified)) | ||
| 1504 | (pr-menu-alist pr-ps-utility-alist | ||
| 1505 | 'pr-ps-utility | ||
| 1506 | 'pr-menu-set-utility-title | ||
| 1507 | '("PostScript Print" "File" "PostScript Utility") | ||
| 1508 | 'save-var | ||
| 1509 | force | ||
| 1510 | "PostScript Utility" | ||
| 1511 | nil 1)) | ||
| 1512 | (pr-menu-alist pr-ps-utility-alist | ||
| 1513 | 'pr-ps-utility | ||
| 1514 | 'pr-menu-set-utility-title | ||
| 1515 | '("PostScript Preview" "File" "PostScript Utility") | ||
| 1516 | 'pr-ps-utility-menu-modified | ||
| 1517 | force | ||
| 1518 | "PostScript Utility" | ||
| 1519 | nil 1) | ||
| 1520 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | ||
| 1521 | |||
| 1522 | ;; GNU Emacs | ||
| 1523 | (defun pr-menu-get-item (name-list) | ||
| 1524 | ;; NAME-LIST is a string or a list of strings. | ||
| 1525 | (or (listp name-list) | ||
| 1526 | (setq name-list (list name-list))) | ||
| 1527 | (and name-list | ||
| 1528 | (let* ((reversed (reverse name-list)) | ||
| 1529 | (name (pr-get-symbol (car reversed))) | ||
| 1530 | (path (nreverse (cdr reversed))) | ||
| 1531 | (menu (lookup-key | ||
| 1532 | global-map | ||
| 1533 | (vconcat pr-menu-bar | ||
| 1534 | (mapcar 'pr-get-symbol path))))) | ||
| 1535 | (assq name (nthcdr 2 menu))))) | ||
| 1536 | |||
| 1537 | ;; GNU Emacs | ||
| 1538 | (defvar pr-temp-menu nil) | ||
| 1539 | |||
| 1540 | ;; GNU Emacs | ||
| 1541 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | ||
| 1542 | entry index) | ||
| 1543 | (when (and alist (or force (symbol-value modified-sym))) | ||
| 1544 | (easy-menu-define pr-temp-menu nil "" | ||
| 1545 | (pr-menu-create name alist var-sym fun entry index)) | ||
| 1546 | (let ((item (pr-menu-get-item menu-path))) | ||
| 1547 | (and item | ||
| 1548 | (let* ((binding (nthcdr 3 item)) | ||
| 1549 | (key-binding (cdr binding))) | ||
| 1550 | (setcar binding pr-temp-menu) | ||
| 1551 | (and key-binding (listp (car key-binding)) | ||
| 1552 | (setcdr binding (cdr key-binding))) ; skip KEY-BINDING | ||
| 1553 | (funcall fun (symbol-value var-sym) item)))) | ||
| 1554 | (set modified-sym nil))) | ||
| 1555 | |||
| 1556 | ;; GNU Emacs | ||
| 1557 | (defun pr-menu-set-item-name (item name) | ||
| 1558 | (and item | ||
| 1559 | (setcar (nthcdr 2 item) name))) ; ITEM-NAME | ||
| 1560 | |||
| 1561 | ;; GNU Emacs | ||
| 1562 | (defun pr-menu-set-ps-title (value &optional item entry index) | ||
| 1563 | (pr-menu-set-item-name (or item | ||
| 1564 | (pr-menu-get-item "PostScript Printers")) | ||
| 1565 | (format "PostScript Printer: %s" value)) | ||
| 1566 | (pr-ps-set-printer value) | ||
| 1567 | (and index | ||
| 1568 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 1569 | |||
| 1570 | ;; GNU Emacs | ||
| 1571 | (defun pr-menu-set-txt-title (value &optional item entry index) | ||
| 1572 | (pr-menu-set-item-name (or item | ||
| 1573 | (pr-menu-get-item "Text Printers")) | ||
| 1574 | (format "Text Printer: %s" value)) | ||
| 1575 | (pr-txt-set-printer value) | ||
| 1576 | (and index | ||
| 1577 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 1578 | |||
| 1579 | ;; GNU Emacs | ||
| 1580 | (defun pr-menu-set-utility-title (value &optional item entry index) | ||
| 1581 | (let ((name (symbol-name value))) | ||
| 1582 | (if item | ||
| 1583 | (pr-menu-set-item-name item name) | ||
| 1584 | (pr-menu-set-item-name | ||
| 1585 | (pr-menu-get-item | ||
| 1586 | '("PostScript Print" "File" "PostScript Utility")) | ||
| 1587 | name) | ||
| 1588 | (pr-menu-set-item-name | ||
| 1589 | (pr-menu-get-item | ||
| 1590 | '("PostScript Preview" "File" "PostScript Utility")) | ||
| 1591 | name))) | ||
| 1592 | (pr-ps-set-utility value) | ||
| 1593 | (and index | ||
| 1594 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | ||
| 1595 | |||
| 1596 | ;; GNU Emacs | ||
| 1597 | (defun pr-even-or-odd-pages (value &optional no-lock) | ||
| 1598 | (pr-menu-set-item-name (pr-menu-get-item "Print All Pages") | ||
| 1599 | (cdr (assq value pr-even-or-odd-alist))) | ||
| 1600 | (setq ps-even-or-odd-pages value) | ||
| 1601 | (or no-lock | ||
| 1602 | (pr-menu-lock 'postscript-options 8 12 'toggle nil))) | ||
| 1603 | |||
| 1604 | )) ; end cond featurep | ||
| 1161 | 1605 | ||
| 1162 | 1606 | ||
| 1163 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1607 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -1190,7 +1634,68 @@ separator; otherwise, ensure unix-style directory separator." | |||
| 1190 | 1634 | ||
| 1191 | 1635 | ||
| 1192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1636 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1193 | ;; User Interface (II) | 1637 | ;; Customization Functions |
| 1638 | |||
| 1639 | |||
| 1640 | (defun pr-alist-custom-set (symbol value) | ||
| 1641 | "Set the value of custom variables for printer & utility selection." | ||
| 1642 | (set symbol value) | ||
| 1643 | (and (featurep 'printing) ; update only after printing is loaded | ||
| 1644 | (pr-update-menus t))) | ||
| 1645 | |||
| 1646 | |||
| 1647 | (defun pr-ps-utility-custom-set (symbol value) | ||
| 1648 | "Update utility menu entry." | ||
| 1649 | (set symbol value) | ||
| 1650 | (and (featurep 'printing) ; update only after printing is loaded | ||
| 1651 | (pr-menu-set-utility-title value))) | ||
| 1652 | |||
| 1653 | |||
| 1654 | (defun pr-ps-name-custom-set (symbol value) | ||
| 1655 | "Update `PostScript Printer:' menu entry." | ||
| 1656 | (set symbol value) | ||
| 1657 | (and (featurep 'printing) ; update only after printing is loaded | ||
| 1658 | (pr-menu-set-ps-title value))) | ||
| 1659 | |||
| 1660 | |||
| 1661 | (defun pr-txt-name-custom-set (symbol value) | ||
| 1662 | "Update `Text Printer:' menu entry." | ||
| 1663 | (set symbol value) | ||
| 1664 | (and (featurep 'printing) ; update only after printing is loaded | ||
| 1665 | (pr-menu-set-txt-title value))) | ||
| 1666 | |||
| 1667 | |||
| 1668 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1669 | ;; User Interface | ||
| 1670 | |||
| 1671 | |||
| 1672 | (defgroup printing nil | ||
| 1673 | "Printing Utilities group." | ||
| 1674 | :tag "Printing Utilities" | ||
| 1675 | :link '(emacs-library-link :tag "Source Lisp File" "printing.el") | ||
| 1676 | :prefix "pr-" | ||
| 1677 | :version "20" | ||
| 1678 | :group 'wp | ||
| 1679 | :group 'postscript) | ||
| 1680 | |||
| 1681 | |||
| 1682 | (defcustom pr-path-style | ||
| 1683 | (if (and (not pr-cygwin-system) | ||
| 1684 | ps-windows-system) | ||
| 1685 | 'windows | ||
| 1686 | 'unix) | ||
| 1687 | "*Specify which path style to use for external commands. | ||
| 1688 | |||
| 1689 | Valid values are: | ||
| 1690 | |||
| 1691 | windows Windows 9x/NT style (\\) | ||
| 1692 | |||
| 1693 | unix Unix style (/)" | ||
| 1694 | :type '(choice :tag "Path style" | ||
| 1695 | (const :tag "Windows 9x/NT Style (\\)" :value windows) | ||
| 1696 | (const :tag "Unix Style (/)" :value unix)) | ||
| 1697 | :version "20" | ||
| 1698 | :group 'printing) | ||
| 1194 | 1699 | ||
| 1195 | 1700 | ||
| 1196 | (defcustom pr-path-alist | 1701 | (defcustom pr-path-alist |
| @@ -2412,6 +2917,30 @@ See also `pr-menu-char-height' and `pr-menu-char-width'." | |||
| 2412 | :group 'printing) | 2917 | :group 'printing) |
| 2413 | 2918 | ||
| 2414 | 2919 | ||
| 2920 | (defcustom pr-menu-char-height (pr-menu-char-height) | ||
| 2921 | "*Specify menu char height in pixels. | ||
| 2922 | |||
| 2923 | This variable is used to guess which vertical position should be locked the | ||
| 2924 | menu, so don't forget to adjust it if menu position is not ok. | ||
| 2925 | |||
| 2926 | See also `pr-menu-lock' and `pr-menu-char-width'." | ||
| 2927 | :type 'integer | ||
| 2928 | :version "20" | ||
| 2929 | :group 'printing) | ||
| 2930 | |||
| 2931 | |||
| 2932 | (defcustom pr-menu-char-width (pr-menu-char-width) | ||
| 2933 | "*Specify menu char width in pixels. | ||
| 2934 | |||
| 2935 | This variable is used to guess which horizontal position should be locked the | ||
| 2936 | menu, so don't forget to adjust it if menu position is not ok. | ||
| 2937 | |||
| 2938 | See also `pr-menu-lock' and `pr-menu-char-height'." | ||
| 2939 | :type 'integer | ||
| 2940 | :version "20" | ||
| 2941 | :group 'printing) | ||
| 2942 | |||
| 2943 | |||
| 2415 | (defcustom pr-setting-database | 2944 | (defcustom pr-setting-database |
| 2416 | '((no-duplex ; setting symbol name | 2945 | '((no-duplex ; setting symbol name |
| 2417 | nil nil nil ; inherits local kill-local | 2946 | nil nil nil ; inherits local kill-local |
| @@ -2640,13 +3169,6 @@ It's used by `pr-interface'." | |||
| 2640 | :version "20" | 3169 | :version "20" |
| 2641 | :group 'printing) | 3170 | :group 'printing) |
| 2642 | 3171 | ||
| 2643 | (defconst pr-even-or-odd-alist | ||
| 2644 | '((nil . "Print All Pages") | ||
| 2645 | (even-page . "Print Even Pages") | ||
| 2646 | (odd-page . "Print Odd Pages") | ||
| 2647 | (even-sheet . "Print Even Sheets") | ||
| 2648 | (odd-sheet . "Print Odd Sheets"))) | ||
| 2649 | |||
| 2650 | 3172 | ||
| 2651 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 3173 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2652 | ;; Internal Variables | 3174 | ;; Internal Variables |
| @@ -2687,504 +3209,6 @@ See `pr-ps-printer-alist'.") | |||
| 2687 | See `pr-ps-printer-alist'.") | 3209 | See `pr-ps-printer-alist'.") |
| 2688 | 3210 | ||
| 2689 | 3211 | ||
| 2690 | (defvar pr-menu-bar nil | ||
| 2691 | "Specify Printing menu-bar entry.") | ||
| 2692 | |||
| 2693 | (defvar pr-menu-print-item "print" | ||
| 2694 | "Non-nil means that menu binding was not done. | ||
| 2695 | |||
| 2696 | Used by `pr-menu-bind' and `pr-update-menus'.") | ||
| 2697 | |||
| 2698 | |||
| 2699 | (defvar pr-ps-printer-menu-modified t | ||
| 2700 | "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.") | ||
| 2701 | (defvar pr-txt-printer-menu-modified t | ||
| 2702 | "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.") | ||
| 2703 | (defvar pr-ps-utility-menu-modified t | ||
| 2704 | "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.") | ||
| 2705 | |||
| 2706 | (defvar pr-menu-char-width) ;; Pacify the byte compiler. | ||
| 2707 | (defvar pr-menu-char-height) | ||
| 2708 | |||
| 2709 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2710 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2711 | ;; XEmacs Definitions | ||
| 2712 | |||
| 2713 | |||
| 2714 | (cond | ||
| 2715 | ((featurep 'xemacs) ; XEmacs | ||
| 2716 | ;; XEmacs | ||
| 2717 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) | ||
| 2718 | (defalias 'pr-f-set-keymap-name 'set-keymap-name) | ||
| 2719 | |||
| 2720 | ;; XEmacs | ||
| 2721 | (defun pr-f-read-string (prompt initial history default) | ||
| 2722 | (let ((str (read-string prompt initial))) | ||
| 2723 | (if (and str (not (string= str ""))) | ||
| 2724 | str | ||
| 2725 | default))) | ||
| 2726 | |||
| 2727 | ;; XEmacs | ||
| 2728 | (defvar zmacs-region-stays nil) | ||
| 2729 | |||
| 2730 | ;; XEmacs | ||
| 2731 | (defun pr-keep-region-active () | ||
| 2732 | (setq zmacs-region-stays t)) | ||
| 2733 | |||
| 2734 | ;; XEmacs | ||
| 2735 | (defun pr-region-active-p () | ||
| 2736 | (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))) | ||
| 2737 | |||
| 2738 | ;; XEmacs | ||
| 2739 | (defun pr-menu-char-height () | ||
| 2740 | (font-height (face-font 'default))) | ||
| 2741 | |||
| 2742 | ;; XEmacs | ||
| 2743 | (defun pr-menu-char-width () | ||
| 2744 | (font-width (face-font 'default))) | ||
| 2745 | |||
| 2746 | ;; XEmacs | ||
| 2747 | (defmacro pr-xemacs-global-menubar (&rest body) | ||
| 2748 | `(save-excursion | ||
| 2749 | (let ((temp (get-buffer-create (make-temp-name " *Temp")))) | ||
| 2750 | ;; be sure to access global menubar | ||
| 2751 | (set-buffer temp) | ||
| 2752 | ,@body | ||
| 2753 | (kill-buffer temp)))) | ||
| 2754 | |||
| 2755 | ;; XEmacs | ||
| 2756 | (defun pr-global-menubar (pr-menu-spec) | ||
| 2757 | ;; Menu binding | ||
| 2758 | (pr-xemacs-global-menubar | ||
| 2759 | (add-submenu nil (cons "Printing" pr-menu-spec) "Apps")) | ||
| 2760 | (setq pr-menu-print-item nil)) | ||
| 2761 | |||
| 2762 | ;; XEmacs | ||
| 2763 | (defvar current-mouse-event nil) | ||
| 2764 | (defun pr-menu-position (entry index horizontal) | ||
| 2765 | (make-event | ||
| 2766 | 'button-release | ||
| 2767 | (list 'button 1 | ||
| 2768 | 'x (- (event-x-pixel current-mouse-event) ; X | ||
| 2769 | (* horizontal pr-menu-char-width)) | ||
| 2770 | 'y (- (event-y-pixel current-mouse-event) ; Y | ||
| 2771 | (* (pr-menu-index entry index) pr-menu-char-height))))) | ||
| 2772 | |||
| 2773 | (defvar pr-menu-position nil) | ||
| 2774 | (defvar pr-menu-state nil) | ||
| 2775 | |||
| 2776 | ;; XEmacs | ||
| 2777 | (defvar current-menubar nil) ; to avoid compilation gripes | ||
| 2778 | (defun pr-menu-lookup (path) | ||
| 2779 | (car (find-menu-item current-menubar (cons "Printing" path)))) | ||
| 2780 | |||
| 2781 | ;; XEmacs | ||
| 2782 | (defun pr-menu-lock (entry index horizontal state path) | ||
| 2783 | (when pr-menu-lock | ||
| 2784 | (or (and pr-menu-position (eq state pr-menu-state)) | ||
| 2785 | (setq pr-menu-position (pr-menu-position entry index horizontal) | ||
| 2786 | pr-menu-state state)) | ||
| 2787 | (let* ((menu (pr-menu-lookup path)) | ||
| 2788 | (result (get-popup-menu-response menu pr-menu-position))) | ||
| 2789 | (and (misc-user-event-p result) | ||
| 2790 | (funcall (event-function result) | ||
| 2791 | (event-object result)))) | ||
| 2792 | (setq pr-menu-position nil))) | ||
| 2793 | |||
| 2794 | ;; XEmacs | ||
| 2795 | (defalias 'pr-update-mode-line 'set-menubar-dirty-flag) | ||
| 2796 | |||
| 2797 | ;; XEmacs | ||
| 2798 | (defvar pr-ps-name-old "PostScript Printers") | ||
| 2799 | (defvar pr-txt-name-old "Text Printers") | ||
| 2800 | (defvar pr-ps-utility-old "PostScript Utility") | ||
| 2801 | (defvar pr-even-or-odd-old "Print All Pages") | ||
| 2802 | |||
| 2803 | ;; XEmacs | ||
| 2804 | (defun pr-do-update-menus (&optional force) | ||
| 2805 | (pr-menu-alist pr-ps-printer-alist | ||
| 2806 | 'pr-ps-name | ||
| 2807 | 'pr-menu-set-ps-title | ||
| 2808 | '("Printing") | ||
| 2809 | 'pr-ps-printer-menu-modified | ||
| 2810 | force | ||
| 2811 | pr-ps-name-old | ||
| 2812 | 'postscript 2) | ||
| 2813 | (pr-menu-alist pr-txt-printer-alist | ||
| 2814 | 'pr-txt-name | ||
| 2815 | 'pr-menu-set-txt-title | ||
| 2816 | '("Printing") | ||
| 2817 | 'pr-txt-printer-menu-modified | ||
| 2818 | force | ||
| 2819 | pr-txt-name-old | ||
| 2820 | 'text 2) | ||
| 2821 | (let ((save-var pr-ps-utility-menu-modified)) | ||
| 2822 | (pr-menu-alist pr-ps-utility-alist | ||
| 2823 | 'pr-ps-utility | ||
| 2824 | 'pr-menu-set-utility-title | ||
| 2825 | '("Printing" "PostScript Print" "File") | ||
| 2826 | 'save-var | ||
| 2827 | force | ||
| 2828 | pr-ps-utility-old | ||
| 2829 | nil 1)) | ||
| 2830 | (pr-menu-alist pr-ps-utility-alist | ||
| 2831 | 'pr-ps-utility | ||
| 2832 | 'pr-menu-set-utility-title | ||
| 2833 | '("Printing" "PostScript Preview" "File") | ||
| 2834 | 'pr-ps-utility-menu-modified | ||
| 2835 | force | ||
| 2836 | pr-ps-utility-old | ||
| 2837 | nil 1) | ||
| 2838 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | ||
| 2839 | |||
| 2840 | ;; XEmacs | ||
| 2841 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | ||
| 2842 | entry index) | ||
| 2843 | (when (and alist (or force (symbol-value modified-sym))) | ||
| 2844 | (pr-xemacs-global-menubar | ||
| 2845 | (add-submenu menu-path | ||
| 2846 | (pr-menu-create name alist var-sym | ||
| 2847 | fun entry index))) | ||
| 2848 | (funcall fun (symbol-value var-sym)) | ||
| 2849 | (set modified-sym nil))) | ||
| 2850 | |||
| 2851 | ;; XEmacs | ||
| 2852 | (defun pr-relabel-menu-item (newname var-sym) | ||
| 2853 | (pr-xemacs-global-menubar | ||
| 2854 | (relabel-menu-item | ||
| 2855 | (list "Printing" (symbol-value var-sym)) | ||
| 2856 | newname) | ||
| 2857 | (set var-sym newname))) | ||
| 2858 | |||
| 2859 | ;; XEmacs | ||
| 2860 | (defun pr-menu-set-ps-title (value &optional item entry index) | ||
| 2861 | (pr-relabel-menu-item (format "PostScript Printer: %s" value) | ||
| 2862 | 'pr-ps-name-old) | ||
| 2863 | (pr-ps-set-printer value) | ||
| 2864 | (and index | ||
| 2865 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 2866 | |||
| 2867 | ;; XEmacs | ||
| 2868 | (defun pr-menu-set-txt-title (value &optional item entry index) | ||
| 2869 | (pr-relabel-menu-item (format "Text Printer: %s" value) | ||
| 2870 | 'pr-txt-name-old) | ||
| 2871 | (pr-txt-set-printer value) | ||
| 2872 | (and index | ||
| 2873 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 2874 | |||
| 2875 | ;; XEmacs | ||
| 2876 | (defun pr-menu-set-utility-title (value &optional item entry index) | ||
| 2877 | (pr-xemacs-global-menubar | ||
| 2878 | (let ((newname (format "%s" value))) | ||
| 2879 | (relabel-menu-item | ||
| 2880 | (list "Printing" "PostScript Print" "File" pr-ps-utility-old) | ||
| 2881 | newname) | ||
| 2882 | (relabel-menu-item | ||
| 2883 | (list "Printing" "PostScript Preview" "File" pr-ps-utility-old) | ||
| 2884 | newname) | ||
| 2885 | (setq pr-ps-utility-old newname))) | ||
| 2886 | (pr-ps-set-utility value) | ||
| 2887 | (and index | ||
| 2888 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | ||
| 2889 | |||
| 2890 | ;; XEmacs | ||
| 2891 | (defun pr-even-or-odd-pages (value &optional no-lock) | ||
| 2892 | (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist)) | ||
| 2893 | 'pr-even-or-odd-old) | ||
| 2894 | (setq ps-even-or-odd-pages value) | ||
| 2895 | (or no-lock | ||
| 2896 | (pr-menu-lock 'postscript-options 8 12 'toggle nil))) | ||
| 2897 | |||
| 2898 | ) | ||
| 2899 | (t ; GNU Emacs | ||
| 2900 | ;; Do nothing | ||
| 2901 | )) ; end cond featurep | ||
| 2902 | |||
| 2903 | |||
| 2904 | |||
| 2905 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2906 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2907 | ;; GNU Emacs Definitions | ||
| 2908 | |||
| 2909 | |||
| 2910 | (cond | ||
| 2911 | ((featurep 'xemacs) ; XEmacs | ||
| 2912 | ;; Do nothing | ||
| 2913 | ) | ||
| 2914 | (t ; GNU Emacs | ||
| 2915 | ;; GNU Emacs | ||
| 2916 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) | ||
| 2917 | (defalias 'pr-f-set-keymap-name 'ignore) | ||
| 2918 | (defalias 'pr-f-read-string 'read-string) | ||
| 2919 | |||
| 2920 | ;; GNU Emacs | ||
| 2921 | (defvar deactivate-mark) | ||
| 2922 | |||
| 2923 | ;; GNU Emacs | ||
| 2924 | (defun pr-keep-region-active () | ||
| 2925 | (setq deactivate-mark nil)) | ||
| 2926 | |||
| 2927 | ;; GNU Emacs | ||
| 2928 | (defun pr-region-active-p () | ||
| 2929 | (and pr-auto-region transient-mark-mode mark-active)) | ||
| 2930 | |||
| 2931 | ;; GNU Emacs | ||
| 2932 | (defun pr-menu-char-height () | ||
| 2933 | (frame-char-height)) | ||
| 2934 | |||
| 2935 | ;; GNU Emacs | ||
| 2936 | (defun pr-menu-char-width () | ||
| 2937 | (frame-char-width)) | ||
| 2938 | |||
| 2939 | ;; GNU Emacs | ||
| 2940 | ;; Menu binding | ||
| 2941 | ;; Replace existing "print" item by "Printing" item. | ||
| 2942 | ;; If you're changing this file, you'll load it a second, | ||
| 2943 | ;; third... time, but "print" item exists only in the first load. | ||
| 2944 | (eval-and-compile | ||
| 2945 | (cond | ||
| 2946 | ;; GNU Emacs 20 | ||
| 2947 | ((< emacs-major-version 21) | ||
| 2948 | (defun pr-global-menubar (pr-menu-spec) | ||
| 2949 | (require 'easymenu) | ||
| 2950 | (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item) | ||
| 2951 | (when pr-menu-print-item | ||
| 2952 | (easy-menu-remove-item nil '("tools") pr-menu-print-item) | ||
| 2953 | (setq pr-menu-print-item nil | ||
| 2954 | pr-menu-bar (vector 'menu-bar 'tools | ||
| 2955 | (pr-get-symbol "Printing"))))) | ||
| 2956 | ) | ||
| 2957 | ;; GNU Emacs 21 & 22 | ||
| 2958 | (t | ||
| 2959 | (defun pr-global-menubar (pr-menu-spec) | ||
| 2960 | (require 'easymenu) | ||
| 2961 | (let ((menu-file (if (= emacs-major-version 21) | ||
| 2962 | '("menu-bar" "files") ; GNU Emacs 21 | ||
| 2963 | '("menu-bar" "file")))) ; GNU Emacs 22 or higher | ||
| 2964 | (cond | ||
| 2965 | (pr-menu-print-item | ||
| 2966 | (easy-menu-add-item global-map menu-file | ||
| 2967 | (easy-menu-create-menu "Print" pr-menu-spec) | ||
| 2968 | "print-buffer") | ||
| 2969 | (dolist (item '("print-buffer" "print-region" | ||
| 2970 | "ps-print-buffer-faces" "ps-print-region-faces" | ||
| 2971 | "ps-print-buffer" "ps-print-region")) | ||
| 2972 | (easy-menu-remove-item global-map menu-file item)) | ||
| 2973 | (setq pr-menu-print-item nil | ||
| 2974 | pr-menu-bar (vector 'menu-bar | ||
| 2975 | (pr-get-symbol (nth 1 menu-file)) | ||
| 2976 | (pr-get-symbol "Print")))) | ||
| 2977 | (t | ||
| 2978 | (easy-menu-add-item global-map menu-file | ||
| 2979 | (easy-menu-create-menu "Print" pr-menu-spec))) | ||
| 2980 | ))) | ||
| 2981 | ))) | ||
| 2982 | |||
| 2983 | (eval-and-compile | ||
| 2984 | (cond | ||
| 2985 | (ps-windows-system | ||
| 2986 | ;; GNU Emacs for Windows 9x/NT | ||
| 2987 | (defun pr-menu-position (entry index horizontal) | ||
| 2988 | (let ((pos (cdr (mouse-pixel-position)))) | ||
| 2989 | (list | ||
| 2990 | (list (or (car pos) 0) ; X | ||
| 2991 | (- (or (cdr pos) 0) ; Y | ||
| 2992 | (* (pr-menu-index entry index) pr-menu-char-height))) | ||
| 2993 | (selected-frame)))) ; frame | ||
| 2994 | ) | ||
| 2995 | (t | ||
| 2996 | ;; GNU Emacs | ||
| 2997 | (defun pr-menu-position (entry index horizontal) | ||
| 2998 | (let ((pos (cdr (mouse-pixel-position)))) | ||
| 2999 | (list | ||
| 3000 | (list (- (or (car pos) 0) ; X | ||
| 3001 | (* horizontal pr-menu-char-width)) | ||
| 3002 | (- (or (cdr pos) 0) ; Y | ||
| 3003 | (* (pr-menu-index entry index) pr-menu-char-height))) | ||
| 3004 | (selected-frame)))) ; frame | ||
| 3005 | ))) | ||
| 3006 | |||
| 3007 | (defvar pr-menu-position nil) | ||
| 3008 | (defvar pr-menu-state nil) | ||
| 3009 | |||
| 3010 | ;; GNU Emacs | ||
| 3011 | (defun pr-menu-lookup (path) | ||
| 3012 | (lookup-key global-map | ||
| 3013 | (if path | ||
| 3014 | (vconcat pr-menu-bar | ||
| 3015 | (mapcar 'pr-get-symbol | ||
| 3016 | (if (listp path) | ||
| 3017 | path | ||
| 3018 | (list path)))) | ||
| 3019 | pr-menu-bar))) | ||
| 3020 | |||
| 3021 | ;; GNU Emacs | ||
| 3022 | (defun pr-menu-lock (entry index horizontal state path) | ||
| 3023 | (when pr-menu-lock | ||
| 3024 | (or (and pr-menu-position (eq state pr-menu-state)) | ||
| 3025 | (setq pr-menu-position (pr-menu-position entry index horizontal) | ||
| 3026 | pr-menu-state state)) | ||
| 3027 | (let* ((menu (pr-menu-lookup path)) | ||
| 3028 | (result (x-popup-menu pr-menu-position menu))) | ||
| 3029 | (and result | ||
| 3030 | (let ((command (lookup-key menu (vconcat result)))) | ||
| 3031 | (if (fboundp command) | ||
| 3032 | (funcall command) | ||
| 3033 | (eval command))))) | ||
| 3034 | (setq pr-menu-position nil))) | ||
| 3035 | |||
| 3036 | ;; GNU Emacs | ||
| 3037 | (defalias 'pr-update-mode-line 'force-mode-line-update) | ||
| 3038 | |||
| 3039 | ;; GNU Emacs | ||
| 3040 | (defun pr-do-update-menus (&optional force) | ||
| 3041 | (pr-menu-alist pr-ps-printer-alist | ||
| 3042 | 'pr-ps-name | ||
| 3043 | 'pr-menu-set-ps-title | ||
| 3044 | "PostScript Printers" | ||
| 3045 | 'pr-ps-printer-menu-modified | ||
| 3046 | force | ||
| 3047 | "PostScript Printers" | ||
| 3048 | 'postscript 2) | ||
| 3049 | (pr-menu-alist pr-txt-printer-alist | ||
| 3050 | 'pr-txt-name | ||
| 3051 | 'pr-menu-set-txt-title | ||
| 3052 | "Text Printers" | ||
| 3053 | 'pr-txt-printer-menu-modified | ||
| 3054 | force | ||
| 3055 | "Text Printers" | ||
| 3056 | 'text 2) | ||
| 3057 | (let ((save-var pr-ps-utility-menu-modified)) | ||
| 3058 | (pr-menu-alist pr-ps-utility-alist | ||
| 3059 | 'pr-ps-utility | ||
| 3060 | 'pr-menu-set-utility-title | ||
| 3061 | '("PostScript Print" "File" "PostScript Utility") | ||
| 3062 | 'save-var | ||
| 3063 | force | ||
| 3064 | "PostScript Utility" | ||
| 3065 | nil 1)) | ||
| 3066 | (pr-menu-alist pr-ps-utility-alist | ||
| 3067 | 'pr-ps-utility | ||
| 3068 | 'pr-menu-set-utility-title | ||
| 3069 | '("PostScript Preview" "File" "PostScript Utility") | ||
| 3070 | 'pr-ps-utility-menu-modified | ||
| 3071 | force | ||
| 3072 | "PostScript Utility" | ||
| 3073 | nil 1) | ||
| 3074 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) | ||
| 3075 | |||
| 3076 | ;; GNU Emacs | ||
| 3077 | (defun pr-menu-get-item (name-list) | ||
| 3078 | ;; NAME-LIST is a string or a list of strings. | ||
| 3079 | (or (listp name-list) | ||
| 3080 | (setq name-list (list name-list))) | ||
| 3081 | (and name-list | ||
| 3082 | (let* ((reversed (reverse name-list)) | ||
| 3083 | (name (pr-get-symbol (car reversed))) | ||
| 3084 | (path (nreverse (cdr reversed))) | ||
| 3085 | (menu (lookup-key | ||
| 3086 | global-map | ||
| 3087 | (vconcat pr-menu-bar | ||
| 3088 | (mapcar 'pr-get-symbol path))))) | ||
| 3089 | (assq name (nthcdr 2 menu))))) | ||
| 3090 | |||
| 3091 | ;; GNU Emacs | ||
| 3092 | (defvar pr-temp-menu nil) | ||
| 3093 | |||
| 3094 | ;; GNU Emacs | ||
| 3095 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name | ||
| 3096 | entry index) | ||
| 3097 | (when (and alist (or force (symbol-value modified-sym))) | ||
| 3098 | (easy-menu-define pr-temp-menu nil "" | ||
| 3099 | (pr-menu-create name alist var-sym fun entry index)) | ||
| 3100 | (let ((item (pr-menu-get-item menu-path))) | ||
| 3101 | (and item | ||
| 3102 | (let* ((binding (nthcdr 3 item)) | ||
| 3103 | (key-binding (cdr binding))) | ||
| 3104 | (setcar binding pr-temp-menu) | ||
| 3105 | (and key-binding (listp (car key-binding)) | ||
| 3106 | (setcdr binding (cdr key-binding))) ; skip KEY-BINDING | ||
| 3107 | (funcall fun (symbol-value var-sym) item)))) | ||
| 3108 | (set modified-sym nil))) | ||
| 3109 | |||
| 3110 | ;; GNU Emacs | ||
| 3111 | (defun pr-menu-set-item-name (item name) | ||
| 3112 | (and item | ||
| 3113 | (setcar (nthcdr 2 item) name))) ; ITEM-NAME | ||
| 3114 | |||
| 3115 | ;; GNU Emacs | ||
| 3116 | (defun pr-menu-set-ps-title (value &optional item entry index) | ||
| 3117 | (pr-menu-set-item-name (or item | ||
| 3118 | (pr-menu-get-item "PostScript Printers")) | ||
| 3119 | (format "PostScript Printer: %s" value)) | ||
| 3120 | (pr-ps-set-printer value) | ||
| 3121 | (and index | ||
| 3122 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 3123 | |||
| 3124 | ;; GNU Emacs | ||
| 3125 | (defun pr-menu-set-txt-title (value &optional item entry index) | ||
| 3126 | (pr-menu-set-item-name (or item | ||
| 3127 | (pr-menu-get-item "Text Printers")) | ||
| 3128 | (format "Text Printer: %s" value)) | ||
| 3129 | (pr-txt-set-printer value) | ||
| 3130 | (and index | ||
| 3131 | (pr-menu-lock entry index 12 'toggle nil))) | ||
| 3132 | |||
| 3133 | ;; GNU Emacs | ||
| 3134 | (defun pr-menu-set-utility-title (value &optional item entry index) | ||
| 3135 | (let ((name (symbol-name value))) | ||
| 3136 | (if item | ||
| 3137 | (pr-menu-set-item-name item name) | ||
| 3138 | (pr-menu-set-item-name | ||
| 3139 | (pr-menu-get-item | ||
| 3140 | '("PostScript Print" "File" "PostScript Utility")) | ||
| 3141 | name) | ||
| 3142 | (pr-menu-set-item-name | ||
| 3143 | (pr-menu-get-item | ||
| 3144 | '("PostScript Preview" "File" "PostScript Utility")) | ||
| 3145 | name))) | ||
| 3146 | (pr-ps-set-utility value) | ||
| 3147 | (and index | ||
| 3148 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) | ||
| 3149 | |||
| 3150 | ;; GNU Emacs | ||
| 3151 | (defun pr-even-or-odd-pages (value &optional no-lock) | ||
| 3152 | (pr-menu-set-item-name (pr-menu-get-item "Print All Pages") | ||
| 3153 | (cdr (assq value pr-even-or-odd-alist))) | ||
| 3154 | (setq ps-even-or-odd-pages value) | ||
| 3155 | (or no-lock | ||
| 3156 | (pr-menu-lock 'postscript-options 8 12 'toggle nil))) | ||
| 3157 | |||
| 3158 | )) ; end cond featurep | ||
| 3159 | |||
| 3160 | |||
| 3161 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 3162 | ;; User Interface (III) | ||
| 3163 | |||
| 3164 | (defcustom pr-menu-char-height (pr-menu-char-height) | ||
| 3165 | "*Specify menu char height in pixels. | ||
| 3166 | |||
| 3167 | This variable is used to guess which vertical position should be locked the | ||
| 3168 | menu, so don't forget to adjust it if menu position is not ok. | ||
| 3169 | |||
| 3170 | See also `pr-menu-lock' and `pr-menu-char-width'." | ||
| 3171 | :type 'integer | ||
| 3172 | :version "20" | ||
| 3173 | :group 'printing) | ||
| 3174 | |||
| 3175 | |||
| 3176 | (defcustom pr-menu-char-width (pr-menu-char-width) | ||
| 3177 | "*Specify menu char width in pixels. | ||
| 3178 | |||
| 3179 | This variable is used to guess which horizontal position should be locked the | ||
| 3180 | menu, so don't forget to adjust it if menu position is not ok. | ||
| 3181 | |||
| 3182 | See also `pr-menu-lock' and `pr-menu-char-height'." | ||
| 3183 | :type 'integer | ||
| 3184 | :version "20" | ||
| 3185 | :group 'printing) | ||
| 3186 | |||
| 3187 | |||
| 3188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 3212 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 3189 | ;; Macros | 3213 | ;; Macros |
| 3190 | 3214 | ||