summaryrefslogtreecommitdiff
path: root/lisp/wid-edit.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2009-03-24 02:30:15 +0000
committerGlenn Morris <rgm@gnu.org>2009-03-24 02:30:15 +0000
commit5e5b7cb12c7caf9a4d6cd996372dc925aedf8e82 (patch)
tree8eb9cfd3ea20f5c318b9d04952d5294948f05024 /lisp/wid-edit.el
parent639239cf9922a305ba028500b85558279328e747 (diff)
downloademacs-5e5b7cb12c7caf9a4d6cd996372dc925aedf8e82.tar.gz
(widget-specify-field): Don't add a second overlay for a
field with just a newline character. (widget-field-value-get): Don't reduce fields with just a space character to null. (character): Accept newline. (Bug#2689)
Diffstat (limited to 'lisp/wid-edit.el')
-rw-r--r--lisp/wid-edit.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index ef89a01e050..5de5f2d9ab5 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -342,12 +342,16 @@ new value.")
(or (not widget-field-add-space) (widget-get widget :size))))
(if (functionp help-echo)
(setq help-echo 'widget-mouse-help))
- (when (= (char-before to) ?\n)
+ (when (and (> to (1+ from))
+ (= (char-before to) ?\n))
;; When the last character in the field is a newline, we want to
;; give it a `field' char-property of `boundary', which helps the
;; C-n/C-p act more naturally when entering/leaving the field. We
- ;; do this by making a small secondary overlay to contain just that
+ ;; do this by making a small secondary overlay to contain just that
;; one character.
+ ;; We DON'T do this if the field just consists of a newline, eg
+ ;; when specifying a character, since it breaks things (below
+ ;; does 1- to, which results in to = from). Bug#2689.
(let ((overlay (make-overlay (1- to) to nil t nil)))
(overlay-put overlay 'field 'boundary)
;; We need the real field for tabbing.
@@ -1945,7 +1949,9 @@ the earlier input."
(set-buffer buffer)
(while (and size
(not (zerop size))
- (> to from)
+ ;; Bug#2689. Don't allow this loop to reduce a
+ ;; character field to zero size if it contains a space.
+ (> to (1+ from))
(eq (char-after (1- to)) ?\s))
(setq to (1- to)))
(let ((result (buffer-substring-no-properties from to)))
@@ -3450,7 +3456,8 @@ To use this type, you must define :match or :match-alternatives."
:value 0
:size 1
:format "%{%t%}: %v\n"
- :valid-regexp "\\`.\\'"
+ ;; `.' does not match newline, but newline is a valid character.
+ :valid-regexp "\\`\\(.\\|\n\\)\\'"
:error "This field should contain a single character"
:value-to-internal (lambda (widget value)
(if (stringp value)