Mercurial > hg > xemacs-beta
comparison lisp/x-toolbar.el @ 221:6c0ae1f9357f r20-4b9
Import from CVS: tag r20-4b9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:10:02 +0200 |
parents | 262b8bb4a523 |
children | 2c611d1463a6 |
comparison
equal
deleted
inserted
replaced
220:04f4bca7b601 | 221:6c0ae1f9357f |
---|---|
36 | 36 |
37 ;;; Code: | 37 ;;; Code: |
38 | 38 |
39 ;; Suppress warning message from bytecompiler | 39 ;; Suppress warning message from bytecompiler |
40 (eval-when-compile | 40 (eval-when-compile |
41 (defvar pending-delete)) | 41 (defvar pending-delete-mode)) |
42 | 42 |
43 (defgroup toolbar nil | 43 (defgroup toolbar nil |
44 "Configure XEmacs Toolbar functions and properties" | 44 "Configure XEmacs Toolbar functions and properties" |
45 :group 'environment) | 45 :group 'environment) |
46 | 46 |
47 | 47 |
48 (defun toolbar-not-configured () | 48 (defun toolbar-not-configured () |
49 (ding) | 49 (interactive) |
50 (message "Configure the item via `M-x customize RET toolbar RET'")) | 50 ;; Note: we don't use `susbtitute-command-keys' here, because |
51 ;; Customize is bound to `C-h C' by default, and that binding is not | |
52 ;; familiar to people. This is more descriptive. | |
53 (error | |
54 "Configure the item via `M-x customize RET toolbar RET'")) | |
51 | 55 |
52 (defcustom toolbar-open-function 'find-file | 56 (defcustom toolbar-open-function 'find-file |
53 "*Function to call when the open icon is selected." | 57 "*Function to call when the open icon is selected." |
54 :type '(radio (function-item find-file) | 58 :type '(radio (function-item find-file) |
55 (function :tag "Other")) | 59 (function :tag "Other")) |
116 :group 'toolbar) | 120 :group 'toolbar) |
117 | 121 |
118 (defun toolbar-paste () | 122 (defun toolbar-paste () |
119 (interactive) | 123 (interactive) |
120 ;; This horrible kludge is for pending-delete to work correctly. | 124 ;; This horrible kludge is for pending-delete to work correctly. |
121 (and (boundp 'pending-delete) | 125 (and (boundp 'pending-delete-mode) |
122 pending-delete | 126 pending-delete-mode |
123 (let ((this-command toolbar-paste-function)) | 127 (let ((this-command toolbar-paste-function)) |
124 (pending-delete-pre-hook))) | 128 (pending-delete-pre-hook))) |
125 (call-interactively toolbar-paste-function)) | 129 (call-interactively toolbar-paste-function)) |
126 | 130 |
127 (defcustom toolbar-undo-function 'undo | 131 (defcustom toolbar-undo-function 'undo |
148 ;; toolbar ispell variables and defuns | 152 ;; toolbar ispell variables and defuns |
149 ;; | 153 ;; |
150 | 154 |
151 (defun toolbar-ispell-internal () | 155 (defun toolbar-ispell-internal () |
152 (interactive) | 156 (interactive) |
153 (if (region-active-p) | 157 (if (region-active-p) |
154 (ispell-region (region-beginning) (region-end)) | 158 (ispell-region (region-beginning) (region-end)) |
155 (ispell-buffer))) | 159 (ispell-buffer))) |
156 | 160 |
157 (defcustom toolbar-ispell-function 'toolbar-ispell-internal | 161 (defcustom toolbar-ispell-function 'toolbar-ispell-internal |
158 "*Function to call when the ispell icon is selected." | 162 "*Function to call when the ispell icon is selected." |
159 :type '(radio (function-item toolbar-ispell-internal) | 163 :type '(radio (function-item toolbar-ispell-internal) |
160 (function :tag "Other")) | 164 (function :tag "Other")) |
217 | 221 |
218 (defun toolbar-mail () | 222 (defun toolbar-mail () |
219 "Run mail in a separate frame." | 223 "Run mail in a separate frame." |
220 (interactive) | 224 (interactive) |
221 (let ((command (cdr (assq toolbar-mail-reader toolbar-mail-commands-alist)))) | 225 (let ((command (cdr (assq toolbar-mail-reader toolbar-mail-commands-alist)))) |
222 (if (not command) | 226 (or command |
223 (error "Uknown mail reader %s" toolbar-mail-reader)) | 227 (error "Uknown mail reader %s" toolbar-mail-reader)) |
224 (if (symbolp command) | 228 (if (symbolp command) |
225 (call-interactively command) | 229 (call-interactively command) |
226 (eval command)))) | 230 (eval command)))) |
227 | 231 |
228 ;; | 232 ;; |
229 ;; toolbar info variables and defuns | 233 ;; toolbar info variables and defuns |
230 ;; | 234 ;; |
231 | 235 |
236 (defcustom toolbar-info-use-separate-frame t | |
237 "*Whether Info is invoked in a separate frame." | |
238 :type 'boolean | |
239 :group 'toolbar) | |
240 | |
241 (defcustom toolbar-info-frame-plist | |
242 ;; Info pages are 80 characters wide, so it makes a good default. | |
243 `(width 80 ,@(let ((h (plist-get default-frame-plist 'height))) | |
244 (and h `(height ,h)))) | |
245 "*The properties of the frame in which news is displayed." | |
246 :type 'plist | |
247 :group 'info) | |
248 | |
249 (define-obsolete-variable-alias 'Info-frame-plist | |
250 'toolbar-info-frame-plist) | |
251 | |
232 (defvar toolbar-info-frame nil | 252 (defvar toolbar-info-frame nil |
233 "The frame in which info is displayed.") | 253 "The frame in which info is displayed.") |
234 | 254 |
235 (defcustom Info-frame-plist | |
236 (append (list 'width 80) | |
237 (let ((h (plist-get default-frame-plist 'height))) | |
238 (when h (list 'height h)))) | |
239 "Frame plist for the Info frame." | |
240 :type '(repeat (group :inline t | |
241 (symbol :tag "Property") | |
242 (sexp :tag "Value"))) | |
243 :group 'info) | |
244 | |
245 (defun toolbar-info () | 255 (defun toolbar-info () |
246 "Run info in a separate frame." | 256 "Run info in a separate frame." |
247 (interactive) | 257 (interactive) |
248 (if (or (not toolbar-info-frame) | 258 (when toolbar-info-use-separate-frame |
249 (not (frame-live-p toolbar-info-frame))) | 259 (cond ((or (not toolbar-info-frame) |
250 (progn | 260 (not (frame-live-p toolbar-info-frame))) |
251 (setq toolbar-info-frame (make-frame Info-frame-plist)) | 261 ;; We used to raise frame here, but it's a bad idea, |
252 (select-frame toolbar-info-frame) | 262 ;; because raising is a matter of WM policy. However, we |
253 (raise-frame toolbar-info-frame))) | 263 ;; *must* select it, to ensure that the info buffer goes to |
254 (if (frame-iconified-p toolbar-info-frame) | 264 ;; the right frame. |
255 (deiconify-frame toolbar-info-frame)) | 265 (setq toolbar-info-frame (make-frame toolbar-info-frame-plist)) |
256 (select-frame toolbar-info-frame) | 266 (select-frame toolbar-info-frame)) |
257 (raise-frame toolbar-info-frame) | 267 (t |
268 ;; However, if the frame already exists, and the user | |
269 ;; clicks on info, it's OK to raise it. | |
270 (select-frame toolbar-info-frame) | |
271 (raise-frame toolbar-info-frame))) | |
272 (when (frame-iconified-p toolbar-info-frame) | |
273 (deiconify-frame toolbar-info-frame))) | |
258 (info)) | 274 (info)) |
259 | 275 |
260 ;; | 276 ;; |
261 ;; toolbar debug variables and defuns | 277 ;; toolbar debug variables and defuns |
262 ;; | 278 ;; |
267 (call-interactively 'eos::start-debugger) | 283 (call-interactively 'eos::start-debugger) |
268 (require 'gdbsrc) | 284 (require 'gdbsrc) |
269 (call-interactively 'gdbsrc))) | 285 (call-interactively 'gdbsrc))) |
270 | 286 |
271 (defvar compile-command) | 287 (defvar compile-command) |
288 (defvar toolbar-compile-already-run nil) | |
272 | 289 |
273 (defun toolbar-compile () | 290 (defun toolbar-compile () |
274 "Run compile without having to touch the keyboard." | 291 "Run compile without having to touch the keyboard." |
275 (interactive) | 292 (interactive) |
276 (require 'compile) | 293 (require 'compile) |
277 (popup-dialog-box | 294 (if toolbar-compile-already-run |
278 `(,(concat "Compile:\n " compile-command) | 295 (compile compile-command) |
279 ["Compile" (compile compile-command) t] | 296 (setq toolbar-compile-already-run t) |
280 ["Edit command" compile t] | 297 (popup-dialog-box |
281 nil | 298 `(,(concat "Compile:\n " compile-command) |
282 ["Cancel" (message "Quit") t]))) | 299 ["Compile" (compile compile-command) t] |
300 ["Edit command" compile t] | |
301 nil | |
302 ["Cancel" (message "Quit") t])))) | |
283 | 303 |
284 ;; | 304 ;; |
285 ;; toolbar news variables and defuns | 305 ;; toolbar news variables and defuns |
286 ;; | 306 ;; |
287 | 307 |
329 :group 'toolbar) | 349 :group 'toolbar) |
330 | 350 |
331 (defvar toolbar-news-frame nil | 351 (defvar toolbar-news-frame nil |
332 "The frame in which news is displayed.") | 352 "The frame in which news is displayed.") |
333 | 353 |
334 (defcustom toolbar-news-frame-properties nil | 354 (defcustom toolbar-news-frame-plist nil |
335 "*The properties of the frame in which news is displayed." | 355 "*The properties of the frame in which news is displayed." |
336 :type '(repeat (group :inline t | 356 :type 'plist |
337 (symbol :tag "Property") | 357 :group 'toolbar) |
338 (sexp :tag "Value"))) | 358 |
339 :group 'toolbar) | 359 (define-obsolete-variable-alias 'toolbar-news-frame-properties |
360 'toolbar-news-frame-plist) | |
340 | 361 |
341 (defun toolbar-gnus () | 362 (defun toolbar-gnus () |
342 "Run Gnus in a separate frame." | 363 "Run Gnus in a separate frame." |
343 (interactive) | 364 (interactive) |
344 (if (not toolbar-news-use-separate-frame) | 365 (if (not toolbar-news-use-separate-frame) |
350 (when (frame-live-p toolbar-news-frame) | 371 (when (frame-live-p toolbar-news-frame) |
351 (if (cdr (frame-list)) | 372 (if (cdr (frame-list)) |
352 (delete-frame toolbar-news-frame)) | 373 (delete-frame toolbar-news-frame)) |
353 (setq toolbar-news-frame nil)))) | 374 (setq toolbar-news-frame nil)))) |
354 (select-frame toolbar-news-frame) | 375 (select-frame toolbar-news-frame) |
355 (raise-frame toolbar-news-frame) | |
356 (gnus)) | 376 (gnus)) |
357 (when (framep toolbar-news-frame) | 377 (when (framep toolbar-news-frame) |
358 (when (frame-iconified-p toolbar-news-frame) | 378 (when (frame-iconified-p toolbar-news-frame) |
359 (deiconify-frame toolbar-news-frame)) | 379 (deiconify-frame toolbar-news-frame)) |
360 (select-frame toolbar-news-frame) | 380 (select-frame toolbar-news-frame) |
361 (raise-frame toolbar-news-frame)))) | 381 (raise-frame toolbar-news-frame)))) |
362 | 382 |
363 (defun toolbar-news () | 383 (defun toolbar-news () |
364 "Run News (in a separate frame??)." | 384 "Run News." |
365 (interactive) | 385 (interactive) |
366 (let ((command (assq toolbar-news-reader toolbar-news-commands-alist))) | 386 (let ((command (assq toolbar-news-reader toolbar-news-commands-alist))) |
367 (if (not command) | 387 (or command |
368 (error "Unknown news reader %s" toolbar-news-reader)) | 388 (error "Uknown news reader %s" toolbar-news-reader)) |
369 (funcall (cdr command)))) | 389 (if (symbolp command) |
390 (call-interactively command) | |
391 (eval command)))) | |
370 | 392 |
371 (defvar toolbar-last-win-icon nil "A `last-win' icon set.") | 393 (defvar toolbar-last-win-icon nil "A `last-win' icon set.") |
372 (defvar toolbar-next-win-icon nil "A `next-win' icon set.") | 394 (defvar toolbar-next-win-icon nil "A `next-win' icon set.") |
373 (defvar toolbar-file-icon nil "A `file' icon set.") | 395 (defvar toolbar-file-icon nil "A `file' icon set.") |
374 (defvar toolbar-folder-icon nil "A `folder' icon set") | 396 (defvar toolbar-folder-icon nil "A `folder' icon set") |