Mercurial > emacs
comparison lisp/textmodes/fill.el @ 90633:6408dbfc7b6a
(fill-find-break-point-function-table): Don't
setup it in defvar.
(fill-nospace-between-words-table): New variable.
(fill-delete-newlines): Check fill-nospace-between-words-table
instead of charset property nospcae-between-words.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 26 Oct 2006 02:29:03 +0000 |
parents | 81b116fa69ab |
children | 02cf29720f31 |
comparison
equal
deleted
inserted
replaced
90632:9438efdad8d0 | 90633:6408dbfc7b6a |
---|---|
366 ;; which follows as a reason to return t. | 366 ;; which follows as a reason to return t. |
367 (and (not (eolp)) | 367 (and (not (eolp)) |
368 (looking-at paragraph-start)))) | 368 (looking-at paragraph-start)))) |
369 (run-hook-with-args-until-success 'fill-nobreak-predicate))))) | 369 (run-hook-with-args-until-success 'fill-nobreak-predicate))))) |
370 | 370 |
371 (defvar fill-find-break-point-function-table | 371 (defvar fill-find-break-point-function-table (make-char-table nil) |
372 (let ((table (make-char-table nil))) | |
373 ;; Register `kinsoku' for scripts HAN, KANA, BOPOMPFO, and CJK-MISS. | |
374 (map-char-table #'(lambda (key val) | |
375 (if (memq val '(han kana bopomofo cjk-misc)) | |
376 (set-char-table-range table key 'kinsoku))) | |
377 char-script-table) | |
378 ;; Register `kinsoku" also for full width characters. | |
379 (set-char-table-range table '(#xFF01 . #xFF61) 'kinsoku) | |
380 (set-char-table-range table '(#xFFE0 . #xFFE6) 'kinsoku) | |
381 table) | |
382 "Char-table of special functions to find line breaking point.") | 372 "Char-table of special functions to find line breaking point.") |
373 | |
374 (defvar fill-nospace-between-words-table (make-char-table nil) | |
375 "Char-table of characters that don't use space between words.") | |
376 | |
377 (progn | |
378 ;; Register `kinsoku' for scripts HAN, KANA, BOPOMPFO, and CJK-MISS. | |
379 ;; Also tell that they don't use space between words. | |
380 (map-char-table | |
381 #'(lambda (key val) | |
382 (when (memq val '(han kana bopomofo cjk-misc)) | |
383 (set-char-table-range fill-find-break-point-function-table | |
384 key 'kinsoku) | |
385 (set-char-table-range fill-nospace-between-words-table | |
386 key t))) | |
387 char-script-table) | |
388 ;; Do the same thing also for full width characters and half | |
389 ;; width kana variants. | |
390 (set-char-table-range fill-find-break-point-function-table | |
391 '(#xFF01 . #xFFE6) 'kinsoku) | |
392 (set-char-table-range fill-nospace-between-words-table | |
393 '(#xFF01 . #xFFE6) 'kinsoku)) | |
383 | 394 |
384 (defun fill-find-break-point (limit) | 395 (defun fill-find-break-point (limit) |
385 "Move point to a proper line breaking position of the current line. | 396 "Move point to a proper line breaking position of the current line. |
386 Don't move back past the buffer position LIMIT. | 397 Don't move back past the buffer position LIMIT. |
387 | 398 |
449 (insert-and-inherit ?\s)))) | 460 (insert-and-inherit ?\s)))) |
450 | 461 |
451 (goto-char from) | 462 (goto-char from) |
452 (if enable-multibyte-characters | 463 (if enable-multibyte-characters |
453 ;; Delete unnecessay newlines surrounded by words. The | 464 ;; Delete unnecessay newlines surrounded by words. The |
454 ;; character category `|' means that we can break a line | 465 ;; character category `|' means that we can break a line at the |
455 ;; at the character. And, charset property | 466 ;; character. And, char-table |
456 ;; `nospace-between-words' tells how to concatenate | 467 ;; `fill-nospace-between-words-table' tells how to concatenate |
457 ;; words. If the value is non-nil, never put spaces | 468 ;; words. If a character has non-nil value in the table, never |
458 ;; between words, thus delete a newline between them. | 469 ;; put spaces between words, thus delete a newline between them. |
459 ;; If the value is nil, delete a newline only when a | 470 ;; Otherwise, delete a newline only when a character preceding a |
460 ;; character preceding a newline has text property | 471 ;; newline has non-nil value in that table. |
461 ;; `nospace-between-words'. | |
462 (while (search-forward "\n" to t) | 472 (while (search-forward "\n" to t) |
463 (if (get-text-property (match-beginning 0) 'fill-space) | 473 (if (get-text-property (match-beginning 0) 'fill-space) |
464 (replace-match (get-text-property (match-beginning 0) 'fill-space)) | 474 (replace-match (get-text-property (match-beginning 0) 'fill-space)) |
465 (let ((prev (char-before (match-beginning 0))) | 475 (let ((prev (char-before (match-beginning 0))) |
466 (next (following-char))) | 476 (next (following-char))) |
467 (if (and (or (aref (char-category-set next) ?|) | 477 (if (and (or (aref (char-category-set next) ?|) |
468 (aref (char-category-set prev) ?|)) | 478 (aref (char-category-set prev) ?|)) |
469 (or (get-charset-property (char-charset prev) | 479 (or (aref fill-nospace-between-words-table next) |
470 'nospace-between-words) | 480 (aref fill-nospace-between-words-table prev))) |
471 (get-text-property (1- (match-beginning 0)) | |
472 'nospace-between-words))) | |
473 (delete-char -1)))))) | 481 (delete-char -1)))))) |
474 | 482 |
475 (goto-char from) | 483 (goto-char from) |
476 (skip-chars-forward " \t") | 484 (skip-chars-forward " \t") |
477 ;; Then change all newlines to spaces. | 485 ;; Then change all newlines to spaces. |