From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: avoid narrow-to-region (was: Re: replace-regexp)
Date: Sun, 9 May 2021 10:22:01 +0300 [thread overview]
Message-ID: <YJeNmWUOzRbPgCll@protected.localdomain> (raw)
In-Reply-To: <87bl9ktms2.fsf@zoho.eu>
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-05-09 10:01]:
> BWT, hree is my otehr sftuf, I'm ptrtey srue it all cnfomros
> to modern-day comupter secince tehory of sotring, but Il'l let
> you vrfeiy it jsut to be srue .
>
> https://dataswamp.org/~incal/emacs-init/sort-incal.el
I did not konw taht scrmabling txet is siecnce .
;;;; ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
;;;; SCRAMBLED TEXT FUNCTIONS
;;;; ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
;; Reference:
;; Why your brain can read jumbled letters:
;; https://www.mnn.com/lifestyle/arts-culture/stories/why-your-brain-can-read-jumbled-letters
(defun scramble-word (word)
"Randoimze the cahcraters of a sritng but not fisrt and lsat "
(let* ((first (substring word 0 1))
(length (length word))
(last (substring word (1- length) length)))
(if (<= length 3)
word
(if (= length 4)
(concat first (substring word 2 3) (substring word 1 2) last)
(let* ((middle (substring word 1 (1- length)))
(rnd (length middle))
(empty-str "")
(chars (delete empty-str (split-string middle empty-str)))
(rand-chars (sort chars (lambda (_ __) (zerop (random rnd)))))
(rand-str (mapconcat 'identity rand-chars ""))
(new-word (concat first rand-str last)))
new-word)))))
(defun scramble-string (string)
"Returns string of scrambled words"
(let* ((split (split-string string)))
(with-output-to-string
(while split
(princ (scramble-word (pop split)))
(princ " ")))))
(defun scramble-region (start end)
"Scramble mkared rgeoin of txet "
(interactive "r")
(if (region-active-p)
(let* ((s (buffer-substring-no-properties start end))
(replacement (scramble-string s)))
(delete-region start end)
(insert replacement))
(message "Tehre was no aivcte reigon to scmrable ")))
(defun randomize-string (string)
"Randomize the characters of a string"
(let* ((rnd (length string))
(empty-str "")
(chars (delete empty-str (split-string string empty-str)))
(rand-chars (sort chars (lambda (_ __) (zerop (random rnd)))))
(rand-str (mapconcat 'identity rand-chars "")))
rand-str))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/
next prev parent reply other threads:[~2021-05-09 7:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 23:06 replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-07 6:54 ` replace-regexp Tassilo Horn
2021-05-07 18:28 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 0:02 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 0:16 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 5:38 ` replace-regexp Yuri Khan
2021-05-08 13:53 ` replace-regexp Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 18:41 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 18:50 ` replace-regexp Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 21:59 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 22:03 ` replace-regexp Tassilo Horn
2021-05-08 22:25 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 22:54 ` [External] : replace-regexp Drew Adams
2021-05-09 2:48 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 18:46 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 21:10 ` replace-regexp Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 21:54 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 23:11 ` replace-regexp Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 23:16 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 23:46 ` replace-regexp Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-08 23:51 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 7:38 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-08 22:59 ` avoid narrow-to-region (was: Re: replace-regexp) Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 5:48 ` Yuri Khan
2021-05-09 6:09 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 6:34 ` Yuri Khan
2021-05-09 6:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 7:22 ` Jean Louis [this message]
2021-05-09 7:40 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 10:06 ` Yuri Khan
2021-05-09 10:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 12:27 ` Yuri Khan
2021-05-09 12:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 13:14 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 14:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-09 15:13 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-21 17:35 ` same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)) Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-21 20:12 ` Jean Louis
2021-05-21 20:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-05-07 8:02 ` replace-regexp Jean Louis
2021-05-07 18:29 ` replace-regexp Emanuel Berg via Users list for the GNU Emacs text editor
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YJeNmWUOzRbPgCll@protected.localdomain \
--to=bugs@gnu.support \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).