From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/47247 Path: main.gmane.org!not-for-mail From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: User format functions - text properies get lost (XEmacs) Date: Thu, 17 Oct 2002 15:00:46 +0200 Organization: University of Dortmund, Germany Sender: owner-ding@hpc.uh.edu Message-ID: <848z0xp6dd.fsf@crybaby.cs.uni-dortmund.de> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1034861525 6108 80.91.224.249 (17 Oct 2002 13:32:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Oct 2002 13:32:05 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 182Akr-0001Ze-00 for ; Thu, 17 Oct 2002 15:32:01 +0200 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 182AkZ-0001Lm-00; Thu, 17 Oct 2002 08:31:43 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Thu, 17 Oct 2002 08:32:26 -0500 (CDT) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id IAA07754 for ; Thu, 17 Oct 2002 08:32:13 -0500 (CDT) Original-Received: (qmail 3776 invoked by alias); 17 Oct 2002 13:31:18 -0000 Original-Received: (qmail 3771 invoked from network); 17 Oct 2002 13:31:18 -0000 Original-Received: from quimby.gnus.org (80.91.224.244) by gnus.org with SMTP; 17 Oct 2002 13:31:18 -0000 Original-Received: from news by quimby.gnus.org with local (Exim 3.12 #1 (Debian)) id 182B7l-00021l-00 for ; Thu, 17 Oct 2002 15:55:41 +0200 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 33 Original-NNTP-Posting-Host: pd951f063.dip.t-dialin.net Original-X-Trace: quimby.gnus.org 1034862941 4704 217.81.240.99 (17 Oct 2002 13:55:41 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: 17 Oct 2002 13:55:41 GMT User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) Cancel-Lock: sha1:2z+AqTic8SgcoZWDBpkcRU7qQug= Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:47247 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:47247 Paul Moore writes: > +(defun gnus-simple-format (str &rest objects) > + ;; A replacement for FORMAT which only handles %s and %% formats. > + ;; Xemacs FORMAT does not preserve text properties on the input > + ;; strings, whereas this version does. Without this function, returning > + ;; strings with properties set from user-defined spec functions does not > + ;; work in xemacs. Arguably, this function should just be an alias for > + ;; format in FSF emacs (where properties are preserved), for speed if > + ;; nothing else. > + (with-temp-buffer > + (insert str) > + (goto-char (point-min)) > + (while (search-forward "%s" nil t) > + (let ((obj (car objects))) > + (replace-match (if (stringp obj) obj (format "%s" obj)) > + nil t)) > + (setq objects (cdr objects))) > + (gnus-replace-in-string (buffer-string) "%%" "%"))) Two issues come to my mind. First of all, what happens if you have "%%s" in the string? I think that this function is buggy in that case. Secondly, converting the string to a buffer and then (for gnus-replace-in-string) back to a string does not appear to be very efficient. Maybe you could search for the regexp "%[%s]", the look at match-string (that's what actually matched the regex) and do different things depending on that. Does this make sense? kai -- ~/.signature is: umop ap!sdn (Frank Nobis)