Gnus development mailing list
 help / color / mirror / Atom feed
* general-purpose Gnus-style matching in a list function?
@ 2013-12-08  4:07 Ted Zlatanov
  2013-12-08 16:17 ` Ted Zlatanov
  2013-12-26 16:17 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 3+ messages in thread
From: Ted Zlatanov @ 2013-12-08  4:07 UTC (permalink / raw)
  To: ding

`gnus-posting-styles' is a good example of a very flexible defcustom
that gets special treatment so the keys and the values can be almost
anything: functions, regexps, strings, etc.

It's processed in a special way by `gnus-configure-posting-styles' and I
was wondering if Gnus has a general-purpose function to do this.  If
not, it should... I would shadow it in the Emacs core actually, it's a
very common usage pattern.

Thanks
Ted




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: general-purpose Gnus-style matching in a list function?
  2013-12-08  4:07 general-purpose Gnus-style matching in a list function? Ted Zlatanov
@ 2013-12-08 16:17 ` Ted Zlatanov
  2013-12-26 16:17 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Ted Zlatanov @ 2013-12-08 16:17 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

On Sat, 07 Dec 2013 23:07:14 -0500 Ted Zlatanov <tzz@lifelogs.com> 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: general-purpose Gnus-style matching in a list function?
  2013-12-08  4:07 general-purpose Gnus-style matching in a list function? Ted Zlatanov
  2013-12-08 16:17 ` Ted Zlatanov
@ 2013-12-26 16:17 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2013-12-26 16:17 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> `gnus-posting-styles' is a good example of a very flexible defcustom
> that gets special treatment so the keys and the values can be almost
> anything: functions, regexps, strings, etc.
>
> It's processed in a special way by `gnus-configure-posting-styles' and I
> was wondering if Gnus has a general-purpose function to do this.  If
> not, it should... I would shadow it in the Emacs core actually, it's a
> very common usage pattern.

I don't think there's anything like that in Emacs code.  The number of
things that can be in `gnus-posting-styles' is so large that it is
perhaps a bit bewildering...

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-26 16:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-08  4:07 general-purpose Gnus-style matching in a list function? Ted Zlatanov
2013-12-08 16:17 ` Ted Zlatanov
2013-12-26 16:17 ` Lars Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).