diff options
| author | Glenn Morris | 2009-03-24 02:30:15 +0000 |
|---|---|---|
| committer | Glenn Morris | 2009-03-24 02:30:15 +0000 |
| commit | 5e5b7cb12c7caf9a4d6cd996372dc925aedf8e82 (patch) | |
| tree | 8eb9cfd3ea20f5c318b9d04952d5294948f05024 | |
| parent | 639239cf9922a305ba028500b85558279328e747 (diff) | |
| download | emacs-5e5b7cb12c7caf9a4d6cd996372dc925aedf8e82.tar.gz emacs-5e5b7cb12c7caf9a4d6cd996372dc925aedf8e82.zip | |
(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)
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 15 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d3978f34feb..886df2dd745 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2009-03-24 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * wid-edit.el (widget-specify-field): Don't add a second overlay for a | ||
| 4 | field with just a newline character. | ||
| 5 | (widget-field-value-get): Don't reduce fields with just a space | ||
| 6 | character to null. | ||
| 7 | (character): Accept newline. (Bug#2689) | ||
| 8 | |||
| 1 | 2009-03-24 Kenichi Handa <handa@m17n.org> | 9 | 2009-03-24 Kenichi Handa <handa@m17n.org> |
| 2 | 10 | ||
| 3 | * international/fontset.el (font-encoding-alist): Add an entry for | 11 | * international/fontset.el (font-encoding-alist): Add an entry for |
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.") | |||
| 342 | (or (not widget-field-add-space) (widget-get widget :size)))) | 342 | (or (not widget-field-add-space) (widget-get widget :size)))) |
| 343 | (if (functionp help-echo) | 343 | (if (functionp help-echo) |
| 344 | (setq help-echo 'widget-mouse-help)) | 344 | (setq help-echo 'widget-mouse-help)) |
| 345 | (when (= (char-before to) ?\n) | 345 | (when (and (> to (1+ from)) |
| 346 | (= (char-before to) ?\n)) | ||
| 346 | ;; When the last character in the field is a newline, we want to | 347 | ;; When the last character in the field is a newline, we want to |
| 347 | ;; give it a `field' char-property of `boundary', which helps the | 348 | ;; give it a `field' char-property of `boundary', which helps the |
| 348 | ;; C-n/C-p act more naturally when entering/leaving the field. We | 349 | ;; C-n/C-p act more naturally when entering/leaving the field. We |
| 349 | ;; do this by making a small secondary overlay to contain just that | 350 | ;; do this by making a small secondary overlay to contain just that |
| 350 | ;; one character. | 351 | ;; one character. |
| 352 | ;; We DON'T do this if the field just consists of a newline, eg | ||
| 353 | ;; when specifying a character, since it breaks things (below | ||
| 354 | ;; does 1- to, which results in to = from). Bug#2689. | ||
| 351 | (let ((overlay (make-overlay (1- to) to nil t nil))) | 355 | (let ((overlay (make-overlay (1- to) to nil t nil))) |
| 352 | (overlay-put overlay 'field 'boundary) | 356 | (overlay-put overlay 'field 'boundary) |
| 353 | ;; We need the real field for tabbing. | 357 | ;; We need the real field for tabbing. |
| @@ -1945,7 +1949,9 @@ the earlier input." | |||
| 1945 | (set-buffer buffer) | 1949 | (set-buffer buffer) |
| 1946 | (while (and size | 1950 | (while (and size |
| 1947 | (not (zerop size)) | 1951 | (not (zerop size)) |
| 1948 | (> to from) | 1952 | ;; Bug#2689. Don't allow this loop to reduce a |
| 1953 | ;; character field to zero size if it contains a space. | ||
| 1954 | (> to (1+ from)) | ||
| 1949 | (eq (char-after (1- to)) ?\s)) | 1955 | (eq (char-after (1- to)) ?\s)) |
| 1950 | (setq to (1- to))) | 1956 | (setq to (1- to))) |
| 1951 | (let ((result (buffer-substring-no-properties from to))) | 1957 | (let ((result (buffer-substring-no-properties from to))) |
| @@ -3450,7 +3456,8 @@ To use this type, you must define :match or :match-alternatives." | |||
| 3450 | :value 0 | 3456 | :value 0 |
| 3451 | :size 1 | 3457 | :size 1 |
| 3452 | :format "%{%t%}: %v\n" | 3458 | :format "%{%t%}: %v\n" |
| 3453 | :valid-regexp "\\`.\\'" | 3459 | ;; `.' does not match newline, but newline is a valid character. |
| 3460 | :valid-regexp "\\`\\(.\\|\n\\)\\'" | ||
| 3454 | :error "This field should contain a single character" | 3461 | :error "This field should contain a single character" |
| 3455 | :value-to-internal (lambda (widget value) | 3462 | :value-to-internal (lambda (widget value) |
| 3456 | (if (stringp value) | 3463 | (if (stringp value) |