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

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

Re: Emacs Function to add dashes to leading spaces in a Selected Region


From: Stephen Berman
Subject: Re: Emacs Function to add dashes to leading spaces in a Selected Region
Date: Fri, 30 Oct 2020 01:12:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Fri, 30 Oct 2020 00:34:16 +0100 Christopher Dimech <dimech@gmx.com> wrote:

> I need an Emacs Function to add dashes to leading spaces in a Selected Region.
> Require help to do this thing.

(defun space-to-dash (beg end)
  "Replace spaces by dashes in region."
  (interactive "r")
  (goto-char beg)
  (while (< (point) end)
    (when (looking-at "^ +")
      (let ((rep (make-string (length (match-string 0)) ?-)))
        (replace-match rep)))
    (forward-line)))

Steve Berman



reply via email to

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