From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: No Wayman Newsgroups: gmane.emacs.bugs Subject: bug#61325: 30.0.50; Jokes in GNUS manual Date: Tue, 07 Mar 2023 15:02:05 -0500 Message-ID: <87a60otji3.fsf@gmail.com> References: <87ttzy7pg1.fsf@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25779"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.21; emacs 30.0.50 To: 61325@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 07 21:04:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZdXj-0006OK-Rk for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Mar 2023 21:04:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZdXY-0003hK-LP; Tue, 07 Mar 2023 15:04:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZdXW-0003fh-Uw for bug-gnu-emacs@gnu.org; Tue, 07 Mar 2023 15:04:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZdXW-00062E-M5 for bug-gnu-emacs@gnu.org; Tue, 07 Mar 2023 15:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pZdXW-0008N9-1N for bug-gnu-emacs@gnu.org; Tue, 07 Mar 2023 15:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: No Wayman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Mar 2023 20:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61325 X-GNU-PR-Package: emacs Original-Received: via spool by 61325-submit@debbugs.gnu.org id=B61325.167821939032125 (code B ref 61325); Tue, 07 Mar 2023 20:04:01 +0000 Original-Received: (at 61325) by debbugs.gnu.org; 7 Mar 2023 20:03:10 +0000 Original-Received: from localhost ([127.0.0.1]:47247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZdWf-0008M4-Ts for submit@debbugs.gnu.org; Tue, 07 Mar 2023 15:03:10 -0500 Original-Received: from mail-qv1-f44.google.com ([209.85.219.44]:44647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pZdWe-0008Lr-1t for 61325@debbugs.gnu.org; Tue, 07 Mar 2023 15:03:08 -0500 Original-Received: by mail-qv1-f44.google.com with SMTP id op8so9701232qvb.11 for <61325@debbugs.gnu.org>; Tue, 07 Mar 2023 12:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678219382; h=mime-version:message-id:date:in-reply-to:subject:to:from:user-agent :from:to:cc:subject:date:message-id:reply-to; bh=SxM3uLGwCvQcQymdBg8p4DWy/YszCjMeGH/H2QWT/fQ=; b=Lu3UAiWM+UsiyjaeAX5E3AN2BF40iTVWl37MibfoW80II+sLtCCemFCiO/ojrj+maC CRSDmKb3sgaliudG8ho6oVyhzUHu3eJzRShkZkxVdayOBtwh4xv7xMnsa0cTkXMX8ikr 3ravUyoOyNNWQIGwfMOgG/sI01xx2ScGgMFNTVwzcM9/tXjdPidJdE4VEJ/kZmxEdxhZ esVVk4OELZZdda22Iu4mqm9oi7lRlCOve1r1khNNdB6A0TC/NyqILGV48mLhyWIbmpU9 LCAHxUIZ0nwosVDzgf94W/Jdmlwf1EVFEP9suGdfiFqBb+8Vniv3K4g1lfiWwYhPQve7 Sssw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678219382; h=mime-version:message-id:date:in-reply-to:subject:to:from:user-agent :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SxM3uLGwCvQcQymdBg8p4DWy/YszCjMeGH/H2QWT/fQ=; b=FMnkx0JNEo6v4x1C6YyXSb7eajnvnMWdQM74LScg5xU7fmXIs6Bsk0qjDWtKH3vKO7 ZDMT5gxK9WWtqSei6irVanYrE7xtFAbmhwWqKgUjzvEvJQyyubT5HBgXG/5QQ1Zx5aV5 dmA5KiG62A+od0VxmI0+AKyaXPIXmoBCoYosqRTbE7oSQbhFkXk5u7jen0Pz7dTWO7zO p//yL/xQTTErASIs4xffvLMTgJg7xH5k7PGmziDQUBYRHlbCM3+WU95ZNK8klN7NafB1 qKWWxDrVqA8XnR/NUuQZE3rNn9GSsjm+MOPkN78vCOH7Ff3gLsbQCTsnESQcrgM560a5 hXlg== X-Gm-Message-State: AO0yUKUWFgcLh7ofNFpIBpIim3EKiiq+mX2YemAdg9DsLTlriCsdNCcg VH9KOOTaskcVxz8uQ/mv2Tfu/WZ3LOo= X-Google-Smtp-Source: AK7set+KRx4H420THxo0xq/HSi1CXhxkDP7F2UCAtgXG/YHkydMIsfn5bIuF4lamJt9JGYH88OIOxA== X-Received: by 2002:a05:6214:40f:b0:56e:a07b:f4df with SMTP id z15-20020a056214040f00b0056ea07bf4dfmr513230qvx.13.1678219382165; Tue, 07 Mar 2023 12:03:02 -0800 (PST) Original-Received: from nbook ([2601:84:847f:c697:8a6b:6703:a961:212b]) by smtp.gmail.com with ESMTPSA id u19-20020a05620a121300b007424376ca4bsm9987378qkj.18.2023.03.07.12.03.01 for <61325@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 12:03:01 -0800 (PST) In-Reply-To: <87fsagg05g.fsf@localhost> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257499 Archived-At: --=-=-= Content-Type: text/plain; format=flowed I feel like this discussion is easily solved by a technical means. What we need is an embedded document mark-up language in order for documentation authors to formally indicate where they are joking. We then define an alist of "harm categories" which users can register themselves with. Before documentation is printed, the "harmfulness coefficient" is determined for a particular user. If it is above their "harmfulness threshold", we display a less offensive joke (defined in a separate, localized user option). See the attached library, joke.el, which solves 99% of the problem. An example usage: #+begin_src emacs-lisp (defconst joke-test-text "A closure is a function that also carries a record of the lexical environment that existed when the function was defined. When it is invoked, any lexical variable references within its definition use the retained lexical environment. In all other respects, closures behave much like ordinary functions; in particular, they can be called in the same way as ordinary functions. Speaking of which: Why did the chicken go to Hell? It wasn't braised right.") (cl-loop for (subject . categories) in '((timmy . (agoraphobic child)) (rachel . (religious vegan))) collect (cons subject (apply #'joke-harm-by-category joke-test-text categories))) ;;((timmy (agoraphobic . 0.0) ;; (child . 12.043010752688172)) ;; (rachel (religious . 12.043010752688172) ;; (vegan . 12.043010752688172))) #+end_src Here we can see 12.04% of the above documentation will offend an agoraphobic child, such as Timmy. However, it will be doubly offensive to a religious vegan, such as Rachel. If I don't hear any convincing objections within the next couple of hours, I'll merge to emacs-29 branch. Thanks. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=joke.el Content-Description: joke ;;; Joke --- Not a joke. ;; -*- lexical-binding: t; -*- ;;; Commentary: ;; yes. ;;; Code: (require 'cl-lib) (defconst joke-harm-categories '((("chicken" "cow" "meat") . vegetarian) ((vegetarian "cheese" "milk" "fish") . vegan) (("god" "sex" "heaven" "hell") . religious) ((religious "religion") . atheist) (("marketplace") . agoraphobic) ((".*") . child)) "Lists of categories of people will be offended by jokes on certain topics.") (defun joke-victims (joke) "Return victims of JOKE." (cl-loop for (spec . victim) in joke-harm-categories for regexps = (flatten-tree (cl-loop for el in spec collect (if (symbolp el) (car (rassoc el joke-harm-categories)) el))) when (cl-some (lambda (regexp) (string-match-p regexp joke)) regexps) collect victim)) (defun joke-jokes (text) "Return list of jokes in TEXT." (let ((jokes)) (with-temp-buffer (insert text) (goto-char (point-min)) (while (re-search-forward "\\(?:\\([^z-a]*?\\)\\)" nil 'noerror) (push (match-string 1) jokes)) (nreverse jokes)))) (defun joke-harm-by-category (text &rest victims) "Return percentage of JOKES in TEXT which will harm VICTIMS." (cl-loop with jokes = (joke-jokes text) for victim in (or victims '(anyone)) for harmful = (cl-remove-if-not (lambda (joke) (member victim (joke-victims joke))) jokes) collect (cons victim (* 100 (/ (cl-reduce #'+ harmful :key #'length) (float (length text))))))) (provide 'joke) ;;; joke.el ends here --=-=-=--