From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/83955 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general,gmane.emacs.devel Subject: Re: general-purpose Gnus-style matching in a list function? Date: Sun, 08 Dec 2013 11:17:07 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87haajwc58.fsf@flea.lifelogs.com> References: <87zjocvvd9.fsf@flea.lifelogs.com> Reply-To: ding@gnus.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1386519381 24565 80.91.229.3 (8 Dec 2013 16:16:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Dec 2013 16:16:21 +0000 (UTC) Cc: emacs-devel@gnu.org To: ding@gnus.org Original-X-From: ding-owner+M32210@lists.math.uh.edu Sun Dec 08 17:16:26 2013 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vph1t-0007l0-6c for ding-account@gmane.org; Sun, 08 Dec 2013 17:16:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Vph1n-00023O-DS; Sun, 08 Dec 2013 10:16:19 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Vph1m-000239-3Z for ding@lists.math.uh.edu; Sun, 08 Dec 2013 10:16:18 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1Vph1h-00045i-EE for ding@lists.math.uh.edu; Sun, 08 Dec 2013 10:16:18 -0600 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1Vph1g-0003PG-2F for ding@gnus.org; Sun, 08 Dec 2013 17:16:12 +0100 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Vph1e-0007dx-71 for ding@gnus.org; Sun, 08 Dec 2013 17:16:10 +0100 Original-Received: from c-98-229-61-72.hsd1.ma.comcast.net ([98.229.61.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Dec 2013 17:16:10 +0100 Original-Received: from tzz by c-98-229-61-72.hsd1.ma.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 08 Dec 2013 17:16:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: ding@gnus.org Original-Lines: 61 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-98-229-61-72.hsd1.ma.comcast.net X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Mail-Copies-To: never User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:u8M7ymejVzC6pGwrQ6dzE3V1Jbc= X-Spam-Score: -2.0 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:83955 gmane.emacs.devel:166205 Archived-At: On Sat, 07 Dec 2013 23:07:14 -0500 Ted Zlatanov wrote: TZ> `gnus-posting-styles' is a good example of a very flexible defcustom TZ> that gets special treatment so the keys and the values can be almost TZ> anything: functions, regexps, strings, etc. TZ> It's processed in a special way by `gnus-configure-posting-styles' and I TZ> was wondering if Gnus has a general-purpose function to do this. If TZ> not, it should... I would shadow it in the Emacs core actually, it's a TZ> very common usage pattern. Following up to emacs-devel as well for any suggestions. Here's the common use case: I have some options that may change based on some context (group name, in the case of `gnus-posting-styles'). This comes up very often in all parts of Emacs, where you want to customize things per file name, per hostname, and so on. It's essentially a form of pattern matching, right? Kind of like `pcase' but for defcustoms. So Gnus ends up with something like this (again, this is an example, there are many other such defcustoms): #+begin_src lisp (defcustom gnus-posting-styles nil "*Alist of styles to use when posting. See Info node `(gnus)Posting Styles'." :group 'gnus-message :link '(custom-manual "(gnus)Posting Styles") :type '(repeat (cons (choice (regexp) (variable) (list (const header) (string :tag "Header") (regexp :tag "Regexp")) (function) (sexp)) (repeat (list (choice (const signature) (const signature-file) (const organization) (const address) (const x-face-file) (const name) (const body) (symbol) (string :tag "Header")) (choice (string) (function) (variable) (sexp))))))) #+end_src This is really nice for the users, who can go wild with customizations. But to extract the parameters, you end up writing complicated functions like `gnus-configure-posting-styles'. So my question was, does this exist already, or do I have to reinvent it? And is `pcase' the right style, in which case it should be better integrated with the defcustom facilities? Thanks Ted