Lisp HUG Maillist Archive

font lock question: put-text-property doesn't work as expected

Lispworks for Linux Pro, 5.0.2

Code doesn't work:

  (in-package #:editor)

  (defvar editor::*play* (second editor:*buffer-list*))

  (use-buffer *play*
    (with-point ((start (current-point))
		 (end (current-point)))
      (line-end end)
      (print (points-to-string start end))
      (put-text-property
       start
       end
       'face
       *font-lock-comment-face*)))

Put this in a buffer.  Assign buffer to *play*.  Put cursor at
beginning of "(use-buffer" line.  cut-and-paste into Listener:

  EDITOR 70 > (use-buffer *play*
    (with-point ((start (current-point))
		 (end (current-point)))
      (line-end end)
      (print (points-to-string start end))
      (put-text-property
       start
       end
       'face
       *font-lock-comment-face*)))

  "(use-buffer *play*" 
  T

But it doesn't change the color of the "(use-buffer" line.  I know, or
at least I'm pretty sure, that the marks are in the right place,
'cause it prints the points-to-string as expected.  So there's
something I'm missing about put-text-property.

Any hints or suggestions?  Do I have to "commit changes" or something?

-- Larry


Re: font lock question: put-text-property doesn't work as expected


On Jun 23, 2007, at 1:25 AM, Larry Clapp wrote:

> But it doesn't change the color of the "(use-buffer" line.  I know, or
> at least I'm pretty sure, that the marks are in the right place,
> 'cause it prints the points-to-string as expected.  So there's
> something I'm missing about put-text-property.
>
> Any hints or suggestions?  Do I have to "commit changes" or something?


Editor operations need to be called in the context of the editor  
process. See the list archives for discussion of editor:process- 
character. I think Windows and Linux are more forgiving on this than  
the Mac version. You might also try calling editor:redisplay after  
your changes.

John




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Updated at: 2020-12-10 08:45 UTC