emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: [SOLVED] (was: how to randomize (scample) regions in a an org buffer)
Date: Wed, 06 Oct 2021 18:37:03 +0200	[thread overview]
Message-ID: <87lf369kk0.fsf@mat.ucm.es> (raw)
In-Reply-To: 87czoib16c.fsf@mat.ucm.es

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

>>> "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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

      reply	other threads:[~2021-10-06 16:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 15:52 how to randomize (scample) regions in a an org buffer Uwe Brauer
2021-10-06 16:37 ` Uwe Brauer [this message]

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87lf369kk0.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@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 public inbox

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

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).