From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann)
Subject: Re: User format functions - text properies get lost (XEmacs)
Date: Thu, 17 Oct 2002 15:00:46 +0200 [thread overview]
Message-ID: <848z0xp6dd.fsf@crybaby.cs.uni-dortmund.de> (raw)
In-Reply-To: <of9z3bue.fsf@morpheus.demon.co.uk>
Paul Moore <gustav@morpheus.demon.co.uk> 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)
next prev parent reply other threads:[~2002-10-17 13:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-12 15:39 Paul Moore
2002-10-14 12:01 ` Kai Großjohann
2002-10-14 21:00 ` Paul Moore
2002-10-15 9:24 ` Kai Großjohann
2002-10-16 20:18 ` Paul Moore
2002-10-17 13:03 ` Kai Großjohann
2002-10-17 19:34 ` Paul Moore
2002-10-17 13:00 ` Kai Großjohann [this message]
2002-10-17 19:48 ` Paul Moore
2002-10-18 14:34 ` Kai Großjohann
2002-10-18 18:15 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=848z0xp6dd.fsf@crybaby.cs.uni-dortmund.de \
--to=kai.grossjohann@cs.uni-dortmund.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).