From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/88196 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.gnus.general Subject: Re: message-simplify-subject too coupled with reply (and not extensible) Date: Sun, 28 Oct 2018 19:16:21 -0700 Message-ID: <87k1m1zedm.fsf@ericabrahamsen.net> References: <87zhux7u4z.fsf@portable.galex-713.eu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1540779330 29250 195.159.176.226 (29 Oct 2018 02:15:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 02:15:30 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: ding@gnus.org Original-X-From: ding-owner+M36410@lists.math.uh.edu Mon Oct 29 03:15:26 2018 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from lists1.math.uh.edu ([129.7.128.208]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGx5Q-0007QM-KU for ding-account@gmane.org; Mon, 29 Oct 2018 03:15:24 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.90_1) (envelope-from ) id 1gGx6k-0006VT-JR; Sun, 28 Oct 2018 21:16:46 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gGx6b-0006Si-VP for ding@lists.math.uh.edu; Sun, 28 Oct 2018 21:16:38 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gGx6a-0003Tj-74 for ding@lists.math.uh.edu; Sun, 28 Oct 2018 21:16:37 -0500 Original-Received: from [195.159.176.226] (helo=blaine.gmane.org) by quimby.gnus.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGx6Y-0003yQ-Ev for ding@gnus.org; Mon, 29 Oct 2018 03:16:34 +0100 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1gGx4P-00061b-MB for ding@gnus.org; Mon, 29 Oct 2018 03:14:21 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 89 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:7N5jXm57aGg375oST0zDPR2x6X8= X-Spam-Score: -0.9 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:88196 Archived-At: "Garreau, Alexandre" writes: > After having discovered `message-strip-subject-trailing-was', I searched > for how it was used and if there were similar functions, and there were, > all in `message-simplify-subject-functions', quite interesting one. > > One critic is, their standard caller, `message-simplify-subject', work > only for the 4 default functions (stopping users from adding their own > custom functions in addition or replacement of the default ones (for > instance I’d like a function to remove the inner “was”s but not the > outer one)), instead of recursively applying them all to the said > subject (after all their have the same call semantics: one argument: the > subject!). Yup, there's quite a few odd places like this in Gnus, where the user is given a custom option, but then Gnus only accepts certain values within that option -- apart from being able to remove values from it, the ability to customize becomes less meaningful. In this case, I don't see why people shouldn't be able to put any function they like in there. > But the main problem is, as this function call manually each of these > four functions, in the special case of `message-strip-subject-re', it > removes excedentary “Re:”… and add a new one! so in the end, > `message-reply' doesn’t do that: that fills terribly wrong. > `message-reply' should add a “Re:” (that’s the least expectable from it, > it’s confusing it is not it that does it), and > `message-simplify-subject' should do what its name says, so that to be > really useful: simplify subject, not prepare it for another different > function (namely, `message-reply')! I'm less certain about this. It's one of those cases where probably no one remembers why it is the way it is, and no one wants to touch it because who knows how things might suddenly break. If I were you I would report two separate bugs, so that the first had a better chance of being accepted. > I wanted to see this function used in `org-email-link-description', but > it’s impossible because of this oddity (otherwise the message could be > falsely seen as a reply while it isn’t one). If it was possible, the > subject cited in org links could be *semantically* shorter (rather than > blindly arbitrarily cut in the middle), and benefit from user > customizations and extensions. > > May I propose the following implementation: > > #+BEGIN_SRC emacs-lisp > (defun message-simplify-subject (subject &optional functions) > "Return simplified SUBJECT" > (let ((functions (or functions message-simplify-subject-functions))) > (if functions > (let ((fun (car functions)) > (other-funs (cdr functions))) > (message-simplify-subject (funcall fun subject) other-funs)) > subject))) > #+END_SRC That looks fine, though you just don't see a whole lot of recursion used in the Emacs codebase. This is the sort of thing I like the `seq' functions for: (seq-reduce (lambda (subject fun) (funcall fun subject)) message-simplify-subject-functions subject) Or just a simple dolist and setq. > Then, `message-reply' should replace “(message-simplify-subject > subject)” with “(concat "Re: " (message-simplify-subject subject))”, and > also, `message-strip-list-identifiers should get a “unless (equal > gnus-list-identifiers "")” around the body of its outer `let' (not > mandatory, but otherwise `message-strip-list-identifiers' might remove a > “Re:”, what `message-strip-subject-re' should do, even if it wasn’t > asked by the user by being put in `message-simplify-subject-functions'). And `message-strip-subject-trailing-was' already checks `message-subject-trailing-was-query', so the extra check there is redundant, which would mean `message-simplify-subject' really could just be a simple reduction function. > May I also suggest, for consistency, to rename > `message-strip-list-identifiers' to > `message-strip-subject-list-identifiers'. I guess it isn’t used > elsewhere than in message.el. > > It is also shorter, in total. I would file a couple of bug reports. Eric