Update icicles
[emacs.git] / .emacs.d / elisp / icicle / icicles-cmd2.el
index fbe8152..2f77e55 100644 (file)
@@ -4,28 +4,32 @@
 ;; Description: Top-level commands for Icicles
 ;; Author: Drew Adams
 ;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
-;; Copyright (C) 1996-2014, Drew Adams, all rights reserved.
+;; Copyright (C) 1996-2015, Drew Adams, all rights reserved.
 ;; Created: Thu May 21 13:31:43 2009 (-0700)
-;; Last-Updated: Sun May 11 12:43:23 2014 (-0700)
+;; Last-Updated: Mon Jan 26 09:24:48 2015 (-0800)
 ;;           By: dradams
-;;     Update #: 6839
+;;     Update #: 7111
 ;; URL: http://www.emacswiki.org/icicles-cmd2.el
 ;; Doc URL: http://www.emacswiki.org/Icicles
 ;; Keywords: extensions, help, abbrev, local, minibuffer,
 ;;           keys, apropos, completion, matching, regexp, command
-;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x
 ;;
 ;; Features that might be required by this library:
 ;;
-;;   `apropos', `apropos-fn+var', `avoid', `cl', `cus-edit',
-;;   `cus-face', `cus-load', `cus-start', `cus-theme', `doremi',
-;;   `easymenu', `el-swank-fuzzy', `ffap', `ffap-', `frame-cmds',
-;;   `frame-fns', `fuzzy', `fuzzy-match', `hexrgb', `icicles-cmd1',
-;;   `icicles-fn', `icicles-mcmd', `icicles-opt', `icicles-var',
-;;   `image-dired', `kmacro', `levenshtein', `misc-fns', `mouse3',
-;;   `mwheel', `naked', `regexp-opt', `ring', `second-sel',
-;;   `strings', `thingatpt', `thingatpt+', `wid-edit', `wid-edit+',
-;;   `widget'.
+;;   `apropos', `apropos+', `apropos-fn+var', `avoid', `bookmark',
+;;   `bookmark+', `bookmark+-1', `bookmark+-bmu', `bookmark+-key',
+;;   `bookmark+-lit', `cl', `cmds-menu', `cus-edit', `cus-face',
+;;   `cus-load', `cus-start', `cus-theme', `doremi', `easymenu',
+;;   `el-swank-fuzzy', `ffap', `ffap-', `fit-frame', `frame-cmds',
+;;   `frame-fns', `fuzzy', `fuzzy-match', `help+20', `hexrgb',
+;;   `icicles-cmd1', `icicles-fn', `icicles-mcmd', `icicles-opt',
+;;   `icicles-var', `image-dired', `info', `info+20', `kmacro',
+;;   `levenshtein', `menu-bar', `menu-bar+', `misc-cmds', `misc-fns',
+;;   `mouse3', `mwheel', `naked', `package', `pp', `pp+',
+;;   `regexp-opt', `ring', `second-sel', `strings', `thingatpt',
+;;   `thingatpt+', `unaccent', `w32browser-dlgopen', `wid-edit',
+;;   `wid-edit+', `widget'.
 ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;;    (+)`icicle-choose-faces', (+)`icicle-choose-invisible-faces',
 ;;    (+)`icicle-choose-visible-faces', (+)`icicle-comint-command',
 ;;    (+)`icicle-comint-search', (+)`icicle-compilation-search',
-;;    (+)`icicle-complete-keys', (+)`icicle-complete-menu-bar',
-;;    `icicle-complete-thesaurus-entry', (+)`icicle-doc',
-;;    (+)`icicle-exchange-point-and-mark',
+;;    `icicle-complete', (+)`icicle-complete-keys',
+;;    (+)`icicle-complete-menu-bar',
+;;    `icicle-complete-thesaurus-entry', `icicle-describe-package',
+;;    (+)`icicle-doc', (+)`icicle-exchange-point-and-mark',
 ;;    (+)`icicle-find-file-all-tags',
 ;;    (+)`icicle-find-file-all-tags-other-window',
 ;;    (+)`icicle-find-file-all-tags-regexp',
 ;;    (+)`icicle-find-file-tagged-other-window', (+)`icicle-font',
 ;;    (+)`icicle-font-lock-keyword', (+)`icicle-frame-bg',
 ;;    (+)`icicle-frame-fg', (+)`icicle-fundoc',
-;;    (+)`icicle-goto-global-marker',
+;;    (+)`icicle-goto-any-marker', (+)`icicle-goto-global-marker',
 ;;    (+)`icicle-goto-global-marker-or-pop-global-mark',
 ;;    (+)`icicle-goto-marker',
 ;;    (+)`icicle-goto-marker-or-set-mark-command',
 ;;    (+)`icicle-hide-faces', (+)`icicle-hide-only-faces',
 ;;    `icicle-hide/show-comments', (+)`icicle-imenu',
 ;;    (+)`icicle-imenu-command', (+)`icicle-imenu-command-full',
-;;    (+)`icicle-imenu-face-full', (+)`icicle-imenu-face-full',
+;;    (+)`icicle-imenu-face', (+)`icicle-imenu-face-full',
 ;;    (+)`icicle-imenu-full', (+)`icicle-imenu-key-explicit-map',
 ;;    (+)`icicle-imenu-key-explicit-map-full',
 ;;    (+)`icicle-imenu-key-implicit-map',
 ;;    (+)`icicle-occur-dired-marked-recursive',
 ;;    (+)`icicle-pick-color-by-name', (+)`icicle-plist',
 ;;    `icicle-previous-visible-thing', `icicle-read-color',
-;;    `icicle-read-color-wysiwyg', `icicle-save-string-to-variable',
+;;    `icicle-read-color-WYSIWYG', `icicle-save-string-to-variable',
 ;;    (+)`icicle-search', (+)`icicle-search-all-tags-bookmark',
 ;;    (+)`icicle-search-all-tags-regexp-bookmark',
 ;;    (+)`icicle-search-autofile-bookmark',
 ;;    (+)`icicle-show-only-faces', (+)`icicle-synonyms',
 ;;    (+)`icicle-tag-a-file', (+)`icicle-tags-search',
 ;;    (+)`icicle-untag-a-file', (+)`icicle-vardoc',
-;;    (+)`icicle-where-is', (+)`synonyms', (+)`what-which-how'.
+;;    (+)`icicle-where-is', (+)`icicle-wide-n', (+)`synonyms',
+;;    (+)`what-which-how'.
 ;;
 ;;  Non-interactive functions defined here:
 ;;
 ;;    `icicle-char-properties-in-buffers',
 ;;    `icicle-choose-anything-candidate',
 ;;    `icicle-choose-candidate-of-type',
+;;    `icicle-color-from-multi-completion-input',
 ;;    `icicle-cmd2-after-load-bookmark+',
 ;;    `icicle-cmd2-after-load-hexrgb',
 ;;    `icicle-cmd2-after-load-highlight',
 ;;    `icicle-comint-search-send-input', `icicle-compilation-hook-fn',
 ;;    `icicle-compilation-search-in-context-fn',
 ;;    `icicle-complete-keys-1', `icicle-complete-keys-action',
-;;    `icicle-defined-thing-p', `icicle-doc-action',
-;;    `icicle-fn-doc-minus-sig',
+;;    `icicle-doc-action', `icicle-fn-doc-minus-sig',
 ;;    `icicle-get-anything-actions-for-type',
 ;;    `icicle-get-anything-cached-candidates',
 ;;    `icicle-get-anything-candidates',
 ;;    `icicle-next-visible-thing-1', `icicle-next-visible-thing-2',
 ;;    `icicle-next-visible-thing-and-bounds',
 ;;    `icicle-ORIG-read-color', `icicle-ORIG-widget-color-complete',
+;;    `icicle-pick-color-by-name-1',
 ;;    `icicle-pick-color-by-name-action',
 ;;    `icicle-previous-single-char-property-change',
 ;;    `icicle-read-args-for-set-completion-methods',
 ;;    `icicle-search-thing-scan', `icicle-search-where-arg',
 ;;    `icicle-set-completion-methods-for-command',
 ;;    `icicle-things-alist', `icicle-this-command-keys-prefix',
-;;    `icicle-update-f-l-keywords', `icicle-widget-color-complete',
-;;    `icicle-WYSIWYG-font'.
+;;    `icicle-update-f-l-keywords', `icicle-wide-n-action',
+;;    `icicle-widget-color-complete', `icicle-WYSIWYG-font'.
 ;;
 ;;  Internal variables defined here:
 ;;
 (eval-when-compile (require 'comint))
   ;; comint-check-proc, comint-copy-old-input, comint-get-old-input, comint-input-ring,
   ;; comint-prompt-regexp, comint-send-input
+(eval-when-compile (require 'completion)) ;; completion-string
 (eval-when-compile (require 'imenu)) ;; imenu-syntax-alist
 (eval-when-compile (require 'compile)) ;; compilation-find-buffer
 (eval-when-compile (require 'info)) ;; Info-goto-node
   ;; icicle-search-overlays, icicle-search-refined-overlays, icicle-search-replacement,
   ;; icicle-transform-before-sort-p, icicle-vardoc-last-initial-cand-set, icicle-whole-candidate-as-text-prop-p
 (require 'icicles-fn)                   ; (This is required anyway by `icicles-mcmd.el'.)
-  ;; icicle-candidate-short-help, icicle-completing-read-history, icicle-highlight-lighter,
-  ;; icicle-insert-cand-in-minibuffer, icicle-some, icicle-read-regexp, icicle-string-match-p, icicle-unlist
+  ;; icicle-alist-key-match, icicle-candidate-short-help, icicle-completing-read-history,
+  ;; icicle-defined-thing-p, icicle-highlight-lighter, icicle-insert-cand-in-minibuffer, icicle-some,
+  ;; icicle-read-regexp, icicle-string-match-p, icicle-unlist
 (require 'icicles-cmd1)
   ;; icicle-bookmark-cleanup, icicle-bookmark-cleanup-on-quit, icicle-bookmark-cmd, icicle-bookmark-help-string,
   ;; icicle-bookmark-propertize-candidate, icicle-buffer-list, icicle-explore, icicle-face-list,
 (defvar anything-idle-delay)            ; In `anything.el'
 (defvar bmkp-non-file-filename)         ; In `bookmark+-1.el'
 (defvar bmkp-sorted-alist)              ; In `bookmark+-1.el'
+(defvar cmpl-cdabbrev-reset-p)          ; In `completion.el'
+(defvar cmpl-current-index)             ; In `completion.el'
+(defvar cmpl-initialized-p)             ; In `completion.el'
+(defvar cmpl-last-insert-location)      ; In `completion.el'
+(defvar cmpl-leave-point-at-start)      ; In `completion.el'
+(defvar cmpl-obarray)                   ; In `completion.el'
+(defvar cmpl-original-string)           ; In `completion.el'
+(defvar cmpl-cdabbrev-reset-p)          ; In `completion.el'
+(defvar cmpl-symbol-end)                ; In `completion.el'
+(defvar cmpl-symbol-start)              ; In `completion.el'
+(defvar cmpl-test-regexp)               ; In `completion.el'
+(defvar cmpl-test-string)               ; In `completion.el'
+(defvar cmpl-tried-list)                ; In `completion.el'
+(defvar completion-cdabbrev-prompt-flag) ; In `completion.el'
+(defvar completion-prefix-min-length)   ; In `completion.el'
+(defvar completion-prompt-speed-threshold) ; In `completion.el'
+(defvar completion-to-accept)           ; In `completion.el'
 (defvar er/try-expand-list)             ; In `expand-region.el'
 (defvar eyedrop-picked-background)      ; In `eyedrop.el' or `palette.el'
 (defvar eyedrop-picked-foreground)      ; In `eyedrop.el' or `palette.el'
 (defvar hlt-act-on-any-face-flag)       ; In `highlight.el'
 (defvar icicle-complete-keys-ignored-prefix-keys) ; In `icicles-var.el' (Emacs 22+)
 (defvar icicle-complete-keys-self-insert-ranges) ; In `icicles-var.el' (Emacs 22+)
+(defvar icicle-face-completing-p)       ; Here
+(defvar icicle-package-completing-p)    ; Here
 (defvar icicle-search-ecm)              ; In `icicle-search'
 (defvar icicle-track-pt)                ; In `icicle-insert-thesaurus-entry'
-(defvar replace-count)                  ; In `replace.el'.
+(defvar imenu-after-jump-hook)          ; In `imenu.el' (Emacs 22+)
+(defvar replace-count)                  ; In `replace.el'
+(defvar wide-n-lighter-narrow-part)     ; In `wide-n.el'
+(defvar wide-n-restrictions)            ; In `wide-n.el'
 
 ;; (< emacs-major-version 21)
 (defvar tooltip-mode)                   ; In `tooltip.el'
@@ -513,10 +544,10 @@ In other words, this command is essentially just a convenience." ; Doc string
     ((enable-recursive-minibuffers           t) ; In case we read input, e.g. File changed on disk...
      (completion-ignore-case                 bookmark-completion-ignore-case)
      (prompt                                 "Bookmark `C-M-j' TAGS: ")
-     (icicle-list-use-nth-parts              '(1))
      (icicle-dot-string                      (icicle-anychar-regexp))
      (icicle-candidate-properties-alist      '((2 (face bookmark-menu-heading))))
      (icicle-multi-completing-p              t)
+     (icicle-bookmark-completing-p           t)
      (icicle-list-use-nth-parts              '(1))
      (icicle-transform-function              (and (not (interactive-p))  icicle-transform-function))
      (icicle-whole-candidate-as-text-prop-p  t)
@@ -594,7 +625,7 @@ In other words, this command is essentially just a convenience." ; Doc string
      (icicle-dot-string                      (icicle-anychar-regexp))
      (icicle-candidate-properties-alist      '((2 (face icicle-msg-emphasis))))
      (icicle-multi-completing-p              t)
-     (icicle-list-use-nth-parts              '(1))
+     (icicle-bookmark-completing-p           t)
      (icicle-transform-function              (and (not (interactive-p))  icicle-transform-function))
      (icicle-whole-candidate-as-text-prop-p  t)
      (icicle-transform-before-sort-p         t)
@@ -669,6 +700,7 @@ During completion (`*' means this requires library `Bookmark+')\\<minibuffer-loc
 can use the following keys:
    C-c C-d      - change the `default-directory' (a la `cd')
    C-c +        - create a new directory
+   C-backspace  - go up one directory level
    \\[icicle-all-candidates-list-alt-action]          - open Dired on the currently matching file names
    \\[icicle-delete-candidate-object]     - delete candidate file or (empty) dir
  * C-x C-t *    - narrow to files with all of the tags you specify
@@ -785,6 +817,7 @@ During completion (`*' means this requires library `Bookmark+')\\<minibuffer-loc
 can use the following keys:
    C-c C-d      - change the `default-directory' (a la `cd')
    C-c +        - create a new directory
+   C-backspace  - go up one directory level
    \\[icicle-all-candidates-list-alt-action]          - open Dired on the currently matching file names
    \\[icicle-delete-candidate-object]     - delete candidate file or (empty) dir
  * C-x C-t *    - narrow to files with all of the tags you specify
@@ -1117,9 +1150,50 @@ at point, or if none then the visited file."
   (when (and (fboundp 'read-color)  (not (fboundp 'icicle-ORIG-read-color))) ; Exists with Emacs 23+.
     (fset 'icicle-ORIG-read-color (symbol-function 'read-color))) ; Not used, but save it anyway.
 
+  (defun icicle-color-from-multi-completion-input (raw-input msgp)
+    "Get color from user RAW-INPUT for color multi-completion candidates.
+The arguments are the same as for `icicle-read-color-WYSIWYG'."
+    (let ((mouse-pseudo-color-p  nil)
+          color)
+      (when (string= "" raw-input) (icicle-user-error "No such color: %S" raw-input))
+      (cond ((string-match "\\`'.+': " raw-input)
+             (let ((icicle-list-nth-parts-join-string  ": ")
+                   (icicle-list-join-string            ": ")
+                   (icicle-list-use-nth-parts          '(2)))
+               (setq color  (icicle-transform-multi-completion raw-input))))
+            ((fboundp 'eyedrop-foreground-at-point)
+             (cond ((string-match "^\*mouse-2 foreground\*" raw-input)
+                    (setq color  (prog1 (eyedrop-foreground-at-mouse
+                                         (read-event
+                                          "Click `mouse-2' anywhere to choose foreground color"))
+                                   (read-event)) ; Discard mouse up event.
+                          mouse-pseudo-color-p  t))
+                   ((string-match "^\*mouse-2 background\*" raw-input)
+                    (setq color  (prog1 (eyedrop-background-at-mouse
+                                         (read-event
+                                          "Click `mouse-2' anywhere to choose background color"))
+                                   (read-event)) ; Discard mouse up event.
+                          mouse-pseudo-color-p  t)))
+             (setq color  (icicle-transform-multi-completion
+                           (if mouse-pseudo-color-p
+                               (concat color ": " (hexrgb-color-name-to-hex color))
+                             raw-input)))))
+
+      ;; If the user did not complete but just entered a color name, then transformation can return "".
+      ;; In that case, get the color just read from the input history, and transform that.
+      (when (string= "" color)          ; This "" resulted from `icicle-transform-multi-completion', above.
+        (let ((col  (car-safe (symbol-value minibuffer-history-variable))))
+          (setq color  (cond ((equal '(1) icicle-list-use-nth-parts)  col) ; Cannot do more.
+                             ((equal '(2) icicle-list-use-nth-parts)  (hexrgb-color-name-to-hex col))
+                             (t  (let ((icicle-list-nth-parts-join-string  ": ")
+                                       (icicle-list-join-string            ": "))
+                                   (icicle-transform-multi-completion color)))))))
+      (when msgp (message "Color: `%s'" (icicle-propertize color 'face 'icicle-msg-emphasis)))
+      color))
+
   ;; See also `hexrgb-read-color' in `hexrgb.el'.
   (defun icicle-read-color (&optional prompt convert-to-RGB-p allow-empty-name-p msgp)
-    "Read a color name or hex RGB hexadecimal color value #RRRRGGGGBBBB.
+    "Read a color name or RGB hexadecimal triplet.
 Return the name or the RGB hex string for the chosen color.
 
 By default (see option `icicle-functions-to-redefine'), this is used
@@ -1132,17 +1206,17 @@ multi-command that provides WYSIWYG completion, color-variable proxy
 candidates, alternate candidate actions, candidate help, and multiple
 color-related candidate sort orders.
 
-In this it is like command `icicle-read-color-wysiwyg' (which see),
-but it is less flexible and powerful than that command.
-`icicle-read-color' always returns the RGB hex string, and your input
-cannot be an arbitrary string - it must match a color candidate (or be
-empty if ALLOW-EMPTY-NAME-P is non-nil).
+In this it is like command `icicle-read-color-WYSIWYG', but it is less
+powerful and generally less flexible than `icicle-read-color-WYSIWYG'.
+Another difference is that `icicle-read-color-WYSIWYG' always raises
+an error for empty input, unless you wrap it in `ignore-errors'.
+
 
 In Lisp code that you write, and for interactive use,
-`icicle-read-color-wysiwyg' is generally a better choice than
+`icicle-read-color-WYSIWYG' is generally a better choice than
 `icicle-read-color'.
 
-Optional argument PROMPT is the prompt to use (default \"Color: \").
+Optional argument PROMPT is a non-default prompt to use.
 
 Interactively, or if CONVERT-TO-RGB-P is non-nil, return the RGB hex
 string for the chosen color.  If nil, return the color name.
@@ -1156,26 +1230,16 @@ action in case of empty input.
 
 Interactively, or with non-nil MSGP, show chosen color in echo area."
     (interactive "i\np\ni\np")          ; Always convert to RGB interactively.
-    (let* ((icicle-require-match-p  (not allow-empty-name-p))
-           (color                   (icicle-read-color-wysiwyg (if convert-to-RGB-p 2 1) prompt)))
-      ;; `icicle-read-color-wysiwyg' transforms input to get the 2nd multi-completion component.
-      ;; But if the user did not complete but just entered a color name, then this transformation returns "".
-      ;; In that case, get the color name that was input from the input history, and convert that to RGB.
-      (when (and (not allow-empty-name-p)  (string= "" color))
-        (let ((col  (car-safe (symbol-value minibuffer-history-variable))))
-          (when (or (equal "" col)  (not (stringp col))) (icicle-user-error "No such color: %S" color))
-          (setq color  (hexrgb-color-name-to-hex col))))
-      (let ((icicle-multi-completing-p  t)
-            (icicle-list-use-nth-parts  (if convert-to-RGB-p '(2) '(1)))
-            (colr                       (icicle-transform-multi-completion color)))
-        (when msgp (message "Color: `%s'" (icicle-propertize colr 'face 'icicle-msg-emphasis)))
-        colr)))
-
-  (defun icicle-read-color-wysiwyg (&optional arg prompt initial-input msgp)
+    (let ((color  (condition-case nil (icicle-read-color-WYSIWYG (if convert-to-RGB-p 2 1) prompt) (error ""))))
+      (when (and (not allow-empty-name-p)  (string= "" color)) (icicle-user-error "No such color: %S" color))
+      (when msgp (message "Color: `%s'" (icicle-propertize color 'face 'icicle-msg-emphasis)))
+      color))
+
+  (defun icicle-read-color-WYSIWYG (&optional arg prompt initial-input msgp)
     "Read a color name or hex RGB color value #RRRRGGGGBBBB.
 Return a string value.
 Interactively, optional argument ARG is the prefix arg - see below.
-Optional argument PROMPT is the prompt to use (default \"Color: \").
+Optional argument PROMPT is a non-default prompt to use.
 Optional argument INITIAL-INPUT is a initial input to insert in the
 minibuffer for completion.  It is passed to `completing-read'.
 Interactively, or with non-nil MSGP, show chosen color in echo area.
@@ -1212,12 +1276,16 @@ color name or input any valid RGB hex value (without completion).
 With no prefix arg, return a string with both the color name and the
 RGB value, separated by `icicle-list-nth-parts-join-string'.
 
-With a numeric prefix arg of 0 or 1, return the color name.  With any
-other numeric prefix arg, return the RGB value.
+With a numeric prefix arg of 0 or 1, return the color name.
+With any other numeric prefix arg, return the RGB hex triplet.
 
 In the plain `C-u' case, your input is checked to ensure that it
 represents a valid color.
 
+An error is raised if you enter empty input.  (In Lisp code, if you
+want to allow a return value of \"\" then wrap the call in
+`ignore-errors'.)
+
 In all other cases:
 
 - You can complete your input against the color name, the RGB value,
@@ -1249,9 +1317,10 @@ This command is intended only for use in Icicle mode (but it can be
 used with `C-u', with Icicle mode turned off)."
     (interactive "P\ni\ni\np")
     (unless (featurep 'hexrgb) (icicle-user-error "You need library `hexrgb.el' for this command"))
-    (let (color)
+    (let ((icicle-color-completing-p  t)
+          raw-input)
       (if (consp arg)                   ; Plain `C-u': complete against color name only, and be able to
-          (setq color  (hexrgb-read-color nil 'CONVERT-TO-RGB)) ; input any valid RGB string.
+          (hexrgb-read-color nil 'CONVERT-TO-RGB) ; input any valid RGB string.
 
         ;; Complete against name+RGB pairs, but user can enter invalid value without completing.
         (when arg (setq arg  (prefix-numeric-value arg))) ; Convert `-' to -1.
@@ -1260,8 +1329,6 @@ used with `C-u', with Icicle mode turned off)."
                (or (and arg  (if (< arg 2) '(1) '(2))) ; 1 or 2, either by program or via `C-1' or `C-2'.
                    icicle-list-use-nth-parts ; Bound externally by program.
                    '(1 2)))             ; Both parts, by default.
-              (mouse-pseudo-color-p  nil)
-
               icicle-candidate-help-fn           completion-ignore-case
               icicle-transform-function          icicle-sort-orders-alist
               icicle-list-nth-parts-join-string  icicle-list-join-string
@@ -1270,61 +1337,21 @@ used with `C-u', with Icicle mode turned off)."
           ;; Copy the prompt string because `icicle-color-completion-setup' puts a text prop on it.
           ;; Use `icicle-prompt' from now on, since that's what `icicle-color-completion-setup'
           ;; sets up.
-          (setq icicle-prompt  (copy-sequence (or prompt  "Color: ")))
+          (setq icicle-prompt  (copy-sequence (or prompt  "Color (name or #RGB triplet): ")))
           (icicle-color-completion-setup)
           (setq icicle-proxy-candidates
                 (append icicle-proxy-candidates
                         (mapcar         ; Convert multi-completions to strings.
                          (lambda (entry) (mapconcat #'identity (car entry) icicle-list-join-string))
                          '((("*mouse-2 foreground*")) (("*mouse-2 background*")))))
-                color  (let ((icicle-orig-window  (selected-window))
-                             (icicle-candidate-alt-action-fn
-                              (or icicle-candidate-alt-action-fn  (icicle-alt-act-fn-for-type "color")))
-                             (icicle-all-candidates-list-alt-action-fn
-                              (or icicle-all-candidates-list-alt-action-fn
-                                  (icicle-alt-act-fn-for-type "color"))))
-                         (completing-read icicle-prompt icicle-named-colors nil nil initial-input)))
-          (cond ((string-match "\\`'.+': " color)
-                 (let ((icicle-list-nth-parts-join-string  ": ")
-                       (icicle-list-join-string            ": ")
-                       (icicle-list-use-nth-parts          '(2)))
-                   (setq color  (icicle-transform-multi-completion color))))
-                ((fboundp 'eyedrop-foreground-at-point)
-                 (cond ((string-match "^\*mouse-2 foreground\*" color)
-                        (setq color  (prog1 (eyedrop-foreground-at-mouse
-                                             (read-event
-                                              "Click `mouse-2' anywhere to choose foreground color"))
-                                       (read-event)) ; Discard mouse up event.
-                              mouse-pseudo-color-p  t))
-                       ((string-match "^\*mouse-2 background\*" color)
-                        (setq color  (prog1 (eyedrop-background-at-mouse
-                                             (read-event
-                                              "Click `mouse-2' anywhere to choose background color"))
-                                       (read-event)) ; Discard mouse up event.
-                              mouse-pseudo-color-p  t)))
-                 (if mouse-pseudo-color-p
-                     (let ((icicle-list-nth-parts-join-string  ": ")
-                           (icicle-list-join-string            ": ")
-                           (icicle-list-use-nth-parts
-                            (or (and arg  (if (< arg 2) '(1) '(2))) ; 1 or 2, via program or `C-1' or `C-2'.
-                                icicle-list-use-nth-parts ; Bound externally by program.
-                                '(1 2)))) ; Both parts, by default.
-                       (setq color  (icicle-transform-multi-completion
-                                     (concat color ": " (hexrgb-color-name-to-hex color)))))
-                   (setq color  (icicle-transform-multi-completion color)))))
-                   (when (string= "" color)
-                     (let ((col  (car-safe (symbol-value minibuffer-history-variable))))
-                       (when (or (equal "" col)  (not (stringp col)))
-                           (icicle-user-error "No such color: %S" color))
-                       ;; Cannot use `case', since that uses `eql', not `equal'.
-                       (setq color  (cond ((equal '(1) icicle-list-use-nth-parts)  col)
-                                          ((equal '(2) icicle-list-use-nth-parts)
-                                           (hexrgb-color-name-to-hex col))
-                                          (t  (let ((icicle-list-nth-parts-join-string  ": ")
-                                                    (icicle-list-join-string            ": "))
-                                                (icicle-transform-multi-completion color)))))))))
-      (when msgp (message "Color: `%s'" (icicle-propertize color 'face 'icicle-msg-emphasis)))
-      color))
+                raw-input  (let ((icicle-orig-window  (selected-window))
+                                 (icicle-candidate-alt-action-fn
+                                  (or icicle-candidate-alt-action-fn  (icicle-alt-act-fn-for-type "color")))
+                                 (icicle-all-candidates-list-alt-action-fn
+                                  (or icicle-all-candidates-list-alt-action-fn
+                                      (icicle-alt-act-fn-for-type "color"))))
+                             (completing-read icicle-prompt icicle-named-colors nil nil initial-input)))
+          (icicle-color-from-multi-completion-input raw-input msgp)))))
 
   (icicle-define-command icicle-frame-bg ; Command name
     "Change background of current frame.
@@ -1516,7 +1543,7 @@ COLOR is a color name, an RGB string, or a multi-completion of both.
 If only a color name, then just say \"No help\"."
     (if (not (member icicle-list-use-nth-parts '((1 2) (2))))
         (icicle-msg-maybe-in-minibuffer "No help")
-      (with-output-to-temp-buffer "*Help*"
+      (icicle-with-help-window "*Help*"
         (princ (format "Color: %s" color)) (terpri) (terpri)
         (let* ((icicle-list-use-nth-parts  '(2))
                (colr                       (icicle-transform-multi-completion color))
@@ -1601,7 +1628,7 @@ name to use."
                                      (cons 'rgb-dist
                                            (let ((enable-recursive-minibuffers  t)
                                                  (icicle-sort-comparer          nil))
-                                             (icicle-read-color-wysiwyg ; Use the color name only.
+                                             (icicle-read-color-WYSIWYG ; Use the color name only.
                                               0 "With RGB close to color: ")))))))
            (base-rgb    (hexrgb-hex-to-rgb (hexrgb-color-name-to-hex base-color)))
            (base-red    (nth 0 base-rgb))
@@ -1687,7 +1714,7 @@ name to use."
                                      (cons 'hsv-dist
                                            (let ((enable-recursive-minibuffers  t)
                                                  (icicle-sort-comparer          nil))
-                                             (icicle-read-color-wysiwyg ; Use the color name only.
+                                             (icicle-read-color-WYSIWYG ; Use the color name only.
                                               0 "With HSV close to color: ")))))))
            (base-hsv    (hexrgb-hex-to-hsv (hexrgb-color-name-to-hex base-color)))
            (base-hue    (nth 0 base-hsv))
@@ -1729,6 +1756,7 @@ returned."
        (icicle-list-join-string            ": ")
        (icicle-multi-completing-p          t)
        (icicle-list-use-nth-parts          '(1))
+       (icicle-face-completing-p           t)
        (prompt                             (copy-sequence "Choose face (`RET' when done): "))
        (face-names                         ()))
       (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code.
@@ -1754,6 +1782,7 @@ returned."
        (icicle-list-join-string            ": ")
        (icicle-multi-completing-p          t)
        (icicle-list-use-nth-parts          '(1))
+       (icicle-face-completing-p           t)
        (prompt                             (copy-sequence "Choose face (`RET' when done): "))
        (face-names                         ()))
       (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code.
@@ -1779,6 +1808,7 @@ returned."
        (icicle-list-join-string            ": ")
        (icicle-multi-completing-p          t)
        (icicle-list-use-nth-parts          '(1))
+       (icicle-face-completing-p           t)
        (prompt                             (copy-sequence "Choose face (`RET' when done): "))
        (face-names                         ()))
       (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code.
@@ -1947,21 +1977,21 @@ is returned.
 As always in Icicles, you can toggle the use of proxy candidates using
 `\\<minibuffer-local-completion-map>\\[icicle-toggle-proxy-candidates]' in the minibuffer.
 
-See `icicle-read-color-wysiwyg' for more information."
-    (let* ((prefix      (buffer-substring-no-properties
-                         (widget-field-start widget) (point)))
+See `icicle-read-color-WYSIWYG' for more information."
+    (let* ((prefix          (buffer-substring-no-properties (widget-field-start widget) (point)))
            ;; Free variables here: `eyedrop-picked-foreground', `eyedrop-picked-background'.
            ;; They are defined in library `palette.el' or library `eyedropper.el'.
-           (colors      (if (fboundp 'hexrgb-defined-colors-alist) ; Defined in `hexrgb.el'.
-                            (if (fboundp 'eyedrop-foreground-at-point)
-                                (append (and eyedrop-picked-foreground  '(("*copied foreground*")))
-                                        (and eyedrop-picked-background  '(("*copied background*")))
-                                        '(("*mouse-2 foreground*") ("*mouse-2 background*")
-                                          ("*point foreground*") ("*point background*"))
-                                        (hexrgb-defined-colors-alist))
-                              (hexrgb-defined-colors-alist))
-                          (mapcar #'list (x-defined-colors))))
-           (completion  (try-completion prefix colors)))
+           (colors                   (if (fboundp 'hexrgb-defined-colors-alist) ; Defined in `hexrgb.el'.
+                                         (if (fboundp 'eyedrop-foreground-at-point)
+                                             (append (and eyedrop-picked-foreground  '(("*copied foreground*")))
+                                                     (and eyedrop-picked-background  '(("*copied background*")))
+                                                     '(("*mouse-2 foreground*") ("*mouse-2 background*")
+                                                       ("*point foreground*") ("*point background*"))
+                                                     (hexrgb-defined-colors-alist))
+                                           (hexrgb-defined-colors-alist))
+                                       (mapcar #'list (x-defined-colors))))
+           (icicle-color-completing  t)
+           (completion               (try-completion prefix colors)))
       (cond ((null completion)
              (widgetp-remove-Completions)
              (error "No completion for \"%s\"" prefix))
@@ -1991,8 +2021,8 @@ See `icicle-read-color-wysiwyg' for more information."
                                                                         (widget-field-end field))))
 
                     (color
-                     (if (and (fboundp 'icicle-read-color-wysiwyg)  icicle-WYSIWYG-Completions-flag)
-                         (icicle-read-color-wysiwyg (if current-prefix-arg 99 0)
+                     (if (and (fboundp 'icicle-read-color-WYSIWYG)  icicle-WYSIWYG-Completions-flag)
+                         (icicle-read-color-WYSIWYG (if current-prefix-arg 99 0)
                                                     "Color (name or #R+G+B+): " prefix 'MSGP)
                        (completing-read "Color: " colors nil nil prefix))))
                (delete-region beg end)
@@ -2004,41 +2034,44 @@ See `icicle-read-color-wysiwyg' for more information."
 (defun icicle-cmd2-after-load-palette ()
   "Things to do for `icicles-cmd2.el' after loading `palette.el'."
 
-  (icicle-define-command icicle-pick-color-by-name ; Bound to `c' in color palette.
-    "Set the current color to a color you name.
+  (defun icicle-pick-color-by-name (color &optional msgp) ; Bound to `c' and `M-c' in color palette.
+    "Set the current palette color to a color you name.
 Instead of a color name, you can use an RGB string #XXXXXXXXXXXX,
 where each X is a hex digit.  The number of Xs must be a multiple of
 3, with the same number of Xs for each of red, green, and blue.
 If you enter an empty color name, then a color is picked randomly.
-The new current color is returned."     ; Doc string
-    icicle-pick-color-by-name-action    ; Action function
-    "Color (name or #R+G+B+): "         ; `completing-read' arguments
-    (hexrgb-defined-colors-alist) nil nil nil nil nil nil
-    ((completion-ignore-case  t)))      ; Bindings
+The new current color is returned.
 
-  (defun icicle-pick-color-by-name-action (color)
+When called from Lisp, non-nil MSGP means echo the chosen color name."
+    (interactive (let ((completion-ignore-case      t)
+                       (icicle-color-completing-p   t)
+                       (icicle-candidate-action-fn  'icicle-pick-color-by-name-action)
+                       (icicle-list-use-nth-parts   '(1)))
+                   (list (icicle-read-color nil nil t) 'MSG)))
+    (icicle-pick-color-by-name-1 color msgp))
+
+  (defun icicle-pick-color-by-name-action (raw-input)
     "Action function for `icicle-pick-color-by-name'."
-    (if (string= "" color)
-        (let* ((colors  (hexrgb-defined-colors))
-               (rand    (random (length colors)))) ; Random color.
-          (setq color  (elt colors rand)))
-      (let ((hex-string  (hexrgb-rgb-hex-string-p color t)))
-        (when (and hex-string  (not (eq 0 hex-string))) (setq color  (concat "#" color))) ; Add #.
-        (unless (or hex-string  (if (fboundp 'test-completion) ; Not defined in Emacs 20.
-                                    (test-completion color (hexrgb-defined-colors-alist))
-                                  (try-completion color (hexrgb-defined-colors-alist))))
-          (icicle-user-error "No such color: %S" color))
-        (setq color  (hexrgb-color-name-to-hex color)))
-      (setq palette-last-color  palette-current-color)
-      (save-selected-window
-        (setq color  (hexrgb-color-name-to-hex color)) ; Needed if not interactive.
-        (palette-set-current-color color)
+    (let ((color  (icicle-color-from-multi-completion-input raw-input 'MSG)))
+      (icicle-pick-color-by-name-1 color)))
+
+  (defun icicle-pick-color-by-name-1 (color &optional msgp)
+    "Set the current palette color to COLOR.
+If the palette is displayed, redisplay it, moving the cursor to COLOR.
+Non-nil MSGP means echo the chosen color name."
+    (setq palette-last-color  palette-current-color
+          color               (hexrgb-color-name-to-hex color))
+    (save-selected-window
+      (palette-set-current-color color)
+      (when (get-buffer-window "Palette (Hue x Saturation)" 'visible)
         (palette-where-is-color color)
         (palette-brightness-scale)
-        (palette-swatch))
-      palette-current-color))
+        (palette-swatch)))
+    (prog1 palette-current-color
+      (when msgp (message "Palette color (RGB) is now `%s'" palette-current-color))))
 
-  (define-key palette-mode-map (icicle-kbd "c")  'icicle-pick-color-by-name)
+  (define-key palette-mode-map (icicle-kbd "c")     'icicle-pick-color-by-name)
+  (define-key palette-mode-map (icicle-kbd "\M-c")  'icicle-pick-color-by-name)
   (define-key palette-popup-map [pick-color-by-name] ; Use same name as in `palette.el'.
     `(menu-item "Choose Color By Name" icicle-pick-color-by-name
       :help "Set the current color to a color you name"))
@@ -2485,6 +2518,156 @@ buffer."
                  "`font-lock-keywords' set to all candidates"))))
   )
 
+;; The name of this command is quite unfortunate.  It must have this name, since we use
+;; `icicle-functions-to-redefine' to switch between vanilla `complete' and this.
+;;
+(defun icicle-complete (&optional arg)
+  "Complete the name before point.
+This has an effect only when `dynamic-completion-mode' is on.  That
+mode is defined in Emacs library `completion.el'.  To use this
+command, enter Icicle mode after turning on `dynamic-completion-mode'.
+
+If option `icicle-cmpl-max-candidates-to-cycle' is non-negative
+integer M, and if there are at least M completion candidates, then use
+Icicles minibuffer completion to choose one.  The text before point is
+treated as a prefix to match, but you can of course use progressive
+completion to then match also substrings or other regexps.
+
+Icicles minibuffer completion is also used regardless of the value of
+`icicle-cmpl-max-candidates-to-cycle', if you use two or more plain
+prefix args (`C-u C-u').
+
+Otherwise, consecutive calls cycle through the possible completions,
+in place.  This is the vanilla `complete' command behavior from
+library `completion.el'.
+
+Point is normally left at the end of the inserted completion.
+
+Prefix arg behavior:
+
+ Odd number of `C-u': Leave point at start, not end, of completion.
+
+ More than one `C-u': Use Icicles minibuffer completion.
+
+ An integer N       : Use Nth next completion (previous Nth if N < 0).
+ `-'                : Same as -1: previous completion.
+
+If option `icicle-cmpl-include-cdabbrev-flag' is non-nil then Icicles
+completion includes candidates found dynamically from the currently
+available windows.  These candidates are highlighted in buffer
+`*Completions*' using face `icicle-special-candidate' so you can
+easily distinguish them.
+
+This is the so-called `CDABBREV' completion method defined in
+`completion.el'.  It is similar to how `dabbrev' finds candidates but
+with these differences:
+* It is sometimes faster, since it does not use regexps.  It searches
+  backwards looking for names that start with the text before point.
+* Case-sensitivity is handled as for other `completion.el' completion.
+
+If Icicles completion is not used then this `CDABBREV' completion is
+used only when no matching completions are found in the completions
+database.  With Icicles completion you can immediately choose one of
+the `CDABBREV' candidates.
+
+During Icicles minibuffer completion you can use `S-delete' to remove
+the current completion candidate from the database of completions.
+Cycle among the candidates (e.g. `down'), and use `S-delete' to delete
+as many as you want.
+
+\(You can also delete any database entry using `\\[kill-completion]'.
+And you can add a database entry using `\\[add-completion]'.)
+
+See the comments at the top of `completion.el' for more info."
+  (interactive "*p")
+  (let ((buf-modified-p        (buffer-modified-p))
+        (icicle-sort-comparer  nil)
+        (icicle-sort-orders-alist
+         '(("by last dynamic completion") ; Renamed from "turned OFF'.
+           ("cdabbrev candidates first" . icicle-special-candidates-first-p)
+           ("alphabetical" . icicle-case-string-less-p)
+           ("by last use as input" . icicle-latest-input-first-p)
+           ("by previous input use alphabetically" . icicle-historical-alphabetic-p))))
+    (cond ((eq last-command this-command)
+           (delete-region cmpl-last-insert-location (point)) ; Undo last one
+           (setq cmpl-current-index  (+ cmpl-current-index (or arg  1)))) ; Get next completion
+          (t
+           (unless cmpl-initialized-p (completion-initialize)) ; Make sure everything is loaded
+           (if (and (consp current-prefix-arg)  (eq (logand (length current-prefix-arg) 1) 1)) ; `oddp'
+               (setq cmpl-leave-point-at-start  t
+                     arg                        0)
+             (setq cmpl-leave-point-at-start  nil))
+           (setq cmpl-original-string  (symbol-before-point-for-complete))
+           (unless cmpl-original-string
+             (setq this-command  'failed-complete)
+             (error "To complete, point must be after a symbol at least %d chars long"
+                    completion-prefix-min-length))
+           (setq cmpl-current-index  (if current-prefix-arg arg 0))
+           (completion-search-reset cmpl-original-string) ; Reset database
+           (delete-region cmpl-symbol-start cmpl-symbol-end))) ; Erase what we've got
+    (let* ((num-comps       0)
+           (db-comps        ())
+           (db-comps        (progn (mapatoms (lambda (sy)
+                                               (when (eq 0 (string-match cmpl-test-regexp (symbol-name sy)))
+                                                 (push (find-exact-completion (symbol-name sy)) db-comps)
+                                                 (setq num-comps  (1+ num-comps))))
+                                             cmpl-obarray)
+                                   db-comps))
+           (all-comps       db-comps)
+           (all-comps       (if (not icicle-cmpl-include-cdabbrev-flag)
+                                db-comps
+                              (unless cmpl-cdabbrev-reset-p
+                                (reset-cdabbrev cmpl-test-string cmpl-tried-list)
+                                (setq cmpl-cdabbrev-reset-p  t))
+                              (let ((next  nil))
+                                (while (and (setq next  (next-cdabbrev))
+                                            (not (assoc next db-comps))) ; Not in database
+                                  (put-text-property 0 (length next) 'face 'icicle-special-candidate next)
+                                  (push (list next) all-comps)
+                                  (setq num-comps  (1+ num-comps)))
+                                all-comps)))
+           (use-icicles-p   (or (and (consp current-prefix-arg) ; `C-u C-u...' (more than one)
+                                     (> (prefix-numeric-value current-prefix-arg) 4)
+                                     (> num-comps 1))
+                                (and icicle-cmpl-max-candidates-to-cycle
+                                     (> num-comps (max 1 icicle-cmpl-max-candidates-to-cycle)))))
+           (print-status-p  (and (>= baud-rate completion-prompt-speed-threshold)
+                                 (not (window-minibuffer-p))))
+           (insert-point    (point))
+           (entry           (if use-icicles-p
+                                (condition-case nil
+                                    (let ((completion-ignore-case                  t)
+                                          (icicle-show-Completions-initially-flag  t)
+                                          (icicle-delete-candidate-object          'delete-completion))
+                                      (completing-read "Completion: " all-comps nil t cmpl-original-string))
+                                  (quit nil)) ; Return nil, so deleted original prefix will be re-inserted.
+                              (completion-search-next cmpl-current-index))) ; Cycle to next.
+           string)
+      ;; If ENTRY is non-nil, it is a full completion entry or a string (if cdabbrev or if USE-ICICLES-P).
+      (cond (entry                      ; Found, so insert it.
+             (setq string  (if (stringp entry) entry (completion-string entry)) ; Use proper case
+                   string  (cmpl-merge-string-cases string cmpl-original-string))
+             (insert string)
+             (setq completion-to-accept  string)
+             (if (not cmpl-leave-point-at-start) ; Fix-up and cache point
+                 (setq cmpl-last-insert-location  insert-point) ; Point at end.
+               (setq cmpl-last-insert-location  (point))
+               (goto-char insert-point))
+             (unless use-icicles-p      ; Display the next completion
+               (cond ((and print-status-p
+                           (sit-for 0)  ; Update the display.  Print only if there is no typeahead.
+                           (setq entry  (completion-search-peek completion-cdabbrev-prompt-flag)))
+                      (setq string  (if (stringp entry) entry (completion-string entry))
+                            string  (cmpl-merge-string-cases string cmpl-original-string))
+                      (message "Next completion: `%s'" string)))))
+            (t                          ; No completion found, so re-insert original.
+             (insert cmpl-original-string)
+             (set-buffer-modified-p buf-modified-p)
+             (setq completion-to-accept  nil) ; Do not accept completions.
+             (when (and print-status-p  (sit-for 0))
+               (message "No %scompletions" (if (eq this-command last-command) "more " "")))
+             (setq this-command  'failed-complete)))))) ; Pretend that we were never here
+
 
 (defvar icicle-info-buff nil
   "Info buffer before command was invoked.")
@@ -2494,10 +2677,12 @@ buffer."
 
 (defun icicle-Info-index (&optional topic)
   "Like vanilla `Info-index', but you can use multi-command keys `C-RET', `C-up' etc.
-Also, for Emacs 22 and later, completion candidates (index topics) for
-nodes already visited are highlighted with face
-`icicle-historical-candidate-other' if there are fewer matching
-candidates than `icicle-Info-visited-max-candidates'"
+Also, for Emacs 22 and later:
+Completion candidates (index topics) for nodes you have already
+visited may be highlighted automatically with face
+`icicle-historical-candidate-other', depending on the value of option
+`icicle-Info-highlight-visited-nodes'.  You can always effect such
+highlighting on demand, using `C-M-l'."
   ;; We allow an arg only for non-interactive use.  E.g., `Info-virtual-index' calls (Info-index TOPIC).
   (interactive)
   (unless (and (featurep 'info)  (eq major-mode 'Info-mode))
@@ -3247,7 +3432,7 @@ See also: `icicle-apropos-value'."      ; Doc string
 
 ;;; $$$$$$ (defun icicle-funvardoc-action (entry)
 ;;;   "Action function for `icicle-vardoc', `icicle-fundoc', `icicle-plist'."
-;;;   (with-output-to-temp-buffer "*Help*" (princ entry)))
+;;;   (icicle-with-help-window "*Help*" (princ entry)))
 
 (icicle-define-command icicle-fundoc    ; Command name
   "Choose a function description.
@@ -3583,9 +3768,16 @@ Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or
 `C-g' to quit.  This is an Icicles command - see command
 `icicle-mode'.
 
-`icicle-apply' overrides `icicle-buffer-ignore-space-prefix-flag',
-binding it to nil so that candidates with initial spaces can be
-matched."
+Note:
+* `icicle-apply' overrides `icicle-buffer-ignore-space-prefix-flag',
+  binding it to nil so that candidates with initial spaces can be
+  matched.
+* `icicle-apply' binds user option `icicle-incremental-completion' to
+  `always', because I think you typically want to start it out with
+  incremental completion turned on.  Functions that call
+  `icicle-apply' thus also turn on incremental completion.
+  Remember that you can use `C-#' (once or twice) to turn incremental
+  completion off."
   (interactive
    (list (symbol-value
           (intern
@@ -3678,16 +3870,24 @@ matched."
     (select-frame-set-input-focus (selected-frame))))
 
 (defun icicle-goto-marker-or-set-mark-command (arg) ; Bound to `C-@', `C-SPC'.
-  "With prefix arg < 0, `icicle-goto-marker'; else `set-mark-command'.
+  "Set mark or goto a marker.
+With no prefix arg or a prefix arg > 0, this is `set-mark-command'.
+\(This includes the cases of `C-u' and `C-u C-u'.) 
+With a prefix arg = 0, this is `icicle-goto-any-marker'.
+With a prefix arg < 0, this is `icicle-goto-marker'.
+
+See each of those commands for more information.
+
 By default, Icicle mode remaps all key sequences that are normally
 bound to `set-mark-command' to
 `icicle-goto-marker-or-set-mark-command'.  If you do not want this
 remapping, then customize option `icicle-top-level-key-bindings'."
   (interactive "P")
-  (if (not (wholenump (prefix-numeric-value arg)))
-      (icicle-goto-marker)
-    (setq this-command 'set-mark-command) ; Let `C-SPC C-SPC' activate if not `transient-mark-mode'.
-    (set-mark-command arg)))
+  (cond ((< (prefix-numeric-value arg) 0) (icicle-goto-marker))
+        ((= (prefix-numeric-value arg) 0) (icicle-goto-any-marker))
+        (t
+         (setq this-command 'set-mark-command) ; Let `C-SPC C-SPC' activate if not `transient-mark-mode'.
+         (set-mark-command arg))))
 
 (defun icicle-goto-global-marker-or-pop-global-mark (arg) ; Bound to `C-x C-@', `C-x C-SPC'.
   "With prefix arg < 0, `icicle-goto-global-marker'; else `pop-global-mark'.
@@ -3728,17 +3928,52 @@ With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2',
 
 Use `mouse-2', `RET', or `S-RET' to choose a candidate as the final
 destination, or `C-g' to quit.  This is an Icicles command - see
-command `icicle-mode'."
+command `icicle-mode'.
+
+See also commands `icicle-goto-any-marker' and
+`icicle-goto-global-marker'."
   (interactive)
   (let ((icicle-sort-orders-alist  (cons '("by position" .  icicle-cdr-lessp) icicle-sort-orders-alist))
         (icicle-sort-comparer      'icicle-cdr-lessp))
     (icicle-goto-marker-1 mark-ring)))
 
+(defun icicle-goto-any-marker ()        ; Bound to `C-0 C-@', `C-0 C-SPC'.
+  "Like `icicle-goto-marker', but lets you visit markers in all buffers.
+If user option `icicle-show-multi-completion-flag' is non-nil, then
+each completion candidate is has two parts, the first of which is the
+name of the marker's buffer, and the second of which is the text from
+the marker's line.
+
+By default, candidates are sorted in buffer order and then marker
+order, that is, buffer positions.  Use `C-M-,' or `C-,' to change the
+sort order.  Remember too that you can use `C-A' to toggle
+case-sensitivity (e.g., for buffer names).
+
+See also command `icicle-goto-global-marker'."
+  (interactive)
+  (let ((icicle-multi-completing-p          icicle-show-multi-completion-flag)
+        (icicle-list-nth-parts-join-string  "\t")
+        (icicle-list-join-string            "\t")
+        (icicle-sort-orders-alist           (cons '("by buffer, then by position" . icicle-part-1-cdr-lessp)
+                                                  icicle-sort-orders-alist))
+        (icicle-sort-comparer               'icicle-part-1-cdr-lessp)
+        (icicle-candidate-properties-alist  (and icicle-show-multi-completion-flag
+                                                 '((1 (face icicle-candidate-part))))))
+    (icicle-goto-marker-1 'all)))
+
 (defun icicle-goto-global-marker ()     ; Bound to `C-- C-x C-@', `C-- C-x C-SPC'.
   "Like `icicle-goto-marker', but visits global, not local, markers.
 If user option `icicle-show-multi-completion-flag' is non-nil, then
-each completion candidate is annotated (prefixed) with the name of the
-marker's buffer, to facilitate orientation."
+each completion candidate is has two parts, the first of which is the
+name of the marker's buffer, and the second of which is the text from
+the marker's line.
+
+By default, candidates are sorted in buffer order and then marker
+order, that is, buffer positions.  Use `C-M-,' or `C-,' to change the
+sort order.  Remember too that you can use `C-A' to toggle
+case-sensitivity (e.g., for buffer names).
+
+See also command `icicle-goto-any-marker'."
   (interactive)
   (let ((icicle-multi-completing-p          icicle-show-multi-completion-flag)
         (icicle-list-nth-parts-join-string  "\t")
@@ -3751,36 +3986,40 @@ marker's buffer, to facilitate orientation."
     (icicle-goto-marker-1 global-mark-ring)))
 
 (defun icicle-goto-marker-1 (ring)
-  "Helper function for `icicle-goto-marker', `icicle-goto-global-marker'.
-RING is the marker ring to use."
-  (unwind-protect
-       (let* ((global-ring-p
-               (memq this-command '(icicle-goto-global-marker
-                                    icicle-goto-global-marker-or-pop-global-mark)))
-              (markers
-               (if (and (not global-ring-p)  (marker-buffer (mark-marker)))
-                   (cons (mark-marker) (icicle-markers ring))
-                 (icicle-markers ring)))
-              (icicle-delete-candidate-object
-               (lambda (cand)
-                 (let ((mrkr+txt  (funcall icicle-get-alist-candidate-function cand)))
-                   (move-marker (cdr mrkr+txt) nil))))
-              (icicle-alternative-sort-comparer  nil)
-              (icicle-last-sort-comparer         nil)
-              (icicle-orig-buff                  (current-buffer)))
-         (unless (consp markers)
-           (icicle-user-error (if global-ring-p "No global markers" "No markers in this buffer")))
-         (cond ((cdr markers)
-                (icicle-apply (mapcar (lambda (mrkr) (icicle-marker+text mrkr global-ring-p))
-                                      markers)
-                              #'icicle-goto-marker-1-action
-                              'nomsg
-                              (lambda (cand)
-                                (marker-buffer (cdr cand)))))
-               ((= (point) (car markers)) (message "Already at marker: %d" (point)))
-               (t
-                (icicle-goto-marker-1-action (icicle-marker+text (car markers) global-ring-p)))))
-    (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch))))
+  "Helper function for Icicles functions for navigating amoung markers.
+RING is the marker ring to use, or the symbol `all', which means use
+the markers in each buffer."
+  (let ((icicle-transform-function  'icicle-remove-duplicates))
+    (unwind-protect
+         (let* ((allp     (eq ring 'all))
+                (globalp  (and (not allp)
+                               (memq this-command '(icicle-goto-global-marker
+                                                    icicle-goto-global-marker-or-pop-global-mark))))
+                (bufs     (if globalp
+                              'global
+                            (if allp
+                                (icicle-remove-if #'minibufferp (buffer-list))
+                              (and (not (minibufferp (current-buffer)))  (list (current-buffer))))))
+                (markers  (icicle-markers bufs))
+                (icicle-delete-candidate-object
+                 (lambda (cand)
+                   (let ((mrkr+txt  (funcall icicle-get-alist-candidate-function cand)))
+                     (move-marker (cdr mrkr+txt) nil))))
+                (icicle-alternative-sort-comparer  nil)
+                (icicle-last-sort-comparer         nil)
+                (icicle-orig-buff                  (current-buffer)))
+           (unless (consp markers) (icicle-user-error (cond (globalp "No global markers")
+                                                            (allp "No markers")
+                                                            (t "No markers in this buffer"))))
+           (cond ((cdr markers)
+                  (icicle-apply (mapcar (lambda (mrkr) (icicle-marker+text mrkr (or allp  globalp))) markers)
+                                #'icicle-goto-marker-1-action
+                                'nomsg
+                                (lambda (cand) (marker-buffer (cdr cand)))))
+                 ((= (point) (car markers)) (message "Already at marker: %d" (point)))
+                 (t
+                  (icicle-goto-marker-1-action (icicle-marker+text (car markers) (or allp  globalp))))))
+      (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)))))
 
 (defun icicle-goto-marker-1-action (cand)
   "Action function for `icicle-goto-marker-1'."
@@ -3790,37 +4029,50 @@ RING is the marker ring to use."
   (unless (pos-visible-in-window-p) (recenter icicle-recenter))
   (when (fboundp 'crosshairs-highlight) (crosshairs-highlight)))
 
-(defun icicle-marker+text (marker &optional globalp)
+(defun icicle-marker+text (marker &optional show-bufname-p)
   "Cons of text line that includes MARKER with MARKER itself.
 If the marker is on an empty line, then text \"<EMPTY LINE>\" is used.
-If both optional argument GLOBALP and option
+If both optional argument SHOW-BUFNAME-P and option
 `icicle-show-multi-completion-flag' are non-nil, then the text is
-prefixed by MARKER's buffer name."
-  (with-current-buffer (marker-buffer marker)
-    (save-excursion
-      (goto-char marker)
-      (let ((line  (let ((inhibit-field-text-motion  t)) ; Just to be sure, for `line-end-position'.
-                     (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
-            (buff  (and globalp  icicle-show-multi-completion-flag  (buffer-name)))
-            (help  (and (or (> icicle-help-in-mode-line-delay 0) ; Get it only if user will see it.
-                            (and (boundp 'tooltip-mode)  tooltip-mode))
-                        (format "Line: %d, Char: %d" (line-number-at-pos) (point)))))
-        (when (string= "" line) (setq line  "<EMPTY LINE>"))
-        (when help
-          (icicle-candidate-short-help help line)
-          (when (and globalp  icicle-show-multi-completion-flag)
-            (icicle-candidate-short-help help buff)))
-        (if (and globalp  icicle-show-multi-completion-flag)
-            (cons (list buff line) marker)
-          (cons line marker))))))
-
-(defun icicle-markers (ring)
-  "Marks in mark RING that are in live buffers other than a minibuffer."
+prefixed by MARKER's buffer name and the line number."
+  (when (buffer-live-p (marker-buffer marker))
+    (with-current-buffer (marker-buffer marker)
+      (save-excursion
+        (goto-char marker)
+        (let* ((line    (let ((inhibit-field-text-motion  t)) ; Just to be sure, for `line-end-position'.
+                          (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
+               (lineno  (line-number-at-pos))
+               (buff    (and show-bufname-p  icicle-show-multi-completion-flag
+                             (format "%s:%5d" (buffer-name) lineno)))
+               (help    (and (or (> icicle-help-in-mode-line-delay 0) ; Get it only if user will see it.
+                                 (and (boundp 'tooltip-mode)  tooltip-mode))
+                             (format "Line: %d, Char: %d" lineno (point)))))
+          (when (string= "" line) (setq line  "<EMPTY LINE>"))
+          (when help
+            (icicle-candidate-short-help help line)
+            (when (and show-bufname-p  icicle-show-multi-completion-flag)
+              (icicle-candidate-short-help help buff)))
+          (if (and show-bufname-p  icicle-show-multi-completion-flag)
+              (cons (list buff line) marker)
+            (cons line marker)))))))
+
+(defun icicle-markers (buffers)
+  "Return the list of markers in the mark rings of BUFFERS.
+If BUFFERS is the symbol `global' then return the list of markers in
+the `global-mark-ring' that are in live buffers other than
+minibuffers."
   (let ((markers  ()))
-    (dolist (mkr  ring)
-      (when (and (buffer-live-p (marker-buffer mkr))
-                 (not (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name (marker-buffer mkr)))))
-        (push mkr markers)))
+    (if (eq buffers 'global)
+        (dolist (mkr  global-mark-ring)
+          (when (and (buffer-live-p (marker-buffer mkr))
+                     (not (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name (marker-buffer mkr)))))
+            (push mkr markers)))
+      (dolist (buf  buffers)
+        (when (buffer-live-p buf)
+          (with-current-buffer buf
+            (setq markers  (nconc markers (if (and (mark-marker)  (marker-buffer (mark-marker)))
+                                              (cons (mark-marker) (copy-sequence mark-ring))
+                                            (copy-sequence mark-ring))))))))
     markers))
 
 (defun icicle-exchange-point-and-mark (&optional arg) ; Bound to `C-x C-x'.
@@ -3888,9 +4140,12 @@ specifying a regexp (followed by `RET').
 After specifying the regexp that defines the search contexts, type
 input (e.g. regexp or other pattern) to match within the contexts.
 The contexts that match your input are available as completion
-candidates.  You can use `\\<minibuffer-local-completion-map>\
-\\[icicle-apropos-complete-and-narrow]' to further narrow the candidates,
-typing additional patterns to match.
+candidates.  Use `S-TAB' to show them.  (Use `TAB' if you want prefix
+completion, which is not commonly the case for `icicle-search'.)
+
+You can use `\\<minibuffer-local-completion-map>\
+\\[icicle-apropos-complete-and-narrow]' to further narrow the candidates, typing
+additional patterns to match.
 
 By default, candidates are in order of buffer occurrence, but you can
 sort them in various ways using `\\[icicle-change-sort-order]'.
@@ -4232,6 +4487,13 @@ zones.  You can limit hits to regexp matches that also satisfy a
 predicate, by using `(PREDICATE)' as ARGS: PREDICATE is then passed to
 `icicle-search-regexp-scan' as its PREDICATE argument.
 
+Note: `icicle-search' effectively binds user option
+`icicle-incremental-completion' to `always', because I think you
+typically want to start it out with incremental completion turned on.
+Other Icicles search commands are defined using `icicle-search', so
+they also effectively turn on incremental completion.  Remember that
+you can use `C-#' (once or twice) to turn it off.
+
 This command is intended for use only in Icicle mode."
   (interactive `(,@(icicle-region-or-buffer-limits)
                  ,(if icicle-search-whole-word-flag
@@ -4579,6 +4841,19 @@ If ACTION is non-nil then it is a function that accepts no arguments.
                         (overlay-put ov 'priority 200) ; > ediff's 100+, < isearch-overlay's 1001.
                         (overlay-put ov 'face 'icicle-search-main-regexp-others)))))
                 (setq last-beg  beg))
+              (let* ((total  (length temp-list))
+                     (count  total)
+                     hit-str  help)
+                (dolist (hit  temp-list)
+                  (when (consp (car hit)) (setq hit  (car hit)))
+                  (setq hit-str  (car hit)
+                        help     (or (get-text-property 0 'icicle-mode-line-help hit-str)  "")
+                        help     (format "Context %d/%d%s%s" count total
+                                         (if add-bufname-p " in " ", ")
+                                         help)
+                        count    (1- count))
+                  (put-text-property 0 1 'icicle-mode-line-help help hit-str)
+                  (setcar hit hit-str)))
               (setq icicle-candidates-alist  (append icicle-candidates-alist (nreverse temp-list))))
           (quit (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)))
           (error (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup))
@@ -4840,13 +5115,8 @@ current input matches candidate") (sit-for 2))
                    (while (and (or first-p  icicle-all-candidates-action)
                                (re-search-forward (or ecm  icicle-current-input) nil 'move-to-end))
                      (setq first-p  nil)
-                      ;; Search for original regexp, to set match data so replacements such as `\N' work.
-                     (when (and icicle-search-regexp  (> emacs-major-version 21))
-                       (goto-char (point-min))
-                       (re-search-forward icicle-search-regexp nil 'move-to-end))
-                     (icicle-search-replace-match replace-string
-                                                  (icicle-search-replace-fixed-case-p
-                                                   icicle-current-input)))))))
+                     (icicle-search-replace-match replace-string (icicle-search-replace-fixed-case-p
+                                                                  icicle-current-input)))))))
         (when replacement-p
           ;; Update the alist and `minibuffer-completion-table' with the new text.
 
@@ -4920,6 +5190,18 @@ FIXEDCASE is as for `replace-match'.  Non-nil means do not alter case."
                    (funcall (car compiled) (cdr compiled) (setq replace-count  (1+ replace-count)))
                  compiled)
                fixedcase icicle-search-replace-literally-flag nil (match-data)))
+          ;; @@@@@@ Hopefully this is only a temporary hack, until Emacs bug #18388 is fixed.
+          (wrong-number-of-arguments
+           (condition-case icicle-search-replace-match3
+               (replace-match-maybe-edit
+                (if (consp compiled)
+                    ;; `replace-count' is free here, bound in `icicle-search'.
+                    (funcall (car compiled) (cdr compiled) (setq replace-count  (1+ replace-count)))
+                  compiled)
+                fixedcase icicle-search-replace-literally-flag nil (match-data)
+                nil)                    ; BACKWARD parameter for Emacs 24.4+ - see bug #18388
+             (buffer-read-only (ding) (icicle-user-error "Buffer is read-only"))
+             (error (icicle-remove-Completions-window) (icicle-user-error "No match for `%s'" replace-string))))
           (buffer-read-only (ding) (icicle-user-error "Buffer is read-only"))
           (error (icicle-remove-Completions-window) (icicle-user-error "No match for `%s'" replace-string))))
     (condition-case icicle-search-replace-match2 ; Emacs < 22.  Try to interpret `\'.
@@ -4982,7 +5264,7 @@ No such highlighting is done if any of these conditions holds:
 (defun icicle-search-replace-fixed-case-p (from)
   "Return non-nil if FROM should be replaced without transferring case.
 FROM is a string or nil.  If FROM is nil, then return nil.
-Retuns non-nil if FROM is a string and one of the following holds:
+Returns non-nil if FROM is a string and one of the following holds:
  * FROM is not all lowercase
  * `case-replace' or `case-fold-search' is nil"
   (and from  (not (and case-fold-search  case-replace  (string= from (downcase from))))))
@@ -5135,10 +5417,13 @@ using `icicle-search'.  For more information, see the doc for command
   ((enable-recursive-minibuffers             t) ; In case we read input, e.g. File changed on disk...
    (completion-ignore-case                   bookmark-completion-ignore-case)
    (prompt                                   "Search bookmark: ")
-   (icicle-search-context-regexp             (icicle-search-read-context-regexp))
+   (icicle-search-context-regexp             (icicle-search-read-context-regexp
+                                              (format "Search bookmarks %swithin contexts (regexp): "
+                                                      (if icicle-search-complement-domain-p "*NOT* " ""))))
    (bookmark-automatically-show-annotations  nil) ; Do not show annotations
    (icicle-multi-completing-p                icicle-show-multi-completion-flag)
    (icicle-list-use-nth-parts                '(1))
+   (icicle-bookmark-completing-p             t)
    (icicle-candidate-properties-alist        (if (not icicle-show-multi-completion-flag)
                                                  ()
                                                '((2 (face icicle-annotation))
@@ -5396,19 +5681,6 @@ list includes the names of the symbols that satisfy
     (setq types  (sort types #'string-lessp))
     (mapcar #'list types)))
 
-;;; Same as `thgcmd-defined-thing-p' in `thing-cmds.el'.
-(defun icicle-defined-thing-p (thing)
-  "Return non-nil if THING (type) is defined as a thing-at-point type."
-  (let ((forward-op    (or (get thing 'forward-op)  (intern-soft (format "forward-%s" thing))))
-        (beginning-op  (get thing 'beginning-op))
-        (end-op        (get thing 'end-op))
-        (bounds-fn     (get thing 'bounds-of-thing-at-point))
-        (thing-fn      (get thing 'thing-at-point)))
-    (or (functionp forward-op)
-        (and (functionp beginning-op)  (functionp end-op))
-        (functionp bounds-fn)
-        (functionp thing-fn))))
-
 ;; Same as `hide/show-comments' in `hide-comnt.el'.
 ;;
 (defun icicle-hide/show-comments (&optional hide/show start end)
@@ -6254,7 +6526,9 @@ using `icicle-search'.  For more information, see the doc for command
 `icicle-search', but without BEG, END, and WHERE."
   (interactive `(,(if icicle-search-whole-word-flag
                       (icicle-search-read-word)
-                      (icicle-search-read-context-regexp))
+                      (icicle-search-read-context-regexp
+                       (format "Search bookmarks %swithin contexts (regexp): "
+                               (if icicle-search-complement-domain-p "*NOT* " ""))))
                  ,(not icicle-show-multi-completion-flag)))
   (let ((icicle-multi-completing-p  icicle-show-multi-completion-flag))
     (apply #'icicle-search nil nil scan-fn-or-regexp require-match
@@ -6553,8 +6827,8 @@ using `icicle-search'.  For more information, see the doc for command
   (let ((icicle-multi-completing-p  (and current-prefix-arg
                                          (not (zerop (prefix-numeric-value current-prefix-arg)))
                                          icicle-show-multi-completion-flag))
-        (fg (face-foreground        'icicle-search-main-regexp-others))
-        (bg (face-background        'icicle-search-main-regexp-others))
+        (fg                         (face-foreground 'icicle-search-main-regexp-others))
+        (bg                         (face-background 'icicle-search-main-regexp-others))
         (icicle-transform-function  (and (not (interactive-p))  icicle-transform-function)))
     (unwind-protect
          (progn (set-face-foreground 'icicle-search-main-regexp-others nil)
@@ -6728,8 +7002,7 @@ information about the arguments, see the doc for command
   ;; Is there a better test we can use, to make sure the current mode inherits from `comint-mode'?
   (unless (where-is-internal 'comint-send-input (keymap-parent (current-local-map)))
     (icicle-user-error "Current mode must be derived from comint mode"))
-  (let ((orig-search-hook           icicle-search-hook)
-        (icicle-transform-function  'icicle-remove-duplicates))
+  (let ((icicle-transform-function  'icicle-remove-duplicates))
     (add-hook 'icicle-search-hook 'icicle-comint-search-send-input)
     (unwind-protect
          (icicle-search beg end (concat comint-prompt-regexp "\\S-.*") nil) ; Match not required (edit).
@@ -6946,7 +7219,7 @@ procedure name."
     (icicle-imenu-1 nil beg end require-match where)))
 
 (defun icicle-imenu-help (cand)
-  "Use as `icicle-candidate-help-fn' for `icicle-search' commands."
+  "Use as `icicle-candidate-help-fn' for `icicle-imenu' commands."
   (let* ((icicle-whole-candidate-as-text-prop-p  t)
          (marker  (cdr (funcall icicle-get-alist-candidate-function cand)))
          (buffer  (marker-buffer marker)))
@@ -7001,7 +7274,7 @@ search multiple regions, buffers, or files, see the doc for command
     (icicle-user-error "This command is only for Emacs-Lisp mode"))
   (icicle-imenu-1 nil beg end require-match where 'icicle-imenu-command-p
                   (lambda (menus)
-                    (or (car (assoc "Functions" menus))
+                    (or (car (icicle-alist-key-match "Functions.*" menus))
                         (car (assoc "Other" menus))
                         (icicle-user-error "No command definitions in buffer")))))
 
@@ -7023,7 +7296,7 @@ anytime during completion using `C-u C-x .'"
     (icicle-user-error "This command is only for Emacs-Lisp mode"))
   (icicle-imenu-1 'FULL beg end require-match where 'icicle-imenu-command-p
                   (lambda (menus)
-                    (or (car (assoc "Functions" menus))
+                    (or (car (icicle-alist-key-match "Functions.*" menus))
                         (car (assoc "Other" menus))
                         (icicle-user-error "No command definitions in buffer")))))
 
@@ -7054,7 +7327,7 @@ search multiple regions, buffers, or files, see the doc for command
     (icicle-user-error "This command is only for Emacs-Lisp mode"))
   (icicle-imenu-1 nil beg end require-match where 'icicle-imenu-non-interactive-function-p
                   (lambda (menus)
-                    (or (car (assoc "Functions" menus))
+                    (or (car (icicle-alist-key-match "Functions.*" menus))
                         (car (assoc "Other" menus))
                         (icicle-user-error "No non-command function definitions in buffer")))))
 
@@ -7076,7 +7349,7 @@ anytime during completion using `C-u C-x .'"
     (icicle-user-error "This command is only for Emacs-Lisp mode"))
   (icicle-imenu-1 'FULL beg end require-match where 'icicle-imenu-non-interactive-function-p
                   (lambda (menus)
-                    (or (car (assoc "Functions" menus))
+                    (or (car (icicle-alist-key-match "Functions.*" menus))
                         (car (assoc "Other" menus))
                         (icicle-user-error "No non-command function definitions in buffer")))))
 
@@ -7353,40 +7626,52 @@ The other args are as for `icicle-search'."
     (unwind-protect
          (save-match-data
            (set-syntax-table table)
-           (let* ((others   0)
+           (let* ((regexp   nil)
+                  (others   0)
                   (menus    (mapcar (lambda (menu)
                                       (when (equal (car menu) "Other")
                                         (setq others  (1+ others))
-                                        (when (> others 1)
-                                          (setcar menu (format "Other<%d>" others))))
+                                        (when (> others 1) (setcar menu (format "Other<%d>" others))))
                                       menu)
                                     (icicle-remove-if-not
                                      #'icicle-imenu-in-buffer-p ; Use only menus that match buffer.
                                      (mapcar (lambda (menu) ; Name unlabeled menu(s) `Other[<N>]'.
-                                               (if (stringp (car menu))
-                                                   menu
-                                                 (cons "Other" (cdr menu))))
+                                               (if (stringp (car menu)) menu (cons "Other" (cdr menu))))
                                              imenu-generic-expression))))
                   (submenu  (if submenu-fn
                                 (funcall submenu-fn menus)
                               (if (cadr menus)
-                                  (let ((icicle-show-Completions-initially-flag  t)
-                                        (completion-ignore-case                  t))
-                                    (completing-read "Choose: " menus nil t))
+                                  ;; There could be multiple submenus with the same name.
+                                  ;; E.g., `Functions' could come from `defun' or `defalias'.
+                                  ;; So we cannot just use (cadr (assoc submenus menus)) to get the regexp.
+                                  (let* ((icicle-show-Completions-initially-flag  t)
+                                         (icicle-whole-candidate-as-text-prop-p   t)
+                                         (icicle-candidates-alist                 menus)
+                                         (icicle-remove-icicles-props-p           nil) ;`icicle-whole-candidate'
+                                         (completion-ignore-case                  t)
+                                         (submnu                                  (completing-read
+                                                                                   "Choose: " menus nil t)))
+                                    (setq regexp  (cadr (icicle-get-alist-candidate submnu 'NO-ERROR))))
                                 (caar menus)))) ; Only one submenu, so use it.
-                  (regexp   (cadr (assoc submenu menus)))
                   (icicle-transform-function
                    (and (not (interactive-p))  icicle-transform-function)))
-             (unless (stringp regexp) (icicle-user-error "No match"))
-             (icicle-search
-              beg end regexp require-match where predicate
-              ;; We rely on the match data having been preserved.
-              ;; $$$$$$ An alternative fn for Lisp only: (lambda () (up-list -1) (forward-sexp))))))
-              (and fullp  (lambda ()
-                            (goto-char (match-beginning 0))
-                            (condition-case icicle-imenu-1
-                                (forward-sexp)
-                              (error (goto-char (match-end 0))))))))) ; Punt: just use regexp match.
+             (unless (stringp regexp)
+               (if submenu (setq regexp  (cadr (assoc submenu menus))) (icicle-user-error "No match")))
+             (unwind-protect
+                  (progn (when (boundp 'imenu-after-jump-hook)
+                           (dolist (fn  imenu-after-jump-hook) (add-hook 'icicle-search-hook fn)))
+                         (icicle-search beg end regexp require-match where predicate
+                                        ;; We rely on the match data having been preserved.
+                                        ;; $$$$$$ An alternative fn for Lisp only:
+                                        ;;        (lambda () (up-list -1) (forward-sexp))))))
+                                        (and fullp  (lambda ()
+                                                      (goto-char (match-beginning 0))
+                                                      (condition-case icicle-imenu-1
+                                                          (forward-sexp)
+                                                        ;; Punt: just use regexp match.
+                                                        (error (goto-char (match-end 0))))))))
+               (when (boundp 'imenu-after-jump-hook)
+                 (dolist (fn  imenu-after-jump-hook) (remove-hook 'icicle-search-hook fn))))))
       (set-syntax-table old-table))))
 
 (defun icicle-imenu-in-buffer-p (menu)
@@ -7447,7 +7732,7 @@ future search commands, not the current one.)"
           (setcar tail (cadr tail))
           (setcdr tail (cddr tail))))
       (when unreadable-files
-        (with-output-to-temp-buffer "*Unreadable Files*"
+        (icicle-with-help-window "*Unreadable Files*"
           (princ "These missing or unreadable files were ignored:") (terpri) (terpri)
           (dolist (file  unreadable-files) (princ file) (terpri)))))
     (select-window (minibuffer-window))
@@ -7926,7 +8211,7 @@ filtering:
                            (and (fboundp 'confirm-nonexistent-file-or-buffer) ; Emacs 23.
                                 (confirm-nonexistent-file-or-buffer))
                            nil 'buffer-name-history nil nil))))
-      (color (icicle-read-color-wysiwyg 1)) ; Use the color name (only).
+      (color (icicle-read-color-WYSIWYG 1)) ; Use the color name (only).
       (command (let* ((pred                                    (lambda (s)
                                                                  (unless (symbolp s) (setq s  (intern s)))
                                                                  (commandp s)))
@@ -8044,6 +8329,112 @@ This command requires library `expand-region.el'."
   (unless (require 'expand-region nil t) ; First code
     (icicle-user-error "You need library `expand-region.el' for this command")))
 
+
+;; Based on the `describe-package' definition in `help-fns+.el'.  Try to keep the two synced.
+;;
+(when (fboundp 'describe-package)       ; Emacs 24+
+  (defun icicle-describe-package (package)
+    "Display the full documentation of PACKAGE (a symbol).
+During completion for a package name, you can use `M-&' to narrow the
+candidates to packages of different kinds."
+    (interactive
+     (let* ((guess  (function-called-at-point)))
+       (require 'finder-inf nil t)
+       ;; Load the package list if necessary (but don't activate them).
+       (unless package--initialized (package-initialize t))
+       (let ((packages                     (append (mapcar 'car package-alist)
+                                                   (mapcar 'car package-archive-contents)
+                                                   (mapcar 'car package--builtins)))
+             (icicle-package-completing-p  t))
+         (unless (memq guess packages) (setq guess  nil))
+         (setq packages  (mapcar 'symbol-name packages))
+         (let ((val  (completing-read (if guess
+                                          (format "Describe package (default %s): " guess)
+                                        "Describe package: ")
+                                      packages nil t nil nil guess)))
+           (list (if (equal val "") guess (intern val)))))))
+    (if (not (or (and (fboundp 'package-desc-p)  (package-desc-p package))
+                 (and package (symbolp package))))
+        (when (called-interactively-p 'interactive) (message "No package specified"))
+      (help-setup-xref (list #'describe-package package) (called-interactively-p 'interactive))
+      (with-help-window (help-buffer)
+        (with-current-buffer standard-output
+          (describe-package-1 package)
+          (when (fboundp 'package-desc-name)  (setq package  (package-desc-name package))) ; Emacs 24.4+
+          (when (fboundp 'Info-make-manuals-xref) ; In `help-fns+.el', for Emacs 23.2+.
+            (Info-make-manuals-xref (concat (symbol-name package) " package")
+                                    nil nil (not (called-interactively-p 'interactive)))))))))
+
+(defun icicle-wide-n ()
+  "Choose a restriction and apply it.  Or choose `No restriction' to widen.
+During completion you can use these keys\\<minibuffer-local-completion-map>:
+
+`C-RET'   - Goto marker named by current completion candidate
+`C-down'  - Goto marker named by next completion candidate
+`C-up'    - Goto marker named by previous completion candidate
+`C-next'  - Goto marker named by next apropos-completion candidate
+`C-prior' - Goto marker named by previous apropos-completion candidate
+`C-end'   - Goto marker named by next prefix-completion candidate
+`C-home'  - Goto marker named by previous prefix-completion candidate
+`\\[icicle-delete-candidate-object]' - Delete restriction named by current completion candidate
+
+When candidate action and cycling are combined (e.g. `C-next'), option
+`icicle-act-before-cycle-flag' determines which occurs first.
+
+Use `mouse-2', `RET', or `S-RET' to choose a candidate as the final
+destination, or `C-g' to quit.  This is an Icicles command - see
+command `icicle-mode'."
+  (interactive)
+  (unless (featurep 'wide-n) (error "You need library `wide-n.el' for this command"))
+  (unless (cadr wide-n-restrictions) (error "No restrictions - you have not narrowed this buffer"))
+  (if (< (length wide-n-restrictions) 3) ; Only one restriction.  If narrowed widen, else apply the restriction.
+      (wide-n 1 'MSG)
+    (let ((icicle-sort-comparer  'icicle-special-candidates-first-p)
+          (icicle-delete-candidate-object
+           (lambda (cand)
+             (let ((nn  (icicle-get-alist-candidate cand)))
+               (if (eq 'all (cadr nn)) (error "Cannot delete `No restriction'")
+                 (with-current-buffer icicle-pre-minibuffer-buffer
+                   (setq wide-n-restrictions  (delete 'all wide-n-restrictions)
+                         wide-n-restrictions  (delete (cdr nn) wide-n-restrictions))
+                   (wide-n-renumber)))))))
+      (icicle-apply (let ((ns  ())
+                          beg end name)
+                      (save-restriction
+                        (widen)
+                        (dolist (nn  wide-n-restrictions)
+                          (if (eq 'all nn)
+                              (push `(,(icicle-propertize "No restriction" 'face 'icicle-special-candidate) all)
+                                    ns)
+                            (setq beg   (marker-position (cadr nn))
+                                  end   (marker-position (cddr nn))
+                                  name  (format "%d-%d, %s" beg end (buffer-substring beg end))
+                                  name  (replace-regexp-in-string "\n" " "
+                                                                  (substring name 0 (min 30 (length name))))
+                                  name  (format "%s\n" name))
+                            (push `(,name ,(car nn) ,@(cdr nn)) ns))))
+                      ns)
+                    #'icicle-wide-n-action
+                    'NOMSG))))
+
+(defun icicle-wide-n-action (cand)
+  "Action function for `icicle-wide-n': Narrow region to candidate CAND.
+If CAND has car \"No restriction\" then widen it instead."
+  (with-current-buffer icicle-pre-minibuffer-buffer
+    (if (not (eq 'all (cadr cand)))     ; "No restriction"
+        (condition-case err
+            (let ((wide-n-push-anyway-p  t))
+              (narrow-to-region (car (cddr cand)) (cdr (cddr cand)))
+              (wide-n-highlight-lighter)
+              (message wide-n-lighter-narrow-part))
+          (args-out-of-range
+           (setq wide-n-restrictions  (cdr wide-n-restrictions))
+           (error "Restriction removed because of invalid limits"))
+          (error (error "%s" (error-message-string err))))
+      (widen)
+      (wide-n-highlight-lighter)
+      (message "No longer narrowed"))))
+
 (defvar icicle-key-prefix nil
   "A prefix key.")
 
@@ -8153,6 +8544,7 @@ Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or
     (interactive)
     (let* ((completion-ignore-case                  t) ; Not case-sensitive, by default.
            (icicle-transform-function               'icicle-remove-duplicates)
+           (icicle-must-pass-after-match-predicate  nil) ; Remove any current one, e.g. for `M-x'.
            (icicle-orig-sort-orders-alist           icicle-sort-orders-alist) ; For recursive use.
            (icicle-orig-show-initially-flag         icicle-show-Completions-initially-flag)
            (icicle-show-Completions-initially-flag  t)
@@ -8179,6 +8571,7 @@ information."
     (interactive)
     (let* ((completion-ignore-case                  t) ; Not case-sensitive, by default.
            (icicle-transform-function               'icicle-remove-duplicates)
+           (icicle-must-pass-after-match-predicate  nil) ; Remove any current one, e.g. for `M-x'.
            (icicle-orig-sort-orders-alist           icicle-sort-orders-alist) ; For recursive use.
            (icicle-orig-show-initially-flag         icicle-show-Completions-initially-flag)
            (icicle-show-Completions-initially-flag  t)
@@ -8204,20 +8597,28 @@ But IF (a) this command is `icicle-complete-keys' and
            option `icicle-complete-keys-ignored-prefix-keys'
   THEN return [], as if `icicle-complete-keys' was invoked at top
        level, i.e., with no prefix key."
-  (let* ((this-key-sequence  (this-command-keys-vector))
-         (this-prefix        (substring this-key-sequence 0 (1- (length this-key-sequence)))))
-    (when (and (eq this-command 'icicle-complete-keys)
-               (icicle-some icicle-complete-keys-ignored-prefix-keys
-                            this-prefix
-                            #'icicle-same-vector-keyseq-p))
-      (setq this-prefix []))
-    this-prefix))
+    (let* ((this-key-sequence  (this-command-keys-vector))
+           (this-prefix        (substring this-key-sequence 0 (1- (length this-key-sequence)))))
+      (when (or (and (active-minibuffer-window)
+                     (icicle-some icicle-key-complete-keys-for-minibuffer
+                                  this-key-sequence
+                                  #'icicle-same-vector-keyseq-p))
+                (and (eq this-command 'icicle-complete-keys)
+                     (icicle-some icicle-complete-keys-ignored-prefix-keys
+                                  this-prefix
+                                  #'icicle-same-vector-keyseq-p)))
+        (setq this-prefix []))
+      this-prefix))
 
   (defun icicle-same-vector-keyseq-p (key1 key2)
     "Return non-nil if KEY1 and KEY2 represent the same key sequence.
 Each is a vector."
-    (equal (apply #'vector (mapcar #'icicle-unlist key1))
-           (apply #'vector (mapcar #'icicle-unlist key2))))
+    ;; 1. Roundtrip through `key-description' and `kbd' so that [ESC ...] and [27 ...] are treated the same.
+    ;; 2. Use `icicle-read-kbd-macro' instead of just `kbd', because Emacs 20 `read-kbd-macro' chokes the
+    ;;    Emacs 20 byte-compiler.
+    (let ((desc1  (key-description (apply #'vector (mapcar #'icicle-unlist key1))))
+          (desc2  (key-description (apply #'vector (mapcar #'icicle-unlist key2)))))
+      (equal (icicle-read-kbd-macro desc1 nil t) (icicle-read-kbd-macro desc2 nil t))))
 
   ;; Free vars here: `icicle-complete-keys-alist' is bound in `icicles-var.el'.
   ;;
@@ -8252,7 +8653,6 @@ Each is a vector."
           (put (car cand) 'icicle-special-candidate nil))))) ; Reset the property.
 
   ;; Free vars here:
-  ;; `icicle-orig-buff', `icicle-orig-window', bound in `icicle-complete-keys'.
   ;; `icicle-orig-extra-cands', `icicle-this-cmd-keys', `icicle-key-prefix',
   ;; bound in `icicle-complete-keys-1'.
   (defun icicle-complete-keys-action (candidate)
@@ -8264,8 +8664,8 @@ Each is a vector."
            (action-window  (selected-window)))
       (unwind-protect
            (progn
-             (set-buffer icicle-orig-buff)
-             (select-window icicle-orig-window)
+             ;; $$$$$$$$ (set-buffer icicle-orig-buff)       ; These are not bound.
+             ;; $$$$$$$$ (select-window icicle-orig-window)
              (if (string= ".." candidate)
                  (setq cmd-name  "..")
                (unless (and (string-match "\\(.+\\)  =  \\(.+\\)" candidate)  (match-beginning 2))