GNU bug report logs -
#14710
add-file-local-variable vs. unquoted string
Previous Next
Reported by: jidanni <at> jidanni.org
Date: Mon, 24 Jun 2013 21:05:03 UTC
Severity: wishlist
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14710 in the body.
You can then email your comments to 14710 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Mon, 24 Jun 2013 21:05:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
jidanni <at> jidanni.org
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 24 Jun 2013 21:05:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Try
M-x add-file-local-variable
compile-command
a b c
Note how b c are thrown away.
Yes the user should have typed "a b c",
but still some warning should be printed upon throwing them away.
Package: emacs-snapshot
Version: 2:20130618-1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Mon, 24 Jun 2013 23:51:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 14710 <at> debbugs.gnu.org (full text, mbox):
> Try
> M-x add-file-local-variable
> compile-command
> a b c
>
> Note how b c are thrown away.
That's because `add-file-local-variable' takes care about writing
only correct values that could be read later without errors.
> Yes the user should have typed "a b c",
> but still some warning should be printed upon throwing them away.
I have no idea how such a warning could be produced, and even
if we will found a way to detect the situation when it should be
displayed, you won't see it anyway because it will be instantaneously
overwritten in the echo area by another recently added message:
"For this change to take effect revisit file using `revert-buffer'".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Mon, 24 Jun 2013 23:57:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 14710 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov wrote:
> displayed, you won't see it anyway because it will be instantaneously
> overwritten in the echo area by another recently added message:
> "For this change to take effect revisit file using `revert-buffer'".
Could use display-warning.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Tue, 25 Jun 2013 06:15:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 14710 <at> debbugs.gnu.org (full text, mbox):
>> displayed, you won't see it anyway because it will be instantaneously
>> overwritten in the echo area by another recently added message:
>> "For this change to take effect revisit file using `revert-buffer'".
>
> Could use display-warning.
display-warning pops up a new window, and this changes the
window configuration that might be undesirable for users.
I wonder why display-warning doesn't support the warning display
in the echo area? I see no problem with displaying multi-line
messages in the echo area.
But anyway for the given report it seems too late to display
the warning after a wrong value is inserted to the buffer.
I suggest to display the warning before entering a string value
by changing the prompt from
Add compile-command with value: a b c
to
Add compile-command with value (use quotes for strings): "a b c"
=== modified file 'lisp/files-x.el'
--- lisp/files-x.el 2013-06-19 22:39:41 +0000
+++ lisp/files-x.el 2013-06-25 06:09:04 +0000
@@ -88,7 +88,8 @@ (defun read-file-local-variable-value (v
(format "Add %s with value: " variable))
default))
(t
- (read (read-string (format "Add %s with value: " variable)
+ (read (read-string (format "Add %s with value (use quotes for strings): "
+ variable)
nil 'set-variable-value-history
(format "%S"
(cond ((eq variable 'unibyte) t)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Tue, 25 Jun 2013 06:57:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 14710 <at> debbugs.gnu.org (full text, mbox):
> display-warning pops up a new window, and this changes the
> window configuration that might be undesirable for users.
It could use `with-help-window' so `q' removes the window as quietly as
possible.
> I wonder why display-warning doesn't support the warning display
> in the echo area? I see no problem with displaying multi-line
> messages in the echo area.
Strictly spoken, this changes the window configuration as well because
it has to change the size of at least one other window.
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Tue, 25 Jun 2013 07:43:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 14710 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> jurta.org> writes:
> - (read (read-string (format "Add %s with value: " variable)
> + (read (read-string (format "Add %s with value (use quotes for strings): "
> + variable)
Just say it's a sexp. Strings are not special here.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Tue, 25 Jun 2013 13:08:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
jidanni <at> jidanni.org
:
bug acknowledged by developer.
(Tue, 25 Jun 2013 13:08:04 GMT)
Full text and
rfc822 format available.
Message #25 received at 14710-done <at> debbugs.gnu.org (full text, mbox):
> Try
> M-x add-file-local-variable
> compile-command
> a b c
> Note how b c are thrown away.
> Yes the user should have typed "a b c",
> but still some warning should be printed upon throwing them away.
Good point. I fixed it with the patch below, which uses
read-from-minibuffer (with a non-nil `read' argument) instead of
read-string, so it re-uses the check that was already used when reading
an Elisp expression.
Stefan
=== modified file 'lisp/files-x.el'
--- lisp/files-x.el 2013-06-18 20:38:43 +0000
+++ lisp/files-x.el 2013-06-25 12:59:31 +0000
@@ -71,12 +69,14 @@
(format "Add %s with value: " variable))
default))
(t
- (read (read-string (format "Add %s with value: " variable)
- nil 'set-variable-value-history
- (format "%S"
+ (let ((default (format "%S"
(cond ((eq variable 'unibyte) t)
((boundp variable)
- (symbol-value variable))))))))))
+ (symbol-value variable)))))
+ (minibuffer-completing-symbol t))
+ (read-from-minibuffer (format "Add %s with value: " variable)
+ nil read-expression-map t
+ 'set-variable-value-history)))))
(defun read-file-local-variable-mode ()
"Read per-directory file-local variable's mode using completion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Tue, 25 Jun 2013 13:58:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 14710-done <at> debbugs.gnu.org (full text, mbox):
You're a wiz.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Tue, 25 Jun 2013 20:20:03 GMT)
Full text and
rfc822 format available.
Message #31 received at 14710 <at> debbugs.gnu.org (full text, mbox):
> Good point. I fixed it with the patch below, which uses
> read-from-minibuffer (with a non-nil `read' argument) instead of
> read-string, so it re-uses the check that was already used when reading
> an Elisp expression.
FWIW, when I wrote `read-file-local-variable-value' I copied its code:
(read (read-string (format "Add %s with value (use quotes for strings): "
variable)
nil 'set-variable-value-history
(format "%S" ...
from `set-variable':
(read
(read-string prompt nil
'set-variable-value-history
(format "%S" ...
So `set-variable' seems to have the same problem, although
after entering a string without quotes with e.g.
`M-x set-variable RET compile-command RET a b c RET'
it checks `custom-type' of the entered value and reports the
error "Value `a' does not match type string of compile-command".
Perhaps this is not too problematic as long as `set-variable' is used
only for customizable options, and not for ordinary variables.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14710
; Package
emacs
.
(Wed, 26 Jun 2013 00:52:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 14710 <at> debbugs.gnu.org (full text, mbox):
> So `set-variable' seems to have the same problem, although
Indeed, thanks,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 24 Jul 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 339 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.