aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-21 23:37:57 +0000
committerRichard M. Stallman1997-06-21 23:37:57 +0000
commitd0acc4ea1e8480fb31748a571680dd5f1d84babe (patch)
treee63600108332acda2bf47649fbf7d8e470a763b4
parent0eef62d5459d56b0ce7ccdc0546ff4013785af0e (diff)
downloademacs-d0acc4ea1e8480fb31748a571680dd5f1d84babe.tar.gz
emacs-d0acc4ea1e8480fb31748a571680dd5f1d84babe.zip
(widget-default-value-set): Preserve point here.
(widget-choice-action, widget-toggle-action): Not here. (widget-choice-action, widget-toggle-action): Display a message about [State]. (widget-field-action): Improve message.
-rw-r--r--lisp/wid-edit.el60
1 files changed, 30 insertions, 30 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 8e9f66f1c1e..7750fd74094 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1466,11 +1466,25 @@ If that does not exists, call the value of `widget-complete-field'."
1466 1466
1467(defun widget-default-value-set (widget value) 1467(defun widget-default-value-set (widget value)
1468 ;; Recreate widget with new value. 1468 ;; Recreate widget with new value.
1469 (save-excursion 1469 (let* ((old-pos (point))
1470 (goto-char (widget-get widget :from)) 1470 (from (copy-marker (widget-get widget :from)))
1471 (widget-apply widget :delete) 1471 (to (copy-marker (widget-get widget :to)))
1472 (widget-put widget :value value) 1472 (offset (if (and (<= from old-pos) (<= old-pos to))
1473 (widget-apply widget :create))) 1473 (if (>= old-pos (1- to))
1474 (- old-pos to 1)
1475 (- old-pos from)))))
1476 ;;??? Bug: this ought to insert the new value before deleting the old one,
1477 ;; so that markers on either side of the value automatically
1478 ;; stay on the same side. -- rms.
1479 (save-excursion
1480 (goto-char (widget-get widget :from))
1481 (widget-apply widget :delete)
1482 (widget-put widget :value value)
1483 (widget-apply widget :create))
1484 (if offset
1485 (if (< offset 0)
1486 (goto-char (+ (widget-get widget :to) offset 1))
1487 (goto-char (min (+ from offset) (1- (widget-get widget :to))))))))
1474 1488
1475(defun widget-default-value-inline (widget) 1489(defun widget-default-value-inline (widget)
1476 ;; Wrap value in a list unless it is inline. 1490 ;; Wrap value in a list unless it is inline.
@@ -1705,7 +1719,7 @@ If END is omitted, it defaults to the length of LIST."
1705(defun widget-field-action (widget &optional event) 1719(defun widget-field-action (widget &optional event)
1706 ;; Move to next field. 1720 ;; Move to next field.
1707 (widget-forward 1) 1721 (widget-forward 1)
1708 (message "To set this variable or face, invoke [State] and choose Set")) 1722 (message "To set the value, invoke [State] and choose the Set operation"))
1709 1723
1710(defun widget-field-validate (widget) 1724(defun widget-field-validate (widget)
1711 ;; Valid if the content matches `:valid-regexp'. 1725 ;; Valid if the content matches `:valid-regexp'.
@@ -1895,20 +1909,13 @@ when he invoked the menu."
1895 current) 1909 current)
1896 choices))) 1910 choices)))
1897 (widget-choose tag (reverse choices) event)))) 1911 (widget-choose tag (reverse choices) event))))
1898 ;; Try to preserve point even if it is within the widget. 1912 (when current
1899 (let* ((old-pos (point)) 1913 (widget-value-set widget
1900 (from (copy-marker (widget-get widget :from))) 1914 (widget-apply current :value-to-external
1901 (to (copy-marker (widget-get widget :to))) 1915 (widget-get current :value)))
1902 (offset (if (and (<= from old-pos) (<= old-pos to)) 1916 (widget-setup)
1903 (- old-pos from)))) 1917 (widget-apply widget :notify widget event)))
1904 (when current 1918 (message "To set the value, invoke [State] and choose the Set operation"))
1905 (widget-value-set widget
1906 (widget-apply current :value-to-external
1907 (widget-get current :value)))
1908 (widget-setup)
1909 (widget-apply widget :notify widget event))
1910 (if offset
1911 (goto-char (min (+ from offset) to))))))
1912 1919
1913(defun widget-choice-validate (widget) 1920(defun widget-choice-validate (widget)
1914 ;; Valid if we have made a valid choice. 1921 ;; Valid if we have made a valid choice.
@@ -1962,16 +1969,9 @@ when he invoked the menu."
1962 1969
1963(defun widget-toggle-action (widget &optional event) 1970(defun widget-toggle-action (widget &optional event)
1964 ;; Toggle value. 1971 ;; Toggle value.
1965 ;; Try to preserve point even if it is within the widget. 1972 (widget-value-set widget (not (widget-value widget)))
1966 (let* ((old-pos (point)) 1973 (widget-apply widget :notify widget event)
1967 (from (copy-marker (widget-get widget :from))) 1974 (message "To set the value, invoke [State] and choose the Set operation"))
1968 (to (copy-marker (widget-get widget :to)))
1969 (offset (if (and (<= from old-pos) (<= old-pos to))
1970 (- old-pos from))))
1971 (widget-value-set widget (not (widget-value widget)))
1972 (widget-apply widget :notify widget event)
1973 (if offset
1974 (goto-char (min (+ from offset) to)))))
1975 1975
1976;;; The `checkbox' Widget. 1976;;; The `checkbox' Widget.
1977 1977