unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
@ 2015-10-13 22:51 Noam Postavsky
  2015-10-14 16:28 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2015-10-13 22:51 UTC (permalink / raw)
  To: 21681

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

Before:

Warning (:warning): : ‘lexical-binding’ at end of file unreliable

After:

Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable

[-- Attachment #2: 0001-Fix-formatting-of-lexical-binding-at-eof-warning.patch --]
[-- Type: text/x-diff, Size: 1275 bytes --]

From 3c3c1bd1d5672930b95d9ac00ba7e48636b7ff7f Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Tue, 13 Oct 2015 18:29:56 -0400
Subject: [PATCH] Fix formatting of lexical-binding at eof warning

* lisp/files.el (hack-local-variables): Get buffer name from the
  visiting buffer, and pass 'files as first arg to `display-warning'.
---
 lisp/files.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 8565aa8..d979a42 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3418,11 +3418,11 @@ (defun hack-local-variables (&optional mode-only)
 			       (unless hack-local-variables--warned-lexical
 				 (setq hack-local-variables--warned-lexical t)
 				 (display-warning
-                                  :warning
+                                  'files
                                   (format-message
                                    "%s: `lexical-binding' at end of file unreliable"
                                    (file-name-nondirectory
-                                    (or buffer-file-name ""))))))
+                                    (or (buffer-file-name thisbuf) ""))))))
 			      (t
 			       (ignore-errors
 				 (push (cons (if (eq var 'eval)
-- 
2.5.3


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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-13 22:51 bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning Noam Postavsky
@ 2015-10-14 16:28 ` Eli Zaretskii
  2015-10-14 16:56   ` Noam Postavsky
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2015-10-14 16:28 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Tue, 13 Oct 2015 18:51:28 -0400
> From: Noam Postavsky <npostavs@gmail.com>
> 
> Before:
> 
> Warning (:warning): : ‘lexical-binding’ at end of file unreliable
> 
> After:
> 
> Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable

Why 'files', and not something more concrete, like
'file-local-variables'?

Otherwise, LGTM, thanks.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 16:28 ` Eli Zaretskii
@ 2015-10-14 16:56   ` Noam Postavsky
  2015-10-14 17:42     ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2015-10-14 16:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

On Wed, Oct 14, 2015 at 12:28 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> Why 'files', and not something more concrete, like
> 'file-local-variables'?

The docstring for display-warning says the TYPE arg should be a custom group.

display-warning doesn't actually enforce this, and it looks like the
choice of symbol(s) is only relevant to warning-suppress-log-types.
Perhaps the TYPE should be '(files local-variables) so the user can
suppress it along with all files warnings or just suppress it on it's
own, but display-warning only prints the 1st symbol of the list so the
warning text itself wouldn't change.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 16:56   ` Noam Postavsky
@ 2015-10-14 17:42     ` Eli Zaretskii
  2015-10-14 17:47       ` Noam Postavsky
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2015-10-14 17:42 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Wed, 14 Oct 2015 12:56:28 -0400
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: 21681@debbugs.gnu.org
> 
> On Wed, Oct 14, 2015 at 12:28 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Why 'files', and not something more concrete, like
> > 'file-local-variables'?
> 
> The docstring for display-warning says the TYPE arg should be a custom group.
> 
> display-warning doesn't actually enforce this, and it looks like the
> choice of symbol(s) is only relevant to warning-suppress-log-types.
> Perhaps the TYPE should be '(files local-variables) so the user can
> suppress it along with all files warnings or just suppress it on it's
> own, but display-warning only prints the 1st symbol of the list so the
> warning text itself wouldn't change.

I find "files" no more explanatory that "warning".  If we lack
infrastructure to display meaningful messages that unequivocally point
to the nature of the problem, let's add the missing infrastructure.

Thanks.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 17:42     ` Eli Zaretskii
@ 2015-10-14 17:47       ` Noam Postavsky
  2015-10-14 17:53         ` Eli Zaretskii
  2015-10-31 22:36         ` Noam Postavsky
  0 siblings, 2 replies; 15+ messages in thread
From: Noam Postavsky @ 2015-10-14 17:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

On Wed, Oct 14, 2015 at 1:42 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Wed, 14 Oct 2015 12:56:28 -0400
>> From: Noam Postavsky <npostavs@users.sourceforge.net>
>> own, but display-warning only prints the 1st symbol of the list so the
>> warning text itself wouldn't change.
>
> I find "files" no more explanatory that "warning".  If we lack
> infrastructure to display meaningful messages that unequivocally point
> to the nature of the problem, let's add the missing infrastructure.

How about making display-warning print all TYPE symbols then?





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 17:47       ` Noam Postavsky
@ 2015-10-14 17:53         ` Eli Zaretskii
  2015-10-14 19:46           ` Eli Zaretskii
  2015-10-31 22:36         ` Noam Postavsky
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2015-10-14 17:53 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Wed, 14 Oct 2015 13:47:40 -0400
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: 21681@debbugs.gnu.org
> 
> How about making display-warning print all TYPE symbols then?

Fine with me, but I don't know enough about display-warning and its
uses to tell if this could cause some harm somewhere.  Maybe someone
else will know; if you hear no objections in a few days, please go
ahead.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 17:53         ` Eli Zaretskii
@ 2015-10-14 19:46           ` Eli Zaretskii
  2015-10-15  2:30             ` Noam Postavsky
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2015-10-14 19:46 UTC (permalink / raw)
  To: npostavs; +Cc: 21681

> Date: Wed, 14 Oct 2015 20:53:39 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 21681@debbugs.gnu.org
> 
> > Date: Wed, 14 Oct 2015 13:47:40 -0400
> > From: Noam Postavsky <npostavs@users.sourceforge.net>
> > Cc: 21681@debbugs.gnu.org
> > 
> > How about making display-warning print all TYPE symbols then?
> 
> Fine with me, but I don't know enough about display-warning and its
> uses to tell if this could cause some harm somewhere.  Maybe someone
> else will know; if you hear no objections in a few days, please go
> ahead.

Having now looked at the code, I actually don't understand why the
documentation says the symbol should be a custom group.  Nothing in
the code enforces that or relies on that, so it sounds like a
gratuitous limitation to me.  Names of custom group are usually so
general that they don't really add any useful information to the
message.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 19:46           ` Eli Zaretskii
@ 2015-10-15  2:30             ` Noam Postavsky
  0 siblings, 0 replies; 15+ messages in thread
From: Noam Postavsky @ 2015-10-15  2:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

On 10/14/15, Eli Zaretskii <eliz@gnu.org> wrote:
> Having now looked at the code, I actually don't understand why the
> documentation says the symbol should be a custom group.

I would speculate it's a way to encourage some convergence of warning
types, so that users are able to suppress several at once.

I did an rgrep on the Emacs source tree for display-warning|lwarn,
only 2 calls pass a list for TYPE, both in lisp/progmodes/python.el:

./lisp/progmodes/python.el:2247:
          (lwarn
           '(python python-shell-prompt-regexp)
./lisp/progmodes/python.el:3443:
       (t (lwarn
           '(python python-shell-completion-native-turn-on-maybe)


There are several mistaken uses of :warning or :error, and the rest
use a general symbol that says little beyond which package a warning
might be coming from; around half are custom groups, but none very
specific.

Symbols used:

(get 'alloc          'custom-group) ;=> ((gc-cons-threshold custom-variable)
(get 'todo           'custom-group) ;=> nil
(get 'org            'custom-group) ;=> ((org-babel custom-group)...
(get 'initialization 'custom-group) ;=> ((user-emacs-directory-warning
custom-variable)...
(get 'url            'custom-group) ;=> ((url-file custom-group)...
(get 'gnus-server    'custom-group) ;=> nil
(get 'mule           'custom-group) ;=> ((keyboard-coding-system
custom-variable)...
(get 'server         'custom-group) ;=> ((server-use-tcp custom-variable)...
(get 'file-error     'custom-group) ;=> nil
(get 'rmail          'custom-group) ;=> nil
(get 'check-declare  'custom-group) ;=> nil
(get 'smie           'custom-group) ;=> ((smie-blink-matching-inners
custom-variable)...
(get 'bytecomp       'custom-group) ;=> ((emacs-lisp-file-regexp
custom-variable)...
(get 'mail           'custom-group) ;=> ((mail-host-address custom-variable)...
(get 'python         'custom-group) ;=> nil
(get 'erc            'custom-group) ;=> nil
(get 'soap-client    'custom-group) ;=> nil
(get 'custom         'custom-group) ;=> nil
(get 'bzrmerge       'custom-group) ;=> nil





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-14 17:47       ` Noam Postavsky
  2015-10-14 17:53         ` Eli Zaretskii
@ 2015-10-31 22:36         ` Noam Postavsky
  2016-01-24 18:43           ` Noam Postavsky
  1 sibling, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2015-10-31 22:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

On Wed, Oct 14, 2015 at 1:47 PM, Noam Postavsky
<npostavs@users.sourceforge.net> wrote:
> On Wed, Oct 14, 2015 at 1:42 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>> Date: Wed, 14 Oct 2015 12:56:28 -0400
>>> From: Noam Postavsky <npostavs@users.sourceforge.net>
>>> own, but display-warning only prints the 1st symbol of the list so the
>>> warning text itself wouldn't change.
>>
>> I find "files" no more explanatory that "warning".  If we lack
>> infrastructure to display meaningful messages that unequivocally point
>> to the nature of the problem, let's add the missing infrastructure.
>
> How about making display-warning print all TYPE symbols then?

I've been playing a bit more with display-warning, and I think the
part in brackets is not supposed to be part of the warning's
explanation, but rather it tells you how to block it. Like gcc's
"[-Wfoo]". The problem with printing all the symbols is that it would
make the warnings using TYPE lists longer, pushing the actual warning
text to the right, and discourage use of more specific TYPEs.

Another possiblity is still to truncate to a single item, but show a
"..." button to expand it, like `eval-last-sexp' does for long lists.

Another thing I've been experimenting with is including buttons with
an action to resolve the problem in the warning text. It seems to work
pretty well, except that because *Warnings* is in special-mode <tab>
isn't bound to forward-button. It could be nice to have a
warnings-mode which does that. It could also bind e.g. `i' to
something like ignore-warning-at-point (which would customize
warning-suppress-types). But I know Emacs supposed to be in feature
freeze so maybe now is not the time to be adding new modes.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2015-10-31 22:36         ` Noam Postavsky
@ 2016-01-24 18:43           ` Noam Postavsky
  2016-01-24 18:51             ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2016-01-24 18:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

I see in the mean time that Glen Morris has changed :warning to 'files
as part of a general display-warnings fix ("Fix some display-warning
usage." 741d0afe021fbe0ff4f3933242526c684ed8c806)

So can we just fix the filename part (see attached) already, surely
this silly bug has been open long enough.

Before:

Warning (files): : ‘lexical-binding’ at end of file unreliable

After:

Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable

[-- Attachment #2: 0001-Fix-lexical-binding-at-eof-warning.patch --]
[-- Type: application/octet-stream, Size: 1000 bytes --]

From 29eba8cc81d3151f2ed2e7791c7a81205edb4687 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 24 Jan 2016 11:17:45 -0500
Subject: [PATCH] Fix lexical binding at eof warning

* files.el (hack-local-variables): Get buffer name from the
  visiting buffer.
---
 lisp/files.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 5a15c71..051bfc6 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3426,7 +3426,7 @@ local variables, but directory-local variables may still be applied."
                                   (format-message
                                    "%s: `lexical-binding' at end of file unreliable"
                                    (file-name-nondirectory
-                                    (or buffer-file-name ""))))))
+                                    (or (buffer-file-name thisbuf) ""))))))
 			      (t
 			       (ignore-errors
 				 (push (cons (if (eq var 'eval)
-- 
2.6.2.windows.1


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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2016-01-24 18:43           ` Noam Postavsky
@ 2016-01-24 18:51             ` Eli Zaretskii
  2016-01-24 19:34               ` Noam Postavsky
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2016-01-24 18:51 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Sun, 24 Jan 2016 13:43:04 -0500
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: 21681@debbugs.gnu.org
> 
> Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable
                                             ^^^^^^^^^^^^^^
But foo.el is not a file in this case.

What is the real-life use case where this is needed for a buffer that
doesn't visit a file?

Thanks.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2016-01-24 18:51             ` Eli Zaretskii
@ 2016-01-24 19:34               ` Noam Postavsky
  2016-01-25 17:07                 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2016-01-24 19:34 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

On Sun, Jan 24, 2016 at 1:51 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sun, 24 Jan 2016 13:43:04 -0500
>> From: Noam Postavsky <npostavs@users.sourceforge.net>
>> Cc: 21681@debbugs.gnu.org
>>
>> Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable
>                                              ^^^^^^^^^^^^^^
> But foo.el is not a file in this case.

Huh? Yes it is.  Perhaps you missed the bug: `display-warning' is
called from inside `with-temp-buffer`, so we need to use `thisbuf' to
reference the original buffer that we are calling
`hack-local-variables' for.  Hmm, perhaps my commit message should
have explained that better.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2016-01-24 19:34               ` Noam Postavsky
@ 2016-01-25 17:07                 ` Eli Zaretskii
  2016-01-31 15:56                   ` Noam Postavsky
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2016-01-25 17:07 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Sun, 24 Jan 2016 14:34:31 -0500
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: 21681@debbugs.gnu.org
> 
> On Sun, Jan 24, 2016 at 1:51 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Sun, 24 Jan 2016 13:43:04 -0500
> >> From: Noam Postavsky <npostavs@users.sourceforge.net>
> >> Cc: 21681@debbugs.gnu.org
> >>
> >> Warning (files): foo.el: ‘lexical-binding’ at end of file unreliable
> >                                              ^^^^^^^^^^^^^^
> > But foo.el is not a file in this case.
> 
> Huh? Yes it is.  Perhaps you missed the bug: `display-warning' is
> called from inside `with-temp-buffer`, so we need to use `thisbuf' to
> reference the original buffer that we are calling
> `hack-local-variables' for.

Right, sorry.  Yes, let's do that.





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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2016-01-25 17:07                 ` Eli Zaretskii
@ 2016-01-31 15:56                   ` Noam Postavsky
  2016-02-03 17:49                     ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Noam Postavsky @ 2016-01-31 15:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 21681

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

On Mon, Jan 25, 2016 at 12:07 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Sun, 24 Jan 2016 14:34:31 -0500
>> From: Noam Postavsky <npostavs@users.sourceforge.net>
>>
>> [...] `display-warning' is
>> called from inside `with-temp-buffer`, so we need to use `thisbuf' to
>> reference the original buffer that we are calling
>> `hack-local-variables' for.
>
> Right, sorry.  Yes, let's do that.

Ping? Resending with above explanation in commit message.

[-- Attachment #2: 0001-Fix-lexical-binding-at-eof-warning.patch --]
[-- Type: application/octet-stream, Size: 1125 bytes --]

From 1e9c294320b920f6f20daa49142de0173ed113c2 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 24 Jan 2016 11:17:45 -0500
Subject: [PATCH] Fix lexical binding at eof warning

* files.el (hack-local-variables): `display-warning' is called from
inside `with-temp-buffer`, so we need to use `thisbuf' to reference the
original buffer that we are calling `hack-local-variables' for.
---
 lisp/files.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 3898dff..b2c90bc 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3426,7 +3426,7 @@ local variables, but directory-local variables may still be applied."
                                   (format-message
                                    "%s: `lexical-binding' at end of file unreliable"
                                    (file-name-nondirectory
-                                    (or buffer-file-name ""))))))
+                                    (or (buffer-file-name thisbuf) ""))))))
 			      (t
 			       (ignore-errors
 				 (push (cons (if (eq var 'eval)
-- 
2.6.2.windows.1


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

* bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning
  2016-01-31 15:56                   ` Noam Postavsky
@ 2016-02-03 17:49                     ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2016-02-03 17:49 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 21681

> Date: Sun, 31 Jan 2016 10:56:28 -0500
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Cc: 21681@debbugs.gnu.org
> 
> Ping? Resending with above explanation in commit message.

Thanks, pushed.





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

end of thread, other threads:[~2016-02-03 17:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-13 22:51 bug#21681: [PATCH] Fix formatting of lexical-binding at eof warning Noam Postavsky
2015-10-14 16:28 ` Eli Zaretskii
2015-10-14 16:56   ` Noam Postavsky
2015-10-14 17:42     ` Eli Zaretskii
2015-10-14 17:47       ` Noam Postavsky
2015-10-14 17:53         ` Eli Zaretskii
2015-10-14 19:46           ` Eli Zaretskii
2015-10-15  2:30             ` Noam Postavsky
2015-10-31 22:36         ` Noam Postavsky
2016-01-24 18:43           ` Noam Postavsky
2016-01-24 18:51             ` Eli Zaretskii
2016-01-24 19:34               ` Noam Postavsky
2016-01-25 17:07                 ` Eli Zaretskii
2016-01-31 15:56                   ` Noam Postavsky
2016-02-03 17:49                     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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