From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 24 05:13:25 2021 Received: (at submit) by debbugs.gnu.org; 24 Dec 2021 10:13:25 +0000 Received: from localhost ([127.0.0.1]:35719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0hZl-0003f8-0u for submit@debbugs.gnu.org; Fri, 24 Dec 2021 05:13:25 -0500 Received: from lists.gnu.org ([209.51.188.17]:42820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n0hZi-0003f0-GH for submit@debbugs.gnu.org; Fri, 24 Dec 2021 05:13:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0hZi-0007Os-CL for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2021 05:13:22 -0500 Received: from st43p00im-zteg10073501.me.com ([17.58.63.180]:55678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n0hZg-00083n-6M for bug-gnu-emacs@gnu.org; Fri, 24 Dec 2021 05:13:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1640340799; bh=OFk8I2FAVrthXGnJdsrnZTGrqpYjOeajX0Cr1EcpxSI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=sD0uMXF7gB/hUrhFbsxoT0LMlPT24YQ1Cy+jyimWXjF73px6gg79jEEpwZjVydU11 H8hr7r7ImW9K4ktfUM8Nvk9/zFkbObyPhNN0CCzNPQyzzljlzcSaOFqVgspphgk1zX e+pyRzeSyWzlIe/CkfCv8LaeKdNSsz/XFbgP/Yyg1LcXwRh/YzMb34oKa5WqcXuvv5 GeW6m6s6I4PrGh0TgV0T3zFV8Vsk8zUdnjK/n3SxsyNGdVFA38nMAYUFxg0aAA5bYn T4xxxw8jAzOijZyY6R1Qujd5JfP2ZUJwceJM+YU0bpM0PXN3Nl+EY3tTON/SNE+y1h B7Z4AlCixMKjw== Received: from Workstation.local (78-141-116-131.dynamic.orange.sk [78.141.116.131]) by st43p00im-zteg10073501.me.com (Postfix) with ESMTPSA id AA4F83600FE for ; Fri, 24 Dec 2021 10:13:18 +0000 (UTC) From: =?utf-8?Q?Rudolf_Adamkovi=C4=8D?= To: bug-gnu-emacs@gnu.org Subject: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region Date: Fri, 24 Dec 2021 11:13:15 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.425,18.0.790,17.0.607.475.0000000_definitions?= =?UTF-8?Q?=3D2021-12-24=5F02:2021-12-24=5F01,2021-12-24=5F02,2020-04-07?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2112240050 Received-SPF: pass client-ip=17.58.63.180; envelope-from=salutis@me.com; helo=st43p00im-zteg10073501.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) I often copy some text from elsewhere to Emacs, and I would like to re-punctuate it. As a user, I would expect it to work as follows: (1) mark a position to form a region and (2) call 'repunctuate-sentences'. 'repunctuate-sentences' documentation says: > Put two spaces at the end of sentences from point to the end of > buffer. It works using query-replace-regexp. =E2=80=A6 and 'query-replace-regexp' documentation says: > In Transient Mark mode, if the mark is active, operate on the contents > of the region. Otherwise, operate from point to the end of the > buffer's accessible portion. Both functions work as documented, but as a user, I often need to 'repunctuate-sentences' in a region. Could we improve 'repunctuate-sentences' to work such that in Transient Mark mode and with mark active, it re-punctuates the contents of the region? Thank you. Rudy Thank you! In GNU Emacs 29.0.50 (build 5, x86_64-apple-darwin21.2.0, NS appkit-2113.20= Version 12.1 (Build 21C52)) of 2021-12-23 built on Workstation.local Repository revision: 2fa7feca336dd16c57ffef072e0f0da6fffe4c5f Repository branch: master Windowing system distributor 'Apple', version 10.3.2113 System Description: macOS 12.1 Configured using: 'configure --with-json --with-xwidgets --with-native-compilation' Configured features: ACL DBUS GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM XWIDGETS ZLIB Important settings: value of $LC_ALL: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Helpful Minor modes in effect: emms-mode-line-mode: t telega-root-auto-fill-mode: t telega-active-locations-mode: t telega-patrons-mode: t telega-mode-line-mode: t TeX-PDF-mode: t global-git-commit-mode: t magit-auto-revert-mode: t shell-dirtrack-mode: t corfu-global-mode: t corfu-mode: t vertico-mode: t marginalia-mode: t global-diff-hl-mode: t yas-global-mode: t yas-minor-mode: t global-hl-todo-mode: t global-subword-mode: t subword-mode: t save-place-mode: t global-auto-revert-mode: t delete-selection-mode: t savehist-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /Users/salutis/.emacs.d/elpa/transient-20211208.1819/transient hides /Users= /salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/transient /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/emacs-l= isp/eieio-compat hides /Users/salutis/src/emacs/nextstep/Emacs.app/Contents= /Resources/lisp/obsolete/eieio-compat Features: (shadow bbdb-message mail-extr view helpful trace edebug info-look help-fns radix-tree elisp-refs tramp-cmds vterm tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat term ehelp vterm-module term/xterm xterm eglot array jsonrpc ert debug backtrace xref pcase mhtml-mode css-mode smie js sgml-mode facemenu org-duration org-pomodoro alert log4e gntp org-timer hl-line emms-mode-line network-stream nsm emms-player-mpd emms-url tq emms-player-simple emms-browser sort emms-playlist-sort emms-last-played emms-volume emms-volume-sndioctl emms-volume-mixerctl emms-volume-pulse emms-volume-amixer emms-playlist-mode emms-source-playlist emms-source-file locate emms-cache emms-info emms-later-do emms emms-compat ox-md ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table ox-ascii ox-publish ox citar-org oc-csl citeproc citeproc-itemgetters citeproc-biblatex citeproc-bibtex citeproc-cite citeproc-subbibs citeproc-sort citeproc-name citeproc-formatters citeproc-number rst citeproc-proc citeproc-disamb citeproc-itemdata citeproc-generic-elements citeproc-macro citeproc-choose citeproc-date citeproc-context citeproc-prange citeproc-style citeproc-locale citeproc-term f citeproc-rt citeproc-lib citeproc-s let-alist queue org-id org-refile citar s parsebib citar-file misearch multi-isearch telega-obsolete telega telega-tdlib-events telega-webpage visual-fill-column telega-root telega-info telega-chat telega-modes telega-company telega-user telega-notifications notifications telega-voip telega-msg telega-tme telega-sticker telega-i18n telega-vvnote bindat telega-ffplay telega-media telega-sort telega-filter telega-ins telega-folders telega-inline telega-tdlib telega-util rainbow-identifiers dired-aux color telega-server telega-core telega-customize cus-edit cus-start cus-load emacsbug sendmail goto-addr bug-reference preview tex-buf font-latex latex latex-flymake tex-ispell tex-style tex texmathp tex-mode flymake-proc flymake compile image-file image-converter disp-table magit-extras char-fold face-remap magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff git-commit log-edit add-log magit-core magit-autorevert magit-margin magit-transient magit-process with-editor shell server magit-mode transient magit-git magit-section magit-utils crm dash orderless cursor-sensor vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs project consult-vertico consult recentf tree-widget paredit edmacro kmacro bbdb bbdb-site timezone modus-vivendi-theme modus-operandi-theme modus-themes corfu vertico marginalia pdf-loader diff-hl log-view pcvs-util vc-dir ewoc vc diminish yasnippet hl-todo finder-inf fortune display-fill-column-indicator ob-sqlite ob-sql ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ob-R org-clock cl ls-lisp cap-words superword subword saveplace autorevert filenotify comp comp-cstr warnings delsel savehist elfeed-link elfeed-show elfeed-search elfeed-csv elfeed elfeed-curl elfeed-log xml-query bookmark pp elfeed-db elfeed-lib vc-git diff-mode vc-dispatcher org-element avl-tree generator ol-eww eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr pixel-fill kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message yank-media rmc puny rfc822 mml mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util text-property-search mail-utils mm-util mail-prsvr wid-edit ol-docview doc-view jka-compr image-mode exif dired dired-loaddefs ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi cl-extra help-mode org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601 time-date ol rx org-keys oc org-compat advice org-macs org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs tex-site info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads xwidget-internal dbusbind kqueue cocoa ns lcms2 multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 1273795 147391) (symbols 48 61371 3) (strings 32 344437 34383) (string-bytes 1 11812916) (vectors 16 121413) (vector-slots 8 2818587 91957) (floats 8 11575 522) (intervals 56 13645 8634) (buffers 992 47)) --=20 "Programming reliably --- must be an activity of an undeniably mathematical= nature [=E2=80=A6] You see, mathematics is about thinking, and doing mathe= matics is always trying to think as well as possible." -- Edsger W. Dijkstr= a (1981) Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 25 14:07:08 2021 Received: (at 52769) by debbugs.gnu.org; 25 Dec 2021 19:07:08 +0000 Received: from localhost ([127.0.0.1]:39863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1CNn-0002U4-RL for submit@debbugs.gnu.org; Sat, 25 Dec 2021 14:07:08 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:42785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n1CNl-0002Ta-L2 for 52769@debbugs.gnu.org; Sat, 25 Dec 2021 14:07:06 -0500 Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 43F70FF807; Sat, 25 Dec 2021 19:06:57 +0000 (UTC) From: Juri Linkov To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Subject: Re: bug#52769: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region Organization: LINKOV.NET References: Date: Sat, 25 Dec 2021 21:04:58 +0200 In-Reply-To: ("Rudolf =?utf-8?Q?Adamkovi=C4=8D?= via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\""'s message of "Fri, 24 Dec 2021 11:13:15 +0100") Message-ID: <86czlkld45.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 52769 Cc: 52769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Could we improve 'repunctuate-sentences' to work such that in Transient > Mark mode and with mark active, it re-punctuates the contents of the > region? Thanks for the request. Until now, I used a custom command 'canonically-double-space-region' attached below, activated by advice when the command 'fill-paragraph' (M-q) is called on the region. But its heuristics is too unreliable to detect the places where two spaces are needed. It often misidentifies an abbreviation as the end of the sentence. So using 'query-replace' would be more reliably to make the decision for every punctuation. When I tried 'repunctuate-sentences', it stunned by its inefficiency: it requires a confirmation even when there are already two spaces at the end of the sentence! Why does it do this? PS: #+begin_src emacs-lisp (defun canonically-double-space-region (beg end) (interactive "*r") (canonically-space-region beg end) (unless (markerp end) (setq end (copy-marker end t))) (let* ((sentence-end-double-space nil) ; to get right regexp below (end-spc-re (rx (>= 5 (not (in ".?!"))) (regexp (sentence-end))))) (save-excursion (goto-char beg) (while (and (< (point) end) (re-search-forward end-spc-re end t)) (unless (or (>= (point) end) (looking-back "[[:space:]]\\{2\\}\\|\n" 3)) (insert " ")))))) (advice-add 'fill-paragraph :before (lambda (&rest _args) (when (use-region-p) (canonically-double-space-region (region-beginning) (region-end)))) '((name . fill-paragraph-double-space))) #+end_src From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 14:20:30 2021 Received: (at 52769) by debbugs.gnu.org; 28 Dec 2021 19:20:30 +0000 Received: from localhost ([127.0.0.1]:47440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2I1N-00008J-RV for submit@debbugs.gnu.org; Tue, 28 Dec 2021 14:20:29 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:42843) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2I1M-000083-5w; Tue, 28 Dec 2021 14:20:28 -0500 Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id D622D240004; Tue, 28 Dec 2021 19:20:20 +0000 (UTC) From: Juri Linkov To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Subject: Re: bug#52769: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region Organization: LINKOV.NET References: Date: Tue, 28 Dec 2021 21:20:00 +0200 In-Reply-To: ("Rudolf =?utf-8?Q?Adamkovi=C4=8D?= via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\""'s message of "Fri, 24 Dec 2021 11:13:15 +0100") Message-ID: <861r1wpme7.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 52769 Cc: 52769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 52769 29.0.50 thanks > Could we improve 'repunctuate-sentences' to work such that in Transient > Mark mode and with mark active, it re-punctuates the contents of the > region? Now this is implemented in master. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 14:31:58 2021 Received: (at 52769) by debbugs.gnu.org; 28 Dec 2021 19:31:58 +0000 Received: from localhost ([127.0.0.1]:47455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ICU-0001zy-9J for submit@debbugs.gnu.org; Tue, 28 Dec 2021 14:31:58 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:58047) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ICQ-0001tD-W2 for 52769@debbugs.gnu.org; Tue, 28 Dec 2021 14:31:56 -0500 Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 98C8DE0003; Tue, 28 Dec 2021 19:31:46 +0000 (UTC) From: Juri Linkov To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Subject: Re: bug#52769: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region Organization: LINKOV.NET References: <86czlkld45.fsf@mail.linkov.net> Date: Tue, 28 Dec 2021 21:28:21 +0200 In-Reply-To: <86czlkld45.fsf@mail.linkov.net> (Juri Linkov's message of "Sat, 25 Dec 2021 21:04:58 +0200") Message-ID: <86v8z8o7fu.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 52769 Cc: 52769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > When I tried 'repunctuate-sentences', it stunned by its inefficiency: > it requires a confirmation even when there are already two spaces > at the end of the sentence! Why does it do this? If no one has a better idea for a simpler implementation, then this patch fixes the problem by skipping the sentences that already have two spaces at the end: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=repunctuate-sentences-filter.patch diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 98362b8579..0b09895339 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -494,7 +494,14 @@ repunctuate-sentences (if no-query (while (re-search-forward regexp nil t) (replace-match to-string)) - (query-replace-regexp regexp to-string nil start end)))) + (let ((regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\)\\( +\\)") + (space-filter (lambda (_start _end) + (not (length= (match-string 4) 2))))) + (unwind-protect + (progn + (add-function :after-while isearch-filter-predicate space-filter) + (query-replace-regexp regexp to-string nil start end)) + (remove-function isearch-filter-predicate space-filter)))))) (defun backward-sentence (&optional arg) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 15:21:44 2021 Received: (at 52769) by debbugs.gnu.org; 28 Dec 2021 20:21:44 +0000 Received: from localhost ([127.0.0.1]:47520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2Iye-0003sk-Ct for submit@debbugs.gnu.org; Tue, 28 Dec 2021 15:21:44 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:49023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2Iyc-0003sU-2d for 52769@debbugs.gnu.org; Tue, 28 Dec 2021 15:21:43 -0500 Received: (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 718A420005; Tue, 28 Dec 2021 20:21:34 +0000 (UTC) From: Juri Linkov To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Subject: Re: bug#52769: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region Organization: LINKOV.NET References: <86czlkld45.fsf@mail.linkov.net> <86v8z8o7fu.fsf@mail.linkov.net> Date: Tue, 28 Dec 2021 22:18:12 +0200 In-Reply-To: <86v8z8o7fu.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 28 Dec 2021 21:28:21 +0200") Message-ID: <86k0foo54r.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 52769 Cc: 52769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > If no one has a better idea for a simpler implementation, > then this patch fixes the problem by skipping the sentences > that already have two spaces at the end: The filter will also allow redefining it with own logic such as skipping known abbreviations that don't require two spaces, i.e., e.g.: (defun repunctuate-sentences-filter (_start _end) (not (or (length= (match-string 4) 2) (looking-back (rx (or "i.e." "e.g.") " ") 5)))) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=repunctuate-sentences-filter-2.patch diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index acb26fd1c1..580f3617d0 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -479,6 +479,9 @@ forward-sentence (setq arg (1- arg))) (constrain-to-field nil opoint t))) +(defun repunctuate-sentences-filter (_start _end) + (not (length= (match-string 4) 2))) + (defun repunctuate-sentences (&optional no-query start end) "Put two spaces at the end of sentences from point to the end of buffer. It works using `query-replace-regexp'. In Transient Mark mode, @@ -489,14 +492,21 @@ repunctuate-sentences (interactive (list nil (if (use-region-p) (region-beginning)) (if (use-region-p) (region-end)))) - (let ((regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\) +") - (to-string "\\1\\2\\3 ")) - (if no-query - (progn - (when start (goto-char start)) - (while (re-search-forward regexp end t) - (replace-match to-string))) - (query-replace-regexp regexp to-string nil start end)))) + (if no-query + (let ((regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\) +") + (to-string "\\1\\2\\3 ")) + (when start (goto-char start)) + (while (re-search-forward regexp end t) + (replace-match to-string))) + (let ((regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\)\\( +\\)") + (to-string "\\1\\2\\3 ")) + (unwind-protect + (progn + (add-function :after-while isearch-filter-predicate + #'repunctuate-sentences-filter) + (query-replace-regexp regexp to-string nil start end)) + (remove-function isearch-filter-predicate + #'repunctuate-sentences-filter))))) (defun backward-sentence (&optional arg) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 28 16:32:10 2021 Received: (at 52769) by debbugs.gnu.org; 28 Dec 2021 21:32:10 +0000 Received: from localhost ([127.0.0.1]:47617 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2K4o-0005fK-B7 for submit@debbugs.gnu.org; Tue, 28 Dec 2021 16:32:10 -0500 Received: from st43p00im-zteg10073401.me.com ([17.58.63.181]:58934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2K4m-0005f8-UW for 52769@debbugs.gnu.org; Tue, 28 Dec 2021 16:32:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1640727123; bh=/u0+NrC+HKQjtdC/W0QOZJbOaO8tfjDi6xykgHw3Srk=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=M0F/xu9V3nWTFJWKAZQXJzn6uNpxbAKPR9ePI8355EdmYJXhTdJxO+ZOx1cEP9+Am CaPliZsMHEFlbV6eF2byMeTy0NjOedKmmid34K7LzbxnbmjaNcMMzfTLRIgdI3Kmd4 uTMVDQFxdqtH0DuT/bzBuwNK60nUhUWtV0TF71k2kAdj3y4UYyw0ZA8meFIdT2CkZp AfMsxi80q9TBx9r0vRVl6lQ1PVILIg1tTb+iQydMu19KCykGxZyASJ574sC17T1v0c Ren4XtYOv/jO4dfoeOWnj7A0JyS6QxVZ/lE6CseP5PzcMGoh/Jm53mhtVn7JrkfuS/ OomfVor7PTksg== Received: from Workstation.local (78-141-116-131.dynamic.orange.sk [78.141.116.131]) by st43p00im-zteg10073401.me.com (Postfix) with ESMTPSA id D1EC3A81575; Tue, 28 Dec 2021 21:32:02 +0000 (UTC) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: Juri Linkov Subject: Re: bug#52769: 29.0.50; [FEATURE REQUEST] repunctuate-sentences in region In-Reply-To: <861r1wpme7.fsf@mail.linkov.net> References: <861r1wpme7.fsf@mail.linkov.net> Date: Tue, 28 Dec 2021 22:31:54 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.790 definitions=2021-12-28_12:2021-12-28, 2021-12-28 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=680 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2112280094 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 52769 Cc: 52769@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Juri Linkov writes: > Now this is implemented in master. I have just recompiled Emacs, and everything works as expected. This patch will make my life easier. Thank you! Rudy --=20 "Programming reliably --- must be an activity of an undeniably mathematical nature [=E2=80=A6] You see, mathematics is about thinking, and doing mathematics is always trying to think as well as possible." -- Edsger W. Dijkstra (1981) Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia From unknown Sat Jun 21 05:16:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 26 Jan 2022 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator