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

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

scramble region


From: Emanuel Berg
Subject: scramble region
Date: Sun, 26 Nov 2017 10:53:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

The other day I made some "ASCII art" (yuk,
that word) to help organize some work on the
wall of a building, mainly keeping track of what
parts are new and how many times they have been
painted. The reason I give this lengthy
explanation is that otherwise you might think
I made this drawing as an excuse not to do
actual work but instead fiddle with Emacs all
night long. But that isn't true at all!

Aaanyway, here is the drawing:

    http://user.it.uu.se/~embe8573/moasen/big-house-back.txt

When I got to the ground, I thought it could be
cool with a function to randomize it after
putting some fitting chars there in equal
shares. Check it out:

    (defun scramble (beg end)
      "Shuffle chars in region from BEG to END."
      (interactive "r")
      (save-excursion
        (let*((str        (region-to-string))
              (chars      (delete "" (split-string str "")))
              (rand-chars (sort chars (lambda (a b) (zerop (random 2))))) )
          (delete-region beg end)
          (dolist (c rand-chars)
            (insert c) ))))

How does it look?

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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