From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: comic-book-insult Date: Mon, 9 Sep 2019 10:00:02 +0200 Message-ID: <20190909080001.GE20896@protected.rcdrun.com> References: <86k1aiip6o.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="47114"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 09 10:00:35 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i7EbC-000C64-JI for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Sep 2019 10:00:34 +0200 Original-Received: from localhost ([::1]:52738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7EbB-00055X-Fz for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Sep 2019 04:00:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47686) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7Eap-00050g-8o for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 04:00:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7Eaj-0000Uw-S6 for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 04:00:11 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:42651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7Eaj-0000TS-ID for help-gnu-emacs@gnu.org; Mon, 09 Sep 2019 04:00:05 -0400 Original-Received: from protected.rcdrun.com ([::ffff:31.223.149.103]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000006A562.000000005D760683.00004144; Mon, 09 Sep 2019 01:00:03 -0700 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local id 00000000000CBDCA.000000005D760682.00005851; Mon, 09 Sep 2019 10:00:02 +0200 Content-Disposition: inline In-Reply-To: <86k1aiip6o.fsf@zoho.eu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.170.207.13 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121488 Archived-At: * Emanuel Berg via Users list for the GNU Emacs text editor [2019-09-08 21:06]: > (defun scramble-string (str) > "Randomize the characters of a string." > (interactive "sscramble me: ") > (let*((empty-str "") > (chars (delete empty-str (split-string str empty-str))) > (rand-chars (sort chars (lambda (_ __) (zerop (random 2))))) > (rand-str (mapconcat 'identity rand-chars "")) > ) > rand-str) ) > > (defun comic-book-insult () > (interactive) > (insert (concat (scramble-string "@#$%&") "!") )) > > ;; (comic-book-insult) ; %@&$#! > ;; (comic-book-insult) ; $%#@&! Thanks, now I learned how to scramble words like this below in Emacs. But I have no idea what means (lambda (_ __) (defun scramble-word (word) "Randomize the characters of a string but not first and last" (let* ((first (substring word 0 1)) (length (length word)) (last (substring word (1- length) length)) (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 "")) (word (concat first rand-str last))) word)) (defun scramble-string (string) (let* ((split (split-string string)) (out (with-output-to-string (dolist (word split) (princ (scramble-word word)) (princ " "))))) out)) (defun scramble-region (start end) "Scramble region" (interactive "r") (let* ((s (buffer-substring-no-properties start end)) (replacement (scramble-string s))) (delete-region start end) (insert replacement))) (scramble-string "Hello there, Emacs is very cool piece of software") => "Hlelo theer, Eamcs is vrey cool peice of sfotware " Reference: Why your brain can read jumbled letters: https://www.mnn.com/lifestyle/arts-culture/stories/why-your-brain-can-read-jumbled-letters Emcas is the extenisble, customblezia, slef doucmenintg rael time dipsaly eidtor. Tihs manaul desrcibes how to eidt wtih Emacs and smoe of the wyas to cuostmize it; it crpeoorsnds to GNU Eacms versoin 235.. Jean