emacs-orgmode
[Top][All Lists]
Advanced

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

[SOLVED] (was: how to randomize (scample) regions in a an org buffer)


From: Uwe Brauer
Subject: [SOLVED] (was: how to randomize (scample) regions in a an org buffer)
Date: Wed, 06 Oct 2021 18:37:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:

> Hi

> I need to replace private information in my org files, but only region wide.

> I found 
> https://www.reddit.com/r/emacs/comments/6pc0ts/sanitize_buffer_by_replacing_words_with_random/

> Where two such functions are discussed, one is even for org files,
> however only buffer wide and the code looks rather complicated to me.

No it was actually quite simple:

(defun randomise-region ()
  "Like `ap/replace-words-randomly', but only replace inside region if it is 
active.
If the region is not active, replace from point to the end of the
buffer.  The region is never considered active outside
`transient-mark-mode'. "
  (interactive)
  (if (or (and (boundp 'zmacs-region-active-p) zmacs-region-active-p)
          (and (boundp 'transient-mark-mode) transient-mark-mode mark-active))
      (save-restriction
        (save-excursion
          (narrow-to-region (point) (mark))
          (goto-char (point-min))
          (ap/replace-words-randomly)))
    (ap/replace-words-randomly)))


Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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