emacs-devel
[Top][All Lists]
Advanced

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

Re: Need help fixing comint fontification for python.


From: Michael Mauger
Subject: Re: Need help fixing comint fontification for python.
Date: Mon, 8 Oct 2012 12:05:43 -0700 (PDT)

On Sun, 07 Oct 2012 10:37:28 -0400, Stefan Monnier said:  > > What would be the 
best way remove the syntax class for all the output?
> 
> Use a syntax-propertize-function.
> 
> Look at the `field' property and wherever its value is `output', place
> an appropriate syntax-table property.
> Or alternatively, use a "safe" syntax-table in the buffer, but add
> Python's syntax-table as a property whereas the `field' property is nil.
> 
> 
>         Stefan I've tried this and it doesn't appear that the field text 
> property has
been applied to the output text when the syntax-propertize-function
fires. Once the display is complete, the field property is present but
in the hook function it isn't present.  Am I missing something? At the start of 
the syntax-propertize-function on the START location: 
------------------------------------------------------------------------ 
position: 12182 of 13643 (89%), column: 4 character: [ (displayed as [) 
(codepoint 91, #o133, #x5b) preferred charset: iso-8859-1 (Latin-1 (ISO/IEC 
8859-1))
code point in charset: 0x5B syntax: (]  which means: open, matches ] category: 
.:Base, a:ASCII, l:Latin, r:Roman to input: type "C-x 8 RET HEX-CODEPOINT" or 
"C-x 8 RET NAME" buffer code: #x5B file code: #x5B (encoded by coding system 
iso-latin-1-unix) display: by this font (glyph code) xft:-unknown-DejaVu Sans 
Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1 (#x3E) Character code 
properties: customize what to show name: LEFT SQUARE BRACKET old-name: OPENING 
SQUARE BRACKET general-category: Ps (Punctuation, Open) decomposition: (91) 
('[') There is an overlay here: From 12182 to 12182 face                 
hl-line window               #<window 44 on *Python*> There are text properties 
here: charset              iso-8859-1 fontified            nil 
------------------------------------------------------------------------ At the 
same location, in the comint buffer 
------------------------------------------------------------------------ 
position: 12182 of
 13643 (89%), column: 0 character: [ (displayed as [) (codepoint 91, #o133, 
#x5b) preferred charset: iso-8859-1 (Latin-1 (ISO/IEC 8859-1))
code point in charset: 0x5B syntax: (]  which means: open, matches ] category: 
.:Base, a:ASCII, l:Latin, r:Roman to input: type "C-x 8 RET HEX-CODEPOINT" or 
"C-x 8 RET NAME" buffer code: #x5B file code: #x5B (encoded by coding system 
iso-latin-1-unix) display: by this font (glyph code) xft:-unknown-DejaVu Sans 
Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1 (#x3E) Character code 
properties: customize what to show name: LEFT SQUARE BRACKET old-name: OPENING 
SQUARE BRACKET general-category: Ps (Punctuation, Open) decomposition: (91) 
('[') There is an overlay here: From 12182 to 12183 face                 
show-paren-match priority             1000 There are text properties here: 
charset              iso-8859-1 field                output fontified           
 t front-sticky         (field inhibit-line-move-field-capture) 
inhibit-line-move-field-capture t rear-nonsticky       t [back] 
------------------------------------------------------------------------
Here's what I did:

  (defun my-comint-output-propertize (start end)
    (let (output-start output-end)
      (while (< start end)
        (describe-char start)
        (setq output-start (text-property-any start end 'field 'output))
        (if output-start    ;; <-- Never satisfied
            (progn 
              (setq output-end 
                    (min 
                     (next-single-char-property-change output-start 'field nil 
end)
                     (next-single-char-property-change output-start 
'font-lock-face nil end)))
              (unless (eq (get-char-property output-start 'font-lock-face) 
                          'comint-highlight-prompt)
                (put-text-property output-start output-end 'font-lock-face 
'italic))
              (setq start output-end))
          (setq start end)))))

  (add-hook 'comint-mode-hook 
            (lambda () (setq syntax-propertize-function 
'my-comint-output-propertize)))


The output above is from the `describe-char' call; the
`text-property-any' call is never detecting the `field' property being
set to `output'.  The second output is from me positioning the caret and
hitting C-u C-x =.

Obviously, dope slap me if appropriate, I can't learn
otherwise. Be gentle. 

-- Michael



reply via email to

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