From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Correct use of text properties? Date: Thu, 02 Mar 2023 09:15:45 +0200 Message-ID: <83sfenei8u.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32613"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 02 08:16:16 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pXdAm-0008Kr-Op for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 02 Mar 2023 08:16:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXdAI-00044N-4O; Thu, 02 Mar 2023 02:15:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXdAF-00043U-AC for help-gnu-emacs@gnu.org; Thu, 02 Mar 2023 02:15:44 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXdAF-00009U-1T for help-gnu-emacs@gnu.org; Thu, 02 Mar 2023 02:15:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=7r+ETmZpdlQy6dtM2MAqmKVz0jzdb2ib4cLSsUGzTHw=; b=K8bySZxOocSu mJDsfsls2ATvnDn52znm8g+10LLmsK7jXzsbbSb2YCY8yN7fl4JN8ro5yWGkrAmFzf24PWJqN8czO XghkpBdfs63DXRmrwJiUNcfFUyxCvI4Qm7xxh26YJPnJxrs4D92Z+hhs+cPJn9WDWOtnGqPARpl6l kArpdhHQ5+Xw6lORe1L1FkQvYiLi0yEbbuziSeFjYzg/lmCYVoxC7T3CwY49gs/BinGDTWT8yIwfb yHuwPfxXH+DDx0JyXEmV0eVXTc6EuSslIes4XKwPg+ha6o5GFwLuvQns2++aIw+/RKq6diUS2FjMc ebs/g5DOyj9X3CFF1KafNw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXdA2-0002tr-Ax for help-gnu-emacs@gnu.org; Thu, 02 Mar 2023 02:15:42 -0500 In-Reply-To: (message from Joshua Lambert on Wed, 1 Mar 2023 22:21:14 -0600) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142887 Archived-At: > 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?