all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indentation via text or overlay property?
@ 2003-06-04 19:13 Kevin Rodgers
  2003-06-04 21:16 ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2003-06-04 19:13 UTC (permalink / raw)


Is there a way to implement indentation via a text property like left-margin
or an overlay property like before-string?  I would like sgml-mode.el or PSGML
to display XML as if it were indented, without actually modifying the buffer
by adding and deleting whitespace.

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: indentation via text or overlay property?
  2003-06-04 19:13 indentation via text or overlay property? Kevin Rodgers
@ 2003-06-04 21:16 ` Stefan Monnier
  2003-06-06 16:23   ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2003-06-04 21:16 UTC (permalink / raw)


>>>>> "Kevin" == Kevin Rodgers <ihs_4664@yahoo.com> writes:
> Is there a way to implement indentation via a text property like left-margin
> or an overlay property like before-string?

(put-text-property start end 'display '(space :align-to N))

will make the text between `start' and `end' appear like a space
that ends at column N.
This is at least documented in the NEWS file of Emacs-21.1, and
I'd expect there to be something about it as well in the elisp manual.


        Stefan

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

* Re: indentation via text or overlay property?
  2003-06-04 21:16 ` Stefan Monnier
@ 2003-06-06 16:23   ` Kevin Rodgers
  2003-06-06 16:59     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2003-06-06 16:23 UTC (permalink / raw)


Stefan Monnier wrote:

>>>>>>"Kevin" == Kevin Rodgers <ihs_4664@yahoo.com> writes:
>>>>>>
>>Is there a way to implement indentation via a text property like left-margin
>>or an overlay property like before-string?
> 
> (put-text-property start end 'display '(space :align-to N))
> 
> will make the text between `start' and `end' appear like a space
> that ends at column N.


Cool!  But since those spaces are displayed instead of the original text (not
in addition to it), I don't see how to use that to implement indentation.

For example, let's say I have a <foo> tag at the beginning of a line that I
want displayed at column 6.  If I specify '(space :align-to 5) for the
display property at the position of "<" in the buffer, it gets indented like
I want except that the "<" is no longer visible.  And apparently I can't use
a value like

	(list '(space :align-to N) (buffer-substring start end))

to get both the spaces and the original text displayed.

> This is at least documented in the NEWS file of Emacs-21.1, and
> I'd expect there to be something about it as well in the elisp manual.

Thanks for the pointers.  Is the correct way to test for this feature:

	(>= emacs-major-version 21)

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: indentation via text or overlay property?
  2003-06-06 16:23   ` Kevin Rodgers
@ 2003-06-06 16:59     ` Stefan Monnier
  2003-06-06 18:09       ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2003-06-06 16:59 UTC (permalink / raw)


> Cool!  But since those spaces are displayed instead of the original text
> (not in addition to it), I don't see how to use that to
> implement indentation.

You might want to put that property on an overlay (of size 0), then.

> Thanks for the pointers.  Is the correct way to test for this feature:
> 	(>= emacs-major-version 21)

I think (featurep 'text-properties 'display) is better.


        Stefan

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

* Re: indentation via text or overlay property?
  2003-06-06 16:59     ` Stefan Monnier
@ 2003-06-06 18:09       ` Kevin Rodgers
  2003-06-06 19:29         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2003-06-06 18:09 UTC (permalink / raw)


Stefan Monnier wrote:

>>Cool!  But since those spaces are displayed instead of the original text
>>(not in addition to it), I don't see how to use that to
>>implement indentation.
> 
> You might want to put that property on an overlay (of size 0), then.


Good idea, especially because I want to avoid modifying the buffer.  But I'm
having problems getting overlays of size 0 to work.  Trying things out manually
with M-:, I've only gotten the desired effect once.  I'm trying things like:

(let ((lbp (line-beginning-position)))
   (overlay-put (make-overlay lbp lbp)
	       'display '(space :align-to 4)))

(let ((lbp (line-beginning-position)))
   (overlay-put (make-overlay lbp lbp)
	       'string-before (make-string 4 ? )))

>>Thanks for the pointers.  Is the correct way to test for this feature:
>>	(>= emacs-major-version 21)
> 
> I think (featurep 'text-properties 'display) is better.

| Debugger entered--Lisp error: (wrong-number-of-arguments #<subr featurep> 2)


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: indentation via text or overlay property?
  2003-06-06 18:09       ` Kevin Rodgers
@ 2003-06-06 19:29         ` Stefan Monnier
  2003-06-09 21:56           ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2003-06-06 19:29 UTC (permalink / raw)


> Good idea, especially because I want to avoid modifying the buffer.
> But I'm having problems getting overlays of size 0 to work.  Trying things
> out manually with M-:, I've only gotten the desired effect once.
> I'm trying things like:

> (let ((lbp (line-beginning-position)))
>    (overlay-put (make-overlay lbp lbp)
> 	       'display '(space :align-to 4)))

Does it work with text-properties ?  How about with a non-empty overlay ?
It's a part of the code that hasn't seen much use yet, so there might
be bugs.

> (let ((lbp (line-beginning-position)))
>    (overlay-put (make-overlay lbp lbp)
> 	       'string-before (make-string 4 ? )))

The `string-before' should be `before-string' and it should work
because it's been around (and used) for a long time.

>>> Thanks for the pointers.  Is the correct way to test for this feature:
>>> (>= emacs-major-version 21)
>> I think (featurep 'text-properties 'display) is better.

> | Debugger entered--Lisp error: (wrong-number-of-arguments #<subr featurep> 2)

Oops, looks like it didn't make it to Emacs-21.1, sorry.  I guess
testing emacs-major-version is not worse than anything else.


        Stefan

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

* Re: indentation via text or overlay property?
  2003-06-06 19:29         ` Stefan Monnier
@ 2003-06-09 21:56           ` Kevin Rodgers
  2003-06-09 22:57             ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2003-06-09 21:56 UTC (permalink / raw)


Stefan Monnier wrote:

>>(let ((lbp (line-beginning-position)))
>>   (overlay-put (make-overlay lbp lbp)
>>	       'display '(space :align-to 4)))
>>
> 
> Does it work with text-properties ?  How about with a non-empty overlay ?
> It's a part of the code that hasn't seen much use yet, so there might
> be bugs.


Yes, it works with non-empty overlays, and with a text property assigned to the

first character on the line.  But the empty overlay case seems to be a bug.


>>(let ((lbp (line-beginning-position)))
>>   (overlay-put (make-overlay lbp lbp)
>>	       'string-before (make-string 4 ? )))
>>
> 
> The `string-before' should be `before-string' and it should work
> because it's been around (and used) for a long time.

Doh!  I think that's the best solution for my problem.

Thanks for your help,
-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: indentation via text or overlay property?
  2003-06-09 21:56           ` Kevin Rodgers
@ 2003-06-09 22:57             ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2003-06-09 22:57 UTC (permalink / raw)


> Yes, it works with non-empty overlays, and with a text property assigned
> to the first character on the line.  But the empty overlay case seems to
> be a bug.

Could you report it with M-x report-emacs-bug ?
That would be very helpful, thank you,


        Stefan

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

end of thread, other threads:[~2003-06-09 22:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-04 19:13 indentation via text or overlay property? Kevin Rodgers
2003-06-04 21:16 ` Stefan Monnier
2003-06-06 16:23   ` Kevin Rodgers
2003-06-06 16:59     ` Stefan Monnier
2003-06-06 18:09       ` Kevin Rodgers
2003-06-06 19:29         ` Stefan Monnier
2003-06-09 21:56           ` Kevin Rodgers
2003-06-09 22:57             ` Stefan Monnier

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.