From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: delete all whitespace (space) in a region Date: Thu, 9 Nov 2023 06:34:39 +0100 Message-ID: References: <878r78jfms.fsf@mat.ucm.es> <874jhwhx9i.fsf@ledu-giraud.fr> <87zfzn4qa2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="M0FJkXalOv8MbqmL" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4201"; 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 Nov 09 06:36:11 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 1r0xi6-0000tW-Lo for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 09 Nov 2023 06:36:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0xgx-0005rO-7v; Thu, 09 Nov 2023 00:34:59 -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 1r0xgv-0005r7-0e for help-gnu-emacs@gnu.org; Thu, 09 Nov 2023 00:34:57 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0xgj-0001cx-QH for help-gnu-emacs@gnu.org; Thu, 09 Nov 2023 00:34:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YiV7whUCH/xLhQtifVIP8wXPJDHC+YQShW2zFo1WJ5w=; b=Y2F+BddUDYzl6y6giesh7TjkpP NRcmskQRlvhH0HxCrpzPSPFEdzrlCthMBzE+CPdpDcj/qcnESSETC4PzxYK14YHg6wA55lt81Nv0i rZReuwMgH/hwA1+4S2P0kcISkedRdzFxW7zJha1xAa18g0d1LZ8xaRY/ux8cpASYe8pEWWR+nYGi4 uQzgp76/nKJRiUZlwp1y7aKWrKbVN+xye0eSdSYnAaAuEDAZUcK58BWA5LwlMR3tuGDHtukrX4nCG d7iapvHr41FoZqaYayWBtFJ6ztgOCJrWSOLI0O7MB+SyY3O+cOEF0SrMBtdh6suCWtbCxntNGvG4U aq9Wz6Fg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1r0xgd-0006ou-Qj for help-gnu-emacs@gnu.org; Thu, 09 Nov 2023 06:34:39 +0100 Content-Disposition: inline In-Reply-To: <87zfzn4qa2.fsf@gmail.com> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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:145468 Archived-At: --M0FJkXalOv8MbqmL Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 08, 2023 at 09:24:53PM -0500, tpeplt wrote: > Manuel Giraud via Users list for the GNU Emacs text editor > writes: > > > > If you don't want to confirm for the replacements, you could instead do > > this: > > > > (defun my-delete-all-whitespace-region (beg end) > > (interactive "r") > > (save-excursion > > (goto-char beg) > > (while (re-search-forward " " end t) > > (replace-match "")))) A small optimisation would be to use the regexp " +", meaning one or more spaces. >=20 > Emacs 28 added the function =E2=80=98replace-string-in-region=E2=80=99. >=20 > (defun my-delete-all-whitespace-region (beg end) > (interactive "r") > (save-excursion > (replace-string-in-region " " "" beg end))) To have this here, you'd have to "replace-regexp-in-region", of course. Cheers --=20 t --M0FJkXalOv8MbqmL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZUxvaQAKCRAFyCz1etHa Ri31AJ4ghJTfCJOUI2kOwunn1blvArtadQCfa81+EHvnHdfPUr68wAzbsDnyemg= =z6Ij -----END PGP SIGNATURE----- --M0FJkXalOv8MbqmL--