diff options
Diffstat (limited to 'lisp/textmodes/fill.el')
-rw-r--r-- | lisp/textmodes/fill.el | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el index 6681b03913c..f394171fb6c 100644 --- a/lisp/textmodes/fill.el +++ b/lisp/textmodes/fill.el @@ -45,14 +45,16 @@ A value of nil means that any change in indentation starts a new paragraph." (defcustom colon-double-space nil "Non-nil means put two spaces after a colon when filling." :type 'boolean) -(put 'colon-double-space 'safe-local-variable 'booleanp) +(put 'colon-double-space 'safe-local-variable #'booleanp) (defcustom fill-separate-heterogeneous-words-with-space nil "Non-nil means to use a space to separate words of a different kind. -This will be done with a word in the end of a line and a word in -the beginning of the next line when concatenating them for -filling those lines. Whether to use a space depends on how the -words are categorized." +For example, when an English word at the end of a line and a CJK word +at the beginning of the next line are joined into a single line, they +will be separated by a space if this variable is non-nil. +Whether to use a space to separate such words also depends on the entry +in `fill-nospace-between-words-table' for the characters before and +after the newline." :type 'boolean :version "26.1") @@ -131,6 +133,8 @@ A nil return value means the function has not determined the fill prefix." (defvar fill-indent-according-to-mode nil ;Screws up CC-mode's filling tricks. "Whether or not filling should try to use the major mode's indentation.") +(defvar current-fill-column--has-warned nil) + (defun current-fill-column () "Return the fill-column to use for this line. The fill-column to use for a buffer is stored in the variable `fill-column', @@ -156,7 +160,14 @@ number equals or exceeds the local fill-column - right-margin difference." (< col fill-col))) (setq here change here-col col)) - (max here-col fill-col))))) + (max here-col fill-col)) + ;; This warning was added in 28.1. It should be removed later, + ;; and this function changed to never return nil. + (unless current-fill-column--has-warned + (lwarn '(fill-column) :warning + "Setting this variable to nil is obsolete; use `(auto-fill-mode -1)' instead") + (setq current-fill-column--has-warned t)) + most-positive-fixnum))) (defun canonically-space-region (beg end) "Remove extra spaces between words in region. @@ -412,12 +423,12 @@ and `fill-nobreak-invisible'." ;; Register `kinsoku' for scripts HAN, KANA, BOPOMOFO, and CJK-MISC. ;; Also tell that they don't use space between words. (map-char-table - #'(lambda (key val) - (when (memq val '(han kana bopomofo cjk-misc)) - (set-char-table-range fill-find-break-point-function-table - key 'kinsoku) - (set-char-table-range fill-nospace-between-words-table - key t))) + (lambda (key val) + (when (memq val '(han kana bopomofo cjk-misc)) + (set-char-table-range fill-find-break-point-function-table + key 'kinsoku) + (set-char-table-range fill-nospace-between-words-table + key t))) char-script-table) ;; Do the same thing also for full width characters and half ;; width kana variants. @@ -703,7 +714,8 @@ space does not end a sentence, so don't break a line there." (or justify (setq justify (current-justification))) ;; Don't let Adaptive Fill mode alter the fill prefix permanently. - (let ((fill-prefix fill-prefix)) + (let ((actual-fill-prefix fill-prefix) + (fill-prefix fill-prefix)) ;; Figure out how this paragraph is indented, if desired. (when (and adaptive-fill-mode (or (null fill-prefix) (string= fill-prefix ""))) @@ -717,7 +729,7 @@ space does not end a sentence, so don't break a line there." (goto-char from) (beginning-of-line) - (if (not justify) ; filling disabled: just check indentation + (if (not justify) ; filling disabled: just check indentation (progn (goto-char from) (while (< (point) to) @@ -747,12 +759,14 @@ space does not end a sentence, so don't break a line there." linebeg) (while (< (point) to) ;; On the first line, there may be text in the fill prefix - ;; zone. In that case, don't consider that area when - ;; trying to find a place to put a line break (bug#45720). + ;; zone (when `fill-prefix' is specified externally, and + ;; not computed). In that case, don't consider that area + ;; when trying to find a place to put a line break + ;; (bug#45720). (if (not first) (setq linebeg (point)) (setq first nil - linebeg (+ (point) (length fill-prefix)))) + linebeg (+ (point) (length actual-fill-prefix)))) (move-to-column (current-fill-column)) (if (when (< (point) to) ;; Find the position where we'll break the line. |