From aa4589a7cfb435c704549855b1f19e335bcf3b20 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sun, 5 Feb 2012 23:33:30 +0800 Subject: [PATCH] Fix how the `character' custom type handles space chars. * lisp/wid-edit.el (widget-field-value-get): New optional arg to suppress trailing whitespace truncation. (character): Use it. Fixes: debbugs:2689 --- lisp/ChangeLog | 6 ++++++ lisp/wid-edit.el | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6a31a20f947..93dd50b5ecb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-02-05 Chong Yidong + + * wid-edit.el (widget-field-value-get): New optional arg to + suppress trailing whitespace truncation. + (character): Use it (Bug#2689). + 2012-02-05 Andreas Schwab * progmodes/gud.el (gud-pv): Use pv instead of pv1. diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 27922327f44..61bb4db558c 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1987,10 +1987,14 @@ the earlier input." (when (overlayp overlay) (delete-overlay overlay)))) -(defun widget-field-value-get (widget) - "Return current text in editing field." +(defun widget-field-value-get (widget &optional no-truncate) + "Return current text in editing field. +Normally, trailing spaces within the editing field are truncated. +But if NO-TRUNCATE is non-nil, include them." (let ((from (widget-field-start widget)) - (to (widget-field-text-end widget)) + (to (if no-truncate + (widget-field-end widget) + (widget-field-text-end widget))) (buffer (widget-field-buffer widget)) (secret (widget-get widget :secret)) (old (current-buffer))) @@ -3407,6 +3411,7 @@ To use this type, you must define :match or :match-alternatives." :format "%{%t%}: %v\n" :valid-regexp "\\`.\\'" :error "This field should contain a single character" + :value-get (lambda (w) (widget-field-value-get w t)) :value-to-internal (lambda (_widget value) (if (stringp value) value -- 2.39.2