;;; 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
(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.
(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)
(lglyph-set-from-to glyph i i)
(setq i (1+ i))))
(if (= (lglyph-width glyph) 0)
- (progn
+ (if (eq (get-char-code-property (lglyph-char glyph)
+ 'general-category)
+ 'Cf)
+ (progn
+ ;; Compose by replacing with a space.
+ (lglyph-set-char glyph 32)
+ (lglyph-set-width glyph 1)
+ (setq i (1+ i)))
;; Compose by prepending a space.
(setq gstring (lgstring-insert-glyph gstring i
(lglyph-copy glyph))
in the region FROM (inclusive) and TO (exclusive).
If the character are composed on a graphic display, FONT-OBJECT
-is a font to use.
-
-Otherwise, FONT-OBJECT is nil, and the fucntion
+is a font to use. Otherwise, FONT-OBJECT is nil, and the function
`compose-gstring-for-terminal' is used instead of FUNC.
If STRING is non-nil, it is a string, and FROM and TO are indices
(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
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