Parrot Mode - Viva la parrot revolution!
We developers are an entitled bunch. Since the times of the Romans, programmers have demanded amenities such as bread and circuses, water slides, and multiple cursors. In fact, people of my generation seem to have a perverse desire to see poptart-clad kittens in their text editors. Most recently, I have heard loud and angry demands for parrots wearing science goggles.
Unrealistic? Maybe, but it’s 2018, and therefore parrots will now rotate on the screen using smooth circular motions, like those seen in kung fu.
Polly want a word rotated? Now you can! Just use
parrot-rotate-next-word-at-point. With the bird, a word. See the screen capture below, because a gif is worth a thousand pngs, or whatever.
Parrot is available on MELPA. You can install it with:
M-x package-install parrot
If you use use-package:
(use-package parrot :config (parrot-mode))
Or the old-fashioned way:
(add-to-list 'load-path "/path/to/parrot-dir/") (require 'parrot) ;; To see the party parrot in the modeline, turn on parrot mode: (parrot-mode)
Rotation function keybindings:
;; for vanilla emacs (global-set-key (kbd "C-c p") 'parrot-rotate-prev-word-at-point) (global-set-key (kbd "C-c n") 'parrot-rotate-next-word-at-point) ;; for evil users (define-key evil-normal-state-map (kbd "[r") 'parrot-rotate-prev-word-at-point) (define-key evil-normal-state-map (kbd "]r") 'parrot-rotate-next-word-at-point)
To get parrot working with spacemacs, you need to apply a few changes from this fork of spaceline to your
~/.emacs.d/elpa/2x.x/develop/spaceline-xxx/spaceline-(segments|config).el files. Adjust the spaceline directory path accordingly if you are not using the develop branch.
parrot-rotate-prev-word-at-point to rotate words at point. If a match is not found under the cursor, parrot will hunt for the nearest match in the current whitespace-delimited word and rotate it.
parrot uses a dictionary list that defines word rotations. You can override the default by setting
parrot-rotate-dict in your init file. A sample one is provided below:
(setq parrot-rotate-dict '( (:rot ("alpha" "beta") :caps t :lower nil) ;; => rotations are "Alpha" "Beta" (:rot ("snek" "snake" "stawp")) ;; => rotations are "snek" "snake" "stawp" (:rot ("yes" "no") :caps t :upcase t) ;; => rotations are "yes" "no", "Yes" "No", "YES" "NO" (:rot ("&" "|")) ;; => rotations are "&" "|" ;; default dictionary starts here ('v') (:rot ("begin" "end") :caps t :upcase t) (:rot ("enable" "disable") :caps t :upcase t) (:rot ("enter" "exit") :caps t :upcase t) (:rot ("forward" "backward") :caps t :upcase t) (:rot ("front" "rear" "back") :caps t :upcase t) (:rot ("get" "set") :caps t :upcase t) (:rot ("high" "low") :caps t :upcase t) (:rot ("in" "out") :caps t :upcase t) (:rot ("left" "right") :caps t :upcase t) (:rot ("min" "max") :caps t :upcase t) (:rot ("on" "off") :caps t :upcase t) (:rot ("prev" "next")) (:rot ("start" "stop") :caps t :upcase t) (:rot ("true" "false") :caps t :upcase t) (:rot ("&&" "||")) (:rot ("==" "!=")) (:rot ("." "->")) (:rot ("if" "else" "elif")) (:rot ("ifdef" "ifndef")) (:rot ("int8_t" "int16_t" "int32_t" "int64_t")) (:rot ("uint8_t" "uint16_t" "uint32_t" "uint64_t")) (:rot ("1" "2" "3" "4" "5" "6" "7" "8" "9" "10")) (:rot ("1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th" "9th" "10th")) ))
The following labels are provided for defining rotations in a dictionary entry:
:upcase twill add UPPER CASE rotations
:caps twill add Capitalized rotations
:lower nilwill exclude lowercase rotations
- If no labels are provided, the word list will default to lowercase rotations
- Defining a word list for which there are no rotations will result in an error, e.g.
(:rot ("yes" "no") :lower nil).
You can also append to the default dictionary:
(dolist (entry '((:rot ("hakuna" "matata")) (:rot ("peeple" "sheeple")))) (add-to-list 'parrot-rotate-dict entry))
By default, after a rotation is performed, the selected parrot in the modeline will start rotating. You may select your desired parrot interactively with
M-x parrot-set-parrot-type or in your init file using:
Like the wonders of the ancient world, parrot comes in 7 original flavors:
Clicking on the parrot will cause it to rotate, but for mouse-less operation, it is recommended that you bind
(parrot-start-animation) to a easily reachable hotkey so you can command your parrot to rotate at will.
parrot-animation-frame-interval- seconds between animation frames; can be a decimal number.
parrot-minimum-window-width- minimum width of the window, below which party parrot mode will be disabled.
tto enable parrot animation,
nilfor a static image.
parrot-spaces-before- number of spaces of padding before the parrot.
parrot-spaces-after- number of spaces of padding after the parrot.
parrot-num-rotations- number of times the parrot will cycle through its gif.
tto rotate words that aren’t directly under the cursor.
tto jump to the word rotated if it isn’t under the cursor.
tto animate the party parrot after rotating a word.
tto highlight a word after rotating.
parrot-rotate-start-char-invalid-regexp- regexp used to determine if parrot shouldn’t start a rotation.
parrot-rotate-start-bound-regexp- regexp used to find the start bound to search for rotations.
parrot-rotate-end-bound-regexp- regexp used to find the end bound to search for rotations.
Is parrot not rotating as much as you want it to? To truly become a parrot provocateur, you can make parrot rotate for many divers reasons by adding
parrot-start-animation to various hooks.
For example, if you want the parrot to animate whenever you receive mail in mu4e, you can try:
(add-hook 'mu4e-index-updated-hook #'parrot-start-animation)
You can also add functions to
parrot-click-hook so they will run whenever you click on the parrot.
(add-hook 'parrot-click-hook 'flyspell-buffer)
Want parrot to rotate forever? Set
parrot-num-rotations to nil to get perfectly perpetual parrot.
(setq parrot-num-rotations nil)
Parrot is integration-tested with ecukes
This is my first emacs package, and as such, I’m happy to receive comments or suggestions about elisp coding, feature requests, or contributions.
Because of the amount of raw lisp being converted to kinetic energy, using parrot to rotate may sink as much power as the equivalent poptart. dp12 is not responsible for any seizures or bird-like dance moves that may occur due to this package.
All parrots including the gifs in this README (with the exception of emacs parrot) were taken from @jmhobbs Cult of the Party Parrot site. Thanks to @mermop (default), @kyprifog (confused), @shiruken (science), @vaicine (nyan), @youngcba3 (rotating), @zeftilldeath (thumbsup parrot) for their respective parrots, and of course @jmhobbs for compiling them.
Thanks to @francoislg for Party Parrot as a Service, with which I created the emacs parrot.
Thanks to Aaron Hawley, from whom I borrowed a good deal of my rotation code. You can see his rotate text implementation on emacswiki.
Thanks to @rejeep for ecukes, an excellent Cucumber-like testing framework.
Thanks to @DamienCassou for his detailed and thoughtful code review comments.
A special thanks to @TeMPOral, without which parrot wouldn’t be possible. I heavily modified the source code of nyan-mode to create parrot spawn. All credit goes to him for paving the way to new heights of mode-line distraction.
Some parrots stand on the shoulders of giant nyan cats.