]> code.delx.au - gnu-emacs/blobdiff - lisp/wid-edit.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / wid-edit.el
index ac2e981033165e5baca77e59687f86cf2ae84ae1..9ede9a5633f76c99eeb9066ad5003d1a241164a6 100644 (file)
@@ -1,6 +1,6 @@
 ;;; wid-edit.el --- Functions for creating and using widgets -*-byte-compile-dynamic: t; lexical-binding:t -*-
 ;;
-;; Copyright (C) 1996-1997, 1999-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 1999-2016 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Maintainer: emacs-devel@gnu.org
@@ -852,8 +852,8 @@ button end points."
     (define-key map [(shift tab)] 'widget-backward)
     (put 'widget-backward :advertised-binding [(shift tab)])
     (define-key map [backtab] 'widget-backward)
-    (define-key map [down-mouse-2] 'widget-button-click)
-    (define-key map [down-mouse-1] 'widget-button-click)
+    (define-key map [mouse-2] 'widget-button-click)
+    (define-key map [mouse-1] 'widget-button-click)
     ;; The following definition needs to avoid using escape sequences that
     ;; might get converted to ^M when building loaddefs.el
     (define-key map [(control ?m)] 'widget-button-press)
@@ -1267,7 +1267,7 @@ When not inside a field, signal an error."
 
 (defun widget-field-find (pos)
   "Return the field at POS.
-Unlike (get-char-property POS 'field), this works with empty fields too."
+Unlike (get-char-property POS \\='field), this works with empty fields too."
   (let ((fields widget-field-list)
        field found)
     (while fields
@@ -1676,7 +1676,7 @@ as the argument to `documentation-property'."
                   (cond ((functionp doc-prop)
                          (funcall doc-prop value))
                         ((symbolp doc-prop)
-                         (documentation-property value doc-prop)))))))
+                         (documentation-property value doc-prop t)))))))
     (when (and (stringp doc) (> (length doc) 0))
       ;; Remove any redundant `*' in the beginning.
       (when (eq (aref doc 0) ?*)
@@ -1789,7 +1789,13 @@ If END is omitted, it defaults to the length of LIST."
   "An embedded link."
   :button-prefix 'widget-link-prefix
   :button-suffix 'widget-link-suffix
-  :follow-link 'mouse-face
+  ;; The `follow-link' property should only be used in those contexts where the
+  ;; mouse-1 event normally doesn't follow the link, yet the `link' widget
+  ;; seems to almost always be used in contexts where (down-)mouse-1 is bound
+  ;; to `widget-button-click' and hence the "mouse-1 to mouse-2" remapping is
+  ;; not necessary (and can even be harmful).  So let's not add a :follow-link
+  ;; by default.  See (bug#22434).
+  ;; :follow-link 'mouse-face
   :help-echo "Follow the link."
   :format "%[%t%]")
 
@@ -2654,8 +2660,7 @@ Return an alist of (TYPE MATCH)."
   (save-excursion
     (let ((children (widget-get widget :children))
          (inhibit-read-only t)
-         before-change-functions
-         after-change-functions)
+         (inhibit-modification-hooks t))
       (cond (before
             (goto-char (widget-get before :entry-from)))
            (t
@@ -2679,8 +2684,7 @@ Return an alist of (TYPE MATCH)."
     (let ((buttons (copy-sequence (widget-get widget :buttons)))
          button
          (inhibit-read-only t)
-         before-change-functions
-         after-change-functions)
+         (inhibit-modification-hooks t))
       (while buttons
        (setq button (car buttons)
              buttons (cdr buttons))
@@ -2691,8 +2695,7 @@ Return an alist of (TYPE MATCH)."
     (let ((entry-from (widget-get child :entry-from))
          (entry-to (widget-get child :entry-to))
          (inhibit-read-only t)
-         before-change-functions
-         after-change-functions)
+         (inhibit-modification-hooks t))
       (widget-delete child)
       (delete-region entry-from entry-to)
       (set-marker entry-from nil)
@@ -3477,10 +3480,10 @@ themselves.  A list, for example, is defined as either nil, or a cons
 cell whose cdr itself is a list.  The obvious way to translate this
 into a widget type would be
 
-  (define-widget 'my-list 'choice
+  (define-widget \\='my-list \\='choice
     \"A list of sexps.\"
     :tag \"Sexp list\"
-    :args '((const nil) (cons :value (nil) sexp my-list)))
+    :args \\='((const nil) (cons :value (nil) sexp my-list)))
 
 Here we attempt to define my-list as a choice of either the constant
 nil, or a cons-cell containing a sexp and my-lisp.  This will not work
@@ -3489,10 +3492,10 @@ because the `choice' widget does not allow recursion.
 Using the `lazy' widget you can overcome this problem, as in this
 example:
 
-  (define-widget 'sexp-list 'lazy
+  (define-widget \\='sexp-list \\='lazy
     \"A list of sexps.\"
     :tag \"Sexp list\"
-    :type '(choice (const nil) (cons :value (nil) sexp sexp-list)))"
+    :type \\='(choice (const nil) (cons :value (nil) sexp sexp-list)))"
   :format "%{%t%}: %v"
   ;; We don't convert :type because we want to allow recursive
   ;; data structures.  This is slow, so we should not create speed
@@ -3706,9 +3709,9 @@ example:
        (widget-value-set ',(widget-get widget :parent) color)
        (let* ((buf (get-buffer "*Colors*"))
               (win (get-buffer-window buf 0)))
-         (bury-buffer buf)
-         (and win (> (length (window-list)) 1)
-              (delete-window win)))
+         (if win
+             (quit-window nil win)
+           (bury-buffer buf)))
        (pop-to-buffer ,(current-buffer))))))
 
 (defun widget-color-sample-face-get (widget)