]> code.delx.au - gnu-emacs/blobdiff - lisp/cus-edit.el
Fix the prefix action of shr-copy-url
[gnu-emacs] / lisp / cus-edit.el
index f56fb6a649e26e84b80449d5764c34fd66bab57d..60d07f9bc77624fda8d34eabbfadc9ba5bb0c5c7 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages -*- 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
 (defun custom-split-regexp-maybe (regexp)
   "If REGEXP is a string, split it to a list at `\\|'.
 You can get the original back from the result with:
-  (mapconcat 'identity result \"\\|\")
+  (mapconcat \\='identity result \"\\|\")
 
 IF REGEXP is not a string, return it unchanged."
   (if (stringp regexp)
@@ -633,7 +633,7 @@ if that fails, the doc string with `custom-guess-doc-alist'."
        (setq found (nth 1 current)
              names nil)))
     (unless found
-      (let ((doc (documentation-property symbol 'variable-documentation))
+      (let ((doc (documentation-property symbol 'variable-documentation t))
            (docs custom-guess-doc-alist))
        (when doc
          (while docs
@@ -1072,9 +1072,10 @@ are shown; the contents of those subgroups are initially hidden."
 
 ;;;###autoload
 (defun customize-mode (mode)
-  "Customize options related to the current major mode.
-If a prefix \\[universal-argument] was given (or if the current major mode has no known group),
-then prompt for the MODE to customize."
+  "Customize options related to a major or minor mode.
+By default the current major mode is used.  With a prefix
+argument or if the current major mode has no known group, prompt
+for the MODE to customize."
   (interactive
    (list
     (let ((completion-regexp-list '("-mode\\'"))
@@ -1083,8 +1084,8 @@ then prompt for the MODE to customize."
          major-mode
        (intern
         (completing-read (if group
-                             (format "Major mode (default %s): " major-mode)
-                           "Major mode: ")
+                             (format "Mode (default %s): " major-mode)
+                           "Mode: ")
                          obarray
                          'custom-group-of-mode
                          t nil nil (if group (symbol-name major-mode))))))))
@@ -1164,7 +1165,7 @@ Show the buffer in another window, but don't select it."
     (unless (eq symbol basevar)
       (message "`%s' is an alias for `%s'" symbol basevar))))
 
-(defvar customize-changed-options-previous-release "24.1"
+(defvar customize-changed-options-previous-release "24.5"
   "Version for `customize-changed-options' to refer back to by default.")
 
 ;; Packages will update this variable, so make it available.
@@ -1189,8 +1190,8 @@ and `defface'.
 
 For example, the MH-E package updates this alist as follows:
 
-     (add-to-list 'customize-package-emacs-version-alist
-                  '(MH-E (\"6.0\" . \"22.1\") (\"6.1\" . \"22.1\")
+     (add-to-list \\='customize-package-emacs-version-alist
+                  \\='(MH-E (\"6.0\" . \"22.1\") (\"6.1\" . \"22.1\")
                          (\"7.0\" . \"22.1\") (\"7.1\" . \"22.1\")
                          (\"7.2\" . \"22.1\") (\"7.3\" . \"22.1\")
                          (\"7.4\" . \"22.1\") (\"8.0\" . \"22.1\")))
@@ -1499,11 +1500,12 @@ Return non-nil if user chooses to customize, for use in
 (defcustom custom-buffer-style 'links
   "Control the presentation style for customization buffers.
 The value should be a symbol, one of:
-
-brackets: groups nest within each other with big horizontal brackets.
-links: groups have links to subgroups."
+`brackets': groups nest within each other with big horizontal brackets.
+`links': groups have links to subgroups.
+`tree': display groups as trees."
   :type '(radio (const brackets)
-               (const links))
+               (const links)
+                (const tree))
   :group 'custom-buffer)
 
 (defcustom custom-buffer-done-kill nil
@@ -1543,27 +1545,29 @@ not for everybody."
        buf))))
 
 ;;;###autoload
-(defun custom-buffer-create (options &optional name description)
+(defun custom-buffer-create (options &optional name _description)
   "Create a buffer containing OPTIONS.
 Optional NAME is the name of the buffer.
 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
 SYMBOL is a customization option, and WIDGET is a widget for editing
 that option.
 DESCRIPTION is unused."
-  (pop-to-buffer-same-window (custom-get-fresh-buffer (or name "*Customization*")))
-  (custom-buffer-create-internal options description))
+  (pop-to-buffer-same-window
+   (custom-get-fresh-buffer (or name "*Customization*")))
+  (custom-buffer-create-internal options))
 
 ;;;###autoload
-(defun custom-buffer-create-other-window (options &optional name description)
+(defun custom-buffer-create-other-window (options &optional name _description)
   "Create a buffer containing OPTIONS, and display it in another window.
 The result includes selecting that window.
 Optional NAME is the name of the buffer.
 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
 SYMBOL is a customization option, and WIDGET is a widget for editing
-that option."
+that option.
+DESCRIPTION is unused."
   (unless name (setq name "*Customization*"))
   (switch-to-buffer-other-window (custom-get-fresh-buffer name))
-  (custom-buffer-create-internal options description))
+  (custom-buffer-create-internal options))
 
 (defcustom custom-reset-button-menu t
   "If non-nil, only show a single reset button in customize buffers.
@@ -1599,7 +1603,7 @@ This button will have a menu with all three reset operations."
 
 (defcustom custom-raised-buttons (not (equal (face-valid-attribute-values :box)
                                             '(("unspecified" . unspecified))))
-  "If non-nil, indicate active buttons in a `raised-button' style.
+  "If non-nil, indicate active buttons in a raised-button style.
 Otherwise use brackets."
   :type 'boolean
   :version "21.1"
@@ -1709,7 +1713,7 @@ Operate on all settings in this buffer:\n"))
            (mapcar (lambda (entry)
                      (prog2
                          (message "Creating customization items ...%2d%%"
-                                  (/ (* 100.0 count) length))
+                                  (floor (* 100.0 count) length))
                          (widget-create (nth 1 entry)
                                         :tag (custom-unlispify-tag-name
                                               (nth 0 entry))
@@ -1748,7 +1752,7 @@ Operate on all settings in this buffer:\n"))
 on a button to invoke its action.
 Invoke [+] to expand a group, and [-] to collapse an expanded group.\n"
                         (if custom-raised-buttons
-                            "`Raised' text indicates"
+                            "Raised text indicates"
                           "Square brackets indicate")))
 
 
@@ -1965,7 +1969,7 @@ Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
 
 STATE is one of the following symbols:
 
-`nil'
+nil
    For internal use, should never occur.
 `unknown'
    For internal use, should never occur.
@@ -2457,7 +2461,7 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
   "Return documentation of VARIABLE for use in Custom buffer.
 Normally just return the docstring.  But if VARIABLE automatically
 becomes buffer local when set, append a message to that effect."
-  (format "%s%s" (documentation-property variable 'variable-documentation)
+  (format "%s%s" (documentation-property variable 'variable-documentation t)
          (if (and (local-variable-if-set-p variable)
                   (or (not (local-variable-p variable))
                       (with-temp-buffer
@@ -3115,7 +3119,7 @@ face attributes (as specified by a `default' defface entry)."
                    widget
                    (widget-get widget :default-face-attributes)))
         entry)
-    (unless (looking-back "^ *")
+    (unless (looking-back "^ *" (line-beginning-position))
       (insert ?\n))
     (insert-char ?\s (widget-get widget :extra-offset))
     (if (or alist defaults show-all)
@@ -3990,12 +3994,12 @@ If GROUPS-ONLY is non-nil, return only those members that are groups."
         ;; (indent (widget-get widget :indent))
         (prefix (widget-get widget :custom-prefix))
         (buttons (widget-get widget :buttons))
-        (tag (widget-get widget :tag))
+        (tag (substitute-command-keys (widget-get widget :tag)))
         (symbol (widget-value widget))
         (members (custom-group-members symbol
                                        (and (eq custom-buffer-style 'tree)
                                             custom-browse-only-groups)))
-        (doc (widget-docstring widget)))
+        (doc (substitute-command-keys (widget-docstring widget))))
     (cond ((and (eq custom-buffer-style 'tree)
                (eq state 'hidden)
                (or members (custom-unloaded-widget-p widget)))
@@ -4377,7 +4381,8 @@ if only the first line of the docstring is shown."))
 
 (defun custom-file (&optional no-error)
   "Return the file name for saving customizations."
-  (if (null user-init-file)
+  (if (or (null user-init-file)
+          (and (null custom-file) init-file-had-error))
       ;; Started with -q, i.e. the file containing Custom settings
       ;; hasn't been read.  Saving settings there won't make much
       ;; sense.
@@ -4406,7 +4411,9 @@ if only the first line of the docstring is shown."))
         old-buffer-name)
 
     (with-current-buffer (let ((find-file-visit-truename t))
-                          (or old-buffer (find-file-noselect filename)))
+                          (or old-buffer
+                               (let ((delay-mode-hooks t))
+                                 (find-file-noselect filename))))
       ;; We'll save using file-precious-flag, so avoid destroying
       ;; symlinks.  (If we're not already visiting the buffer, this is
       ;; handled by find-file-visit-truename, above.)
@@ -4415,7 +4422,7 @@ if only the first line of the docstring is shown."))
        (set-visited-file-name (file-chase-links filename)))
 
       (unless (eq major-mode 'emacs-lisp-mode)
-       (emacs-lisp-mode))
+        (delay-mode-hooks (emacs-lisp-mode)))
       (let ((inhibit-read-only t)
            (print-length nil)
            (print-level nil))