Gnus development mailing list
 help / color / mirror / Atom feed
* Shouldn't `mml-parse' use `save-excursion'?
@ 2000-12-23  1:50 Lloyd Zusman
  2000-12-23  2:09 ` ShengHuo ZHU
  0 siblings, 1 reply; 3+ messages in thread
From: Lloyd Zusman @ 2000-12-23  1:50 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Shouldn't `mml-parse' use `save-excursion'?
  2000-12-23  1:50 Shouldn't `mml-parse' use `save-excursion'? Lloyd Zusman
@ 2000-12-23  2:09 ` ShengHuo ZHU
  2000-12-23  2:20   ` Lloyd Zusman
  0 siblings, 1 reply; 3+ messages in thread
From: ShengHuo ZHU @ 2000-12-23  2:09 UTC (permalink / raw)


Lloyd Zusman <ljz@asfast.com> writes:

> 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:

It is reasonable.  Added.

ShengHuo



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Shouldn't `mml-parse' use `save-excursion'?
  2000-12-23  2:09 ` ShengHuo ZHU
@ 2000-12-23  2:20   ` Lloyd Zusman
  0 siblings, 0 replies; 3+ messages in thread
From: Lloyd Zusman @ 2000-12-23  2:20 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> Lloyd Zusman <ljz@asfast.com> writes:
> 
> > 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:
> 
> It is reasonable.  Added.

Wow!  That was fast!  I was planning on making the change myself, once
I got the go-ahead here.

Thank you very much.

> ShengHuo

-- 
 Lloyd Zusman
 ljz@asfast.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-12-23  2:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-23  1:50 Shouldn't `mml-parse' use `save-excursion'? Lloyd Zusman
2000-12-23  2:09 ` ShengHuo ZHU
2000-12-23  2:20   ` Lloyd Zusman

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).