aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2002-11-07 06:27:27 +0000
committerKenichi Handa2002-11-07 06:27:27 +0000
commit68fbe6508f306a5aec2f4fb1a36136cba700e3fb (patch)
tree993238711b83c0fb46725097ed7741a4ee4f35f7
parent6d710052313a8ac100081f887cb75cf6d4940dbb (diff)
downloademacs-68fbe6508f306a5aec2f4fb1a36136cba700e3fb.tar.gz
emacs-68fbe6508f306a5aec2f4fb1a36136cba700e3fb.zip
Remove all autoload cookies.
(composition-function-table): Variable declaration moved from composite.c. Format changed. (save-buffer-state): Copied from font-lock.el. (auto-composition-chunk-size): New variable. (auto-compose-chars): New function. Set auto-composition-function to it. (toggle-auto-composition): New function.
-rw-r--r--lisp/composite.el121
1 files changed, 110 insertions, 11 deletions
diff --git a/lisp/composite.el b/lisp/composite.el
index 500ac84cdd5..cbaeb182d58 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -26,7 +26,6 @@
26 26
27;;; Code: 27;;; Code:
28 28
29;;;###autoload
30(defconst reference-point-alist 29(defconst reference-point-alist
31 '((tl . 0) (tc . 1) (tr . 2) 30 '((tl . 0) (tc . 1) (tr . 2)
32 (Bl . 3) (Bc . 4) (Br . 5) 31 (Bl . 3) (Bc . 4) (Br . 5)
@@ -154,7 +153,6 @@ follows (the point `*' corresponds to both reference points):
154 (setq i (+ i 2)))) 153 (setq i (+ i 2))))
155 components) 154 components)
156 155
157;;;###autoload
158(defun compose-region (start end &optional components modification-func) 156(defun compose-region (start end &optional components modification-func)
159 "Compose characters in the current region. 157 "Compose characters in the current region.
160 158
@@ -191,7 +189,6 @@ text in the composition."
191 (compose-region-internal start end components modification-func) 189 (compose-region-internal start end components modification-func)
192 (set-buffer-modified-p modified-p))) 190 (set-buffer-modified-p modified-p)))
193 191
194;;;###autoload
195(defun decompose-region (start end) 192(defun decompose-region (start end)
196 "Decompose text in the current region. 193 "Decompose text in the current region.
197 194
@@ -203,7 +200,6 @@ positions (integers or markers) specifying the region."
203 (remove-text-properties start end '(composition nil)) 200 (remove-text-properties start end '(composition nil))
204 (set-buffer-modified-p modified-p))) 201 (set-buffer-modified-p modified-p)))
205 202
206;;;###autoload
207(defun compose-string (string &optional start end components modification-func) 203(defun compose-string (string &optional start end components modification-func)
208 "Compose characters in string STRING. 204 "Compose characters in string STRING.
209 205
@@ -228,13 +224,11 @@ text in the composition."
228 (compose-string-internal string start end components modification-func) 224 (compose-string-internal string start end components modification-func)
229 string) 225 string)
230 226
231;;;###autoload
232(defun decompose-string (string) 227(defun decompose-string (string)
233 "Return STRING where `composition' property is removed." 228 "Return STRING where `composition' property is removed."
234 (remove-text-properties 0 (length string) '(composition nil) string) 229 (remove-text-properties 0 (length string) '(composition nil) string)
235 string) 230 string)
236 231
237;;;###autoload
238(defun compose-chars (&rest args) 232(defun compose-chars (&rest args)
239 "Return a string from arguments in which all characters are composed. 233 "Return a string from arguments in which all characters are composed.
240For relative composition, arguments are characters. 234For relative composition, arguments are characters.
@@ -258,7 +252,6 @@ A composition rule is a cons of glyph reference points of the form
258 (setq str (concat args))) 252 (setq str (concat args)))
259 (compose-string-internal str 0 (length str) components))) 253 (compose-string-internal str 0 (length str) components)))
260 254
261;;;###autoload
262(defun find-composition (pos &optional limit string detail-p) 255(defun find-composition (pos &optional limit string detail-p)
263 "Return information about a composition at or nearest to buffer position POS. 256 "Return information about a composition at or nearest to buffer position POS.
264 257
@@ -298,7 +291,6 @@ WIDTH is a number of columns the composition occupies on the screen."
298 result)) 291 result))
299 292
300 293
301;;;###autoload
302(defun compose-chars-after (pos &optional limit object) 294(defun compose-chars-after (pos &optional limit object)
303 "Compose characters in current buffer after position POS. 295 "Compose characters in current buffer after position POS.
304 296
@@ -339,7 +331,6 @@ This function is the default value of `compose-chars-after-function'."
339 (setq func nil tail (cdr tail))))))) 331 (setq func nil tail (cdr tail)))))))
340 result)) 332 result))
341 333
342;;;###autoload
343(defun compose-last-chars (args) 334(defun compose-last-chars (args)
344 "Compose last characters. 335 "Compose last characters.
345The argument is a parameterized event of the form 336The argument is a parameterized event of the form
@@ -360,13 +351,121 @@ after a sequence character events."
360 (compose-region (- (point) chars) (point) (nth 2 args)) 351 (compose-region (- (point) chars) (point) (nth 2 args))
361 (compose-chars-after (- (point) chars) (point)))))) 352 (compose-chars-after (- (point) chars) (point))))))
362 353
363;;;###autoload(global-set-key [compose-last-chars] 'compose-last-chars) 354(global-set-key [compose-last-chars] 'compose-last-chars)
355
356
357;;; Automatic character composition.
358
359(defvar composition-function-table
360 (make-char-table nil)
361 "Char table of functions for automatic character composition.
362For each character that has to be composed automatically with
363preceding and/or following characters, this char table contains
364a function to call to compose that character.
365
366Each function is called with two arguments, POS and STRING.
367
368If STRING is nil, POS is a position in the current buffer, and the
369function has to compose a character at POS with surrounding characters
370in the current buffer.
371
372Otherwise, STRING is a string, and POS is an index to the string. In
373this case, the function has to compose a character at POS with
374surrounding characters in the string.
375
376See also the command `toggle-auto-composition'.")
377
378;; Copied from font-lock.el.
379(eval-when-compile
380 ;;
381 ;; We don't do this at the top-level as we only use non-autoloaded macros.
382 (require 'cl)
383 ;;
384 ;; Borrowed from lazy-lock.el.
385 ;; We use this to preserve or protect things when modifying text properties.
386 (defmacro save-buffer-state (varlist &rest body)
387 "Bind variables according to VARLIST and eval BODY restoring buffer state."
388 (let ((modified (make-symbol "modified")))
389 `(let* ,(append varlist
390 `((,modified (buffer-modified-p))
391 (buffer-undo-list t)
392 (inhibit-read-only t)
393 (inhibit-point-motion-hooks t)
394 (inhibit-modification-hooks t)
395 deactivate-mark
396 buffer-file-name
397 buffer-file-truename))
398 (progn
399 ,@body)
400 (unless ,modified
401 (restore-buffer-modified-p nil)))))
402 (put 'save-buffer-state 'lisp-indent-function 1)
403 (def-edebug-spec save-buffer-state let))
404
405
406(defvar auto-composition-chunk-size 500
407 "*Automatic composition chunks of this many characters, or smaller.")
408
409(defun auto-compose-chars (pos string)
410 "Compose characters after the buffer position POS.
411If STRING is non-nil, it is a string, and POS is an index to the string.
412In that case, compose characters in the string.
413
414This function is the default value of `auto-composition-function' (which see)."
415 (save-buffer-state nil
416 (save-excursion
417 (save-restriction
418 (save-match-data
419 (let* ((start pos)
420 (end (if string (length string) (point-max)))
421 (limit (next-single-property-change pos 'auto-composed string
422 end))
423 (lines 0)
424 ch func newpos)
425 (if (> (- limit start) auto-composition-chunk-size)
426 (setq limit (+ start auto-composition-chunk-size)))
427 (while (and (< pos end)
428 (setq ch (if string (aref string pos)
429 (char-after pos)))
430 (or (< pos limit)
431 (/= ch ?\n)))
432 (setq func (aref composition-function-table ch))
433 (if (fboundp func)
434 (setq newpos (funcall func pos string)
435 pos (if (and (integerp newpos) (> newpos pos))
436 newpos
437 (1+ pos)))
438 (setq pos (1+ pos))))
439 (if (< pos limit)
440 (setq pos (1+ pos)))
441 (put-text-property start pos 'auto-composed t string)))))))
442
443(setq auto-composition-function 'auto-compose-chars)
444
445(defun toggle-auto-composition (&optional arg)
446 "Change whether automatic character composition is enabled in this buffer.
447With arg, enable it iff arg is positive."
448 (interactive "P")
449 (let ((enable (if (null arg) (not auto-composition-function)
450 (> (prefix-numeric-value arg) 0))))
451 (if enable
452 (kill-local-variable 'auto-composition-function)
453 (make-local-variable 'auto-composition-function)
454 (setq auto-composition-function nil)
455 (save-buffer-state nil
456 (save-restriction
457 (widen)
458 (decompose-region (point-min) (point-max)))))
459
460 (save-buffer-state nil
461 (save-restriction
462 (widen)
463 (put-text-property (point-min) (point-max) 'auto-composed nil)))))
364 464
365 465
366;;; The following codes are only for backward compatibility with Emacs 466;;; The following codes are only for backward compatibility with Emacs
367;;; 20.4 and the earlier. 467;;; 20.4 and the earlier.
368 468
369;;;###autoload
370(defun decompose-composite-char (char &optional type with-composition-rule) 469(defun decompose-composite-char (char &optional type with-composition-rule)
371 "Convert CHAR to string. 470 "Convert CHAR to string.
372This is only for backward compatibility with Emacs 20.4 and the earlier. 471This is only for backward compatibility with Emacs 20.4 and the earlier.