unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to get a file name with a warning like this
@ 2020-08-28 22:59 Harry Putnam
  2020-08-29  2:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-29  5:12 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Harry Putnam @ 2020-08-28 22:59 UTC (permalink / raw)
  To: help-gnu-emacs

[Note: This message is reprint of a message posted on .. gnus.general
probably the wrong group since it is not gnus specific]

I've been getting this warning message:

Warning (bytecomp): Use ‘with-current-buffer’ ....
             rather than save-excursion+set-buffer
[all on one line] -hp]

... (for some months now) ...

emacs version:
,----
| GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
|    version 1.14.8, Xaw3d scroll bars) of 2020-05-31
`----

I've searched obvious files like ~/.emacs ~/.gnus ...site-start.el
with no result.

How can I make the warning message tell me which file[s] it is finding
the problem code in?




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

* Re: How to get a file name with a warning like this
  2020-08-28 22:59 How to get a file name with a warning like this Harry Putnam
@ 2020-08-29  2:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-29  2:12   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-29  5:12 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-29  2:02 UTC (permalink / raw)
  To: help-gnu-emacs

Harry Putnam wrote:

> Warning (bytecomp): Use ‘with-current-buffer’ ....
> rather than save-excursion+set-buffer [...]
>
> How can I make the warning message tell me which
> file[s] it is finding the problem code in?

Seem like a tough problem ... but ...

wait!

I just got a moment of inspiration!

What about using `with-current-buffer' rather than
`save-excursion' and `set-buffer'

???

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: How to get a file name with a warning like this
  2020-08-29  2:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-29  2:12   ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-29  2:12 UTC (permalink / raw)
  To: help-gnu-emacs

>> Warning (bytecomp): Use ‘with-current-buffer’ ....
>> rather than save-excursion+set-buffer [...]
>> How can I make the warning message tell me which
>> file[s] it is finding the problem code in?
>
> Seem like a tough problem ... but ...
>
> wait!
>
> I just got a moment of inspiration!
>
> What about using `with-current-buffer' rather than
> `save-excursion' and `set-buffer'
>
> ???

Heh, sorry, but to answer you question ... the byte
compiler should tell you already what file is the
origin of the warning. B/c you yanked the error
message here, this makes it even weirder, b/c that
means you killed the part that tells in what file
it happened.

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: How to get a file name with a warning like this
  2020-08-28 22:59 How to get a file name with a warning like this Harry Putnam
  2020-08-29  2:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-29  5:12 ` Stefan Monnier
  2020-08-29  5:32   ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2020-08-29  5:12 UTC (permalink / raw)
  To: help-gnu-emacs

> Warning (bytecomp): Use ‘with-current-buffer’ ....
>              rather than save-excursion+set-buffer

Usually, this comes from the byte-compiler when it's called directly via
`byte-compile` with an Elisp expression as argument, rather than by
compiling a file, so the compiler has no idea which file it comes from.
You might try `M-x trace-function RET byte-compile RET` but you have to
do that before the warning is emitted.


        Stefan




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

* Re: How to get a file name with a warning like this
  2020-08-29  5:12 ` Stefan Monnier
@ 2020-08-29  5:32   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2020-08-29  5:36     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-29  5:32 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

>> Warning (bytecomp): Use ‘with-current-buffer’ ....
>> rather than save-excursion+set-buffer
>
> Usually, this comes from the byte-compiler when
> it's called directly via `byte-compile` with an
> Elisp expression as argument, rather than by
> compiling a file, so the compiler has no idea which
> file it comes from. You might try `M-x
> trace-function RET byte-compile RET` but you have
> to do that before the warning is emitted.

OK, that explains it, sorry.

That said... even so, why not simply grep the entire
source for save-excursion and set-buffer ?

And fix every instance?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

* Re: How to get a file name with a warning like this
  2020-08-29  5:32   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-08-29  5:36     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-08-29  5:36 UTC (permalink / raw)
  To: help-gnu-emacs

> why not simply grep the entire source for
> save-excursion and set-buffer ?

... using the byte compiler!

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




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

end of thread, other threads:[~2020-08-29  5:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-28 22:59 How to get a file name with a warning like this Harry Putnam
2020-08-29  2:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-29  2:12   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-29  5:12 ` Stefan Monnier
2020-08-29  5:32   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-08-29  5:36     ` Emanuel Berg via Users list for the GNU Emacs text editor

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 read-only IMAP folder(s) and NNTP newsgroup(s).