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: Wed, 06 Jul 2022 09:43:37 +0200 Message-ID: <87tu7ubs9i.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> <87wncrzp19.fsf@elite.giraud> <875ykb34gr.fsf@gnus.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="1941"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: Eli Zaretskii , 56335@debbugs.gnu.org, Manuel Giraud To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 06 09:44:36 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 1o8zi7-0000Hw-As for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 09:44:35 +0200 Original-Received: from localhost ([::1]:52472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8zi5-0002Ya-SA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Jul 2022 03:44:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8zha-0002YS-Kt for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 03:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8zha-0007QI-Bu for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 03:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o8zha-0002RU-8E for bug-gnu-emacs@gnu.org; Wed, 06 Jul 2022 03:44: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: Wed, 06 Jul 2022 07:44: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.16570934249358 (code B ref 56335); Wed, 06 Jul 2022 07:44:02 +0000 Original-Received: (at 56335) by debbugs.gnu.org; 6 Jul 2022 07:43:44 +0000 Original-Received: from localhost ([127.0.0.1]:52149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8zhI-0002Qs-Dp for submit@debbugs.gnu.org; Wed, 06 Jul 2022 03:43:44 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:22868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o8zhE-0002Qe-8x for 56335@debbugs.gnu.org; Wed, 06 Jul 2022 03:43:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=2vfVcj2B2WC20y/b XrU6BLAT05XNQkpKZZnOFLMvknU=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=DE3ZD3qr4I5q+nF8Z/1sHS7svBjqEk70CyXlQu MnOMpXqoo4hwxFBtrWXyJUh1fxB0mzeYYC3vMpNYCq4A8k8gO9PKR+N+Cwh3ViXL+akjNg xTGEMlYZzplRSCsiIUlBW1OJXSOu0XJaSTddOcw29nAvMw4wds6X2YR6y8jq1pzvHwKk98 P2m/osiYUbYYt05nw61VrhCiw8j1oH6fGbfXOSLgbqfGelssmcTPV62Bq1jRDPMoqubhdH toT6f/xNn5oFF3erxRLhjxeKl158olp50o89xcbqhc5wYN0DDQAkWBCo0sNoRyf/6kKD78 kFwcwblPp7XPBuFlLVtdBY+w== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id dd356fec (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 6 Jul 2022 09:43:38 +0200 (CEST) In-Reply-To: <875ykb34gr.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 05 Jul 2022 18:32:36 +0200") 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:236201 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Manuel Giraud writes: > >> 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. > > This leads to > > In longlines-encode-string: > longlines.el:394:18: Warning: assignment to free variable `pos' > longlines.el:395:24: Warning: reference to free variable `pos' Sorry, here is a new version of the patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-longlines-substring-update.patch >From c5739c078834afe85e96da3867c2c702694619be 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..6dc2f61ed9 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 ((start 0) + (result nil) + pos) + (while (setq pos (string-search "\n" string start)) + (unless (= start pos) + (push (substring string start pos) result)) + (when (get-text-property pos 'hard string) + (push (substring string pos (1+ pos)) result)) + (setq start (1+ pos))) + (if (null result) + (copy-sequence string) + (unless (= start (length string)) + (push (substring string start) result)) + (apply #'concat (nreverse result))))) ;;; Auto wrap -- 2.36.1 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--