aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2009-02-23 01:37:34 +0000
committerKenichi Handa2009-02-23 01:37:34 +0000
commita485d4f774626b44efb1ccb8ec94d7f3f7415311 (patch)
tree259019d78c99fd1633073a7973441daf703967e7
parentb8f908b3a47e085fb28c4ace9e62b30a64bbbe73 (diff)
downloademacs-a485d4f774626b44efb1ccb8ec94d7f3f7415311.tar.gz
emacs-a485d4f774626b44efb1ccb8ec94d7f3f7415311.zip
(auto-composition-mode): Don't add a hook to
after-change-functions. Don't decompose the buffer. (auto-composition-after-change): Delete it. (toggle-auto-composition): Make it an alias of auto-composition-mode. (auto-compose-region): Delete it.
-rw-r--r--lisp/composite.el98
1 files changed, 2 insertions, 96 deletions
diff --git a/lisp/composite.el b/lisp/composite.el
index 667f158a346..7c04bcff088 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -748,57 +748,9 @@ Auto Composition mode in all buffers (this is the default)."
748 (if noninteractive 748 (if noninteractive
749 (setq auto-composition-mode nil)) 749 (setq auto-composition-mode nil))
750 (cond (auto-composition-mode 750 (cond (auto-composition-mode
751 (add-hook 'after-change-functions 'auto-composition-after-change nil t)
752 (setq auto-composition-function 'auto-compose-chars)) 751 (setq auto-composition-function 'auto-compose-chars))
753 (t 752 (t
754 (remove-hook 'after-change-functions 'auto-composition-after-change t) 753 (setq auto-composition-function nil))))
755 (setq auto-composition-function nil)))
756 (save-buffer-state nil
757 (save-restriction
758 (widen)
759 (remove-text-properties (point-min) (point-max) '(auto-composed nil))
760 (decompose-region (point-min) (point-max)))))
761
762(defun auto-composition-after-change (start end old-len)
763 (save-buffer-state nil
764 (if (< start (point-min))
765 (setq start (point-min)))
766 (if (> end (point-max))
767 (setq end (point-max)))
768 (when (and auto-composition-mode (not memory-full))
769 (let (func1 func2)
770 (when (and (> start (point-min))
771 (setq func2 (aref composition-function-table
772 (char-after (1- start))))
773 (or (= start (point-max))
774 (not (setq func1 (aref composition-function-table
775 (char-after start))))
776 (eq func1 func2)))
777 (setq start (1- start)
778 func1 func2)
779 (while (eq func1 func2)
780 (if (> start (point-min))
781 (setq start (1- start)
782 func2 (aref composition-function-table
783 (char-after start)))
784 (setq func2 nil))))
785 (when (and (< end (point-max))
786 (setq func2 (aref composition-function-table
787 (char-after end)))
788 (or (= end (point-min))
789 (not (setq func1 (aref composition-function-table
790 (char-after (1- end)))))
791 (eq func1 func2)))
792 (setq end (1+ end)
793 func1 func2)
794 (while (eq func1 func2)
795 (if (< end (point-max))
796 (setq func2 (aref composition-function-table
797 (char-after end))
798 end (1+ end))
799 (setq func2 nil))))
800 (if (< start end)
801 (remove-text-properties start end '(auto-composed nil)))))))
802 754
803(defun turn-on-auto-composition-if-enabled () 755(defun turn-on-auto-composition-if-enabled ()
804 (if enable-multibyte-characters 756 (if enable-multibyte-characters
@@ -813,53 +765,7 @@ Auto Composition mode in all buffers (this is the default)."
813 :group 'auto-composition 765 :group 'auto-composition
814 :version "23.1") 766 :version "23.1")
815 767
816(defun toggle-auto-composition (&optional arg) 768(defalias 'toggle-auto-composition 'auto-composition-mode)
817 "Change whether automatic character composition is enabled in this buffer.
818With arg, enable it if and only if arg is positive."
819 (interactive "P")
820 (let ((enable (if (null arg) (not auto-composition-function)
821 (> (prefix-numeric-value arg) 0))))
822 (if enable
823 (kill-local-variable 'auto-composition-function)
824 (make-local-variable 'auto-composition-function)
825 (setq auto-composition-function nil)
826 (save-buffer-state nil
827 (save-restriction
828 (widen)
829 (decompose-region (point-min) (point-max)))))
830
831 (save-buffer-state nil
832 (save-restriction
833 (widen)
834 (remove-text-properties (point-min) (point-max)
835 '(auto-composed nil))))))
836
837(defun auto-compose-region (from to)
838 "Force automatic character composition on the region FROM and TO."
839 (save-excursion
840 (if (get-text-property from 'auto-composed)
841 (setq from (next-single-property-change from 'auto-composed nil to)))
842 (goto-char from)
843 (let ((modified-p (buffer-modified-p))
844 (inhibit-read-only '(composition auto-composed))
845 (stop (next-single-property-change (point) 'auto-composed nil to)))
846 (while (< (point) to)
847 (if (= (point) stop)
848 (progn
849 (goto-char (next-single-property-change (point)
850 'auto-composed nil to))
851 (setq stop (next-single-property-change (point)
852 'auto-composed nil to)))
853 (let ((func (aref composition-function-table (following-char)))
854 (font-obj (and (display-multi-font-p)
855 (font-at (point) (selected-window))))
856 (pos (point)))
857 (if (and (functionp func) font-obj)
858 (goto-char (funcall func (point) to font-obj nil)))
859 (if (<= (point) pos)
860 (forward-char 1)))))
861 (put-text-property from to 'auto-composed t)
862 (set-buffer-modified-p modified-p))))
863 769
864 770
865;; The following codes are only for backward compatibility with Emacs 771;; The following codes are only for backward compatibility with Emacs