Gnus development mailing list
 help / color / mirror / Atom feed
From: Lloyd Zusman <ljz@asfast.com>
Subject: Shouldn't `mml-parse' use `save-excursion'?
Date: 22 Dec 2000 20:50:50 -0500	[thread overview]
Message-ID: <lt7l4rq51h.fsf@asfast.com> (raw)

In the lastest cvs version of gnus, I'm looking through the code
within `mml.el'.  One thing I noticed is that the `mml-parse' function
changes the buffer pointer without doing a `save-excursion'.  Here's
how `mml-parse' looks now:

  (defun mml-parse ()
    "Parse the current buffer as an MML document."
    (goto-char (point-min))
    (let ((table (syntax-table)))
      (unwind-protect
	  (progn
	    (set-syntax-table mml-syntax-table)
	    (mml-parse-1))
        (set-syntax-table table))))

However, I think it should actually look something like this:

  (defun mml-parse ()
    "Parse the current buffer as an MML document."
    (save-excursion
     (goto-char (point-min))
     (let ((table (syntax-table)))
       (unwind-protect
	   (progn
	     (set-syntax-table mml-syntax-table)
	     (mml-parse-1))
         (set-syntax-table table)))))

I'm thinking that `mml-parse' should probably used in more places
within gnus (I'll explain in a moment), and the `save-excursion' will
make it easier to use it without unwanted side effects.

The reason I would like to use `mml-parse', is because I'd like to fix
the `mml-secure-part' function in `mml-sec.el' so that it doesn't
insert duplicate tags, and so its functioning isn't dependent on the
current point's position within the message buffer when it gets
invoked (it is dependent now).  For this reason, I think it would be a
good idea to call `mml-parse' early within `mml-secure-part' so that
the results of `mml-parse' can be used to determine whether or not the
part that's being requested already exists in the message buffer
... if so, then `mml-secure-part' could be a no-op.

Anyway, whatever turns out to be good to do within `mml-secure-part',
it still seems to me that wrapping the logic of `mml-parse' within a
`save-excursion' will allow this very helpful function to be used in
more places within gnus.

Thoughts?

-- 
 Lloyd Zusman
 ljz@asfast.com



             reply	other threads:[~2000-12-23  1:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-23  1:50 Lloyd Zusman [this message]
2000-12-23  2:09 ` ShengHuo ZHU
2000-12-23  2:20   ` Lloyd Zusman

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=lt7l4rq51h.fsf@asfast.com \
    --to=ljz@asfast.com \
    /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).