help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: disable that the face of a newline character extends to the right


From: martin rudalics
Subject: Re: disable that the face of a newline character extends to the right
Date: Fri, 22 May 2009 10:00:33 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

> The face of a newline character seems to extend to the right to
> infinity.
>
> I have set the background color of font-lock-comment-face, but I find
> it ugly if now all comment lines have a colored beam at the right
> side.
>
> Is there a way to configure how the background color of a newline
> character should be rendered? E.g. not at all, or just the newline
> character itself.

Try to add the function below to your .emacs.  It's likely suboptimal
and I didn't look into it for quite a while but it still does the job.

martin



(defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)
  "Put proper face on each string and comment between START and END.
START should be at the beginning of a line."
  (let (state face from to lep)
    (goto-char start)
    (setq state (or ppss (syntax-ppss start)))
    (while
        (progn
          (when (or (nth 3 state) (nth 4 state))
            (setq face (funcall font-lock-syntactic-face-function state))
            (setq from (max (nth 8 state) start))
            (setq state
                  (parse-partial-sexp (point) end nil nil state 'syntax-table))
            (setq to (point))
            (save-excursion
              (goto-char from)
              (while (< from to)
                (setq lep (line-end-position))
                (if (< lep to)
                    (progn
                      (put-text-property from lep 'face face)
                      (remove-text-properties
                       lep (1+ lep) '(face nil)) ; rear-nonsticky t))
                      (goto-char (setq from (1+ lep))))
                  (put-text-property from to 'face face)
                  (setq from to)))))
          (< (point) end))
      (setq state
        (parse-partial-sexp (point) end nil nil state 'syntax-table)))))




reply via email to

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