Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dp12/parrot

A package to rotate text and party with parrots at the same time
https://github.com/dp12/parrot

emacs parrot party-parrot partyparrot plugin rotate slack

Last synced: 2 months ago
JSON representation

A package to rotate text and party with parrots at the same time

Awesome Lists containing this project

README

        

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

[[https://stable.melpa.org/#/parrot][file:https://stable.melpa.org/packages/parrot-badge.svg]]
[[https://melpa.org/#/parrot][file:https://melpa.org/packages/parrot-badge.svg]]
[[https://travis-ci.org/dp12/parrot][file:https://api.travis-ci.org/dp12/parrot.png?branch=master]]
[[http://www.gnu.org/licenses/gpl-3.0.html][file: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.

[[file:parrot_in_action.gif]]

** Install
Parrot is available on MELPA. You can install it with:
#+begin_src emacs-lisp
M-x package-install parrot
#+end_src

If you use use-package:
#+begin_src emacs-lisp
(use-package parrot
:config
(parrot-mode))
#+end_src

Or the old-fashioned way:
#+begin_src emacs-lisp
(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)
#+end_src

Rotation function keybindings:
#+begin_src emacs-lisp
;; 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)
#+end_src
*** Spacemacs Installation
To get parrot working with spacemacs, you need to apply a few changes from this [[https://github.com/dp12/spaceline/commit/f0dff948ebb104fb43228f0bfb3ab18b11b4487a][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:

#+begin_src emacs-lisp
(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"))
))
#+end_src

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:
#+begin_src emacs-lisp
(dolist (entry '((:rot ("hakuna" "matata"))
(:rot ("peeple" "sheeple"))))
(add-to-list 'parrot-rotate-dict entry))
#+end_src
** 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:

#+begin_src emacs-lisp
(parrot-set-parrot-type 'science)
#+end_src
Like the wonders of the ancient world, parrot comes in 7 original flavors:
| Parrot | Name |
|------------------------------------------+----------|
| [[file:https://i.imgur.com/53YCmpd.gif]] | default |
| [[file:https://i.imgur.com/svleFy1.gif]] | confused |
| [[file:https://i.imgur.com/DSExpFD.gif]] | emacs |
| [[file:https://i.imgur.com/xpUahDq.gif]] | nyan |
| [[file:https://i.imgur.com/BnSpEwK.gif]] | rotating |
| [[file:https://i.imgur.com/fMf23JR.gif]] | science |
| [[file:https://i.imgur.com/WmXn4wz.gif]] | thumbsup |

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:
#+begin_src emacs-lisp
(add-hook 'mu4e-index-updated-hook #'parrot-start-animation)
#+end_src

You can also add functions to =parrot-click-hook= so they will run whenever you click on the parrot.
#+begin_src emacs-lisp
(add-hook 'parrot-click-hook 'flyspell-buffer)
#+end_src

*NEW!*
Want parrot to rotate forever? Set =parrot-num-rotations= to nil to get perfectly perpetual parrot.
#+begin_src emacs-lisp
(setq parrot-num-rotations nil)
#+end_src

** Misc
Parrot is integration-tested with ecukes [[https://github.com/ecukes/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 [[https://github.com/TeMPOraL/nyan-mode][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 [[https://github.com/jmhobbs][@jmhobbs]] [[https://github.com/jmhobbs/cultofthepartyparrot.com][Cult of the Party Parrot site]]. Thanks to [[https://github.com/mermop][@mermop]] (default), [[https://github.com/kyprifog][@kyprifog]] (confused), [[https://github.com/shiruken][@shiruken]] (science), [[https://github.com/vaicine][@vaicine]] (nyan), [[https://github.com/youngcba3][@youngcba3]] (rotating), [[https://github.com/zeftilldeath][@zeftilldeath]] (thumbsup parrot) for their respective parrots, and of course [[https://github.com/jmhobbs][@jmhobbs]] for compiling them.

Thanks to [[https://github.com/francoislg][@francoislg]] for [[https://github.com/francoislg/PPaaS][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 [[https://www.emacswiki.org/emacs/RotateText][emacswiki]].

Thanks to [[https://github.com/rejeep][@rejeep]] for ecukes, an excellent Cucumber-like testing framework.

Thanks to [[https://github.com/DamienCassou][@DamienCassou]] for his detailed and thoughtful code review comments.

A special thanks to [[https://github.com/TeMPOraL][@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.

#+BEGIN_QUOTE
Some parrots stand on the shoulders of giant nyan cats.
#+END_QUOTE

[[file:parrot3cat.png]]