From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joshua Lambert Newsgroups: gmane.emacs.help Subject: Correct use of text properties? Date: Wed, 1 Mar 2023 22:21:14 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000082534d05f5e32915" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5447"; 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 05:22:14 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 1pXaSM-0001KT-NR for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 02 Mar 2023 05:22:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXaRf-0005uq-KE; Wed, 01 Mar 2023 23:21:31 -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 1pXaRe-0005ue-VX for help-gnu-emacs@gnu.org; Wed, 01 Mar 2023 23:21:30 -0500 Original-Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXaRd-0007Fr-BV for help-gnu-emacs@gnu.org; Wed, 01 Mar 2023 23:21:30 -0500 Original-Received: by mail-wr1-x432.google.com with SMTP id r18so15304744wrx.1 for ; Wed, 01 Mar 2023 20:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677730886; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=U3PzCO/ce+Mcea7bbuJKPNnPstMqKQInk5P1iQZzBH8=; b=ChsVLG3YEUhOdcCi1x71GmixHn6DRh+X9k91O1zW3nObe9T4ScRNHfUV2gOJjtvH1z cF5TZ1f7Fm1rx8LOW2R5F2wefLRuBMriK69ha0SjywGAPYQq5Rhn2DHLmXAo9i9hVb/x WxvX/Rle+XP/zWutxbrczFH4aH4ZXetFBVOKko6bMV2iNcxUTNn/Biu2a9ZAvl1Lula/ YQsEHLOVIwkFTOgb1+YZ0+DjS8QYbB0BDB87tT6eAGuND5XkK4eh1DOntRjGgez+9HcY qe6P4sVqJVrwgvPdLsLMBQLRsMZlWgDYo26eHqlUPTloxs+Frby3Vf8thAZMMzhFixRT 0aew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677730886; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U3PzCO/ce+Mcea7bbuJKPNnPstMqKQInk5P1iQZzBH8=; b=rZbGaMzkMnkDlXUO/PpytY1hvQfCiAjnftOSxq+jUn6EjWetb86fQzUbpAR2uSH/YM Tu5/dLZUcbR3pd2y+3qQj/neBezG1uiDxy0XNJ0htHqLwP2V0ArDzH4PQjEWXS8Z+MdJ I92zWunYDZd3r9WDyT+4BCFi2pLtnlsVdFKg0Z/cLgUVi/ZiGcTr8v1+hyiU1AHFwMhD y8Nl4feAd5dSS2tgbzGac8lh6BJ8dtA5DBFBmN4KAjcgYAPWfOrrrczWMlR62YzC4tJf IynMf2d9zS0no5F+/mM4NOErJvnlNS6sCO+LsZSLnNTr8mXLZoTOwjwarmkml5c+j5Jj IaKg== X-Gm-Message-State: AO0yUKUt1oVN1We6uWVKIdQcmmAEgqcRw0lQiqQ4baqf10tMhJeLe1Sf L2L2IIUL+3K4Yn6VLaV9ocM1Y3Ffn6aHitk5oFK/1Njs6jg= X-Google-Smtp-Source: AK7set+lOzxp08ouii0Ra7bkvyUXbVmtyWdOrtHKEIR737w1Nv0/rW9p3SxeXT+/V9WIAwzoMsv6ESKC6721ILGp23s= X-Received: by 2002:a5d:5146:0:b0:2c7:1d73:d59a with SMTP id u6-20020a5d5146000000b002c71d73d59amr1495012wrt.1.1677730886324; Wed, 01 Mar 2023 20:21:26 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=jlambert.lis.tech@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:142886 Archived-At: --00000000000082534d05f5e32915 Content-Type: text/plain; charset="UTF-8" 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? (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 Following is what a sample MARC record looks like, though MARC files don't have newlines. So, if you test this, use the attached file. #+begin_example MARC transmission record 00608nam 22001817a 45000010012000000050017000120080041000290490009000700400013000790740014 00092086002300106245009400129260002600223500003300249500003500282710006 900317949004000386 tmp97483713 20221114095123.0 221114s2022 xxu f000 0 eng d aMOUE aMvI cMvI a1017-A-07 0 aY 4.F 76/1:117-105 04 aThe Burma Crisis, One Year After the Coup, Hearing, Serial No. 117-105, February 17, 2022 a[S.l : bs.n., c2022?] aShipping List #: 2023-0021-P aShipping List Date: 11/02/2022 1 aUnited States. bCongress. bHouse. bCommittee on Foreign Affairs. 1 aY 4.F 76/1:117-105 lSMVUS s- t1 h60 #+end_example Following is the visual result after executing the function above. #+begin_example 00608nam 22001817a 45000010012000000050017000120080041000290490009000700400013000790740014 00092086002300106245009400129260002600223500003300249500003500282710006 900317949004000386 tmp97483713 20221114095123.0 221114s2022 xxu f000 0 eng d aMOUE aMvI cMvI a1017-A-07 0 aY 4.F 76/1:117-105 04 aThe Burma Crisis, One Year After the Coup, Hearing, Serial No. 117-105, February 17, 2022 a[S.l : bs.n., c2022?] aShipping List #: 2023-0021-P aShipping List Date: 11/02/2022 1 aUnited States. bCongress. bHouse. bCommittee on Foreign Affairs. 1 aY 4.F 76/1:117-105 lSMVUS s- t1 h60 #+end_example I'm relatively new to Emacs, elisp, and programming in general so thanks for your help. J. Lambert --00000000000082534d05f5e32915 Content-Type: application/marc; name="sample-marc.mrc" Content-Disposition: attachment; filename="sample-marc.mrc" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_leqln0u90 MDA2MDhuYW0gMjIwMDE4MTdhNDUwMDAwMTAwMTIwMDAwMDAwNTAwMTcwMDAxMjAwODAwNDEwMDAy OTA0OTAwMDkwMDA3MDA0MDAwMTMwMDA3OTA3NDAwMTQwMDA5MjA4NjAwMjMwMDEwNjI0NTAwOTQw MDEyOTI2MDAwMjYwMDIyMzUwMDAwMzMwMDI0OTUwMDAwMzUwMDI4MjcxMDAwNjkwMDMxNzk0OTAw NDAwMDM4Nh50bXA5NzQ4MzcxMx4yMDIyMTExNDA5NTEyMy4wHjIyMTExNHMyMDIyeHh1IGYwMDAg MCBlbmcgZB4gH2FNT1VFHiAfYU12SR9jTXZJHiAfYTEwMTctQS0wNx4wIB9hWSA0LkY3Ni8xOjEx Ny0xMDUeMDQfYVRoZSBCdXJtYSBDcmlzaXMsIE9uZSBZZWFyIEFmdGVyIHRoZSBDb3VwLCBIZWFy aW5nLFNlcmlhbCBOby4gMTE3LTEwNSwgRmVicnVhcnkgMTcsIDIwMjIeIB9hW1MubCA6H2JzLm4u LB9jMjAyMj9dHh9hU2hpcHBpbmcgTGlzdCAjOiAyMDIzLTAwMjEtUB4gH2FTaGlwcGluZyBMaXN0 IERhdGU6IDExLzAyLzIwMjIeMR9hVW5pdGVkIFN0YXRlcy4fYkNvbmdyZXNzLh9iSG91c2UuH2JD b21taXR0ZWUgb24gRm9yZWlnbkFmZmFpcnMuHiAxH2FZIDQuRiA3Ni8xOjExNy0xMDUfbFNNVlVT H3MtH3QxH2g2MB4d --00000000000082534d05f5e32915--