Mercurial > hg > xemacs-beta
comparison lisp/egg/egg.el @ 114:8619ce7e4c50 r20-1b9
Import from CVS: tag r20-1b9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:21:54 +0200 |
parents | fe104dbd9147 |
children | 1370575f1259 |
comparison
equal
deleted
inserted
replaced
113:2ec2fe4a4c89 | 114:8619ce7e4c50 |
---|---|
394 | 394 |
395 (provide 'egg) | 395 (provide 'egg) |
396 | 396 |
397 ;; XEmacs addition: (and remove disable-undo variable) | 397 ;; XEmacs addition: (and remove disable-undo variable) |
398 ;; For Emacs V18/Nemacs compatibility | 398 ;; For Emacs V18/Nemacs compatibility |
399 (and (not (fboundp 'buffer-disable-undo)) | 399 ;(and (not (fboundp 'buffer-disable-undo)) |
400 (fboundp 'buffer-flush-undo) | 400 ; (fboundp 'buffer-flush-undo) |
401 (defalias 'buffer-disable-undo 'buffer-flush-undo)) | 401 ; (defalias 'buffer-disable-undo 'buffer-flush-undo)) |
402 | 402 |
403 ;; 97.2.4 Created by J.Hein to simulate Mule-2.3 | 403 ;; 97.2.4 Created by J.Hein to simulate Mule-2.3 |
404 (defun read-event () | 404 (defun egg-read-event () |
405 "Cheap 'n cheesy event filter to facilitate translation from Mule-2.3" | 405 "FSFmacs event emulator that shoves non key events into |
406 (let ((event (make-event))) | 406 unread-command-events to facilitate translation from Mule-2.3" |
407 (while (progn | 407 (let ((event (make-event)) |
408 (next-event event) | 408 (ch nil)) |
409 (not (key-press-event-p event))) | 409 (next-command-event event) |
410 (dispatch-event event)) | 410 (if (key-press-event-p event) |
411 (event-key event))) | 411 (setq ch (event-key event)) |
412 (setq unread-command-events (list event))) | |
413 (deallocate-event event) | |
414 ch)) | |
412 | 415 |
413 (eval-when-compile (require 'egg-jsymbol)) | 416 (eval-when-compile (require 'egg-jsymbol)) |
414 | 417 |
415 ;;;---------------------------------------------------------------------- | 418 ;;;---------------------------------------------------------------------- |
416 ;;; | 419 ;;; |
681 (setq menu:*select-item-no* 0) | 684 (setq menu:*select-item-no* 0) |
682 (menu:select-goto-menu 0)) | 685 (menu:select-goto-menu 0)) |
683 ) | 686 ) |
684 ;; end of patch | 687 ;; end of patch |
685 (while (not finished) | 688 (while (not finished) |
686 (let ((ch (read-event))) | 689 (let ((ch (egg-read-event))) |
687 (setq quit-flag nil) | 690 (setq quit-flag nil) |
688 (cond | 691 (cond |
689 ((eq ch ?\C-a) | 692 ((eq ch ?\C-a) |
690 (menu:select-goto-item 0)) | 693 (menu:select-goto-item 0)) |
691 ((eq ch ?\C-e) | 694 ((eq ch ?\C-e) |
1613 (setq from (1+ from))))) | 1616 (setq from (1+ from))))) |
1614 | 1617 |
1615 (defun its:peek-char () | 1618 (defun its:peek-char () |
1616 (if (= (point) its:*buff-e*) | 1619 (if (= (point) its:*buff-e*) |
1617 (if its:*interactive* | 1620 (if its:*interactive* |
1618 (setq unread-command-events (list (character-to-event(read-event)))) | 1621 (let ((ch (egg-read-event))) |
1622 (if ch | |
1623 (progn | |
1624 (setq unread-command-events (list (character-to-event ch))) | |
1625 ch) | |
1626 nil)) | |
1619 nil) | 1627 nil) |
1620 (following-char))) | 1628 (following-char))) |
1621 | 1629 |
1622 (defun its:read-char () | 1630 (defun its:read-char () |
1623 (if (= (point) its:*buff-e*) | 1631 (if (= (point) its:*buff-e*) |
1624 (progn | 1632 (progn |
1625 (setq its:*char-from-buff* nil) | 1633 (setq its:*char-from-buff* nil) |
1626 (if its:*interactive* | 1634 (if its:*interactive* |
1627 (read-event) | 1635 (egg-read-event) |
1628 nil)) | 1636 nil)) |
1629 (let ((ch (following-char))) | 1637 (let ((ch (following-char))) |
1630 (setq its:*char-from-buff* t) | 1638 (setq its:*char-from-buff* t) |
1631 (delete-char 1) | 1639 (delete-char 1) |
1632 ch))) | 1640 ch))) |
1814 (let ((point (point)) | 1822 (let ((point (point)) |
1815 (output (cdr action-output)) | 1823 (output (cdr action-output)) |
1816 (ch 0)) | 1824 (ch 0)) |
1817 (while (not (eq ch ?\^L)) | 1825 (while (not (eq ch ?\^L)) |
1818 (insert "<" (nth (car action-output)output) ">") | 1826 (insert "<" (nth (car action-output)output) ">") |
1819 (setq ch (read-event)) | 1827 (setq ch (egg-read-event)) |
1820 (cond ((eq ch ?\^N) | 1828 (cond ((eq ch ?\^N) |
1821 (setcar action-output | 1829 (setcar action-output |
1822 (mod (1+ (car action-output)) (length output)))) | 1830 (mod (1+ (car action-output)) (length output)))) |
1823 ((eq ch ?\^P) | 1831 ((eq ch ?\^P) |
1824 (setcar action-output | 1832 (setcar action-output |
2113 ;; (load "its-hira") | 2121 ;; (load "its-hira") |
2114 ;; (load-library "its-kata") | 2122 ;; (load-library "its-kata") |
2115 ;; (load-library "its-hankaku") | 2123 ;; (load-library "its-hankaku") |
2116 ;; (load-library "its-zenkaku") | 2124 ;; (load-library "its-zenkaku") |
2117 | 2125 |
2118 | |
2119 (defvar its:*current-map* nil) | 2126 (defvar its:*current-map* nil) |
2120 (make-variable-buffer-local 'its:*current-map*) | 2127 (make-variable-buffer-local 'its:*current-map*) |
2121 ;; 92.3.13 by K.Handa | 2128 ;; 92.3.13 by K.Handa |
2122 ;; moved to each language specific setup files (japanese.el, ...) | 2129 ;; moved to each language specific setup files (japanese.el, ...) |
2123 ;; (setq-default its:*current-map* (its:get-mode-map "roma-kana")) | 2130 ;; (setq-default its:*current-map* (its:get-mode-map "roma-kana")) |
2376 | 2383 |
2377 (substitute-key-definition 'self-insert-command | 2384 (substitute-key-definition 'self-insert-command |
2378 'egg-self-insert-command | 2385 'egg-self-insert-command |
2379 global-map) | 2386 global-map) |
2380 | 2387 |
2388 ;; wire us into pending-delete | |
2389 (put 'egg-self-insert-command 'pending-delete t) | |
2390 | |
2381 ;;; | 2391 ;;; |
2382 ;;; Currently entries C-\ and C-^ at global-map are undefined. | 2392 ;;; Currently entries C-\ and C-^ at global-map are undefined. |
2383 ;;; | 2393 ;;; |
2384 | 2394 |
2385 (define-key global-map "\C-\\" 'toggle-egg-mode) | 2395 (define-key global-map "\C-\\" 'toggle-egg-mode) |
2396 (define-key mule-keymap "Q" 'its:select-upcase) | 2406 (define-key mule-keymap "Q" 'its:select-upcase) |
2397 (define-key mule-keymap "z" 'its:select-zenkaku-downcase) | 2407 (define-key mule-keymap "z" 'its:select-zenkaku-downcase) |
2398 (define-key mule-keymap "Z" 'its:select-zenkaku-upcase) | 2408 (define-key mule-keymap "Z" 'its:select-zenkaku-upcase) |
2399 | 2409 |
2400 ;;; | 2410 ;;; |
2401 ;;; auto fill controll | 2411 ;;; auto fill control |
2402 ;;; | 2412 ;;; |
2403 | 2413 |
2404 (defun egg:do-auto-fill () | 2414 (defun egg:do-auto-fill () |
2405 (if (and auto-fill-function (not buffer-read-only) | 2415 (if (and auto-fill-function (not buffer-read-only) |
2406 (> (current-column) fill-column)) | 2416 (> (current-column) fill-column)) |
2579 (extentp egg:*fence-extent*) | 2589 (extentp egg:*fence-extent*) |
2580 (detach-extent egg:*fence-extent*) )) | 2590 (detach-extent egg:*fence-extent*) )) |
2581 | 2591 |
2582 (defun enter-fence-mode () | 2592 (defun enter-fence-mode () |
2583 ;; XEmacs change: | 2593 ;; XEmacs change: |
2584 (buffer-disable-undo (current-buffer)) | 2594 ; (buffer-disable-undo (current-buffer)) |
2595 (undo-boundary) | |
2585 (setq egg:*in-fence-mode* t) | 2596 (setq egg:*in-fence-mode* t) |
2586 (egg:mode-line-display) | 2597 (egg:mode-line-display) |
2587 ;;;(setq egg:*global-map-backup* (current-global-map)) | 2598 ;;;(setq egg:*global-map-backup* (current-global-map)) |
2588 (setq egg:*local-map-backup* (current-local-map)) | 2599 (setq egg:*local-map-backup* (current-local-map)) |
2589 ;;;(use-global-map fence-mode-map) | 2600 ;;;(use-global-map fence-mode-map) |
2690 (if its:*previous-map* | 2701 (if its:*previous-map* |
2691 (setq its:*current-map* its:*previous-map* | 2702 (setq its:*current-map* its:*previous-map* |
2692 its:*previous-map* nil)) | 2703 its:*previous-map* nil)) |
2693 (egg:quit-egg-mode)) | 2704 (egg:quit-egg-mode)) |
2694 | 2705 |
2695 (defvar egg-insert-after-hook nil) | 2706 ;; jhod: This seems bogus to me, as it should be called either after each |
2707 ;; egg-self-insert, or after accepting input, but not both. Otherwise, I can't | |
2708 ;; really think of a use for it. | |
2709 (defvar egg-insert-after-hook nil "Hook to run when egg inserts a character | |
2710 in the buffer") | |
2696 (make-variable-buffer-local 'egg-insert-after-hook) | 2711 (make-variable-buffer-local 'egg-insert-after-hook) |
2697 | 2712 |
2698 (defvar egg-exit-hook nil | 2713 (defvar egg-exit-hook nil |
2699 "Hook to run when egg exits. Should take two arguments START and END | 2714 "Hook to run when egg exits. Should take two arguments START and END |
2700 correspoding to character position.") | 2715 correspoding to character position.") |
2716 (if (not (= egg:*region-start* egg:*region-end*)) | 2731 (if (not (= egg:*region-start* egg:*region-end*)) |
2717 (egg:do-auto-fill)))) | 2732 (egg:do-auto-fill)))) |
2718 (set-marker egg:*region-start* nil) | 2733 (set-marker egg:*region-start* nil) |
2719 (set-marker egg:*region-end* nil) | 2734 (set-marker egg:*region-end* nil) |
2720 ;; XEmacs change: | 2735 ;; XEmacs change: |
2721 (buffer-enable-undo (current-buffer)) | 2736 ; (buffer-enable-undo (current-buffer)) |
2722 (if egg-insert-after-hook | 2737 (if egg-insert-after-hook |
2723 (run-hooks 'egg-insert-after-hook)) | 2738 (run-hooks 'egg-insert-after-hook)) |
2724 ) | 2739 ) |
2725 | 2740 |
2726 (defun fence-cancel-input () | 2741 (defun fence-cancel-input () |
2727 (interactive) | 2742 (interactive) |
2728 (delete-region egg:*region-start* egg:*region-end*) | 2743 (delete-region egg:*region-start* egg:*region-end*) |
2729 (fence-exit-mode)) | 2744 (fence-exit-mode)) |
2745 | |
2746 (defun fence-mouse-protect () | |
2747 "Cancel entry in progress if mouse events occur." | |
2748 (if egg:*in-fence-mode* | |
2749 (save-excursion | |
2750 (its:reset-input) | |
2751 (fence-cancel-input)))) | |
2752 | |
2753 (if (boundp 'mouse-track-cleanup-hook) | |
2754 (add-hook 'mouse-track-cleanup-hook 'fence-mouse-protect)) | |
2730 | 2755 |
2731 (defun fence-mode-help-command () | 2756 (defun fence-mode-help-command () |
2732 "Display documentation for fence-mode." | 2757 "Display documentation for fence-mode." |
2733 (interactive) | 2758 (interactive) |
2734 (let ((buf "*Help*")) | 2759 (let ((buf "*Help*")) |