SkillAgentSearch skills...

Parrot

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

Install / Use

/learn @dp12/Parrot
About this skill

Quality Score

0/100

Supported Platforms

Universal

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]] [[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-hook-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-hook-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

Parrot Hook Speed Customization Want the parrot to spin slower or faster when a hook function fires? Setting the =parrot-hook-animation-frame-interval= to a different value than =parrot-animation-frame-interval= will accomplish this and also cause the parrot to spin in perpetuity when =parrot-hook-start-animation= is called. #+begin_src emacs-lisp (setq parrot-animation-frame-interval 0.045) (setq parrot-hook-animation-frame-interval 0.09) ;; <-- it's slower

;; ascii version of parrot looks nicer with a different speed than the graphical one (setq parrot-ascii-animation-frame-interval 0.2) (setq parrot-ascii-hook-animation-frame-interval 0.4) #+end_src Thanks to @jnc-nj for the PoC. ** Misc Parrot is integration-tested with ecukes [[https://github.com/ecukes/ecukes][🥒]] and is licensed under the GPLv3.

I designed parrot first as a text rotation package, with some optional eyecandy on the modebar. Therefore, I now consider parrot feature-complete in terms of rotate-text and animation functionality. In the interest of avoiding scope creep, no new PRs related to animation features will be merged. However, feel free to fork your own versions of parrot and expand on it for other purposes. I envision some nice names for animation-focused parrot packages could be "parrot-animations" or "parrot-notifications".

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/cultofthepartypa

Related Skills

View on GitHub
GitHub Stars186
CategoryDevelopment
Updated25d ago
Forks13

Languages

Emacs Lisp

Security Score

100/100

Audited on Mar 16, 2026

No findings