;;;; -*- mode:emacs-lisp;coding:utf-8;lexical-binding:t -*-
;;;;**************************************************************************
;;;;FILE:               insulte.el
;;;;LANGUAGE:           emacs lisp
;;;;SYSTEM:             POSIX
;;;;USER-INTERFACE:     NONE
;;;;DESCRIPTION
;;;;
;;;;    Captain Haddock's insults generator.
;;;;
;;;;AUTHORS
;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
;;;;MODIFICATIONS
;;;;    2016-06-05 <PJB> Added distinction between ga and gap.
;;;;    2015-06-17 <PJB> Translated from Common Lisp.
;;;;BUGS
;;;;LEGAL
;;;;    AGPL3
;;;;
;;;;    Copyright Pascal J. Bourguignon 2015 - 2016
;;;;
;;;;    This program is free software: you can redistribute it and/or modify
;;;;    it under the terms of the GNU Affero General Public License as published by
;;;;    the Free Software Foundation, either version 3 of the License, or
;;;;    (at your option) any later version.
;;;;
;;;;    This program is distributed in the hope that it will be useful,
;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;;    GNU Affero General Public License for more details.
;;;;
;;;;    You should have received a copy of the GNU Affero General Public License
;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;;;**************************************************************************

(require 'cl)
(defvar *insulte-insults*)
(defvar *insulte-nm*)
(defvar *insulte-nf*)
(defvar *insulte-ad*)

(setf *insulte-insults* '(
                          ("accapareur" (nm))
                          ("aérolithe" (nm))
                          ("amiral de bateau­lavoir" (gnm))
                          ("amphitryon" (nm))
                          ("anacoluthe" (nf))
                          ("analphabète" (n a))
                          ("anthracite" (nm))
                          ("anthropophage" (nm a))
                          ("anthropopithèque" (nm))
                          ("apache" (nm))
                          ("apprenti dictateur à la noix de coco" (gnm))
                          ("arlequin" (nm))
                          ("astronaute d'eau douce" (gn))
                          ("athlète complet" (n))
                          ("autocrate" (nm))
                          ("autodidacte" (n a))
                          ("azteque" (nm))
                          ("babouin" (nm))
                          ("bachi­bouzouk" (nm))
                          ("bande de" (|...|))
                          ("bandit" (nm))
                          ("bayadère" (nf))
                          ("bibendum" (nm))
                          ("boit­sans­soif" (ni))
                          ("brontosaure" (nm))
                          ("bougre de" (|...|))
                          ("brute" (nf))
                          ("bulldozer à réaction" (gnm))
                          ("vieux" (a p))
                          ("cachalot" (nm))
                          ("canaille" (nf))
                          ("canaque" (nm a))
                          ("cannibale" (nm))
                          ("carnaval" (nm))
                          ("catachrèse" (nf))
                          ("cataplasme" (nm))
                          ("cercopithèque" (nm))
                          ("chauffard" (nm))
                          ("chenapan" (nm))
                          ("choléra" (nm))
                          ("chouette mal empaillée" (gnf))
                          ("cloporte" (nm))
                          ("clysopompe" (nm))
                          ("coléoptère" (nm))
                          ("coloquinte" (nf))
                          ("coquin" (n a))
                          ("cornemuse" (nf))
                          ("cornichon" (nm))
                          ("corsaire" (nm))
                          ("coupe­jarret" (nm))
                          ("cow­boy de la route" (gnm))
                          ("crétin des Alpes" (gnm))
                          ("Cro­magnon" (np))
                          ("cyanure" (nm))
                          ("cyclone" (nm))
                          ("cyclotron" (nm))
                          ("Cyrano à quatre pattes" (gnm))
                          ("diablesse" (nf))
                          ("diplodocus" (nm))
                          ("doryphore" (nm))
                          ("dynamiteur" (nm))
                          ("ecornifleur" (nm))
                          ("ecraseur" (nm))
                          ("ectoplasme" (nm))
                          ("egoïste" (nm))
                          ("emplatre" (nm))
                          ("empoisonneur" (nm a))
                          ("enragé" (nm a))
                          ("épouvantail" (nm))
                          ("équilibriste" (nm))
                          ("esclavagiste" (nm))
                          ("escogriffe" (nm))
                          ("espèce de" (|...|))
                          ("extrait de" (|...|))
                          ("faux jeton" (nm))
                          ("flibustier" (nm))
                          ("forban" (nm))
                          ("frères de la côte" (gnm))
                          ("froussard" (nm a))
                          ("galopin" (nm))
                          ("gangster" (nm))
                          ("garde­côte à la mie de pain" (gnm))
                          ("gargarisme" (nm))
                          ("garnement" (nm))
                          ("gibier de potence" (nm))
                          ("goujat" (nm))
                          ("gredin" (nm))
                          ("grenouille" (nf))
                          ("gros plein de soupe" (gnm))
                          ("gyroscope" (nm))
                          ("hérétique" (n a))
                          ("hors­la­loi" (nm))
                          ("huluberlu" (nm))
                          ("hydrocarbure" (nm))
                          ("iconoclaste" (nm a))
                          ("incas de carnaval" (gnmp))
                          ("individou de général" (gnm))
                          ("invertébré" (nm))
                          ("ivrogne" (n))
                          ("jet d'eau ambulant" (gnm))
                          ("jocrisse" (nm))
                          ("judas" (nm))
                          ("jus de réglisse" (gnm))
                          ("kroumir" (nm))
                          ("ku klux klan" (gnm))
                          ("lâche" (nm))
                          ("lépidoptère" (nm))
                          ("logarithme" (nm))
                          ("loup­garou à la graisse de renoncule" (gnm))
                          ("macaque" (nm))
                          ("macrocéphale" (nm))
                          ("malappris" (n a))
                          ("malotru" (n))
                          ("mamelouk" (nm))
                          ("marchand de guano" (gnm))
                          ("marchand de tapis" (gnm))
                          ("marin d'eau douce" (gnm))
                          ("marmotte" (nf))
                          ("mégalomane" (nm a))
                          ("mégacycle" (nm))
                          ("mercanti" (nm))
                          ("mercenaire" (nm a))
                          ("mérinos" (nm))
                          ("mille sabords" (gnmp))
                          ("misérable" (a))
                          ("mitrailleur à bavette" (gnm))
                          ("moratorium" (nm))
                          ("moricaud" (nm a))
                          ("mouchard" (nm))
                          ("moujik" (nm))
                          ("moule à gaufres" (gnm))
                          ("moussaillon" (nm))
                          ("mrkrpxzkrmtfrz" (nm))
                          ("mufle" (nm))
                          ("Mussolini de carnaval" (nm))
                          ("naufrageur" (nm))
                          ("négrier" (nm))
                          ("noix de coco" (gnm))
                          ("nyctalope" (n a))
                          ("olibrius" (nm))
                          ("ophicléïde" (nm))
                          ("ornithorynque" (nm))
                          ("oryctérope" (nm))
                          ("ostrogoth" (n a))
                          ("ours mal lèché" (gnm))
                          ("pacte à quatre" (gnm))
                          ("paltoquet" (nm))
                          ("pantoufle" (nf))
                          ("Papous" (nm))
                          ("paranoïaque" (nm a))
                          ("parasite" (nm a))
                          ("Patagon" (nm))
                          ("patapouf" (nm))
                          ("patate" (nf))
                          ("péronnelle" (nf))
                          ("perruche bavarde" (gnf))
                          ("phénomène" (nm))
                          ("phlébotome" (nm))
                          ("phylactère" (nm))
                          ("phylloxéra" (nm))
                          ("pignouf" (nm))
                          ("pirate" (nm))
                          ("Polichinelle" (nm))
                          ("polygraphe" (nm))
                          ("porc­épic mal embouché" (gnm))
                          ("potentat emplumé" (gnm))
                          ("poussière" (nf))
                          ("profiteur" (nm))
                          ("projectile guidé" (gnm))
                          ("protozoaire" (nm))
                          ("pyromane" (nm))
                          ("pyrophore" (nm))
                          ("rapace" (nm))
                          ("rat" (nm))
                          ("Ravachol" (nm))
                          ("renégat" (nm))
                          ("rhizopode" (nm))
                          ("Rocambole" (nm))
                          ("sacripant" (nm))
                          ("sajou" (nm))
                          ("saltimbanque" (nm))
                          ("sapajou" (nm))
                          ("satané bazar de fourbi de truc" (gnm))
                          ("satrape" (nm))
                          ("sauvage" (n a))
                          ("scélérat" (nm))
                          ("schizophrène" (n a))
                          ("scolopendre" (nf))
                          ("scorpion" (nm))
                          ("serpent" (nm))
                          ("simili martien à la graisse de cabestan" (gnm))
                          ("sinapisme" (nm))
                          ("soulographe" (nm))
                          ("squatter" (nm))
                          ("tchouk­tchouk­nougat" (nm))
                          ("technocrate" (nm))
                          ("tête de lard" (gnf))
                          ("tête de mule" (gnf))
                          ("tigresse" (nf))
                          ("tonnerre de Brest" (gnm))
                          ("topinanbour" (nm))
                          ("tortionnaire" (nm))
                          ("traficant de chair humaine" (gnm))
                          ("traine­potence" (nm))
                          ("traitre" (nm a))
                          ("troglodyte" (nm))
                          ("trompe­la­mort" (nm))
                          ("vampire" (nm))
                          ("vandale" (nm a))
                          ("va­nu­pieds" (nm))
                          ("vaurien" (nm))
                          ("végétarien" (nm))
                          ("Vercingétorix de carnaval" (nm))
                          ("ver de terre" (gnm))
                          ("vermicelle" (nm))
                          ("vermine" (nm))
                          ("vipère" (nf))
                          ("vivisectionniste" (nm))
                          ("voleur" (nm))
                          ("wisigoth" (n a))
                          ("zapotèque" (nm))
                          ("zèbre" (nm))
                          ("zigomar" (nm))
                          ("zouave" (nm))
                          ("Zoulou" (nm))
                          )
      *insulte-nm* (remove-if-not (lambda (x) (intersection '(n np nm gnm) (second x))) *insulte-insults*)
      *insulte-nf* (remove-if-not (lambda (x) (intersection '(nf np) (second x))) *insulte-insults*)
      *insulte-ad* (remove-if-not (lambda (x) (member 'a (second x))) *insulte-insults*))

(defun insulte ()
  (let* ((a   (elt *insulte-ad* (random (length *insulte-ad*))))
         (ad  (first a))
         (gn (let ((n (random (+ (length *insulte-nf*) (length *insulte-nm*)))))
               (if (>= n (length *insulte-nm*))
                   (prog1
                       (first (elt *insulte-nf* (- n (length *insulte-nm*))))
                     (cond
                       ((= 0 (length ad)))
                       ((string= "e"     (subseq ad   (- (length ad) 1)) ))
                       ((string= "eux"   (subseq ad   (- (length ad) 3)))
                        (setf ad (concat (subseq ad 0 (- (length ad) 2)) "ille")))
                       ((string= "eur"   (subseq ad   (- (length ad) 3)))
                        (setf ad (concat (subseq ad 0 (- (length ad) 1)) "se")))
                       (t
                        (setf ad (concat ad "e")))))
                   (first (elt *insulte-nm* n)))))
         (ga  (if (member 'p (second a))
                  ""
                  (format " %s" ad)))
         (gap (if (member 'p (second a))
                  (format "%s " ad)
                  ""))
         (conj (if (position (aref (concat gap gn) 0) "aeiouyh") "d'" "de "))
         (ins  (case (random 4)
                 ((0)       (concat "espèce " conj gap gn ga))
                 ((1)       (concat "bande "  conj gap gn ga))
                 (otherwise (concat gap gn ga)))))
    (concat (capitalize (subseq ins 0 1)) (subseq ins 1) " !")))


(defun insulte-moi ()
  (interactive)
  (message "%s" (insulte)))

;; (loop repeat 10 do (princ (insulte)) (terpri))
;; Vieux saltimbanque !
;; Zapotèque ostrogoth !
;; Potentat emplumé sauvage !
;; Espèce de végétarien moricaud !
;; Vieux hors­la­loi !
;; Vieux moricaud !
;; Coléoptère moricaud !
;; Paltoquet canaque !
;; Bande de rat paranoïaque !
;; Cachalot misérable !
;; nil

(provide 'insulte)
;;;; THE END ;;;;
ViewGit