;; Description: Non-interactive functions 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: Mon Feb 27 09:25:53 2006
-;; Last-Updated: Tue Apr 29 18:03:41 2014 (-0700)
+;; Last-Updated: Sat Feb 7 14:17:40 2015 (-0800)
;; By: dradams
-;; Update #: 14628
+;; Update #: 15075
;; URL: http://www.emacswiki.org/icicles-fn.el
;; Doc URL: http://www.emacswiki.org/Icicles
;; Keywords: internal, 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', `cl', `cus-theme',
-;; `el-swank-fuzzy', `ffap', `ffap-', `fuzzy', `fuzzy-match',
-;; `hexrgb', `icicles-opt', `icicles-var', `kmacro', `levenshtein',
-;; `naked', `regexp-opt', `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-theme',
+;; `el-swank-fuzzy', `ffap', `ffap-', `fit-frame', `frame-fns',
+;; `fuzzy', `fuzzy-match', `help+20', `hexrgb', `icicles-opt',
+;; `icicles-var', `info', `info+20', `kmacro', `levenshtein',
+;; `menu-bar', `menu-bar+', `misc-cmds', `misc-fns', `naked',
+;; `package', `pp', `pp+', `regexp-opt', `second-sel', `strings',
+;; `thingatpt', `thingatpt+', `unaccent', `w32browser-dlgopen',
+;; `wid-edit', `wid-edit+', `widget'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;; `assq-delete-all', `icicle-2nd-part-string-less-p',
;; `icicle-abbreviate-or-expand-file-name',
-;; `icicle-all-completions', `icicle-alpha-p',
-;; `icicle-alt-act-fn-for-type', `icicle-any-candidates-p',
-;; `icicle-apropos-any-candidates-p',
+;; `icicle-alist-key-match', `icicle-all-completions',
+;; `icicle-alpha-p', `icicle-alt-act-fn-for-type',
+;; `icicle-any-candidates-p', `icicle-apropos-any-candidates-p',
;; `icicle-apropos-any-file-name-candidates-p',
;; `icicle-apropos-candidates', `icicle-assoc-delete-all',
;; `icicle-barf-if-outside-Completions',
;; `icicle-barf-if-outside-Completions-and-minibuffer',
;; `icicle-barf-if-outside-minibuffer',
+;; `icicle-bookmark-annotated-p', `icicle-bookmark-autofile-p',
+;; `icicle-bookmark-autonamed-p',
+;; `icicle-bookmark-autonamed-this-buffer-p',
+;; `icicle-bookmark-bookmark-file-p',
+;; `icicle-bookmark-bookmark-list-p', `icicle-bookmark-desktop-p',
+;; `icicle-bookmark-dired-p', `icicle-bookmark-dired-this-dir-p',
+;; `icicle-bookmark-dired-wildcards-p', `icicle-bookmark-file-p',
+;; `icicle-bookmark-file-this-dir-p', `icicle-bookmark-flagged-p',
+;; `icicle-bookmark-function-p', `icicle-bookmark-gnus-p',
+;; `icicle-bookmark-icicle-search-hits-p',
+;; `icicle-bookmark-image-p', `icicle-bookmark-info-p',
+;; `icicle-bookmark-lighted-p',
+;; `icicle-bookmark-local-directory-p',
+;; `icicle-bookmark-local-file-p', `icicle-bookmark-man-p',
+;; `icicle-bookmark-marked-p', `icicle-bookmark-modified-p',
+;; `icicle-bookmark-navlist-p', `icicle-bookmark-non-dir-file-p',
+;; `icicle-bookmark-non-file-p', `icicle-bookmark-omitted-p',
+;; `icicle-bookmark-orphaned-file-p',
+;; `icicle-bookmark-orphaned-local-file-p',
+;; `icicle-bookmark-orphaned-remote-file-p',
+;; `icicle-bookmark-region-p', `icicle-bookmark-remote-file-p',
+;; `icicle-bookmark-sequence-p', `icicle-bookmark-snippet-p',
+;; `icicle-bookmark-tagged-p', `icicle-bookmark-temporary-p',
+;; `icicle-bookmark-this-buffer-p', `icicle-bookmark-url-p',
+;; `icicle-bookmark-url-browse-p',
+;; `icicle-bookmark-variable-list-p', `icicle-bookmark-w3m-p',
;; `icicle-bounds-of-thing-at-point',
;; `icicle-buffer-file/process-name-less-p',
-;; `icicle-buffer-smaller-p',
+;; `icicle-buffer-modified-p', `icicle-buffer-smaller-p',
;; `icicle-call-then-update-Completions', `icicle-candidate-set-1',
;; `icicle-candidate-short-help',
;; `icicle-case-insensitive-string-less-p',
;; `icicle-case-string-less-p', `icicle-cdr-lessp',
;; `icicle-char-cands-from-charlist',
;; `icicle-choose-completion-string', `icicle-clear-lighter',
-;; `icicle-clear-minibuffer', `icicle-color-name-w-bg',
-;; `icicle-color-rgb-lessp', `icicle-command-abbrev-save',
+;; `icicle-clear-minibuffer', `icicle-color-gray-p',
+;; `icicle-color-name-w-bg', `icicle-color-rgb-lessp',
+;; `icicle-color-supported-p', `icicle-command-abbrev-save',
;; `icicle-command-abbrev-used-more-p',
;; `icicle-command-names-alphabetic-p',
-;; `icicle-complete-again-update', `icicle-completing-p',
-;; `icicle-completing-read', `icicle-completing-read-multiple',
+;; `icicle-compilation-buffer-p', `icicle-complete-again-update',
+;; `icicle-completing-p', `icicle-completing-read',
+;; `icicle-completing-read-default',
+;; `icicle-completing-read-multiple',
;; `icicle-completing-read-history',
;; `icicle-completion-all-completions',
;; `icicle-completion-setup-function',
;; `icicle-completion--embedded-envvar-table',
;; `icicle-completion-try-completion', `icicle-create-thumb',
;; `icicle-current-TAB-method', `icicle-custom-type',
-;; `icicle-defaults-at-point', `icicle-define-crm-completion-map',
+;; `icicle-custom-variable-p', `icicle-defaults-at-point',
+;; `icicle-define-crm-completion-map', `icicle-defined-thing-p',
;; `icicle-delete-alist-dups', `icicle-delete-count',
;; `icicle-delete-dups', `icicle-delete-whitespace-from-string',
;; `icicle-dired-read-shell-command',
;; `icicle-dirs-last-p', `icicle-displayable-cand-from-saved-set',
;; `icicle-display-cand-from-full-cand',
;; `icicle-display-completion-list', `icicle-display-Completions',
-;; `icicle-display-candidates-in-Completions',
;; `icicle-expanded-common-match',
;; `icicle-expanded-common-match-1', `icicle-expand-file-name-20',
;; `icicle-expand-file-or-dir-name',
;; `icicle-explicit-saved-completion-candidates',
-;; `icicle-extra-candidates-first-p',
+;; `icicle-extra-candidates-first-p', `icicle-face-bold-p',
+;; `icicle-face-differs-from-default-p',
+;; `icicle-face-inverse-video-p', `icicle-face-italic-p',
+;; `icicle-face-nontrivial-p', `icicle-face-underline-p',
;; `icicle-face-valid-attribute-values',
+;; `icicle-ffap-file-remote-p', `icicle-ffap-url-p',
+;; `icicle-file-accessible-directory-p',
+;; `icicle-file-compressed-p', `icicle-file-desktop-p',
+;; `icicle-file-directory-p', `icicle-file-elc-p',
+;; `icicle-file-executable-p', `icicle-file-exists-p',
+;; `icicle-file-locked-p', `icicle-file-name-absolute-p',
;; `icicle-file-name-apropos-candidates',
;; `icicle-file-name-directory',
;; `icicle-file-name-directory-w-default',
;; `icicle-file-name-input-p', `icicle-file-name-nondirectory',
;; `icicle-file-name-prefix-candidates', `icicle-file-readable-p',
-;; `icicle-file-remote-p', `icicle-file-type-less-p',
-;; `icicle-file-writable-p', `icicle-filesets-files-under',
+;; `icicle-file-regular-p', `icicle-file-remote-p',
+;; `icicle-file-symlink-p', `icicle-file-writable-p',
+;; `icicle-filesets-files-under', `icicle-file-type-less-p',
;; `icicle-files-within', `icicle-files-within-1',
;; `icicle-filter-alist', `icicle-filter-wo-input',
;; `icicle-find-tag-default-as-regexp',
;; `icicle-first-matching-candidate', `icicle-first-N',
;; `icicle-fit-completions-window', `icicle-fix-default-directory',
-;; `icicle-flat-list', `icicle-frames-on',
-;; `icicle-fuzzy-candidates', `icicle-get-alist-candidate',
+;; `icicle-flat-list', `icicle-frame-iconified-p',
+;; `icicle-frame-invisible-p', `icicle-frames-on',
+;; `icicle-frame-splittable-p', `icicle-frame-thumbnail-p',
+;; `icicle-frame-unsplittable-p', `icicle-fuzzy-candidates',
+;; `icicle-get-alist-candidate',
;; `icicle-get-candidates-from-saved-set', `icicle-get-safe',
;; `icicle-dired-guess-shell-command',
-;; `icicle-handle-default-for-prompt', `icicle-help-line-buffer',
-;; `icicle-help-line-file',
+;; `icicle-handle-default-for-prompt',
;; `icicle-highlight-candidate-in-Completions',
;; `icicle-highlight-complete-input',
;; `icicle-highlight-initial-whitespace',
;; `icicle-highlight-input-noncompletion',
;; `icicle-highlight-input-noncompletion-rest',
;; `icicle-highlight-lighter', `icicle-historical-alphabetic-p',
-;; `icicle-increment-cand-nb+signal-end',
+;; `icicle-image-file-p', `icicle-increment-cand-nb+signal-end',
;; `icicle-Info-node-is-indexed-by-topic',
;; `icicle-input-from-minibuffer', `icicle-insert-candidates',
;; `icicle-insert-cand-in-minibuffer',
;; `icicle-insert-Completions-help-string',
-;; `icicle-join-nth-parts', `icicle-key-description',
-;; `icicle-kill-a-buffer', `icicle-latest-access-first-p',
-;; `icicle-latest-input-first-p',
+;; `icicle-interesting-buffer-p', `icicle-join-nth-parts',
+;; `icicle-key-description', `icicle-kill-a-buffer',
+;; `icicle-latest-access-first-p', `icicle-latest-input-first-p',
;; `icicle-latest-modification-first-p',
;; `icicle-latest-use-first-p', `icicle-levenshtein-match',
;; `icicle-levenshtein-one-match', `icicle-levenshtein-one-regexp',
-;; `icicle-levenshtein-strict-match',
-;; `icicle-lisp-vanilla-completing-read', `icicle-list-position',
+;; `icicle-levenshtein-strict-match', `icicle-list-position',
;; `icicle-looks-like-dir-name-p', `icicle-local-keys-first-p',
;; `icicle-make-char-candidate', `icicle-make-face-candidate',
;; `icicle-make-plain-predicate', `icicle-major-mode-name-less-p',
;; `icicle-mouseover-help', `icicle-msg-maybe-in-minibuffer',
;; `icicle-ms-windows-NET-USE',
;; `icicle-multi-comp-apropos-complete-match', `icicle-multi-sort',
-;; `icicle-next-candidate', `icicle-not-basic-prefix-completion-p',
+;; `icicle-next-candidate', `icicle-next-error-buffer-p',
+;; `icicle-nondirectory-p', `icicle-not-basic-prefix-completion-p',
+;; `icicle-not-special-candidate-p',
;; `icicle-ORIG-choose-completion-string',
;; `icicle-ORIG-completing-read',
;; `icicle-ORIG-completing-read-multiple',
;; `icicle-ORIG-read-from-minibuffer', `icicle-ORIG-read-number',
;; `icicle-ORIG-read-string', `icicle-ORIG-shell-command',
;; `icicle-ORIG-shell-command-on-region',
-;; `icicle-part-1-cdr-lessp', `icicle-part-1-lessp',
-;; `icicle-part-2-lessp', `icicle-part-3-lessp',
-;; `icicle-part-4-lessp', `icicle-part-N-lessp',
-;; `icicle-place-cursor', `icicle-place-overlay',
-;; `icicle-position', `icicle-prefix-any-candidates-p',
+;; `icicle-package-built-in-p', `icicle-package-disabled-p',
+;; `icicle-package-installed-p', `icicle-part-1-cdr-lessp',
+;; `icicle-part-1-lessp', `icicle-part-2-lessp',
+;; `icicle-part-3-lessp', `icicle-part-4-lessp',
+;; `icicle-part-N-lessp', `icicle-place-cursor',
+;; `icicle-place-overlay', `icicle-position',
+;; `icicle-prefix-any-candidates-p',
;; `icicle-prefix-any-file-name-candidates-p',
;; `icicle-prefix-candidates', `icicle-prefix-keys-first-p',
;; `icicle-propertize', `icicle-proxy-candidate-first-p',
;; `icicle-read-regexp', `icicle-read-shell-command',
;; `icicle-read-shell-command-completing', `icicle-read-string',
;; `icicle-read-string-completing', `icicle-repeat-command',
+;; `icicle-recentf-include-p', `icicle-recentf-keep-p',
;; `icicle-recentf-make-menu-items', `icicle-recompute-candidates',
;; `icicle-remove-color-duplicates', `icicle-remove-dots',
;; `icicle-remove-duplicates', `icicle-remove-dups-if-extras',
;; `icicle-save-raw-input', `icicle-scatter',
;; `icicle-scatter-match', `icicle-scroll-or-update-Completions',
;; `icicle-set-difference', `icicle-set-intersection',
-;; `icicle-set-union', `icicle-show-help-in-mode-line',
-;; `icicle-show-in-mode-line', `icicle-some',
-;; `icicle-special-candidates-first-p',
+;; `icicle-set-union', `icicle-some', `icicle-special-candidate-p',
+;; `icicle-special-candidates-first-p', `icicle-special-display-p',
+;; `icicle-special-variable-p',
;; `icicle-start-of-candidates-in-Completions',
;; `icicle-string-match-p', `icicle-strip-ignored-files-and-sort',
;; `icicle-subst-envvar-in-file-name',
;; `icicle-unsorted-prefix-candidates', `icicle-upcase',
;; `icicle-value-satisfies-type-p', `icicle-var-inherits-type-p',
;; `icicle-var-is-of-type-p', `icicle-var-matches-type-p',
-;; `icicle-var-val-satisfies-type-p',
+;; `icicle-var-val-satisfies-type-p', `icicle-window-at-bottom-p',
+;; `icicle-window-at-left-p', `icicle-window-at-right-p',
+;; `icicle-window-at-top-p', `icicle-window-dedicated-p',
+;; `icicle-window-deletable-p', `icicle-window-invisible-p',
;; `select-frame-set-input-focus'.
;;
;; Internal variables defined here:
;;
;; ***** NOTE: These EMACS PRIMITIVES have been REDEFINED HERE:
;;
+;; `face-valid-attribute-values' - (See doc string.)
+;; `read-buffer' - (See doc string.)
+;; `read-string' - (See doc string.)
+;;
+;;
+;; ***** NOTE: The following functions defined in `crm.el'
+;; have been REDEFINED HERE:
+;;
+;; `completing-read-multiple' - Inhibit Icicles features.
+;;
+;;
+;; ***** NOTE: The following functions defined in `dired-aux.el' and
+;; `dired-x.el' have been REDEFINED HERE:
+;;
+;; `dired-read-shell-command' - Use Icicles completion.
+;; - Added optional arg HISTORY.
+;; `dired-smart-shell-command' - Icicles completion (Emacs<23).
+;;
+;;
+;; ***** NOTE: The following functions defined in `faces.el'
+;; have been REDEFINED HERE:
+;;
+;; `read-face-name' - Show face names with the faces they name.
+;;
+;;
+;; ***** NOTE: The following function defined in `filesets.el' has
+;; been REDEFINED HERE:
+;;
+;; `filesets-get-filelist' - Fixed for Emacs bug #976.
+;;
+;;
+;; ***** NOTE: The following function defined in `files-x.el' is
+;; ADVISED HERE:
+;;
+;; `read-file-local-variable' - Provide predicates for `M-&'.
+;;
+;;
+;; ***** NOTE: The following functions defined in `minibuffer.el'
+;; have been REDEFINED HERE:
+;;
;; `completing-read' - (See doc string.)
;; `display-completion-list' - (See doc string.)
-;; `face-valid-attribute-values' - (See doc string.)
;; `read-file-name' Emacs 20, 21 only - (See doc string.)
;; `read-from-minibuffer' - (See doc string.)
-;; `read-string' - (See doc string.)
+;;
+;;
+;; ***** NOTE: The following functions defined in `mule-cmds.el'
+;; have been REDEFINED HERE:
+;;
+;; `read-char-by-name' - Use `icicle-ucs-names'.
+;; Display the char also.
+;; Added optional arg NAMES.
+;;
+;;
+;; ***** NOTE: The following function defined in `recentf.el' has
+;; been REDEFINED HERE:
+;;
+;; `recentf-make-menu-items' - Add Icicles submenu.
;;
;;
;; ***** NOTE: The following functions defined in `simple.el' have
;; been REDEFINED HERE:
;;
-;; `choose-completion-string' -
-;; Don't exit minibuffer after `lisp-complete-symbol' completion.
-;; `completion-setup-function' - 1. Put faces on inserted string(s).
-;; 2. Help on help.
-;; `repeat-complex-command' - Use `completing-read' to read command.
+;; `choose-completion-string' - Don't exit minibuffer after
+;; `lisp-complete-symbol' completion.
+;; `completion-setup-function' - 1. Put faces on inserted strings.
+;; 2. Help on help.
+;; `minibuffer-default-add-completions' - Respect Icicles filters.
+;; `read-shell-command' - Use Icicles completion.
+;; `repeat-complex-command' - Use `completing-read'.
+;; `shell-command' - Use Icicles completion (Emacs<23).
+;; `shell-command-on-region' - Use Icicles completion (Emacs<23).
;;
;;
-;; ***** NOTE: The following function defined in `filesets.el' has
+;; ***** NOTE: The following functions defined in `subr.el' have
;; been REDEFINED HERE:
;;
-;; `filesets-get-filelist' - Fix. Bug #976 reported to Emacs devel.
+;; `read-number' - You can enter a numeric var name.
+;; Allow completion. Handle errors.
+;;
;;
;; For descriptions of changes to this file, see `icicles-chg.el'.
;; http://dto.freeshell.org/notebook/Linkd.html.
;;
;; (@> "Macros")
-;; (@> "Redefined standard functions")
-;; (@> "Icicles functions - completion display (not cycling)")
-;; (@> "Icicles functions - TAB completion cycling")
-;; (@> "Icicles functions - S-TAB completion cycling")
-;; (@> "Icicles functions - common helper functions")
-;; (@> "Icicles functions - sort functions")
+;; (@> "Redefined Standard Functions")
+;; (@> "Icicles Functions - Completion Display (Not Cycling)")
+;; (@> "Icicles Functions - TAB Completion Cycling")
+;; (@> "Icicles Functions - S-TAB Completion Cycling")
+;; (@> "Icicles Functions - Common Helper Functions")
+;; (@> "Icicles Functions - Sort Functions")
+;; (@> "Icicles Predicates for Different Candidate Types")
+;; (@> "Bookmark-Completion Predicates")
+;; (@> "Buffer-Completion Predicates")
+;; (@> "Color-Completion Predicates")
+;; (@> "Face-Completion Predicates")
+;; (@> "File- and Directory-Completion Predicates")
+;; (@> "Frame-Completion Predicates")
+;; (@> "Package-Completion Predicates")
+;; (@> "Special Candidate-Completion Predicates")
+;; (@> "Symbol-Completion Predicates")
+;; (@> "Window-Completion Predicates")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(defvar completion-annotate-function)
(defvar completion-common-substring)
(defvar completion-extra-properties)
+ (defvar completion-list-insert-choice-function)
(defvar completion-root-regexp)
- (defvar icicle-Info-visited-max-candidates) ; In `icicles-opt.el' (for Emacs 22+)
(defvar minibuffer-completing-symbol)
(defvar minibuffer-prompt-properties)
(defvar partial-completion-mode)
(when (< emacs-major-version 23)
(defvar completion--embedded-envvar-re) ; In `minibuffer.el'.
(defvar completion-styles) ; In `minibuffer.el'
- (defvar icicle-Completions-text-scale-decrease)) ; In `icicles-opt.el' (for Emacs 23)
+ (defvar icicle-Completions-text-scale-decrease) ; In `icicles-opt.el' (for Emacs 23+)
+ (defvar icicle-read-char-by-name-multi-completion-flag)) ; In `icicles-opt.el' (for Emacs 23+)
-(defvar last-repeatable-command) ; Defined in `repeat.el'.
(defvar completion-root-regexp) ; In `simple.el' (for Emacs 22 and 23.1)
(defvar crm-local-completion-map) ; In `crm.el'
(defvar crm-local-must-match-map) ; In `crm.el'
(defvar doremi-up-keys) ; In `doremi.el'
(defvar eyedrop-picked-background) ; In `eyedrop.el' and `palette.el'
(defvar eyedrop-picked-foreground) ; In `eyedrop.el' and `palette.el'
+(defvar ffap-alist) ; In `ffap.el'
+(defvar ffap-url-regexp) ; In `ffap.el'
+(defvar ffap-shell-prompt-regexp) ; In `ffap.el'
+(defvar ffap-machine-p-known) ; In `ffap.el'
(defvar filesets-data) ; In `filesets.el'
(defvar font-width-table) ; In C code.
(defvar font-weight-table) ; In C code.
(defvar font-slant-table) ; In C code.
(defvar history-delete-duplicates) ; In C code for Emacs 22+.
(defvar icicle-file-name-completion-table) ; In `icicles-var.el' for Emacs 24+.
-(defvar icicle-Info-hist-list) ; In `icicles-cmd2.el'
(defvar icicle-Info-index-nodes) ; In `icicles-cmd2.el'
(defvar icicle-Info-manual) ; In `icicles-cmd2.el'
(defvar icicle-read-char-history) ; In `icicles-var.el' for Emacs 23+.
(defvar image-dired-thumb-height) ; In `image-dired.el'.
(defvar image-dired-thumb-width) ; In `image-dired.el'.
+(defvar last-repeatable-command) ; Defined in `repeat.el'.
(defvar list-colors-sort) ; In `facemenu.el'
(defvar 1on1-*Completions*-frame-flag) ; In `oneonone.el'
(defvar minibuffer-default-in-prompt-regexps) ; In `minibuf-eldef.el'.
(progn (add-hook 'minibuffer-setup-hook ,hook) ,@body)
(remove-hook 'minibuffer-setup-hook ,hook)))))
-;;(@* "Redefined standard functions")
+;;(@* "Redefined Standard Functions")
-;;; Redefined standard functions -------------------------------------
+;;; Redefined Standard Functions -------------------------------------
;; REPLACE ORIGINAL `choose-completion-string' in `simple.el',
((or (> emacs-major-version 23) ; Emacs 23.2+
(and (= emacs-major-version 23) (> emacs-minor-version 1)))
- (defun icicle-choose-completion-string (choice &optional buffer base-position)
+ (defun icicle-choose-completion-string (choice &optional buffer base-position insert-function)
"Switch to BUFFER and insert the completion choice CHOICE.
BASE-POSITION should be a cons whose car is the position where the
choice is inserted. It is ignored if not a cons.
+INSERT-FUNCTION says how to insert the completion and falls
+ back on `completion-list-insert-choice-function' when nil.
If BUFFER is the minibuffer, then exit the minibuffer, unless one of
the following is true:
- it is reading a file name, CHOICE is a directory, and
;; (minibufferp BUFFER). The last arg used to be BASE-SIZE - keep it to avoid
;; breaking older code.
choice buffer base-position nil)
- ;; Forget about base-size altogether. Replace the whole input always.
- (delete-region (if mini-p (minibuffer-prompt-end) (point-min))
- (if mini-p (point-max) (point)))
- (insert choice)
- (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil))
+ (let ((choice-copy (copy-sequence choice)) ; Do not modify original string.
+ (start (if mini-p
+ (minibuffer-prompt-end)
+ (previous-single-property-change (point) 'read-only nil (point-min))))
+ (end (if mini-p
+ (point-max)
+ (next-single-property-change (point) 'read-only nil (point-max)))))
+ ;; Do not assume that properties have been removed - remove `mouse-face' here.
+ (remove-text-properties 0 (length choice-copy) '(mouse-face nil) choice-copy)
+ (delete-region start end) ; Replace the whole input always.
+ (if (or insert-function (boundp 'completion-list-insert-choice-function))
+ (funcall (or insert-function completion-list-insert-choice-function)
+ (or (car base-position) (point))
+ (or (cadr base-position) (point))
+ choice-copy)
+ (insert choice-copy)))
+
+ ;; $$$$$$$$ (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil)))
+
;; Update point in the window where BUFFER is showing.
(let ((window (get-buffer-window buffer t))) (set-window-point window (point)))
;; If completing for the minibuffer, exit it with this choice,
(setq hist-val (mapcar #'prin1-to-string hist-val)))
(completing-read prompt (mapcar #'list hist-val) pred nil init-input hist def inherit-i-m)))
-;; Based on the Emacs 22 C code that defined `completing-read'.
-(defun icicle-lisp-vanilla-completing-read (prompt collection &optional predicate require-match
- initial-input hist def inherit-input-method)
- "Lisp version of vanilla Emacs `completing-read'."
- (let ((pos 0) val histvar histpos position init)
- (setq init initial-input
- minibuffer-completion-table collection
- minibuffer-completion-predicate predicate
- minibuffer-completion-confirm (and (not (eq require-match t)) require-match)
- position nil)
- (when init
- (when (consp init) (setq position (cdr init)
- init (car init)))
- (unless (stringp init)
- (error "`icicle-lisp-vanilla-completing-read', INIT not a string: %S" init))
- (if (not position)
- (setq pos (1+ (length init))) ; Default is to put cursor at end of INITIAL-INPUT.
- (unless (integerp position)
- (error "`icicle-lisp-vanilla-completing-read', POSITION not an integer: %S" position))
- (setq pos (1+ position)))) ; Convert zero-based to one-based.
- (if (symbolp hist)
- (setq histvar hist
- histpos nil)
- (setq histvar (car-safe hist)
- histpos (cdr-safe hist)))
- (unless histvar (setq histvar 'minibuffer-history))
- (unless histpos (setq histpos 0))
- ;; $$$$$$
- ;; (setq val (read-from-minibuffer
- ;; prompt
- ;; (cons init pos) ; initial-contents
- ;; (if (not require-match) ; key map
- ;; (if (or (not minibuffer-completing-file-name)
- ;; (eq minibuffer-completing-file-name 'lambda)
- ;; (not (boundp 'minibuffer-local-filename-completion-map)))
- ;; minibuffer-local-completion-map
- ;; minibuffer-local-filename-completion-map)
- ;; (if (or (not minibuffer-completing-file-name)
- ;; (eq minibuffer-completing-file-name 'lambda)
- ;; (not (boundp 'minibuffer-local-filename-must-match-map)))
- ;; minibuffer-local-must-match-map
- ;; minibuffer-local-filename-must-match-map))
- ;; nil histvar def inherit-input-method))
- (setq val (read-from-minibuffer
- prompt
- (cons init pos) ; initial-contents
- (if (not require-match) ; keymap
- (if (or (not minibuffer-completing-file-name)
- (eq minibuffer-completing-file-name 'lambda)
- (not (boundp 'minibuffer-local-filename-completion-map)))
- minibuffer-local-completion-map
- (if (fboundp 'make-composed-keymap) ; Emacs 24, starting July 2011.
- (make-composed-keymap minibuffer-local-filename-completion-map
- minibuffer-local-completion-map)
- minibuffer-local-filename-completion-map))
+;; $$$$$$$$ Same as `completing-read-default', except: (a) Added optional arg KEYMAP and
+;; (b) works for all Emacs versions.
+(defun icicle-completing-read-default (prompt collection &optional predicate require-match
+ initial-input hist def inherit-input-method keymap)
+ "Default way to read from the minibuffer with completion.
+Optional arg KEYMAP, if non-nil, should be a completion keymap.
+See `completing-read' for the other arguments."
+
+ (when (consp initial-input)
+ ;; `completing-read' uses a 0-based index, but `read-from-minibuffer' uses a 1-based index.
+ (setq initial-input (cons (car initial-input) (1+ (cdr initial-input)))))
+ (let* ((minibuffer-completion-table collection)
+ (minibuffer-completion-predicate predicate)
+ (minibuffer-completion-confirm (and (not (eq require-match t)) require-match))
+ (base-map (if require-match
+ minibuffer-local-must-match-map
+ minibuffer-local-completion-map))
+ (map
+ (or keymap
+ (if (not require-match) ; keymap
(if (or (not minibuffer-completing-file-name)
(eq minibuffer-completing-file-name 'lambda)
- (and (not (fboundp 'make-composed-keymap)) ; Emacs 24, starting July 2011.
- (not (boundp 'minibuffer-local-filename-must-match-map))))
- minibuffer-local-must-match-map
- (if (fboundp 'make-composed-keymap) ; Emacs 24, starting July 2011.
+ (not (boundp 'minibuffer-local-filename-completion-map)))
+ minibuffer-local-completion-map
+ (if (fboundp 'make-composed-keymap) ; Emacs 24+
(make-composed-keymap minibuffer-local-filename-completion-map
- minibuffer-local-must-match-map)
- minibuffer-local-filename-must-match-map)))
- nil histvar def inherit-input-method))
+ minibuffer-local-completion-map)
+ minibuffer-local-filename-completion-map))
+ (if (or (not minibuffer-completing-file-name)
+ (eq minibuffer-completing-file-name 'lambda)
+ (and (not (fboundp 'make-composed-keymap)) ; Emacs 24+
+ (not (boundp 'minibuffer-local-filename-must-match-map))))
+ minibuffer-local-must-match-map
+ (if (fboundp 'make-composed-keymap) ; Emacs 24+
+ (make-composed-keymap minibuffer-local-filename-completion-map
+ minibuffer-local-must-match-map)
+ minibuffer-local-filename-must-match-map)))))
+ (result (read-from-minibuffer prompt initial-input map
+ nil hist def inherit-input-method)))
;; Use `icicle-filtered-default-value', not DEF, because `read-from-minibuffer' filters it.
- (when (consp icicle-filtered-default-value) ; Emacs 23 lets DEF be a list of strings - use first.
- (setq icicle-filtered-default-value (car icicle-filtered-default-value)))
- (when (and (stringp val) (string= val "") icicle-filtered-default-value)
- (setq val icicle-filtered-default-value))
- val))
+ (when (and (equal result "") icicle-filtered-default-value)
+ (setq result (if (consp icicle-filtered-default-value) ; Emacs 23+ lets DEF be a list - use first string.
+ (car icicle-filtered-default-value)
+ icicle-filtered-default-value)))
+ result))
;; REPLACE ORIGINAL `completing-read' (built-in function),
(defalias 'icicle-ORIG-completing-read (symbol-function 'completing-read)))
(defun icicle-completing-read (prompt collection &optional predicate require-match
- initial-input hist-m@%=!$+&^*z def inherit-input-method)
+ initial-input hist-m@%=!$+&^*z def inherit-input-method keymap)
"Read string in minibuffer, with completion and cycling of completions.
Prefix completion via \\<minibuffer-local-completion-map>\
`\\[icicle-prefix-word-complete]' (word) and `\\[icicle-prefix-complete]' (full).
If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits the
current input method and the setting of `enable-multibyte-characters'.
+Optional arg KEYMAP, if non-nil, should be a completion keymap to use.
+
Both completion candidates and DEF are filtered using these Icicles
variables:
`icicle-must-match-regexp'
(setq collection (car c+p) ; After banalizing for vanilla Emacs.
predicate (cadr c+p))))
;; $$$$$$ (setq minibuffer-completion-table collection)
- (when def (setq prompt (icicle-handle-default-for-prompt prompt def (eq icicle-default-value t))))
+
+ (when def
+ (let ((def1 (if (listp def) (car def) def))) ; Use only the first default (for `file-relative-name').
+ (setq prompt (icicle-handle-default-for-prompt
+ prompt
+ ;; If `insert-default-directory' then make DEF in prompt relative to `default-directory'.
+ (if (and def1 (eq icicle-default-value t) insert-default-directory)
+ (file-relative-name def1)
+ def1)
+ (and (eq icicle-default-value t)
+ ;; Include in prompt only if `insert-default-directory' does not insert it as input.
+ (or (not insert-default-directory)
+ (not (icicle-file-name-input-p))
+ (not (equal def1 default-directory))))))))
(cond ((not icicle-mode)
- (setq result (icicle-lisp-vanilla-completing-read
- prompt collection predicate require-match initial-input
- hist-m@%=!$+&^*z def inherit-input-method)))
+ (setq result (icicle-completing-read-default prompt collection predicate require-match initial-input
+ hist-m@%=!$+&^*z def inherit-input-method keymap)))
(t
(let* ((minibuffer-prompt-properties (and (boundp 'minibuffer-prompt-properties)
(icicle-remove-property ; Emacs 21+ only
(when (< emacs-major-version 21)
(setq prompt (concat (and icicle-candidate-action-fn "+ ") prompt)))
(setq result (catch 'icicle-read-top
- (icicle-lisp-vanilla-completing-read
- prompt collection predicate require-match initial-input
- hist-m@%=!$+&^*z def inherit-input-method)))
+ (icicle-completing-read-default prompt collection predicate require-match
+ initial-input hist-m@%=!$+&^*z def
+ inherit-input-method keymap)))
(icicle-unpropertize-completion result))))
;; HACK. Without this, when REQUIRE-MATCH is non-nil, `*Completions*' window
;; does not disappear.
\" [___] \""
(when (consp default) (setq default (car default)))
;; Remove the default, if already there.
- (dolist (rgx (if (boundp 'minibuffer-default-in-prompt-regexps) ; Get rid of HINT if already there.
+ (dolist (rgx (if (boundp 'minibuffer-default-in-prompt-regexps) ; In `minibuf-eldef.el'.
minibuffer-default-in-prompt-regexps
'(("\\( (default\\(?: is\\)? \\(.*\\))\\):? \\'" 1)
("\\( \\[.*\\]\\):? *\\'" 1))))
(read-file-name-predicate (and (boundp 'read-file-name-predicate)
read-file-name-predicate))
(ffap-available-p (or (require 'ffap- nil t) (require 'ffap nil t)))
- ;; The next four prevent slowing down `ffap-guesser'.
- (ffap-alist nil) (ffap-machine-p-known 'accept)
- (ffap-url-regexp nil) (ffap-shell-prompt-regexp nil)
+
+ ;; These four `ffap-*' bindings would speed up `ffap-guesser' - see `ffap.el' about them.
+ ;; Do not bind them for Emacs 23+, however, so users can get multiple default values for `M-n'.
+ (emacs-23+ (>= emacs-major-version 23))
+ (ffap-alist (and emacs-23+ ffap-alist))
+ (ffap-url-regexp (and emacs-23+ ffap-url-regexp))
+ (ffap-shell-prompt-regexp (and emacs-23+ ffap-shell-prompt-regexp))
+ (ffap-machine-p-known (if emacs-23+ ffap-machine-p-known 'accept))
+
(fap
(if (and (eq major-mode 'dired-mode) (fboundp 'dired-get-file-for-visit))
(condition-case nil
(setq default-value
(if (atom default-value)
(icicle-filter-wo-input default-value)
- (delq nil (mapcar #'icicle-filter-wo-input default-value))))) ; Emacs 23 accepts a list.
- ;; Save new default value for caller (e.g. `icicle-lisp-vanilla-completing-read'.
+ (delq nil (mapcar #'icicle-filter-wo-input default-value)))))
+ (when (and (< emacs-major-version 23) (consp default-value)) ; Emacs <23 does not accept a list.
+ (setq default-value (car default-value)))
+ ;; Save new default value for caller (e.g. `icicle-completing-read-default'.
(setq icicle-filtered-default-value default-value)
;; If a list of strings, use the first one for prompt etc.
(let ((def-value (icicle-unlist default-value)))
;; Maybe use DEFAULT-VALUE for INITIAL-CONTENTS also.
(when (and icicle-default-value (not (eq icicle-default-value t))
- def-value (stringp initial-contents) (string= "" initial-contents))
+ def-value (equal "" initial-contents))
(setq initial-contents (if (integerp def-value) ; Character
(string def-value)
def-value)))
;; REPLACE ORIGINAL `read-number' defined in `subr.el',
;; saving it for restoration when you toggle `icicle-mode'.
+;;
;; 1. Let user enter a numeric variable name, for its value. Allow completion.
;; 2. Allow for error reading input.
;; 3. Call `ding' if not a number, and don't redisplay for `sit-for'.
;;
;; 1. Use `icicle-ucs-names', not `ucs-names'.
;; 2. Exclude character names "" and "VARIATION SELECTOR*".
-;; 3. Display the character itself, after its name, in `*Completions*'.
+;; 3. If `icicle-read-char-by-name-multi-completion-flag' is non-nil, show the character itself, after its name,
+;; in `*Completions*'.
;; 4. Added optional arg NAMES.
;; 5. Add char read to `icicle-read-char-history'.
-;; 5. See doc string for the rest.
+;; 6. See doc string for the rest.
;;
(when (fboundp 'read-char-by-name) ; Emacs 23+
Properties `help-echo' and `icicle-mode-line-help' are put on NAME,
showing both NAME and the code point (in hex, octal, and decimal)."
(and (not (string= "" (car name.char)))
- ;; $$$$$$ Maybe make this optional?
- ;; (not (string-match "\\`VARIATION SELECTOR" (car name.char))))
- (let* ((name (copy-sequence (car name.char)))
- (char (cdr name.char)))
- (icicle-candidate-short-help (format "Char: %-10cCode Point: x%X, o%o, %d" char char char char) name)
- (cons (list name (format "%X" char) (format "%c" char)) char))))
-
-
+ (if icicle-read-char-by-name-multi-completion-flag
+ ;; $$$$$$ Maybe make this optional?
+ ;; (not (string-match "\\`VARIATION SELECTOR" (car name.char))))
+ (let* ((name (copy-sequence (car name.char)))
+ (char (cdr name.char)))
+ (icicle-candidate-short-help
+ (format "Char: %-10cCode Point: x%X, o%o, %d" char char char char) name)
+ (cons (list name (format "%X" char) (format "%c" char)) char))
+ name.char)))
(unless (fboundp 'icicle-ORIG-read-char-by-name)
(defalias 'icicle-ORIG-read-char-by-name (symbol-function 'read-char-by-name)))
You can use completion against the Unicode name of the character.
-In Icicle mode:
+In Icicle mode, if `icicle-read-char-by-name-multi-completion-flag' is
+non-nil:
* The Unicode code point of the char and the char itself appear next
to the char name in `*Completions*' - WYSIWYG.
(let* ((new-prompt (copy-sequence prompt))
(enable-recursive-minibuffers t)
(completion-ignore-case t)
- (icicle-show-multi-completion-flag t) ; Override user setting.
- (icicle-multi-completing-p t)
+ (icicle-multi-completing-p (and icicle-read-char-by-name-multi-completion-flag
+ icicle-show-multi-completion-flag))
(icicle-list-use-nth-parts '(1))
(icicle-transform-before-sort-p t)
(icicle-list-join-string "\t")
(icicle-candidate-properties-alist '((3 (face icicle-candidate-part))))
- (icicle-whole-candidate-as-text-prop-p t)
+ (icicle-whole-candidate-as-text-prop-p icicle-multi-completing-p)
(mctized-cands (car (icicle-mctize-all names nil)))
(collection-fn `(lambda (string pred action)
(if (eq action 'metadata)
chr)
(setq chr (cond ((string-match-p "\\`[0-9a-fA-F]+\\'" input) (string-to-number input 16))
((string-match-p "^#" input) (read input))
- ((cddr (assoc-string input mctized-cands t))) ; INPUT is a multi-completion.
- (t
+ ((if icicle-multi-completing-p
+ (cddr (assoc-string input mctized-cands t)) ; INPUT is one of the multi-completions.
+ (cdr (assoc-string input mctized-cands t)))) ; INPUT is a character name.
+ (icicle-multi-completing-p
(let ((completion (try-completion input collection-fn)))
(and (stringp completion)
;; INPUT is not a multi-completion, but it may match a single sulti-completion.
(add-to-list 'icicle-read-char-history chr)
chr))
- ;; This would not be needed if there were not Emacs bug #9653.
+ ;; This would not be needed if there were not STILL Emacs bug #9653.
(defun icicle-ucs-names ()
"Same as `ucs-names', except remove entries with an empty name: \"\"."
(setq ucs-names (assq-delete-all "" (ucs-names))))) ; Free var here: `ucs-names'.
;; REPLACE ORIGINAL `read-shell-command' defined in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
-;; Uses Icicles completion.
+;;
+;; Use Icicles completion.
;;
(defun icicle-read-shell-command (prompt &optional initial-contents hist default-value
inherit-input-method)
default-value inherit-input-method))))
-;; REPLACE ORIGINAL `shell-command' defined in `simple.el',
+;; REPLACE ORIGINAL `dired-smart-shell-command' defined in `dired-x.el',
;; saving it for restoration when you toggle `icicle-mode'.
-;; Uses Icicles completion.
+;;
+;; Use Icicles completion.
;;
;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'.
;;
;; REPLACE ORIGINAL `shell-command' defined in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
-;; Uses Icicles completion.
+;;
+;; Use Icicles completion.
;;
;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'.
;;
;; REPLACE ORIGINAL `shell-command-on-region' defined in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
-;; Uses Icicles completion.
+;;
+;; Use Icicles completion.
;;
;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'.
;;
;; REPLACE ORIGINAL `dired-read-shell-command' defined in `dired-aux.el'
;; and redefined in `dired-x.el', saving it for restoration when you toggle `icicle-mode'.
;;
-;; Uses Icicles completion.
-;; Uses `icicle-minibuffer-default-add-dired-shell-commands', not
+;; Use Icicles completion.
+;; Use `icicle-minibuffer-default-add-dired-shell-commands', not
;; `minibuffer-default-add-dired-shell-commands'.
-;; Binds `icicle-files' for use as free var elsewhere.
+;; Bind `icicle-files' for use as free var elsewhere.
;; Added optional arg HISTORY.
;;
(defun icicle-dired-read-shell-command (prompt arg files &optional history)
(icicle-point-position-in-candidate 'input-end)
(icicle-candidate-help-fn (lambda (cand)
(if (member cand icicle-extra-candidates)
- (with-output-to-temp-buffer "*Help*"
- (princ
- (shell-command-to-string
- (concat "apropos "
- (shell-quote-argument cand)))))
+ (icicle-with-help-window "*Help*"
+ (princ (shell-command-to-string
+ (concat "apropos "
+ (shell-quote-argument cand)))))
(icicle-describe-file cand nil 'NO-ERROR-P))))
(icicle-extra-candidates icicle-extra-candidates)
(icicle-must-match-regexp icicle-file-match-regexp)
;; REPLACE ORIGINAL `recentf-make-menu-items' defined in `recentf.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
-;; Adds Icicles submenu to `Open Recent' menu.
+;; Add Icicles submenu to `Open Recent' menu.
;;
(defun icicle-recentf-make-menu-items (&optional menu)
"Make menu items from the recent list.
["+ Open Recent File..." icicle-recent-file]
["+ Open Recent File (Other Window)..." icicle-recent-file-other-window]
["+ Remove from Recent Files List..." icicle-remove-file-from-recentf-list]))))))
+
+(when (fboundp 'read-file-local-variable) ; Emacs 23+, after `files-x.el' is loaded.
+ (defadvice read-file-local-variable (around icicle-bind-variable-completing-p activate)
+ "Provide predefined variable predicates for `M-&'."
+ (let ((icicle-variable-completing-p t))
+ ad-do-it)))
-;;(@* "Icicles functions - completion display (not cycling)")
-
-;;; Icicles functions - completion display (not cycling) -------------
-
-(defun icicle-display-candidates-in-Completions (&optional reverse-p no-display-p)
- "Refresh the current set of completion candidates in `*Completions*'.
-REVERSE-P non-nil means display the candidates in reverse order.
-NO-DISPLAY-P non-nil means do not display the candidates; just
- recompute them. If the value is `no-msg', then do not show a
- minibuffer message indicating that candidates were updated."
-
- ;; FREE var used here (bound in `icicle-Info-index'): `icicle-Info-hist-list'.
-
- ;;$$ ;; Pred is special if `minibuffer-completion-table' is a function.
- ;; (when (and (not (functionp minibuffer-completion-table))
- ;; (functionp minibuffer-completion-predicate))
- ;; (setq icicle-completion-candidates
- ;; (icicle-remove-if-not
- ;; (lambda (cand)
- ;; (funcall minibuffer-completion-predicate
- ;; (if (arrayp minibuffer-completion-table) (intern cand) (list cand))))
- ;; icicle-completion-candidates)))
-
- ;; $$$ (case icicle-incremental-completion
- ;; ((t always) (setq icicle-incremental-completion-p 'always))
- ;; ((nil) (setq icicle-incremental-completion-p nil)))
-
- ;; $$$$$ (unless (input-pending-p) ; Do nothing if user hit a key.
-
- ;; Upgrade `icicle-incremental-completion-p' if we are redisplaying, so that completions will
- ;; be updated by `icicle-call-then-update-Completions' when you edit.
- (setq icicle-incremental-completion-p icicle-incremental-completion)
- (when (and (eq t icicle-incremental-completion-p) (get-buffer-window "*Completions*" 0))
- (setq icicle-incremental-completion-p 'always))
- (let ((nb-cands (length icicle-completion-candidates)))
- ;; $$$$$$ Could use this binding to prevent frame fitting, to allow room for images.
- ;; But that is not really the solution. Really should fit the frame or window in such a way
- ;; that it takes image sizes into account. Might need to wait for a fix to Emacs bug #7822.
- ;; (autofit-frames-flag (not icicle-image-files-in-Completions)))
- (cond ((eq no-display-p 'no-msg)) ; No-op.
- (no-display-p
- (icicle-msg-maybe-in-minibuffer
- "Candidates updated (%s matching): %s" icicle-current-completion-mode
- (icicle-propertize (format "%d" nb-cands) 'face 'icicle-msg-emphasis)))
- ((null icicle-completion-candidates)
- (save-selected-window (icicle-remove-Completions-window))
- (icicle-msg-maybe-in-minibuffer
- (if (eq 'apropos icicle-current-completion-mode)
- (let ((typ (car (rassq icicle-apropos-complete-match-fn
- icicle-S-TAB-completion-methods-alist))))
- (concat "No " typ (and typ " ") "completions"))
- (case (icicle-current-TAB-method)
- (fuzzy "No fuzzy completions")
- (swank "No swank (fuzzy symbol) completions")
- (vanilla "No vanilla completions")
- (t "No prefix completions")))))
- (t
- (when (> nb-cands icicle-incremental-completion-threshold)
- (message "Displaying completion candidates..."))
- ;; Display `*Completions*' now, so we can get its window's width.
- ;; We don't wait for `with-output-to-temp-buffer' to display it, because displaying it
- ;; might lead to splitting the display window, which would change its width.
- ;; We need to know the width in order to calculate the proper candidate formatting.
- (when (consp icicle-completion-candidates)
- (let ((fit-frame-inhibit-fitting-flag t)
- (comp-buf (get-buffer-create "*Completions*")))
- (unless (get-buffer-window comp-buf 'visible)
- (save-selected-window (display-buffer comp-buf t 0)
- (deactivate-mark))))) ; Remove any leftover mouse selection.
- (with-output-to-temp-buffer "*Completions*"
- ;; Each candidate in `icicle-completion-candidates' is a string, regardless of the
- ;; original type of candidate used (e.g. symbol, string, alist candidate,...). Here,
- ;; provided `icicle-fancy-cands-internal-p' is non-nil, we transform these candidates,
- ;; replacing each by a string that takes into account symbol properties
- ;; `icicle-display-string' and `icicle-special-candidate'.
- ;;
- ;; Because `icicle-completion-candidates' is affected, changes to the candidate strings
- ;; (e.g. propertizing) are also reflected in the completion return value chosen by the
- ;; user. It is not only the display in `*Completions*' that is affected.
- ;;
- ;; The symbol whose properties are used is the one in the current obarray that is named
- ;; by the string candidate to be transformed. If there is no such symbol, then no
- ;; transformation occurs. Unless `minibuffer-completion-table' is an obarray, the
- ;; global obarray is used to get the symbol.
- ;;
- ;; 1. If the symbol has an `icicle-display-string' property, then that property value
- ;; must be a string (possibly propertized). We replace the candidate by that string.
- ;;
- ;; 2. If the symbol has an `icicle-special-candidate' property, then we transfer the
- ;; property to the candidate string as a set of text properties. (If the value is
- ;; not a plist, and `icicle-special-candidate-regexp' is nil, then just apply face
- ;; `icicle-special-candidate'.) The effect is similar to using
- ;; `icicle-special-candidate-regexp', but the completion return value is also
- ;; affected.
- (when icicle-fancy-cands-internal-p
- (setq icicle-completion-candidates
- (mapcar (lambda (cand)
- (let* ((symb (intern-soft
- cand (and (arrayp minibuffer-completion-table)
- minibuffer-completion-table)))
- (display-strg (and symb
- (stringp (get symb 'icicle-display-string))
- (get symb 'icicle-display-string)))
- (new-cand (or display-strg cand))
- (spec-prop (and symb (get symb 'icicle-special-candidate))))
- ;; Apply `icicle-special-candidate' property's value.
- ;; If the value is a plist, then apply the properties as text props.
- ;; Else (the value is t), apply face `icicle-special-candidate'.
- (when spec-prop
- (setq new-cand (copy-sequence new-cand))
- (if (consp spec-prop)
- (add-text-properties 0 (length new-cand) spec-prop new-cand)
- (unless icicle-special-candidate-regexp
- (add-text-properties 0 (length new-cand)
- '(face icicle-special-candidate)
- new-cand))))
- new-cand))
- icicle-completion-candidates)))
- (icicle-display-completion-list (if reverse-p
- (reverse icicle-completion-candidates)
- icicle-completion-candidates)
- nil ; IGNORED
- nb-cands))
- (save-excursion
- (save-window-excursion
- (with-current-buffer (get-buffer "*Completions*")
- (let* ((buffer-read-only nil)
- (eob (point-max))
- (filep (or (icicle-file-name-input-p) icicle-abs-file-candidates))
- (dir (and filep icicle-last-input
- (icicle-file-name-directory icicle-last-input)))
- (histvar (and (symbolp minibuffer-history-variable)
- (boundp minibuffer-history-variable)
- minibuffer-history-variable))
- (hist (and histvar (if filep
- (let ((default-directory dir))
- (mapcar #'expand-file-name
- (symbol-value histvar)))
- (symbol-value histvar))))
- (case-fold-search
- ;; Don't bother with buffer completion, `read-buffer-completion-ignore-case'.
- (if (and filep (boundp 'read-file-name-completion-ignore-case))
- read-file-name-completion-ignore-case
- completion-ignore-case)))
- (when (fboundp 'remove-images) (remove-images (point-min) (point-max)))
- (goto-char (icicle-start-of-candidates-in-Completions))
- (while (not (eobp))
- (let* ((beg (point))
- (end (next-single-property-change beg 'mouse-face nil eob))
- (next (next-single-property-change end 'mouse-face nil eob))
- (faces ()))
-
- ;; Highlight candidate specially if it is a proxy candidate.
- (let ((candidate (icicle-current-completion-in-Completions)))
- ;;$$$ (when dir (setq candidate (expand-file-name candidate dir)))
- (when (member candidate icicle-proxy-candidates)
- (setq faces (cons 'icicle-proxy-candidate faces))
- (if (not icicle-proxy-candidate-regexp)
- (add-text-properties beg end (cons 'face (list faces)))
- (save-match-data
- (when (string-match icicle-proxy-candidate-regexp candidate)
- (add-text-properties (+ beg (match-beginning 0)) (+ beg (match-end 0))
- (cons 'face (list faces))))))))
-
- ;; Highlight candidate specially if it is an extra candidate.
- (let ((candidate (icicle-current-completion-in-Completions)))
- ;;$$$ (when dir (setq candidate (expand-file-name candidate dir)))
- (save-match-data
- (when (member candidate icicle-extra-candidates)
- (setq faces (cons 'icicle-extra-candidate faces))
- (add-text-properties beg end (cons 'face (list faces))))))
-
- ;; Highlight candidate specially if it is a special candidate.
- (let ((candidate (icicle-current-completion-in-Completions)))
- ;;$$$ (when dir (setq candidate (expand-file-name candidate dir)))
- (save-match-data
- (when (and icicle-special-candidate-regexp
- (string-match icicle-special-candidate-regexp candidate))
- (setq faces (cons 'icicle-special-candidate faces))
- (add-text-properties (+ beg (match-beginning 0)) (+ beg (match-end 0))
- (cons 'face (list faces))))))
-
- ;; Highlight candidate (`*-historical-candidate') if it was used previously.
- (when icicle-highlight-historical-candidates-flag
- (let ((candidate (icicle-current-completion-in-Completions)))
- (when (and (consp hist) (not (member candidate icicle-hist-cands-no-highlight)))
- (let ((default-directory dir))
- (when (member (if filep
- (expand-file-name (icicle-transform-multi-completion
- candidate))
- candidate)
- hist)
- (add-text-properties
- beg end `(face ,(setq faces (cons 'icicle-historical-candidate faces)))))))))
-
- ;; Highlight Info index-entry cand (`icicle-historical-candidate-other')
- ;; if its node has been visited.
- ;;
- ;; FREE var here (bound in `icicle-Info-index'): `icicle-Info-hist-list'.
- (when (and (> emacs-major-version 21)
- (memq icicle-last-top-level-command '(Info-index icicle-Info-index))
- icicle-highlight-historical-candidates-flag
- (boundp 'icicle-Info-hist-list) (consp icicle-Info-hist-list)
- (<= nb-cands icicle-Info-visited-max-candidates)
- (progn (message "Highlighting topics in visited nodes...") t))
- (let ((candidate (icicle-current-completion-in-Completions)))
- (when (or (assoc candidate icicle-Info-index-cache)
- (icicle-some (mapcar 'cadr icicle-Info-hist-list)
- candidate
- #'icicle-Info-node-is-indexed-by-topic))
- (add-text-properties
- beg end `(face ,(setq faces (cons 'icicle-historical-candidate-other faces)))))))
-
- ;; Highlight, inside the candidate, the expanded common match.
- (when (and icicle-current-input (not (string= "" icicle-current-input)))
- (save-excursion
- (save-restriction
- (narrow-to-region beg end) ; Restrict to the completion candidate.
- (when (re-search-forward (regexp-quote (icicle-minibuf-input-sans-dir
- icicle-current-input))
- nil t)
- (setq faces (cons 'icicle-common-match-highlight-Completions faces))
- (put-text-property (match-beginning 0) (point) 'face faces)))))
-
- ;; Hide match for `icicle-current-input' (expanded common match, if available),
- ;; if `icicle-hide-common-match-in-Completions-flag' is non-nil.
- (save-excursion
- (save-restriction
- (narrow-to-region beg end) ; Restrict to the completion candidate.
- (when (and icicle-hide-common-match-in-Completions-flag icicle-common-match-string)
- (when (re-search-forward (regexp-quote icicle-common-match-string) nil t)
- (if (> emacs-major-version 20)
- (put-text-property (match-beginning 0) (point) 'display "...")
- (put-text-property (match-beginning 0) (point) 'invisible t))))))
-
- ;; Highlight, inside the candidate, what the input expression matches.
- (unless (and icicle-current-raw-input (string= "" icicle-current-raw-input)
- icicle-apropos-complete-match-fn)
- (save-excursion
- (save-restriction
- (narrow-to-region beg end) ; Restrict to the completion candidate.
- (let ((fn (if (and (eq 'prefix icicle-current-completion-mode)
- (not (memq (icicle-current-TAB-method) '(fuzzy swank))))
- ;; $$$$$$ What is best for `vanilla' (Emacs 23) completion?
- 'search-forward
- (case icicle-apropos-complete-match-fn
- (icicle-scatter-match
- (lambda (input bound noerr)
- (re-search-forward (icicle-scatter input) bound noerr)))
- (icicle-levenshtein-match
- (if (= icicle-levenshtein-distance 1)
- (lambda (input bound noerr)
- (re-search-forward (icicle-levenshtein-one-regexp input)
- bound noerr))
- 're-search-forward))
- (otherwise 're-search-forward)))))
- (save-excursion
- (when (and (funcall fn (icicle-minibuf-input-sans-dir icicle-current-raw-input)
- nil t)
- (not (eq (match-beginning 0) (point))))
- (setq faces (cons 'icicle-match-highlight-Completions faces))
- (put-text-property (match-beginning 0) (point) 'face faces)))
-
- ;; If `icicle-hide-non-matching-lines-flag' then hide all lines
- ;; of candidate that do not match current input.
- (let ((candidate (icicle-current-completion-in-Completions))
- (input (icicle-minibuf-input-sans-dir
- icicle-current-raw-input))
- (cbeg beg))
- (when (and icicle-hide-non-matching-lines-flag
- (string-match "\n" candidate)
- (not (string= "\n" candidate)))
- (goto-char cbeg)
- (while (not (eobp))
- (unless (funcall fn input (line-end-position) t)
- (if (> emacs-major-version 20)
- (put-text-property (line-beginning-position)
- (min (1+ (line-end-position)) (point-max))
- 'display "...\n")
- (put-text-property (line-beginning-position)
- (min (1+ (line-end-position)) (point-max))
- 'invisible t)))
- (forward-line 1))))))))
-
- ;; Highlight candidate if it has been saved.
- (when (and icicle-highlight-saved-candidates-flag icicle-saved-completion-candidates)
- (let ((candidate (icicle-current-completion-in-Completions)))
- (when (member candidate icicle-saved-completion-candidates)
- (let ((ov (make-overlay beg end)))
- (push ov icicle-saved-candidate-overlays)
- (overlay-put ov 'face 'icicle-saved-candidate)
- (overlay-put ov 'priority '10)))))
-
- ;; Treat `icicle-candidate-properties-alist'.
- ;; A `face' prop will unfortunately wipe out any `face' prop we just applied.
- (when icicle-candidate-properties-alist
- (save-excursion
- (save-restriction
- (narrow-to-region beg end) ; Restrict to the completion candidate.
- (let* ((candidate (buffer-substring (point-min) (point-max)))
- (orig-pt (point))
- (start 0)
- (end 0)
- (partnum 1)
- (join (concat "\\(" icicle-list-join-string "\\|\\'\\)"))
- (len-cand (length candidate))
- (len-join (length icicle-list-join-string))
- (first t))
- (save-match-data
- (while (and (or first
- (not (= end (match-beginning 0)))
- (< (+ end len-join) len-cand))
- (string-match join candidate (if (and (not first)
- (= end (match-beginning 0))
- (< end len-cand))
- (+ end len-join)
- end))
- (< end len-cand))
- (setq first nil
- end (or (match-beginning 0) len-cand))
- (let* ((entry (assq partnum
- icicle-candidate-properties-alist))
- (properties (cadr entry))
- (propertize-join-string (car (cddr entry))))
- (when properties
- (add-text-properties (+ start orig-pt) (+ end orig-pt) properties))
- (when propertize-join-string
- (add-text-properties (+ end orig-pt) (+ end orig-pt len-join)
- properties)))
- (setq partnum (1+ partnum)
- start (match-end 0))))))))
-
- ;; Thumbnail image for an image file or image-file bookmark (Bookmark+): Maybe show it
- ;; in `*Completions*'; maybe show it only in `*Completions*' mouseover tooltip.
- (when (or (and icicle-image-files-in-Completions
- (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
- (or (and filep (fboundp 'image-file-name-regexp))
- (and icicle-show-multi-completion-flag
- (symbolp icicle-last-top-level-command)
- (string-match "^icicle-bookmark-"
- (symbol-name icicle-last-top-level-command)))))
- (and (boundp 'tooltip-mode) tooltip-mode icicle-image-preview-in-tooltip))
- (let ((image-file
- (if (and icicle-show-multi-completion-flag
- (symbolp icicle-last-top-level-command)
- ;; We could alternatively put a property on such symbols and
- ;; test that. But just matching the cmd name is OK so far.
- (string-match "^icicle-bookmark-"
- (symbol-name icicle-last-top-level-command)))
- ;; This is bound by the bookmark commands to `(1)': bookmark name.
- ;; The file name is part #2, so we rebind this here.
- (let ((icicle-list-use-nth-parts '(2)))
- (icicle-transform-multi-completion
- (icicle-current-completion-in-Completions)))
- (icicle-transform-multi-completion
- (icicle-current-completion-in-Completions)))))
- (when (and (require 'image-dired nil t)
- (icicle-string-match-p (image-file-name-regexp) image-file))
- (let ((thumb-img (append (image-dired-get-thumbnail-image image-file)
- '(:margin 2))))
- ;; In `tooltip-mode', show image preview on mouseover,
- ;; unless it is a thumbnail and `*Completions*' already shows thumbnails.
- (when (and (boundp 'tooltip-mode) tooltip-mode
- (or (not icicle-image-files-in-Completions)
- (not (numberp icicle-image-preview-in-tooltip))))
- (with-current-buffer "*Completions*"
- (put-text-property
- (point) (+ (point) (length (icicle-current-completion-in-Completions)))
- 'help-echo 'icicle-mouseover-help)))
- (when icicle-image-files-in-Completions
- (let ((img-ov (overlays-in (point) (min (point-max) (1+ (point))))))
- (if img-ov
- (delete-overlay (car img-ov))
- (put-image thumb-img beg)
- (setq img-ov (loop for ov in (overlays-in
- (point) (min (point-max) (1+ (point))))
- when (overlay-get ov 'put-image) collect ov into ovs
- finally return (car ovs)))
- (overlay-put img-ov 'image-file image-file)
- (overlay-put img-ov 'thumb-img thumb-img)
- (overlay-put img-ov 'image-size (image-size thumb-img))))
- ;; `image-only'. Replace file name with a space.
- ;; And hide mouse-face highlighting, as it just confuses.
- (when (eq 'image-only icicle-image-files-in-Completions)
- (with-current-buffer "*Completions*"
- (put-text-property
- (point) (+ (point) (length (icicle-current-completion-in-Completions)))
- 'mouse-face 'default))
- (let ((name-ov (overlays-in end end)))
- (if name-ov
- (delete-overlay (car name-ov))
- (setq name-ov (make-overlay beg end))
- (overlay-put name-ov 'display " ")))))))))
- (goto-char next)))
-
- ;; Remove all newlines for images-only display.
- (when (eq icicle-image-files-in-Completions 'image-only)
- (save-excursion (goto-char (icicle-start-of-candidates-in-Completions))
- (while (and (re-search-forward "$") (not (eobp))) (delete-char 1)))))
- (set-buffer-modified-p nil)
- (setq buffer-read-only t))))
-
- ;; Put lighter, number of candidates, completion mode, and sort order in mode line.
- (with-current-buffer (get-buffer "*Completions*")
- (set (make-local-variable 'mode-line-format)
- (format " %s%s%s, sorting %s%s"
- (icicle-propertize (format "%d" nb-cands) 'face 'icicle-mode-line-help)
- (if (and icicle-max-candidates
- (integerp icicle-max-candidates) ; Not `RESET'.
- (< icicle-max-candidates icicle-nb-candidates-before-truncation))
- (format "%s candidates shown"
- (icicle-propertize (format "/%d" icicle-nb-candidates-before-truncation)
- 'face 'icicle-mode-line-help))
- " candidates")
- (if (memq icicle-current-completion-mode '(prefix apropos))
- (format ", %s completion"
- (icicle-propertize
- (cond ((eq 'apropos icicle-current-completion-mode)
- ;; If nil, COLLECTION arg is probably a fn and we set it to nil
- ;; to prevent automatic input matching in
- ;; `icicle-unsorted-apropos-candidates', because COLLECTION fn
- ;; does everything. So here we treat nil like `apropos'.
- (if icicle-apropos-complete-match-fn
- (or (car (rassq icicle-apropos-complete-match-fn
- icicle-S-TAB-completion-methods-alist))
- "")
- "apropos"))
- ((eq 'prefix icicle-current-completion-mode)
- (case (icicle-current-TAB-method)
- (fuzzy "fuzzy")
- (swank "swank (fuzzy symbol)")
- (vanilla "vanilla")
- (t "prefix"))))
- 'face 'icicle-mode-line-help))
- "")
- (icicle-propertize (or (car (rassoc icicle-sort-comparer icicle-sort-orders-alist))
- "turned OFF")
- 'face 'icicle-mode-line-help)
- (if (and icicle-reverse-sort-p icicle-sort-comparer)
- (icicle-propertize " (reversed)" 'face 'icicle-mode-line-help)
- "")))
- (let* ((lighter (cadr (assoc 'icicle-mode minor-mode-alist)))
- (regexp (and lighter (concat (regexp-quote icicle-lighter-truncation) "$")))
- props)
- (when lighter
- (setq lighter (concat lighter " ")
- props (text-properties-at 0 lighter))
- (when (string-match regexp lighter) (setq lighter (substring lighter 0 (match-beginning 0))))
- (add-text-properties 0 (length lighter) props lighter))
- (setq mode-line-format (concat lighter mode-line-format)))
- (goto-char (icicle-start-of-candidates-in-Completions))
- (set-window-point (get-buffer-window "*Completions*" 0) (point))
- (icicle-fit-completions-window))
-
- ;; Use the same font family as the starting buffer. This is particularly for picking up
- ;; the proper font for Unicode chars in `*Completions*'. Emacs 23+ only.
- ;; But skip this if using `oneonone.el', since `1on1-display-*Completions*-frame' does it.
- (when (and (not (fboundp '1on1-display-*Completions*-frame))
- (get-buffer-window "*Completions*" 'visible)
- icicle-pre-minibuffer-buffer
- (> emacs-major-version 22))
- (save-window-excursion
- (select-window (get-buffer-window "*Completions*" 'visible))
- (when (one-window-p t) ; $$$$$ Also this? (window-dedicated-p (selected-window))
- (let* ((orig-win (get-buffer-window icicle-pre-minibuffer-buffer 'visible))
- (orig-font-fam (and (window-live-p orig-win)
- (save-window-excursion (select-window orig-win)
- (face-attribute 'default :family)))))
- (when orig-font-fam (set-face-attribute 'default (selected-frame) :family orig-font-fam))))))
- (message nil))))) ; Clear out any "Looking for..."
+;;(@* "Icicles Functions - Completion Display (Not Cycling)")
+
+;;; Icicles Functions - Completion Display (Not Cycling) -------------
;; Similar to `diredp-mouseover-help'.
(defun icicle-mouseover-help (window buffer pos)
Version of `minibuffer-prompt-end' that works for Emacs 20 and later."
(if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) (point-min)))
-;;(@* "Icicles functions - TAB completion cycling")
+;;(@* "Icicles Functions - TAB Completion Cycling")
-;;; Icicles functions - TAB completion cycling --------------------
+;;; Icicles Functions - TAB Completion Cycling --------------------
(defun icicle-prefix-candidates (input)
"List of prefix or fuzzy completions for the current partial INPUT.
icicle-buffer-ignore-space-prefix-flag))))
(icicle-extra-candidates
(icicle-remove-if-not
- (lambda (cand)
- (save-match-data
- (string-match (concat "^" (regexp-quote input)) cand))) icicle-extra-candidates))
+ (lambda (cand) (save-match-data (string-match (concat "^" (regexp-quote input)) cand)))
+ icicle-extra-candidates))
(icicle-proxy-candidates
(icicle-remove-if-not
- (lambda (cand)
- (save-match-data
- (string-match (concat "^" (regexp-quote input)) cand))) icicle-proxy-candidates))
+ (lambda (cand) (save-match-data (string-match (concat "^" (regexp-quote input)) cand)))
+ icicle-proxy-candidates))
(filtered-candidates
(icicle-transform-candidates
(append icicle-extra-candidates icicle-proxy-candidates
(completion--field-metadata (field-beginning))))
(icicle-all-completions input minibuffer-completion-table pred)))
(icicle-extra-candidates
- (icicle-remove-if-not
- (lambda (cand)
- (save-match-data
- (string-match (concat "^" (regexp-quote input)) cand))) icicle-extra-candidates))
+ (let ((relname (file-name-nondirectory input)))
+ (icicle-remove-if-not
+ (lambda (cand) (save-match-data (string-match (concat "^" (regexp-quote relname)) cand)))
+ icicle-extra-candidates)))
(icicle-proxy-candidates
- (icicle-remove-if-not
- (lambda (cand)
- (save-match-data
- (string-match (concat "^" (regexp-quote input)) cand))) icicle-proxy-candidates))
+ (let ((relname (file-name-nondirectory input)))
+ (icicle-remove-if-not
+ (lambda (cand) (save-match-data (string-match (concat "^" (regexp-quote relname)) cand)))
+ icicle-proxy-candidates)))
(filtered-candidates
(icicle-transform-candidates
(append icicle-extra-candidates icicle-proxy-candidates
(lambda (&rest args) t))))
(if (stringp comp) (concat prefix comp) (mapcar (lambda (s) (concat prefix s)) comp)))))))))
-;;(@* "Icicles functions - S-TAB completion cycling")
+;;(@* "Icicles Functions - S-TAB Completion Cycling")
-;;; Icicles functions - S-TAB completion cycling -------------------
+;;; Icicles Functions - S-TAB Completion Cycling -------------------
(defun icicle-apropos-candidates (input)
"List of candidate apropos completions for the current partial INPUT.
(dotimes (idx (- (length string) (1- len))) (push (substring string idx (+ idx len)) subs))
(nreverse subs))))
-;;(@* "Icicles functions - common helper functions")
+;;(@* "Icicles Functions - Common Helper Functions")
-;;; Icicles functions - common helper functions ----------------------
+;;; Icicles Functions - Common Helper Functions ----------------------
(defun icicle-try-switch-buffer (buffer)
"Try to switch to BUFFER, first in same window, then in other window.
(substring filename 0 (1+ (match-beginning 0)))
(or (file-name-directory filename) ""))) ; Don't return nil, in any case.
-;; Note: Property `icicle-mode-line-help' with a function value is not used yet in Icicles code.
-(defun icicle-show-help-in-mode-line (candidate)
- "If short help for CANDIDATE is available, show it in the mode-line.
-Do this only if `icicle-help-in-mode-line-delay' is positive.
-
-For a string or symbol CANDIDATE: Use the help from property
-`icicle-mode-line-help', if that is non-nil, or the help from
-property `help-echo' if that is non-nil. For a string CANDIDATE,
-check only the first char for the property.
-
-The value of property `icicle-mode-line-help' can be a string or a
-function. If a string, use that as the help. If a function, apply
-the function to the candidate and use the result as the help."
- (when (> icicle-help-in-mode-line-delay 0)
- (let* ((cand (cond (;; Call to `lacarte-execute(-menu)-command' (in `lacarte.el').
- ;; Use command associated with menu item.
- (consp lacarte-menu-items-alist)
- (cdr (assoc candidate lacarte-menu-items-alist)))
- (;; Key-completion candidate. Get command from candidate.
- icicle-completing-keys-p
- (if (string= ".." candidate)
- "GO UP"
- (let ((cmd-name (save-match-data
- (string-match "\\(.+\\) = \\(.+\\)" candidate)
- (substring candidate (match-beginning 2)
- (match-end 2)))))
- (if (string= "..." cmd-name) "Prefix key" (intern-soft cmd-name)))))
- (;; Buffer or file name.
- (or (get-buffer candidate)
- (icicle-file-name-input-p)
- icicle-abs-file-candidates)
- (icicle-transform-multi-completion candidate))
- (t ; Convert to symbol or nil.
- (intern-soft (icicle-transform-multi-completion candidate)))))
- (doc (progn (when (stringp candidate)
- (setq candidate (icicle-transform-multi-completion candidate)))
- (cond ((and (stringp candidate) ; String with help as property.
- (let ((prop (or (get-text-property 0 'icicle-mode-line-help
- candidate)
- (get-text-property 0 'help-echo candidate))))
- (and prop
- (icicle-propertize
- (if (functionp prop) (funcall prop candidate) prop)
- 'face 'icicle-mode-line-help)))))
- ((and cand
- (symbolp cand) ; Symbol.
- (let ((doc2
- (cond ((get cand 'icicle-mode-line-help)) ; Icicles help prop.
- ((get cand 'help-echo)) ; General help prop.
- ((fboundp cand) ; Function.
- (or (documentation cand t) ; Functon's doc string.
- (if (string-match ; Easy-menu item.
- "^menu-function-[0-9]+$" (symbol-name cand))
- (format "%s" (symbol-function cand))
- (format "Command `%s'" cand))))
- ((facep cand) (face-documentation cand)) ; Face.
- (t (documentation-property ; Variable.
- cand 'variable-documentation t)))))
- (and doc2
- (icicle-propertize doc2 'face 'icicle-mode-line-help)))))
- ((and (consp cand) (eq (car cand) 'lambda)) ; Lambda form.
- (icicle-propertize (format "%s" cand) 'face 'icicle-mode-line-help))
- ((and (stringp cand) ; Prefix key, `..'.
- (member cand '("Prefix key" "GO UP")))
- (icicle-propertize cand 'face 'icicle-mode-line-help))
- ((stringp candidate) ; String without help property.
- (cond ((and (or (icicle-file-name-input-p) ; File name.
- icicle-abs-file-candidates)
- (or (icicle-file-remote-p candidate) ; Avoid Tramp.
- (file-exists-p candidate)))
- (if (get-file-buffer candidate)
- (concat (icicle-help-line-buffer (get-file-buffer candidate)
- 'NO-BYTES-P
- 'NO-FILE-P)
- " "
- (icicle-help-line-file cand))
- (icicle-help-line-file candidate)))
- ((get-buffer candidate) ; Non-file buffer.
- (icicle-help-line-buffer candidate))
- (t nil)))))) ; Punt.
- (doc-line1 (and (stringp doc) (string-match ".+$" doc) (match-string 0 doc))))
- (when doc-line1
- (icicle-show-in-mode-line
- doc-line1
- (cond ((get-buffer-window "*Completions*" 'visible) "*Completions*")
- ((eq (current-buffer) (window-buffer (minibuffer-window))) (cadr (buffer-list)))
- (t (current-buffer))))))))
-
-(defun icicle-help-line-buffer (buffer &optional no-bytes-p no-file-p)
- "Simple help string for BUFFER.
-Non-nil NO-BYTES-P means do not include the number of bytes.
-Non-nil NO-FILE-P means do not include the buffer's file name."
- (with-current-buffer buffer
- (let* ((mode (format "Mode: %s"
- (icicle-propertize
- (if (fboundp 'format-mode-line) (format-mode-line mode-name) mode-name)
- 'face 'icicle-mode-line-help)))
- (bytes (format "Bytes: %s"
- (icicle-propertize (let ((size (buffer-size)))
- (if (> size most-positive-fixnum)
- (format "> %d" most-positive-fixnum)
- size))
- 'face 'icicle-mode-line-help)))
- (file (or (buffer-file-name)
- (and (eq major-mode 'dired-mode) default-directory))))
- (cond ((and no-bytes-p no-file-p) mode)
- ((or no-file-p (not file)) (concat mode ", " bytes))
- (t
- (setq file (format "File: %s" (icicle-propertize (icicle-abbreviate-or-expand-file-name file)
- 'face 'icicle-mode-line-help)))
- (if no-bytes-p (concat mode ", " file) (concat mode ", " bytes ", " file)))))))
-
-(defun icicle-help-line-file (file)
- "Simple help string for FILE."
- (let ((attrs (file-attributes file)))
- (and attrs (format "Bytes: %s, Saved: %s, Access: %s, Perm: %s"
- (let ((size (nth 7 attrs)))
- (icicle-propertize (if (> size most-positive-fixnum)
- (format "> %d" most-positive-fixnum)
- size)
- 'face 'icicle-mode-line-help))
- (icicle-propertize (format-time-string "%c" (nth 5 attrs)) ; "%Y-%m-%d %H"
- 'face 'icicle-mode-line-help)
- (icicle-propertize (format-time-string "%c" (nth 4 attrs)) ; "%Y-%m-%d %H"
- 'face 'icicle-mode-line-help)
- (icicle-propertize (nth 8 attrs) 'face 'icicle-mode-line-help)))))
-
-(defun icicle-show-in-mode-line (text &optional buffer)
- "Display TEXT in BUFFER's mode line.
-The text is shown for `icicle-help-in-mode-line-delay' seconds, or
-until a user event. So call this last in a sequence of user-visible
-actions."
- (message nil) ; Remove any msg, such as "Computing completion candidates...".
- (with-current-buffer (or buffer (current-buffer))
- (make-local-variable 'mode-line-format) ; Needed for Emacs 21+.
- (let ((mode-line-format text)) (force-mode-line-update) (sit-for icicle-help-in-mode-line-delay))
- (force-mode-line-update)))
-
(defun icicle-recompute-candidates (nth candidates-fn saved-last-input)
"Recompute `icicle-completion-candidates', if needed.
If buffer `*Completions*' is already displayed, it is updated.
This means that completion candidates are relative file names.
If instead you want to test whether input is a file name, absolute or
relative, use this test:
-
(or (icicle-file-name-input-p) icicle-abs-file-candidates)"
minibuffer-completing-file-name)
-(defun icicle-looks-like-dir-name-p (file)
- "Return non-nil if FILE looks like a directory name.
-If FILE is not a string, return nil. Otherwise, FILE can be an
-absolute or a relative file name.
-
-This compares FILE with the directory part of its name, or with
-`default-directory' if there is no directory part.
-
-This does not do the file-handler processing that `file-directory-p'
-does, so it is not a replacement for that function. And unlike
-`file-directory-p', this returns non-nil for an argument like
-\"~/foo//usr/\"."
- (and (stringp file) (string= file (icicle-file-name-directory-w-default file))))
-
(defun icicle-minibuf-input ()
"Return the user minibuffer input as a string, without text-properties."
(save-selected-window (select-window (minibuffer-window)) (icicle-input-from-minibuffer)))
(let ((lookup (gethash drive icicle-ms-windows-drive-hash 'no-assoc)))
(if (eq lookup 'no-assoc)
(puthash drive (call-process shell-file-name nil nil nil shell-command-switch
- (concat "NET USE " drive)) icicle-ms-windows-drive-hash)
+ (concat "NET USE " drive))
+ icicle-ms-windows-drive-hash)
lookup))
;; Don't bother to hash for Emacs 20, 21, unless `cl.el' happens to be loaded.
(call-process shell-file-name nil nil nil shell-command-switch (concat "NET USE " drive))))
-;;; $$$$$$
-;;; (defun icicle-file-remote-p (file) ; Older definition - new one is like `bmkp-file-remote-p'.
-;;; "Non-nil means FILE is likely to name a file on a remote system.
-;;; For MS Windows, if `icicle-network-drive-means-remote-flag' is non-nil
-;;; then this includes a file on a mapped network drive.
-
-;;; Otherwise, use, in order, `ffap-file-remote-p' or `file-remote-p'. If
-;;; those functions are not defined then return nil."
-;;; (or (and (eq system-type 'windows-nt)
-;;; ;; $$$$ (save-match-data ; IS THIS NEEDED?
-;;; (let ((case-fold-search t)) (string-match "\\`\\([a-z]:\\)" file))
-;;; (eq 0 (condition-case nil
-;;; (icicle-ms-windows-NET-USE (match-string 1 file))
-;;; (error nil)))
-;;; icicle-network-drive-means-remote-flag)
-;;; (and (fboundp 'ffap-file-remote-p) (ffap-file-remote-p file))
-;;; (and (fboundp 'file-remote-p) (file-remote-p file))))
-
-(defun icicle-file-remote-p (file)
- "Non-nil means FILE is likely to name a file on a remote system.
-For MS Windows, if `icicle-network-drive-means-remote-flag' is non-nil
-then this includes a file on a mapped network drive.
-
-Otherwise, use, in order, `ffap-file-remote-p' or `file-remote-p'. If
-those functions are not defined then return nil."
- (or (and (eq system-type 'windows-nt)
- ;; $$$$ (save-match-data ; IS THIS NEEDED?
- (let ((case-fold-search t)) (string-match "\\`\\([a-z]:\\)" file))
- (eq 0 (condition-case nil
- (icicle-ms-windows-NET-USE (match-string 1 file))
- (error nil)))
- icicle-network-drive-means-remote-flag)
- (and (fboundp 'file-remote-p) (file-remote-p file))
- (and (stringp file) (string-match "\\`/[^/]+:" file) (match-string 0 file))))
-
;;; $$$$$ Should these `*-any-*' fns call `icicle-transform-candidates'? For now, no, to save time.
(defun icicle-any-candidates-p (input)
"Return non-nil if there is any completion for INPUT, nil otherwise."
(setq last-repeatable-command command)
(repeat nil)))
-(defun icicle-file-readable-p (file)
- "Return non-nil if FILE (a string) names a readable file."
- (and (not (string= "" file)) (file-readable-p file) (not (file-directory-p file))))
-
-(defun icicle-file-writable-p (file)
- "Return non-nil if FILE (a string) names a writable file."
- (and (not (string= "" file)) (file-writable-p file) (not (file-directory-p file))))
-
(defvar icicle-dirs-done ()
"Directories already processed.")
(buffer-string))))
(defun icicle-barf-if-outside-minibuffer ()
- "Raise an error if `this-command' is called outside the minibuffer."
- (unless (eq (current-buffer) (window-buffer (minibuffer-window)))
- (icicle-user-error "Command `%s' must be called from the minibuffer" this-command)))
+ "Raise an error if `this-command' is called outside the minibuffer.
+Return non-nil otherwise."
+ (or (eq (current-buffer) (window-buffer (minibuffer-window)))
+ (icicle-user-error "Command `%s' must be called from the minibuffer" this-command)))
(defun icicle-barf-if-outside-Completions ()
- "Raise error if `this-command' is called outside buffer `*Completions*'."
- (unless (eq (current-buffer) (get-buffer "*Completions*"))
- (icicle-user-error "Command `%s' must be called from `*Completions*' buffer" this-command)))
+ "Raise error if `this-command' is called outside buffer `*Completions*'.
+Return non-nil otherwise."
+ (or (eq (current-buffer) (get-buffer "*Completions*"))
+ (icicle-user-error "Command `%s' must be called from `*Completions*' buffer" this-command)))
(defun icicle-barf-if-outside-Completions-and-minibuffer ()
- "Error if `this-command' called outside `*Completions*' and minibuffer."
- (unless (or (eq (current-buffer) (window-buffer (minibuffer-window)))
- (eq (current-buffer) (get-buffer "*Completions*")))
- (icicle-user-error "`%s' must be called from `*Completions*' or minibuffer" this-command)))
+ "Error if `this-command' called outside `*Completions*' and minibuffer.
+Return non-nil otherwise."
+ (or (or (eq (current-buffer) (window-buffer (minibuffer-window)))
+ (eq (current-buffer) (get-buffer "*Completions*")))
+ (icicle-user-error "`%s' must be called from `*Completions*' or minibuffer" this-command)))
(defun icicle-command-abbrev-save ()
"Save `icicle-command-abbrev-alist'. Used on `kill-emacs-hook'."
- (icicle-condition-case-no-debug err ; Don't raise an error, since it's on `kill-emacs-hook.
+ (icicle-condition-case-no-debug err ; Don't raise an error, since it's on `kill-emacs-hook'.
(let ((sav (get 'icicle-command-abbrev-alist 'saved-value)))
(unless (and (or (null sav)
(and (consp sav) (consp (car sav)) (consp (cdar sav))
(setq expanded-input (file-name-as-directory expanded-input)))
expanded-input))
-(defun icicle-expand-file-name-20 (input dir)
+(defun icicle-expand-file-name-20 (input &optional dir)
"Emacs 20's `expand-file-name': does not collapse consecutive slashes."
;; Replace // with five ^Gs, then replace back again.
(let ((escaped-input (and input (replace-regexp-in-string "//" (make-string 5 7) input)))
(setq candidates (cdr candidates))))
res))
+;;; $$$$$$$$
+;;; (defun icicle-completing-p ()
+;;; "Non-nil if reading minibuffer input with completion.
+;;; This caches the value returned in variable `icicle-completing-p'.
+;;; Use the function, not the variable, to test, if not sure to be in the
+;;; minibuffer."
+;;; (setq icicle-completing-p ; Cache the value.
+;;; (and (active-minibuffer-window)
+;;; ;; We used to include filename keymaps in MAPS, but that does not work for
+;;; ;; Emacs > 24.3 - it uses a composed keymap that it creates on the fly.
+;;; ;; So instead we just check `minibuffer-completing-file-name' now for Emacs 22+.
+;;; (or (and minibuffer-completing-file-name (> emacs-major-version 21))
+;;; (let* ((loc-map (current-local-map))
+;;; (parent (keymap-parent loc-map))
+;;; (maps (list minibuffer-local-completion-map
+;;; minibuffer-local-must-match-map)))
+;;; (and (or (and parent (member parent maps)) (member loc-map maps))
+;;; t)))))) ; Cache t, not the keymap portion.
+
(defun icicle-completing-p ()
"Non-nil if reading minibuffer input with completion.
This caches the value returned in variable `icicle-completing-p'.
Use the function, not the variable, to test, if not sure to be in the
minibuffer."
- (setq icicle-completing-p ; Cache the value.
- (and (active-minibuffer-window)
- ;; We used to include filename keymaps in MAPS, but that does not work for
- ;; Emacs > 24.3 - it uses a composed keymap that it creates on the fly.
- ;; So instead we just check `minibuffer-completing-file-name' now for Emacs 22+.
- (or (and minibuffer-completing-file-name (> emacs-major-version 21))
- (let* ((loc-map (current-local-map))
- (parent (keymap-parent loc-map))
- (maps (list minibuffer-local-completion-map
- minibuffer-local-must-match-map)))
- (and (or (and parent (member parent maps)) (member loc-map maps))
- t)))))) ; Cache t, not the keymap portion.
+ (let ((mini-win (active-minibuffer-window)))
+ (setq icicle-completing-p ; Cache the value.
+ (and mini-win (icicle-with-selected-window mini-win
+ (local-key-binding [icicle-is-completion-map]))))))
;; This is just `substring-no-properties', defined also for Emacs < 22.
(defun icicle-substring-no-properties (string &optional from to)
(funcall #'non-nil-symbol-name-nearest-point))
((icicle-thing-at-point 'symbol))
((function-called-at-point))))
+
+(defun icicle-alist-key-match (regexp alist)
+ "Return non-nil if REGEXP matches a key of ALIST.
+The non-nil value returned is the first element whose key matches."
+ (catch 'icicle-alist-key-match
+ (dolist (key.val alist)
+ (when (string-match regexp (car key.val)) (throw 'icicle-alist-key-match key.val)))
+ nil))
+
-;;(@* "Icicles functions - sort functions")
+;;(@* "Icicles Functions - Sort Functions")
-;;; Icicles functions - sort functions -------------------------------
+;;; Icicles Functions - Sort Functions -------------------------------
(defun icicle-merge-saved-order-less-p (s1 s2)
"String S1 has a lower index than S2 in current and saved candidates list."
That is, S1 < S2 if S1 is a special candidate and S2 is not or S1
`icicle-case-string-less-p' S2 and either both or neither are special
candidates."
- (let ((s1-special (get (intern s1) 'icicle-special-candidate))
- (s2-special (get (intern s2) 'icicle-special-candidate)))
+ (let ((s1-special (icicle-special-candidate-p s1))
+ (s2-special (icicle-special-candidate-p s2)))
(when (or case-fold-search
completion-ignore-case
;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'.
(defun icicle-get-safe (object property)
"If OBJECT is a symbol, `get' its PROPERTY value. Else return nil."
(and (symbolp object) (get object property)))
+
+;;(@* "Icicles Predicates for Different Candidate Types")
+
+;;; Icicles Predicates for Different Candidate Types -----------------
+
+
+;;(@* "Bookmark-Completion Predicates")
+;; ** Bookmark-Completion Predicates **
+
+(when (require 'bookmark+ nil t)
+
+ (defun icicle-bookmark-annotated-p (bookmark)
+ "Return non-nil if BOOKMARK has an annotation.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name.
+In this case, the second part is tested."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-annotated-bookmark-p bookmark))
+
+ (defun icicle-bookmark-autofile-p (bookmark)
+ "Return non-nil if BOOKMARK is an autofile bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name.
+In this case, the second part is tested."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-autofile-bookmark-p bookmark))
+
+ (defun icicle-bookmark-autonamed-p (bookmark)
+ "Return non-nil if BOOKMARK is an autonamed bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-autonamed-bookmark-p bookmark))
+
+ (defun icicle-bookmark-autonamed-this-buffer-p (bookmark)
+ "Return non-nil if BOOKMARK is an autonamed bookmark for this buffer.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (with-current-buffer icicle-orig-buff ; FREE here: ICICLE-ORIG-BUFF.
+ (bmkp-autonamed-this-buffer-bookmark-p bookmark)))
+
+ (defun icicle-bookmark-bookmark-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a bookmark-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-bookmark-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-bookmark-list-p (bookmark)
+ "Return non-nil if BOOKMARK is a bookmark-list bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-bookmark-list-bookmark-p bookmark))
+
+ (defun icicle-bookmark-desktop-p (bookmark)
+ "Return non-nil if BOOKMARK is a desktop bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-desktop-bookmark-p bookmark))
+
+ (defun icicle-bookmark-dired-p (bookmark)
+ "Return non-nil if BOOKMARK is a Dired bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-dired-bookmark-p bookmark))
+
+ (defun icicle-bookmark-dired-this-dir-p (bookmark)
+ "Return non-nil if BOOKMARK is a Dired bookmark for this buffer.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (with-current-buffer icicle-orig-buff ; FREE here: ICICLE-ORIG-BUFF.
+ (bmkp-dired-this-dir-bookmark-p bookmark)))
+
+ (defun icicle-bookmark-dired-wildcards-p (bookmark)
+ "Return non-nil if BOOKMARK bookmarks a Dired buffer with wildcards.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-dired-wildcards-bookmark-p bookmark))
+
+ (defun icicle-bookmark-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-file-this-dir-p (bookmark)
+ "Return non-nil if BOOKMARK is a file bookmark for this directory.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (with-current-buffer icicle-orig-buff ; FREE here: ICICLE-ORIG-BUFF.
+ (bmkp-file-this-dir-bookmark-p bookmark)))
+
+ (defun icicle-bookmark-flagged-p (bookmark)
+ "Return non-nil if BOOKMARK is flagged for deletion in `*Bookmark List*'.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-flagged-bookmark-p bookmark))
+
+ (defun icicle-bookmark-function-p (bookmark)
+ "Return non-nil if BOOKMARK is a function bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-function-bookmark-p bookmark))
+
+ (defun icicle-bookmark-gnus-p (bookmark)
+ "Return non-nil if BOOKMARK is a Gnus bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-gnus-bookmark-p bookmark))
+
+ (defun icicle-bookmark-icicle-search-hits-p (bookmark)
+ "Return non-nil if BOOKMARK records a list of Icicles search hits.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-icicle-search-hits-bookmark-p bookmark))
+
+ (defun icicle-bookmark-image-p (bookmark)
+ "Return non-nil if BOOKMARK is an image-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-image-bookmark-p bookmark))
+
+ (defun icicle-bookmark-info-p (bookmark)
+ "Return non-nil if BOOKMARK is an Info bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-info-bookmark-p bookmark))
+
+;;;; (defun icicle-bookmark-last-specific-buffer-p (bookmark)
+;;;; "Return non-nil if BOOKMARK's buffer is `bmkp-last-specific-buffer'.
+;;;; That is the buffer last used by command `bmkp-this-buffer-bmenu-list'
+;;;; to list bookmarks for a specific buffer in `*Bookmark List*'.
+
+;;;; If BOOKMARK is a cons with a string car, then the car is used as the
+;;;; effective argument. This is so that the function can be used to
+;;;; filter completion candidates. The string can be a multi-completion
+;;;; whose first part is the bookmark name."
+;;;; (when (consp bookmark) (setq bookmark (car bookmark)))
+;;;; (when icicle-multi-completing-p
+;;;; (let ((icicle-list-use-nth-parts '(1)))
+;;;; (setq bookmark (icicle-transform-multi-completion bookmark))))
+;;;; (bmkp-last-specific-buffer-p bookmark))
+
+;;;; (defun icicle-bookmark-last-specific-file-p (bookmark)
+;;;; "Return non-nil if BOOKMARK's file is `bmkp-last-specific-file'.
+;;;; That is the file last used by command `bmkp-this-file-bmenu-list' to
+;;;; list bookmarks for a specific file in `*Bookmark List*'.
+
+;;;; If BOOKMARK is a cons with a string car, then the car is used as
+;;;; the effective argument. This is so that the function can be used to
+;;;; filter completion candidates. The string can be a multi-completion
+;;;; whose first part is the bookmark name."
+;;;; (when (consp bookmark) (setq bookmark (car bookmark)))
+;;;; (when icicle-multi-completing-p
+;;;; (let ((icicle-list-use-nth-parts '(1)))
+;;;; (setq bookmark (icicle-transform-multi-completion bookmark))))
+;;;; (bmkp-last-specific-file-p bookmark))
+
+ (when (require 'bookmark+-lit nil t)
+ (defun icicle-bookmark-lighted-p (bookmark)
+ "Return non-nil if BOOKMARK is a highlighted bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-lighted-p bookmark)))
+
+ (defun icicle-bookmark-local-directory-p (bookmark)
+ "Return non-nil if BOOKMARK is a local-directory bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-local-directory-bookmark-p bookmark))
+
+ (defun icicle-bookmark-local-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a local-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-local-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-man-p (bookmark)
+ "Return non-nil if BOOKMARK is a `man'-page bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-man-bookmark-p bookmark))
+
+ (defun icicle-bookmark-marked-p (bookmark)
+ "Return non-nil if BOOKMARK is marked in `*Bookmark List*'.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-marked-bookmark-p bookmark))
+
+ (defun icicle-bookmark-modified-p (bookmark)
+ "Return non-nil if BOOKMARK is a modified (unsaved) bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-modified-bookmark-p bookmark))
+
+ (defun icicle-bookmark-navlist-p (bookmark)
+ "Return non-nil if BOOKMARK is in the bookmark navigation list.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-navlist-bookmark-p bookmark))
+
+ (defun icicle-bookmark-non-dir-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a non-directory file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-non-dir-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-non-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a non-file bookmark (e.g `*scratch*').
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-non-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-omitted-p (bookmark)
+ "Return non-nil if BOOKMARK is omitted in `*Bookmark List*'.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-omitted-bookmark-p bookmark))
+
+ (defun icicle-bookmark-orphaned-file-p (bookmark)
+ "Return non-nil if BOOKMARK is an orphaned-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-orphaned-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-orphaned-local-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a orphaned-local-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-orphaned-local-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-orphaned-remote-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a orphaned-remote-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-orphaned-remote-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-region-p (bookmark)
+ "Return non-nil if BOOKMARK has region information.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-region-bookmark-p bookmark))
+
+ (defun icicle-bookmark-remote-file-p (bookmark)
+ "Return non-nil if BOOKMARK is a remote-file bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-remote-file-bookmark-p bookmark))
+
+ (defun icicle-bookmark-sequence-p (bookmark)
+ "Return non-nil if BOOKMARK is a sequence (composite) bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-sequence-bookmark-p bookmark))
+
+ (defun icicle-bookmark-snippet-p (bookmark)
+ "Return non-nil if BOOKMARK is a snippet bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-snippet-bookmark-p bookmark))
+
+ (defun icicle-bookmark-tagged-p (bookmark)
+ "Return non-nil if BOOKMARK is a tagged bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-tagged-bookmark-p bookmark))
+
+ (defun icicle-bookmark-temporary-p (bookmark)
+ "Return non-nil if BOOKMARK is a temporary bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-temporary-bookmark-p bookmark))
+
+ (defun icicle-bookmark-this-buffer-p (bookmark)
+ "Return non-nil if BOOKMARK is a bookmark for this buffer.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (with-current-buffer icicle-orig-buff ; FREE here: ICICLE-ORIG-BUFF.
+ (bmkp-this-buffer-p bookmark)))
+
+;;; (defun icicle-bookmark-this-file-p (bookmark)
+;;; "Return non-nil if BOOKMARK is a bookmark for this file.
+;;; If BOOKMARK is a cons with a string car, then the car is used as
+;;; the effective argument. This is so that the function can be used to
+;;; filter completion candidates. The string can be a multi-completion
+;;; whose first part is the bookmark name."
+;;; (when (consp bookmark) (setq bookmark (car bookmark)))
+;;; (when icicle-multi-completing-p
+;;; (let ((icicle-list-use-nth-parts '(1)))
+;;; (setq bookmark (icicle-transform-multi-completion bookmark))))
+;;; (with-current-buffer icicle-orig-buff ; FREE here: ICICLE-ORIG-BUFF.
+;;; (bmkp-this-file-p bookmark)))
+
+ (defun icicle-bookmark-url-p (bookmark)
+ "Return non-nil if BOOKMARK is a URL bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-url-bookmark-p bookmark))
+
+ (defun icicle-bookmark-url-browse-p (bookmark)
+ "Return non-nil if BOOKMARK is a `browse-url' bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-url-browse-bookmark-p bookmark))
+
+ (defun icicle-bookmark-variable-list-p (bookmark)
+ "Return non-nil if BOOKMARK is a variable-list bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-variable-list-bookmark-p bookmark))
+
+ (defun icicle-bookmark-w3m-p (bookmark)
+ "Return non-nil if BOOKMARK is a W3M bookmark.
+If BOOKMARK is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+whose first part is the bookmark name."
+ (when (consp bookmark) (setq bookmark (car bookmark)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq bookmark (icicle-transform-multi-completion bookmark))))
+ (bmkp-w3m-bookmark-p bookmark))
+
+ )
+
+
+;;(@* "Buffer-Completion Predicates")
+;; ** Buffer-Completion Predicates **
+
+(when (fboundp 'interesting-buffer-p) ; In `misc-cmds.el'.
+ (defun icicle-interesting-buffer-p (buffer-or-name)
+ "Return non-nil if BUFFER-OR-NAME is or names an interesting buffer.
+This means that the buffer is live and its name does not start with a
+space.
+
+If BUFFER-OR-NAME is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates."
+ (when (consp buffer-or-name) (setq buffer-or-name (car buffer-or-name)))
+ (when (stringp buffer-or-name) (setq buffer-or-name (get-buffer buffer-or-name)))
+ (interesting-buffer-p buffer-or-name)))
+
+(when (fboundp 'next-error-buffer-p) ; Emacs 22+
+ (defun icicle-next-error-buffer-p (buffer-or-name &optional avoid-current
+ extra-test-inclusive extra-test-exclusive)
+ "Return non-nil if BUFFER-OR-NAME is or names a `next-error' buffer.
+If BUFFER-OR-NAME is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates.
+
+If AVOID-CURRENT is non-nil, treat the current buffer only as an
+absolute last resort.
+
+EXTRA-TEST-INCLUSIVE, if non-nil, is a function that is called in each
+buffer that normally would not qualify. If it returns non-nil then
+so does `next-error-buffer-p'.
+
+EXTRA-TEST-EXCLUSIVE, if non-nil, is a function that is called in each
+buffer that normally would qualify. If it returns nil then so does
+`next-error-buffer-p'."
+ (when (consp buffer-or-name) (setq buffer-or-name (car buffer-or-name)))
+ (when (stringp buffer-or-name) (setq buffer-or-name (get-buffer buffer-or-name)))
+ (next-error-buffer-p buffer-or-name avoid-current extra-test-inclusive extra-test-exclusive)))
+
+(defun icicle-compilation-buffer-p (buffer-or-name)
+ "Return non-nil if BUFFER-OR-NAME is or names a compilation buffer.
+If BUFFER-OR-NAME is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates."
+ (when (consp buffer-or-name) (setq buffer-or-name (car buffer-or-name)))
+ (when (stringp buffer-or-name) (setq buffer-or-name (get-buffer buffer-or-name)))
+ (compilation-buffer-p buffer-or-name))
+
+(defun icicle-special-display-p (buffer-name)
+ "Return non-nil if a buffer named BUFFER-NAME gets a special frame.
+More precisely, return t if `special-display-buffer-names' or
+`special-display-regexps' contains a string entry equaling or matching
+BUFFER-NAME, respectively. If `special-display-buffer-names' or
+`special-display-regexps' contains a list entry whose car equals or
+matches BUFFER-NAME, the return value is the cdr of that entry.
+
+If BUFFER-NAME is a cons with a string car, then the car is used as
+the effective argument. This is so that the function can be used to
+filter completion candidates."
+ (when (consp buffer-name) (setq buffer-name (car buffer-name)))
+ (special-display-p buffer-name))
+
+(defun icicle-buffer-modified-p (buffer-or-name)
+ "Return non-nil if BUFFER-OR-NAME is or names a buffer that is modified.
+Same as `buffer-modified-p' except that it returns non-nil if the
+argument is a string naming a modified buffer. If the argument is a
+cons with a string car, then the car is used as the effective
+argument. This is so that the function can be used to filter
+completion candidates."
+ (when (consp buffer-or-name) (setq buffer-or-name (car buffer-or-name)))
+ (when (stringp buffer-or-name) (setq buffer-or-name (get-buffer buffer-or-name)))
+ (and buffer-or-name (buffer-modified-p buffer-or-name)))
+
+;;(@* "Color-Completion Predicates")
+;; ** Color-Completion Predicates **
+
+(when (fboundp 'color-gray-p) ; Emacs 22+
+ (defun icicle-color-gray-p (color &optional frame)
+ "Return non-nil if COLOR is a shade of gray (or white or black).
+See `icicle-color-defined-p' for COLOR.
+FRAME specifies the frame and thus the display for interpreting COLOR.
+If FRAME is nil or omitted, use the selected frame."
+ (when (consp color) (setq color (car color)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(2)))
+ (setq color (icicle-transform-multi-completion color))))
+ (color-gray-p color frame)))
+
+(when (fboundp 'color-supported-p) ; Emacs 22+
+ (defun icicle-color-supported-p (color &optional frame background-p)
+ "Return non-nil if COLOR can be displayed on FRAME.
+See `icicle-color-defined-p' for COLOR.
+BACKGROUND-P non-nil means COLOR is used as a background.
+Otherwise, this function tells whether it can be used as a foreground.
+If FRAME is nil or omitted, use the selected frame."
+ (when (consp color) (setq color (car color)))
+ (when icicle-multi-completing-p
+ (let ((icicle-list-use-nth-parts '(2)))
+ (setq color (icicle-transform-multi-completion color))))
+ (color-supported-p color frame background-p)))
+
+;;(@* "Face-Completion Predicates")
+;; ** Face-Completion Predicates **
+
+(defun icicle-face-bold-p (face &optional frame inherit)
+ "Return non-nil if the font of FACE is bold on FRAME.
+If FACE is a cons with a string car, then the car is used as the
+name of the face. This is so that the function can be used to
+filter completion candidates. The string can be a multi-completion
+as produced by `icicle-make-face-candidate'.
+
+If optional argument FRAME is given, report on FACE in that frame.
+If FRAME is t, report on the defaults for face FACE (for new frames).
+If FRAME is omitted or nil, use the selected frame.
+Optional argument INHERIT is passed to `face-attribute'.
+Use `face-attribute' for finer control."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (if (> emacs-major-version 21)
+ (face-bold-p face frame inherit)
+ (face-bold-p face frame)))
+
+(defun icicle-face-differs-from-default-p (face &optional frame)
+ "Return non-nil if FACE displays differently from the default face.
+See `icicle-face-bold-p' for FACE.
+If optional argument FRAME is given, report on FACE in that frame.
+If FRAME is t, report on the defaults for FACE (for new frames).
+If FRAME is omitted or nil, use the selected frame."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (face-differs-from-default-p face frame))
+
+(defun icicle-face-inverse-video-p (face &optional frame inherit)
+ "Return non-nil if FACE specifies a non-nil inverse-video.
+See `icicle-face-bold-p' for arguments."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (if (> emacs-major-version 21)
+ (face-inverse-video-p face frame inherit)
+ (face-inverse-video-p face frame)))
+
+(defun icicle-face-italic-p (face &optional frame inherit)
+ "Return non-nil if the font of FACE is italic on FRAME.
+See `icicle-face-bold-p' for arguments."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (if (> emacs-major-version 21)
+ (face-italic-p face frame inherit)
+ (face-italic-p face frame)))
+
+(defun icicle-face-nontrivial-p (face &optional frame)
+ "Return non-nil if FACE has some non-nil attribute.
+See `icicle-face-bold-p' for FACE.
+If optional argument FRAME is given, report on FACE in that frame.
+If FRAME is t, report on the defaults for FACE (for new frames).
+If FRAME is omitted or nil, use the selected frame."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (face-differs-from-default-p face frame))
+
+(defun icicle-face-underline-p (face &optional frame inherit)
+ "Return non-nil if the font of FACE specifies non-nil underlining.
+See `icicle-face-bold-p' for arguments."
+ (when (consp face) (setq face (car face)))
+ (when (and icicle-multi-completing-p (stringp face))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq face (icicle-transform-multi-completion face))))
+ (when (stringp face) (setq face (intern face)))
+ (if (> emacs-major-version 21)
+ (face-underline-p face frame inherit)
+ (face-underline-p face frame)))
+
+;;(@* "File- and Directory-Completion Predicates")
+;; ** File- and Directory-Completion Predicates **
+
+(defun icicle-file-accessible-directory-p (file-or-dir)
+ "Return non-nil if FILE-OR-DIR names a directory you can open.
+For the value to be non-nil, FILE-OR-DIR must specify the name of a
+directory as a file, and the directory must let you open files in it.
+In order to use a directory as the current directory of a buffer, this
+predicate must return non-nil. A directory-name spec may be given
+instead; then the value is non-nil if the directory so specified
+exists and really is a readable and searchable directory.
+
+FILE-OR-DIR is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp file-or-dir) (setq file-or-dir (car file-or-dir)))
+ (file-accessible-directory-p file-or-dir))
+
+;; Similar to `bmkp-desktop-file-p' in `bookmark+-1.el'.
+;; This is better than using `find-file-noselect', which visits the file and leaves its buffer.
+(defun icicle-file-desktop-p (filename)
+ "Return non-nil if FILENAME names a desktop file.
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (and (stringp filename)
+ (file-readable-p filename)
+ (not (file-directory-p filename))
+ (with-temp-buffer
+ (insert-file-contents-literally filename nil 0 1000)
+ (goto-char (point-min))
+ (and (zerop (forward-line 2))
+ (icicle-looking-at-p "^;; Desktop File for Emacs"))))) ; No $, because maybe eol chars (e.g. ^M).
+
+(defun icicle-file-directory-p (file-or-dir)
+ "Return t if FILE-OR-DIR names an existing directory.
+Symbolic links to directories count as directories.
+See `file-symlink-p' to distinguish symlinks.
+
+FILE-OR-DIR is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp file-or-dir) (setq file-or-dir (car file-or-dir)))
+ (file-directory-p file-or-dir))
+
+(defun icicle-looks-like-dir-name-p (file-or-dir)
+ "Return non-nil if FILE-OR-DIR looks like a directory name.
+If FILE-OR-DIR is not a string, return nil. Otherwise, FILE-OR-DIR
+can be an absolute or a relative file name.
+
+This compares FILE-OR-DIR with the directory part of its name, or with
+`default-directory' if there is no directory part.
+
+This does not do the file-handler processing that `file-directory-p'
+does, so it is not a replacement for that function. And unlike
+`file-directory-p', this returns non-nil for an argument like
+\"~/foo//usr/\"."
+ (when (consp file-or-dir) (setq file-or-dir (car file-or-dir)))
+ (and (stringp file-or-dir) (string= file-or-dir (icicle-file-name-directory-w-default file-or-dir))))
+
+;; Same as `dired-nondirectory-p', except this accepts also a cons.
+(defun icicle-nondirectory-p (file-or-dir)
+ "Return non-nil if FILE-OR-DIR does not name directory.
+Symbolic links to directories count as directories.
+See `file-symlink-p' to distinguish symlinks.
+
+FILE-OR-DIR is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp file-or-dir) (setq file-or-dir (car file-or-dir)))
+ (not (file-directory-p file-or-dir)))
+
+(defun icicle-file-compressed-p (filename)
+ "Return non-nil if FILENAME names a compressed file.
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (and (require 'jka-compr nil t) (icicle-string-match-p (jka-compr-build-file-regexp) filename)))
+
+(when (fboundp 'ffap-file-remote-p) ; In `ffap.el'
+ (defun icicle-ffap-file-remote-p (filename)
+ "Return non-nil if FILENAME looks like it names a remote file.
+The non-nil value is FILENAME (maybe slightly improved)."
+ (when (consp filename) (setq filename (car filename)))
+ (ffap-file-remote-p filename))
+
+ (defun icicle-ffap-url-p (url)
+ "Return non-nil if URL looks like a URL.
+The non-nil value is URL (maybe slightly improved)."
+ (when (consp url) (setq url (car url)))
+ (ffap-url-p url)))
+
+(when (fboundp 'recentf-include-p)
+ (defun icicle-recentf-include-p (filename)
+ "Return non-nil if FILENAME is not to be excluded by `recentf-exclude'.
+FILENAME is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (recentf-include-p filename)))
+
+(when (fboundp 'recentf-keep-p) ; In `recentf.el'
+ (defun icicle-recentf-keep-p (filename)
+ "Return non-nil if FILENAME is to be kept, according to `recentf-keep'.
+FILENAME is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (recentf-keep-p filename)))
+
+(defun icicle-file-elc-p (file)
+ "Return non-nil if FILE has extension `elc'.
+Usually this means that FILE is an Emacs-Lisp byte-compiled file.
+FILE is normally a string, but it can also be a cons whose car is a
+string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp file) (setq file (car file)))
+ (equal "elc" (file-name-extension file)))
+
+(defun icicle-file-executable-p (file-or-dir)
+ "Return non-nil if FILE-OR-DIR can be executed by you.
+For a directory, this means you can access files in that directory.
+\(It is generally better to use `file-accessible-directory-p' for that
+purpose, however.)
+
+FILE-OR-DIR is normally a string, but it can also be a cons whose car
+is a string. This is so that the function can be used to filter
+absolute file-name completion candidates."
+ (when (consp file-or-dir) (setq file-or-dir (car file-or-dir)))
+ (file-executable-p file-or-dir))
+
+(defun icicle-file-exists-p (file)
+ "Return non-nil if FILE exists (whether or not you can read it).
+FILE is normally a string, but it can also be a cons whose car is a
+string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp file) (setq file (car file)))
+ (file-exists-p file))
+
+(defun icicle-file-locked-p (file)
+ "Return a value indicating whether FILE is locked.
+The value is nil if FILE is not locked, t if it is locked by you, else
+a string saying which user has locked it.
+
+FILE is normally a string, but it can also be a cons whose car is a
+string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp file) (setq file (car file)))
+ (file-locked-p file))
+
+(defun icicle-file-name-absolute-p (filename)
+ "Return non-nil if FILENAME specifies an absolute file or directory name.
+On Unix, this is a name starting with `/' or `~'.
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (file-name-absolute-p filename))
+
+;; NOTE: This is *not* a general substitute for `file-readable-p'.
+(defun icicle-file-readable-p (filename)
+ "Return non-nil if FILENAME names a readable file.
+Return nil if FILENAME is \"\" or it names a directory.
+
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (and (not (string= "" filename)) (file-readable-p filename) (not (file-directory-p filename))))
+
+(defun icicle-file-regular-p (filename)
+ "Return non-nil if FILENAME names a regular file.
+This is the sort of file that holds an ordinary stream of data bytes.
+Symbolic links to regular files count as regular files.
+See `file-symlink-p' to distinguish symlinks.
+
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (file-regular-p filename))
+
+
+;; NOTE: This is *not* a general substitute for `file-remote-p'.
+(defun icicle-file-remote-p (filename)
+ "Non-nil means FILENAME is likely to name a remote file or directory.
+For MS Windows, if `icicle-network-drive-means-remote-flag' is non-nil
+then this includes a file on a mapped network drive.
+
+Otherwise, use `file-remote-p' if defined, or return nil if not.
+
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (or (and (eq system-type 'windows-nt)
+ ;; $$$$ (save-match-data ; IS THIS NEEDED?
+ (let ((case-fold-search t)) (string-match "\\`\\([a-z]:\\)" filename))
+ (eq 0 (condition-case nil
+ (icicle-ms-windows-NET-USE (match-string 1 filename))
+ (error nil)))
+ icicle-network-drive-means-remote-flag)
+ (and (fboundp 'file-remote-p) (file-remote-p filename))
+ (and (stringp filename) (string-match "\\`/[^/]+:" filename) (match-string 0 filename))))
+
+(defun icicle-file-symlink-p (filename)
+ "Return non-nil if FILENAME is the name of a symbolic link.
+The value is the link target, as a string. Otherwise it returns nil.
+This function does not check whether the link target exists.
+
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (file-symlink-p filename))
+
+;; NOTE: This is *not* a general substitute for `file-writable-p'.
+(defun icicle-file-writable-p (filename)
+ "Return non-nil if FILENAME names a writable file.
+Return nil if FILENAME is \"\" or it names a directory.
+FILENAME is normally a string, but it can also be a cons whose car is
+a string. This is so that the function can be used to filter absolute
+file-name completion candidates."
+ (when (consp filename) (setq filename (car filename)))
+ (and (not (string= "" filename)) (file-writable-p filename) (not (file-directory-p filename))))
+
+(defun icicle-image-file-p (filename)
+ "Return non-nil if FILENAME names an image file.
+The regexp value of `image-file-name-regexp' is used for the test.
+Returns nil if library `image-file.el' cannot be loaded, so use this
+only for Emacs 23 and later."
+ (when (consp filename) (setq filename (car filename)))
+ (and (if (fboundp 'display-graphic-p) (display-graphic-p) window-system)
+ (fboundp 'image-file-name-regexp)
+ (require 'image-file nil t)
+ (icicle-string-match-p (image-file-name-regexp) filename)))
+
+;;(@* "Frame-Completion Predicates")
+;; ** Frame-Completion Predicates **
+
+(defun icicle-frame-splittable-p (&optional frame)
+ "Return non-nil if FRAME can be split.
+This means that frame parameter `unsplittable' is absent or nil.
+FRAME can be a frame or a cons (FNAME . FR), as for an element in
+the return value of `icicle-make-frame-alist', in which case it is
+frame FR that is tested."
+ (when (consp frame) (setq frame (cdr frame)))
+ (not (icicle-frame-unsplittable-p frame)))
+
+(defun icicle-frame-unsplittable-p (&optional frame)
+ "Return non-nil if FRAME cannot be split.
+This means that frame parameter `unsplittable' is non-nil.
+FRAME can be a frame or a cons (FNAME . FR), as for an element in
+the return value of `icicle-make-frame-alist', in which case it is
+frame FR that is tested."
+ (when (consp frame) (setq frame (cdr frame)))
+ (cdr (assq 'unsplittable (frame-parameters frame))))
+
+(defun icicle-frame-invisible-p (frame)
+ "Return non-nil if FRAME can is currently invisible.
+This means that FRAME is live and `frame-visible-p' returns nil.
+FRAME can be a frame or a cons (FNAME . FR), as for an element in
+the return value of `icicle-make-frame-alist', in which case it is
+frame FR that is tested."
+ (when (consp frame) (setq frame (cdr frame)))
+ (not (frame-visible-p frame)))
+
+
+(when (fboundp 'frcmds-frame-iconified-p)
+ (defun icicle-frame-iconified-p (frame)
+ "Return non-nil if FRAME is iconified.
+This means that FRAME is live and `frame-visible-p' returns `icon'.
+FRAME can be a frame or a cons (FNAME . FR), as for an element in
+the return value of `icicle-make-frame-alist', in which case it is
+frame FR that is tested."
+ (when (consp frame) (setq frame (cdr frame)))
+ (frcmds-frame-iconified-p frame)))
+
+(when (fboundp 'thumfr-thumbnail-frame-p) ; In `thumb-frm.el'
+ (defun icicle-frame-thumbnail-p (&optional frame)
+ "Return non-nil if FRAME is a thumbnail frame.
+This means that frame parameter `thumfr-thumbnail-frame' is non-nil.
+FRAME can be a frame or a cons (FNAME . FR), as for an element in
+the return value of `icicle-make-frame-alist', in which case it is
+frame FR that is tested."
+ (when (consp frame) (setq frame (cdr frame)))
+ (thumfr-thumbnail-frame-p frame)))
+
+;;(@* "Package-Completion Predicates")
+;; ** Package-Completion Predicates **
+
+(when (require 'package nil t) ; Emacs 24+
+ (defun icicle-package-built-in-p (package &optional min-version)
+ "Same as `package-built-in-p', but PACKAGE can be a string or a cons.
+PACKAGE is normally a symbol, but it can also be a string that names a
+package or a cons whose car is such a string. This is so that the
+function can be used to filter completion candidates."
+ (when (consp package) (setq package (car package)))
+ (when (stringp package) (setq package (intern package)))
+ (package-built-in-p package min-version))
+
+ (defun icicle-package-disabled-p (package &optional version)
+ "Same as `package-disabled-p', but PACKAGE can be a string or a cons.
+PACKAGE is normally a symbol, but it can also be a string that names a
+package or a cons whose car is such a string. This is so that the
+function can be used to filter completion candidates."
+ (when (consp package) (setq package (car package)))
+ (when (stringp package) (setq package (intern package)))
+ (package-disabled-p package version))
+
+ (defun icicle-package-installed-p (package &optional min-version)
+ "Same as `package-installed-p', but PACKAGE can be a string or a cons.
+PACKAGE is normally a symbol, but it can also be a string that names a
+package or a cons whose car is such a string. This is so that the
+function can be used to filter completion candidates."
+ (when (consp package) (setq package (car package)))
+ (when (stringp package) (setq package (intern package)))
+ (package-installed-p package min-version)))
+
+;;(@* "Special Candidate-Completion Predicates")
+;; ** Special Candidate-Completion Predicates **
+
+(defun icicle-special-candidate-p (candidate)
+ "Return non-nil if CANDIDATE is a special candidate.
+The meaning of \"special candidate\" depends on the context.
+For example, during key completion local key bindings are special
+candidates.
+
+Special candidates are highlighted in buffer `*Completions*' using
+face `icicle-special-candidate'."
+ (when (consp candidate) (setq candidate (car candidate)))
+ (or (and (symbolp candidate) (get candidate 'icicle-special-candidate))
+ (and (stringp candidate)
+ (stringp icicle-special-candidate-regexp)
+ (icicle-string-match-p icicle-special-candidate-regexp candidate))
+ (and (stringp candidate)
+ (let ((fprop (get-text-property 0 'face candidate)))
+ (if (consp fprop)
+ (memq 'icicle-special-candidate fprop)
+ (eq 'icicle-special-candidate fprop))))))
+
+(defun icicle-not-special-candidate-p (candidate)
+ "Return non-nil if CANDIDATE is not a special candidate."
+ (not (icicle-special-candidate-p candidate)))
+
+;;(@* "Symbol-Completion Predicates")
+;; ** Symbol-Completion Predicates **
+
+;; Do not bother with `user-variable-p'. For Emacs > 22 it is the same as `custom-variable-p'.
+(defun icicle-custom-variable-p (variable)
+ "Return non-nil if VARIABLE is a customizable variable.
+A customizable variable is either (i) a variable whose property
+list contains a non-nil `standard-value' or `custom-autoload'
+property, or (ii) an alias for another customizable variable.
+
+If VARIABLE is a cons with a string car, then the car is used as the
+name of the face. This is so that the function can be used to filter
+completion candidates. The string can be a multi-completion
+whose first part is the variable name."
+ (when (consp variable) (setq variable (car variable)))
+ (when (and icicle-multi-completing-p (stringp variable))
+ (let ((icicle-list-use-nth-parts '(1)))
+ (setq variable (icicle-transform-multi-completion variable))))
+ (when (stringp variable) (setq variable (intern variable)))
+ (custom-variable-p variable))
+
+(defun icicle-binary-option-p (symbol)
+ "Return non-nil if SYMBOL is a user option with custom-type `boolean'.
+SYMBOL is normally a symbol, but it can also be a string that names a
+symbol or a cons whose car is such a string. This is so that the
+function can be used to filter completion candidates."
+ (when (consp symbol) (setq symbol (car symbol)))
+ (when (stringp symbol) (setq symbol (intern symbol)))
+ (eq (icicle-get-safe symbol 'custom-type) 'boolean))
+
+(when (fboundp 'special-variable-p) ; Emacs 24+
+ (defun icicle-special-variable-p (variable)
+ "Return non-nil if VARIABLE's global binding is special.
+A special variable is one that is bound dynamically, even in a context
+where binding is lexical by default.
+
+If VARIABLE is a cons with a string car, then the car is used as the
+name of the face. This is so that the function can be used to filter
+completion candidates."
+ (when (consp variable) (setq variable (car variable)))
+ (when (stringp variable) (setq variable (intern variable)))
+ (special-variable-p variable)))
+
+;;; Same as `thgcmd-defined-thing-p' in `thing-cmds.el', except this accepts also a cons or a string, so it
+;;; can be used as an element of `icicle-cand-preds-all', to filter completion candidates.
+(defun icicle-defined-thing-p (thing)
+ "Return non-nil if THING is defined as a thing-at-point type.
+THING is normally a symbol, but it can also be a string that names a
+symbol or a cons whose car is such a string. This is so that the
+function can be used to filter completion candidates."
+ (when (consp thing) (setq thing (car thing)))
+ (when (stringp thing) (setq thing (intern thing)))
+ (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))))
+
+;;(@* "Window-Completion Predicates")
+;; ** Window-Completion Predicates **
+
+(when (fboundp 'window-at-side-p) ; Emacs 24+
+ (defun icicle-window-at-bottom-p (window)
+ "Return non-nil if WINDOW is at the bottom of its frame.
+WINDOW can be a window or a cons (WNAME . WIN), as for an element in
+the return value of `icicle-make-window-alist', in which case it is
+window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-at-side-p window 'bottom))
+
+ (defun icicle-window-at-left-p (window)
+ "Return non-nil if WINDOW is at the left side of its frame.
+WINDOW can be a window or a cons (WNAME . WIN), as for an element in
+the return value of `icicle-make-window-alist', in which case it is
+window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-at-side-p window 'left))
+
+ (defun icicle-window-at-right-p (window)
+ "Return non-nil if WINDOW is at the right side of its frame.
+WINDOW can be a window or a cons (WNAME . WIN), as for an element in
+the return value of `icicle-make-window-alist', in which case it is
+window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-at-side-p window 'right))
+
+ (defun icicle-window-at-top-p (window)
+ "Return non-nil if WINDOW is at the top of its frame.
+WINDOW can be a window or a cons (WNAME . WIN), as for an element in
+the return value of `icicle-make-window-alist', in which case it is
+window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-at-side-p window 'top)))
+
+(when (fboundp 'window-deletable-p) ; Emacs 24+
+ (defun icicle-window-deletable-p (&optional window)
+ "Return non-nil if WINDOW can be safely deleted from its frame.
+Same as `window-deletable-p', but WINDOW can be a cons (WNAME . WIN).
+If it is such a cons, it is window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-deletable-p window)))
+
+(defun icicle-window-dedicated-p (&optional window)
+ "Same as `window-dedicated-p', but WINDOW can be a cons (WNAME . WIN).
+If it is such a cons, it is window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (window-dedicated-p window))
+
+(defun icicle-window-invisible-p (&optional window)
+ "Return non-nil if WINDOW is invisible, that is, on an invisible frame.
+WINDOW can be a window or a cons (WNAME . WIN), where WNAME is a name.
+If it is such a cons, it is window WIN that is tested."
+ (when (consp window) (setq window (cdr window)))
+ (not (frame-visible-p (window-frame window))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;