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

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

Markers and text properties


From: Deniz Dogan
Subject: Markers and text properties
Date: Tue, 30 Aug 2011 22:19:40 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0

Hi

I'm writing yet another IRC client (named Nima) for Emacs. It is largely based on rcirc, for what it's worth.

So for the input prompt in this client, I'm doing this:

(define-derived-mode nima-mode nil "Nima"
  "Major mode for nima buffers."

  ;; Set up the input prompt.
  (set (make-local-variable 'nima-prompt-start) (point-max-marker))
  (set (make-local-variable 'nima-prompt-end) (point-max-marker))
  (let ((prompt
         (propertize "> "
                     'face 'nima-prompt-face
                     'read-only t
                     'intangible t
                     'field t
                     'front-sticky t
                     'rear-nonsticky t)))
    (insert prompt)
    (set-marker nima-prompt-start (- (point) (length prompt)))
    (set-marker nima-prompt-end (point))
    (set-marker-insertion-type nima-prompt-start t)
    (set-marker-insertion-type nima-prompt-end t)))

And when I want to insert something into a Nima buffer I do this (slightly simplified):

(defun nima-print (buffer prefix rest)
  (with-current-buffer buffer
    (let ((old-point (point-marker))
          (inhibit-read-only t)
          (time-string (format-time-string nima-time-format)))
      (insert-before-markers time-string)
      (insert-before-markers prefix rest "\n"))
    (goto-char old-point)))

The problem is that the only thing that ends up being _visible_ is the input prompt ("> "). These are the values of nima-prompt-start and nima-prompt-end after some messages from the server:

nima-prompt-start:
#<marker (moves after insertion) at 1057 in nima:localhost>

nima-prompt-end:
#<marker (moves after insertion) at 1059 in nima:localhost>

So basically the text I insert before the marker ends up invisible. In rcirc-print, we do something similar before the actual insertion takes place:

          ;; temporarily set the marker insertion-type because
          ;; insert-before-markers results in hidden text in new buffers
          (goto-char rcirc-prompt-start-marker)
          (set-marker-insertion-type rcirc-prompt-start-marker t)
          (set-marker-insertion-type rcirc-prompt-end-marker t)

I don't understand this at all.  What is going on?  What should I do?

Thanks,
Deniz



reply via email to

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