help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: delete all whitespace (space) in a region


From: Uwe Brauer
Subject: Re: delete all whitespace (space) in a region
Date: Mon, 13 Nov 2023 17:02:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>> "EB" == Emanuel Berg <incal@dataswamp.org> writes:

> tpeplt wrote:
>> Emacs 28 added the function ‘replace-string-in-region’.
>> 
>> (defun my-delete-all-whitespace-region (beg end)
>> (interactive "r")
>> (save-excursion
>> (replace-string-in-region " " "" beg end)))

> (defun delete-all-whitespace (&optional beg end)
>   (interactive
>     (when (use-region-p)
>       (list (region-beginning) (region-end)) ))
>   (or beg (setq beg (point-min)))
>   (or end (setq end (point-max)))
>   (save-mark-and-excursion
>     (replace-string-in-region " " "" beg end) ))

> A pretty fancy interface to a one-liner function with
> hardcoded data :)

Right, but well I would only use this function region wide never on the
whole buffer. That is why I prefer *(interactive "r")*

-- 
I strongly condemn Hamas heinous atrocities on Israel, especially the 
despicable pogroms.
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]