* help with lisp function
@ 2004-02-17 15:03 Javier Oviedo
2004-02-17 15:21 ` Pascal Bourguignon
0 siblings, 1 reply; 4+ messages in thread
From: Javier Oviedo @ 2004-02-17 15:03 UTC (permalink / raw)
Hi all. I'm trying to write a function that copies lines from one buffer to
another buffer and keeps the original text properties. It works...sort of.
The problem is that after 70 lines, the copy stops carrying the text
properties over....the copy itself is done correctly and I end up with two
identical buffers. The problem is only with the text-properties being lost
after line 70. So, for the first 70 lines are displayed with the original
text-properties, but everything after that is displayed as plain text. Doing
a describe-text-properties verifies this.
Any help/thoughts/comments? Thanks in advance!
Here is the function:
(defun jo-test ()
(interactive)
(setq buf-name "*JOTest*")
(setq curbuf (buffer-name))
(setq test-buf (get-buffer-create buf-name))
(display-buffer test-buf)
(save-excursion
(goto-char (point-min))
(with-current-buffer test-buf
(setq buffer-read-only nil)
(with-current-buffer curbuf
(while (not (eobp))
(setq curMatch "")
(setq curMatch (buffer-substring (line-beginning-position)
(line-end-position)))
(forward-line 1)
(with-current-buffer test-buf
(insert (concat curMatch "\n"))
)
)
)
)
)
)
--
Javier
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help with lisp function
2004-02-17 15:03 help with lisp function Javier Oviedo
@ 2004-02-17 15:21 ` Pascal Bourguignon
2004-02-17 16:03 ` Peter Lee
2004-02-17 16:18 ` Javier Oviedo
0 siblings, 2 replies; 4+ messages in thread
From: Pascal Bourguignon @ 2004-02-17 15:21 UTC (permalink / raw)
"Javier Oviedo" <email_joviedo@yahoo.com> writes:
> Hi all. I'm trying to write a function that copies lines from one buffer to
> another buffer and keeps the original text properties. It works...sort of.
> The problem is that after 70 lines, the copy stops carrying the text
> properties over....the copy itself is done correctly and I end up with two
> identical buffers. The problem is only with the text-properties being lost
> after line 70. So, for the first 70 lines are displayed with the original
> text-properties, but everything after that is displayed as plain text. Doing
> a describe-text-properties verifies this.
>
> Any help/thoughts/comments? Thanks in advance!
>
> Here is the function:
>
> (defun jo-test ()
> (interactive)
> (setq buf-name "*JOTest*")
> (setq curbuf (buffer-name))
> (setq test-buf (get-buffer-create buf-name))
> (display-buffer test-buf)
> (save-excursion
> (goto-char (point-min))
> (with-current-buffer test-buf
> (setq buffer-read-only nil)
> (with-current-buffer curbuf
> (while (not (eobp))
> (setq curMatch "")
> (setq curMatch (buffer-substring (line-beginning-position)
> (line-end-position)))
> (forward-line 1)
> (with-current-buffer test-buf
> (insert (concat curMatch "\n")) ))))))
Notice how it looks nicer _______________________^
I assume the text properties you're asking for include the
fontification of the source buffer? Fontification is done
lazily. Only shown lines and a few more are fontified. The rest is
done only if and when it's shown.
--
__Pascal_Bourguignon__ http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help with lisp function
2004-02-17 15:21 ` Pascal Bourguignon
@ 2004-02-17 16:03 ` Peter Lee
2004-02-17 16:18 ` Javier Oviedo
1 sibling, 0 replies; 4+ messages in thread
From: Peter Lee @ 2004-02-17 16:03 UTC (permalink / raw)
>>>> Pascal Bourguignon writes:
Pascal> I assume the text properties you're asking for include the
Pascal> fontification of the source buffer? Fontification is done
Pascal> lazily. Only shown lines and a few more are fontified.
Pascal> The rest is done only if and when it's shown.
Doesn't that depend on which type of fontification you are using? I
thought fast-lock-mode did it all on load whereas lazy and jit are, as
you say, dynamic.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help with lisp function
2004-02-17 15:21 ` Pascal Bourguignon
2004-02-17 16:03 ` Peter Lee
@ 2004-02-17 16:18 ` Javier Oviedo
1 sibling, 0 replies; 4+ messages in thread
From: Javier Oviedo @ 2004-02-17 16:18 UTC (permalink / raw)
Aaahhhh. It seems that having lazy-lock enabled in the source buffer causes
this problem. If I temporarily disable lazy-lock in the source buffer then
text properties get copied over as expected. Thanks!!
--
Javier
"Pascal Bourguignon" <spam@thalassa.informatimago.com> wrote in message
news:87d68dd94s.fsf@thalassa.informatimago.com...
> "Javier Oviedo" <email_joviedo@yahoo.com> writes:
>
> > Hi all. I'm trying to write a function that copies lines from one buffer
to
> > another buffer and keeps the original text properties. It works...sort
of.
> > The problem is that after 70 lines, the copy stops carrying the text
> > properties over....the copy itself is done correctly and I end up with
two
> > identical buffers. The problem is only with the text-properties being
lost
> > after line 70. So, for the first 70 lines are displayed with the
original
> > text-properties, but everything after that is displayed as plain text.
Doing
> > a describe-text-properties verifies this.
> >
> > Any help/thoughts/comments? Thanks in advance!
> >
> > Here is the function:
> >
> > (defun jo-test ()
> > (interactive)
> > (setq buf-name "*JOTest*")
> > (setq curbuf (buffer-name))
> > (setq test-buf (get-buffer-create buf-name))
> > (display-buffer test-buf)
> > (save-excursion
> > (goto-char (point-min))
> > (with-current-buffer test-buf
> > (setq buffer-read-only nil)
> > (with-current-buffer curbuf
> > (while (not (eobp))
> > (setq curMatch "")
> > (setq curMatch (buffer-substring (line-beginning-position)
> > (line-end-position)))
> > (forward-line 1)
> > (with-current-buffer test-buf
> > (insert (concat curMatch "\n")) ))))))
>
> Notice how it looks nicer _______________________^
>
> I assume the text properties you're asking for include the
> fontification of the source buffer? Fontification is done
> lazily. Only shown lines and a few more are fontified. The rest is
> done only if and when it's shown.
>
> --
> __Pascal_Bourguignon__ http://www.informatimago.com/
> There is no worse tyranny than to force a man to pay for what he doesn't
> want merely because you think it would be good for him.--Robert Heinlein
> http://www.theadvocates.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-17 16:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-17 15:03 help with lisp function Javier Oviedo
2004-02-17 15:21 ` Pascal Bourguignon
2004-02-17 16:03 ` Peter Lee
2004-02-17 16:18 ` Javier Oviedo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).