[Top][All Lists]

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

Re: Correct use of text properties?

From: Eli Zaretskii
Subject: Re: Correct use of text properties?
Date: Thu, 02 Mar 2023 09:15:45 +0200

> From: Joshua Lambert <>
> Date: Wed, 1 Mar 2023 22:21:14 -0600
> I am trying to use text properties to make library MARC records more
> readable in Emacs. Is the function below correctly written? It is meant to
> simply replace codepoints 29 and 30 with newlines, using text properties.
> It seems to visually accomplish what I want, but line numbers and some
> cursor motions don't treat the newlines like true newlines. Is that
> expected behavior?

Probably.  But you don't describe the behavior you found surprising,
so it is hard to tell whether what you see is expected.  Please tell
more about the behavior you observe that surprised you.

> (The files use codepoints 29-31 in ASCII or UTF8 so they may not display
> properly.)
> #+begin_src emacs-lisp
> (defun marc-add-newlines ()
>   "Replace the display text property of all   with newline."
>   (interactive)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward " " nil 1)
>       (put-text-property (- (point) 1) (point) 'display "\n")))
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward " " nil 1)
>       (put-text-property (- (point) 1) (point) 'display "\n"))))
> #+end_src

If all you want is to break long lines on space characters, I suggest
to try visual-line-mode instead: it does that automatically in
low-level display code.  Did you try that?

reply via email to

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