+;; splitted from gnus-configure-posting-styles to allow recursive traversal.
+(defun gnus-configure-posting-style (style stack)
+ "Parse one posting style STYLE and returns the value as an alist."
+ (let (results element variable filep value v)
+ (dolist (attribute style)
+ (setq element (pop attribute)
+ variable nil
+ filep nil)
+ (setq value
+ (cond
+ ((eq (car attribute) ':file)
+ (setq filep t)
+ (cadr attribute))
+ ((eq (car attribute) :value)
+ (cadr attribute))
+ (t
+ (car attribute))))
+ ;; We get the value.
+ (setq v
+ (cond
+ ((stringp value)
+ value)
+ ((or (symbolp value)
+ (gnus-functionp value))
+ (cond ((gnus-functionp value)
+ (funcall value))
+ ((boundp value)
+ (symbol-value value))))
+ ((listp value)
+ (eval value))))
+ ;; Translate obsolescent value.
+ (cond
+ ((eq element 'signature-file)
+ (setq element 'signature
+ filep t))
+ ((eq element 'x-face-file)
+ (setq element 'x-face
+ filep t)))
+ ;; Get the contents of file elems.
+ (when (and filep v)
+ (setq v (with-temp-buffer
+ (insert-file-contents v)
+ (goto-char (point-max))
+ (while (bolp)
+ (delete-char -1))
+ (buffer-string))))
+ (if (eq element 'import)
+ (progn
+ (if (member v stack)
+ (error "Circular import of \"%s\"" v))
+ (setq results
+ (nconc (nreverse (gnus-configure-posting-style
+ (cdr (assoc v gnus-named-posting-styles))
+ (cons v stack)))
+ results)))
+ (push (cons element v) results)))
+ (nreverse results)))
+
+(defun gnus-summary-execute-command-with-posting-style (style command)
+ "Temporarily select a posting-style named STYLE and execute COMMAND."
+ (interactive
+ (let ((style (completing-read "Posting style: "
+ gnus-named-posting-styles nil t)))
+ (list style
+ (key-binding
+ (read-key-sequence
+ (format "Command to execute with %s: " style))))))
+ (let ((gnus-posting-styles (list (list ".*" (list 'import style)))))
+ (call-interactively command)))
+