all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasenwood@zoho.eu>
To: help-gnu-emacs@gnu.org
Subject: Re: Generate random char (and string) from unicode category (e.g: letter)
Date: Thu, 06 Dec 2018 15:29:58 +0100	[thread overview]
Message-ID: <86lg52wwwp.fsf@zoho.eu> (raw)
In-Reply-To: 87r2eu3gzw.fsf@bsb.me.uk

Here [1] is a little something that can be
interesting, who knows?

(defun scramble (beg end)
  "Shuffle chars in region from BEG to END."
  (interactive "r")
  (when (use-region-p)
    (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) )))))

[1] http://user.it.uu.se/~embe8573/emacs-init/sort-my.el

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


  reply	other threads:[~2018-12-06 14:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5272.1544093503.1284.help-gnu-emacs@gnu.org>
2018-12-06 13:46 ` Generate random char (and string) from unicode category (e.g: letter) Ben Bacarisse
2018-12-06 14:29   ` Emanuel Berg [this message]
2018-12-06 10:44 Alexandre Garreau
2018-12-06 11:24 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86lg52wwwp.fsf@zoho.eu \
    --to=moasenwood@zoho.eu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.