A package to rotate text and party with parrots at the same time
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
features
img Initial commit of parrot (Version 1.0.0) Oct 13, 2018
.travis.yml Initial commit of parrot (Version 1.0.0) Oct 13, 2018
Cask
LICENSE
Makefile
README.org
parrot-rotate.el Add click handler and bump version to 1.0.1 Oct 26, 2018
parrot.el Add click handler and bump version to 1.0.1 Oct 26, 2018
parrot3cat.png
parrot_in_action.gif

README.org

https://cultofthepartyparrot.com/parrots/parrot.gif Parrot Mode - Viva la parrot revolution!

https://stable.melpa.org/packages/parrot-badge.svg https://melpa.org/packages/parrot-badge.svg https://api.travis-ci.org/dp12/parrot.png?branch=master http://img.shields.io/:license-gpl3-blue.svg

Background

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_in_action.gif

Install

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)

Spacemacs Installation

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.

Usage

Use parrot-rotate-next-word-at-point and 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 t will add UPPER CASE rotations
  • :caps t will add Capitalized rotations
  • :lower nil will 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))

Party Parrots

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:

(parrot-set-parrot-type 'science)

Like the wonders of the ancient world, parrot comes in 7 original flavors:

ParrotName
https://cultofthepartyparrot.com/parrots/parrot.gifdefault
https://cultofthepartyparrot.com/parrots/confusedparrot.gifconfused
https://ppaas.herokuapp.com/partyparrot?overlay=https://upload.wikimedia.org/wikipedia/commons/thumb/0/08/EmacsIcon.svg/1024px-EmacsIcon.svg.png&overlayWidth=15&overlayHeight=15&overlayOffsetX=11&overlayOffsetY=1emacs
https://cultofthepartyparrot.com/parrots/nyanparrot.gifnyan
https://cultofthepartyparrot.com/parrots/rotatingparrot.gifrotating
https://cultofthepartyparrot.com/parrots/scienceparrot.gifscience
https://cultofthepartyparrot.com/parrots/thumbsupparrot.gifthumbsup

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.

Customization

Party parrot

  • 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.
  • parrot-animate-parrot - t to enable parrot animation, nil for 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.

Rotations

  • parrot-rotate-hunt-for-words - t to rotate words that aren’t directly under the cursor.
  • parrot-rotate-jump-to-word-after-hunt - t to jump to the word rotated if it isn’t under the cursor.
  • parrot-rotate-animate-after-rotation - t to animate the party parrot after rotating a word.
  • parrot-rotate-highlight-after-rotation - t to 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.

Customization

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)

Misc

Parrot is integration-tested with ecukes 🥒 and is licensed under the GPLv3.

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.

Acknowledgements

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.

parrot3cat.png