comparison lisp/composite.el @ 89497:76c9d23be7a1

Doc fixes. (auto-compose-chars): Use functionp, not fboundp.
author Dave Love <fx@gnu.org>
date Thu, 11 Sep 2003 09:24:56 +0000
parents 2f877ed80fa6
children c75e3c6b608a
comparison
equal deleted inserted replaced
89496:efdf5369988e 89497:76c9d23be7a1
38 ;; For backward compatibility... 38 ;; For backward compatibility...
39 (ml . 3) (mc . 10) (mr . 5) 39 (ml . 3) (mc . 10) (mr . 5)
40 (mid-left . 3) (mid-center . 10) (mid-right . 5)) 40 (mid-left . 3) (mid-center . 10) (mid-right . 5))
41 "Alist of symbols vs integer codes of glyph reference points. 41 "Alist of symbols vs integer codes of glyph reference points.
42 A glyph reference point symbol is to be used to specify a composition 42 A glyph reference point symbol is to be used to specify a composition
43 rule in COMPONENTS argument to such functions as `compose-region' and 43 rule in COMPONENTS argument to such functions as `compose-region'.
44 `make-composition'.
45 44
46 Meanings of glyph reference point codes are as follows: 45 Meanings of glyph reference point codes are as follows:
47 46
48 0----1----2 <---- ascent 0:tl or top-left 47 0----1----2 <---- ascent 0:tl or top-left
49 | | 1:tc or top-center 48 | | 1:tc or top-center
162 When called from a program, expects these four arguments. 161 When called from a program, expects these four arguments.
163 162
164 First two arguments START and END are positions (integers or markers) 163 First two arguments START and END are positions (integers or markers)
165 specifying the region. 164 specifying the region.
166 165
167 Optional 3rd argument COMPONENTS, if non-nil, is a character or a 166 Optional 3rd argument COMPONENTS, if non-nil, is a character, a string
168 sequence (vector, list, or string) of integers. In this case, 167 Optional 3rd argument COMPONENTS, if non-nil, is a character, a string
169 characters are composed not relatively but according to COMPONENTS. 168 or a vector or list of integers and rules.
170 169
171 If it is a character, it is an alternate character to display instead 170 If it is a character, it is an alternate character to display instead
172 of the text in the region. 171 of the text in the region.
173 172
174 If it is a string, the elements are alternate characters. 173 If it is a string, the elements are alternate characters.
313 CHARS (integer) -- if CHARS characters were composed. 312 CHARS (integer) -- if CHARS characters were composed.
314 313
315 Optional 2nd arg LIMIT, if non-nil, limits the matching of text. 314 Optional 2nd arg LIMIT, if non-nil, limits the matching of text.
316 315
317 Optional 3rd arg OBJECT, if non-nil, is a string that contains the 316 Optional 3rd arg OBJECT, if non-nil, is a string that contains the
318 text to compose. In that case, POS and LIMIT index to the string. 317 text to compose. In that case, POS and LIMIT index into the string.
319 318
320 This function is the default value of `compose-chars-after-function'." 319 This function is the default value of `compose-chars-after-function'."
321 (let ((tail (aref composition-function-table (char-after pos))) 320 (let ((tail (aref composition-function-table (char-after pos)))
322 pattern func result) 321 pattern func result)
323 (when tail 322 (when tail
371 370
372 If STRING is nil, POS is a position in the current buffer, and the 371 If STRING is nil, POS is a position in the current buffer, and the
373 function has to compose a character at POS with surrounding characters 372 function has to compose a character at POS with surrounding characters
374 in the current buffer. 373 in the current buffer.
375 374
376 Otherwise, STRING is a string, and POS is an index to the string. In 375 Otherwise, STRING is a string, and POS is an index into the string. In
377 this case, the function has to compose a character at POS with 376 this case, the function has to compose a character at POS with
378 surrounding characters in the string. 377 surrounding characters in the string.
379 378
380 See also the command `toggle-auto-composition'.") 379 See also the command `toggle-auto-composition'.")
381 380
382 ;; Copied from font-lock.el. 381 ;; Copied from font-lock.el.
383 (eval-when-compile 382 (eval-when-compile
384 ;;
385 ;; We don't do this at the top-level as we only use non-autoloaded macros.
386 (require 'cl)
387 ;;
388 ;; Borrowed from lazy-lock.el. 383 ;; Borrowed from lazy-lock.el.
389 ;; We use this to preserve or protect things when modifying text properties. 384 ;; We use this to preserve or protect things when modifying text properties.
390 (defmacro save-buffer-state (varlist &rest body) 385 (defmacro save-buffer-state (varlist &rest body)
391 "Bind variables according to VARLIST and eval BODY restoring buffer state." 386 "Bind variables according to VARLIST and eval BODY restoring buffer state."
392 `(let* ,(append varlist 387 `(let* ,(append varlist
396 deactivate-mark buffer-file-name buffer-file-truename)) 391 deactivate-mark buffer-file-name buffer-file-truename))
397 ,@body 392 ,@body
398 (unless modified 393 (unless modified
399 (restore-buffer-modified-p nil)))) 394 (restore-buffer-modified-p nil))))
400 (put 'save-buffer-state 'lisp-indent-function 1) 395 (put 'save-buffer-state 'lisp-indent-function 1)
401 ;; Fixme: This makes bootstrapping fails by this error. 396 ;; Fixme: This makes bootstrapping fail with this error.
402 ;; Symbol's function definition is void: eval-defun 397 ;; Symbol's function definition is void: eval-defun
403 ;;(def-edebug-spec save-buffer-state let) 398 ;;(def-edebug-spec save-buffer-state let)
404 ) 399 )
405 400
406 (defvar auto-composition-chunk-size 500 401 (defvar auto-composition-chunk-size 500
407 "*Automatic composition chunks of this many characters, or smaller.") 402 "*Automatic composition uses chunks of this many characters, or smaller.")
408 403
409 (defun auto-compose-chars (pos string) 404 (defun auto-compose-chars (pos string)
410 "Compose characters after the buffer position POS. 405 "Compose characters after the buffer position POS.
411 If STRING is non-nil, it is a string, and POS is an index to the string. 406 If STRING is non-nil, it is a string, and POS is an index into the string.
412 In that case, compose characters in the string. 407 In that case, compose characters in the string.
413 408
414 This function is the default value of `auto-composition-function' (which see)." 409 This function is the default value of `auto-composition-function' (which see)."
415 (save-buffer-state nil 410 (save-buffer-state nil
416 (save-excursion 411 (save-excursion
428 (setq ch (if string (aref string pos) 423 (setq ch (if string (aref string pos)
429 (char-after pos))) 424 (char-after pos)))
430 (or (< pos limit) 425 (or (< pos limit)
431 (/= ch ?\n))) 426 (/= ch ?\n)))
432 (setq func (aref composition-function-table ch)) 427 (setq func (aref composition-function-table ch))
433 (if (fboundp func) 428 (if (functionp func)
434 (setq newpos (funcall func pos string) 429 (setq newpos (funcall func pos string)
435 pos (if (and (integerp newpos) (> newpos pos)) 430 pos (if (and (integerp newpos) (> newpos pos))
436 newpos 431 newpos
437 (1+ pos))) 432 (1+ pos)))
438 (setq pos (1+ pos)))) 433 (setq pos (1+ pos))))