Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#323 closed defect (fixed)

Strange errors of make compile concerning save-excursion/set-buffer

Reported by: Makarius Owned by: David Aspinall
Priority: major Milestone: PG-Emacs-4.0
Component: 2:pg-emacs Keywords:
Cc:

Description

This is GNU Emacs 23.2.1 on Mac OS.

Byte-compilation via make EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs compile fails with strange errors like this:

coq/coq.el:291:8:Error: `save-excursion' defeated by `set-buffer'

The source in question in this case is

(defun proof-last-locked-span ()
  (save-excursion ;; didn't found a way to avoid buffer switching
    (set-buffer proof-script-buffer)
    (span-at (- (proof-unprocessed-begin) 1) 'type)
    )
  )

The same for isar, lego etc. Maybe this indicates an actual instability that was undetected so far.

Attachments (1)

compile.log (7.1 KB) - added by Makarius 14 years ago.
stderr of "make compile", with (setq byte-compile-error-on-warn nil)

Download all attachments as: .zip

Change History (6)

comment:1 Changed 14 years ago by David Aspinall

Status: newaccepted

No, I don't think there is an instability necessarily. This is a new compiler warning with 23.2, which is quite confusing. It is probably aimed at people who did not properly understand the behaviour of save-excursion anyway. See lengthy discussion here:

http://thread.gmane.org/gmane.emacs.devel/118710

The usage above is absolutely fine (no move of point in the temp buffer) so the warning is spurious.

Our compile is set to strictly treat warnings as errors so halts.

With newer Emacs API there are cleaner ways of doing this which we can switch to.

Unfortunately at the moment I can't build Emacs 23.2, so I've fixed the cases I found by looking around quickly. (A dump of warnings would be useful if you turn off the strict behaviour of make compile)

comment:2 Changed 14 years ago by David Aspinall

Resolution: fixed
Status: acceptedclosed

OK, struggled a while with library mess and built latest Emacs and patched the remaining cases (I hope correctly, will this get enough testing for PG 4.0?).

The idiom is rife in loads of Emacs lisp as it was a prototypical usage demonstrated in documentation, but =with-current-buffer= is usually what's wanted.

Changed 14 years ago by Makarius

Attachment: compile.log added

stderr of "make compile", with (setq byte-compile-error-on-warn nil)

comment:3 Changed 14 years ago by Makarius

BTW, GNU Emacs 23.2.1 is available as "no non-sense" Mac OS application from http://emacsformacosx.com/

Cygwin 1.7.5 also provides 23.2.1 by default.

comment:4 Changed 14 years ago by Makarius

Resolution: fixed
Status: closedreopened

comment:5 Changed 14 years ago by David Aspinall

Resolution: fixed
Status: reopenedclosed

Thanks for the log. I forgot to commit the remainder of the fixes. Done now, should compile cleanly without warnings.

Note: See TracTickets for help on using tickets.