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

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

Re: [SOLVED]


From: Emanuel Berg
Subject: Re: [SOLVED]
Date: Wed, 06 Oct 2021 22:58:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Uwe Brauer wrote:

> Thanks but the file edit, is missing at least not included
> in my emacs

You are right, "must" fix the names, try these and only these:

(defun region-to-string ()
  "Return the region text as a string. Replace newlines with spaces."
  (when (use-region-p)
    (let ((beg (region-beginning))
          (end (region-end) ))
    (let ((text (buffer-substring-no-properties beg end)))
      (replace-regexp-in-string "\n" " " text) ))))

(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 (_ __) (zerop (random 2))))) )
        (delete-region beg end)
        (dolist (c rand-chars)
          (insert c) )))))

(require 'seq)
(defun scramble-string (str)
  "Randomize the characters of a string."
  (interactive "sscramble me: ")
  (let ((rand-str (seq-sort (lambda (_ __) (zerop (random 2))) str )))
    (if (called-interactively-p 'any)
        (message rand-str)
      rand-str) ))

(defun comic-book-insult ()
  (interactive)
  (insert (concat (scramble-string "@#$%&") "!")) )

;; (comic-book-insult) ; @#$%&!
;; (comic-book-insult) ; $&#@%!

;; (scramble-string "Hello there, Emacs is very cool piece of software")
;; "aye eposrr lvre olsec,ewfico ceti ftomH hseoa l E"

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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