all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Markers and text properties
@ 2011-08-30 20:19 Deniz Dogan
  2011-08-31  5:58 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Deniz Dogan @ 2011-08-30 20:19 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-01  5:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-30 20:19 Markers and text properties Deniz Dogan
2011-08-31  5:58 ` Eli Zaretskii
2011-09-01  5:36   ` Deniz Dogan

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.