git pull http://www.baby-gnu.org/~nebu/archives/gnus/gnus.git dad/match-substitute-replacement-in-posting-style:dad/match-substitute-replacement-in-posting-style * lisp/gnus-util.el: Define gnus-match-substitute-replacement as an alias of match-substitute-replacement or with the definition of match-substitute-replacement from subr.el. * lisp/gnus-msg.el (gnus-configure-posting-styles): Use gnus-match-substitute-replacement to replace positional parameters in attributes. * texi/gnus.texi (Posting Styles): Update the documentation: string values can now be regular expressions. --- lisp/gnus-msg.el | 6 +++++- lisp/gnus-util.el | 23 +++++++++++++++++++++++ texi/gnus.texi | 22 ++++++++++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lisp/gnus-msg.el b/lisp/gnus-msg.el index a7d6711..46cbc75 100644 --- a/lisp/gnus-msg.el +++ b/lisp/gnus-msg.el @@ -1891,7 +1891,11 @@ this is a reply." (setq v (cond ((stringp value) - value) + (if (and (stringp match) + (string-match-p "\\\\[&[:digit:]]" value) + (match-beginning 1)) + (gnus-match-substitute-replacement value nil nil group) + value)) ((or (symbolp value) (functionp value)) (cond ((functionp value) diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index 5bcda97..43ce739 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -1982,6 +1982,29 @@ Sizes are in pixels." (memq elem list)))) found)) +(eval-and-compile + (cond + ((fboundp 'match-substitute-replacement) + (defalias 'gnus-match-substitute-replacement 'match-substitute-replacement)) + (t + (defun gnus-match-substitute-replacement (replacement &optional fixedcase literal string subexp) + "Return REPLACEMENT as it will be inserted by `replace-match'. +In other words, all back-references in the form `\\&' and `\\N' +are substituted with actual strings matched by the last search. +Optional FIXEDCASE, LITERAL, STRING and SUBEXP have the same +meaning as for `replace-match'. + +This is the definition of match-substitute-replacement in subr.el from GNU Emacs." + (let ((match (match-string 0 string))) + (save-match-data + (set-match-data (mapcar (lambda (x) + (if (numberp x) + (- x (match-beginning 0)) + x)) + (match-data t))) + (replace-match replacement fixedcase literal match subexp)))) + ))) + (provide 'gnus-util) ;;; gnus-util.el ends here diff --git a/texi/gnus.texi b/texi/gnus.texi index 0a0f96b..5fea3f0 100644 --- a/texi/gnus.texi +++ b/texi/gnus.texi @@ -13428,14 +13428,20 @@ the headers of the article; if the value is @code{nil}, the header name will be removed. If the attribute name is @code{eval}, the form is evaluated, and the result is thrown away. -The attribute value can be a string (used verbatim), a function with -zero arguments (the return value will be used), a variable (its value -will be used) or a list (it will be @code{eval}ed and the return value -will be used). The functions and sexps are called/@code{eval}ed in the -message buffer that is being set up. The headers of the current article -are available through the @code{message-reply-headers} variable, which -is a vector of the following headers: number subject from date id -references chars lines xref extra. +The attribute value can be a string, a function with zero arguments +(the return value will be used), a variable (its value will be used) +or a list (it will be @code{eval}ed and the return value will be +used). The functions and sexps are called/@code{eval}ed in the +message buffer that is being set up. The headers of the current +article are available through the @code{message-reply-headers} +variable, which is a vector of the following headers: number subject +from date id references chars lines xref extra. + +In the case of a string value, if the @code{match} is a regular +expression, a @samp{gnus-match-substitute-replacement} is proceed on +the value to replace the positional parameters @samp{\@var{n}} by the +corresponding parenthetical matches (see @xref{Replacing the Text that +Matched, , Text Replacement, elisp, The Emacs Lisp Reference Manual}.) @vindex message-reply-headers -- 1.7.2.3 -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1