Mercurial > emacs
comparison lisp/emulation/viper-init.el @ 92383:6eac1e449121
(viper-cond-compile-for-xemacs-or-emacs): Delete macro.
Expand all viper-cond-compile-for-xemacs-or-emacs calls to a featurep test.
Replace obselete frame-local variables with frame-parameters.
(viper-replace-overlay-cursor-color, viper-insert-state-cursor-color)
(viper-emacs-state-cursor-color, viper-vi-state-cursor-color): Only
call make-variable-frame-local on XEmacs.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 01 Mar 2008 20:23:18 +0000 |
parents | 107ccd98fa12 |
children | d7554c14325c |
comparison
equal
deleted
inserted
replaced
92382:df1420681df6 | 92383:6eac1e449121 |
---|---|
47 (interactive) | 47 (interactive) |
48 (message "Viper version is %s" viper-version)) | 48 (message "Viper version is %s" viper-version)) |
49 | 49 |
50 ;; Tell whether we are running as a window application or on a TTY | 50 ;; Tell whether we are running as a window application or on a TTY |
51 | 51 |
52 ;; This is used to avoid compilation warnings. When emacs/xemacs forms can | 52 (defsubst viper-device-type () |
53 ;; generate compile time warnings, we use this macro. | |
54 ;; In this case, the macro will expand into the form that is appropriate to the | |
55 ;; compiler at hand. | |
56 ;; Suggested by rms. | |
57 (defmacro viper-cond-compile-for-xemacs-or-emacs (xemacs-form emacs-form) | |
58 (if (featurep 'xemacs) | 53 (if (featurep 'xemacs) |
59 xemacs-form emacs-form)) | 54 (device-type (selected-device)) |
60 | 55 window-system)) |
61 | |
62 (defsubst viper-device-type () | |
63 (viper-cond-compile-for-xemacs-or-emacs | |
64 (device-type (selected-device)) | |
65 window-system | |
66 )) | |
67 | 56 |
68 (defun viper-color-display-p () | 57 (defun viper-color-display-p () |
69 (condition-case nil | 58 (condition-case nil |
70 (viper-cond-compile-for-xemacs-or-emacs | 59 (if (featurep 'xemacs) |
71 (eq (device-class (selected-device)) 'color) ; xemacs form | 60 (eq (device-class (selected-device)) 'color) |
72 (if (fboundp 'display-color-p) ; emacs form | 61 (display-color-p)) |
73 (display-color-p) | |
74 (x-display-color-p)) | |
75 ) | |
76 (error nil))) | 62 (error nil))) |
77 | 63 |
78 ;; in XEmacs: device-type is tty on tty and stream in batch. | 64 ;; in XEmacs: device-type is tty on tty and stream in batch. |
79 (defun viper-window-display-p () | 65 (defun viper-window-display-p () |
80 (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc))))) | 66 (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc))))) |
351 | 337 |
352 (defun viper-inactivate-input-method () | 338 (defun viper-inactivate-input-method () |
353 (cond ((and (featurep 'emacs) (fboundp 'inactivate-input-method)) | 339 (cond ((and (featurep 'emacs) (fboundp 'inactivate-input-method)) |
354 (inactivate-input-method)) | 340 (inactivate-input-method)) |
355 ((and (featurep 'xemacs) (boundp 'current-input-method)) | 341 ((and (featurep 'xemacs) (boundp 'current-input-method)) |
356 ;; XEmacs had broken quil-mode for some time, so we are working around | 342 ;; XEmacs had broken quail-mode for some time, so we are working around |
357 ;; it here | 343 ;; it here |
358 (setq quail-mode nil) | 344 (setq quail-mode nil) |
359 (if (featurep 'quail) | 345 (if (featurep 'quail) |
360 (quail-delete-overlays)) | 346 (quail-delete-overlays)) |
361 (setq describe-current-input-method-function nil) | 347 (setq describe-current-input-method-function nil) |
442 :group 'viper) | 428 :group 'viper) |
443 | 429 |
444 ;; internal var, used to remember the default cursor color of emacs frames | 430 ;; internal var, used to remember the default cursor color of emacs frames |
445 (defvar viper-vi-state-cursor-color nil) | 431 (defvar viper-vi-state-cursor-color nil) |
446 | 432 |
447 (if (fboundp 'make-variable-frame-local) | 433 ;; Frame-local variables are obsolete from Emacs 22.2 onwards, so we |
448 (dolist (v '(viper-replace-overlay-cursor-color | 434 ;; do it by hand with viper-frame-value (qv). |
449 viper-insert-state-cursor-color viper-emacs-state-cursor-color | 435 (when (and (featurep 'xemacs) |
450 viper-vi-state-cursor-color)) | 436 (fboundp 'make-variable-frame-local)) |
451 (make-variable-frame-local v))) | 437 (make-variable-frame-local 'viper-replace-overlay-cursor-color) |
438 (make-variable-frame-local 'viper-insert-state-cursor-color) | |
439 (make-variable-frame-local 'viper-emacs-state-cursor-color) | |
440 (make-variable-frame-local 'viper-vi-state-cursor-color)) | |
452 | 441 |
453 (viper-deflocalvar viper-replace-overlay nil "") | 442 (viper-deflocalvar viper-replace-overlay nil "") |
454 (put 'viper-replace-overlay 'permanent-local t) | 443 (put 'viper-replace-overlay 'permanent-local t) |
455 | 444 |
456 (defcustom viper-replace-region-end-delimiter "$" | 445 (defcustom viper-replace-region-end-delimiter "$" |
478 "Function to use for prompting the user for a buffer name." | 467 "Function to use for prompting the user for a buffer name." |
479 :type 'symbol | 468 :type 'symbol |
480 :group 'viper) | 469 :group 'viper) |
481 | 470 |
482 ;; XEmacs requires glyphs | 471 ;; XEmacs requires glyphs |
483 (viper-cond-compile-for-xemacs-or-emacs | 472 (when (featurep 'xemacs) |
484 (progn ; xemacs | 473 (or (glyphp viper-replace-region-end-delimiter) |
485 (or (glyphp viper-replace-region-end-delimiter) | 474 (setq viper-replace-region-end-delimiter |
486 (setq viper-replace-region-end-delimiter | 475 (make-glyph viper-replace-region-end-delimiter))) |
487 (make-glyph viper-replace-region-end-delimiter))) | 476 (or (glyphp viper-replace-region-start-delimiter) |
488 (or (glyphp viper-replace-region-start-delimiter) | 477 (setq viper-replace-region-start-delimiter |
489 (setq viper-replace-region-start-delimiter | 478 (make-glyph viper-replace-region-start-delimiter)))) |
490 (make-glyph viper-replace-region-start-delimiter))) | |
491 ) | |
492 nil ; emacs | |
493 ) | |
494 | |
495 | |
496 | 479 |
497 ;; These are local marker that must be initialized to nil and moved with | 480 ;; These are local marker that must be initialized to nil and moved with |
498 ;; `viper-move-marker-locally' | 481 ;; `viper-move-marker-locally' |
499 ;; | 482 ;; |
500 ;; Remember the last position inside the replace region. | 483 ;; Remember the last position inside the replace region. |