emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: Syntax and Hard Newlines


From: Herbert Euler
Subject: Re: Patch: Syntax and Hard Newlines
Date: Thu, 30 Nov 2006 14:36:08 +0800

    Or in the Lisp level, perhaps we can make adding a
    `syntax-table' text property default when inserting soft
    newlines.

Since that is the method we are using, why not?

Looking through fill.el, I find that many filling functions such as
`fill-paragraph', `fill-region', `fill-individual-paragraphs' etc
finally invokes `fill-region-as-paragraph', which inserts (soft)
newlines with `fill-newline'.  It is defined as follows:

(defun fill-newline ()
 ;; Replace whitespace here with one newline, then
 ;; indent to left margin.
 (skip-chars-backward " \t")
 (insert ?\n)
 ;; Give newline the properties of the space(s) it replaces
 (set-text-properties (1- (point)) (point)
                      (fill-text-properties-at (point)))
 (and (looking-at "\\( [ \t]*\\)\\(\\c|\\)?")
(or (aref (char-category-set (or (char-before (1- (point))) ?\000)) ?|)
          (match-end 2))
;; When refilling later on, this newline would normally not be replaced ;; by a space, so we need to mark it specially to re-install the space
      ;; when we unfill.
(put-text-property (1- (point)) (point) 'fill-space (match-string 1)))
 ;; If we don't want breaks in invisible text, don't insert
 ;; an invisible newline.
 (if fill-nobreak-invisible
     (remove-text-properties (1- (point)) (point)
                             '(invisible t)))
 (if (or fill-prefix
         (not fill-indent-according-to-mode))
     (fill-indent-to-left-margin)
   (indent-according-to-mode))
 ;; Insert the fill prefix after indentation.
 (and fill-prefix (not (equal fill-prefix ""))
      ;; Markers that were after the whitespace are now at point: insert
      ;; before them so they don't get stuck before the prefix.
      (insert-before-markers-and-inherit fill-prefix)))

If all filling functions insert soft newlines with `fill-newline',
changing this function will be Ok.  And if making this change is Ok,
how about adding a customizable variable to control whether putting
the `syntax-table' property?  This would require as little functions
to be changed as possible.

Regards,
Guanpeng Xu

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.com/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]