From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.bugs Subject: bug#56335: 29.0.50; [PATCH] Add more breakpoint chars support to longlines-mode Date: Tue, 05 Jul 2022 15:07:14 +0200 Message-ID: <87wncrzp19.fsf@elite.giraud> References: <87czep15pf.fsf@elite.giraud> <87y1xb1zk5.fsf@gnus.org> <83sfnjbse9.fsf@gnu.org> <87edz31y62.fsf@gnus.org> <83pminbrak.fsf@gnu.org> <87fsjjzfpl.fsf@gnus.org> <87k08vrz4b.fsf@elite.giraud> <831qv2bwx3.fsf@gnu.org> <87iloduwt0.fsf@elite.giraud> <834jzx9ld5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21901"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: larsi@gnus.org, 56335@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 05 15:08:12 2022 Return-path: Envelope-to: geb-bug-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 1o8iHk-0005W9-8i for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Jul 2022 15:08:12 +0200 Original-Received: from localhost ([::1]:41128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8iHi-0003nn-7P for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Jul 2022 09:08:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8iHb-0003n5-6E for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2022 09:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8iHa-0007M7-UN for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2022 09:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o8iHa-0004Oq-Mo for bug-gnu-emacs@gnu.org; Tue, 05 Jul 2022 09:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jul 2022 13:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56335 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56335-submit@debbugs.gnu.org id=B56335.165702644116838 (code B ref 56335); Tue, 05 Jul 2022 13:08:02 +0000 Original-Received: (at 56335) by debbugs.gnu.org; 5 Jul 2022 13:07:21 +0000 Original-Received: from localhost ([127.0.0.1]:49662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8iGv-0004NW-4G for submit@debbugs.gnu.org; Tue, 05 Jul 2022 09:07:21 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:39037) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8iGr-0004NI-BI for 56335@debbugs.gnu.org; Tue, 05 Jul 2022 09:07:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=H8drAW5hMwsD3EpR tzRpJ/ayLioUuN7BOePdu4X72yg=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=oMOhoG0cb5x60SFgxRhWU8l61qnXbEx293vPB7 ijWyFXF+3GzqVKi0oZH5j5+MwjWFfFyWERuA8jeSeBnyb9S46WWnfkNtM55Cp56h5Y8lr4 CRUfzN27R2ss8jORD7X0G63ugpqo6gTWdvc2jhrZH/s/UXCwDryQTYB/5Vx8rm85IJeebQ Td8zab8Z1kjiedHeOwwrmZEUkqHIZTTO9HfPAQMcAI9KueSLKwBoz707niscp9Aa3a+iCQ 96w4j3O0YyjCVz9d9uv30/XtAglccxdiioP+f4AswOb+jTYAYSJy03fZtYUYe4MuTfWVxx XsGvZ3mMCKBrbmFBtIJUmPbA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id fdc39527 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 5 Jul 2022 15:07:15 +0200 (CEST) In-Reply-To: <834jzx9ld5.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 04 Jul 2022 14:18:46 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:236114 Archived-At: --=-=-= Content-Type: text/plain Hi, Here is a new patch for longlines-mode. It updates substring filtering to the new interface and do not replace soft newlines with spaces anymore. So now, copy/pasting from a longlines buffer should work as intended. I'm now trying to update the search/query-replace but I don't understand how 'search-spaces-regex' works. It seems that with it I should be able to jump above soft newlines during search, but how ? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-longlines-substring-update.patch >From 1a7eb36393aba16680765d34ae3e4329df7f397e Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 5 Jul 2022 14:38:43 +0200 Subject: [PATCH] [longlines] substring update * lisp/longlines.el (longlines-mode, longlines-encode-string): Update from `buffer-substring-filters' to `filter-buffer-substring-function'. Remove soft newlines in substring. --- lisp/longlines.el | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lisp/longlines.el b/lisp/longlines.el index a6cf93a039..855fbc6e0e 100644 --- a/lisp/longlines.el +++ b/lisp/longlines.el @@ -118,7 +118,6 @@ longlines-mode (add-to-list 'buffer-file-format 'longlines) (add-hook 'change-major-mode-hook #'longlines-mode-off nil t) (add-hook 'before-revert-hook #'longlines-before-revert-hook nil t) - (make-local-variable 'buffer-substring-filters) (make-local-variable 'longlines-auto-wrap) (set (make-local-variable 'isearch-search-fun-function) #'longlines-search-function) @@ -126,7 +125,8 @@ longlines-mode #'longlines-search-forward) (set (make-local-variable 'replace-re-search-function) #'longlines-re-search-forward) - (add-to-list 'buffer-substring-filters 'longlines-encode-string) + (add-function :filter-return (local 'filter-buffer-substring-function) + #'longlines-encode-string) (when longlines-wrap-follows-window-size (let ((dw (if (and (integerp longlines-wrap-follows-window-size) (>= longlines-wrap-follows-window-size 0) @@ -143,7 +143,7 @@ longlines-mode (inhibit-modification-hooks t) (mod (buffer-modified-p)) buffer-file-name buffer-file-truename) - ;; Turning off undo is OK since (spaces + newlines) is + ;; Turning off undo is OK since (separators + newlines) is ;; conserved, except for a corner case in ;; longlines-wrap-lines that we'll never encounter from here (save-restriction @@ -202,7 +202,8 @@ longlines-mode (kill-local-variable 'replace-search-function) (kill-local-variable 'replace-re-search-function) (kill-local-variable 'require-final-newline) - (kill-local-variable 'buffer-substring-filters) + (remove-function (local 'filter-buffer-substring-function) + #'longlines-encode-string) (kill-local-variable 'use-hard-newlines))) (defun longlines-mode-off () @@ -385,15 +386,22 @@ longlines-encode-region end))) (defun longlines-encode-string (string) - "Return a copy of STRING with each soft newline replaced by a space. + "Return a copy of STRING with each soft newline removed. Hard newlines are left intact." - (let* ((str (copy-sequence string)) - (pos (string-search "\n" str))) - (while pos - (if (null (get-text-property pos 'hard str)) - (aset str pos ? )) - (setq pos (string-search "\n" str (1+ pos)))) - str)) + (let ((str (copy-sequence string)) + (start 0) + (result nil)) + (while (setq pos (string-search "\n" str start)) + (unless (= start pos) + (push (substring str start pos) result)) + (when (get-text-property pos 'hard str) + (push (substring str pos (1+ pos)) result)) + (setq start (1+ pos))) + (if (null result) + str + (unless (= start (length str)) + (push (substring str start) result)) + (apply #'concat (nreverse result))))) ;;; Auto wrap -- 2.36.1 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--