]> code.delx.au - gnu-emacs/blobdiff - lisp/composite.el
Fix bug #5992.
[gnu-emacs] / lisp / composite.el
index ce34336cedec59143bf0cd0c24762a0b8d6054bb..6a12b42e41148ffc18993bfca4273b67df040d31 100644 (file)
@@ -1,7 +1,7 @@
 ;;; composite.el --- support character composition
 
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009
+;;   2008, 2009, 2010
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
 
@@ -185,8 +185,17 @@ RULE is a cons of global and new reference point symbols
 (defun compose-region (start end &optional components modification-func)
   "Compose characters in the current region.
 
-Characters are composed relatively, i.e. composed by overstricking or
-stacking depending on ascent, descent and other properties.
+Characters are composed relatively, i.e. composed by overstriking
+or stacking depending on ascent, descent and other metrics of
+glyphs.
+
+For instance, if the region has three characters \"XYZ\", X is
+regarded as BASE glyph, and Y is displayed:
+  (1) above BASE if Y's descent value is not positive
+  (2) below BASE if Y's ascent value is not positive
+  (3) on BASE (i.e. at the BASE position) otherwise
+and Z is displayed with the same rule while regarding the whole
+XY glyphs as BASE.
 
 When called from a program, expects these four arguments.
 
@@ -646,7 +655,7 @@ All non-spacing characters has this function in
              (setq i (1+ i))))
          gstring))))))
 
-(let ((elt '(["\\c.\\c^+" 1 compose-gstring-for-graphic]
+(let ((elt `([,(purecopy "\\c.\\c^+") 1 compose-gstring-for-graphic]
             [nil 0 compose-gstring-for-graphic])))
   (map-char-table
    #'(lambda (key val)
@@ -735,10 +744,14 @@ This function is the default value of `auto-composition-function' (which see)."
          (setq func 'compose-gstring-for-terminal))
       (funcall func gstring))))
 
+(make-variable-buffer-local 'auto-composition-mode)
+(put 'auto-composition-mode 'permanent-local t)
+
 (make-variable-buffer-local 'auto-composition-function)
+(setq-default auto-composition-function 'auto-compose-chars)
 
 ;;;###autoload
-(define-minor-mode auto-composition-mode
+(defun auto-composition-mode (&optional arg)
   "Toggle Auto Composition mode.
 With ARG, turn Auto Composition mode off if and only if ARG is a non-positive
 number; if ARG is nil, toggle Auto Composition mode; anything else turns Auto
@@ -749,27 +762,23 @@ by functions registered in `composition-function-table' (which see).
 
 You can use `global-auto-composition-mode' to turn on
 Auto Composition mode in all buffers (this is the default)."
-  nil nil nil
-  (if noninteractive
-      (setq auto-composition-mode nil))
-  (cond (auto-composition-mode
-        (setq auto-composition-function 'auto-compose-chars))
-       (t
-        (setq auto-composition-function nil))))
-
-(defun turn-on-auto-composition-if-enabled ()
-  (if enable-multibyte-characters
-      (auto-composition-mode 1)))
+  (interactive "P")
+  (setq auto-composition-mode
+       (if arg
+           (or (not (integerp arg)) (> arg 0))
+         (not auto-composition-mode))))
 
 ;;;###autoload
-(define-global-minor-mode global-auto-composition-mode
-  auto-composition-mode turn-on-auto-composition-if-enabled
-  :extra-args (dummy)
-  :initialize 'custom-initialize-safe-default
-  :init-value (not noninteractive)
-  :group 'auto-composition
-  :version "23.1")
-
+(defun global-auto-composition-mode (&optional arg)
+  "Toggle Auto-Composition mode in every possible buffer.
+With prefix arg, turn Global-Auto-Composition mode on if and only if arg
+is positive.
+See `auto-composition-mode' for more information on Auto-Composition mode."
+  (interactive "P")
+  (setq-default auto-composition-mode
+               (if arg
+                   (or (not (integerp arg)) (> arg 0))
+                 (not (default-value 'auto-composition-mode)))))
 (defalias 'toggle-auto-composition 'auto-composition-mode)
 
 \f