[Top][All Lists]

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

Re: Randomly capitalise letters

From: Johnny
Subject: Re: Randomly capitalise letters
Date: Fri, 23 Nov 2012 00:20:39 +0000
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (gnu/linux)

"Pascal J. Bourguignon" <> writes:

> Johnny <> writes:
>> Hi all,
>> I am looking for a way to randomly capitalise letters in a word or a
>> region, but haven't found anything in the manual or online (someone must
>> have had this odd idea before I am sure!). Any help on how to achieve
>> this would be great! For clarity, I'd like to AchiEVe soMeTHiNg LIke
>> thIs. 
> That's not a library command, that's for sure, but it's easy to write
> it.  You can learn how to configure emacs to do this kind of things by
> reading:
>   An Introduction to Programming in Emacs Lisp
>  or  M-: (info 
> "(eintr)Top") RET
>   (for non programmers)
>   Emacs Lisp Manual
>  or  M-: (info 
> "(elisp)Top") RET
>   Emacs Manual
>   or  M-: (info "(emacs)Top") RET
> For example, you could write:
> (defun capitalize-randomly (start end)
>    (interactive "r")
>    (goto-char start)
>    (while (< (point) end)
>      (let ((ch (char-after (point))))
>        (delete-region (point) (1+ (point)))
>        (insert (format "%c" (if (zerop (random 2))
>                                (upcase  ch)
>                                (downcase ch)))))))
> So  with M-x capitalize-randomly RET you can get something like:
>> I Am LOOKIng FOr A way TO rAnDOMLy cAPiTalISe lettErS In A woRd or A
>> rEGIoN, BUT HaVen't fOuND anYTHiNG IN THe mANUal oR ONlINE (SomEoNe MuSt
>> HaVe HaD tHIs OdD iDea bEFOrE I Am sure!). AnY HElp ON hOW To AcHIevE
>> ThiS wOuLD be greAt! foR CLaRIty, i'd lIKE tO acHiEve sOmeTHiNg lIKE
>> ThIs. 

Thanks Pascal, I will check out the links to try to learn some lisp,
it's long overdue!

All the best,

reply via email to

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