unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21771: 25.0.50; Can't customize whitespace-display-mappings
@ 2015-10-27 20:58 Ivan Andrus
  2015-12-30  3:38 ` Ivan Andrus
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Andrus @ 2015-10-27 20:58 UTC (permalink / raw)
  To: 21771

This might be related to bug #2689,
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2689

;; emacs -Q
;; Evaluated
(require 'whitespace)
(customize-variable 'whitespace-display-mappings)
;; Change anything, say deleting one of space mappings
;; Try to save
;; Get the error
custom-variable-set: This field should contain a single character

-Ivan


In GNU Emacs 25.0.50.6 (x86_64-apple-darwin14.5.0, NS appkit-1348.17
Version 10.10.5 (Build 14F27))
of 2015-10-21
Repository revision: ecba9093844fb32756923e3124f6c1dbc0dc7a79
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
'configure --with-ns PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig --with-xpm'

Configured features:
JPEG RSVG IMAGEMAGICK DBUS ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Resetting customization items...done
Creating customization setup...done
You can run the command ‘customize-variable’ with M-x c-var RET
Creating customization setup...done
custom-variable-set: This field should contain a single character [2 times]
Mark set [2 times]
kill-region: Buffer is read-only: #<buffer *Messages*>
Mark set
<C-s-268632064> is undefined
Undo! [2 times]

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils filecache whitespace help-fns help-mode
cus-edit easymenu cus-start cus-load wid-edit cl-loaddefs pcase cl-lib
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 106811 7389)
(symbols 48 20947 0)
(miscs 40 721 530)
(strings 32 17666 4716)
(string-bytes 1 492986)
(vectors 16 11943)
(vector-slots 8 424806 7171)
(floats 8 141 392)
(intervals 56 780 11)
(buffers 976 14))





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

* bug#21771: 25.0.50; Can't customize whitespace-display-mappings
  2015-10-27 20:58 bug#21771: 25.0.50; Can't customize whitespace-display-mappings Ivan Andrus
@ 2015-12-30  3:38 ` Ivan Andrus
  2016-01-01  2:17   ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Ivan Andrus @ 2015-12-30  3:38 UTC (permalink / raw)
  To: 21771

Ivan Andrus <darthandrus@gmail.com> writes:

> This might be related to bug #2689,
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2689
>
> ;; emacs -Q
> ;; Evaluated
> (require 'whitespace)
> (customize-variable 'whitespace-display-mappings)
> ;; Change anything, say deleting one of space mappings
> ;; Try to save
> ;; Get the error
> custom-variable-set: This field should contain a single character
>
> -Ivan

It turns out this is due to one of the characters being a newline.
There are two problems.  First, the validation regex doesn't match a
newline.  This is easily addressed with the following patch:

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index d0410aa..55e8ac7 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3400,7 +3400,7 @@ 'character
   :value 0
   :size 1
   :format "%{%t%}: %v\n"
-  :valid-regexp "\\`.\\'"
+  :valid-regexp "\\`\\(.\\|\n\\)\\'"
   :error "This field should contain a single character"
   :value-get (lambda (w) (widget-field-value-get w t))
   :value-to-internal (lambda (_widget value)


Second, a string consisting of only a newline is returned as an empty
string from `widget-field-value-get' even with `no-truncate' non-nil.  I
have worked around this, but I suspect it's a suboptimal solution.  It
seems like the special handling of newlines is probably intended, so a
"proper" solution might be tricky.

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 55e8ac7..7ff4ac2 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -3406,7 +3406,9 @@ 'character
   :value-to-internal (lambda (_widget value)
                       (if (stringp value)
                           value
-                        (char-to-string value)))
+                        (if (eq value ?\n)
+                            "\n\n"
+                          (char-to-string value))))
   :value-to-external (lambda (_widget value)
                       (if (stringp value)
                           (aref value 0)


Any pointers as to a better fix (or if this is sufficient) and/or how to
write a test for this would be much appreciated.

-Ivan






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

* bug#21771: 25.0.50; Can't customize whitespace-display-mappings
  2015-12-30  3:38 ` Ivan Andrus
@ 2016-01-01  2:17   ` Glenn Morris
  2016-01-01 23:18     ` Ivan Andrus
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2016-01-01  2:17 UTC (permalink / raw)
  To: Ivan Andrus; +Cc: 21771

Ivan Andrus wrote:

>> This might be related to bug #2689,
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2689

> -  :valid-regexp "\\`.\\'"
> +  :valid-regexp "\\`\\(.\\|\n\\)\\'"

Note that this reintroduces part of the patch for #2689, which I had to
revert since it caused a worse problem (#3136) than the one it solved.
(I haven't checked whether the same issue applies now to your patch, but
you should.)





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

* bug#21771: 25.0.50; Can't customize whitespace-display-mappings
  2016-01-01  2:17   ` Glenn Morris
@ 2016-01-01 23:18     ` Ivan Andrus
  0 siblings, 0 replies; 4+ messages in thread
From: Ivan Andrus @ 2016-01-01 23:18 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 21771

On Thu, Dec 31, 2015 at 7:17 PM, Glenn Morris <rgm@gnu.org> wrote:
> Ivan Andrus wrote:
>
>>> This might be related to bug #2689,
>>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2689
>
>> -  :valid-regexp "\\`.\\'"
>> +  :valid-regexp "\\`\\(.\\|\n\\)\\'"
>
> Note that this reintroduces part of the patch for #2689, which I had to
> revert since it caused a worse problem (#3136) than the one it solved.
> (I haven't checked whether the same issue applies now to your patch, but
> you should.)

Thanks for bringing that to my attention.  My patch doesn’t cause 3136,
because it doesn’t really solve the problem.  It just works around it by
using "\n\n" to mean "\n".

It does make things a little weird because there is a difference between
when it starts out as a newline and when it’s changed to a newline.  That
is, with my patch, if you customize white `whitespace-display-mappings’,
you’ll see it displayed as "\n\n".  If you change it to (say) "d" it
will be displayed as "d\n".  It saves 'd' fine, but if you customize it
again it will display as "d".  Changing this to "\n" will cause it to
display as "\n" and it will save "\n".  Customizing again will show "\n\n"
again.

But given that the alternative causes #3136, maybe it’s not so bad.

-Ivan





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

end of thread, other threads:[~2016-01-01 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 20:58 bug#21771: 25.0.50; Can't customize whitespace-display-mappings Ivan Andrus
2015-12-30  3:38 ` Ivan Andrus
2016-01-01  2:17   ` Glenn Morris
2016-01-01 23:18     ` Ivan Andrus

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