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

* Re: Markers and text properties
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2011-08-31  5:58 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Tue, 30 Aug 2011 22:19:40 +0200
> From: Deniz Dogan <deniz@dogan.se>
> 
>    (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 ("> ").
> [...]
> I don't understand this at all.  What is going on?  What should I do?

Sorry, I can't make heads or tails out of your description.  Perhaps I
don't yet have enough caffeine in my blood ;-)  And since you didn't
show a complete example, I cannot try anything myself.

First, where does the invisibility come from?  I see no invisible
properties in the fragments you posted, only intangible (which AFAIK
does not hide text).  Are you saying that Emacs hides text without any
reason such as text properties?

Next, I don't understand all the games you play with stickyness,
insertions, and markers.  For starters:

 . you define stickyness properties, but use insert and
   insert-before-markers which are documented to not inherit text
   properties, so stickyness is not relevant to the code you wrote

 . you use set-marker-insertion-type, but insert-before-markers is
   documented to ignore the markers' insertion types

What is going on?  What am I missing here?



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

* Re: Markers and text properties
  2011-08-31  5:58 ` Eli Zaretskii
@ 2011-09-01  5:36   ` Deniz Dogan
  0 siblings, 0 replies; 3+ messages in thread
From: Deniz Dogan @ 2011-09-01  5:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On 2011-08-31 07:58, Eli Zaretskii wrote:
> What is going on?  What am I missing here?
>

Well, this is embarrassing.  It seems that I just had to recenter the 
window...



^ 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.