Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
7528 lines (6895 sloc) 401 KB
;;; icicles-mcmd.el --- Minibuffer commands for Icicles
;;
;; Filename: icicles-mcmd.el
;; Description: Minibuffer commands for Icicles
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1996-2012, Drew Adams, all rights reserved.
;; Created: Mon Feb 27 09:25:04 2006
;; Version: 22.0
;; Last-Updated: Fri Jan 20 17:32:19 2012 (-0800)
;; By: dradams
;; Update #: 17546
;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-mcmd.el
;; Keywords: internal, extensions, help, abbrev, local, minibuffer,
;; keys, apropos, completion, matching, regexp, command
;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
;;
;; Features that might be required by this library:
;;
;; `apropos', `apropos-fn+var', `backquote', `bytecomp', `cl',
;; `doremi', `el-swank-fuzzy', `ffap', `ffap-', `fuzzy',
;; `fuzzy-match', `hexrgb', `icicles-face', `icicles-fn',
;; `icicles-opt', `icicles-var', `image-dired', `kmacro',
;; `levenshtein', `mouse3', `mwheel', `naked', `pp', `pp+',
;; `regexp-opt', `ring', `ring+', `thingatpt', `thingatpt+',
;; `wid-edit', `wid-edit+', `widget'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This is a helper library for library `icicles.el'. It defines
;; commands to be used mainly in the minibuffer or buffer
;; `*Completions*' (and a few non-interactive functions used in those
;; commands). For top-level commands, see `icicles-cmd1.el' and
;; `icicles-cmd2.el'. For Icicles documentation, see
;; `icicles-doc1.el' and `icicles-doc2.el'.
;;
;; Commands defined here:
;;
;; `cycle-icicle-image-file-thumbnail',
;; `icicle-abort-recursive-edit', `icicle-add-file-to-fileset',
;; `icicle-add/update-saved-completion-set',
;; `icicle-all-candidates-action',
;; `icicle-all-candidates-alt-action',
;; `icicle-all-candidates-list-action',
;; `icicle-all-candidates-list-alt-action',
;; `icicle-apropos-complete', `icicle-apropos-complete-and-exit',
;; `icicle-apropos-complete-and-narrow',
;; `icicle-apropos-complete-and-widen',
;; `icicle-apropos-complete-no-display',
;; `icicle-backward-char-dots',
;; `icicle-backward-delete-char-untabify',
;; `icicle-backward-kill-paragraph',
;; `icicle-backward-kill-sentence', `icicle-backward-kill-sexp',
;; `icicle-backward-kill-word', `icicle-beginning-of-line+',
;; `icicle-candidate-action', `icicle-candidate-alt-action',
;; `icicle-candidate-read-fn-invoke',
;; `icicle-candidate-set-complement',
;; `icicle-candidate-set-define',
;; `icicle-candidate-set-difference',
;; `icicle-candidate-set-intersection',
;; `icicle-candidate-set-retrieve',
;; `icicle-candidate-set-retrieve-from-variable',
;; `icicle-candidate-set-retrieve-more',
;; `icicle-candidate-set-retrieve-persistent',
;; `icicle-candidate-set-save', `icicle-candidate-set-save-more',
;; `icicle-candidate-set-save-more-selected',
;; `icicle-candidate-set-save-persistently',
;; `icicle-candidate-set-save-selected',
;; `icicle-candidate-set-save-to-variable',
;; `icicle-candidate-set-swap', `icicle-candidate-set-truncate',
;; `icicle-candidate-set-union',
;; `icicle-change-alternative-sort-order',
;; `icicle-change-history-variable', `icicle-change-sort-order',
;; `icicle-choose-completion', `icicle-completing-read+insert',
;; `icicle-Completions-mouse-3-menu',
;; `icicle-cycle-image-file-thumbnail',
;; `icicle-cycle-incremental-completion',
;; `icicle-delete-backward-char', `icicle-delete-candidate-object',
;; `icicle-delete-char', `icicle-delete-windows-on',
;; `icicle-describe-file', `icicle-digit-argument',
;; `icicle-dispatch-C-^', `icicle-dispatch-C-.',
;; `icicle-dispatch-C-x.', `icicle-dispatch-M-_',
;; `icicle-dispatch-M-comma', `icicle-dispatch-M-q',
;; `icicle-doremi-candidate-width-factor+',
;; `icicle-doremi-increment-max-candidates+',
;; `icicle-doremi-increment-swank-prefix-length+',
;; `icicle-doremi-increment-swank-timeout+',
;; `icicle-doremi-inter-candidates-min-spaces+',
;; `icicle-doremi-zoom-Completions+', `icicle-end-of-line+',
;; `icicle-erase-minibuffer',
;; `icicle-erase-minibuffer-or-history-element',
;; `icicle-exit-minibuffer', `icicle-forward-char-dots',
;; `icicle-goto/kill-failed-input', `icicle-help-on-candidate',
;; `icicle-help-on-next-apropos-candidate',
;; `icicle-help-on-next-prefix-candidate',
;; `icicle-help-on-previous-apropos-candidate',
;; `icicle-help-on-previous-prefix-candidate',
;; `icicle-help-string-completion',
;; `icicle-help-string-non-completion', `icicle-history',
;; `icicle-insert-completion', `icicle-insert-dot-command',
;; `icicle-insert-history-element',
;; `icicle-insert-key-description',
;; `icicle-insert-list-join-string',
;; `icicle-insert-newline-in-minibuffer',
;; `icicle-insert-string-at-point',
;; `icicle-insert-string-from-variable', `icicle-isearch-complete',
;; `icicle-keep-only-past-inputs', `icicle-kill-line',
;; `icicle-kill-paragraph', `icicle-kill-region',
;; `icicle-kill-region-wimpy', `icicle-kill-sentence',
;; `icicle-kill-sexp', `icicle-kill-word', `icicle-make-directory',
;; `icicle-minibuffer-complete-and-exit', `icicle-minibuffer-help',
;; `icicle-mouse-candidate-action',
;; `icicle-mouse-candidate-alt-action',
;; `icicle-mouse-candidate-read-fn-invoke',
;; `icicle-mouse-candidate-set-save',
;; `icicle-mouse-candidate-set-save-more',
;; `icicle-mouse-choose-completion',
;; `icicle-mouse-help-on-candidate',
;; `icicle-mouse-remove-candidate',
;; `icicle-mouse-save/unsave-candidate',
;; `icicle-mouse-save-then-kill', `icicle-mouse-yank-secondary',
;; `icicle-move-to-next-completion',
;; `icicle-move-to-previous-completion',
;; `icicle-narrow-candidates',
;; `icicle-narrow-candidates-with-predicate',
;; `icicle-negative-argument', `icicle-next-apropos-candidate',
;; `icicle-next-apropos-candidate-action',
;; `icicle-next-apropos-candidate-alt-action',
;; `icicle-next-candidate-per-mode',
;; `icicle-next-candidate-per-mode-action',
;; `icicle-next-candidate-per-mode-alt-action',
;; `icicle-next-history-element', `icicle-next-line',
;; `icicle-next-prefix-candidate',
;; `icicle-next-prefix-candidate-action',
;; `icicle-next-prefix-candidate-alt-action',
;; `icicle-next-S-TAB-completion-method',
;; `icicle-next-TAB-completion-method', `icicle-other-history',
;; `icicle-plus-saved-sort',
;; `icicle-pp-eval-expression-in-minibuffer',
;; `icicle-prefix-complete', `icicle-prefix-complete-no-display',
;; `icicle-prefix-word-complete',
;; `icicle-previous-apropos-candidate',
;; `icicle-previous-apropos-candidate-action',
;; `icicle-previous-apropos-candidate-alt-action',
;; `icicle-previous-candidate-per-mode',
;; `icicle-previous-candidate-per-mode-action',
;; `icicle-previous-candidate-per-mode-alt-action',
;; `icicle-previous-line', `icicle-previous-prefix-candidate',
;; `icicle-previous-prefix-candidate-action',
;; `icicle-previous-prefix-candidate-alt-action',
;; `icicle-read+insert-file-name', `icicle-regexp-quote-input',
;; `icicle-remove-candidate', `icicle-remove-Completions-window',
;; `icicle-resolve-file-name', `icicle-retrieve-last-input',
;; `icicle-retrieve-next-input', `icicle-retrieve-previous-input',
;; `icicle-reverse-sort-order',
;; `icicle-save-predicate-to-variable',
;; `icicle-save/unsave-candidate',
;; `icicle-scroll-Completions-backward',
;; `icicle-scroll-Completions-forward', `icicle-scroll-backward',
;; `icicle-scroll-forward', `icicle-search-define-replacement',
;; `icicle-self-insert', `icicle-sit-for',
;; `icicle-sort-alphabetical', `icicle-sort-by-abbrev-frequency',
;; `icicle-sort-by-directories-first',
;; `icicle-sort-by-directories-last', `icicle-sort-by-file-type',
;; `icicle-sort-by-last-file-modification-time',
;; `icicle-sort-by-last-use-as-input',
;; `icicle-sort-by-previous-use-alphabetically',
;; `icicle-sort-by-2nd-parts-alphabetically',
;; `icicle-sort-case-insensitive',
;; `icicle-sort-extra-candidates-first',
;; `icicle-sort-proxy-candidates-first',
;; `icicle-sort-special-candidates-first',
;; `icicle-sort-turned-OFF', `icicle-switch-to-Completions-buf',
;; `icicle-switch-to-completions',
;; `icicle-switch-to/from-minibuffer', `icicle-toggle-.',
;; `icicle-toggle-~-for-home-dir',
;; `icicle-toggle-alternative-sorting',
;; `icicle-toggle-angle-brackets',
;; `icicle-toggle-case-sensitivity', `icicle-toggle-C-for-actions',
;; `icicle-toggle-dot', `icicle-toggle-expand-to-common-match',
;; `icicle-toggle-hiding-common-match',
;; `icicle-toggle-hiding-non-matching-lines',
;; `icicle-toggle-highlight-all-current',
;; `icicle-toggle-highlight-historical-candidates',
;; `icicle-toggle-highlight-saved-candidates',
;; `icicle-toggle-ignored-extensions',
;; `icicle-toggle-ignored-space-prefix',
;; `icicle-toggle-ignoring-comments',
;; `icicle-toggle-literal-replacement',
;; `icicle-toggle-proxy-candidates', `icicle-toggle-regexp-quote',
;; `icicle-toggle-remote-file-testing',
;; `icicle-toggle-search-cleanup',
;; `icicle-toggle-search-complementing-domain',
;; `icicle-toggle-search-replace-common-match',
;; `icicle-toggle-search-replace-whole',
;; `icicle-toggle-search-whole-word',
;; `icicle-toggle-show-multi-completion', `icicle-toggle-sorting',
;; `icicle-toggle-transforming',
;; `icicle-toggle-WYSIWYG-Completions', `icicle-transpose-chars',
;; `icicle-transpose-sexps', `icicle-transpose-words',
;; `icicle-universal-argument', `icicle-universal-argument-minus',
;; `icicle-universal-argument-more',
;; `icicle-universal-argument-other-key', `icicle-up-directory',
;; `icicle-use-interactive-command-history',
;; `icicle-widen-candidates', `icicle-yank', `icicle-yank-pop',
;; `icicle-yank-secondary', `old-choose-completion',
;; `old-exit-minibuffer', `old-minibuffer-complete-and-exit',
;; `old-sit-for', `old-switch-to-completions', `toggle-icicle-.',
;; `toggle-icicle-~-for-home-dir',
;; `toggle-icicle-alternative-sorting',
;; `toggle-icicle-angle-brackets',
;; `toggle-icicle-case-sensitivity', `toggle-icicle-C-for-actions',
;; `toggle-icicle-dot', `toggle-icicle-expand-to-common-match',
;; `toggle-icicle-hiding-common-match',
;; `toggle-icicle-hiding-non-matching-lines',
;; `toggle-icicle-highlight-all-current',
;; `toggle-icicle-highlight-historical-candidates',
;; `toggle-icicle-highlight-saved-candidates',
;; `toggle-icicle-ignored-extensions',
;; `toggle-icicle-ignored-space-prefix',
;; `toggle-icicle-incremental-completion',
;; `toggle-icicle-literal-replacement',
;; `toggle-icicle-proxy-candidates', `toggle-icicle-regexp-quote',
;; `toggle-icicle-remote-file-testing',
;; `toggle-icicle-search-cleanup',
;; `toggle-icicle-search-complementing-domain',
;; `toggle-icicle-search-replace-common-match',
;; `toggle-icicle-search-replace-whole',
;; `toggle-icicle-search-whole-word',
;; `toggle-icicle-show-multi-completion', `toggle-icicle-sorting',
;; `toggle-icicle-transforming',
;; `toggle-icicle-WYSIWYG-Completions'.
;;
;; Non-interactive functions defined here:
;;
;; `icicle-add/remove-tags-and-refresh',
;; `icicle-all-candidates-action-1', `icicle-all-exif-data',
;; `icicle-anychar-regexp', `icicle-apply-to-saved-candidate',
;; `icicle-apropos-complete-1', `icicle-apropos-complete-2',
;; `icicle-backward-delete-char-untabify-dots',
;; `icicle-bind-file-candidate-keys', `icicle-candidate-action-1',
;; `icicle-candidate-set-retrieve-1',
;; `icicle-candidate-set-save-1',
;; `icicle-candidate-set-save-selected-1',
;; `icicle-column-wise-cand-nb', `icicle-Completions-popup-choice',
;; `icicle-Completions-popup-choice-1', `icicle-convert-dots',
;; `icicle-current-completion-in-Completions',
;; `icicle-current-sort-functions', `icicle-current-sort-order',
;; `icicle-delete-backward-char-dots',
;; `icicle-delete-candidate-object-1', `icicle-delete-char-dots',
;; `icicle-delete-current-candidate-object',
;; `icicle-ensure-overriding-map-is-bound',
;; `icicle-help-on-candidate-symbol',
;; `icicle-input-is-a-completion-p', `icicle-insert-dot',
;; `icicle-insert-input', `icicle-insert-thing',
;; `icicle-looking-at-anychar-regexp-p',
;; `icicle-looking-back-at-anychar-regexp-p',
;; `icicle-markers-to-readable',
;; `icicle-maybe-multi-completion-completing-p',
;; `icicle-mouse-candidate-action-1', `icicle-nb-Completions-cols',
;; `icicle-nb-of-cand-at-Completions-pos',
;; `icicle-nb-of-cand-in-Completions-horiz',
;; `icicle-prefix-complete-1', `icicle-prefix-complete-2',
;; `icicle-raise-Completions-frame',
;; `icicle-remove-cand-from-lists',
;; `icicle-remove-candidate-display-others',
;; `icicle-replace-input-w-parent-dir',
;; `icicle-retrieve-candidates-from-set',
;; `icicle-row-wise-cand-nb', `icicle-signum',
;; `icicle-substitute-keymap-vars', `icicle-successive-action',
;; `icicle-transform-sole-candidate',
;; `icicle-transpose-chars-dots',
;; `icicle-unbind-file-candidate-keys',
;; `icicle-upcase-if-ignore-case', `icicle-update-and-next'.
;;
;; Internal variables defined here:
;;
;; `overriding-map-is-bound', `saved-overriding-map'.
;;
;;
;; ***** NOTE: These EMACS PRIMITIVES have been REDEFINED HERE:
;;
;; `exit-minibuffer' - Remove *Completion* window and
;; input mismatch highlighting
;; `minibuffer-complete-and-exit' - Use Icicles prefix completion
;;
;;
;; ***** NOTE: The following function defined in `mouse.el' has
;; been REDEFINED HERE:
;;
;; `choose-completion' - Don't iconify frame or bury buffer.
;; `mouse-choose-completion' - Return the number of the completion.
;;
;;
;; ***** NOTE: The following function defined in `simple.el' has
;; been REDEFINED HERE:
;;
;; `switch-to-completions' - Always selects `*Completions*' window.
;;
;;
;; Key bindings made by Icicles: See "Key Bindings" in
;; `icicles-doc2.el'.
;;
;; For descriptions of changes to this file, see `icicles-chg.el'.
;;(@> "Index")
;;
;; If you have library `linkd.el' and Emacs 22 or later, load
;; `linkd.el' and turn on `linkd-mode' now. It lets you easily
;; navigate around the sections of this doc. Linkd mode will
;; highlight this Index, as well as the cross-references and section
;; headings throughout this file. You can get `linkd.el' here:
;; http://dto.freeshell.org/notebook/Linkd.html.
;;
;; (@> "Redefined standard commands")
;; (@> "Icicles commands")
;; (@> "Minibuffer editing commands")
;; (@> "Commands to sort completion candidates")
;; (@> "Other commands to be used mainly in the minibuffer")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(eval-when-compile (require 'cl)) ;; case, flet, lexical-let, loop
;; plus, for Emacs < 21: dolist, push
(eval-when-compile (require 'filesets nil t)) ; Emacs 22+.
;; filesets-data, filesets-entry-get-files, filesets-entry-mode, filesets-entry-set-files,
;; filesets-files-equalp, filesets-init, filesets-member, filesets-set-config
(eval-when-compile
(or (condition-case nil
(load-library "icicles-mac") ; Use load-library to ensure latest .elc.
(error nil))
(require 'icicles-mac))) ; Require, so can load separately if not on `load-path'.
;; icicle-assoc-delete-all, icicle-define-sort-command
(require 'icicles-opt) ; (This is required anyway by `icicles-var.el'.)
;; icicle-alternative-sort-comparer, icicle-move-Completions-frame,
;; icicle-Completions-mouse-3-menu-entries, icicle-default-cycling-mode,
;; icicle-default-thing-insertion, icicle-expand-input-to-common-match-flag,
;; icicle-hide-common-match-in-Completions-flag, icicle-hide-non-matching-lines-flag,
;; icicle-ignore-space-prefix-flag, icicle-incremental-completion-flag, icicle-input-string,
;; icicle-key-descriptions-use-<>-flag, icicle-regexp-quote-flag, icicle-saved-completion-sets,
;; icicle-search-cleanup-flag, icicle-search-highlight-all-current-flag, icicle-sort-comparer,
;; icicle-sort-orders-alist, icicle-TAB-shows-candidates-flag, icicle-thing-at-point-functions,
;; icicle-transform-function
(eval-and-compile (require 'icicles-var)) ; (This is required anyway by `icicles-fn.el'.)
;; lacarte-menu-items-alist, icicle-candidate-action-fn, icicle-candidate-nb,
;; icicle-complete-keys-alist, icicle-completion-candidates,
;; icicle-current-completion-candidate-overlay, icicle-current-completion-mode,
;; icicle-current-input, icicle-current-raw-input, icicle-default-directory,
;; icicle-default-thing-insertion-flipped-p, icicle-edit-update-p, icicle-general-help-string,
;; icicle-get-alist-candidate-function, icicle-ignored-extensions, icicle-ignored-extensions-regexp,
;; icicle-incremental-completion-p, icicle-insert-string-at-pt-end, `icicle-insert-string-at-pt-start,
;; icicle-last-completion-candidate, icicle-last-completion-command, icicle-last-input,
;; icicle-last-sort-comparer, icicle-last-transform-function,
;; icicle-nb-of-other-cycle-candidates, icicle-pre-minibuffer-buffer,
;; icicle-saved-candidates-variables-obarray, icicle-saved-completion-candidates,
;; icicle-saved-ignored-extensions, icicle-successive-grab-count, icicle-thing-at-pt-fns-pointer,
;; icicle-universal-argument-map, icicle-variable-name-history
(require 'icicles-fn)
;; icicle-isearch-complete-past-string, icicle-minibuf-input-sans-dir,
;; icicle-toggle-icicle-mode-twice
(require 'pp+ nil t) ;; (no error if not found): pp-eval-expression
(require 'doremi nil t) ;; (no error if not found):
;; doremi, doremi(-boost)-(up|down)-keys, doremi-limit, doremi-wrap
(when (> emacs-major-version 22) (require 'help-fns+ nil t)) ;; (no error if not found):
;; help-commands-to-key-buttons
(eval-when-compile (require 'fit-frame nil t)) ;; (no error if not found): fit-frame
(eval-when-compile
(when (> emacs-major-version 21) (require 'linkd nil t))) ;; (no error if not found): linkd-mode
;; Byte-compiling this file, you will likely get some byte-compiler warning messages.
;; These are probably benign - ignore them. Icicles is designed to work with multiple
;; versions of Emacs, and that fact provokes compiler warnings. If you get byte-compiler
;; errors (not warnings), then please report a bug, using `M-x icicle-send-bug-report'.
;; Some defvars to quiet byte-compiler a bit:
(when (< emacs-major-version 22)
(defvar overriding-map-is-bound)
(defvar read-file-name-completion-ignore-case) ; In `minibuffer.el'
(defvar read-file-name-predicate)
(defvar saved-overriding-map))
(when (< emacs-major-version 23)
(defvar read-buffer-completion-ignore-case)
(defvar mouse-drag-copy-region))
(defvar doremi-boost-down-keys) ; In `doremi.el'
(defvar doremi-boost-up-keys) ; In `doremi.el'
(defvar doremi-down-keys) ; In `doremi.el'
(defvar doremi-up-keys) ; In `doremi.el'
(defvar filesets-data) ; In `filesets.el'.
(defvar icicle-ido-like-mode) ; In `icicles-cmd2.el' (implicit)
(defvar ignore-comments-flag) ; In `thing-cmds.el'.
(defvar minibuffer-confirm-exit-commands) ; In `minibuffer.el' in Emacs 23+.
(defvar minibuffer-local-filename-completion-map) ; In Emacs 22+.
(defvar minibuffer-local-filename-must-match-map) ; In Emacs 23.2 (but not Emacs 24+).
(defvar minibuffer-local-must-match-filename-map) ; In Emacs 22+.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;(@* "Redefined standard commands")
;;; Redefined standard commands --------------------------------------
;; REPLACE ORIGINAL `next-history-element' in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Selects minibuffer contents and leaves point at its beginning.
;;
(unless (fboundp 'old-next-history-element)
(defalias 'old-next-history-element (symbol-function 'next-history-element)))
;;;###autoload
(defun icicle-next-history-element (arg) ; Bound to `M-n' in minibuffer.
"Insert the next element of the minibuffer history in the minibuffer.
With argument N, it uses the Nth following element."
(interactive "p")
(old-next-history-element (prefix-numeric-value arg))
(when (and icicle-mode (memq icicle-default-value '(preselect-start preselect-end)))
(icicle-select-minibuffer-contents)
(setq deactivate-mark nil)))
;; REPLACE ORIGINAL `exit-minibuffer' (built-in function),
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Remove input mismatch highlighting.
;; Remove *Completion* window.
;;
(unless (fboundp 'old-exit-minibuffer)
(defalias 'old-exit-minibuffer (symbol-function 'exit-minibuffer)))
;;;###autoload
(defun icicle-exit-minibuffer () ; Bound to `C-m' (`RET') in minibuffer.
"Terminate this minibuffer argument.
Remove `*Completions*' window. Remove Icicles minibuffer faces."
;; This removal lets users retrieve candidates that have other faces, and saves input-history space.
(interactive)
(when (active-minibuffer-window)
(with-current-buffer (window-buffer (minibuffer-window))
(let ((pos (icicle-minibuffer-prompt-end))
(icy-minibuf-faces '(icicle-input-completion-fail icicle-input-completion-fail-lax
icicle-whitespace-highlight icicle-match-highlight-minibuffer
icicle-complete-input))
(keep-faces ()))
(while (< pos (point-max))
(let ((faces (get-text-property pos 'face)))
(when (or (and (consp faces) (cdr faces) (atom (cdr faces))) ; (background-color . "abc")
(and faces (atom faces))) ; face name
(setq faces (list faces))) ; No-op: (foo (background-color . "abc") (:foreground "abc"))
(setq keep-faces (icicle-set-union keep-faces
(icicle-set-difference faces icy-minibuf-faces))))
(setq pos (1+ pos)))
(when keep-faces ; Don't add a nil `face' property.
(put-text-property (icicle-minibuffer-prompt-end) (point-max) 'face keep-faces)))
;; $$$$$ (let ((pos (icicle-minibuffer-prompt-end)))
;; (while (< pos (point-max))
;; (when (memq (get-text-property pos 'face)
;; '(icicle-input-completion-fail icicle-input-completion-fail-lax))
;; (remove-text-properties pos (point-max) '(face))
;; (setq pos (point-max)))
;; (setq pos (1+ pos))))
))
(icicle-remove-Completions-window)
(old-exit-minibuffer))
;; REPLACE ORIGINAL `minibuffer-complete-and-exit' (built-in function),
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Use Icicles completion.
;;
(unless (fboundp 'old-minibuffer-complete-and-exit)
(defalias 'old-minibuffer-complete-and-exit (symbol-function 'minibuffer-complete-and-exit)))
;; Bound to `C-m' (`RET') in must-match minibuffer completion maps.
;;;###autoload
(defun icicle-minibuffer-complete-and-exit ()
"If the minibuffer contents is a valid completion, then exit.
Otherwise try to complete it."
(interactive)
(let ((last-cmd last-command))
(cond ((string= "" (if (icicle-file-name-input-p) ; Empty input - exit.
(icicle-minibuf-input-sans-dir)
(icicle-input-from-minibuffer)))
(icicle-exit-minibuffer))
;; This case serves when property `icicle-display-string' is used.
;; What's returned is the replacement display string, not the original candidate.
;; If you want to get the original candidate back, you'll need to search the obarray for a
;; symbol that has this `icicle-display-string' value. Or put the symbol on the display
;; string as a text property.
((icicle-input-is-a-completion-p) (icicle-exit-minibuffer))
((eq minibuffer-completion-confirm 'confirm) ; User wants it anyway? - Emacs 23+.
(if (eq last-cmd this-command)
(icicle-exit-minibuffer)
(minibuffer-message "Confirm")
nil))
((eq minibuffer-completion-confirm 'confirm-after-completion) ; Emacs 23+.
;; Similar to `confirm', but only if trying to exit immediately
;; after completing (this catches most minibuffer typos).
(if (not (memq last-cmd (and (boundp 'minibuffer-confirm-exit-commands)
(append icicle-confirm-exit-commands
minibuffer-confirm-exit-commands))))
(icicle-exit-minibuffer)
(minibuffer-message "Confirm")
nil))
(t
(setq icicle-current-input (icicle-input-from-minibuffer))
(let* (;; Bind these first two to suppress (a) the throw or (b) the message, highlighting,
;; mode-line help, and the wait involved in completing again.
(icicle-prefix-complete-and-exit-p t)
(icicle-apropos-complete-and-exit-p t)
(candidates
;; If we're not using `icicle-candidates-alist', complete the input again.
;; If we're using `icicle-candidates-alist', try filtering it against just the
;; input.
;; If the input is already complete, then we're done. If not, then filtering
;; will give nil and we will just continue to display the candidates. If there
;; are multiple matches, then the user can either cycle or complete again.
(if (not icicle-candidates-alist)
(if (eq icicle-current-completion-mode 'apropos)
(icicle-apropos-complete-no-display 'nomsg)
(icicle-prefix-complete-no-display 'nomsg))
(icicle-filter-alist icicle-candidates-alist (list icicle-current-input)))))
(cond ((and (eq icicle-require-match-p t) ; Don't exit if non-nil and non-t.
(icicle-input-is-a-completion-p))
(icicle-exit-minibuffer))
(t
(icicle-display-candidates-in-Completions))))))))
;;; $$$$$$ Should probably rename it. It's no longer necessarily about apropos completion.
;;;###autoload
(defun icicle-apropos-complete-and-exit () ; Bound to `S-return' in minibuffer completion maps.
"If minibuffer content is a valid completion or has a single match, exit.
If the content is not complete, try to complete it. If completion
leads to a valid completion, then exit.
This differs from `icicle-minibuffer-complete-and-exit' (bound to
`RET' in must-match minibuffer maps) in these ways:
* If there is only one completion, this completes the input, rather
than accepting it uncompleted.
* This does not bother with the various special cases: empty input or
non-nil `minibuffer-completion-confirm' values."
(interactive)
(setq icicle-current-input (icicle-input-from-minibuffer))
(let* (;; Bind these first two to suppress (a) the throw or (b) the message, highlighting,
;; mode-line help, and the wait involved in completing again.
(icicle-expand-input-to-common-match-flag t)
(icicle-prefix-complete-and-exit-p t)
(icicle-apropos-complete-and-exit-p t)
(candidates
;; If we're not using `icicle-candidates-alist', complete the input again.
;; If we're using `icicle-candidates-alist', try filtering it against just the
;; input.
;; If the input is already complete, then we're done. If not, then filtering
;; will give nil and we will just continue to display the candidates. If there
;; are multiple matches, then the user can either cycle or complete again.
(if (not icicle-candidates-alist)
(if (eq icicle-current-completion-mode 'apropos)
(icicle-apropos-complete-no-display 'nomsg)
(icicle-prefix-complete-no-display 'nomsg))
(icicle-filter-alist icicle-candidates-alist (list icicle-current-input)))))
(when (and candidates (null (cdr candidates))) (old-exit-minibuffer)))) ; Single candidate.
;; REPLACE ORIGINAL `choose-completion' in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Don't iconify frame or bury buffer.
;; Don't strip text properties.
;;
(unless (fboundp 'old-choose-completion)
(defalias 'old-choose-completion (symbol-function 'choose-completion)))
;;;###autoload
(defun icicle-choose-completion ()
"Choose the completion that point is in or next to."
(interactive)
(let ((buffer completion-reference-buffer)
(base-size completion-base-size)
beg end completion)
(when (and (not (eobp)) (get-text-property (point) 'mouse-face))
(setq end (point)
beg (1+ (point))))
(when (and (>= (point) (icicle-start-of-candidates-in-Completions))
(get-text-property (1- (point)) 'mouse-face))
(setq end (1- (point))
beg (point)))
(unless beg (error "No completion here"))
(setq beg (previous-single-property-change beg 'mouse-face)
end (or (next-single-property-change end 'mouse-face) (point-max))
;; $$$$ completion (buffer-substring-no-properties beg end))
completion (buffer-substring beg end))
;; (let ((owindow (selected-window)))
;; (if (and (one-window-p t 'selected-frame) (window-dedicated-p (selected-window)))
;; (iconify-frame (selected-frame)) ; Iconify special buffer's frame
;; (or (window-dedicated-p (selected-window)) (bury-buffer)))
;; (select-window owindow))
(unless (or (not (member completion icicle-extra-candidates))
icicle-extra-candidates-dir-insert-p)
(setq base-size 0))
(choose-completion-string completion buffer base-size)))
;; REPLACE ORIGINAL `mouse-choose-completion' in `mouse.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Return the number of the completion.
;; Don't strip text properties.
;;
(when (and (fboundp 'mouse-choose-completion) (not (fboundp 'old-mouse-choose-completion)))
(defalias 'old-mouse-choose-completion (symbol-function 'mouse-choose-completion)))
;;;###autoload
(defun icicle-mouse-choose-completion (event) ; Bound to `mouse-2' in `*Completions*'.
"Click a completion candidate in buffer `*Completions*', to choose it.
Return the number of the candidate: 0 for first, 1 for second, ..."
(interactive "e")
;; $$$$$ (unless (active-minibuffer-window) (error "Minibuffer is not active"))
;; Give temporary modes such as isearch a chance to turn off.
(run-hooks 'mouse-leave-buffer-hook)
(let ((buffer (window-buffer))
;; $$$$$$ (icicle-orig-buff buffer)
choice base-size)
(with-current-buffer (window-buffer (posn-window (event-start event)))
(save-excursion
(when completion-reference-buffer (setq buffer completion-reference-buffer))
(setq base-size completion-base-size)
(save-excursion
(goto-char (posn-point (event-start event)))
(let (beg end)
(when (and (not (eobp)) (get-text-property (point) 'mouse-face))
(setq end (point)
beg (1+ (point))))
(unless beg (error "No completion here"))
(setq beg (previous-single-property-change beg 'mouse-face)
end (or (next-single-property-change end 'mouse-face) (point-max)))
;; $$$$$$ (setq choice (buffer-substring-no-properties beg end)))))
(setq choice (buffer-substring beg end))))))
;; $$$$$ (if (eq icicle-orig-buff (get-buffer "*Completions*"))
;; (icicle-remove-Completions-window)
;; (save-selected-window (icicle-remove-Completions-window)))
(setq icicle-candidate-nb (icicle-nb-of-cand-at-Completions-pos (posn-point (event-start event))))
(when (and (icicle-file-name-input-p) insert-default-directory
(or (not (member choice icicle-extra-candidates))
icicle-extra-candidates-dir-insert-p))
(let ((dir (icicle-file-name-directory-w-default icicle-current-input)))
(with-current-buffer buffer
(icicle-clear-minibuffer)
(insert dir)
(setq choice (concat dir choice)
base-size 0))))
(choose-completion-string choice buffer base-size))
icicle-candidate-nb)
(defun icicle-nb-of-cand-at-Completions-pos (position)
"Return number of candidate at POSITION in `*Completions*'.
POSITION is a buffer position."
(let ((hor-nb (icicle-nb-of-cand-in-Completions-horiz position)))
(save-excursion
(with-current-buffer (get-buffer "*Completions*")
(goto-char position)
(if (memq icicle-completions-format '(horizontal nil))
hor-nb
(let* ((cols (icicle-nb-Completions-cols))
(nb-cands (length icicle-completion-candidates))
(rows (/ nb-cands cols)))
(unless (zerop (% nb-cands cols)) (setq rows (1+ rows)))
(icicle-column-wise-cand-nb hor-nb nb-cands rows cols)))))))
(defun icicle-nb-of-cand-in-Completions-horiz (position)
"Return number of horizontal candidate at POSITION in `*Completions*'.
POSITION is a buffer position."
(let ((compl-buf (get-buffer "*Completions*")))
(unless compl-buf (error "No `*Completions*' buffer"))
(save-window-excursion
(set-buffer compl-buf)
(goto-char position)
;; If in a completion, move to its start, and set POSITION there.
(let ((prop (get-text-property (1- (point)) 'mouse-face)))
(when (and prop (eq prop (get-text-property (point) 'mouse-face)))
(goto-char (previous-single-property-change (point) 'mouse-face nil
(icicle-start-of-candidates-in-Completions)))))
(setq position (point))
;; Binary search.
(let ((cand-nb (/ (length icicle-completion-candidates) 2))
(last-nb 0)
(icicle-completions-format 'horizontal)
delta)
(goto-char (point-min))
(icicle-move-to-next-completion cand-nb t)
(while (/= (point) position)
(setq delta (max 1 (/ (abs (- cand-nb last-nb)) 2))
last-nb cand-nb)
(cond ((< (point) position)
(icicle-move-to-next-completion delta t)
(setq cand-nb (+ cand-nb delta)))
(t
(icicle-move-to-next-completion (- delta) t)
(setq cand-nb (- cand-nb delta)))))
(set-buffer-modified-p nil)
(1- cand-nb)))))
(defun icicle-nb-Completions-cols ()
"Return the number of candidate columns in `*Completions*'."
(let* ((start (icicle-start-of-candidates-in-Completions))
(eol (save-excursion (goto-char start) (line-end-position)))
(mouse-chgs 0)
mousef)
(save-excursion
(goto-char start)
(while (< (point) eol)
(setq mousef (next-single-property-change (point) 'mouse-face nil eol))
(when mousef
(goto-char mousef)
(setq mouse-chgs (1+ mouse-chgs)))))
;; Handle the case where the `while' loop is skipped so `mouse-chgs' is still 0.
(max 1 (/ (1+ mouse-chgs) 2)))) ; Return # of columns.
(defun icicle-column-wise-cand-nb (horiz-nb nb-cands rows cols)
"Column-wise number of horizontal candidate number HORIZ-NB."
(let ((row-lim (- rows (- (* rows cols) nb-cands)))
(row (/ horiz-nb cols))
(col (mod horiz-nb cols))
nb)
(setq nb (+ row (* col rows)))
(when (>= row row-lim)
(setq cols (1- cols)
horiz-nb (- horiz-nb row-lim)
row (/ horiz-nb cols)
col (mod horiz-nb cols)
nb (+ row (* col rows))))
nb))
(defun icicle-row-wise-cand-nb (vert-nb nb-cands rows cols)
"Row-wise number of vertical candidate number VERT-NB."
(let* ((row (mod vert-nb rows))
(col (/ vert-nb rows))
(nb (+ col (* row cols)))
(lim (- rows (- (* rows cols) nb-cands))))
(when (> row lim) (setq nb (- nb (- row lim))))
nb))
;; REPLACE ORIGINAL `switch-to-completions' defined in `simple.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Selects `*Completions*' window even if on another frame.
;;
(unless (fboundp 'old-switch-to-completions)
(defalias 'old-switch-to-completions (symbol-function 'switch-to-completions)))
;;;###autoload
(defun icicle-switch-to-completions ()
"Select the completion list window, `*Completions*'."
(interactive)
;; Make sure we have a completions window.
(or (get-buffer-window "*Completions*") (minibuffer-completion-help))
(let ((window (get-buffer-window "*Completions*" 0))) ; Added 0 arg.
(when window
(select-window window)
(goto-char (icicle-start-of-candidates-in-Completions)))))
;; The branch that deletes a history element is based on Juri Linkov's
;; `delete-history-element', proposed for Emacs 22 but rejected by RMS.
;;;###autoload
(defun icicle-erase-minibuffer-or-history-element () ; Bound to `M-k' in minibuffer.
"`icicle-erase-minibuffer' or, if using history, delete history element."
(interactive)
(if (not (memq last-command '(previous-history-element next-history-element
icicle-erase-minibuffer-or-history-element
previous-matching-history-element next-matching-history-element)))
(icicle-erase-minibuffer)
(let* ((curr-pos (1- minibuffer-history-position))
(current (nth curr-pos (and (boundp minibuffer-history-variable)
(symbol-value minibuffer-history-variable)))))
(cond ((= minibuffer-history-position 1)
(set minibuffer-history-variable (and (boundp minibuffer-history-variable)
(cdr (symbol-value minibuffer-history-variable)))))
((> minibuffer-history-position 1)
(setcdr (nthcdr (- minibuffer-history-position 2)
(and (boundp minibuffer-history-variable)
(symbol-value minibuffer-history-variable)))
(nthcdr minibuffer-history-position
(and (boundp minibuffer-history-variable)
(symbol-value minibuffer-history-variable))))))
(condition-case nil
(cond ((memq last-command '(next-history-element next-matching-history-element))
(next-history-element 1)
(setq this-command 'next-history-element))
((memq last-command '(previous-history-element previous-matching-history-element))
(next-history-element 1)
(previous-history-element 1)
(setq this-command 'previous-history-element)))
(error (icicle-condition-case-no-debug nil
(cond ((memq last-command '(next-history-element next-matching-history-element))
(previous-history-element 1)
(setq this-command 'previous-history-element))
((memq last-command
'(previous-history-element previous-matching-history-element))
(next-history-element 1)
(setq this-command 'next-history-element)))
(error nil))))
(when (and current (wholenump curr-pos))
(icicle-msg-maybe-in-minibuffer "Deleted `%s'"
(icicle-propertize current 'face 'icicle-msg-emphasis))))))
;;(@* "Icicles commands")
;;; Icicles commands -------------------------------------------------
;;(@* "Minibuffer editing commands")
;;; Minibuffer editing commands . . . . . . . . . . . . . . . . . . .
;;;
;;; All except `icicle-erase-minibuffer' are bound in the minibuffer to whatever the same
;;; command without `icicle-' is bound to globally.
(defun icicle-looking-back-at-anychar-regexp-p ()
"Return non-nil if `icicle-anychar-regexp' immediately precedes point."
(let ((len (length icicle-anychar-regexp)))
(save-excursion (save-match-data
(search-backward icicle-anychar-regexp
(max (- (point) len) (icicle-minibuffer-prompt-end)) t)))))
(defun icicle-looking-at-anychar-regexp-p ()
"Return non-nil if `icicle-anychar-regexp' immediately succeeds point."
(let ((len (length icicle-anychar-regexp)))
(save-excursion (save-match-data
(search-forward icicle-anychar-regexp (min (+ (point) len) (point-max)) t)))))
;;;###autoload
(defun icicle-forward-char-dots (&optional n)
"Move forward N chars (backward if N is negative). Handles dots (`.')."
(interactive "p")
(let ((len (length icicle-anychar-regexp)))
(dotimes (i (abs n))
(or (save-match-data
(if (wholenump n)
(search-forward icicle-anychar-regexp (min (+ (point) len) (point-max)) t)
(search-backward icicle-anychar-regexp
(max (- (point) len) (icicle-minibuffer-prompt-end)) t)))
(forward-char (if (wholenump n) 1 -1))))))
;;;###autoload
(defun icicle-backward-char-dots (&optional n)
"Move backward N chars (forward if N is negative). Handles dots (`.')."
(interactive "p")
(icicle-forward-char-dots (- n)))
;; Make delete-selection mode recognize it, so region is deleted.
(put 'icicle-backward-delete-char-untabify 'delete-selection 'supersede)
;;;###autoload
(defun icicle-backward-delete-char-untabify (n &optional killflag)
"`backward-delete-char-untabify' + update `*Completions*' with matches.
Handles Icicles dots (`.')."
(interactive "*p\nP")
(icicle-call-then-update-Completions #'icicle-backward-delete-char-untabify-dots n killflag))
(defun icicle-backward-delete-char-untabify-dots (n killflag)
"`backward-delete-char-untabify', but also handle dots (`.')."
(let ((len (length icicle-anychar-regexp)))
(dotimes (i (abs n))
(if (icicle-looking-back-at-anychar-regexp-p)
(backward-delete-char-untabify len killflag)
(backward-delete-char-untabify 1 killflag)))))
;; Make delete-selection mode recognize it, so region is deleted.
(put 'icicle-delete-backward-char 'delete-selection 'supersede)
;;;###autoload
(defun icicle-delete-backward-char (n &optional killflag) ; Bound to `DEL' in minibuffer.
"`delete-backward-char' and update `*Completions*' with input matches.
Handles Icicles dots (`.')."
(interactive "*p\nP")
(icicle-call-then-update-Completions #'icicle-delete-backward-char-dots n killflag))
(defun icicle-delete-backward-char-dots (n killflag)
"`delete-backward-char', but also handle dots (`.')."
(let ((len (length icicle-anychar-regexp)))
(dotimes (i (abs n))
(if (icicle-looking-back-at-anychar-regexp-p)
(delete-char (- len) killflag)
(delete-char -1 killflag)))))
;; Make delete-selection mode recognize it, so region is deleted.
(put 'icicle-delete-char 'delete-selection 'supersede)
;;;###autoload
(defun icicle-delete-char (n &optional killflag) ; Bound to `C-d' in minibuffer.
"`delete-char' and update `*Completions*' with input matches.
Handles Icicles dots (`.')."
(interactive "*p\nP")
(icicle-call-then-update-Completions #'icicle-delete-char-dots n killflag))
(defun icicle-delete-char-dots (n killflag)
"`delete-char', but also handle dots (`.')."
(let ((len (length icicle-anychar-regexp)))
(dotimes (i (abs n))
(if (icicle-looking-at-anychar-regexp-p)
(delete-char len killflag)
(delete-char 1 killflag)))))
;;;###autoload
(defun icicle-backward-kill-word (arg) ; Bound to `M-DEL' (`M-backspace') in minibuffer.
"`backward-kill-word' and update `*Completions*' with input matches.
See description of `backward-kill-word'."
(interactive "p")
(icicle-call-then-update-Completions #'backward-kill-word arg))
;;;###autoload
(defun icicle-kill-word (arg) ; Bound to `M-d' in minibuffer.
"`kill-word' and update `*Completions*' with regexp input matches.
See description of `kill-word'."
(interactive "p")
(icicle-call-then-update-Completions #'kill-word arg))
;;;###autoload
(defun icicle-backward-kill-sexp (arg) ; Bound to `C-M-backspace' in minibuffer.
"`backward-kill-sexp' and update `*Completions*' with input matches.
See description of `backward-kill-sexp'."
(interactive "p")
(icicle-call-then-update-Completions #'backward-kill-sexp arg))
;;;###autoload
(defun icicle-kill-sexp (arg) ; Bound to `C-M-delete' and `C-M-k' in minibuffer.
"`kill-sexp' and update `*Completions*' with regexp input matches.
See description of `kill-sexp'."
(interactive "p")
(icicle-call-then-update-Completions #'kill-sexp arg))
;;;###autoload
(defun icicle-backward-kill-sentence (arg) ; Bound to `C-x DEL' in minibuffer.
"`backward-kill-sentence' and update `*Completions*' with input matches.
See description of `backward-kill-sentence'."
(interactive "p")
(icicle-call-then-update-Completions #'backward-kill-sentence arg))
;;;###autoload
(defun icicle-kill-sentence (arg)
"`kill-sentence' and update `*Completions*' with regexp input matches.
See description of `kill-sentence'."
(interactive "p")
(icicle-call-then-update-Completions #'kill-sentence arg))
;;;###autoload
(defun icicle-backward-kill-paragraph (arg) ; Bound to `C-backspace' in minibuffer, except for files.
"`backward-kill-paragraph' and update `*Completions*' with input matches.
See description of `backward-kill-paragraph'."
(interactive "p")
(icicle-call-then-update-Completions #'backward-kill-paragraph arg))
;;;###autoload
(defun icicle-kill-paragraph (arg) ; Bound to `C-delete' in minibuffer.
"`kill-paragraph' and update `*Completions*' with regexp input matches.
See description of `kill-paragraph'."
(interactive "p")
(icicle-call-then-update-Completions #'kill-paragraph arg))
;;;###autoload
(defun icicle-kill-line (arg) ; Bound to `C-k' and `deleteline' in minibuffer.
"`kill-line' and update `*Completions*' with regexp input matches.
See description of `kill-line'."
(interactive "P")
(icicle-call-then-update-Completions #'kill-line arg))
;;;###autoload
(defun icicle-kill-region (beg end) ; Bound to `C-w' in minibuffer.
;; Don't bother with Emacs 22 optional 3rd arg.
"`kill-region' and update `*Completions*' with regexp input matches.
See description of `kill-region'."
(interactive "r")
(icicle-call-then-update-Completions #'kill-region beg end))
(when (fboundp 'kill-region-wimpy)
(defun icicle-kill-region-wimpy (beg end) ; Bound to `C-w' in minibuffer.
"`kill-region-wimpy' and update `*Completions*' with input matches.
See description of `kill-region-wimpy'."
(interactive "r")
(icicle-call-then-update-Completions #'kill-region-wimpy beg end)))
;;;###autoload
(defun icicle-make-directory (dir)
"Create a directory."
(interactive
(let ((enable-recursive-minibuffers t))
(list (funcall (if (fboundp 'read-directory-name) #'read-directory-name #'read-file-name)
"Create directory: " default-directory default-directory))))
(setq dir (directory-file-name (expand-file-name dir)))
(while (file-exists-p dir)
(message "%s already exists" dir) (sit-for 1)
(let ((enable-recursive-minibuffers t))
(setq dir (funcall (if (fboundp 'read-directory-name) #'read-directory-name #'read-file-name)
"Create directory: " default-directory default-directory))))
;;(setq dir (directory-file-name (expand-file-name dir)))
(if (not (y-or-n-p (format "Really create %s? " (file-name-as-directory dir))))
(message "Directory creation canceled")
(make-directory dir 'PARENTS-TOO)
(unless (file-accessible-directory-p dir)
(error "Could not create %s" (file-name-as-directory dir)))
(message "Created %s" (file-name-as-directory dir))))
;;;###autoload
(defun icicle-up-directory () ; Bound to `C-backspace' in minibuffer, for file-name completion.
"Replace minibuffer input with parent directory, then upate `*Completions*'."
(interactive)
(icicle-call-then-update-Completions #'icicle-replace-input-w-parent-dir))
;;;###autoload
(defun icicle-replace-input-w-parent-dir ()
"Replace minibuffer input with the parent directory."
(interactive)
(goto-char (point-max))
(let ((directoryp (equal ?/ (char-before)))
(bob (icicle-minibuffer-prompt-end)))
(while (and (> (point) bob) (not (equal ?/ (char-before)))) (delete-char -1))
(when directoryp
(delete-char -1)
(while (and (> (point) bob) (not (equal ?/ (char-before)))) (delete-char -1)))))
;;; ;;;###autoload
;;; (defun icicle-kill-failed-input () ; Bound to `C-M-l' in minibuffer during completion.
;;; "Kill (delete) the part of the input that does not complete.
;;; Repeat to delete more."
;;; (interactive)
;;; (goto-char (1- (point-max)))
;;; (while (and (not (bobp))
;;; (memq (get-text-property (point) 'face)
;;; '(icicle-input-completion-fail icicle-input-completion-fail-lax)))
;;; (delete-char 1)
;;; (backward-char 1))
;;; (unless (eobp) (forward-char))
;;; (icicle-highlight-input-noncompletion))
;;;###autoload
(defun icicle-goto/kill-failed-input () ; Bound to `C-M-l' in minibuffer during completion.
"Go to start of input portion that does not complete. Repeat to kill.
Kill (delete) the part of the input that does not complete.
Repeat to delete more."
(interactive)
(if (eq last-command this-command)
(unless (eobp) (kill-line))
(when (and (overlayp icicle-input-completion-fail-overlay)
(overlay-start icicle-input-completion-fail-overlay))
(goto-char (overlay-start icicle-input-completion-fail-overlay)))))
;;;###autoload
(defun icicle-transpose-chars (arg) ; Bound to `C-t' in minibuffer.
"`transpose-chars' and update `*Completions*' with regexp input matches.
Handles Icicles dots (`.')."
(interactive "*P")
(icicle-call-then-update-Completions #'icicle-transpose-chars-dots arg))
(defun icicle-transpose-chars-dots (arg)
"`transpose-chars', but also handle dots (`.')."
(and (null arg) (eolp) (icicle-forward-char-dots -1))
(transpose-subr 'icicle-forward-char-dots (prefix-numeric-value arg)))
;;;###autoload
(defun icicle-transpose-words (arg) ; Bound to `M-t' in minibuffer.
"`transpose-words' and update `*Completions*' with regexp input matches.
See description of `transpose-words'."
(interactive "*p")
(icicle-call-then-update-Completions #'transpose-words arg))
;;;###autoload
(defun icicle-transpose-sexps (arg) ; Bound to `C-M-t' in minibuffer.
"`transpose-sexps' and update `*Completions*' with regexp input matches.
See description of `transpose-sexps'."
(interactive "*p")
(icicle-call-then-update-Completions #'transpose-sexps arg))
;;;###autoload
(defun icicle-yank (arg) ; Bound to `C-y' and `S-insert' in minibuffer.
"`yank' and update `*Completions*' with regexp input matches.
See description of `yank'."
(interactive "*P")
(icicle-call-then-update-Completions #'yank arg))
;;;###autoload
(defun icicle-yank-pop (arg) ; Bound to `M-y' and `M-insert' in minibuffer.
"`yank-pop' and update `*Completions*' with regexp input matches.
See description of `yank-pop'."
(interactive "*p")
(icicle-call-then-update-Completions #'yank-pop arg))
(when (fboundp 'yank-secondary) ; In `second-sel.el'.
(defun icicle-yank-secondary () ; Bound to `C-M-y' in minibuffer.
"Insert the secondary selection at point.
Move point to the end of the inserted text. Does not change mark."
(interactive "*")
(icicle-call-then-update-Completions #'yank-secondary))
;; Tell `delete-selection-mode' to replace active region by yanked secondary selection.
(put 'icicle-yank-secondary 'delete-selection 'yank))
;; Tell `delete-selection-mode' to replace active region by yanked secondary selection.
(put 'icicle-mouse-yank-secondary 'delete-selection 'yank)
;;;###autoload
(defun icicle-mouse-yank-secondary (event) ; Bound to `M-mouse-2' in minibuffer.
"Insert the secondary selection where you click.
Move point to the end of the inserted text.
If `mouse-yank-at-point' is non-nil, insert at point
regardless of where you click."
(interactive "*e")
(if (fboundp 'yank-secondary) ; In `mouse+.el'.
(icicle-call-then-update-Completions #'mouse-yank-secondary event current-prefix-arg)
(icicle-call-then-update-Completions #'mouse-yank-secondary event)))
;; Make delete-selection mode recognize self-insertion, so it replaces region text.
(put 'icicle-self-insert 'delete-selection t)
;;;###autoload
(defun icicle-self-insert (n) ;; Bound in minibuffer to stuff bound globally to `self-insert-command'.
"`self-insert' and update `*Completions*' with regexp input matches.
See description of `self-insert'."
(interactive "p")
(if executing-kbd-macro
(funcall #'self-insert-command n)
(icicle-call-then-update-Completions #'self-insert-command n)))
;;;###autoload
(defun icicle-insert-a-space ()
"Insert a space.
For convenience in the minibuffer - does the same thing as `C-q SPC'.
To use this, bind it to some key sequence in keymaps
`minibuffer-local-completion-map',
`minibuffer-local-filename-completion-map', and
`minibuffer-local-must-match-map'."
(interactive) (insert ?\ ))
;;;###autoload
(defun icicle-insert-dot-command (&optional arg) ; Bound to `.' in minibuffer during completion.
"Insert `icicle-dot-string': either `.' or `icicle-anychar-regexp'.
With a numeric prefix argument, insert the dot that many times.
With a plain prefix arg (`C-u'), insert the opposite kind of dot
\(once) from what is indicated by the current value of
`icicle-dot-string'."
(interactive "P")
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(if (consp arg)
(let ((opposite (if (string= icicle-dot-string-internal ".")
(icicle-anychar-regexp)
(let ((strg "."))
(add-text-properties
0 1 '(icicle-user-plain-dot t rear-nonsticky (icicle-user-plain-dot))
strg)
strg))))
(if executing-kbd-macro
(insert opposite)
(icicle-call-then-update-Completions (lambda () (insert opposite)))))
(setq arg (prefix-numeric-value arg))
(if executing-kbd-macro
(funcall #'icicle-insert-dot arg)
(icicle-call-then-update-Completions #'icicle-insert-dot arg))))
(defun icicle-insert-dot (n)
"Insert `icicle-dot-string' N times."
(dotimes (i n)
(if (not (string= icicle-dot-string-internal "."))
(insert (icicle-anychar-regexp))
(insert ".")
(add-text-properties (1- (point)) (point) '(icicle-user-plain-dot t rear-nonsticky t)))))
(defun icicle-anychar-regexp ()
"Return a regexp that matches any single character, including newline.
The value returned is like that of constant `icicle-anychar-regexp',
but the `display' string is unique for each call."
(let ((strg (copy-sequence "\\(.\\|[\n]\\)")))
(set-text-properties 0 (length strg)
(if icicle-dot-show-regexp-flag
'(face highlight rear-nonsticky t)
`(display ,(copy-sequence ".") face highlight rear-nonsticky t))
strg)
strg))
;;;###autoload
(defun icicle-erase-minibuffer () ; Bound to `M-S-backspace', `M-S-delete' in minibuffer.
"Delete all user input in the minibuffer, then update completions."
(interactive)
(icicle-call-then-update-Completions #'icicle-clear-minibuffer))
;;(@* "Commands to sort completion candidates")
;;; Commands to sort completion candidates . . . . . . . . . . . . . .
;; We don't bother to define a command for the sort functions `icicle-prefix-keys-first-p' and
;; `icicle-command-names-alphabetic-p'. They are bound in `icicle-complete-keys'.
;; The order here defines the reverse order of `icicle-sort-orders-alist'.
;; The first here is also the default sort order. Entries are traversed by `C-,' in
;; `icicle-sort-orders-alist' order.
;;;###autoload (autoload 'icicle-sort-alphabetical "icicles-mcmd.el")
(icicle-define-sort-command "alphabetical" ; `icicle-sort-alphabetical'
icicle-case-string-less-p
"Sort completion candidates alphabetically.
Ignore letter case if `completion-ignore-case' or `case-fold-search'
is non-nil.")
;;;###autoload (autoload 'icicle-sort-special-candidates-first "icicles-mcmd.el")
(icicle-define-sort-command "special candidates first" ; `icicle-sort-special-candidates-first'
icicle-special-candidates-first-p
"Sort completion candidates by putting special candidates first.
Otherwise, sorting is alphabetical. Ignore letter case if
`completion-ignore-case' or `case-fold-search' is non-nil.")
;;;###autoload (autoload 'icicle-sort-extra-candidates-first "icicles-mcmd.el")
(icicle-define-sort-command "extra candidates first" ; `icicle-sort-extra-candidates-first'
icicle-extra-candidates-first-p
"Sort completion candidates by putting extra candidates first.
Otherwise, sorting is alphabetical. Ignore letter case if
`completion-ignore-case' or `case-fold-search' is non-nil.
An extra candidate is one that is a member of
`icicle-extra-candidates'.")
;;;###autoload (autoload 'icicle-sort-proxy-candidates-first "icicles-mcmd.el")
(icicle-define-sort-command "proxy candidates first" ; `icicle-sort-proxy-candidates-first'
icicle-proxy-candidate-first-p
"Sort completion candidates by putting proxy candidates first.
Otherwise, sorting is alphabetical. Ignore letter case if
`completion-ignore-case' or `case-fold-search' is non-nil.")
;;;###autoload (autoload 'icicle-sort-case-insensitive "icicles-mcmd.el")
(icicle-define-sort-command "case insensitive" ; `icicle-sort-case-insensitive'
icicle-case-insensitive-string-less-p
"Sort completion candidates alphabetically, but case-insenstively.")
;;;###autoload (autoload 'icicle-sort-by-2nd-parts-alphabetically "icicles-mcmd.el")
(icicle-define-sort-command "by 2nd parts alphabetically" ; `icicle-sort-by-2nd-parts-alphabetically'
icicle-2nd-part-string-less-p
"Sort multi-completion candidates alphabetically by their second parts.
After that, sort alphabetically by the first parts. Ignore letter
case if `completion-ignore-case' or `case-fold-search' is non-nil.")
;;;###autoload (autoload 'icicle-sort-by-last-file-modification-time "icicles-mcmd.el")
(icicle-define-sort-command "by last file modification time"
icicle-last-modified-first-p ; `icicle-sort-by-last-file-modification-time'
"Sort file-name completion candidates in order of last modification.
If not doing file-name completion, then sort alphabetically.")
;;;###autoload (autoload 'icicle-sort-by-file-type "icicles-mcmd.el")
(icicle-define-sort-command "by file type" ; `icicle-sort-by-file-type'
icicle-file-type-less-p
"Sort file-name completion candidates by file type.
Directories sort first, alphabetically.
Then sort by file type (extension), alphabetically.
Sort names that have the same extension alphabetically.
If not doing file-name completion, sort candidates alphabetically.")
;;;###autoload (autoload 'icicle-sort-by-directories-first "icicles-mcmd.el")
(icicle-define-sort-command "by directories first" ; `icicle-sort-by-directories-first'
icicle-dirs-first-p
"Sort file-name completion candidates so that directories are first.
If not doing file-name completion, then sort alphabetically.")
;;;###autoload (autoload 'icicle-sort-by-directories-last "icicles-mcmd.el")
(icicle-define-sort-command "by directories last" ; `icicle-sort-by-directories-last'
icicle-dirs-last-p
"Sort file-name completion candidates so that directories are last.
If not doing file-name completion, then sort alphabetically.")
;;;###autoload (autoload 'icicle-sort-by-last-use-as-input "icicles-mcmd.el")
(icicle-define-sort-command "by last use as input" ; `icicle-sort-by-last-use-as-input'
icicle-most-recent-first-p
"Sort completion candidates in order of last use as minibuffer input.")
;;;###autoload (autoload 'icicle-sort-by-previous-use-alphabetically "icicles-mcmd.el")
(icicle-define-sort-command "by previous use alphabetically"
icicle-historical-alphabetic-p ; `icicle-sort-by-previous-use-alphabetically'
"Sort completion candidates by previous use and alphabetically.
Candidates matching previous inputs are available first. Candidates
are in two groups, each of which is sorted alphabetically separately:
those matching previous inputs, followed by those that have not yet
been used.")
;;;###autoload (autoload 'icicle-sort-by-abbrev-frequency "icicles-mcmd.el")
(icicle-define-sort-command "by abbrev frequency" ; `icicle-sort-by-abbrev-frequency'
icicle-command-abbrev-used-more-p
"Sort abbrev completion candidates by frequency of use
Otherwise, sort alphabetically. Ignore letter case if
`completion-ignore-case' or `case-fold-search' is non-nil.")
;;;###autoload (autoload 'icicle-sort-turned-OFF "icicles-mcmd.el")
(icicle-define-sort-command "turned OFF" nil ; `icicle-sort-turned-OFF'
"Do not sort completion candidates.")
;;;###autoload
(defun icicle-dispatch-M-_ () ; Bound to `M-_' in minibuffer.
"Do the right thing for `M-_'.
During Icicles search, call `icicle-toggle-search-replace-whole'.
Otherwise, call `icicle-toggle-ignored-space-prefix'.
Bound to `M-_' in the minibuffer."
(interactive)
(if icicle-searching-p
(icicle-toggle-search-replace-whole)
(call-interactively #'icicle-toggle-ignored-space-prefix)))
;;; No longer used.
;;; (defun icicle-dispatch-C-comma ()
;;; "Do the right thing for `C-,'.
;;; When candidate sorting is possible, call `icicle-change-sort-order'.
;;; When searching, call `icicle-toggle-search-replace-whole'.
;;; Otherwise, do nothing.
;;;
;;; Bound to `C-,' in the minibuffer."
;;; (interactive)
;;; (cond (icicle-searching-p (icicle-toggle-search-replace-whole))
;;; (icicle-inhibit-sort-p (message "Cannot sort candidates now"))
;;; (t (call-interactively #'icicle-change-sort-order))))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
;;;###autoload
(defalias 'toggle-icicle-ignoring-comments 'icicle-toggle-ignoring-comments)
;;;###autoload
(defun icicle-toggle-ignoring-comments () ; Bound to `C-M-;' in minibuffer.
"Toggle the value of option `icicle-ignore-comments-flag'.
If option `ignore-comments-flag' is defined (in library
`thing-cmds.el') then it too is toggled.
Bound to `C-M-;' in the minibuffer."
(interactive)
(setq icicle-ignore-comments-flag (not icicle-ignore-comments-flag))
(when (boundp 'ignore-comments-flag) (setq ignore-comments-flag (not ignore-comments-flag)))
(icicle-msg-maybe-in-minibuffer
"Ignoring comments is now %s" (icicle-propertize (if icicle-ignore-comments-flag "ON" "OFF")
'face 'icicle-msg-emphasis)))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
;;;###autoload
(defalias 'toggle-icicle-search-replace-common-match 'icicle-toggle-search-replace-common-match)
;;;###autoload
(defun icicle-toggle-search-replace-common-match () ; Bound to `M-;' in minibuffer.
"Toggle the value of `icicle-search-replace-common-match-flag'.
Note that that option has no effect if
`icicle-expand-input-to-common-match-flag' is nil.
Bound to `M-;' in the minibuffer."
(interactive)
(setq icicle-search-replace-common-match-flag (not icicle-search-replace-common-match-flag))
(icicle-msg-maybe-in-minibuffer
"Replacing expanded common match is now %s"
(icicle-propertize (if icicle-search-replace-common-match-flag "ON" "OFF")
'face 'icicle-msg-emphasis)))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
;;;###autoload
(defalias 'toggle-icicle-search-replace-whole 'icicle-toggle-search-replace-whole)
;;;###autoload
(defun icicle-toggle-search-replace-whole ()
"Toggle the value of `icicle-search-replace-whole-candidate-flag'.
Bound to `M-_' in the minibuffer when searching."
(interactive)
(setq icicle-search-replace-whole-candidate-flag (not icicle-search-replace-whole-candidate-flag))
(icicle-msg-maybe-in-minibuffer
"Replacing whole search context is now %s"
(icicle-propertize (if icicle-search-replace-whole-candidate-flag "ON" "OFF")
'face 'icicle-msg-emphasis)))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
;;;###autoload
(defalias 'toggle-icicle-dot 'icicle-toggle-dot)
;;;###autoload
(defalias 'toggle-icicle-. 'icicle-toggle-dot)
;;;###autoload
(defalias 'icicle-toggle-. 'icicle-toggle-dot)
;;;###autoload
(defun icicle-toggle-dot () ; Bound to `C-M-.' in minibuffer.
"Toggle `icicle-dot-string' between `.' and `icicle-anychar-regexp'.
Bound to `C-M-.' in the minibuffer."
(interactive)
(icicle-barf-if-outside-minibuffer)
(setq icicle-dot-string (if (string= icicle-dot-string ".") (icicle-anychar-regexp) "."))
(icicle-msg-maybe-in-minibuffer
(cond ((string= icicle-dot-string ".")
(icicle-convert-dots (equal icicle-current-input icicle-last-input) t)
(format "`%s' now matches any char %s newline"
(icicle-propertize "." 'face 'icicle-msg-emphasis)
(icicle-propertize "EXCEPT" 'face 'icicle-msg-emphasis)))
(t
(icicle-convert-dots (equal icicle-current-input icicle-last-input))
(format "`%s' now matches any char, including %s"
(icicle-propertize "." 'face 'icicle-msg-emphasis)
(icicle-propertize "NEWLINE" 'face 'icicle-msg-emphasis)))))
(setq icicle-dot-string-internal icicle-dot-string))
(defun icicle-convert-dots (&optional no-confirm-p plainp)
"Convert existing dots.
Optional arg NO-CONFIRM-P means don't ask user for confirmation.
Optional arg PLAINP means convert to plain `.'.
Otherwise, convert to `icicle-anychar-regexp'."
(if plainp
(save-excursion
(when (and (goto-char (icicle-minibuffer-prompt-end))
(search-forward icicle-anychar-regexp nil t))
(goto-char (icicle-minibuffer-prompt-end))
(while (search-forward icicle-anychar-regexp nil t)
(replace-match "." nil t))))
(save-excursion
(when (and (goto-char (icicle-minibuffer-prompt-end)) (search-forward "." nil t))
(goto-char (icicle-minibuffer-prompt-end))
(let ((allp nil))
(while (search-forward "." nil t)
;; If we hit a plain dot inserted by user explicitly, ask if we should convert all such.
(when (and (not allp)
(get-text-property (match-beginning 0) 'icicle-user-plain-dot)
(not no-confirm-p)
(y-or-n-p "Should all dots (`.') in current input match newlines too? "))
(setq allp t))
(when (or allp (not (get-text-property (match-beginning 0) 'icicle-user-plain-dot)))
(replace-match (icicle-anychar-regexp) nil t))))))))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
(when (require 'image-dired nil t) ; Emacs 22+.
(defalias 'cycle-icicle-image-file-thumbnail 'icicle-toggle-show-image-file-thumbnail)
(defun icicle-cycle-image-file-thumbnail () ; Bound to `C-x t' in minibuffer.
"Toggle `icicle-image-files-in-Completions'.
This has no effect if you do not have library `image-dired.el' (Emacs 23+).
Bound to `C-x t' in the minibuffer."
(interactive)
(if (not (require 'image-dired nil t))
(message "No-op: this command requires library `image-dired.el'")
(setq icicle-image-files-in-Completions
(case icicle-image-files-in-Completions
((nil) 'image-only)
(image-only t)
(t nil)))
(icicle-complete-again-update)
(icicle-msg-maybe-in-minibuffer
(case icicle-image-files-in-Completions
((nil) (concat "Image files in `*Completions*': showing only "
(icicle-propertize "NAMES" 'face 'icicle-msg-emphasis)))
(image-only (concat "Image files in `*Completions*': showing only "
(icicle-propertize "IMAGES" 'face 'icicle-msg-emphasis)))
(t (concat "Image files in `*Completions*': showing "
(icicle-propertize "IMAGES and NAMES" 'face 'icicle-msg-emphasis))))))))
;;;###autoload
(defun icicle-doremi-increment-max-candidates+ (&optional increment) ; `C-x #' in minibuffer
"Change `icicle-max-candidates' incrementally.
Use `up', `down' or the mouse wheel to increase or decrease. You can
use the `Meta' key (e.g. `M-up') to increment in larger steps.
You can use a numeric prefix arg to specify the increment.
A plain prefix arg (`C-u') resets `icicle-max-candidates' to nil,
meaning no limit."
(interactive "P")
(cond ((consp increment)
(setq icicle-max-candidates nil)
(icicle-msg-maybe-in-minibuffer "No longer any limit on number of candidates"))
(t
(setq increment (prefix-numeric-value increment))
(unless (require 'doremi nil t) (error "This command needs library `doremi.el'."))
(let ((mini (active-minibuffer-window)))
(unwind-protect
(save-selected-window
(select-window (minibuffer-window))
(unless icicle-completion-candidates (message "Hit `TAB' or `S-TAB'"))
(let ((enable-recursive-minibuffers t)
(nb-cands (length icicle-completion-candidates)))
(when (or (not icicle-max-candidates) (> icicle-max-candidates nb-cands))
(setq icicle-max-candidates nb-cands))
(when (zerop icicle-max-candidates) (setq icicle-max-candidates 10))
(doremi (lambda (new-val)
(setq icicle-max-candidates
(setq new-val (doremi-limit new-val 2 nil)))
(unless (input-pending-p)
(let ((icicle-edit-update-p t)
(icicle-last-input nil))
(funcall (or icicle-last-completion-command
(if (eq icicle-current-completion-mode 'prefix)
#'icicle-prefix-complete
#'icicle-apropos-complete)))
(run-hooks 'icicle-update-input-hook)))
new-val)
icicle-max-candidates
increment))
(setq unread-command-events ()))
(unless mini (icicle-remove-Completions-window)))))))
;;;###autoload
(defun icicle-doremi-increment-swank-timeout+ () ; Bound to `C-x 1' in minibuffer (swank only)
"Change `icicle-swank-timeout' incrementally.
Use `up', `down' or the mouse wheel to increase or decrease. You can
use the `Meta' key (e.g. `M-up') to increment in larger steps."
(interactive)
(icicle-doremi-increment-variable+ 'icicle-swank-timeout 1000))
;;;###autoload
(defun icicle-doremi-increment-swank-prefix-length+ () ; Bound to `C-x 2' in minibuffer (swank only)
"Change `icicle-swank-prefix-length' incrementally.
Use `up', `down' or the mouse wheel to increase or decrease. You can
use the `Meta' key (e.g. `M-up') to increment in larger steps."
(interactive)
(icicle-doremi-increment-variable+ 'icicle-swank-prefix-length 1))
;;;###autoload
(defun icicle-next-TAB-completion-method (temporary-p) ; Bound to `C-(' in minibuffer.
"Cycle to the next `TAB' completion method.
Bound to \\<minibuffer-local-completion-map>`\\[icicle-next-TAB-completion-method]' \
in the minibuffer.
Option `icicle-TAB-completion-methods' determines the TAB completion
methods that are available.
With a prefix argument, the newly chosen method is used only for the
current command. More precisely, the previously active method is
restored as soon as you return to the top level."
(interactive "P")
(unless icicle-current-TAB-method ; nil means the same as the default (first).
(setq icicle-current-TAB-method (car icicle-TAB-completion-methods)))
(if temporary-p
(unless (get 'icicle-last-top-level-command 'icicle-current-TAB-method)
(put 'icicle-last-top-level-command 'icicle-current-TAB-method icicle-current-TAB-method))
(put 'icicle-last-top-level-command 'icicle-current-TAB-method nil))
(let ((now (memq icicle-current-TAB-method icicle-TAB-completion-methods)))
(setq icicle-current-TAB-method (or (cadr now) (car icicle-TAB-completion-methods)))
;; Skip any method that is not currently supported.
(while (or (and (eq icicle-current-TAB-method 'fuzzy) (not (featurep 'fuzzy-match)))
(and (eq icicle-current-TAB-method 'vanilla) (not (boundp 'completion-styles)))
(and (eq icicle-current-TAB-method 'swank) (not (featurep 'el-swank-fuzzy))))
(setq now (memq icicle-current-TAB-method icicle-TAB-completion-methods)
icicle-current-TAB-method (or (cadr now) (car icicle-TAB-completion-methods)))))
(cond ((and (eq icicle-current-TAB-method 'swank) (fboundp 'doremi))
(define-key minibuffer-local-completion-map (icicle-kbd "C-x 1")
'icicle-doremi-increment-swank-timeout+)
(define-key minibuffer-local-must-match-map (icicle-kbd "C-x 1")
'icicle-doremi-increment-swank-timeout+)
(define-key minibuffer-local-completion-map (icicle-kbd "C-x 2")
'icicle-doremi-increment-swank-prefix-length+)
(define-key minibuffer-local-must-match-map (icicle-kbd "C-x 2")
'icicle-doremi-increment-swank-prefix-length+))
((fboundp 'doremi)
(define-key minibuffer-local-completion-map (icicle-kbd "C-x 1") nil)
(define-key minibuffer-local-must-match-map (icicle-kbd "C-x 1") nil)
(define-key minibuffer-local-completion-map (icicle-kbd "C-x 2") nil)
(define-key minibuffer-local-must-match-map (icicle-kbd "C-x 2") nil)))
;; $$$$$$ Inhibiting sorting is not correct for file-name completion, and sorting would not be
;; restored when change back to non-fuzzy.
;; (when (eq 'fuzzy icicle-current-TAB-method) (setq icicle-inhibit-sort-p t))
(icicle-msg-maybe-in-minibuffer
"TAB completion is %s %s"
(icicle-propertize (icicle-upcase (symbol-name icicle-current-TAB-method))
'face 'icicle-msg-emphasis)
(if temporary-p
(concat "for " (icicle-propertize "this command" 'face 'icicle-msg-emphasis))
"now")))
;;;###autoload
(defun icicle-next-S-TAB-completion-method (temporary-p) ; Bound to `M-(' in minibuffer.
"Cycle to the next `S-TAB' completion method.
Bound to `M-(' in the minibuffer.
Option `icicle-S-TAB-completion-methods-alist' customizes the
available TAB completion methods.
With a prefix argument, the newly chosen method is used only for the
current command. More precisely, the previously active method is
restored as soon as you return to the top level."
(interactive "P")
(if temporary-p
(unless (get 'icicle-last-top-level-command 'icicle-apropos-complete-match-fn)
(put 'icicle-last-top-level-command 'icicle-apropos-complete-match-fn
icicle-apropos-complete-match-fn))
(put 'icicle-last-top-level-command 'icicle-apropos-complete-match-fn nil))
(let ((entry (rassq icicle-apropos-complete-match-fn icicle-S-TAB-completion-methods-alist)))
(setq icicle-apropos-complete-match-fn
(or (cdadr (member entry icicle-S-TAB-completion-methods-alist))
(cdar icicle-S-TAB-completion-methods-alist))
icicle-last-apropos-complete-match-fn icicle-apropos-complete-match-fn) ; Backup copy.
(icicle-msg-maybe-in-minibuffer
"S-TAB completion is %s%s %s"
(icicle-propertize (icicle-upcase (car (rassq icicle-apropos-complete-match-fn
icicle-S-TAB-completion-methods-alist)))
'face 'icicle-msg-emphasis)
(if (memq icicle-apropos-complete-match-fn
'(icicle-levenshtein-match icicle-levenshtein-strict-match))
(icicle-propertize (format " (%d)" icicle-levenshtein-distance) 'face 'icicle-msg-emphasis)
"")
(if temporary-p
(concat "for " (icicle-propertize "this command" 'face 'icicle-msg-emphasis))
"now"))))
;; (icicle-complete-again-update) ; No - too slow for some completion methods.
;;;###autoload
(defun icicle-change-sort-order (&optional arg alternativep) ; Bound to `C-,' in minibuffer.
"Choose a sort order.
With a numeric prefix arg, reverse the current sort order.
If plain `C-u' is used or `C-u' is not used at all:
- Use completion if `icicle-change-sort-order-completion-flag' is
non-nil and no prefix arg is used, or if it is nil and a prefix arg
is used.
- Otherwise, just cycle to the next sort order.
This command updates `icicle-sort-comparer'. Non-interactively,
optional arg ALTERNATIVEP means change the current alternative sort
order instead, updating `icicle-alternative-sort-comparer'."
(interactive "P")
(setq icicle-sort-orders-alist (delq nil icicle-sort-orders-alist)) ; Purge any nil entries.
(if (and (interactive-p) icicle-inhibit-sort-p)
(icicle-msg-maybe-in-minibuffer "Cannot sort candidates now")
(if (and arg (not (consp arg)))
(icicle-reverse-sort-order)
(let (next-order)
(cond ((or (and icicle-change-sort-order-completion-flag (not arg)) ; Use completion.
(and (not icicle-change-sort-order-completion-flag) arg))
(setq next-order (let ((icicle-whole-candidate-as-text-prop-p nil)
(enable-recursive-minibuffers t))
(save-selected-window
(completing-read
(format "New %ssort order: " (if alternativep "alternative " ""))
(icicle-current-sort-functions)
nil t))))
(set (if alternativep 'icicle-alternative-sort-comparer 'icicle-sort-comparer)
(cdr (assoc next-order icicle-sort-orders-alist))))
(t ; Cycle to next sort order.
(let ((orders (mapcar #'car (icicle-current-sort-functions))))
(setq next-order (or (cadr (memq (icicle-current-sort-order alternativep) orders))
(car orders)))
(set (if alternativep 'icicle-alternative-sort-comparer 'icicle-sort-comparer)
(cdr (assoc next-order icicle-sort-orders-alist))))))
(icicle-complete-again-update)
(icicle-msg-maybe-in-minibuffer
"%sorting is now %s. Reverse: `C-9 C-,'"
(if alternativep "Alternative s" "S")
(icicle-propertize (concat next-order (and icicle-reverse-sort-p ", REVERSED"))
'face 'icicle-msg-emphasis))))))
(defun icicle-current-sort-functions ()
"Subset of `icicle-sort-orders-alist' that is currently appropriate.
For some common kinds of completion, remove simple sort functions (not
multi-sort comparers) that are not pertinent for the current kind of
completion."
(icicle-remove-if (lambda (pred)
(setq pred (cdr pred))
(and pred (symbolp pred) ; Do not handle multi-sort comparers.
(or (and (get pred 'icicle-proxy-sort-predicate)
(not icicle-add-proxy-candidates-flag))
(and (get pred 'icicle-file-name-sort-predicate)
(not (icicle-file-name-input-p)))
;; Not really needed yet, because we only add such sorts dynamically.
(and (get pred 'icicle-buffer-name-sort-predicate) ; Better than nothing.
(not (eq minibuffer-history-variable 'buffer-name-history)))
(and (get pred 'icicle-command-sort-predicate)
(not (and (eq minibuffer-completion-table obarray)
;; But this will fail if predicate is more complex.
(eq minibuffer-completion-predicate 'commandp))))
;; Sort order for multi-completions. `minibuffer-completion-table'
;; could be a function (e.g. `icicle-describe-opt-of-type-complete')
;; or it could be a list of multi-completions.
(and (get pred 'icicle-multi-completion-sort-predicate)
(not (icicle-maybe-multi-completion-completing-p))))))
icicle-sort-orders-alist))
(defun icicle-maybe-multi-completion-completing-p ()
"Returns non-nil if we might currently be multi-completion completing.
Note: If `minibuffer-completion-table' is a function, multi-completion
is possible but not sure. Return non-nil in that case."
(or (functionp minibuffer-completion-table) icicle-list-use-nth-parts))
;;;###autoload
(defun icicle-dispatch-M-comma () ; Bound to `M-,' in minibuffer.
"Do the right thing for `M-,'.
If sorting is possible, call `icicle-change-alternative-sort-order'.
If using `icicle-search', call `icicle-search-define-replacement'.
Otherwise, do nothing.
Bound to `M-,' in the minibuffer."
(interactive)
(cond (icicle-searching-p (icicle-search-define-replacement))
(icicle-inhibit-sort-p (message "Cannot sort candidates now"))
(t (icicle-change-alternative-sort-order))))
;; Free vars here: `icicle-scan-fn-or-regexp' is bound in `icicle-search'.
;;;###autoload
(defun icicle-search-define-replacement () ; Bound to `M-,' in minibuffer during `icicle-search'.
"Prompt user and set new value of `icicle-search-replacement'.
Bound to `M-,' in the minibuffer."
(interactive)
(save-selected-window
(icicle-remove-Completions-window)) ; Prevent incremental completion kicking in from the get-go.
(setq icicle-search-replacement
(let ((enable-recursive-minibuffers t)
(icicle-incremental-completion-flag t) ; Override current upgrade to `always'.
(icicle-completion-candidates icicle-completion-candidates)
(icicle-current-input icicle-current-input)
(icicle-candidate-nb icicle-candidate-nb)
(icicle-update-input-hook nil))
(icicle-completing-read-history "Replace with: " 'icicle-search-replacement-history)))
;; Just a sanity check. Cannot really test equivalence of two regexps.
(while (if icicle-search-replace-whole-candidate-flag
(equal icicle-search-replacement icicle-scan-fn-or-regexp)
(equal icicle-search-replacement icicle-current-input))
(setq icicle-search-replacement
(let ((enable-recursive-minibuffers t)
(icicle-incremental-completion-flag t) ; Override current upgrade to `always'.
(icicle-completion-candidates icicle-completion-candidates)
(icicle-current-input icicle-current-input)
(icicle-candidate-nb icicle-candidate-nb)
(icicle-update-input-hook nil))
(icicle-completing-read-history "Replacement = replaced. Replace with: "
'icicle-search-replacement-history)))))
;;;###autoload
(defun icicle-change-alternative-sort-order (&optional arg) ; Bound to `M-,' in minibuffer (not search).
"Choose an alternative sort order.
Similar to command `icicle-change-sort-order', but change the
alternative sort order, not the current sort order."
(interactive "P")
(if (and (interactive-p) icicle-inhibit-sort-p)
(icicle-msg-maybe-in-minibuffer "Cannot sort candidates now")
(icicle-change-sort-order arg t)))
(defun icicle-current-sort-order (alternativep)
"Current sort order, or nil if sorting is inactive.
If ALTERNATIVEP is non-nil, the alternative sort order is returned."
(car (rassq (if alternativep icicle-alternative-sort-comparer icicle-sort-comparer)
icicle-sort-orders-alist)))
;;;###autoload
(defun icicle-reverse-sort-order ()
"Reverse the current sort order."
(interactive)
(if (and (interactive-p) icicle-inhibit-sort-p)
(icicle-msg-maybe-in-minibuffer "Cannot sort candidates now")
(setq icicle-reverse-sort-p (not icicle-reverse-sort-p))
(icicle-display-candidates-in-Completions icicle-reverse-sort-p)
(icicle-complete-again-update)
(icicle-msg-maybe-in-minibuffer
"Sort order is %s" (icicle-propertize (concat (icicle-current-sort-order nil)
(and icicle-reverse-sort-p ", REVERSED"))
'face 'icicle-msg-emphasis))))
;;;###autoload
(defun icicle-plus-saved-sort () ; Bound to `C-M-+' during completion.
"Sort candidates by combining their current order with the saved order."
(interactive)
(let ((icicle-sort-comparer 'icicle-merge-saved-order-less-p)
(cands (copy-sequence icicle-completion-candidates)))
(setq icicle-completion-candidates
(if (or (icicle-file-name-input-p) icicle-abs-file-candidates)
(icicle-strip-ignored-files-and-sort cands)
(icicle-maybe-sort-maybe-truncate cands))))
(when (get-buffer-window "*Completions*" 0) (icicle-display-candidates-in-Completions))
(when (interactive-p) (icicle-msg-maybe-in-minibuffer "Added in the saved sort order")))
;;(@* "Other commands to be used mainly in the minibuffer")
;;; Other commands to be used mainly in the minibuffer . . . . . . . .
;; $$ Probably need to do something to work around problem of Windows
;; selecting the new frame, when `pop-up-frames' is non-nil. Need to
;; redirect focus back to the frame with the minibuffer. Leave it as
;; is, for now, in hopes Emacs will eventually fix this.
;;
;;;###autoload
(defun icicle-minibuffer-help () ; Bound to `C-?' in minibuffer.
"Describe Icicles minibuffer and *Completion* buffer bindings."
(interactive)
(let ((cur-buf (current-buffer)))
(with-output-to-temp-buffer "*Help*"
(help-setup-xref (list #'icicle-minibuffer-help) (interactive-p))
(when (icicle-completing-p)
(princ (concat "You are completing input" (and icicle-candidate-action-fn
" for an Icicles multi-command")
".\n\n"))
(princ "To show help on individual completion candidates:
Current candidate C-M-RET, C-M-mouse-2
Next, previous candidate C-M-down, C-M-up,
C-M- plus mouse wheel
prefix-match candidate C-M-end, C-M-home
apropos-match candidate C-M-next, C-M-prior\n\n")
(when icicle-candidate-action-fn
(princ "To act on individual candidates:
Current candidate C-RET, C-mouse-2
Next, previous candidate C-down, C-up,
C- plus mouse wheel
prefix-match candidate C-end, C-home
apropos-match candidate C-next, C-prior
All candidates at once C-! (each) or M-! (list)
Delete object named by candidate S-delete
Object-action: apply a fn to candidate M-RET"))
(when icicle-candidate-alt-action-fn
(princ "\n\nFor alt action, use `C-S-' instead of `C-', but use `C-|' or `M-|',\n\
instead of `C-!' or `M-!', to act on all.\n")))
(if icicle-completing-p
(with-current-buffer standard-output
(insert (concat "\n" (icicle-help-string-completion))))
(princ (icicle-help-string-non-completion))))
;; Don't bother to do this for Emacs 21.3. Its `help-insert-xref-button' signature is different.
(when (and (> emacs-major-version 21)
(require 'help-mode nil t) (fboundp 'help-insert-xref-button)) ; In `help-mode.el'.
(save-excursion
(with-current-buffer (get-buffer "*Help*")
(let ((buffer-read-only nil))
(goto-char (point-min))
(help-insert-xref-button "[Icicles Help on the Web]" 'icicle-help-button)
(insert " ")
(help-insert-xref-button "[Icicles Doc, Part 1]" 'icicle-commentary1-button)
(insert "\n")
(help-insert-xref-button "[Icicles Options & Faces]" 'icicle-customize-button)
(insert " ")
(help-insert-xref-button "[Icicles Doc, Part 2]" 'icicle-commentary2-button)
(insert "\n\n")
(goto-char (point-max))
(insert (make-string 70 ?_))
(insert (funcall
(if (fboundp 'help-commands-to-key-buttons) ; In `help-fns.el'.
#'help-commands-to-key-buttons
#'substitute-command-keys)
"\n\nSend an Icicles bug report: `\\[icicle-send-bug-report]'.\n\n"))
(help-insert-xref-button "[Icicles Help on the Web]" 'icicle-help-button)
(insert " ")
(help-insert-xref-button "[Icicles Doc, Part 1]" 'icicle-commentary1-button)
(insert "\n")
(help-insert-xref-button "[Icicles Options & Faces]" 'icicle-customize-button)
(insert " ")
(help-insert-xref-button "[Icicles Doc, Part 2]" 'icicle-commentary2-button)
(insert "\n\n")
(goto-char (point-min))))))
(when (memq cur-buf (list (window-buffer (minibuffer-window)) (get-buffer "*Completions*")))
(select-window (minibuffer-window))
(select-frame-set-input-focus (selected-frame)))))
(defun icicle-help-string-completion ()
"Update the bindings within the Icicles completion help string."
(icicle-S-iso-lefttab-to-S-TAB
(funcall
(if (fboundp 'help-commands-to-key-buttons) ; In `help-fns+.el'.
#'help-commands-to-key-buttons
#'substitute-command-keys)
(concat
(format "\\<minibuffer-local-completion-map>
Icicles Minibuffer Completion
-----------------------------
Minibuffer input can be completed in several ways.
These are the main Icicles actions and their minibuffer key bindings:
* Show Icicles minibuffer help (this). \\[icicle-minibuffer-help]
For help on individual completion candidates, see \"Show help on
individual completion candidates\", below.
* Abandon or commit your input.
Abandon input \\[icicle-abort-recursive-edit]
Commit input to Emacs RET
Complete partial input, then commit \\<minibuffer-local-must-match-map>\
\\[icicle-apropos-complete-and-exit]\\<minibuffer-local-completion-map>
* Toggle/cycle Icicles options on the fly. Key: \tCurrently:
Highlighting of past inputs \\[icicle-toggle-highlight-historical-candidates]\t%S
Highlighting of saved candidates \\[icicle-toggle-highlight-saved-candidates]\t%S
Removal of duplicate candidates \\[icicle-toggle-transforming]\t%S
Sort order \\[icicle-change-sort-order]\t%s
Alternative sort order \\[icicle-dispatch-M-comma]\t%s
Swap alternative/normal sort \\[icicle-toggle-alternative-sorting]\t- (swaps) -
Case sensitivity \\[icicle-toggle-case-sensitivity]\t%S
`.' matching newlines too (any char) \\[icicle-toggle-dot]\t%S
Escaping of special regexp chars \\[icicle-toggle-regexp-quote]\t%S
Incremental completion \\[icicle-cycle-incremental-completion]\t%S
Input expansion to common match \\[icicle-toggle-expand-to-common-match]\t%S
Hiding common match in `*Completions*' \\[icicle-dispatch-C-x.]\t%S
Hiding no-match lines in `*Completions*' C-u \\[icicle-dispatch-C-x.]\t%S
S-TAB completion method \\[icicle-next-S-TAB-completion-method]\t%s
TAB completion method \\[icicle-next-TAB-completion-method]\t%s
Showing image-file thumbnails (E22+) C-x t\t%S
Inclusion of proxy candidates \\[icicle-toggle-proxy-candidates]\t%S
Ignoring certain file extensions \\[icicle-dispatch-C-.]\t%S
Checking for remote file names \\[icicle-dispatch-C-^]\t%S
Ignoring space prefix \\[icicle-dispatch-M-_]\t%S
Using `C-' for multi-command actions \\[icicle-toggle-C-for-actions]\t%S
Using `~' for your home directory \\[icicle-toggle-~-for-home-dir]\t%S
`icicle-search' all-current highlights \\[icicle-dispatch-C-^]\t%S
Whole-word searching \\[icicle-dispatch-M-q]\t%S
Removal of `icicle-search' highlighting \\[icicle-dispatch-C-.]\t%S
Replacement of whole search hit \\[icicle-dispatch-M-_]\t%S
Replacement of expanded common match \\[icicle-toggle-search-replace-common-match]\t%S
* Regexp-quote input, then apropos-complete \\[icicle-regexp-quote-input]
* Change the set of completion candidates. Modify your input.
Edit your input (just edit in minibuffer)
Erase your input (clear minibuffer) \\[icicle-erase-minibuffer-or-history-element]
Goto/kill non-matching portion of input \\[icicle-goto/kill-failed-input]
Retrieve previous completion inputs \\[icicle-retrieve-previous-input], \
\\[icicle-retrieve-next-input]
Match another regexp (chaining) \\[icicle-narrow-candidates]
Satisfy another predicate (chaining) \\[icicle-narrow-candidates-with-predicate]
Remove a candidate from set of matches delete, S-mouse-2
Yank text at cursor into minibuffer \\[icicle-insert-string-at-point]
Insert text (string) from a variable \\[icicle-insert-string-from-variable]
Insert `icicle-list-join-string' \\[icicle-insert-list-join-string]
Insert previously entered input \\[icicle-insert-history-element]
Insert key description (key completion) \\[icicle-dispatch-M-q]
* Complete your current input in the minibuffer.
Apropos (regexp) completion \\[icicle-apropos-complete]
Without displaying candidates \\[icicle-apropos-complete-no-display]
Complete and match another regexp \\[icicle-apropos-complete-and-narrow]
Prefix completion
As much as possible \\[icicle-prefix-complete]
Without displaying candidates \\[icicle-prefix-complete-no-display]
A word at a time \\[icicle-prefix-word-complete]
Complete and commit \\<minibuffer-local-must-match-map>\
\\[icicle-apropos-complete-and-exit]\\<minibuffer-local-completion-map>
Complete search string using past input \\[icicle-apropos-complete]
* Display/navigate completions for current input (in `*Completions*').
Show completion candidates
Prefix completion \\[icicle-prefix-complete] (repeat)
Apropos completion \\[icicle-apropos-complete]
Move between minibuffer and list \\<completion-list-mode-map>\
\\[icicle-insert-completion]
Cycle among completion candidates right, left, \
\\[icicle-move-to-next-completion], \\[icicle-move-to-previous-completion]
Within a `*Completions*' column down, up
Choose a completion candidate \\[choose-completion], \
\\[mouse-choose-completion]\\<minibuffer-local-completion-map>
* Cycle among input candidates.
Completion candidates
Current mode down, up, mouse wheel
Prefix completion end, home
Apropos completion next, prior
Minibuffer history items \\[next-history-element], \
\\[previous-history-element]
Completion history items \\[icicle-retrieve-previous-input], \
\\[icicle-retrieve-next-input]
* Show help on individual completion candidates.
Current candidate C-M-RET, C-M-mouse-2
Next, previous candidate C-M-down, C-M-up,
C-M- plus mouse wheel
prefix-match candidate C-M-end, C-M-home
apropos-match candidate C-M-next, C-M-prior
* Choose a previous input from the minibuffer history.
Complete to insert a previous input \\[icicle-insert-history-element]
Complete against history items \\[icicle-history], \
\\[icicle-keep-only-past-inputs]
Restrict candidates to history items \\[icicle-keep-only-past-inputs]
Change to another history \\[icicle-other-history]
List history items first in Completions \\[icicle-toggle-alternative-sorting]
Cycle among minibuffer history items \\[next-history-element], \
\\[previous-history-element]
Search among minibuffer history items \
\\[next-matching-history-element], \\[previous-matching-history-element]
* Delete history entries
Delete current entry (cycling) \\[icicle-erase-minibuffer-or-history-element]
Delete any or all entries \\[icicle-clear-current-history]
* Multi-commands: Act on completion candidates.
For alternative action, use `C-S-' instead of `C-', but
`C-|' and `M-|' are alternative action versions of `C-!' and `M-!'.
Current candidate C-RET, C-mouse-2
Next, previous candidate C-down, C-up,
C- with mouse wheel
prefix-match candidate C-end, C-home
apropos-match candidate C-next, C-prior
Act on each matching candidate, in turn C-!
Act on the list of matching candidates M-!
Delete object named by candidate S-delete
Remove candidate from set of matches delete, S-mouse-2
Save candidate (add to those saved) insert, M-S-mouse-2
Object-action: apply a fn to candidate M-RET
* Search and replace (e.g. `C-c `'). See also `icicle-search'.
Use action keys (prefix `C-') to navigate.
Use alternative action keys (prefix `C-S-') to replace matches.
Toggle input highlighting at all hits \\[icicle-dispatch-C-^]
Toggle whole-word searching \\[icicle-dispatch-M-q]
Toggle `.' matching newlines too \\[icicle-toggle-dot]
Toggle escaping of special regexp chars \\[icicle-toggle-regexp-quote]
Toggle removal of search highlighting \\[icicle-dispatch-C-.]
Replace all M-|
Redefine the replacement string \\[icicle-dispatch-M-comma]
Toggle literal replacement \\[icicle-toggle-literal-replacement]
Toggle replacement of whole search hit \\[icicle-dispatch-M-_]
Toggle replacement of common match \\[icicle-toggle-search-replace-common-match]
* Perform set operations on candidate sets.
Remove candidate from current set delete, S-mouse-2
Add current candidate to saved set insert, M-S-mouse-2
Retrieve saved candidates from...
`icicle-saved-completion-candidates' \\[icicle-candidate-set-retrieve]
another variable \\[icicle-candidate-set-retrieve-from-variable]
a cache file \\[icicle-candidate-set-retrieve-persistent]
Retrieve more saved candidates \\[icicle-candidate-set-retrieve-more]
Save candidates in current set to...
`icicle-saved-completion-candidates' \\[icicle-candidate-set-save]
another variable \\[icicle-candidate-set-save-to-variable]
a cache file \\[icicle-candidate-set-save-persistently]
Save more candidates to current set \\[icicle-candidate-set-save-more]
Save, save more selected candidates \\[icicle-candidate-set-save-selected], \
\\[icicle-candidate-set-save-more-selected] with region
Clear all saved candidates \\[icicle-candidate-set-save-selected] \
with empty region
Add new or update existing saved set
\\[icicle-add/update-saved-completion-set]
Remove a saved completion set
\\[icicle-remove-saved-completion-set]
Swap current and saved sets \\[icicle-candidate-set-swap]
Define current set by evaluating sexp \\[icicle-candidate-set-define]
Restrict candidates to history items \\[icicle-keep-only-past-inputs]
Set complement \\[icicle-candidate-set-complement]
Set difference \\[icicle-candidate-set-difference]
Set union \\[icicle-candidate-set-union]
Set intersection \\[icicle-candidate-set-intersection]
Set intersection using regexp \\[icicle-narrow-candidates]
Set intersection using predicate \\[icicle-narrow-candidates-with-predicate]
Save current predicate to a variable \\[icicle-save-predicate-to-variable]
Insert string variable as input \\[icicle-insert-string-from-variable]
* Adjust Icicles options incrementally on the fly (uses Do Re Mi).
`icicle-candidate-width-factor' \\[icicle-doremi-candidate-width-factor+]
`icicle-max-candidates' \\[icicle-doremi-increment-max-candidates+]
`icicle-swank-timeout' C-x 1
`icicle-swank-prefix-length' C-x 2
`icicle-inter-candidates-min-spaces' \\[icicle-doremi-inter-candidates-min-spaces+]
Zoom `*Completions*' (not an option) C-x - (Emacs 23+)
Remember: You can always input any character (e.g. \\[icicle-prefix-complete]) that is bound
to a command by preceding it with \\<global-map>\\[quoted-insert].
Though it has no direct connection with completion, you can use \
`\\<minibuffer-local-completion-map>\\[icicle-pp-eval-expression-in-minibuffer]'
in the minibuffer at any time to evaluate an Emacs-Lisp expression.
This calls `icicle-pp-eval-expression-in-minibuffer', which displays
the result in the echo area or a popup buffer, *Pp Eval Output*.
It also provides some of the Emacs-Lisp key bindings during expression
editing."
icicle-highlight-historical-candidates-flag
icicle-highlight-saved-candidates-flag
icicle-transform-function
(icicle-current-sort-order nil)
(icicle-current-sort-order 'ALTERNATIVE)
(not case-fold-search)
(string= icicle-dot-string icicle-anychar-regexp)
icicle-regexp-quote-flag
icicle-incremental-completion-flag
icicle-expand-input-to-common-match-flag
icicle-hide-common-match-in-Completions-flag
icicle-hide-non-matching-lines-flag
(car (rassq icicle-apropos-complete-match-fn icicle-S-TAB-completion-methods-alist))
(icicle-current-TAB-method)
icicle-add-proxy-candidates-flag
(and completion-ignored-extensions t)
icicle-image-files-in-Completions
icicle-test-for-remote-files-flag
icicle-ignore-space-prefix-flag
icicle-use-C-for-actions-flag
icicle-use-~-for-home-dir-flag
icicle-search-highlight-all-current-flag
icicle-search-whole-word-flag
icicle-search-cleanup-flag
icicle-search-replace-whole-candidate-flag
icicle-search-replace-common-match-flag)
icicle-general-help-string
"
These are all of the minibuffer bindings during completion:
\\{minibuffer-local-completion-map}"))))
(defun icicle-help-string-non-completion ()
"Description of Icicles minibuffer bindings when not completing input."
(icicle-S-iso-lefttab-to-S-TAB
(substitute-command-keys
(concat "\\<minibuffer-local-completion-map>\
Icicles Minibuffer Input when Not Completing
--------------------------------------------
These are the main Icicles minibuffer key bindings when completion is
not available:
* Show this help. \\[icicle-minibuffer-help]
* Abandon your input. \\[icicle-abort-recursive-edit]
* Commit your input to Emacs. RET
* Modify your input.
Edit your input (just edit in minibuffer)
Erase your input (clear minibuffer) \\[icicle-erase-minibuffer-or-history-element]
Yank text at cursor into minibuffer \\[icicle-insert-string-at-point]
Insert text (string) from a variable \\[icicle-insert-string-from-variable]
Insert previously entered input \\[icicle-insert-history-element]
* Choose a previous input from the minibuffer history.
Complete to insert a previous input \\[icicle-insert-history-element]
Cycle among minibuffer history items \\[next-history-element], \
\\[previous-history-element]
Search among minibuffer history items \
\\[next-matching-history-element], \\[previous-matching-history-element]
* Delete history entries
Delete current entry (cycling) \\[icicle-erase-minibuffer-or-history-element]
Delete any or all entries \\[icicle-clear-current-history]
* Evaluate an Emacs-Lisp sexp on the fly \\[icicle-pp-eval-expression-in-minibuffer]
Remember: You can always input any character that is bound to a
command by preceding it with \\<global-map>\\[quoted-insert]."
icicle-general-help-string
"
These are the minibuffer bindings when not completing input:
\\{minibuffer-local-map}"))))
(when (and (> emacs-major-version 21)
(require 'help-mode nil t) (get 'help-xref 'button-category-symbol)) ; In `button.el'
(define-button-type 'icicle-help-button
:supertype 'help-xref
'help-function #'(lambda () (browse-url "http://www.emacswiki.org/cgi-bin/wiki/Icicles"))
'help-echo
(purecopy "mouse-2, RET: Icicles documentation on the Emacs Wiki (requires Internet access)"))
(define-button-type 'icicle-commentary1-button
:supertype 'help-xref
'help-function #'(lambda ()
(finder-commentary "icicles-doc1")
(when (require 'linkd nil t) (linkd-mode 1))
(when (require 'fit-frame nil t) (fit-frame)))
'help-echo (purecopy "mouse-2, RET: Icicles documentation, Part 1 (no Internet needed)"))
(define-button-type 'icicle-commentary2-button
:supertype 'help-xref
'help-function #'(lambda ()
(finder-commentary "icicles-doc2")
(when (require 'linkd nil t) (linkd-mode 1))
(when (require 'fit-frame nil t) (fit-frame)))
'help-echo (purecopy "mouse-2, RET: Icicles documentation, Part 2 (no Internet needed)"))
(define-button-type 'icicle-customize-button
:supertype 'help-xref
'help-function #'(lambda () (customize-group-other-window 'Icicles))
'help-echo (purecopy "mouse-2, RET: Customize/Browse Icicles Options & Faces")))
;; This is just the macro expansion of the following:
;; `(def-completion-wrapper icicle-abort-recursive-edit :minibuffer-separator)'.
;; Taken from the definition of `def-completion-wrapper' in `completion.el'.
(put 'icicle-abort-recursive-edit 'completion-function 'use-completion-minibuffer-separator)
;;;###autoload
(defun icicle-abort-recursive-edit () ; Bound to `C-]',`C-g' in minibuf, `C-g',`q' in `*Completions*'.
"Abort command that requested this recursive edit or minibuffer input.
This calls `abort-recursive-edit' after killing the `*Completions*'
buffer or (if called from the minibuffer) removing its window.
By default, Icicle mode remaps all key sequences that are normally
bound to `abort-recursive-edit' to `icicle-abort-recursive-edit'. If
you do not want this remapping, then customize option
`icicle-top-level-key-bindings'."
(interactive)
(if (not (active-minibuffer-window))
(when (get-buffer "*Completions*") (kill-buffer (get-buffer "*Completions*")))
(icicle-remove-Completions-window 'FORCE))
(abort-recursive-edit))
(unless (fboundp 'save&set-overriding-map) ; Only Emacs 20-23 use `ensure-overriding-map-is-bound'.
(defun icicle-ensure-overriding-map-is-bound ()
"Set `overriding-terminal-local-map' to `icicle-universal-argument-map'."
(if (not (boundp 'overriding-map-is-bound)) ; Emacs 20, 21.
(setq overriding-terminal-local-map icicle-universal-argument-map)
(unless overriding-map-is-bound ; Emacs 22+.
(setq saved-overriding-map overriding-terminal-local-map
overriding-terminal-local-map icicle-universal-argument-map
overriding-map-is-bound t)))))
;;;###autoload
(defun icicle-digit-argument (arg) ; Bound to `C-<0-9>', `M-<0-9>', `C-M-<0-9>' in minibuffer.
"`digit-argument', but also echo the prefix."
(interactive "P")
(let* ((char (if (integerp last-command-char)
last-command-char
(get last-command-char 'ascii-character)))
(digit (- (logand char ?\177) ?0)))
(cond ((integerp arg)
(setq prefix-arg (+ (* arg 10) (if (< arg 0) (- digit) digit))))
((eq arg '-)
;; Treat -0 as just -, so that -01 will work.
(setq prefix-arg (if (zerop digit) '- (- digit))))
(t
(setq prefix-arg digit))))
(setq universal-argument-num-events (length (this-command-keys)))
(if (fboundp 'save&set-overriding-map) ; Emacs 24+
(save&set-overriding-map icicle-universal-argument-map)
(icicle-ensure-overriding-map-is-bound))
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;;;###autoload
(defun icicle-negative-argument (arg) ; Bound to `M--', `C-M--' in minibuffer.
"`negative-argument', but also echo the prefix."
(interactive "P")
(cond ((integerp arg) (setq prefix-arg (- arg)))
((eq arg '-) (setq prefix-arg nil))
(t (setq prefix-arg '-)))
(setq universal-argument-num-events (length (this-command-keys)))
(if (fboundp 'save&set-overriding-map) ; Emacs 24+
(save&set-overriding-map icicle-universal-argument-map)
(icicle-ensure-overriding-map-is-bound))
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;;;###autoload
(defun icicle-universal-argument () ; Bound to `C-u' in minibuffer.
"`universal-argument', but also echo the prefix."
(interactive)
(setq prefix-arg (list 4)
universal-argument-num-events (length (this-command-keys)))
(if (fboundp 'save&set-overriding-map) ; Emacs 24+
(save&set-overriding-map icicle-universal-argument-map)
(icicle-ensure-overriding-map-is-bound))
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;;;###autoload
(defun icicle-universal-argument-more (arg)
"`universal-argument-more', but also echo the prefix."
(interactive "P")
(universal-argument-more arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;;;###autoload
(defun icicle-universal-argument-other-key (arg)
"`universal-argument-other-key', but also echo the prefix."
(interactive "P")
(universal-argument-other-key arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;;;###autoload
(defun icicle-universal-argument-minus (arg)
"`universal-argument-minus', but also echo the prefix."
(interactive "P")
(universal-argument-minus arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
;; REPLACE ORIGINAL `sit-for' in `subr.el',
;; saving it for restoration when you toggle `icicle-mode'.
;;
;; Ensure that `sit-for' after `C-u' in the minibuffer is immediately interrupted by user input.
;; This fix is not needed for Emacs < 23.
;;
(unless (fboundp 'old-sit-for)
(defalias 'old-sit-for (symbol-function 'sit-for)))
(when (> emacs-major-version 22)
(defun icicle-sit-for (seconds &optional nodisp obsolete)
"Perform redisplay, then wait for SECONDS seconds or until input is available.
SECONDS may be a floating-point value.
\(On operating systems that do not support waiting for fractions of a
second, floating-point values are rounded down to the nearest integer.)
If optional arg NODISP is t, don't redisplay, just wait for input.
Redisplay does not happen if input is available before it starts.
Value is t if waited the full time with no input arriving, and nil otherwise.
An obsolete, but still supported form is
\(sit-for SECONDS &optional MILLISECONDS NODISP)
where the optional arg MILLISECONDS specifies an additional wait period,
in milliseconds; this was useful when Emacs was built without
floating point support."
(if (numberp nodisp)
(setq seconds (+ seconds (* 1e-3 nodisp))
nodisp obsolete)
(if obsolete (setq nodisp obsolete)))
(cond (noninteractive
(sleep-for seconds)
t)
((input-pending-p)
nil)
((<= seconds 0)
(or nodisp (redisplay)))
(t
(or nodisp (redisplay))
(let ((read (read-event nil nil seconds)))
(or (null read)
(progn
;; If last command was a prefix arg, e.g. C-u, push this event onto
;; `unread-command-events' as (t . EVENT) so it will be added to
;; `this-command-keys' by `read-key-sequence'.
(if (memq overriding-terminal-local-map
(list universal-argument-map icicle-universal-argument-map))
(setq read (cons t read)))
(push read unread-command-events)
nil)))))))
;;;###autoload
(defun icicle-retrieve-next-input (&optional arg) ; Bound to `C-S-l' (`C-L') in minibuffer.
"Retrieve next minibuffer input.
Like `icicle-retrieve-previous-input', but traverses history toward
the present.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-retrieve-next-input]')."
(interactive "P")
(icicle-retrieve-previous-input arg 'interactive-p)) ; Must be `interactive-p'.
;;;###autoload
(defun icicle-retrieve-previous-input (&optional arg reversep allow-empty-p) ; `C-l' in minibuffer.
"Retrieve previous minibuffer input.
The possible inputs were not necessarily those entered with `RET'.
With a negative prefix arg, this just empties the completion history.
Otherwise:
Use completion if `icicle-C-l-uses-completion-flag' is non-nil and no
prefix arg is used, or if it is nil and a prefix arg is used, or if
`icicle-retrieve-previous-input' is not used interactively.
Otherwise, just cycle to the previous input.
Non-interactively:
Non-nil argument REVERSEP means reverse the history order: return the
next, not the previous, input.
Non-nil ALLOW-EMPTY-P means the retrieved input can be \"\".
You can use this command only from buffer *Completions or from the
minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-retrieve-previous-input]')."
(interactive "P")
(let ((interactive-p (or (interactive-p) (eq reversep 'interactive-p)))
(prev-inputs-var (if (icicle-file-name-input-p)
'icicle-previous-raw-file-name-inputs
'icicle-previous-raw-non-file-name-inputs))
;; `irpi-was-cycling-p' is used to remember, for the second `C-l' in a row, that the first
;; `C-l' came after cycling. In that case, the second `C-l' restores the current raw input.
(irpi-was-cycling-p icicle-cycling-p))
(when interactive-p (icicle-barf-if-outside-Completions-and-minibuffer))
(cond ((wholenump (prefix-numeric-value arg))
(let ((input ""))
(save-selected-window
(select-window (minibuffer-window))
(icicle-clear-minibuffer)
(let ((prev-inputs
(if allow-empty-p
(symbol-value prev-inputs-var)
(icicle-remove-if (lambda (x) (string= "" x)) ; Exclude "".
(symbol-value prev-inputs-var)))))
(setq input
(if (and interactive-p (or (and icicle-C-l-uses-completion-flag (not arg))
(and (not icicle-C-l-uses-completion-flag) arg)))
(let ((icicle-whole-candidate-as-text-prop-p nil)
(enable-recursive-minibuffers t)
(icicle-show-Completions-initially-flag t))
(prog1 (completing-read
"Retrieve input: " (mapcar #'list prev-inputs) nil t)
(setq icicle-last-input nil)))
(if (or (not interactive-p)
(not (memq last-command '(icicle-retrieve-next-input
icicle-retrieve-previous-input))))
;; We use this one, to exclude common-match expansions from completion
;; history, and to save the typed input only when you complete.
(let ((try (if icicle-cycling-p
icicle-last-input
icicle-current-raw-input)))
(if (or allow-empty-p (not (equal "" try))) try (car prev-inputs)))
;; You can use this one instead, if you want to include common-match
;; expansions and save the typed input even when you don't complete.
;; (or icicle-last-input icicle-current-raw-input)
(let ((next (member icicle-current-raw-input prev-inputs)))
(unless next (setq next prev-inputs))
(if reversep
(or (let ((res ())
(inputs prev-inputs))
(while (and (consp inputs) (not (eq inputs next)))
(push (pop inputs) res))
(car res))
(car (last prev-inputs)))
;; If we were cycling before the first `C-l', then need to pick up the
;; current raw input. Otherwise, we need to pick up the previous one.
(prog1 (if irpi-was-cycling-p (car next) (cadr next))
(setq irpi-was-cycling-p nil))))))) ; So third `C-l' acts normally.
(when input (icicle-call-then-update-Completions #'insert input))))
;;; $$$$$$ REPLACED by previous line only.
;;; (when input
;;; (setq icicle-current-raw-input input)
;;; (insert input)
;;; (icicle-highlight-initial-whitespace input) ; (e.g. user typo).
;;; (icicle-place-cursor input 'deactivate-mark))))
;;; (let ((icicle-edit-update-p t))
;;; (funcall (or icicle-last-completion-command 'icicle-apropos-complete))
;;; ;; Restore raw input. Cycling resets it to "", so `icicle-save-or-restore-input'
;;; ;; doesn't use out-of-date raw input (cycling does not necessarily follow completion
;;; ;; or completion of the same kind).
;;; (setq icicle-current-raw-input input))
(setq icicle-last-input nil ; So `TAB' will expand it - `icicle-save-or-restore-input'.
icicle-cycling-p irpi-was-cycling-p))) ; Let next `C-l' know the state.
(t
(set prev-inputs-var nil)
(setq icicle-current-raw-input "")
(icicle-msg-maybe-in-minibuffer "Cleared completion history")))))
;; $$ No longer bound. Now we bind `icicle-retrieve-previous-input', instead, to `C-l'.
;;;###autoload
(defun icicle-retrieve-last-input ()
"Put the last real input into the minibuffer.
Use this to replace a completion candidate inserted during cycling.
If `icicle-expand-input-to-common-match-flag' is non-nil or this is
prefix completion, then using this once restores the expanded common
match string, and using it twice in succession restores your original
input.
You can use this command only from buffer *Completions or from the
minibuffer."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer))
(save-selected-window
(select-window (minibuffer-window))
(icicle-clear-minibuffer)
(if (and (or icicle-expand-input-to-common-match-flag (eq icicle-current-completion-mode 'prefix))
(eq last-command 'icicle-retrieve-last-input))
(insert icicle-current-raw-input)
(insert icicle-current-input))
;;$$$ (when (interactive-p) (setq icicle-last-completion-command nil))
(let ((input (if (and (or icicle-expand-input-to-common-match-flag
(eq icicle-current-completion-mode 'prefix))
(eq last-command this-command))
icicle-current-raw-input
icicle-current-input)))
(icicle-highlight-initial-whitespace input) ; Highlight initial whitespace (e.g. user typo).
(icicle-place-cursor input 'deactivate-mark))))
;; $$ No longer used. It was originally used in `icicle-retrieve-last-input'.
(defun icicle-insert-input (input)
"Insert INPUT. Prepend the directory if appropriate."
(insert (if (and (icicle-file-name-input-p) insert-default-directory
(or (not (member input icicle-extra-candidates))
icicle-extra-candidates-dir-insert-p))
(icicle-expand-file-or-dir-name input (icicle-file-name-directory input))
input)))
;;;###autoload
(defun icicle-insert-history-element () ; Bound to `M-o' in minibuffer.
"Use completion to insert a previously entered input in the minibuffer.
Always available for any minibuffer input, not just during completion."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(when (and (boundp minibuffer-history-variable) (consp (symbol-value minibuffer-history-variable)))
(let ((enable-recursive-minibuffers t))
(insert (icicle-completing-read-history "Choose input: " minibuffer-history-variable))))
(when (and icicle-mode (memq icicle-default-value '(preselect-start preselect-end)))
(icicle-select-minibuffer-contents)
(setq deactivate-mark nil)))
;;;###autoload
(defun icicle-insert-string-at-point (&optional arg) ; Bound to `M-.' in minibuffer.
"Insert text at the cursor into the minibuffer.
Each time this command is called, some text at or near the cursor is
inserted into the minibuffer. One of two things happens, depending on
the value of option `icicle-default-thing-insertion' and whether or
not you use `C-u'.
See the doc for option `icicle-thing-at-point-functions' for a
complete description of its behavior. What follows is an overview.
`icicle-thing-at-point-functions' is a cons of two parts - call them
ALTERNATIVES and FORWARD-THING.
If ALTERNATIVES is not nil and one of the following is true:
- FORWARD-THING is nil
- the value of `icicle-default-thing-insertion' is `alternatives' and
you have not used plain `C-u' in this series of `M-.'
- the value of `icicle-default-thing-insertion' is `more-of-the-same'
and you have used plain `C-u' in this series of `M-.'
then the next function in ALTERNATIVES is used to retrieve the text to
be inserted.
If FORWARD-THING is not nil and one of the following is true:
- ALTERNATIVES is nil
- the value of `icicle-default-thing-insertion' is `more-of-the-same'
and you have not used `C-u' in this series of `M-.'
- the value of `icicle-default-thing-insertion' is `alternatives' and
you have used `C-u' in this series of `M-.'
then function FORWARD-THING is used to retrieve the text to be
inserted.
If you use a numeric prefix arg (not just plain `C-u'), the behavior
is as follows.
* If a function in ALTERNATIVES is used (see above), then the text
that is grabbed at or near point is read as a Lisp sexp and
evaluated, and the value is inserted instead of the grabbed text.
Yes, this means you need to know when the particular ALTERNATIVES
function that you want is coming up next, and use, say, `C-9' just
before hitting `M-.' for that alternative. So if, e.g., you want to
evaluate the active region and insert the value, then you use
`M-. C-9 M-.', since it is the second `M-.' that grabs the region.
* If the FORWARD-THING is being used, then the prefix arg determines
the number of things to grab, and the direction of grabbing.: A
negative argument grabs text to the left of the cursor; a positive
argument grabs text to the right.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-insert-string-at-point]')."
(interactive "P")
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(when (consp icicle-thing-at-point-functions) ; Option should always be a cons cell.
(unless (eq last-command this-command) (setq icicle-default-thing-insertion-flipped-p nil))
(let ((alt-fns (car icicle-thing-at-point-functions))
(fwd-thing-fn (cdr icicle-thing-at-point-functions))
(flipped (or icicle-default-thing-insertion-flipped-p ; Already flipped.
(setq icicle-default-thing-insertion-flipped-p (consp arg)))))
(cond
;; Use alternative text-grabbing functions successively.
((and alt-fns (or (if (eq 'alternatives icicle-default-thing-insertion)
(not flipped) ; Normal behavior for `alternatives'.
flipped) ; Flipped behavior for `more-of-the-same'.
(not fwd-thing-fn))) ; No alternative.
(setq icicle-successive-grab-count 1 ; In this mode, reset other mode's accumulator.
icicle-thing-at-pt-fns-pointer
(if (eq last-command this-command) ; If repeated, get next text-grabbing function.
(mod (1+ icicle-thing-at-pt-fns-pointer) (length alt-fns))
0))
(let ((thing "")
(alt-fn (nth icicle-thing-at-pt-fns-pointer alt-fns)))
(save-excursion (with-current-buffer icicle-pre-minibuffer-buffer
(setq thing (funcall alt-fn))))
(setq thing (or thing "nil"))
(when (and arg (atom arg)) ; Numeric prefix arg.
(setq thing (condition-case err
(format "%s" (eval (car (read-from-string thing))))
(error thing))))
(icicle-insert-thing thing)
(icicle-msg-maybe-in-minibuffer (format "`%s'" alt-fn))))
;; Use same text-grabbing function successively.
((and fwd-thing-fn (or (if (eq 'alternatives icicle-default-thing-insertion)
flipped ; Flipped behavior for `alternatives'.
(not flipped)) ; Normal behavior for `more-of-the-same'.
(not alt-fns))) ; No alternative.
(if (and arg (atom arg))
;; Explicit numeric arg. If it doesn't change direction, then increment
;; existing count. Otherwise, set count absolutely.
(if (eq last-command this-command)
(if (= (icicle-signum icicle-successive-grab-count) ; Repeated `M-.'.
(icicle-signum (prefix-numeric-value arg)))
(setq icicle-successive-grab-count ; Same direction - increment count.
(* (icicle-signum icicle-successive-grab-count)
(+ (abs icicle-successive-grab-count)
(abs (prefix-numeric-value arg)))))
(setq icicle-successive-grab-count (prefix-numeric-value arg))) ; New dir - set.
(setq icicle-successive-grab-count (prefix-numeric-value arg))) ; First `M-.' - set.
;; No explicit numeric arg.
;; If first `M-.' or plain `C-u', set count. Otherwise, increment count.
(if (eq last-command this-command)
(setq icicle-successive-grab-count ; Repeated `M-.'.
(if (consp arg)
;; We're here from plain `C-u' with `alternatives' - use 1, not 4.
(if (wholenump icicle-successive-grab-count) 1 -1)
(if (wholenump icicle-successive-grab-count) ; Increment count.
(+ icicle-successive-grab-count (abs (prefix-numeric-value arg)))
(- icicle-successive-grab-count (abs (prefix-numeric-value arg))))))
(setq icicle-successive-grab-count 1))) ; First `M-.' - reset count.
(let ((things ""))
(save-excursion
(with-current-buffer (cadr (buffer-list))
(setq things (buffer-substring-no-properties
(point)
(save-excursion (funcall fwd-thing-fn icicle-successive-grab-count)
(point))))))
(icicle-insert-thing things)))))))
(defun icicle-signum (num)
"Return 1 if NUM is positive, -1 if negative, 0 if zero."
(cond ((< num 0) -1) ((> num 0) 1) (t 0)))
(defun icicle-insert-thing (text &optional no-replace-p)
"Insert TEXT in the minibuffer.
TEXT replaces the last text that was inserted, if this command repeats
the last and NO-REPLACE-P is nil."
(when (and (stringp text) (not (string= "" text)))
(remove-text-properties 0 (length text) '(face nil) text)
(when (and (eq last-command this-command) (not no-replace-p)
icicle-insert-string-at-pt-start) ; Ensure that we've defined the ends.
(delete-region icicle-insert-string-at-pt-start icicle-insert-string-at-pt-end))
(setq icicle-insert-string-at-pt-start (point))
(insert text)
(setq icicle-insert-string-at-pt-end (point))))
;;;###autoload
(defun icicle-insert-string-from-variable (askp) ; Bound to `C-=' in minibuffer.
"Insert text into the minibuffer from a variable.
By default, the variable is user option `icicle-input-string'. To
insert from a different variable, use a prefix argument. You are then
prompted for the variable to use. Completion candidates for this
include all string-valued variables.
You can use command `icicle-save-string-to-variable' to save a string
to a variable. Typically, you store a regexp or part of a regexp in
the variable. This command is bound in the minibuffer to `C-=', by
default. This is especially useful when used with command
`icicle-search'.
Some regexps that you might want to assign to variables:
\"[A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\" ; Email address
\"\\\\([0-9]+\\\.[0-9]+\\\.[0-9]+\\\.[0-9]+\\\\)\" ; IP address
\"[0-9]\\\\\\\={4\\\\}-[0-9]\\\\\\\={2\\\\}-[0-9]\\\\\\\={2\\\\}\" ; Date: 2006-04-14, Time:
\"^[ \\\=\\t]*[0-9]?[0-9]\\\\([:.]?[0-9][0-9]\\\\)?\\\\(am\\\\|pm\\\\|AM\\\\|PM\\\\)?\"
\"`\\\\(\\\\sw\\\\sw+\\\\)'\" ; Words inside `_'
\"\\\\*.*\\\\*\" ; Special buffer name: *_*
Standard Emacs Lisp libraries are full of regexps that you can assign
to variables for use with `C-='.
See `align.el' for regexps for programming languages.
See `url-dav.el' for regexps matching iso8601 dates.
See `rmail.el', `sendmail.el', and `mh-show.el' for regexps matching
mail-header fields.
Imenu regexps occurring as parts of different values of
`imenu-generic-expression' for different buffer types can be used as
variable values for `C-='. They all work fine with `icicle-search',
turning it into a browser or navigator for the given mode.
See, for example, `generic-x.el' and `lisp-mode.el'. Here is a regexp
for Javascript function definitions from `generic-x.el':
\"^function\\\\s-+\\\\([A-Za-z0-9_]+\\\\)\"
And `lisp-imenu-generic-expression' (in `lisp-mode.el') provides
regexps for Lisp function, variable, and type definitions. Here is
the variable-definition regexp:
\"^\\\\s-*(\\\\(def\\\\(c\\\\(onst\\\\(ant\\\\)?\\\\|ustom\\\\)\\\\|ine-symbol-macro\\\\|
parameter\\\\|var\\\\)\\\\)\\\\s-+\\\\(\\\\(\\\\sw\\\\|\\\\s_\\\\)+\\\\)\"
Command `icicle-imenu' exploits this to automatically let you browse
definitions. It is a specialization of `icicle-search' for Imenu.
For more useful regexps, grep for `font-lock-keywords' in Emacs `lisp'
directory and subdirs.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-insert-string-from-variable]')."
(interactive "P")
(when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer))
(save-selected-window
(select-window (minibuffer-window))
(if askp
(let* ((icicle-whole-candidate-as-text-prop-p nil)
;; If we didn't use this here we'd at least have to bind it to
;; `orig-must-pass-after-match-predicate', because of `icicle-execute-extended-command'.
(icicle-must-pass-after-match-predicate #'(lambda (s)
(let ((sym (intern-soft s)))
(and sym (boundp (intern s))
(condition-case nil
(icicle-var-is-of-type-p
sym '(string color regexp)
'inherit-or-value)
(error nil))))))
(enable-recursive-minibuffers t)
(var
(intern (completing-read "Insert text from variable: " obarray nil nil nil
(if (boundp 'variable-name-history)
'variable-name-history
'icicle-variable-name-history))))
;; Make sure we use the buffer-local value of the variable, if there is one.
(text
(with-current-buffer (cadr (buffer-list)) (symbol-value var))))
(icicle-insert-thing text 'no-replace))
(icicle-insert-thing icicle-input-string 'no-replace))))
;;;###autoload
(defun icicle-insert-list-join-string () ; Bound to `C-M-j' in minibuffer during completion.
"Insert `icicle-list-join-string' in the minibuffer.
Then, if `1on1-fit-minibuffer-frame-flag' is defined and non-nil, fit
a standalone minibuffer frame to the new minibuffer contents.
You need library `fit-frame.el' for the frame-fitting part."
(interactive)
(icicle-insert-thing icicle-list-join-string 'no-replace)
(let ((len (length icicle-list-join-string)))
(when (and (string= "\C-j" (substring icicle-list-join-string (1- len) len))
(boundp '1on1-fit-minibuffer-frame-flag) ; In `oneonone.el'.
1on1-fit-minibuffer-frame-flag
(require 'fit-frame nil t))
(1on1-fit-minibuffer-frame))))
;;;###autoload
(defun icicle-dispatch-M-q (&optional arg) ; Bound to `M-q' in minibuffer.
"Do the right thing for `M-q'.
If searching, call `icicle-toggle-search-whole-word'.
Otherwise, call `icicle-insert-key-description'.
Bound to `M-q' in the minibuffer."
(interactive "P") ; Argument is ignored for `icicle-toggle-search-whole-word'.
(cond (icicle-searching-p (icicle-toggle-search-whole-word))
(t (icicle-insert-key-description arg))))
;; Top-level commands. Could instead be in `icicles-cmd2.el'.
;;;###autoload
(defalias 'toggle-icicle-search-whole-word 'icicle-toggle-search-whole-word)
;;;###autoload
(defun icicle-toggle-search-whole-word () ; Bound to `M-q' in minibuffer during Icicles search.
"Toggle the value of `icicle-search-whole-word-flag'.
The new value takes effect for the next Icicles search command.
Bound to `M-q' in the minibuffer when searching."
(interactive)
(setq icicle-search-whole-word-flag (not icicle-search-whole-word-flag))
(icicle-msg-maybe-in-minibuffer
"Whole-word searching is now %s, starting with next search"
(icicle-propertize (if icicle-search-whole-word-flag "ON" "OFF") 'face 'icicle-msg-emphasis)))
;;;###autoload
(defun icicle-insert-key-description (toggle-angle-brackets-p) ; Bound to `M-q' in minibuffer.
"Read key and insert its description.
For example, if the key read is ^F, then \"C-f\" is inserted.
For Emacs 21+, `icicle-key-descriptions-use-<>-flag' determines
whether angle brackets (`<', `>') are used for named keys, such as
function keys, but a prefix argument reverses the meaning of
`icicle-key-descriptions-use-<>-flag'.
Bound to `M-q' in the minibuffer during key completion (Emacs 22+)."
(interactive "P")
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(let* ((enable-recursive-minibuffers t)
(key (progn (minibuffer-message " [Quoting key]") (read-event))))
(insert (if (< emacs-major-version 21)
(single-key-description key)
(single-key-description key (if toggle-angle-brackets-p
icicle-key-descriptions-use-<>-flag
(not icicle-key-descriptions-use-<>-flag)))))))
;;;###autoload
(defun icicle-pp-eval-expression-in-minibuffer (insert-value) ; Bound to `M-:' in minibuffer.
"Evaluate an Emacs-Lisp expression and pretty-print its value.
This just calls `pp-eval-expression' from a recursive minibuffer."
(interactive "P")
(when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer))
(let ((enable-recursive-minibuffers t))
(call-interactively 'icicle-pp-eval-expression))
(select-window (minibuffer-window))
(select-frame-set-input-focus (selected-frame)))
;;;###autoload
(defun icicle-insert-newline-in-minibuffer (arg) ; Bound to `C-j' in minibuffer.
"Insert a newline character (`C-j'), in the minibuffer.
Then, if `1on1-fit-minibuffer-frame-flag' is defined and non-nil, fit
a standalone minibuffer frame to the new minibuffer contents.
You need library `fit-frame.el' for the frame-fitting part."
(interactive "p")
(icicle-self-insert arg)
(when (and (boundp '1on1-fit-minibuffer-frame-flag) ; In `oneonone.el'.
1on1-fit-minibuffer-frame-flag
(require 'fit-frame nil t))
(1on1-fit-minibuffer-frame)))
;; Bound in minibuffer to keys in `icicle-modal-cycle-down-keys' (`down', `wheel-down').
;;;###autoload
(defun icicle-next-candidate-per-mode (&optional nth)
"Replace input by NTH next completion candidate.
Default value of NTH is 1, meaning use the next candidate.
Negative NTH means use a previous, not subsequent, candidate.
Uses the next prefix or apropos completion command, depending on
`icicle-current-completion-mode'. If that is nil and
`icicle-default-cycling-mode' is non-nil, uses the next history
element instead.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-candidate-per-mode]')."
(interactive)
(unless nth (setq nth 1))
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(case icicle-current-completion-mode
(prefix
(setq this-command
(if (wholenump nth) 'icicle-next-prefix-candidate 'icicle-previous-prefix-candidate))
(icicle-next-prefix-candidate nth))
(apropos
(setq this-command
(if (wholenump nth) 'icicle-next-apropos-candidate 'icicle-previous-apropos-candidate))
(icicle-next-apropos-candidate nth))
((nil)
(when icicle-default-cycling-mode (next-history-element (or nth 1))))))
;; Bound in minibuffer to keys in `icicle-modal-cycle-up-keys' (`up', `wheel-up').
;;;###autoload
(defun icicle-previous-candidate-per-mode (&optional nth)
"Replace input by NTH previous completion candidate.
Default value of NTH is 1, meaning use the previous candidate.
Negative NTH means use a subsequent, not previous, candidate.
Uses the previous prefix or apropos completion command, depending on
`icicle-current-completion-mode'. If that is nil and
`icicle-default-cycling-mode' is non-nil, uses the previous history
element instead.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-candidate-per-mode]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-next-candidate-per-mode (- (or nth 1))))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-previous-keys' (`home').
(put 'icicle-previous-prefix-candidate 'icicle-cycling-command 'backward)
(put 'icicle-previous-prefix-candidate 'icicle-prefix-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-prefix-candidate (&optional nth)
"Replace input by NTH previous prefix completion for an input.
Default value of NTH is 1, meaning use the previous prefix completion.
Negative NTH means use a subsequent, not previous, prefix completion.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-prefix-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(setq nth (or nth 1))
(icicle-next-prefix-candidate (- nth)))
;; Bound in minibuffer to keys in `icicle-next-cycle-previous-keys' (`end').
(put 'icicle-next-prefix-candidate 'icicle-cycling-command 'forward)
(put 'icicle-next-prefix-candidate 'icicle-prefix-cycling-command 'forward)
;;;###autoload
(defun icicle-next-prefix-candidate (&optional nth)
"Replace input by NTH next prefix completion for an input.
Default value of NTH is 1, meaning use the next prefix completion.
Negative NTH means use a previous, not subsequent, prefix completion.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-prefix-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(setq icicle-current-completion-mode 'prefix
icicle-next-apropos-complete-cycles-p nil)
(icicle-next-candidate nth (if (icicle-file-name-input-p)
'icicle-file-name-prefix-candidates
'icicle-prefix-candidates)))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-previous-keys' (`prior').
(put 'icicle-previous-apropos-candidate 'icicle-cycling-command 'backward)
(put 'icicle-previous-apropos-candidate 'icicle-apropos-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-apropos-candidate (&optional nth)
"Replace input by NTH previous apropos completion for an input.
Default value of NTH is 1, meaning use the previous apropos completion.
Negative NTH means use a subsequent, not previous, apropos completion.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-apropos-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(setq nth (or nth 1))
(icicle-next-apropos-candidate (- nth)))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-next-keys' (`next').
(put 'icicle-next-apropos-candidate 'icicle-cycling-command 'forward)
(put 'icicle-next-apropos-candidate 'icicle-apropos-cycling-command 'forward)
;;;###autoload
(defun icicle-next-apropos-candidate (&optional nth)
"Replace input by NTH next apropos completion for an input.
Default value of NTH is 1, meaning use the next apropos completion.
Negative NTH means use a previous, not subsequent, apropos completion.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-apropos-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(setq icicle-current-completion-mode 'apropos
icicle-next-prefix-complete-cycles-p nil)
(icicle-next-candidate nth (if (icicle-file-name-input-p)
'icicle-file-name-apropos-candidates
'icicle-apropos-candidates)
'regexp-p))
;; Bound in minibuffer to keys in `icicle-modal-cycle-up-action-keys' (`C-up').
;;;###autoload
(defun icicle-previous-candidate-per-mode-action (&optional nth)
"`icicle-previous-candidate-per-mode' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-candidate-per-mode-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-candidate-per-mode #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-modal-cycle-up-alt-action-keys' (`C-S-up').
;;;###autoload
(defun icicle-previous-candidate-per-mode-alt-action (&optional nth)
"`icicle-previous-candidate-per-mode' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-candidate-per-mode-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-candidate-per-mode #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-modal-cycle-down-action-keys' (`C-down').
;;;###autoload
(defun icicle-next-candidate-per-mode-action (&optional nth)
"`icicle-next-candidate-per-mode' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-candidate-per-mode-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-candidate-per-mode #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-modal-cycle-down-alt-action-keys' (`C-S-down').
;;;###autoload
(defun icicle-next-candidate-per-mode-alt-action (&optional nth)
"`icicle-next-candidate-per-mode' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-candidate-per-mode-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-candidate-per-mode #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-modal-cycle-up-help-keys' (`C-M-up').
;;;###autoload
(defun icicle-previous-candidate-per-mode-help (&optional nth)
"`icicle-previous-candidate-per-mode' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-candidate-per-mode-help]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-candidate-per-mode #'icicle-help-on-candidate nth))
;; Bound in minibuffer to keys in `icicle-modal-cycle-down-help-keys' (`C-M-down').
;;;###autoload
(defun icicle-next-candidate-per-mode-help (&optional nth)
"`icicle-next-candidate-per-mode' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-candidate-per-mode'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-candidate-per-mode-help]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-candidate-per-mode #'icicle-help-on-candidate nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-previous-action-keys' (`C-home').
(put 'icicle-previous-prefix-candidate-action 'icicle-cycling-command 'backward)
(put 'icicle-previous-prefix-candidate-action 'icicle-prefix-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-prefix-candidate-action (&optional nth)
"`icicle-previous-prefix-candidate' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-prefix-candidate-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-prefix-candidate #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-next-action-keys' (`C-end').
(put 'icicle-next-prefix-candidate-action 'icicle-cycling-command 'forward)
(put 'icicle-next-prefix-candidate-action 'icicle-prefix-cycling-command 'forward)
;;;###autoload
(defun icicle-next-prefix-candidate-action (&optional nth)
"`icicle-next-prefix-candidate' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-prefix-candidate-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-prefix-candidate #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-previous-action-keys' (`C-prior').
(put 'icicle-previous-apropos-candidate-action 'icicle-cycling-command 'backward)
(put 'icicle-previous-apropos-candidate-action 'icicle-apropos-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-apropos-candidate-action (&optional nth)
"`icicle-previous-apropos-candidate' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-apropos-candidate-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-apropos-candidate #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-next-action-keys' (`C-next').
(put 'icicle-next-apropos-candidate-action 'icicle-cycling-command 'forward)
(put 'icicle-next-apropos-candidate-action 'icicle-apropos-cycling-command 'forward)
;;;###autoload
(defun icicle-next-apropos-candidate-action (&optional nth)
"`icicle-next-apropos-candidate' and `icicle-candidate-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-apropos-candidate-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-apropos-candidate #'icicle-candidate-action nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-previous-alt-action-keys' (`C-S-home').
(put 'icicle-previous-prefix-candidate-alt-action 'icicle-cycling-command 'backward)
(put 'icicle-previous-prefix-candidate-alt-action 'icicle-prefix-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-prefix-candidate-alt-action (&optional nth)
"`icicle-previous-prefix-candidate' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-prefix-candidate-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-prefix-candidate #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-next-alt-action-keys' (`C-S-end').
(put 'icicle-next-prefix-candidate-alt-action 'icicle-cycling-command 'forward)
(put 'icicle-next-prefix-candidate-alt-action 'icicle-prefix-cycling-command 'forward)
;;;###autoload
(defun icicle-next-prefix-candidate-alt-action (&optional nth)
"`icicle-next-prefix-candidate' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-prefix-candidate-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-prefix-candidate #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-previous-alt-action-keys' (`C-S-prior').
(put 'icicle-previous-apropos-candidate-alt-action 'icicle-cycling-command 'backward)
(put 'icicle-previous-apropos-candidate-alt-action 'icicle-apropos-cycling-command 'backward)
;;;###autoload
(defun icicle-previous-apropos-candidate-alt-action (&optional nth)
"`icicle-previous-apropos-candidate' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-previous-apropos-candidate-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-apropos-candidate #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-next-alt-action-keys' (`C-S-next').
(put 'icicle-next-apropos-candidate-alt-action 'icicle-cycling-command 'forward)
(put 'icicle-next-apropos-candidate-alt-action 'icicle-apropos-cycling-command 'forward)
;;;###autoload
(defun icicle-next-apropos-candidate-alt-action (&optional nth)
"`icicle-next-apropos-candidate' and `icicle-candidate-alt-action'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-next-apropos-candidate-alt-action]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-apropos-candidate #'icicle-candidate-alt-action nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-previous-help-keys' (`C-M-home').
(put 'icicle-help-on-previous-prefix-candidate 'icicle-cycling-command 'backward)
(put 'icicle-help-on-previous-prefix-candidate 'icicle-prefix-cycling-command 'backward)
;;;###autoload
(defun icicle-help-on-previous-prefix-candidate (&optional nth)
"`icicle-previous-prefix-candidate' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-help-on-previous-prefix-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-prefix-candidate #'icicle-help-on-candidate nth))
;; Bound in minibuffer to keys in `icicle-prefix-cycle-next-help-keys' (`C-M-end').
(put 'icicle-help-on-next-prefix-candidate 'icicle-cycling-command 'forward)
(put 'icicle-help-on-next-prefix-candidate 'icicle-prefix-cycling-command 'forward)
;;;###autoload
(defun icicle-help-on-next-prefix-candidate (&optional nth)
"`icicle-next-prefix-candidate' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-prefix-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-help-on-next-prefix-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-prefix-candidate #'icicle-help-on-candidate nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-previous-help-keys' (`C-M-prior').
(put 'icicle-help-on-previous-apropos-candidate 'icicle-cycling-command 'backward)
(put 'icicle-help-on-previous-apropos-candidate 'icicle-apropos-cycling-command 'backward)
;;;###autoload
(defun icicle-help-on-previous-apropos-candidate (&optional nth)
"`icicle-previous-apropos-candidate' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-previous-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-help-on-previous-apropos-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-previous-apropos-candidate #'icicle-help-on-candidate nth))
;; Bound in minibuffer to keys in `icicle-apropos-cycle-previous-help-keys' (`C-M-next').
(put 'icicle-help-on-next-apropos-candidate 'icicle-cycling-command 'forward)
(put 'icicle-help-on-next-apropos-candidate 'icicle-apropos-cycling-command 'forward)
;;;###autoload
(defun icicle-help-on-next-apropos-candidate (&optional nth)
"`icicle-next-apropos-candidate' and `icicle-help-on-candidate'.
Option `icicle-act-before-cycle-flag' determines which occurs first.
Optional argument NTH is as for `icicle-next-apropos-candidate'.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-help-on-next-apropos-candidate]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-successive-action #'icicle-next-apropos-candidate #'icicle-help-on-candidate nth))
(defun icicle-successive-action (nav-fn action-fn nth)
"Call NAV-FN and ACTION-FN. Pass argument NTH to NAV-FN.
Set `icicle-current-completion-mode'.
The order between NAV-FN and ACTION-FN respects the value of
`icicle-act-before-cycle-flag'."
;; Set mode only if known. Otherwise, leave it alone (e.g. for per-mode functions).
(cond ((get nav-fn 'icicle-apropos-cycling-command)
(setq icicle-current-completion-mode 'apropos
icicle-next-prefix-complete-cycles-p nil))
((get nav-fn 'icicle-prefix-cycling-command)
(setq icicle-current-completion-mode 'prefix
icicle-next-apropos-complete-cycles-p nil)))
;; We bind `icicle-acting-on-next/prev' to non-nil (and the direction) while calling the action
;; function. This is used by Icicles search-and-replace (`icicle-search-highlight-and-maybe-replace')
;; to ensure the correct candidate number for a series of replacements.
;; (Not currently used for the `icicle-act-before-cycle-flag' case, but we do it there also, anyway.)
(cond (icicle-act-before-cycle-flag
(let ((icicle-acting-on-next/prev (get nav-fn 'icicle-cycling-command)))
(save-excursion (save-selected-window (funcall action-fn))))
(funcall nav-fn nth))
(t
;; Inhibit showing help in mode-line while moving to next/previous candidate
;; in `*Completions*', because help sits for `icicle-help-in-mode-line-delay' sec.
;; Display the help after we do the action.
(let ((icicle-help-in-mode-line-delay 0)) (funcall nav-fn nth))
(let ((icicle-acting-on-next/prev (get nav-fn 'icicle-cycling-command)))
(save-excursion (save-selected-window (funcall action-fn))))
(when (stringp icicle-last-completion-candidate)
(icicle-show-help-in-mode-line icicle-last-completion-candidate)))))
;; Bound in minibuffer to keys in `icicle-prefix-complete-keys' (`TAB').
(put 'icicle-prefix-complete 'icicle-cycling-command t)
(put 'icicle-prefix-complete 'icicle-prefix-cycling-command t)
(put 'icicle-prefix-complete 'icicle-completing-command t)
(put 'icicle-prefix-complete 'icicle-prefix-completing-command t)
;;;###autoload
(defun icicle-prefix-complete ()
"Complete the minibuffer contents as far as possible, as a prefix.
Repeat this to cycle among candidate completions.
If no characters can be completed, display the possible completions.
Candidate completions are appropriate names whose prefix is the
minibuffer input, where appropriateness is determined by the context
\(command, variable, and so on).
Return nil if there is no valid completion.
Otherwise, return the list of completion candidates.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-prefix-complete]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(unless (string= icicle-dot-string-internal ".")
(icicle-convert-dots t t)
(setq icicle-dot-string-internal "."))
(icicle-prefix-complete-1))
;; Bound in minibuffer to keys in `icicle-prefix-complete-no-display-keys' (`C-M-TAB').
(put 'icicle-prefix-complete-no-display 'icicle-cycling-command t)
(put 'icicle-prefix-complete-no-display 'icicle-prefix-cycling-command t)
(put 'icicle-prefix-complete-no-display 'icicle-completing-command t)
(put 'icicle-prefix-complete-no-display 'icicle-prefix-completing-command t)
;;;###autoload
(defun icicle-prefix-complete-no-display (&optional no-msg-p) ; Bound to `C-M-TAB' in minibuffer.
"Like `icicle-prefix-complete', but without displaying `*Completions*'.
Optional arg NO-MSG-P non-nil means do not show a minibuffer message
indicating that candidates were updated.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-prefix-complete-no-display]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-prefix-complete-1 (if no-msg-p 'no-msg 'no-display)))
;; Bound in minibuffer to keys in `icicle-word-completion-keys' (`M-SPC').
(put 'icicle-prefix-word-complete 'icicle-cycling-command t)
(put 'icicle-prefix-word-complete 'icicle-prefix-cycling-command t)
(put 'icicle-prefix-word-complete 'icicle-completing-command t)
(put 'icicle-prefix-word-complete 'icicle-prefix-completing-command t)
;;;###autoload
(defun icicle-prefix-word-complete ()
"Complete the minibuffer contents at most a single word.
Repeating this completes additional words.
Spaces and hyphens in candidates are considered word separators.
If only a single candidate matches, the input is completed entirely.
Return nil if there is no valid completion, else t.
You can use this command only from the minibuffer (`\\<minibuffer-local-completion-map>\
\\[icicle-prefix-word-complete]')."
(interactive)
(when (interactive-p) (icicle-barf-if-outside-minibuffer))
(icicle-prefix-complete-1 nil t))
(defun icicle-prefix-complete-1 (&optional no-display-p word-p)
"Helper function for `icicle-prefix-complete(-no-display)'.
Return the list of completion candidates.
Optional argument NO-DISPLAY-P non-nil means do not display buffer
`*Completions*'. If the value is `no-msg', then do not show any
message either. NO-DISPLAY-P is passed to
`icicle-display-candidates-in-Completions' as its second arg.
Optional argument WORD-P non-nil means complete only a word at a time."
(let ((ipc1-was-cycling-p icicle-cycling-p)
(mode-line-help nil))
(setq icicle-current-input (if (and icicle-last-input
icicle-cycling-p
(not icicle-edit-update-p)
(eq icicle-current-completion-mode 'prefix)
(or (not word-p)
(eq this-command last-command))
(symbolp last-command)
(or (get last-command 'icicle-cycling-command)
(get last-command 'icicle-action-command))
icicle-completion-candidates)
icicle-last-input
(if (icicle-file-name-input-p)
(abbreviate-file-name
(icicle-input-from-minibuffer 'leave-envar))
(icicle-input-from-minibuffer)))
icicle-current-completion-mode 'prefix
icicle-next-apropos-complete-cycles-p nil
icicle-input-fail-pos nil
icicle-cycling-p nil)
(when icicle-edit-update-p (setq icicle-next-prefix-complete-cycles-p nil))
(let ((word-complete-input "")
(input-before-completion icicle-current-input)
return-value)
(unless (and (stringp icicle-current-input) (stringp icicle-last-input)
(string= icicle-current-input icicle-last-input)
(or (get last-command 'icicle-prefix-completing-command)
(get last-command 'icicle-action-command))
(not word-p))
(unless (or icicle-edit-update-p (get-buffer-window "*Completions*" 0) no-display-p)
(message "Computing completion candidates..."))
(if (not word-p)
(setq icicle-completion-candidates
(icicle-condition-case-no-debug nil
(if (icicle-file-name-input-p)
(icicle-file-name-prefix-candidates icicle-current-input)
(icicle-prefix-candidates icicle-current-input))
(error icicle-completion-candidates))) ; No change if completion error.
;; Complete a word. Save input before trying to complete.
;; Update `icicle-current-input': `minibuffer-complete-word' might have completed the input
;; beyond a complete candidate - e.g. `forwar-char' to `forward-char-'.
(setq word-complete-input (icicle-input-from-minibuffer)
return-value
(let ((temp-buffer-show-hook nil) ; Don't let it fit frame here.
(completion-auto-help nil) ; Don't show `*Completions*'.
(minibuffer-message-timeout 0)) ; No timeout.
(icicle-clear-minibuffer)
(insert icicle-current-input)
(save-selected-window (minibuffer-complete-word)))
icicle-current-input (icicle-input-from-minibuffer)) ; Update input.
;; If incremental compl., or completed some, or not repeated, then update input and recompute.
(when (or icicle-edit-update-p
(> (length icicle-current-input) (length word-complete-input))
(not (eq this-command last-command)))
(setq word-complete-input icicle-current-input
icicle-completion-candidates (icicle-condition-case-no-debug nil
(if (icicle-file-name-input-p)
(icicle-file-name-prefix-candidates
icicle-current-input)
(icicle-prefix-candidates icicle-current-input))
(error icicle-completion-candidates)))))
(message nil)) ; Clear out "Computing completion candidates..." message.
(unless word-p (setq return-value icicle-completion-candidates)) ; Word returns special value.
(icicle-save-or-restore-input)
(cond ((null icicle-completion-candidates)
(setq icicle-nb-of-other-cycle-candidates 0)
(let ((icicle-incremental-completion-flag ; Upgrade if OK for explicit.
(or (memq icicle-highlight-input-completion-failure
'(explicit-strict explicit explicit-remote))
icicle-incremental-completion-flag)))
(icicle-highlight-input-noncompletion))
(save-selected-window (icicle-remove-Completions-window))
(run-hooks 'icicle-no-match-hook)
(unless (eq no-display-p 'no-msg)
(minibuffer-message (case (icicle-current-TAB-method)
(fuzzy " [No fuzzy completions]")
(vanilla " [No vanilla completions]")
(swank " [No swank (fuzzy symbol) completions]")
(t " [No prefix completions]")))))
((null (cdr icicle-completion-candidates)) ; Single candidate. Update minibuffer.
(setq icicle-nb-of-other-cycle-candidates 0)
(cond ((and icicle-edit-update-p (not icicle-expand-input-to-common-match-flag))
(when icicle-incremental-completion-p (sit-for icicle-incremental-completion-delay))
(icicle-display-candidates-in-Completions nil no-display-p))
(t
(setq icicle-current-input
(if (not (icicle-file-name-input-p))
;; Transfer any `icicle-whole-candidate' property from
;; candidate to `icicle-current-input', so things that use
;; `icicle-candidates-alist' will work.
(car icicle-completion-candidates)
(if (string= "" icicle-current-input)
(or (icicle-file-name-directory icicle-current-input)
"")
(directory-file-name
(icicle-abbreviate-or-expand-file-name
(car icicle-completion-candidates)
(icicle-file-name-directory icicle-current-input))))))
(unless (and icicle-edit-update-p
(or (not icicle-incremental-completion-p)
(not (sit-for icicle-incremental-completion-delay))))
(icicle-clear-minibuffer)
(let ((cand (car icicle-completion-candidates)))
(if (icicle-file-name-input-p)
(cond ((string= "" cand) ; This indicates an empty dir.
(setq icicle-last-completion-candidate icicle-current-input))
((eq ?\/ (aref cand (1- (length cand))))
;; Add `/', so cycling expands dir.
(setq icicle-current-input (file-name-as-directory
icicle-current-input)
icicle-last-completion-candidate icicle-current-input))
(t ; Non-dir - use the candidate file, but without any dir.
(setq icicle-last-completion-candidate
(icicle-file-name-nondirectory cand))))
(setq icicle-last-completion-candidate cand)))
(let ((inserted (if (and (icicle-file-name-input-p) insert-default-directory
(or (not (member icicle-last-completion-candidate
icicle-extra-candidates))
icicle-extra-candidates-dir-insert-p))
(icicle-abbreviate-or-expand-file-name
icicle-last-completion-candidate
(icicle-file-name-directory-w-default icicle-current-input))
icicle-last-completion-candidate)))
(insert inserted)
(when (and (icicle-file-name-input-p)
(icicle-file-directory-p (icicle-abbreviate-or-expand-file-name
inserted)))
(setq icicle-default-directory (icicle-abbreviate-or-expand-file-name
inserted))))
(save-selected-window (icicle-remove-Completions-window))
(icicle-transform-sole-candidate))))
(unless (boundp 'icicle-prefix-complete-and-exit-p)
(icicle-highlight-complete-input)
(cond ((and icicle-top-level-when-sole-completion-flag
(or (and (not (and (boundp 'icicle-ido-like-mode) icicle-ido-like-mode))
(not icicle-files-ido-like-flag))
(and (not (icicle-file-name-input-p))
(not icicle-abs-file-candidates))
(string= "" (car icicle-completion-candidates)) ; Empty directory
(not (eq ?\/
(aref (car icicle-completion-candidates)
(1- (length (car icicle-completion-candidates)))))))
(sit-for icicle-top-level-when-sole-completion-delay))
(set minibuffer-history-variable
(cons icicle-current-input (symbol-value minibuffer-history-variable)))
(icicle-condition-case-no-debug icicle-prefix-complete-1
(throw 'icicle-read-top
(if (and (icicle-file-name-input-p) insert-default-directory
(or (not (member icicle-current-input
icicle-extra-candidates))
icicle-extra-candidates-dir-insert-p))
(expand-file-name icicle-current-input)
icicle-current-input))
(no-catch (icicle-retrieve-last-input)
icicle-current-input)
(error (message "%s" (error-message-string icicle-prefix-complete-1)))))
((and icicle-edit-update-p (not (eq no-display-p 'no-msg)))
(minibuffer-message
(format (case (icicle-current-TAB-method)
(fuzzy " [One fuzzy completion: %s]")
(vanilla " [One vanilla completion: %s]")
(swank " [One swank (fuzzy symbol) completion: %s]")
(t " [One prefix completion: %s]"))
icicle-current-input))
(setq mode-line-help icicle-current-input))
((not (eq no-display-p 'no-msg))
(minibuffer-message (case (icicle-current-TAB-method)
(fuzzy " [Sole fuzzy completion]")
(vanilla " [Sole vanilla completion]")
(swank " [Sole swank (fuzzy symbol) completion]")
(t " [Sole prefix completion]")))
(setq mode-line-help icicle-current-input)))))
(t ; Multiple candidates.
(when (and icicle-edit-update-p icicle-incremental-completion-p
(sit-for icicle-incremental-completion-delay))
(icicle-display-candidates-in-Completions nil no-display-p))
(when (icicle-prefix-complete-2 word-p)
(setq mode-line-help (icicle-minibuf-input-sans-dir icicle-current-input)))
(cond (;; Candidates visible. If second prefix complete, cycle, else update candidates.
(get-buffer-window "*Completions*" 0)
(if (and (or ipc1-was-cycling-p icicle-next-prefix-complete-cycles-p)
(get icicle-last-completion-command 'icicle-prefix-completing-command)
(if word-p
;; Word completion cycles only if both of these are true:
;; * Input is not yet complete (null `return-value').
;; * Either last command was an edit and input does not end in `-',
;; or the current input is from cycling.
;; E.g. `M-x fo M-SPC r M-SPC' cycles among foreground-color etc.
(and (not return-value)
(or (and (not (or (get last-command
'icicle-prefix-completing-command)
(get last-command 'icicle-action-command)))
(not (eq (aref icicle-current-input
(1- (length icicle-current-input)))
?-)))
(not (string= icicle-last-input word-complete-input))))
(or (get last-command 'icicle-prefix-completing-command)
(get last-command 'icicle-action-command))))
;; Second prefix complete in a row. Cycle down.
(icicle-next-candidate 1 (if (icicle-file-name-input-p)
'icicle-file-name-prefix-candidates
'icicle-prefix-candidates))
;; User did something else (e.g. changed input). Update the candidates.
(icicle-display-candidates-in-Completions nil no-display-p)))
(;; No candidates shown. Could be first completion or could follow `C-M-(S-)TAB'.
icicle-TAB-shows-candidates-flag
(if (not (and (or ipc1-was-cycling-p icicle-next-prefix-complete-cycles-p)
(get icicle-last-completion-command
'icicle-prefix-completing-command)
(or (get last-command 'icicle-prefix-completing-command)
(get last-command 'icicle-action-command))
(not word-p)))
;; First prefix complete is enough to update candidates.
(icicle-display-candidates-in-Completions nil no-display-p)
;; Second prefix complete. If `TAB', then it follows `C-M-TAB', so show window.
(unless no-display-p (icicle-display-candidates-in-Completions nil))
(icicle-next-candidate 1 (if (icicle-file-name-input-p)
'icicle-file-name-prefix-candidates
'icicle-prefix-candidates))))
(;; No candidates shown. Second prefix complete.
;; If NO-DISPLAY-P and either not WORD-P or input is complete, then cycle down.
;; Else, vanilla Emacs: second `TAB' shows candidates.
(and (get icicle-last-completion-command 'icicle-prefix-completing-command)
(or (get last-command 'icicle-prefix-completing-command)
(get last-command 'icicle-action-command))
completion-auto-help)
(if (or (not no-display-p) (and word-p (not return-value)))
(icicle-display-candidates-in-Completions nil)
(icicle-next-candidate 1 (if (icicle-file-name-input-p)
'icicle-file-name-prefix-candidates
'icicle-prefix-candidates))))
;; Input is complete, but exist other candidates with same prefix.
((and (member icicle-current-input icicle-completion-candidates)
(not (eq no-display-p 'no-msg)))
(minibuffer-message " [Complete, but not unique]")))))
(setq icicle-last-completion-command (if word-p
'icicle-prefix-word-complete
(if no-display-p
'icicle-prefix-complete-no-display
'icicle-prefix-complete))
icicle-next-prefix-complete-cycles-p (equal input-before-completion
(icicle-input-from-minibuffer 'leave-envvars)))
(when mode-line-help (icicle-show-help-in-mode-line mode-line-help))
return-value)))
(defun icicle-prefix-complete-2 (word-p)
"Replace minibuffer content with highlighted current input.
Call `icicle-highlight-initial-whitespace'.
If completing file name, set default dir based on current completion.