From fec1262f6357663cea44faaef949e770ec26f4aa Mon Sep 17 00:00:00 2001 From: michener Date: Fri, 13 Aug 2010 17:44:58 +0000 Subject: [PATCH] Add Icicles to emacs config git-svn-id: http://photonzero.com/dotfiles/trunk@58 23f722f6-122a-0410-8cef-c75bd312dd78 --- .emacs.d/icicles/icicles-chg.el | 7310 ++++++++++++++++++++++++++++++++ .emacs.d/icicles/icicles-cmd1.el | 6036 +++++++++++++++++++++++++++ .emacs.d/icicles/icicles-cmd2.el | 5312 ++++++++++++++++++++++++ .emacs.d/icicles/icicles-doc1.el | 6617 +++++++++++++++++++++++++++++ .emacs.d/icicles/icicles-doc2.el | 8539 ++++++++++++++++++++++++++++++++++++++ .emacs.d/icicles/icicles-face.el | 681 +++ .emacs.d/icicles/icicles-fn.el | 5972 ++++++++++++++++++++++++++ .emacs.d/icicles/icicles-mac.el | 631 +++ .emacs.d/icicles/icicles-mcmd.el | 6690 +++++++++++++++++++++++++++++ .emacs.d/icicles/icicles-mode.el | 3570 ++++++++++++++++ .emacs.d/icicles/icicles-opt.el | 3209 ++++++++++++++ .emacs.d/icicles/icicles-var.el | 1362 ++++++ .emacs.d/icicles/icicles.el | 1196 ++++++ .emacs.d/init.el | 12 + 14 files changed, 57137 insertions(+) create mode 100644 .emacs.d/icicles/icicles-chg.el create mode 100644 .emacs.d/icicles/icicles-cmd1.el create mode 100644 .emacs.d/icicles/icicles-cmd2.el create mode 100644 .emacs.d/icicles/icicles-doc1.el create mode 100644 .emacs.d/icicles/icicles-doc2.el create mode 100644 .emacs.d/icicles/icicles-face.el create mode 100644 .emacs.d/icicles/icicles-fn.el create mode 100644 .emacs.d/icicles/icicles-mac.el create mode 100644 .emacs.d/icicles/icicles-mcmd.el create mode 100644 .emacs.d/icicles/icicles-mode.el create mode 100644 .emacs.d/icicles/icicles-opt.el create mode 100644 .emacs.d/icicles/icicles-var.el create mode 100644 .emacs.d/icicles/icicles.el diff --git a/.emacs.d/icicles/icicles-chg.el b/.emacs.d/icicles/icicles-chg.el new file mode 100644 index 0000000..cffcd12 --- /dev/null +++ b/.emacs.d/icicles/icicles-chg.el @@ -0,0 +1,7310 @@ +;;; icicles-chg.el --- Change logs for Icicles libraries. +;; +;; Filename: icicles-chg.el +;; Description: Change logs for Icicles libraries. +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 2007-2009, Drew Adams, all rights reserved. +;; Created: Tue Nov 27 07:47:53 2007 +;; Version: 22.0 +;; Last-Updated: Tue Jul 20 13:45:00 2010 (-0700) +;; By: dradams +;; Update #: 5589 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-chg.el +;; Keywords: 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: +;; +;; None +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; Change logs for Icicles libraries. +;; +;; This file consolidates the change logs for all Icicles libraries. +;; It contains no code. +;; +;; Libraries `icicles-doc1.el' and `icicles-doc2.el' contain only +;; documentation, and they do not have change logs. Initially, +;; everything was in one library, `icicles.el', so its change log is +;; the oldest. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@> "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. +;; +;; (@> "CHANGE LOG FOR `icicles-cmd1.el'") +;; (@> "CHANGE LOG FOR `icicles-cmd2.el'") +;; (@> "CHANGE LOG FOR `icicles-face.el'") +;; (@> "CHANGE LOG FOR `icicles-fn.el'") +;; (@> "CHANGE LOG FOR `icicles-mac.el'") +;; (@> "CHANGE LOG FOR `icicles-mcmd.el'") +;; (@> "CHANGE LOG FOR `icicles-mode.el'") +;; (@> "CHANGE LOG FOR `icicles-opt.el'") +;; (@> "CHANGE LOG FOR `icicles-var.el'") +;; (@> "CHANGE LOG FOR `icicles.el'") +;; (@> "CHANGE LOG FOR `icicles-cmd.el'" - Deprecated file) + +;;;(@* "CHANGE LOG FOR `icicles-cmd1.el'") +;; +;; 2010/07/20 dadams +;; icicle-find-file-in-tags-table(-other-window): +;; Pick up default-directory of TAGS table. Thx to Chris Hecker. +;; icicle-bookmark-jump-1: Applied renaming of bmkp-use-region-flag to bmkp-use-region. +;; 2010/07/17 dadams +;; Added: icicle-bookmark-url-narrow, icicle-bookmark-url(-other-window). +;; icicle-bookmark(-list|-set|-other-window|-propertize-candidate|-help-string), +;; icicle-define-bookmark-command-1: w3m -> url. +;; Bound URL commands to C-M-u, C-x j u. +;; 2010/07/02 dadams +;; icicle-bookmark-set: Added INTERACTIVEP arg. Prompt for tags when bmkp-prompt-for-tags-flag. +;; Highlight bookmark if bmkp-auto-light-when-set. +;; icicle-bookmark-cmd: Call icicle-bookmark-set with new INTERACTIVEP arg. +;; 2010/06/25 dadams +;; icicle-find-file(-other-window): +;; Use default-directory, not nil, as third arg to read-file-name. Thx to Thomas Lim. +;; Note: This more or less reverts a change I made (why?) on 2008/12/27 (see that, below). +;; 2010/06/18 dadams +;; Renamed: bookmarkp-* to bmkp-*. +;; 2010/06/11 dadams +;; icicle-find-file-absolute*, icicle-recent-file*, icicle-locate-file-1: +;; Bind C-c + to icicle-make-directory. +;; icicle-find-file-in-tags-table*: Removed bindings: C-x m, C-backspace. +;; 2010/06/10 dadams +;; icicle-cd-for-abs-files: Bound enable-recursive-minibuffers to t. +;; 2010/06/08 dadams +;; Added: icicle-bookmark-delete-action: Make it refresh the cache. +;; icicle-bookmark(-list|-other-window), icicle-define-bookmark-command-1: +;; Use icicle-bookmark-delete-action. +;; Use condition-case to filter out bad bookmarks (so no error). Thx to M. Heerdegen. +;; 2010/06/04 dadams +;; Applied renamings of doremi commands (added +). +;; icicle-(buffer|*file|directory)*: Updated doc string to mention icicle-(buffers|files)-ido-like. +;; 2010/05/30 dadams +;; Added: icicle-locate-file-no-symlinks(-other-window), icicle-locate-file(-other-window)-action, +;; icicle-locate-file-1. +;; icicle-locate-file*: Moved body to icicle-locate-file-1. Use named action functions. +;; Respect icicle-ignored-directories (via *-files-within). +;; icicle-cd-for-loc-files: Added optional arg NO-SYMLINKS-P. +;; icicle-dired-saved-file-candidates(-other-window): Handle multi-completion candidates. +;; Thx to M. Heerdegen. +;; 2010/05/28 dadams +;; icicle-(recent|locate)-file(-other-window), +;; Use *-transform-multi-completion in *-all-candidates-list-alt-action-fn. Thx to M. Heerdegen. +;; 2010/05/27 dadams +;; icicle-cd-for-loc-files: Wrap interactive spec in save-selected-window. Thx to M. Heerdegen. +;; 2010/05/26 dadams +;; icicle-bookmark-set: Removed pseudo-default. Thx to Michael Heerdegen. +;; 2010/05/24 dadams +;; icicle-comint-replace-orig-completion-fns: Rewrote to not use case. Thx to Michael Heerdegen. +;; 2010/05/21 dadams +;; icicle-bookmark-help-string: +;; Use BOOKMARK-NAME, not BMK, as arg to vanilla fns, for Emacs < 23. Thx to Alexander Haeckel. +;; 2010-05-18 dadams +;; Added: icicle-cd-for-abs-files, icicle-cd-for-loc-files. +;; icicle-find-file-absolute*, icicle-locate-file*: Bind C-c C-d to icicle-cd-for-(abs|loc)-files. +;; icicle-locate-file*: Make icicle-list-use-nth-parts be nil if no non-positive prefix arg. +;; 2010/05/16 dadams +;; icicle-define-bookmark-command-1: Defined command requires bookmark+.el. +;; Added: icicle-bookmark-specific-(buffers|files)-narrow, icicle-bookmark-this-buffer-narrow. +;; icicle-bookmark(-other-window), icicle-bookmark-set: +;; Bound C-M-= (b|f), C-M-. for narrowing to specific-(buffers|files), this-buffer. +;; icicle-bookmark-cleanup: Updated for added narrowing keys. +;; 2010/05/15 dadams +;; Added: icicle-define-bookmark-command(-1). Added ARGS param for use as arg for *-alist-only. +;; Added same-window commands for bookmark jumping. +;; Added: *-specific-(buffers|files)*, *-this-buffer*, *-(all|some)-tags(-regexp)* jump commands, +;; *-bookmarked-(buffer|file)-list. +;; icicle-bookmark-set: *-selected-buffers-alist-only -> *-specific-buffers-alist-only. +;; 2010/05/06 dadams +;; icicle-bookmark-set: Removed spurious format call with its arg. +;; 2010/04/29 dadams +;; icicle-explore: Bind icicle-remove-icicles-props-p to nil around call to completing-read. +;; Call icicle-unpropertize at the end (without that binding). +;; 2010/04/20 dadams +;; icicle-dired(-other-window): Use icicle-dirs-first-p, not icicle-dirs-last-p, and don't reverse. +;; 2010/04/17 dadams +;; Added: icicle-bookmark-set. +;; icicle-bookmark-cmd: Use icicle-bookmark-set, not bookmark-set. Simpler PARG code in that case. +;; icicle-bookmark(-list|-other-window), icicle-define-bookmark-other-window-command: +;; Use icicle-transform-multi-completion in icicle-delete-candidate-object. +;; 2010/04/10 dadams +;; Corrected prefix arg use for icicle-find-file(-read-only)(-other-window). Thx to M. Heerdegen. +;; 2010/04/09 dadams +;; Added: icicle-find-file-read-only(-other-window). +;; icicle-find-file(-other-window): +;; Prefix arg on individual candidate means visit read-only. +;; Prefix arg for the command means reverse the prefix arg effect: read-only for all by default. +;; 2010/04/02 dadams +;; Added: icicle-bookmark-list. +;; icicle-bookmark-cleanup: Clean up both minibuffer maps. +;; 2010/03/27 dadams +;; icicle-define-bookmark-other-window-command: Use optional PROMPT arg. +;; 2010/03/19 dadams +;; icicle-define-bookmark-other-window-command: Rich multi-completions per icicle-bookmark. +;; 2010/03/16 dadams +;; icicle-bookmark(-other-window): +;; Use tags, not just file names, in the multi-completions. +;; Use the default join string, ^G^J, and end string, ^J^J. +;; Use just icicle-candidate-properties-alist to highlight the file name. +;; Remove extra quote marks from face names. +;; 2010/03/14 dadams +;; icicle-bookmark(-other-window): +;; Copy file/buffer name string for candidate-part face, so we don't touch bookmark-alist. +;; Handle icicle-bookmark-refresh-cache-flag and C-u. +;; Bind the narrow keys in minibuffer-local-completion also (lax for multi-completion). +;; Use face file-name-shadow, not icicle-candidate-part (too distracting). +;; icicle-bookmark-*-narrow: Use icicle-get-alist-candidate-function. +;; icicle-define-bookmark-other-window-command: Rewrote to handle multi-completion. +;; icicle-bookmark-non-file-narrow: Use bookmarkp-non-file-bookmark-p. +;; icicle-bookmark-propertize-candidate: Typo in a face name. +;; 2010/03/13 dadams +;; icicle-bookmark(-other-window): +;; If Bookmark+ available then, depending on icicle-show-multi-completion-flag, use a +;; multi-completion showing file or buffer. Use icicle-candidates-alist to do that. +;; Don't put icicle-fancy-candidates prop on prompt. +;; Don't use icicle-sorted-bookmark-alist (removed). Recompute each time. +;; 2010/03/10 dadams +;; icicle-bookmark-help-string: +;; Mention the type in the help: sequence, function, bookmark list, desktop, etc. +;; Don't show position for types that don't use one. Don't show file for buffer & Dired. +;; 2010/03/09 dadams +;; icicle-color-theme: Initialize variable icicle-color-themes here, not in icicles-opt.el. +;; 2010/03/04 dadams +;; icicle-bookmark(-other-window): Use bookmarkp-describe-bookmark(-internals) for C-M-RET. +;; 2010/03/03 dadams +;; icicle-bookmark(-other-window), icicle-define-bookmark-other-window-command: +;; Use bookmarkp-sort-and-remove-dups. +;; Bind icicle-sort-orders-alist, using bookmarkp predicates. +;; icicle-bookmark(-other-window): +;; Set icicle-sorted-bookmark-alist and bookmarkp-sorted-alist. +;; Use bookmarkp-sorted-alist. +;; Don't append original icicle-sort-orders-alist. Just include a couple of its entries. +;; Applied renamings: icicle-sort-function to icicle-sort-comparer, +;; icicle-sort-functions-alist to icicle-sort-orders-alist. +;; 2010/02/28 dadams +;; icicle-send-bug-report: Formatted body a bit. +;; 2010/02/14 dadams +;; Added: icicle-bookmark-bookmark-list-other-window, icicle-bookmark-bookmark-list-narrow. +;; icicle-bookmark(-other-window): +;; Bound to C-M- prefix: icicle-bookmark-bookmark-list-narrow. Updated doc string. +;; 2010/02/13 dadams +;; Added: icicle-bookmark-(desktop|man)-other-window, +;; icicle-bookmark-(dired|desktop|man)-narrow. +;; icicle-define-bookmark-other-window-command: Raise error if bookmark+.el not found. +;; icicle-bookmark(-other-window): +;; Bound to C-M- prefix: icicle-bookmark-(dired|desktop|man)-narrow. +;; icicle-bookmark-propertize-candidate: +;; Handle also: sequence, function, bookmark list, desktop, man, buffer, bad bookmarks. +;; 2010/02/02 dadams +;; icicle-bookmark-jump-1: Don't select minibuffer window and give it focus. +;; 2010/01/30 dadams +;; icicle-dired(-other-window), icicle-(find|recent|locate)-file(-absolute)(-other-window) +;; icicle-find-file-in-tags-table(-other-window): +;; Bind icicle-all-candidates-list-alt-action-fn to open Dired on matching files. +;; 2010/01/13 dadams +;; icicle-recent-file(-other-window): +;; Restore C-S-RET as icicle-remove-from-recentf-candidate-action (accidentally removed). +;; 2010/01/12 dadams +;; Added: icicle-pp-display-expression. +;; icicle-pp-eval-expression: Use icicle-pp-display-expression. +;; icicle-bbdb-complete-name: save-excursion + set-buffer -> with-current-buffer. +;; 2009/12/21 dadams +;; fset -> defalias. +;; 2009/12/13 dadams +;; Added: icicle-bookmark-dired-other-window, icicle-dired(-other-window). +;; *-buffer*, *-dired-project*, *-find-file(-absolute)*, *-(recent|locate)-file*, +;; *-find-file-in-tags-table*: +;; Bind C-x m to icicle-bookmark-(non-file|dired|file)-other-window. +;; 2009/11/27 dadams +;; Added: icicle(-doremi)-increment-(variable|option). +;; 2009/11/25 dadams +;; icicle-color-theme: Raise error for empty input. Thx to Ahei. +;; 2009/11/24 dadams +;; icicle-color-theme: Take a snapshot each time invoked, unless prefix arg. +;; 2009/11/22 dadams +;; icicle-color-theme: Use color-theme-initialize instead of load-library, to load themes. +;; 2009/11/21 dadams +;; icicle-color-theme: Use color-theme-snapshot to let C-g undo changes. +;; Try to load color-theme-library.el (available with version 6.6.0). +;; 2009/11/17 dadams +;; icicle-bbdb-complete-name: Bind completion-case-ignore. +;; 2009/11/14 dadams +;; icicle-bbdb-complete-name: Replace macro bbdb-hashtable by its expansion. +;; 2009/09/21 dadams +;; icicle-lisp-complete-symbol: +;; Complete symbol in buffer as far as possible first. Show completions initially. +;; 2009/09/17 dadams +;; icicle-delete-file, icicle-(file|directory)-list, +;; icicle-find-file(-absolute)(-other-window), +;; icicle-(recent|locate)-file(-other-window), +;; icicle-find-file-in-tags-table(-other-window): Use icicle-file-bindings (new macro). +;; 2009/09/16 dadams +;; Added: icicle-insert-buffer. +;; icicle-kill-buffer, icicle-buffer(-other-window), icicle-add-buffer-candidate: +;; Use icicle-buffer-bindings (new macro). +;; 2009/08/29 dadams +;; Added: icicle-define-bookmark-other-window-command, icicle-select-bookmarked-region, +;; icicle-bookmark(-region|-info|-gnus|-w3m|(-non|-local|-remote)-file)-other-window. +;; icicle-bookmark-propertize-candidate: Updated to reflect renamed bookmark+.el face names. +;; icicle-bookmark-file-narrow: Use bookmarkp-file-bookmark-p. +;; (lambda...) -> #'(lambda...). +;; 2009/08/25 dadams +;; Added: icicle-bookmark-cleanup-on-quit. +;; icicle-bookmark(-other-window): Use icicle-bookmark-cleanup-on-quit. +;; icicle-bookmark-cleanup: Removed code to return to original window a focus minibuffer. +;; 2009/08/24 dadams +;; Added: icicle-bookmark-propertize-candidate. +;; icicle-bookmark(-other-window): Put faces on bookmark candidates according to type. +;; 2009/08/23 dadams +;; Added: icicle-bookmark-(region|info|gnus|w3m|(non-|local-|remote-)file)-narrow. +;; icicle-bookmark(-other-window): Bind keys to bookmark candidate narrowing commands. +;; icicle-bookmark-cleanup: Unbind the same commands. +;; icicle-bookmark-cmd: +;; Let bookmark+.el (latest version) handle prompting for name, even for region bookmark. +;; Remove any newlines in bookmark name, when no prompting (thx to Thierry Volpiatto). +;; 2009/08/21 dadams +;; icicle-bookmark-jump-1: Typo. +;; 2009/08/20 dadams +;; icicle-bookmark-cmd: Use icicle-bookmark-other-window, not icicle-bookmark. +;; Fix trimmed-name: no longer than def-name. +;; icicle-bookmark(-other-window): Bind enable-recursive-minibuffers, in case need to read. +;; icicle-bookmark-jump-1: No crosshair highlighting for region bookmarks. +;; 2009/08/19 dadams +;; Added: icicle-bookmark-help-string. +;; icicle-bookmark-cmd: Handle creation of region bookmarks (new default values). +;; icicle-bookmark-name-length-max now applies to whole bookmark name. +;; icicle-bookmark(-other-window): +;; Apply icicle-candidate-short-help to candidates. Use also for the help function. +;; icicle-bookmark-jump-1: Use bookmark--jump-via if it is defined. +;; 2009/06/21 dadams +;; icicle-bookmark-jump-1: Removed temporary Emacs 23 workaround for (fixed) bug #1175. +;; 2009/06/07 dadams +;; icicle-get-alist-candidate -> funcall icicle-get-alist-candidate-function. +;; 2009/05/22 dadams +;; Require icicles-mac.el if load-library doesn't find it. +;; Created - Split off from icicles-cmd.el. + +;;;(@* "CHANGE LOG FOR `icicles-cmd2.el'") +;; +;; 2010/07/17 dadams +;; Added: icicle-search-url-bookmark. +;; icicle-search-bookmark, icicle-define-search-bookmark-command: w3m -> url. Added C-M-u binding. +;; 2010/07/14 dadams +;; icicle-Info-index: Bind C-x m to icicle-bookmark-info-other-window. +;; icicle-Info-read-node-name: Restore original binding of C-x m, if any. +;; 2010/06/21 dadams +;; icicle-comint-search: Wrap search with unwind-protect to remove hook. Thx to M. Heerdegen. +;; 2010/06/18 dadams +;; icicle-search-replace-match: Specific error message for read-only buffer. Thx to M. Heerdegen. +;; Renamed: bookmarkp-* to bmkp-*. +;; 2010/06/12 dadams +;; icicle-goto-marker-or-set-mark-command: +;; Set this-command so C-SPC C-SPC activates when not t-m mode. Thx to Chris Hecker. +;; 2010/06/11 dadams +;; icicle-search-action-1: (unless (pos-visible-in-window-p) (recenter -2)). Thx to M. Heerdegen. +;; 2010/06/08 dadams +;; icicle-search-bookmark, icicle-define-search-bookmark-command: +;; Use icicle-bookmark-delete-action. +;; Use condition-case to filter out bad bookmarks (so no error). +;; 2010/06/04 dadams +;; Added: icicle-ido-like-mode. +;; 2010/05/16 dadams +;; Added: icicle-search-(all|some)-tags(-regexp)-bookmark, icicle-search-desktop-bookmark, +;; icicle-search-specific-(buffers|files)-bookmark, icicle-search-this-buffer-bookmark. +;; icicle-define-search-bookmark-command: Defined cmd requires bookmark+.el. Added &rest arg ARGS. +;; 2010/05/15 dadams +;; icicle-search-highlight-and-maybe-replace: If candidate number is nil, set to 0. +;; icicle-search: Updated doc string: Can sort. Don't say not to use C-|. +;; 2010/05/09 dadams +;; Icicles search: Change to allow sorting. Use mctized candidates, not alist + candidate nb. +;; icicle-search-highlight-and-maybe-replace: +;; Use *-replace-cand-in-mct, not *-replace-cand-in-alist. Do not *-input-matches-here. +;; icicle-search-replace-cand-in-mct: Rewrote. +;; Handle multi-completions also. Update CAND+MRKER to use replacement string, but keep props. +;; icicle-search-in-context-default-fn: Rewrote. +;; Update icicle-last-completion-candidate to current candidate. Insert that. +;; Recompute input-match highlighting in current context. Remove current if no candidates. +;; icicle-search-action-1: Do nothing if no candidates. +;; icicle-search-help: Bind icicle-whole-candidate-as-text-prop-p to t, not nil. +;; 2010/05/04 dadams +;; icicle-object-action: Pass TYP to icicle-apply-to-saved-candidate. (UNTESTED) +;; icicle-choose-anything-candidate: Pass TYPE to icicle-apply-to-saved-candidate. (UNTESTED) +;; icicle-apply, icicle-read-var-value-satisfying: Bug fix: Removed #'. +;; 2010/04/30 dadams +;; icicle-search: Delete icicle-search-current-overlay via icicle-no-match-hook (& restore hook). +;; 2010/04/29 dadams +;; icicle-apply: Added optional args predicate initial-input hist def inherit-input-method. +;; Pass them to icicle-explore. +;; icicle-goto-marker-1: Pass a PREDICATE arg that ensures the marker points somewhere. +;; 2010/04/25 dadams +;; icicle-complete-keys-action: +;; Bind icicle-*, esp. *-initially-flag, around call of this-command-keys. Thx to M Heerdegen. +;; icicle-complete-keys: Save some icicle-* vars to reuse in icicle-complete-keys-action. +;; 2010/04/17 dadams +;; icicle-search-bookmark, icicle-define-search-bookmark-command: +;; Use icicle-transform-multi-completion in icicle-delete-candidate-object. +;; 2010/04/08 dadams +;; icicle-get-anything-candidates: Removed #' - it was preventing the fn from being functionp. +;; 2010/04/03 dadams +;; Removed: icicle-search-desktop-bookmark (no need). +;; 2010/04/02 dadams +;; Removed: +;; icicle-add-region, icicle-delete-region-from-alist, icicle-purge-bad-file-regions, +;; icicle-region-add-buffers, icicle-region-add-short-help, icicle-region-help, +;; icicle-region-open-all-files, icicle-regions, icicle-region-sorted, +;; icicle-remove-all-regions-action, icicle-remove-all-regions-in-buffer, icicle-remove-region, +;; icicle-search-all-regions, icicle-search-region(-action), icicle-select-region(-action). +;; Added: +;; icicle-search-bookmark-list-bookmark, icicle-search-bookmarks-together, +;; icicle-search-desktop-bookmark, icicle-search-dired-bookmark, icicle-search-man-bookmark. +;; icicle-exchange-point-and-mark, icicle-search(-define-candidates), +;; icicle-char-properties-in-buffers: +;; Use only region bookmarks, not Icicles saved regions. +;; icicle-exchange-point-and-mark: Negative prefix arg prompts for bookmark name. +;; icicle-search-define-candidates(-1): Raise the no-candidates error in parent, not in (-1). +;; icicle-search-bookmark: Use full multi-completions. Use bookmark sort orders. +;; Define narrowing keys in both minibuffer maps. +;; icicle-search-bookmark-action: Transform multi-completion. Use bookmark posns only for region. +;; icicle-define-search-bookmark-command: Added PROMPT arg. Use multi-completions, bookmark sorts. +;; 2010/03/28 dadams +;; Renamed: icicle-search-all-regions to icicle-search-region. +;; Removed: old icicle-search-region (use icicle-search-region-bookmark instead), +;; icicle-region-add-buffers, icicle-region-add-short-help, icicle-region-help, +;; icicle-region-sorted, icicle-region-open-all-files, icicle-add-region, +;; icicle-remove-region, icicle-delete-region-from-alist, +;; icicle-purge-bad-file-regions, icicle-remove-all-regions-(in-buffer|action). +;; icicle-search-all-regions: Use region bookmarks, not icicle-region-alist. +;; 2010/03/27 dadams +;; Added: icicle-search-(bookmark-list|desktop|dired|man)-bookmark. +;; icicle-search-bookmark: Use multi-completions. +;; icicle-search-bookmark-action: +;; Use icicle-transform-multi-completion. Use both minibuffer completion maps. +;; Search region if region bookmark. +;; icicle-define-search-bookmark-command: Added optional PROMPT arg. Use multi-completions. +;; 2010/03/13 dadams +;; Applied renaming of icicle-add-buffer-name-flag to icicle-show-multi-completion-flag. +;; 2010/03/09 dadams +;; icicle-regions: Use icicle-reversible-sort (with KEY arg), not sort. +;; 2010/03/03 dadams +;; Applied renamings: icicle-sort-function to icicle-sort-comparer +;; icicle-sort-functions-alist to icicle-sort-orders-alist, +;; icicle-alternative-sort-function to icicle-alternative-sort-comparer, +;; icicle-last-sort-function to icicle-last-sort-comparer. +;; 2010/02/06 dadams +;; icicle-where-is: Make sure orig-buff is current when look up the bindings. +;; 2010/01/12 dadams +;; icicle-insert-thesaurus-entry-cand-fn, icicle-marker+text, +;; icicle-search-(bookmark|region)-action, icicle-char-properties-in-buffer, +;; icicle-search-char-property-scan: +;; save-excursion + set-buffer -> with-current-buffer (+ save-excursion). +;; icicle-search-regexp-scan: set-buffer -> with-current-buffer. +;; 2009/12/13 dadams +;; icicle-Info-read-node-name: Bind C-x m to icicle-bookmark-info-other-window. +;; 2009/11/24 dadams +;; icicle-read-color: Copy the prompt string, so *-color-completion-setup can put props. +;; 2009/11/22 dadams +;; icicle-frame-(bg|fg): Don't apply *-make-color-candidate to named-colors (done already). +;; 2009/11/03 dadams +;; icicle-frame-(bg|fg): Use named-colors, not x-defined-colors. +;; icicle-read-color: No need to bind icicle-transform-function, since we use hexrgb.el. +;; 2009/09/05 dadams +;; icicle-search-replace-all-search-hits: +;; Bind to nil: icicle-minibuffer-message-ok-p, icicle-help-in-mode-line-flag. +;; icicle-search-action-1: Add condition-case to ignore disappearance of *Completions* win. +;; icicle-search-highlight-and-maybe-replace: +;; Apply renaming of icicle-acting-on-next/prev (no -p). +;; Use length of *-completion-candidates, not mct. +;; Fix assignment of new candidate nb, and for both directions. +;; Bind icicle-minibuffer-message-ok-p to inhibit no-candidates msg. +;; Wrap around to first only if not icicle-acting-on-next/prev. +;; 2009/09/02 dadams +;; icicle-exchange-point-and-mark: Respect icicle-region-bookmarks-flag. +;; 2009/08/29 dadams +;; Added: icicle-define-search-bookmark-command, +;; icicle-search(-region|-info|-gnus|-w3m|(-non|-local|-remote)-file)-bookmark, +;; icicle-search-bookmark-action. +;; Moved (and redefined) to icicles-cmd1.el: icicle-select-bookmarked-region. +;; (lambda...) -> #'(lambda...). +;; 2009/08/25 dadams +;; Added icicle-select-bookmarked-region. +;; icicle-exchange-point-and-mark: +;; If bookmark+ is loaded, use region bookmarks. +;; Raise error if try to save inactive region or try to select with no saved regions. +;; 2009/08/11 dadams +;; Added: icicle-search-replace-all-search-hits. +;; Renamed: icicle-search-replace-candidate to icicle-search-replace-cand-in-alist. +;; Added: icicle-search-replace-cand-in-mct (not used, for now). +;; icicle-search: +;; Bind icicle-all-candidates-list-alt-action-fn to icicle-search-replace-all-search-hits. +;; Bind replace-count to 0. Bind icicle-current-input to empty string. +;; Updated doc string. +;; icicle-search-replace-search-hit: +;; Do not bind icicle-completion-candidates, icicle-candidate-nb, icicle-last-input. +;; No lack-of-current-candidate error if icicle-all-candidates-action-p. +;; Added: icicle-search-action-1 (factored out from icicle-search-action. +;; icicle-search-action, icicle-search-help: +;; Bind icicle-whole-candidate-as-text-prop-p to nil, to force use of alist. +;; icicle-search-action(-1): Do not bind icicle-candidate-nb, so don't save and restore it. +;; icicle-search-in-context-default-fn: If replacement tried, then update the dialog state. +;; icicle-search-highlight-and-maybe-replace: REWRITE. +;; Msg if string to be replaced is not found in candidate. +;; Swap order: Don't search unless first time (or replacing all). +;; icicle-search-replace-candidate -> icicle-search-replace-cand-in-alist. +;; If replacement done, then: Update alist, minibuffer-completion-table, and +;; minibuffer content. Change candidate nb if navigating next/prev. Complete again. +;; Return indication of whether we tried to replace something. +;; icicle-search-replace-cand-in-alist: Added catch, to skip whole list traversal. +;; Moved byte-compile quieting defvars to top level. Added one for tooltip-mode. +;; 2009/07/20 dadams +;; icicle-font: Ensure no nil elements in COLLECTION arg to completing-read, for Emacs 22+. +;; 2009/06/07 dadams +;; icicle-get-alist-candidate -> funcall icicle-get-alist-candidate-function. +;; Added: icicle-purge-bad-file-regions. +;; icicle-add-region, icicle-(select|search)-region-action: +;; Special-case Info buffers. Thx to Thierry Volpiatto. +;; 2009/05/28 dadams +;; Bind icicle-search-replacement to nil. (Somehow forgot when moved to icicle-explore.) +;; icicle-search-replace-search-hit: Raise an error if icicle-candidate-nb is nil. +;; 2009/05/26 dadams +;; icicle-compilation-search: Use value 'until-move for next-error-highlight. +;; 2009/05/22 dadams +;; Added: icicle-Info-virtual-book. +;; Require icicles-mac.el if load-library doesn't find it. +;; icicle-search: Set icicle-search-final-choice to result. +;; Created - Split off from icicles-cmd.el. + +;;;(@* "CHANGE LOG FOR `icicles-face.el'") +;; +;; 2010/05/05 dadams +;; icicle-mustmatch-completion: Changed line-width from 2 to -2. +;; 2010/04/08 dadams +;; Added autoload cookies. +;; 2010/03/13 dadams +;; Made icicle-candidate-part paler (light background): #EF84FFEAF427, not #DB17FFF4E581. +;; 2010/02/17 dadams +;; Moved functions here from icicles-opt.el: icicle-increment-color-(hue|saturation). +;; So no longer require icicles-opt.el. +;; 2009/04/18 dadams +;; Removed load-time warning about using Icicles in a text terminal. +;; 2009/04/12 dadams +;; Added: face icicle-mode-line-help. +;; 2009/01/13 dadams +;; Added: icicle-extra-candidate. +;; 2008/10/26 dadams +;; Added group: Icicles-Files. +;; 2008/03/29 dadams +;; Redefined and renamed faces for completion status indicators. +;; Renamed: icicle-completing-mustmatch-prompt-prefix to icicle-mustmatch-completion, +;; icicle-mode-lighter-highlight(-plus) to icicle(-multi-command)-completion. +;; Removed: icicle-completing-prompt-prefix, icicle-prompt-suffix. +;; 2008/03/09 dadams +;; Added: icicle-mode-lighter-highlight. +;; 2007/12/10 dadams +;; Added: icicle-input-completion-fail-lax. +;; 2007/11/18 dadams +;; Added: icicle-proxy-candidate. +;; icicle-special-candidate: No longer use a raised box. +;; 2007/10/22 dadams +;; icicle-special-candidate: Raised box. +;; 2007/08/19 dadams +;; Added: icicle-input-completion-fail. +;; 2007/06/21 dadams +;; Added: icicle-candidate-part. Changed definition of icicle-special-candidate. +;; 2007/06/17 dadams +;; Added: icicle-saved-candidate. +;; 2007/06/12 dadams +;; icicle-prompt-suffix: No box for dark background. +;; 2007/06/11 dadams +;; Better defaults for dark background frames. +;; 2007/06/07 dadams +;; Changed emacs-commentary-link to point to icicles-doc1.el and icicles-doc2.el. +;; 2007/05/22 dadams +;; Protected icicle-search-context-level-1 to *-8, in case hexrgb is not loaded. +;; 2007/04/20 dadams +;; Added: icicle-search-context-level-1 through *-8. +;; Require icicles-opt.el. +;; 2006/12/22 dadams +;; Renamed group icicles to Icicles. +;; Added Icicles subgroups, and assigned them instead of group Icicles: +;; -Buffers, -Completions-Display, -Key-Bindings, -Key-Completion, -Matching, +;; -Minibuffer-Display, -Miscellaneous, -Searching. +;; 2006/11/06 dadams +;; icicle-search-highlight-all-flag -> icicle-search-highlight-threshold (integer) +;; 2006/10/16 dadams +;; icicle-special-candidate: changed background from Pink to #DB17FFF4E581. +;; 2006/10/04 dadams +;; Added: icicle-special-candidate. +;; 2006/08/13 dadams +;; Added: icicle-completing-prompt-prefix. +;; 2006/07/16 dadams +;; Added dark-background face suggestions from Le Wang - thx. +;; 2006/06/30 dadams +;; Added: minibuffer-prompt for Emacs < 22 (e.g. Emacs 21.4 has propertize). +;; 2006/04/28 dadams +;; Added: icicle-whitespace-highlight. +;; 2006/04/14 dadams +;; Renamed icicle-search-refined-regexp to icicle-search-current-input. +;; 2006/04/07 dadams +;; Added: icicle-search-main-regexp-others. +;; Renamed: icicle-search-main-regexp to icicle-search-main-regexp-current. +;; 2006/03/27 dadams +;; Added: icicle-search-*-regexp. +;; 2006/03/22 dadams +;; Renamed: icicle-root-highlight-* to icicle-match-highlight-*. +;; 2006/03/21 dadams +;; Added: icicle-common-match-highlight-Completions. +;; icicle-root-highlight-Completions: Changed default face. +;; 2006/03/08 dadams +;; Added: icicle-current-candidate-highlight. + +;;;(@* "CHANGE LOG FOR `icicles-fn.el'") +;; +;; 2010/06/18 dadams +;; icicle-completing-read: +;; Initialize icicle-completions-format-internal to icicle-completions-format. +;; icicle-mctized-full-candidate: +;; Set icicle-completions-format-internal to horizontal for multi-line multi-completions. +;; icicle-insert-candidates: +;; Remove face property from end of candidate to next column. +;; Replace icicle-completions-format by icicle-completions-format-internal. +;; Renamed: bookmarkp-* to bmkp-*. +;; 2010/06/14 dadams +;; icicle-read-from-minibuffer: +;; If add file-name default to prompt, remove dir part first. Thx to Chris Hecker. +;; icicle-next-candidate: Do not icicle-recompute-candidates if this command was repeated. +;; icicle-increment-cand-nb+signal-end: +;; Signal wrap from initial, not from 0. Negative INCR -> start at end. Thx to M. Heerdegen. +;; icicle-call-then-update-Completions: +;; Set icicle-last-input to nil so icicle-save-or-restore-input makes next-candidate recompute. +;; 2010/06/12 dadams +;; icicle-fit-completions-window: Let-bind window-min-height to prevent deletion in Emacs 23. +;; 2010/06/10 dadams +;; icicle-maybe-sort-and-strip-candidates: +;; Set icicle-completion-candidates to result of *maybe...maybe*. (It broke C-~.) +;; 2010/06/09 dadams +;; icicle-isearch-complete-past-string: Use the last-used ring. Thx to Michael Heerdegen. +;; 2010/06/08 dadams +;; icicle-display-candidates-in-Completions: Show also total when truncated: N shown / M. +;; icicle-maybe-sort-maybe-truncate: Save icicle-nb-candidates-before-truncation before truncating. +;; 2010/06/04 dadams +;; Added: icicle-clear-lighter, icicle-maybe-sort-maybe-truncate, icicle-take. +;; icicle-(prefix|apropos)-candidates, icicle-strip-ignored-files-and-sort, +;; icicle-maybe-sort-and-strip-candidates, icicle-display-Completions: +;; Use icicle-maybe-sort-maybe-truncate, not icicle-reversible-sort. +;; icicle-(un)highlight-lighter: Use icicle-clear-lighter (factored out). +;; 2010/05/30 dadams +;; Added: icicle-files-within-1. +;; icicle-files-within: +;; Use icicle-files-within-1. Optionally don't follow symlinks (new arg NO-SYMLINKS-P). +;; Don't process same dir twice. Respect icicle-ignored-directories. Thx to Michael Heerdegen. +;; 2010/05/18 dadams +;; icicle-save-or-restore-input: +;; Use icicle-file-directory-p, not file-directory-p (fails: ~/foo//usr/). Thx to M. Heerdegen. +;; 2010/05/04 dadams +;; icicle-alt-act-fn-for-type: Pass TYPE to icicle-apply-to-saved-candidate. +;; 2010/04/30 dadams +;; icicle(-file-name)-unsorted-(apropos|prefix)-candidates, icicle-fuzzy-candidates: +;; Set icicle-common-match-string to nil when no candidates. +;; 2010/04/29 dadams +;; icicle-unpropertize: Do nothing unless icicle-remove-icicles-props-p. +;; 2010/04/27 dadams +;; icicle-show-help-in-mode-line: Test value, not just boundp, of icicle-completing-keys-p. +;; 2010/04/21 dadams +;; icicle-mode-line-name-less-p: Removed bogus calls to symbol-name. Thx to Michael Heerdegen. +;; 2010/04/20 dadams +;; Added: icicle-dirs-first-p. +;; 2010/04/02/dadams +;; icicle-completing-p: Cache t, not the keymap portion. +;; 2010/03/16 dadams +;; icicle-display-candidates-in-Completions, treating icicle-candidate-properties-alist: +;; For subsequent matches of join string, skip over the last join string (not 1 char). +;; icicle-candidate-short-help: Treat each property individually. +;; 2010/03/13 dadams +;; icicle-reversible-sort: Respect icicle-transform-before-sort-p. +;; 2010/03/10 dadams +;; icicle-show-help-in-mode-line: +;; Put this test first: If candidate is a string with a help property, use that. +;; Use get-file-buffer, not get-buffer, for a visited file. +;; 2010/03/09 dadams +;; icicle-reversible-sort: Added optional KEY arg. Set LIST to sort result and return it. +;; icicle-multi-sort: Set RESULT to funcall result. +;; 2010/03/03 dadams +;; Added: icicle-multi-sort, icicle-make-plain-predicate, icicle-alpha-p. +;; icicle-reversible-sort: Use icicle-sort-comparer and icicle-multi-sort. +;; Reset to unsorted if an error is raised. +;; Applied renamings: icicle-sort-function to icicle-sort-comparer, +;; icicle-sort-functions-alist to icicle-sort-orders-alist. +;; icicle-read-shell-command-completing: Removed extra binding for icicle-sort-function. +;; 2010/01/12 dadams +;; icicle-display-candidates-in-Completions: set-buffer -> with-current-buffer. +;; 2009/12/25 dadams +;; icicle-strip-ignored-files-and-sort: +;; Call completion-ignored-build-apply and icicle-update-ignored-extensions-regexp. +;; 2009/12/21 dadams +;; fset -> defalias. +;; 2009/12/07 dadams +;; Added: icicle-minibuffer-default-add-dired-shell-commands. +;; icicle-dired-read-shell-command: Instead of using minibuffer-default-add-shell-commands, +;; use icicle-minibuffer-default-add-dired-shell-commands. +;; icicle-read-shell-command-completing: Bind insert-default-directory to nil. +;; icicle-dir-prefix-wo-wildcards: Don't ever return nil - return "" if need be. +;; icicle-read-string: +;; Handle a consp default-value when user enters "": use the car. Thx to Sakuma Ryo. +;; 2009/12/03 dadams +;; icicle-completing-read: +;; Make sure we don't use a nil def value for init value. Thx to Sebastian Luque. +;; 2009/11/27 dadams +;; *-display-candidates-in-Completions, *-prefix-candidates, *-fuzzy-candidates: +;; Handle swank completions too. +;; 2009/11/25 dadams +;; icicle-insert-candidates: Handle vertical layout: icicle-completions-format. +;; 2009/11/03 dadams +;; icicle-color-completion-setup: Use hexrgb-defined-colors, not x-defined-colors. +;; No icicle-transform-function, since we use hexrgb.el. +;; 2009/10/25 dadams +;; Added: icicle-dir-prefix-wo-wildcards. Use in icicle-insert-cand-in-minibuffer. +;; icicle-save-or-restore-input: Remove test comparing last completion with current input. +;; icicle-abbreviate-or-expand-file-name: If arg is absolute, do not expand. +;; icicle-display-candidates-in-Completions, icicle-prefix-candidates, +;; icicle-not-basic-prefix-completion-p: +;; Updated for new completion methods. Use *-current-TAB-method, not old fuzzy flag. +;; 2009/10/24 dadams +;; icicle-unsorted-file-name-*-candidates, icicle-*-any-file-name-candidates-p: +;; Got rid of slashed-p. +;; icicle-unsorted-file-name-apropos-candidates: +;; Set icicle-common-match-string to nil if there are no candidates. +;; icicle-apropos-any-file-name-candidates-p: +;; When input is a dir, remove final /, so we don't non-match highlight the / (empty dir). +;; Bind case-fold-search, for apropos matching. +;; icicle-abbreviate-or-expand-file-name: Set DIR to nil if it's relative. +;; 2009/10/22 dadams +;; Added: icicle-file-name-directory. +;; icicle-completion-setup-function, icicle-display-candidates-in-Completions, +;; icicle-save-or-restore-input, icicle-file-name-directory-w-default, +;; icicle-historical-alphabetic-p: +;; Use icicle-file-name-directory, not file-name-directory. +;; 2009/10/17 dadams +;; icicle-completion-try-completion: Return RES. +;; 2009/10/12 dadams +;; icicle-unsorted-prefix-candidates, icicle-prefix-any-candidates-p: +;; Use length of INPUT, not length from point backward to field-beginning. +;; icicle-input-from-minibuffer: Added optional LEAVE-ENVVARS-P arg. +;; icicle-next-candidate, icicle-highlight-complete-input: +;; Call icicle-input-from-minibuffer with LEAVE-ENVVARS-P arg. +;; icicle-completion-all-completions: +;; If not basic completion (Emacs 23) and input ends in $, then append $ to cands also. +;; 2009/09/25 dadams +;; icicle-file-name-prefix-candidates: Use whole input, not just nondirectory. +;; Added: icicle-not-basic-prefix-completion-p. Use where appropriate. +;; 2009/09/19 dadams +;; icicle-unpropertize: Remove the internal text properties added by Icicles. +;; icicle-completing-read, icicle-read-file-name: Call icicle-unpropertize unconditionally. +;; 2009/09/12 dadams +;; icicle-kill-a-buffer: Bind enable-recursive-minibuffers, to confirm modified buffer. +;; 2009/09/05 dadams +;; icicle-msg-maybe-in-minibuffer: Do nothing if icicle-minibuffer-message-ok-p is nil. +;; 2009/08/19 dadams +;; icicle-candidate-short-help: Return (possibly propertized) STRING. +;; 2009/08/09 dadams +;; Added: icicle-insert-cand-in-minibuffer - factored out code from icicle-next-candidate. +;; eval-after-load "crm": +;; Test that icy-mode is available using featurep, not fboundp. Thx to Michael Heerdegen. +;; 2009/07/26 dadams +;; icicle-completing-read, icicle-read-file-name-1: +;; Bind minibuffer-history-variable to itself. +;; 2009/07/13 dadams +;; icicle-read-face-name (Emacs 20 version): Use copy-sequence on prompt, before add prop. +;; 2009/07/12 dadams +;; icicle-display-completion-list: +;; Use different protection (fboundp) for fix for latest Emacs 23 crap (base size in cdr). +;; 2009/07/11 dadams +;; icicle-next-candidate: +;; If icicle-regexp-quote-flag, regexp-quote before string-match for highlighting root. +;; icicle-place-cursor: If icicle-regexp-quote-flag, regexp-quote input to search for it. +;; 2009/07/02 dadams +;; icicle-displayable-cand-from-saved-set: +;; If icicle-readable-to-markers returns an atom, just use that. +;; 2009/06/17 dadams +;; icicle-fit-completions-window: Scale text size initially. +;; 2009/06/07 dadams +;; icicle-get-alist-candidate -> funcall icicle-get-alist-candidate-function. +;; icicle-mctize-all: If PRED is nil, so is NEWPRED (use and instead of when). +;; 2009/05/22 dadams +;; Require icicles-mac.el if load-library doesn't find it. +;; 2009/05/18 dadams +;; icicle-display-candidates-in-Completions: deactivate-mark in *Completions* after display. +;; 2009/05/17 dadams +;; icicle-next-candidate: Updated to reflect thumb-frm.el name changes. +;; 2009/05/17 dadams +;; Added: icicle-toggle-icicle-mode-twice. +;; In eval-after-load crm: Use icicle-toggle-icicle-mode-twice, not icy-mode calls. +;; 2009/05/15 dadams +;; icicle-unhighlight-lighter: Wrap redisplay in condition-case, like elsewhere. +;; 2009/05/11 dadams +;; Added: icicle-upcase. Use in place of upcase everywhere, to work around Emacs 20 bug. +;; Added: icicle-local-keys-first-p. +;; icicle-display-candidates-in-Completions: +;; Don't highlight historical candidate if in icicle-hist-cands-no-highlight. +;; 2009/05/09 dadams +;; icicle-input-from-minibuffer: Keep text properties when pick up input. +;; icicle-highlight-input-noncompletion(-rest): Use an overlay instead of text property. +;; icicle-show-help-in-mode-line: Fix special case for pseudo-key/cmd ..: go up to prefix. +;; 2009/05/07 dadams +;; icicle-display-candidates-in-Completions, in the code that hides common match: +;; Don't reset display property to nil. +;; Use icicle-common-match-string, not current input. +;; icicle-expanded-common-match-1: +;; If input doesn't match candidate, return nil. Throw nil, not input, everywhere. +;; *-unsorted(-file-name)-apropos-candidates, *-apropos-any(-file-name)-candidates-p: +;; Protect calls to icicle-apropos-complete-match-fn with condition-case, for Emacs 20. +;; icicle-place-cursor: Added optional arg. +;; 2009/05/05 dadams +;; icicle-alt-act-fn-for-type: +;; Bind completion-ignore-case, based on read-buffer-completion-ignore-case. +;; 2009/05/03 dadams +;; Use (fboundp 'minibuffer-default-add-completions), not (> emacs-major version 22). +;; 2009/05/01 dadams +;; Renamed: icicle-choose-action-for-type to icicle-alt-act-fn-for-type. +;; icicle-type-actions-alist: Rewrote. Handle both list of objs and single obj. +;; icicle-quote-file-name-part-of-cmd: Rewrote. Quote file name always, and only file name. +;; 2009/04/30 dadams +;; icicle-show-in-mode-line: Clear any message (e.g. Computing completion candidates...). +;; 2009/04/29 dadams +;; icicle-get-alist-candidate: If NO-ERROR-P is 'no-error-no-msg, just return nil (no msg). +;; icicle-choose-action-for-type: Use lax completion. +;; 2009/04/28 dadams +;; icicle-choose-action-for-type: +;; Moved here from icicles-mac.el, changed to a function, and locally bind +;; *-alt-action-fn to icicle-choose-action-for-type function. +;; For undefined TYPE, provide all functions as candidates. +;; Added eval-when-compile of load-library icicles-mac. +;; 2009/04/27 dadams +;; icicle-recompute-candidates: +;; Keep no-display completion mode, if that's current. +;; Set icicle-last-completion-command only if completion type, not user input, changed. +;; icicle-complete-again-update: Added icicle-prefix-complete-no-display to first case. +;; 2009/04/19 dadams +;; Use unless instead of or for fset's. (cosmetic) +;; icicle-completing-read, icicle-read-from-minibuffer, icicle-read-string: +;; Renamed history parameter to HIST-m@%=!$+&^*z, so C-h f output looks less strange. +;; 2009/04/18 dadams +;; Soft-require hexrgb.el unconditionally, not just when there is a window-system. +;; 2009/04/12 dadams +;; icicle-display-candidates-in-Completions: Added number of candidates to mode-line. +;; icicle-show-help-in-mode-line: Use face icicle-show-help-in-mode-line. Fix prefix keys. +;; 2009/04/11 dadams +;; icicle-candidate-short-help: +;; Do nothing if either icicle-help-in-mode-line-flag or tooltip-mode is nil. +;; icicle-show-help-in-mode-line: +;; If no symbol help, try string. +;; Handle lambdas, menu-function-# from easy-menu, and prefix keys. +;; icicle-make-color-candidate: Construct short help only if user will see it. +;; 2009/04/10 dadams +;; Added: icicle-candidate-short-help, icicle-color-completion-setup (from i*-read-color). +;; Moved here from icicle-cmds.el: +;; icicle-remove-color-duplicates, icicle-color-help, icicle-make-color-candidate. +;; icicle-make-color-candidate: Added short help, using icicle-candidate-short-help. +;; icicle-show-help-in-mode-line: +;; Treat :icicle-candidate-help text property on strings. +;; Use candidate, not cand, for stringp clause, and use icicle-transform-multi-completion. +;; Renamed: :icicle-candidate-help to icicle-mode-line-help. +;; 2009/04/08 dadams +;; icicle-show-help-in-mode-line: Treat absolute file names too. +;; 2009/04/07 dadams +;; icicle-show-help-in-mode-line: (bufferp (get-buffer...)...) -> (get-buffer...) Duh. +;; 2009/04/06 dadams +;; Added: icicle-show-help-in-mode-line - from code in icicle-next-candidate: +;; Added arg. Handle: faces, buffer names, file names, :icicle-candidate-help. +;; Added: icicle-help-line-(buffer|file). +;; icicle-next-candidate: Use icicle-show-help-in-mode-line. +;; 2009/04/05 dadams +;; Added: icicle-show-in-mode-line. +;; icicle-next-candidate: Use icicle-show-in-mode-line to show help in mode-line. +;; 2009/04/04 dadams +;; Added: icicle-buffer-smaller-p, icicle-major-mode-name-less-p, +;; icicle-mode-line-name-less-p, icicle-buffer-file/process-name-less-p. +;; 2009/04/03 dadams +;; icicle-read-from-minibuffer: Save filtered default val as icicle-filtered-default-value. +;; icicle-lisp-vanilla-completing-read: Use icicle-filtered-default-value, not DEF, at end. +;; 2009/03/29 dadams +;; icicle-read-shell-command: If non-nil initial-contents, punt to use original (old-*). +;; 2009/03/27 dadams +;; Don't fset minibuffer-default-add-completions unless > Emacs 22. +;; 2009/03/27 dadams +;; icicle-read-from-minibuffer: Use icicle-filter-wo-input on default-value (all values). +;; icicle-completing-read, icicle-read-file-name-1: +;; Use icicle-filter-wo-input on default value only to get init value. +;; Added: icicle-minibuffer-default-add-completions, icicle-first-N. +;; 2009/03/26 dadams +;; icicle-completing-read, icicle-read-file-name-1: +;; Filter default values using icicle-filter-wo-input. +;; icicle-filter-wo-input: Return the candidate, if it passes filtering. +;; 2009/03/16 dadams +;; Added: icicle-recentf-make-menu-items. +;; 2009/03/10 dadams +;; icicle-read-shell-command-completing: Applied renamings: icicle-guess-commands-in-path, +;; icicle-shell-command-candidates-cache, icicle-recompute-shell-command-candidates. +;; Moved to icicles-opt.el and renamed: icicle-shell-command-candidates. +;; 2009/03/08 dadams +;; Added: icicle-quote-file-name-part-of-cmd. +;; icicle-read-shell-command-completing: +;; Call icicle-quote-file-name-part-of-cmd to escape spaces etc. in file names. +;; Removed unneeded minibuffer-local-*-map let bindings. +;; icicle-dired-smart-shell-command: +;; Protected dired-default-directory with fboundp, for Emacs 20. +;; 2009/03/01 dadams +;; icicle-read-from-minibuffer: +;; No longer use icicle-complete-on-demand-cmd and on-demand-map. +;; 2009/02/28 dadams +;; Don't fset old-dired-smart-shell-command here - do after load Dired-X (icicles-mode.el). +;; Added for Emacs 20: definition of replace-regexp-in-string. +;; icicle-read-(number|string-completing): +;; No need for fboundp of replace-regexp-in-string, since provide it now for Emacs 20. +;; icicle-read-file-name: Treat directory candidates as special candidates. +;; icicle-read-shell-command-completing: +;; Candidate help depends on candidate type. +;; Use existing icicle-extra-candidates as its own default, not icicle-file-extras. +;; 2009/02/27 dadams +;; icicle-shell-command: Fixed typo: shell-command -> old-shell-command. +;; icicle-read-shell-command-completing: Append icicle-file-extras to i*-extra-candidates. +;; 2009/02/23 dadams +;; icicle-read-shell-command-completing: +;; Bind icicle-extra-candidates-dir-insert-p, not insert-default-directory, to nil. +;; icicle-next-candidate: Protect dir insertion with icicle-extra-candidates-dir-insert-p. +;; 2009/02/22 dadams +;; icicle-dired-read-shell-command: Use minibuffer-default-add-shell-commands if available. +;; 2009/02/20 dadams +;; icicle-read-from-minibuffer: Treat icicle-complete-on-demand-cmd - on-demand completion. +;; Added: icicle-dired-smart-shell-command, icicle-read-shell-command-completing, +;; icicle-dired-read-shell-command, icicle-extra-candidates-first-p, +;; icicle-require-match-p, icicle-shell-command(-on-region). +;; icicle-read-shell-command: +;; Call icicle-read-shell-command-completing. Define always, not just when mailcap. +;; icicle-dired-guess-shell-command: Just call icicle-read-shell-command-completing. +;; icicle-shell-command-candidates: Cache completions in icicle-shell-command-candidates. +;; icicle-highlight-input-noncompletion(-rest), icicle-highlight-lighter: +;; Use function icicle-require-match-p, not var. +;; icicle-completing-p: Test also whether parent map is a completion map. Always cache. +;; 2009/02/17 dadams +;; icicle-read-shell-command: Handle nil default-value. Thx to Kao Felix. +;; icicle-read-file-name: Append new proxy cands to any existing ones. +;; Don't assume that a proxy cand is a variable. +;; 2009/01/25 dadams +;; Added: *-dired-guess-shell-command, *-read-shell-command, *-shell-command-candidates. +;; 2009/01/17 dadams +;; icicle-display-candidates-in-Completions: Highlight Levenshtein (1) match. +;; icicle-unsorted-apropos(-file-name)-candidates, icicle-display-Completions, +;; icicle-apropos-any(-file-name)-candidates-p: Removed PCM. +;; Added: icicle-levenshtein(-strict|-one)-match, icicle-levenshtein-one-regexp, +;; icicle-substrings-of-length. +;; 2009/01/15 dadams +;; Lose "icicle-" for fboundp's: completion-all-completions, completion-try-completion. +;; 2009/01/14 dadams +;; Added: icicle-remove-dups-if-extras. +;; 2009/01/13 dadams +;; Added: icicle-completion-all-completions, icicle-completion-try-completion. +;; icicle-unsorted(-file-name)-(prefix|apropos)-candidates, icicle-display-Completions, +;; icicle-any-(prefix|apropos)(-file-name)-candidates-p: +;; Respect icicle-respect-completion-styles-p (Emacs 23). +;; icicle-unsorted-file-name-prefix-candidates: Removed matching "^"++(regexp-quote input). +;; icicle(-unsorted)(-file-name)-(prefix|apropos)-candidates: +;; Call icicle-transform-candidates for extra candidates and proxy candidates too. +;; icicle-display-candidates-in-Completions: Highlight extra candidates. +;; icicle-face-valid-attribute-values: +;; Use font-family-list instead of x-font-family-list, if available. +;; 2009/01/03 dadams +;; icicle-call-then-update-Completions: +;; If icicle-last-completion-command is nil, test icicle-current-completion-mode - don't +;; just call icicle-prefix-complete. E.g. icicle-search shouldn't end with a single +;; prefix match. +;; 2008/12/25 dadams +;; Added: icicle-save-raw-input (factored out from icicle-save-or-restore-input). +;; icicle-save-or-restore-input: +;; Change test whether last-command is cycling cmd to add also not being completing cmd. +;; Use icicle-completing-p instead of testing this-command for being a cycling cmd. +;; Use icicle-save-raw-input. +;; icicle-next-candidate: Set icicle-cycling-p (new var) to t. +;; 2008/12/20 dadams +;; icicle-save-or-restore-input: Don't restore last input if this is a completing command. +;; 2008/12/07 dadams +;; icicle-completing-read, icicle-read-file-name-1: +;; Removed icicle-prompt. Don't add completion prompt prefix, except for Emacs 20. +;; 2008/12/06 dadams +;; icicle-call-then-update-Completions: +;; To update, call icicle-last-completion-command, not icicle-(apropos|prefix)-complete. +;; 2008/12/02 dadams +;; icicle-unsorted(-file-name)-apropos-candidates: +;; Call icicle-filter-wo-input before filtering with user input (as the doc string says). +;; 2008/11/28 dadams +;; icicle-recompute-candidates, icicle-save-or-restore-input: +;; Test property icicle-(prefix|apropos)-completing-command, not eq cmds. +;; 2008/11/23 dadams +;; icicle-read-file-name: +;; Don't initialize icicle-proxy-candidates unless icicle-add-proxy-candidates-flag. +;; Don't add + to completion indicator if Emacs 23. +;; 2008/11/22 dadams +;; icicle-completing-read: +;; Bind icicle-fancy-cands-internal-p. Do not call icicle-mctize-all unless fancy cands. +;; icicle-mctized-full-candidate: +;; No-op unless icicle-fancy-cands-internal-p or icicle-whole-candidate-as-text-prop-p. +;; icicle-read-(number|char-exclusive|string-completing|face-name): +;; Put icicle-fancy-candidates property on prompt if proxy candidates. +;; icicle-display-candidates-in-Completions: +;; Don't transform candidates unless icicle-fancy-cands-internal-p. +;; 2008/11/18 dadams +;; icicle-display-candidates-in-Completions: +;; Add icicle-special-candidate property as text property to candidates in +;; icicle-completion-candidates, instead of just to display candidate, so returned also. +;; Added support for icicle-display-string property. +;; For these properties: look up symbol first in minibuffer-completion-table if obarray. +;; 2008/11/14 dadams +;; icicle-display-candidates-in-Completions: +;; Respect icicle-hide-common-match-in-Completions-flag. +;; 2008/11/10 dadams +;; icicle(-unsorted)(-file-name)-(apropos|prefix)-candidates: +;; Moved special and proxy candidates outside match filtering, +;; reversing a change made on 2007/11/18. Dunno why that change was made. +;; But filter special and proxy candidates using the input. +;; 2008/11/09 dadams +;; Added: icicle-join-nth-parts, icicle-display-cand-from-full-cand. +;; icicle-transform-multi-completion: Use icicle-join-nth-parts. +;; icicle-transform-multi-completion: Don't test icicle-list-join-string (always non-nil). +;; icicle-first-matching-candidate: +;; Fix: set res properly, not to the tested value. Thx to Hannes Janetzek. +;; 2008/11/07 dadams +;; icicle-color-name-w-bg: Return input if hexrgb.el is not loaded. Thx to Fabrice Knevez. +;; 2008/11/04 dadams +;; icicle-read-face-name: Soft-require eyedropper.el or palette.el. +;; 2008/11/03 dadams +;; icicle-expanded-common-match: Bug fix for Emacs 20: If error matching, just return INPUT. +;; icicle-highlight-input-noncompletion: Erase any message first before highlighting. +;; 2008/11/02 dadams +;; icicle-display-candidates-in-Completions: For icicle-candidate-properties-alist, use +;; narrowed buffer content, not i-current-completion-in-Completions. +;; 2008/10/24 dadams +;; icicle-first-matching-candidate: +;; Use regexp-quote on CAND. +;; Add icicle-list-end-string to each entry in CANDIDATES. +;; Iteration, not recursion. +;; icicle-get-alist-candidate: Added optional arg NO-ERROR-P. +;; 2008/10/18 dadams +;; Replaced customize-save-variable by funcall icicle-customize-save-variable-function. +;; 2008/10/14 dadams +;; Applied renaming of icicle-completion-help to icicle-minibuffer-help. +;; 2008/10/06 dadams +;; Don't toggle icy-mode after loading crm.el unless icy-mode is defined (!). +;; icicle-ms-windows-NET-USE: If hash tables not available, just run the NET USE process. +;; 2008/10/04 dadams +;; Substitute Icicles version of completing-read-multiple and its maps. Thx to Per Nordlow. +;; Added: (icicle|old)-completing-read-multiple, icicle-define-crm-completion-map, +;; (icicle|old)-crm-local-(completion|must-match)-map. +;; icicle-display-completion-list: Protect against Emacs 23 nonsense with base-size in cdr. +;; 2008/09/30 dadams +;; Added: icicle-ms-windows-NET-USE. Thx to Thomas Lim. +;; icicle-file-remote-p: Use icicle-ms-windows-NET-USE. +;; icicle-highlight-input-noncompletion: Return file-local-p if test shows it's local. +;; icicle-call-then-update-Completions: +;; Treat also known file-local-p return from icicle-highlight-input-noncompletion. +;; Renamed icicle-isearch-complete-1 to icicle-isearch-complete-past-string and moved it +;; here from icicles-mcmd.el. +;; icicle-isearch-complete-past-string: Always use regexp-search-ring. Changed prompt. +;; 2008/09/27 dadams +;; icicle-highlight-input-noncompletion: Fixed typo: implicit-remote -> implicit. +;; 2008/09/20 dadams +;; icicle-(apropos|prefix)-candidates, icicle-maybe-sort-and-strip-candidates: +;; Strip ignored files if icicle-abs-file-candidates. +;; 2008/09/19 dadams +;; icicle-get-candidates-from-saved-set: Added optional arg DONT-EXPAND-FILESETS-P. +;; Use icicle-kill-a-buffer, not kill-buffer. +;; Moved icicle-kill-a-buffer here from icicles-cmd.el. +;; Added: icicle-unpropertize. +;; icicle-completing-read, icicle-read-file-name: Use icicle-unpropertize. +;; 2008/09/16 dadams +;; filesets-get-filelist: Fixed :tree so it includes files in subdirs. +;; Added: icicle-filesets-files-under. +;; 2008/09/15 dadams +;; Added: icicle-saved-fileset-p, icicle-displayable-cand-from-saved-set. +;; icicle-get-candidates-from-saved-set: +;; Rewrote code to convert saved candidates to displayable candidates. +;; Use icicle-displayable-cand-from-*, icicle-saved-fileset-p. Require filesets.el. +;; Moved filesets-get-fileset-from-name into and of first cond clause. +;; Wrapped defun of filesets-get-filelist in eval-after-load. +;; 2008/09/13 dadams +;; Added: icicle-get-candidates-from-saved-set (factored from code in +;; icicle-retrieve-candidates-from-set), filesets-get-filelist (redefined), +;; icicle-explicit-saved-completion-candidates. +;; Moved here from icicles-mcmd.el: icicle-readable-to-markers. +;; 2008/09/04 dadams +;; icicle-read-file-name-1: Removed unused code for non icicle-mode case. +;; 2008/09/03 dadams +;; Removed: icicle-(un)highlight-crosshairs, icicle-unhighlight-crosshairs+cleanup. +;; 2008/09/01 dadams +;; Added: icicle-(un)highlight-crosshairs, icicle-unhighlight-crosshairs+cleanup. +;; 2008/08/29 dadams +;; icicle-mctize-all: +;; Do it for all list collections (new icicle-mctized-full-candidate). +;; Adjust PRED to use cdr only for conses with string cars. +;; icicle-mctized-full-candidate: +;; Treat all kinds of list entries: strings, symbols, and conses with symbol args, etc. +;; 2008/08/25 dadams +;; icicle-display-candidates-in-Completions: Do nothing if NO-DISPLAY-P is 'no-msg. +;; 2008/08/24 dadams +;; icicle-filter-wo-input: Filter out empty-string candidates: "". +;; Added: icicle-minibuf-input-sans-dir. +;; Renamed: icicle-minibuffer-contents-from-minibuffer to icicle-input-from-minibuffer, +;; icicle-minibuffer-contents to icicle-minibuf-input. +;; icicle-display-candidates-in-Completions, icicle-next-candidate, icicle-place-cursor: +;; Use icicle-minibuf-input-sans-dir. +;; 2008/08/23 dadams +;; icicle-display-candidates-in-Completions: +;; Wrap preliminary display of *Completions* in save-selected-window. +;; 2008/08/22 dadams +;; icicle-display-candidates-in-Completions: +;; Display *Completions* before calling with-output-to-temp-buffer and filling it. +;; This is so we can know the window width, to determine the correct formatting. +;; icicle-insert-candidates: +;; Don't use lru window or *-Completions-*-default-width (removed). Failsafe width 40. +;; 2008/08/21 dadams +;; icicle-completing-read: +;; Bind minibuffer-completing-file-name to nil if not completing a file name. +;; Removed setq of minibuffer-completion-table. Already do it in *-lisp-vanilla-*. +;; 2008/08/20 dadams +;; icicle-insert-candidates: +;; Turn off mouse-face after insert candidate. +;; Fixup whitespace correctly: Don't remove whitespace that is part of a candidate. +;; Added: icicle-ding. +;; icicle-read-number: Replaced ding by icicle-ding. +;; 2008/08/18 dadams +;; Moved here from icicles-cmd.el (and renamed from *-less-p): icicle-cdr-lessp. +;; Added: icicle-delete-count, icicle-mctize-all, icicle-mctized-(display|full)-candidate, +;; icicle-part-1-cdr-lessp. +;; Renamed: icicle-delete-if(-not) to icicle-remove-if(-not), +;; icicle-put-alist-candidate to icicle-put-whole-cand-prop, +;; icicle-update-completions to icicle-complete-again-update. +;; icicle-completing-read: Factored out transformation to MCT into new fn icicle-mctize-all. +;; 2008/08/08 dadams +;; icicle-completing-read: Updated doc string for Emacs 23. +;; 2008/08/03 dadams +;; icicle-completing-read: Convert the predicate to apply to just the cdr (= original cons). +;; icicle-save-or-restore-input: Don't save empty string ("") to C-l history. +;; 2008/07/27 dadams +;; Added: icicle-2nd-part-string-less-p. +;; Moved here from icicles-mcmd.el: icicle-transform-multi-completion. +;; 2008/07/19 dadams +;; icicle-choose-completion-string: Don't move to point-max unless in minibuffer. +;; 2008/06/24 dadams +;; Make *-must-match-filename-map an alias for *-filename-completion-map. Use the latter. +;; 2008/06/22 dadams +;; icicle-completing-read, icicle-read-file-name: +;; Remove text properties from result (only) if icicle-unpropertize-*-flag. +;; 2008/06/21 dadams +;; icicle-read-file-name: Remove text properties from result file name. +;; 2008/06/01 dadams +;; icicle-lisp-vanilla-completing-read: Typo: minibuffer-local-must-match-filename-map. +;; Put sort predicate properties on some sort predicate symbols, e.g. icicle-dirs-last-p. +;; 2008/05/22 dadams +;; icicle-read-file-name: Bind minibuffer-completing-file-name to t. +;; icicle-read-file-name-1: Do not prepend ". " if Emacs 23+, since it uses completing-read. +;; icicle-(un)highlight-lighter: Reflect case-sensitivity in lighter. +;; 2008/05/11 dadams +;; icicle-unsorted(-file-name)-apropos-candidates: +;; Pass input to all-completions only if not icicle-apropos-complete-match-fn. +;; 2008/05/11 dadams +;; Renamed icicle-fit-Completions-window to icicle-fit-completions-window. +;; icicle-fit-completions-window: Use current window - not necessarily for *Completions*. +;; 2008/05/06 dadams +;; icicle-highlight-lighter: Wrap redisplay in condition-case to ignore any errors. +;; 2008/05/05 dadams +;; icicle-file-name-input-p: Redefined to just use minibuffer-completing-file-name. +;; 2008/05/01 dadams +;; icicle-lisp-vanilla-completing-read, icicle-lisp-vanilla-completing-read, +;; icicle-read-from-minibuffer, icicle-read-number, icicle-read-string-completing: +;; Adapted to Emacs 23 change to allow list of strings for default value. +;; 2008/04/25 dadams +;; icicle-call-then-update-Completions: +;; nil icicle-test-for-remote-files-flag means don't test for remote file name. +;; icicle-highlight-input-noncompletion: +;; Correction: implicit, not always, in combination with not incremental completion. +;; Added check for icicle-completing-command if value is explicit*. +;; Added check for icicle-test-for-remote-files-flag if *-strict with lax completion. +;; Protect call to icicle-file-remote-p with check of icicle-test-for-remote-files-flag. +;; 2008/04/18 dadams +;; Renamed icicle-init-value-flag to icicle-default-value. +;; icicle-read-from-minibuffer: +;; If icicle-default-value is t, add to prompt. Thx to Dominique Quatrevaux. +;; icicle-completing-read, icicle-read-file-name-1, icicle-read-from-minibuffer: +;; Change icicle-default-value test to rule out t also. +;; icicle-completion-setup-function: +;; Don't call file-name-directory unless minibuffer-completing-file-name. +;; 2008/04/01 dadams +;; icicle-unsorted(-file-name)-apropos-candidates: +;; If icicle-unsorted-apropos-candidates pass input to all-completions. +;; icicle-expanded-common-match-1: +;; Use icicle-apropos-complete-match-fn throughout, but return nil if that is nil. +;; icicle-display-candidates-in-Completions: +;; If icicle-apropos-complete-match-fn is nil, don't try to highlight input match. +;; 2008/03/31 dadams +;; icicle-display-candidates-in-Completions: +;; Allow for no completion type, for No completions msg. +;; 2008/03/30 dadams +;; icicle-read-file-name-1: +;; Bind read-file-name-function to nil. +;; Funcall icicle-old-read-file-name-fn instead of old-read-file-name. +;; icicle-(un)highlight-lighter: Respect icicle-highlight-lighter-flag. +;; Top-level: Moved fset for old-read-file-name to icicles-mode.el and renamed it. +;; 2008/03/29 dadams +;; icicle-completing-read, icicle-read-file-name-1: +;; Combine new faces for single-character minibuffer completion status indicator. +;; Call icicle-highlight-lighter after establishing require-match, not at beginning. +;; No longer use completing-prompt-prefix(-symb). +;; No longer use icicle-reminder-prompt-flag (no longer add help to prompt). +;; Removed: icicle-control-reminder-prompt. +;; icicle-highlight-lighter: +;; Combine faces for highlighting. Indicate multi-command and strict/lax completion. +;; icicle-unhighlight-lighter: Add + for multi-command. Don't bother to propertize strg. +;; icicle-file-remote-p: If name matches Windows drive letter, don't try other remote tests. +;; 2008/03/11 dadams +;; icicle-completing-read-history: +;; Convert cons list elements to strings. Lets you use M-o with command-history. +;; 2008/03/09 dadams +;; Added: icicle-(un)highlight-lighter. +;; icicle-completing-read, icicle-read-file-name: Call icicle-highlight-lighter. +;; 2008/03/08 dadams +;; icicle-completing-p: Replaced where-is-internal test with completion keymaps test. +;; 2008/03/05 dadams +;; icicle-completing-read: +;; Copy TABLE etc. only if candidates are strings. Thx to Damon Permezel for bug report. +;; icicle-files-within: Skip inaccessible directories and unreadable files. Thx to Damon. +;; 2008/02/28 dadams +;; icicle-completing-read: Fixed test for multicompletion: List of strings, not just list. +;; 2008/02/24 dadams +;; Added: icicle-scatter(-match). +;; icicle-display-*-in-Completions: Highlighting of input match can use icicle-scatter. +;; Use icicle-apropos-complete-match-fn in message. +;; icicle-expanded-common-match-1: Use icicle-apropos-complete-match-fn, not string-match. +;; 2008/02/23 dadams +;; icicle-completing-read: +;; Change initial-input to a cons with 0 position if icicle-init-value-flag is *-start. +;; icicle-lisp-vanilla-completing-read: Set position to end of initial-input, by default. +;; Convert zero-based position to one-based. +;; 2008/02/22 dadams +;; icicle-completing-read: +;; For all alist candidates (not just multi-completion): +;; Copy the car and replace the cdr with the whole candidate. +;; icicle-get-alist-candidate: Get and return just whole icicle-whole-candidate property. +;; icicle-completion-setup-function (for Emacs 20): +;; minibuffer-prompt-end -> icicle-minibuffer-prompt-end. +;; 2008/02/16 dadams +;; icicle-get-alist-candidate: +;; Reconstitute whole candidate, by consing string onto data, which is only the cdr now. +;; icicle-completing-read: Use icicle-put-alist-candidate to put candidate data onto string. +;; Added: icicle-put-alist-candidate. Put only the cdr (data), not whole, onto the string. +;; 2008/02/14 dadams +;; Added: icicle-substring-no-properties. +;; 2008/02/11 dadams +;; icicle-read-string-completing: Moved save-match-data so replace-match can use match data. +;; 2008/02/06 dadams +;; icicle-highlight-input-noncompletion: +;; Wait icicle-highlight-input-completion-failure-delay before highlighting. +;; Don't highlight if past icicle-highlight-input-completion-failure-threshold. +;; Combined input-pending test with highlighting test, and moved it before file-name test. +;; Conditionalized face removal. +;; Return nil when input within delay preempts highlighting. +;; icicle-highlight-initial-whitespace: Removed only vestigial whitespace highlighting. +;; icicle-read-number: Moved save-match-data outside cond. +;; 2008/02/03 dadams +;; icicle-choose-completion-string: +;; Go to point-max before insert choice. Respect icicle-dir-candidate-can-exit-p. +;; icicle-completion-setup-function: +;; Set default dir only if this is a completion cmd or not *-comp-base-is-default-dir-p. +;; If icicle-comp-base-is-default-dir-p, set completion-base-size to default-dir length. +;; icicle-read-file-name: Bind ffap vars to prevent slowing down ffap-guesser. +;; 2008/01/29 dadams +;; Added: icicle-(apropos|prefix)-any(-file-name)-candidates-p, +;; icicle-subst-envvar-in-file-name, icicle-highlight-input-noncompletion-rest, +;; icicle-any-candidates-p, icicle-file-remote-p. +;; icicle-minibuffer-contents-from-minibuffer: Use icicle-subst-envvar-in-file-name. +;; icicle-call-then-update-Completions: +;; Reinitialize icicle-input-fail-pos to nil. +;; If we know input is a remote file name from failure highlighting, skip remote test. +;; Use icicle-file-remote-p, not file-remote-p. +;; icicle-highlight-input-noncompletion: Rewrote. +;; Takes no args now. +;; Do nothing if input pending or input is empty. +;; Use icicle-file-remote-p, not file-remote-p. Return value indicating remote file name. +;; Use new values of icicle-highlight-input-completion-failure, including always. +;; First check through last two chars, then icicle-highlight-input-noncompletion-rest. +;; icicle-highlight-input-noncompletion-rest (was in icicle-highlight-input-noncompletion): +;; No longer use icicle-max-chars-noncompletion-highlight. +;; Use icicle-any-candidates-p, so don't compute candidate lists. +;; 2008/01/15 dadams +;; icicle-command-abbrev-save: Added condition-case with message in case of error. +;; icicle-control-reminder-prompt: Added message. +;; 2008/01/13 dadams +;; icicle-read-face-name: Use icicle-transform-multi-completion. +;; icicle-next-candidate: Do not use icicle-transform-multi-completion. +;; icicle-next-candidate, icicle-save-or-restore-input: Do not treat handle-switch-frame. +;; 2008/01/08 dadams +;; Renamed icicle-expanded-common-match to icicle-expanded-common-match-1. +;; New icicle-expanded-common-match uses longest of two tries. +;; icicle-expanded-common-match-1, first loop: Match ecm only up to orig-match-end. +;; icicle-read-file-name: Use icicle-var-is-of-type-p for proxy candidates. +;; icicle-choose-completion-string, icicle-strip-ignored-files-and-sort, +;; icicle-filter-wo-input, icicle-first-matching-candidate, +;; icicle-(proxy-candidate|prefix-keys)-first-p, icicle-var-(matches|inherits)-type-p, +;; icicle-read-(number|face-name|file-name|string-completing), +;; icicle-unsorted(-file-name)-prefix-candidates, icicle-expanded-common-match-1, +;; icicle-next-candidate, icicle-remove-dots: Wrap string-match in save-match-data. +;; icicle-display-candidates-in-Completions: Moved save-match-data locations. +;; 2008/01/05 dadams +;; icicle-next-candidate: Don't refresh Completions if last-command = handle-switch-frame. +;; 2008/01/04 dadams +;; icicle-insert-candidates: Put property icicle-keep-newline on final \n of candidate. +;; 2007/12/31 dadams +;; icicle-choose-completion-string: In minibuffer, delete all input before inserting. +;; 2007/12/27 dadams +;; icicle-unsorted(-file-name)-apropos-candidates: +;; Use null *-apropos-*-match-fn, not function-valued TABLE to inhibit input match. +;; 2007/12/26 dadams +;; icicle-next-candidate: Raise *Completions* frame at the end. +;; 2007/12/24 dadams +;; icicle-unsorted(-file-name)-apropos-candidates: +;; Don't match input regexp if minibuffer-completion-table is a function. +;; icicle-var-inherits-type-p: +;; Recheck var-type match after set var-type to its car. +;; Handle string (regexp) TYPES elements. +;; icicle-value-satisfies-type-p: Skip type check for string type (regexp). +;; icicle-var-is-of-type-p: Doc string. Use icicle-var-matches-type-p. +;; Added: icicle-var-matches-type-p, icicle-custom-type. +;; 2007/12/23 dadams +;; icicle-var-is-of-type-p: +;; Added MODE arg. Use icicle-var-inherits-type-p, icicle-var-val-satisfies-type-p. +;; Redefined as MODE choice, not just a simple or. Treat more cases. +;; Added: icicle-var-inherits-type-p, icicle-var-val-satisfies-type-p, +;; icicle-value-satisfies-type-p. +;; icicle-read-(number|char-exclusive|string-completing|face-name): +;; Don't fill icicle-proxy-candidates unless icicle-add-proxy-candidates-flag. +;; Corrected doc string to refer to icicle-add-proxy-candidates-flag. +;; 2007/12/22 dadams +;; icicle-var-is-of-type-p: +;; Check supertypes also. Use both :validate and :match. +;; Wrap type check in condition-case. Use widget-put instead of plist-put. +;; Added soft require of wid-edit+.el. +;; 2007/12/21 dadams +;; icicle-var-is-of-type-p: Use :validate, not :match, for the test. +;; 2007/12/19 dadams +;; icicle-display-candidates-in-Completions: +;; Ensure icicle-last-input is non-nil in (file-name-directory icicle-last-input). +;; 2007/12/14 dadams +;; icicle-fit-Completions-window: +;; Don't try to get a property if it's not a symbol. Thx to Mike Mattie. +;; 2007/12/11 dadams +;; Added: icicle-read-char-exclusive. +;; icicle-read-face-name: Include face-name vars as proxy candidates. +;; 2007/12/10 dadams +;; icicle-highlight-input-noncompletion: Use face icicle-input-completion-fail-lax also. +;; 2007/12/09 dadams +;; icicle-highlight-input-noncompletion: Respect icicle-max-chars-noncompletion-highlight. +;; 2007/12/08 dadams +;; icicle-read-file-name: +;; Include file-name variables as proxy candidates. Reset icicle-proxy-candidates at end. +;; icicle-read-number: float type is not defined before Emacs 22. +;; icicle-read-string-completing: +;; Set default to "" if nil, but only after completing-read. +;; Set car of hist to var value, replacing var name. Treat consp hist also. +;; 2007/12/03 dadams +;; Renamed icicle-longest-common-match to icicle-expanded-common-match. +;; 2007/12/02 dadams +;; Added: icicle-var-is-of-type-p. +;; icicle-read-(number|string-completing): +;; Use icicle-var-is-of-type-p, to handle compatible types. +;; 2007/11/30 dadams +;; icicle-read-file-name, icicle-read-(number|string-completing), +;; icicle-display-candidates-in-Completions, icicle-proxy-candidate-first-p: +;; Use only membership in icicle-proxy-candidates, not icicle-proxy-candidate property. +;; icicle-choose-completion-string: +;; Condition for exit: could be no minibuffer-completion-table if extra or proxy cands. +;; 2007/11/29 dadams +;; icicle-read-(number|string-completing): +;; Treat icicle-add-proxy-candidates-flag and icicle-proxy-candidates. +;; icicle-display-candidates-in-Completions: Treat empty icicle-completion-candidates. +;; 2007/11/27 dadams +;; Added: icicle-read-number, icicle-read-string-completing. +;; icicle-read-file-name: Remove icicle-proxy-candidate property in unwind-protect. +;; 2007/11/25 dadams +;; Added: icicle-command-abbrev(save|-used-more-p). +;; 2007/11/24 dadams +;; icicle-longest-common-match, first loop: string-match -> not string-match. +;; len-first -> length of lcm. +;; Added: icicle-proxy-candidate-first-p. +;; 2007/11/18 dadams +;; icicle(-unsorted)(-file-name)-(apropos|prefix)-candidates: +;; Include also icicle-proxy-candidates. +;; Move special and proxy candidates inside match filtering. +;; icicle-display-candidates-in-Completions: +;; Don't expand directory when highlighting special candidate. +;; 2007/11/02 dadams +;; icicle-longest-common-match: +;; First loop: (1) match against at most len-first, (2) put the match into the and test. +;; 2007/10/28 dadams +;; icicle-display-candidates-in-Completions: +;; Always highlight longest common match for prefix completion. +;; icicle-unsorted(-file-name)-prefix-candidates, icicle-fuzzy-candidates: +;; Set icicle-common-match-string, regardless of icicle-expand-input-*-flag. +;; icicle-save-or-restore-input: +;; Update to lcm even if no input change, if completion mode changed. +;; Update to lcm if prefix completing, even if icicle-expand-input-*-flag is nil. +;; Save input for C-l even if this command is an icicle-completing-command (?). +;; Don't reset raw input to "" if cycling, so keep highlight in *Completions*. +;; icicle-longest-common-match: Test prefix through embedded input each time. +;; 2007/10/26 dadams +;; icicle-read-face-name (Emacs 22): Fix the treatment of default value. +;; 2007/10/22 dadams +;; icicle-display-candidates-in-Completions: +;; Highlight only regexp matching part of special candidates. +;; Highlight special cands regardless of icicle-highlight-historical-candidates-flag. +;; 2007/10/02 dadams +;; icicle-next-candidate: +;; Apply abbreviate-file-name to file-name input. Thx to Joonhwan Lee. +;; 2007/09/29 dadams +;; Added: icicle-fuzzy-candidates. +;; icicle-prefix-candidates: Treat fuzzy completion. +;; icicle-display-candidates-in-Completions: +;; For prefix completion, highlight literal input match in Completions. +;; 2007/09/26 dadams +;; icicle-read-from-minibuffer: Removed keep-all arg - see also 2006/06/01. +;; 2007/09/22 dadamms +;; icicle-completing-read, icicle-read-from-minibuffer: +;; Ensure that init arg is string when get it from default arg via icicle-init-*-flag. +;; 2007/09/18 dadams +;; icicle-call-then-update-Completions: +;; Test icicle-current-completion-mode, not icicle-last-completion-command. +;; 2007/09/16 dadams +;; icicle-call-then-update-Completions: +;; Don't complete if file-remote-p. +;; Highlight completion failure only if input > icicle-*-display-min-input-chars. +;; icicle-highlight-input-noncompletion: +;; Don't highlight unless also icicle-incremental-completion-flag. +;; Call icicle-file-name-*-candidates for file-name input. +;; Don't highlight if file-remote-p and reading file name. Instead, remove highlighting. +;; 2007/09/14 dadams +;; icicle-highlight-input-noncompletion, icicle-update-completions, +;; icicle-recompute-candidates: +;; Wrapped condition-case around candidates computation. +;; 2007/09/02 dadams +;; icicle-display-candidates-in-Completions: +;; Restore point and window point to start of candidates in *Completions*. +;; 2007/08/21 dadams +;; icicle-highlight-input-noncompletion: Remove any vestigial highlighting on matched part. +;; 2007/08/19 dadams +;; Added: icicle-lisp-vanilla-completing-read, icicle-highlight-input-noncompletion. +;; icicle-completing-read: +;; Allow reading and returning string candidates with properties: +;; bind minibuffer-allow-text-properties. +;; Put whole candidate on string as text property. +;; Use icicle-lisp-vanilla-completing-read, not old-completing-read. +;; icicle-call-then-update-Completions: Call icicle-highlight-input-noncompletion. +;; icicle-get-alist-candidate: +;; If icicle-whole-candidate-as-text-prop-p, try to get full candidate from text prop. +;; 2007/08/16 dadams +;; icicle-insert-candidates: Don't reset text props if endpos > point. Thx Chris Hecker. +;; 2007/08/14 dadams +;; icicle-increment-cand-nb+signal-end: Removed audible bell - use visible bell only. +;; 2007/07/22 dadams +;; icicle-read-face-name (Emacs 22 version): +;; Revert multiple branch to not use icicle-make-face-candidate. +;; Moved here from icicles-mode.el: icicle-completing-p. +;; 2007/07/06 dadams +;; icicle-display-candidates-in-Completions: Leave cursor at start of candidates. +;; 2007/07/03 dadams +;; icicle-save-or-restore-input: +;; Add current-raw-input to icicle-previous(-non)-file-*-raw-inputs, respecting max len. +;; Don't save input if current command is C-l or C-L. +;; If don't save raw input, set it to empty string. +;; Added: icicle-put-at-head. +;; icicle-highlight-complete-input: Ensure no error treatment in call to search-forward. +;; icicle-display-candidates-in-Completions: +;; Ensure non-nil current(-raw)-input, for highlight. +;; 2007/06/23 dadams +;; Added: icicle-completing-read-history. +;; Moved here from icicles-cmd.el: icicle-read-from-minibuf-nil-default. +;; 2007/06/20 dadams +;; icicle-make-face-candidate, icicle-read-face-name: +;; Use new string value of icicle-WYSIWYG-Completions-flag. +;; 2007/06/19 dadams +;; icicle-read-face-name: +;; Use a multi-completion, depending on icicle-WYSIWYG-Completions-flag. +;; For Emacs 22, isolate the multiple case and do nothing for it. +;; icicle-make-face-candidate: Treat also whole-number value for icicle-WYSIWYG-*-flag. +;; 2007/06/17 dadams +;; icicle-make-face-candidate: Respect icicle-WYSIWYG-Completions-flag. +;; icicle-display-candidates-in-Completions: highlight saved candidates. +;; icicle-place-overlay: Added priority arg. +;; 2007/06/13 dadams +;; icicle-display-candidates-in-Completions: +;; Upgrade icicle-incremental-completion-p only if redisplaying. Thx Mark Elston. +;; 2007/06/10 dadams +;; Removed unconditional add-hook for icicle-fit-Completions-window. +;; 2007/06/09 dadams +;; icicle-insert-candidates: Don't mouse-face last char of candidate if it is a newline. +;; icicle-display-candidates-in-Completions: Treat icicle-candidate-properties-alist last. +;; 2007/06/07 dadams +;; icicle-read-face-name: Use (icicle-)face-name-history. +;; 2007/06/05 dadams +;; Added soft require of hexrgb.el, but only if window-system. +;; icicle-color*: Protected with featurep hexrgb and error message. +;; 2007/06/01 dadams +;; icicle-completing-read, icicle-read-from-minibuffer, icicle-read-string: +;; Use M@R%M=X!L$S+P&L^T*Z to avoid name capture by minibuffer-history-variable's value. +;; icicle-display-candidates-in-Completions, icicle-historical-alphabetic-p, +;; icicle-most-recent-first-p: +;; Ensure value of minibuffer-history-variable is bound. +;; 2007/05/29 dadams +;; icicle-call-then-update-Completions: Don't recomplete if only one candidate. +;; 2007/05/24 dadams +;; icicle-completing-read, icicle-read-file-name: +;; Fix length test for consp initial-input. Thx to Anupam Sengupta. +;; 2007/05/04 dadams +;; icicle-unsorted-*: C-g quits to top-level. +;; icicle-candidate-set-1, icicle-scroll-or-update-*, icicle-msg-maybe-in-minibuffer: +;; Move to minibuffer window for minibuffer-message. +;; icicle-display-candidates-in-Completions, icicle-highlight-initial-whitespace, +;; icicle-unsorted-file-name-*-candidates, icicle-longest-common-match, +;; icicle-next-candidate, icicle-place-cursor, icicle-highlight-complete-input, +;; icicle-special-candidates-first-p, icicle-case-string-less-p: +;; Use read-file-name-completion-ignore-case, if completing file name. +;; Moved mention of read-file-name-completion-ignore-case and +;; icicle-cycle-into-subdirs-flag from icicle-completing-read to icicle-read-file-name. +;; Added empty defvars for Emacs 22 standard vars, to quiet byte compiler. +;; 2007/04/29 dadams +;; Added: icicle-last-modified-first-p. +;; icicle-call-then-update-Completions: Delete icicle-complete-input-overlay. +;; 2007/04/08 dadams +;; Added: icicle-highlight-candidate-in-Completions, from code in icicle-next-candidate. +;; But changed to: 1) make Completions dedicated and 2) not bind case-fold-search. +;; icicle-next-candidate: Use icicle-highlight-candidate-in-Completions. +;; 2007/04/02 dadams +;; Moved here from icicles-cmd.el: icicle-filter-alist, icicle-first-matching-candidate. +;; 2007/04/01 dadams +;; icicle-insert-candidates: Don't fixup-whitespace if bolp. +;; 2007/03/30 dadams +;; icicle-fit-Completions-window: Don't resize *Completions* window if split horizontally. +;; icicle-insert-candidates: +;; Calculate nb of columns using max-candidate-len, not number of candidates. +;; Indent at least one colwidth, and leave less space between candidates. +;; 2007/03/26 dadams +;; icicle-completion-setup-function: +;; Protected minibuffer-completing-symbol with boundp (not define in Emacs 23). +;; 2007/03/23 dadams +;; icicle-completing-read, icicle-read-file-name: +;; Record require-match in icicle-require-match-p. +;; 2007/03/17 dadams +;; icicle-read-face-name: Undo Emacs 21+ brain-dead treatment of PROMPT arg. +;; 2007/03/14 dadams +;; icicle-fit-Completions-window: +;; Don't let *Completions* take over the frame, so don't lose other window. +;; Respect icicle-Completions-window-max-height property of top-level command. +;; 2007/03/12 dadams +;; Added: icicle-fit-Completions-window. Use in temp-buffer-show-hook. +;; icicle-display-completion-list: +;; Print help lines here, not in icicle-completion-setup-*, so window fit includes them. +;; Put face on string candidates intro string, Possible completions are:. +;; icicle-completion-setup-function: +;; Don't print the help lines here. +;; Updated wrt latest Emacs 22 CVS version. +;; icicle-insert-Completions-help-string: Remove second newline at end. +;; icicle-start-of-candidates-in-Completions: Advance 1 or 2 lines, not 0 or 3. +;; 2007/03/10 dadams +;; icicle-display-completion-list: Rewrote to adjust columns to window width. +;; Added: icicle-insert-candidates. +;; 2007/03/09 dadams +;; Moved icicle-get-alist-candidate here from icicles-cmd.el. +;; 2007/03/07 dadams +;; icicle-choose-completion-string, icicle-next-candidate: +;; Use 0, not t, as frame arg to get-buffer-window. +;; 2007/03/04 dadams +;; icicle-highlight-initial-whitespace: Removed unused local var input-start-position. +;; icicle-completing-read: Do not initialize icicle-candidates-alist. +;; 2007/03/03 dadams +;; icicle-reversible-sort: Don't display Sorting candidates message - too annoying. +;; 2007/03/02 dadams +;; icicle-completion-setup-function for Emacs 22: Don't use file-name-directory if nil. +;; 2007/03/01 dadams +;; icicle-completing-read: Initialize icicle-candidates-alist. +;; 2007/02/24 dadams +;; icicle-next-candidate: +;; Transform multi-completion icicle-last-completion-candidate. +;; If last-command is icicle(mouse)-remove-candidate don't reset common match string or +;; redisplay *Completions*. +;; icicle-recompute-candidates: +;; Don't recompute if icicle-last-completion-command is icicle-mouse-remove-candidate. +;; 2007/02/18 dadams +;; icicle-save-or-restore-input: Use "" if file-name-directory is nil. Thx Shreevatsa R. +;; 2007/02/17 dadams +;; icicle-reversible-sort: No Sorting... message if icicle-edit-update-p. Thx Shreevatsa. +;; 2007/02/05 dadams +;; icicle-completing-read: Added info about multi-completions to doc string. +;; 2007/02/04 dadams +;; icicle-display-candidates-in-Completions: Fixed composition of multiple faces. +;; 2007/02/03 dadams +;; Renamed icicle-icompleting-p to icicle-edit-update-p. +;; Require icicles-var.el. Removed eval-when-compile for require of icicles-opt. +;; 2007/02/02 dadams +;; icicle-case-string-less-p: Use var, not function, icicle-completing-p (else too slow). +;; icicle-reversible-sort: Added sorting progress message. +;; 2007/01/29 dadams +;; icicle-display-candidates-in-Completions: +;; Allow for consp proplist value of icicle-special-candidate. +;; icicle-special-candidates-first-p: Added neither-special case. Treat letter case. +;; Renamed: icicle-case-insensitive-string-lessp to icicle-case-insensitive-string-less-p. +;; Added: icicle-case-string-less-p. +;; icicle-historical-alphabetic-p, icicle-most-recent-first-p, icicle-dirs-last-p, +;; icicle-part-N-lessp, icicle-prefix-keys-first-p: +;; Use icicle-case-string-less-p, not string-lessp. +;; icicle-prefix-keys-first-p: Ignore case. +;; 2007/01/28 dadams +;; Added: icicle-command-names-alphabetic-p. +;; Moved here from icicles-cmd.el: +;; icicle-prefix-keys-first-p, icicle-special-candidates-first-p. +;; 2007/01/23 dadams +;; Added: icicle-read-face-name, icicle-make-face-candidate, +;; icicle-face-valid-attribute-values, icicle-color-name-w-bg. +;; icicle-choose-completion-string: Added Emacs 21 version. +;; icicle-display-candidates-in-Completions: +;; Only highlight past inputs if icicle-highlight-historical-candidates-flag. +;; 2007/01/22 dadams +;; icicle-part-N-lessp, icicle-color-*-lessp: Do nothing if strings are not multipart. +;; icicle-display-candidates-in-Completions: +;; Highlight past inputs after treat *-prop*-alist. +;; icicle-delete-whitespace-from-string: Added optional args. +;; 2007/01/21 dadams +;; Added: icicle-part-*-lessp, icicle-color-*-lessp. +;; 2007/01/20 dadams +;; Added: icicle-display-completion-list. +;; 2007/01/19 dadams +;; icicle-display-candidates-in-Completions: Treat icicle-candidate-properties-alist. +;; 2007/01/15 dadams +;; Added: icicle-reversible-sort. Use it where standard sort function was used. +;; Renamed: icicle-sort-and-strip-ignored to icicle-strip-ignored-files-and-sort, +;; icicle-sort-dirs-last to icicle-dirs-last-p, +;; icicle-sort-case-insensitively to icicle-case-insensitive-string-lessp. +;; Grouped sort functions together. +;; 2007/01/14 dadams +;; icicle-next-candidate: Use icicle-transform-multi-completion. Thx to Rubikitch. +;; icicle-transform-candidates: Updated doc string. +;; 2007/01/12 dadams +;; icicle-next-candidate: Use icicle-list-use-nth-parts. Thx to Rubikitch. +;; icicle-display-candidates-in-Completions: Added message when no-display-p. +;; 2007/01/07 dadams +;; icicle-completing-read: Updated doc string for Emacs 22. +;; 2007/01/06 dadams +;; Added: icicle-abbreviate-or-expand-file-name. +;; icicle-fix-default-directory: Use icicle-abbreviate-or-expand-file-name. +;; icicle-save-or-restore-input: expand-file-name -> icicle-abbreviate-or-expand-file-name. +;; icicle-completion-setup-function: Don't set default-directory to nil if minibuf empty. +;; icicle-read-file-name: Bug fix: Don't set initial-input to icicle-initial-value if "". +;; 2007/01/05 dadams +;; icicle-completing-read, icicle-read-file-name: +;; Use existing string value of icicle-initial-value. Thx to rubikitch for suggestion. +;; 2007/01/01 dadams +;; Added assq-delete-all for Emacs 20 (moved here from icicles-mode.el). +;; Added: icicle-assoc-delete-all. +;; 2006/12/25 dadams +;; Added: icicle-most-recent-first-p. +;; icicle-update-completions: Added optional no-display arg. +;; Moved here from icicles-opt.el: icicle-historical-alphabetic-p. +;; 2006/11/10 dadams +;; icicle-completing-read, icicle-read-file-name: Prefix prompt by + if a multi-command. +;; 2006/10/15 dadams +;; icicle-save-or-restore-input: +;; Change test from cmd is same as last to input is same as last. +;; icicle-rebind-completion-maps: +;; When turn off, bind C-M-mouse-2 and C-down-mouse-2 to nil. +;; icicle-display-candidates-in-Completions: Accumulate (merge) highlight faces. +;; Moved to icicles-mode.el: +;; icicle-bind-isearch-keys, icicle-rebind-completion-maps, +;; icicle-(redefine|restore)-standard-(commands|options), +;; icicle-(redefine|restore)-std-completion-fns), icicle-(re|un)map, +;; icicle-(bind|restore)-completion-keys, icicle-minibuffer-setup, +;; icicle-cancel-*Help*-redirection, icicle-activate-mark, +;; icicle-run-icicle-(pre|post)-command-hook, icicle-set-calling-cmd, +;; icicle-undo-std-completion-faces, icicle-update-ignored-extensions-regexp, +;; icicle-completing-p, icicle-restore-region-face. +;; Removed eval-when-compile of *-face, *-var, *-mac, *-cmd. +;; Removed some defvars for quieting byte compiler. +;; 2006/10/05 dadams +;; icicle-display-candidates-in-Completions: Highlight candidates that are special. +;; 2006/10/03 dadams +;; icicle-display-candidates-in-Completions: +;; Removed predicate filtering, as the pred doesn't necessarily apply to the candidate. +;; This has been in the code forever, so commented it out, in case it is needed ;-). +;; 2006/10/01 dadams +;; icicle-alternative-sort -> icicle-toggle-alternative-sorting. +;; icicle-update-completions: Treat icicle-prefix-word-complete case too. +;; 2006/09/30 dadams +;; Added: icicle-key-description. +;; icicle-(bind|restore)-completion-keys: +;; Bind icicle-candidate-set-(save|retrieve) to C-M-(<|>), not C-(<|>). +;; Bind icicle-toggle-angle-brackets to C-<. +;; No longer remap help-command to icicle-completion-help. +;; Bind icicle-completion-help to C-?. +;; Rename [menu-bar minibuf C-h] to [menu-bar minibuf completion-help]. +;; icicle-completing-p: Bug fix: Use where-is-internal, not minibuffer-completion-table. +;; 2006/09/22 dadams +;; icicle-minibuffer-setup: +;; Apropos-complete, don't prefix-complete, when icicle-show-Completions-initially-flag. +;; 2006/09/17 dadams +;; icicle-completing-p: Ensure minibuffer is active too. +;; 2006/09/16 dadams +;; Bound icicle-insert-key-description to M-q. +;; icicle-completing-read: +;; Use icicle-list-join-string only to join parts of candidate (alist key). +;; Append icicle-list-end-string instead. +;; icicle-msg-maybe-in-minibuffer: Fixed doc string (active -> inactive). +;; 2006/09/12 dadams +;; icicle-minibuffer-setup: Set icicle-pre-minibuffer-buffer. +;; Renamed icicle-switch-to-minibuffer to icicle-insert-completion. +;; 2006/09/03 dadams +;; Renamed icicle-show-Completions-help to icicle-show-Completions-help-flag. +;; 2006/08/27 dadams +;; Bind Quit in Minibuf menu to icicle-abort-minibuffer-input. +;; 2006/08/22 dadams +;; icicle-save-or-restore-input: If icicle-last-completion-candidate is nil, don't try to restore. +;; 2006/08/18 dadams +;; icicle-minibuffer-setup: Reset icicle-last-completion-candidate to nil. +;; icicle-rebind-completion-maps: +;; Added icicle-Info-goto-node to icicle-completion-help-string. +;; 2006/08/15 dadams +;; icicle-(bind|restore)-completion-keys: +;; Bind icicle-help-on-(previous|next)-(apropos|prefix)-candidate. +;; Reorder bindings. Bind C-mouse-2 to 'ignore, not nil. +;; icicle-rebind-completion-maps: Bind icicle-help-on-* in completion-list-mode-map. +;; Added: icicle-barf-if-outside-Completions-and-minibuffer. +;; 2006/08/13 dadams +;; icicle-completing-read, icicle-read-file-name: Use icicle-completing*-prompt-prefix. +;; 2006/08/04 dadams +;; icicle-call-then-update-Completions: +;; Call icicle-last-completion-command, not just prefix or apropos (so prefix-word too). +;; icicle-completing-read, icicle-read-file-name, icicle-next-candidate, +;; icicle-recompute-candidates, icicle-call-then-update-Completions: +;; Use icicle-remove-Completions-window. +;; icicle-(bind|restore)-completion-keys: Bound icicle-pp-eval-expression to M-:. +;; 2006/08/03 dadams +;; icicle-completion-setup-function: Removed useless highlighting code at end (Emacs 20). +;; icicle-rebind-completion-maps: Updated icicle-completion-help-string. +;; 2006/07/30 dadams +;; icicle-call-then-update-Completions: save match-data. +;; 2006/07/29 dadams +;; icicle-activate-mark: Do it only if icicle-completing-p. Thx to Le Wang. +;; icicle-rebind-completion-maps: +;; Updated to use icicle-dispatch-C-.. +;; Added icicle-toggle-search-cleanup to icicle-completion-help-string. +;; icicle-bind-completion-keys: +;; Use icicle-dispatch-C-. instead of icicle-toggle-ignored-extensions. +;; 2006/07/28 dadams +;; icicle-longest-common-match: Treat special case of input such as "$" or "\\>$". +;; 2006/07/24 dadams +;; icicle-call-then-update-Completions: Deactivate mark at the end. Thx to Le Wang. +;; 2006/07/23 dadams +;; Added: icicle-transform-candidates. +;; icicle-rebind-completion-maps, icicle-(bind|restore)-completion-keys: +;; Added icicle-toggle-transforming. +;; icicle-unsorted(-file-name)-*-candidates: Use icicle-transform-candidates. +;; 2006/07/20 dadams +;; Renamed icicle-arrows-respect-* to icicle-cycling-respects-completion-mode-flag. +;; 2006/07/19 dadams +;; Applied patch from Damien Elmes : +;; Added icicle-insert-help-string, icicle-start-of-completions (factored from existing). +;; icicle-completion-setup-function: Use icicle-insert-help-string. +;; icicle-display-candidates-in-Completions: +;; Use icicle-start-of-completions, and adjust loop accordingly. +;; icicle-minibuffer-setup: +;; Reset icicle-current-completion-type. +;; Bind (up|down) to icicle-*-context-candidate, not (previous|next)-history-element. +;; icicle-next-candidate: Use icicle-start-of-completions. +;; icicle-scroll-or-update-Completions: Use icicle-scroll-completions. +;; Renamed: icicle-start-of-completions to icicle-start-of-candidates-in-Completions, +;; icicle-insert-help-string to icicle-insert-Completions-help-string, +;; icicle-current-completion-type to icicle-current-completion-mode, +;; icicle-*-context-candidate to icicle-(next|previous)-candidate-per-mode, +;; icicle-scroll-completions to icicle-scroll-Completions. +;; icicle-minibuffer-setup: +;; Replaced icicle-display-Completions with icicle-prefix-complete, to get initial +;; highlight. +;; 2006/07/18 dadams +;; icicle-call-then-update-Completions: +;; Delete *Completions* window, depending on icicle-Completions-display-min-input-chars. +;; Thx to Damien Elmes. +;; icicle-rebind-completion-maps: Add icicle-toggle-case-sensitivity to help list. +;; icicle-bind-completion-keys: Bind icicle-toggle-case-sensitivity to S-C-a (i.e. C-A). +;; 2006/07/17 dadams +;; icicle-call-then-update-Completions: sit-for delay if no candidates. Thx Damien Elmes. +;; 2006/07/09 dadams +;; icicle-save-or-restore-input: +;; Put back test: current input differs from last cycling candidate (user has edited it). +;; icicle-next-candidate: Removed filtering with predicate (vestigial cruft). +;; 2006/07/08 dadams +;; icicle-save-or-restore-input: Restore if currently cycling, not if not completing. +;; 2006/07/07 dadams +;; icicle-display-candidates-in-Completions: Fixed test for historical candidate. +;; Bound icicle-alternative-sort to M-,. Updated icicle-completion-help-string. +;; 2006/07/05 dadams +;; icicle-save-or-restore-input: +;; For restoring: 1) No longer test if current input = *-last-completion-candidate. +;; 2) No longer test if current input = icicle-initial-value. +;; No longer save icicle-current-input as icicle-last-completion-candidate. +;; Simplified the code. +;; icicle-call-then-update-Completions: Do not set this-command or last-command. +;; Renamed: icicle-current-regexp-input to icicle-current-raw-input. +;; 2006/07/04 dadams +;; icicle-unsorted(-file-name)-prefix-candidates: Update icicle-common-match-string. +;; icicle-unsorted-file-name-prefix-candidates: +;; If prefix matches an empty directory, then use that directory as the sole completion. +;; icicle-next-candidate: Use icicle-*-cycling-command properties. +;; Removed regexp-p arg in calls to icicle-save-or-restore-input. +;; icicle-save-or-restore-input: +;; Update icicle-common-*-string and icicle-current-regexp-input even if not regexp-p. +;; Removed optional regexp-p argument. +;; Do not update icicle-last-completion-candidate. +;; Use icicle-*-*ing-command properties. +;; icicle-recompute-candidates: Use icicle-*-cycling-command properties. +;; 2006/07/03 dadams +;; Bug fixes - +;; icicle-next-candidate: +;; Don't reset icicle-common-match-string if this is an apropos cycling command +;; and last command was an apropos command (cycling or completing). +;; Do icicle-save-or-restore-input a second time, after recompute candidates, +;; to pick up the common match. +;; Always pass icicle-current-input to icicle-place-cursor. +;; icicle-save-or-restore-input: +;; Don't do anything if last command was a cycling command. +;; Don't save input as regexp for C-l if this command is a cycling command, +;; unless it is the first or it follows a completion command. +;; 2006/07/02 dadams +;; icicle-place-cursor: position point & mark at least past prompt. Thx to Peter Povinec. +;; 2006/06/09 dadams +;; icicle(-file-name)-(apropos|prefix)-candidates: Reset icicle-candidate-nb to nil. +;; icicle-recompute-candidates: Don't reset icicle-candidate-nb to nil. +;; icicle-place-cursor: Prevent error on search-forward. +;; 2006/06/08 dadams +;; icicle-save-or-restore-input: Do not restore if current command is completion. +;; Added: icicle-expand-file-name. +;; icicle-next-candidate: Don't pass NTH arg to icicle-display-candidates-in-Completions. +;; 2006/06/06 dadams +;; icicle-control-reminder-prompt: condition-case, since it's on kill-emacs-hook. +;; 2006/06/01 dadams +;; icicle-read-from-minibuffer: Emacs 22 removed the keep-all arg it had added. +;; 2006/05/31 dadams +;; icicle-barf-if-outside*: Simplified. +;; 2006/05/30 dadams +;; Bind icicle-erase-minibuffer-or-history to M-k also in non-completion minibuffer maps. +;; 2006/05/26 dadams +;; Bind icicle-erase-minibuffer-or-history to M-k. +;; Do not remap (or unmap) kill-sentence (it is on M-k in global map). +;; 2006/05/19 dadams +;; Added: icicle-control-reminder-prompt. +;; icicle-reminder-*-flag, icicle-read-file-name: Treat new values of icicle-reminder*. +;; Renamed icicle-inhibit-reminder* to icicle-reminder*. +;; 2006/05/16 dadams +;; icicle-recompute-candidates: Add new saved-last-input arg (replaces icicle-last-input). +;; icicle-next-candidate: Pass saved old last input to icicle-recompute-candidates. +;; 2006/05/15 dadams +;; Reverted change to icicle-unsorted(-file-name)-apropos-candidates, +;; icicle-display-Completions: Use icicle-completion-nospace-flag, not nil. +;; Renamed: icicle-completion-nospace-flag to icicle-ignore-space-prefix-flag. +;; icicle-toggle-incremental-completion: C-#, icicle-toggle-ignored-space-prefix: C-^. +;; 2006/05/13 dadams +;; icicle-unsorted(-file-name)-apropos-candidates, icicle-display-Completions: +;; Use nil, not icicle-completion-nospace-flag. +;; 2006/05/12 dadams +;; icicle-completion-help-string: Added faces and commands. Cleanup. +;; Moved from icicles-cmd.el: icicle-barf-if-outside-*. +;; 2006/05/09 dadams +;; icicle-display-*: Only issue Displaying... message when more candidates than threshold. +;; 2006/05/01 dadams +;; icicle-save-or-restore-input: No-restore test is non-nil, not non-"", icicle-last-input. +;; icicle-minibuffer-setup: Reset icicle-last-input to nil, not "". +;; icicle-next-candidate: Highlight initial whitespace before underline root. +;; 2006/04/28 dadams +;; icicle-save-or-restore-input: +;; Restore empty input if it is not a file name. +;; Don't expand empty common-match-string file-name input (it would lose trailing /). +;; Added: icicle-highlight-initial-whitespace. +;; icicle-next-candidate, icicle-call-then-update-Completions: +;; Use icicle-highlight-initial-whitespace. +;; 2006/04/14 dadams +;; icicle-call-then-update-Completions: Call icicle-update-input-hook. +;; Bound icicle-insert-string-from-variable to C-=. Update icicle-completion-help-string. +;; 2006/04/09 dadams +;; icicle-bind-completion-keys, icicle-minibuffer-setup: +;; Deal with icicle-arrows-respect-completion-type-flag. +;; icicle-display-candidates-in-Completions: +;; Bug fix: regexp-quote common match when highlighting it. +;; icicle-clear-minibuffer: Remove interactive spec. +;; Moved to icicles-cmd.el: icicle-customize-apropos*, icicle-repeat-complex-command. +;; 2006/04/02 dadams +;; Bound icicle-toggle-regexp-quote. +;; 2006/03/31 dadams +;; icicle-next-candidate: +;; Apply icicle-place-cursor to icicle-current-regexp-input if regexp-p. +;; icicle-save-or-restore-input: +;; Don't set icicle-current-regexp-input if this is a next-candidate action. +;; 2006/03/27 dadams +;; icicle-place-overlay: Made generic: added args overlay, face, buffer, properties. +;; 2006/03/25 dadams +;; icicle-call-then-update-Completions: Corrected use of icicle-incremental-completion*. +;; 2006/03/24 dadams +;; Renamed icicle-expand-input-to-common-match to icicle-longest-common-match. Rewrote it. +;; icicle-call-then-update-Completions: +;; Use icicle-incremental-completion-delay and -threshold. +;; Mapped icicle-delete-char. +;; 2006/03/23 dadams +;; icicle-expand-input-to-common-match: +;; Return the longest common match. Don't set icicle-common-match-string here. +;; icicle-unsorted-*apropos-candidates: Set icicle-common-match-string here explicitly. +;; Added: icicle-maybe-sort-and-strip-candidates. Use in icicle-candidate-set-1. +;; 2006/03/22 dadams +;; icicle-display-candidates-in-Completions: +;; Removed root arg (always use icicle-current-input). +;; Always highlight normal match part. +;; Highlight common-match part if icicle-expand-input-to-common-match-flag. +;; icicle-save-or-restore-input: +;; Update regexp even if not icicle-expand-input-to-common-match-flag. +;; icicle-recompute-candidates: If no candidates, then delete *Completions* window. +;; icicle-next-candidate: Set default-directory only if icicle-file-name-input-p. +;; Applied renamings of icicle-match-* faces. +;; 2006/03/21 dadams +;; icicle-expand-input-to-common-match: +;; Bug fixes: +;; If no overlap between first and second candidates, then no common match. +;; If no match with another candidate, then no common match. +;; Input must match computed common match. +;; When checking others, check only the added (pre|suf)fix, and reduce those as needed. +;; icicle-save-or-restore-input: +;; Bug fixes: +;; When icicle-expand-input-to-common-match-flag, expand using directory from the +;; input, not the default-directory. Thx to cacher3.ericsson.net for report. +;; Do test for case-only difference only when case-fold-search. +;; If input is a directory (with slash), then use it as is. +;; Save icicle-current-regexp-input if no icicle-common-match-string too. +;; icicle-display-candidates-in-Completions: Use icicle-common-match-highlight-Completions. +;; 2006/03/20 dadams +;; icicle-save-or-restore-input: Set icicle-current-regexp-input too. +;; Corrected letter-case test. +;; 2006/03/19 dadams +;; Added: icicle-expand-input-to-common-match. +;; icicle-unsorted*-apropos-candidates: +;; Set icicle-common-match-string if icicle-expand-input-to-common-match-flag. +;; icicle-save-or-restore-input: +;; Added regexp-p arg. Update input to icicle-common-match-string if appropriate. +;; icicle-next-candidate: Reset icicle-common-match-string. +;; 2006/03/17 dadams +;; icicle-file-(read|writ)able-p: Put non-empty string condition first. +;; Added: icicle-delete-whitespace-from-string. +;; icicle-files-within: Moved here from icicle-cmd.el. +;; 2006/03/14 dadams +;; Removed: icicle-reset-icicle-completing-p. +;; icicle-completing-read, icicle-read-file-name: Removed icicle-icicle-completing-p. +;; icicle-display-*: Added Displaying... message. +;; 2006/03/13 dadams +;; Added: icicle-file-(read|writ)able-p. Bound them to C-{ and C-} in minibuffer. +;; icicle-rebind-completion-maps, icicle-bind-completion-keys: Added the new commands. +;; icicle-recompute-candidates: Forgot icicle-keep-only-past-inputs in other branch. +;; 2006/03/10 dadams +;; icicle-save-or-restore-input: Bug fix (thx Toby Cubitt) - Not relative to default dir. +;; Use directory-file-name, so don't include /. +;; Use file-name-nondirectory, not file-relative-name if not cycling into subdirs. +;; Renamed icicle-minibuffer-contents to icicle-minibuffer-contents-from-minibuffer. +;; Added new icicle-minibuffer-contents, which can be called outside minibuffer. +;; 2006/03/08 dadams +;; icicle-place-overlay: Use new face, icicle-current-candidate-highlight. +;; 2006/03/05 dadams +;; Bound icicle-toggle-incremental-completion to C-^ in minibuffer. +;; Updated icicle-completion-help-string with C-^ binding. +;; icicle-display-candidates-in-Completions: +;; Allow for on-the-fly changes to icicle-incremental-completion-flag. +;; 2006/03/01 dadams +;; Added: icicle-clear-minibuffer. Use in icicle-next-candidate. +;; 2006/02/27 dadams +;; icicle-call-then-update-Completions: Set last-command to fn arg. + +;;;(@* "CHANGE LOG FOR `icicles-mac.el'") +;; +;; 2010/06/05 dadams +;; icicle-file-bindings: Put back non-insertion for non-ido-like case. +;; 2010/06/04 dadams +;; icicle-(buffer|file)-bindings: Bind vars that depend on icicle-(buffers|files)-ido-like-flag. +;; 2010/03/03 dadams +;; Applied renamings: icicle-sort-function to icicle-sort-comparer, +;; icicle-sort-functions-alist to icicle-sort-orders-alist. +;; 2009/12/21 dadams +;; fset -> defalias. +;; 2009/12/13 dadams +;; icicle-define-sort-command: Add REVERSED to msg if reversed. +;; 2009/10/22 dadams +;; icicle-define-file-command: Use icicle-file-name-directory, not file-name-directory. +;; 2009/09/17 dadams +;; Added: icicle-file-bindings. +;; 2009/09/16 dadams +;; Added: icicle-buffer-bindings. +;; icicle-define(-file)-command: Macroexpand bindings, (e.g. to use icicle-buffer-bindings). +;; 2009/04/28 dadams +;; Moved icicle-choose-action-for-type to icicles-fn.el and changed to a function. +;; 2009/04/26 dadams +;; Added: icicle-choose-action-for-type, icicle-with-selected-window. +;; 2008/08/31 dadams +;; icicle-define(-file)-command: Select window before call select-frame-set-input-focus. +;; 2008/08/18 dadams +;; icicle-try-switch-buffer: Do nothing if icicle-inhibit-try-switch-buffer is non-nil. +;; Use renaming from icicles-fn.el: icicle-complete-again-update. +;; 2008/03/29 dadams +;; icicle-define(-file)-command: Do not call icicle-highlight-lighter. +;; 2008/03/09 dadams +;; icicle-define(-file)-command: Call icicle-highlight-lighter. +;; 2007/11/25 dadams +;; icicle-define(-file)-command: +;; Bound minibuffer variables, so they are restored after action function +;; (in case it uses minibuffer for completion). +;; Return nil after, not before select-frame-set-input-focus. +;; Added optional arg not-interactive-p. +;; Quiet the byte compiler for Emacs versions before 22. +;; 2007/10/14 dadams +;; icicle-define(-file)-command: +;; Updated generated doc to reflect icicle-act-before-cycle-flag. +;; 2007/05/01 dadams +;; icicle-define(-file)-command: Reset icicle-candidate-action-fn after reading input. +;; 2007/04/15 dadams +;; icicle-define(-file)-command: +;; Simplified action fn: Removed unwind-protect and outer condition-case, +;; so don't return error msg now, and only set minibuf focus if succeed. +;; icicle-define(-file)-command, icicle-try-switch-buffer: Removed "%s" from handlers. +;; 2007/02/06 dadams +;; icicle-define(-file)-command: Mention mouse bindings in command doc strings. +;; 2007/01/15 dadams +;; Added: icicle-define-sort-command. +;; Updated font-lock-add-keywords. Added lisp-indentation-hack (commented out). +;; 2007/01/06 dadams +;; font-lock-add-keywords: 2 or 3, not 1 or 2, is index after add icicle-define-add-to-*. +;; Use lax matching, so no error if no match. +;; 2007/01/01 dadams +;; Added: icicle-define-add-to-alist-command. +;; Removed compile-time require of icicles-var.el. +;; font-lock-add-keywords: +;; "\\>[ \t'\(]*\\(\\sw+\\)?", not "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)". +;; Added icicle-define-add-to-alist-command. +;; 2006/10/14 dadams +;; Require icicles-var.el. +;; Moved conditional eval-when-compile to top level. +;; 2006/09/24 dadams +;; icicle-define(-file)-command: Corrected bindings mentioned in doc strings. +;; 2006/08/27 dadams +;; icicle-define(-file)-command: Ensure orig-window is live before using it. +;; 2006/08/23 dadams +;; Added: icicle-try-switch-buffer. Use it in icicle-define(-file)-command. +;; 2006/08/03 dadams +;; icicle-define(-file)-command: +;; (error (error-message-string...)) -> (error "%s" (error-message-string...)). +;; 2006/05/16 dadams +;; icicle-define(-file)-command: Treat cases where user wiped out orig-buff or orig-window. +;; 2006/03/31 dadams +;; icicle-define(-file)-command: Wrap action fn in unwind-protect to select minibuf frame. +;; 2006/03/11 dadams +;; icicle-define-file-command: Expand file in directory of icicle-last-input. +;; 2006/03/08 dadams +;; icicle-define(-file)-command: Bug fix (thx to TobyCubitt): +;; Make sure icicle-candidate-action-fn runs FUNCTION in original buffer and window. +;; 2006/03/07 dadams +;; icicle-define(-file)-command: Mention in doc string that BINDINGS are not in effect +;; within icicle-candidate-action-fn. + +;;;(@* "CHANGE LOG FOR `icicles-mcmd.el'") +;; +;; 2010/06/18 dadams +;; icicle-nb-of-candidate-in-Completions(-horiz), icicle-move-to-next-completion: +;; Replace icicle-completions-format by icicle-completions-format-internal. +;; icicle-scroll-Completions: Do nothing if *Completions* is not displayed. +;; 2010/06/16 dadams +;; Added: icicle-col-wise-cand-nb. +;; Renamed icicle-nb-of-candidate-in-Completions to icicle-nb-of-cand-in-Completions-horiz. +;; Rewrote icicle-nb-of-candidate-in-Completions to handle vertical format also. +;; icicle-candidate-set-save-selected-1: +;; After setting BEG to next face chg, if BEG > END then raise error. +;; After setting END to previous fact chg, BEG > END then swap. +;; After extending, if BEG > END then swap. +;; 2010/06/14 dadams +;; icicle-narrow-candidates: Handle Emacs 23.2+: Use completing-read with read-file-name-internal. +;; icicle-search-define-replacement: +;; Wrap *-remove-Completions-window in save-selected-window. Thx to M. Heerdegen. +;; icicle-help-on-candidate-symbol: Show combined help for fns, vars, and faces (Emacs 22+). +;; 2010/06/11 dadams +;; Added: icicle-make-directory. +;; icicle-read+insert-file-name: Bind icicle-make-directory to C-c +. +;; 2010/06/08 dadams +;; icicle-doremi-increment-max-candidates+: Plain C-u resets icicle-max-candidates to nil. +;; 2010/06/07 dadams +;; icicle-exit-minibuffer: Do not fiddle with faces if not in minibuffer. Thx to M. Heerdegen. +;; icicle-prefix-complete-1: +;; Sole completion case: Move removal of *Completions* before the top-level throw. +;; 2010/06/04 dadams +;; Added: icicle-doremi-increment-max-candidates+. +;; Renamed by adding +: icicle-doremi-increment-swank-(timeout|prefix-length). +;; icicle-help-string-completion: Mention missing doremi toggle keys. +;; icicle-doremi-zoom-Completions+: Show *Completions* if not shown. +;; 2010/05/15 dadams +;; icicle-all-candidates-action-1: Bind *-minibuffer-message-ok-p, *-help-in-mode-line-flag to nil. +;; 2010/05/09 dadams +;; Added: icicle-dispatch-M-_. +;; Removed: icicle-dispatch-C-comma. +;; icicle-help-string-completion: +;; Removed extra arg to format (icicle-key-descriptions-use-<>-flag). Corrected arg order. +;; Updated to reflect binding changes. +;; icicle-toggle-highlight-all-current: Focus to minibuffer before show msg. +;; 2010/05/04 dadams +;; icicle-change-sort-order: Use save-selected-window. Thx to Michael Heerdegen. +;; icicle-apply-to-saved-candidate: +;; Only call sit-for if current-message. Added TYPE arg. Thx to Michael H. +;; 2010/05/03 dadams +;; icicle-toggle-remote-file-testing: Updated for Emacs 23.2+ Thx to Michael Albinus. +;; 2010/04/30 dadams +;; icicle-(apropos|prefix)-complete-1: Run icicle-no-match-hook when no candidates. +;; 2010/04/28 dadams +;; icicle-remove-cand-from-lists: Fix pred a la icicle-mctize-all. Thx to M. Heerdegen. +;; 2010/04/27 dadams +;; icicle-apply-to-saved-candidate: Added sit-for for non-C-u case, to see any msg displayed. +;; icicle-help-on-candidate: Test value, not just boundp, of icicle-completing-keys-p. +;; 2010/04/26 dadams +;; icicle-toggle-highlight-all-current: +;; Save/restore cand nb. Re-complete, rehighlight. Go to current cand only if it is defined. +;; 2010/04/21 dadams +;; Added: icicle-sit-for (Emacs 23+), so user input interrupts sit-for after C-u in minibuffer. +;; 2010/04/20 dadams +;; Added: icicle-sort-by-directories-first. +;; icicle-nb-of-candidate-in-Completions: +;; Bind icicle-completions-format to nil (for calls to *-move-to-next-*). Thx to M. Heerdegen. +;; 2010/04/13 dadams +;; icicle-(apropos|prefix)-complete-1: Fixed recent file-name completion bugs. +;; When icicle-whole-candidate-as-text-prop-p is t and icicle-expand-input-to-common-match-flag +;; is nil, expand the input, unless it is a directory. +;; Expand file-name input to the common match for the current candidate. +;; 2010/04/11 dadams +;; icicle-(apropos|prefix)-complete-1: Fix last fix: +;; Put whole-cand prop on sole candidate only if not a dir, and use icicle-expanded-common-match. +;; 2010/04/09 dadams +;; icicle-(apropos|prefix)-complete-1: When sole candidate, set icicle-current-input to it. +;; Needed, in order to get icicle-whole-candidate property when +;; icicle-expand-input-to-common-match-flag is nil. Thx to Michael Heerdegen. +;; 2010/03/13 dadams +;; Added: icicle-toggle-show-multi-completion. +;; 2010/03/03 dadams +;; Applied renamings: icicle-sort-function to icicle-sort-comparer +;; icicle-sort-functions-alist to icicle-sort-orders-alist, +;; icicle-alternative-sort-function to icicle-alternative-sort-comparer, +;; icicle-last-sort-function to icicle-last-sort-comparer. +;; 2010/03/02 dadams +;; icicle-remove-Completions-window: Do nothing unless *Completions* is shown. +;; icicle-delete-windows-on: Do nothing unless buffer is visible. +;; Do not delete frame if it is the only one. +;; 2010/01/12 dadams +;; icicle-mouse-choose-completion, icicle-insert-string-at-point, +;; icicle-mouse-candidate-action-1, icicle-mouse-remove-candidate, +;; icicle-mouse-candidate-read-fn-invoke, icicle-Completions-mouse-3-menu, +;; icicle-mouse-save/unsave-candidate: +;; set-buffer -> with-current-buffer. +;; icicle-mouse-candidate-read-fn-invoke, icicle-Completions-mouse-3-menu, +;; icicle-mouse-save/unsave-candidate: +;; Removed unused local var BUFFER. +;; icicle-mouse-choose-completion: Removed unused local var ORIG-BUFFER. +;; 2009/12/21 dadams +;; icicle-narrow-candidates: +;; Add fn to minibuffer-setup-hook to make the reference buffer be the new minibuffer. +;; fset -> defalias. +;; 2009/12/13 dadams +;; icicle-change-sort-order: Add REVERSED to msg when reversed. +;; 2009/11/27 dadams +;; Added: icicle-doremi-increment-swank-(prefix-length|timeout). +;; *-next-TAB-completion-method, *-prefix-complete-1: Handle swank completions too. +;; *-next-TAB-completion-method: Bind icicle-doremi-increment-swank-(prefix-length|timeout). +;; 2009/11/26 dadams +;; icicle-next-TAB-completion-method: Do not set icicle-inhibit-sort-p to t for fuzzy. +;; 2009/11/25 dadams +;; Added: icicle-completions-format, icicle-row-wise-cand-nb. +;; icicle-move-to-next-completion: Handle completions laid out vertically. +;; 2009/11/07 dadams +;; Renamed Icicles doremi cmds (added +). Applied other doremi cmd renamings (added +). +;; 2009/10/25 dadams +;; icicle-prefix-complete-1: When sole cand, use the candidate, but without any dir. +;; Renamed: icicle-next-apropos-match-function to icicle-next-S-TAB-completion-method, +;; icicle-toggle-fuzzy-completion to icicle-next-TAB-completion-method (rewrote). +;; icicle-(prefix|apropos)-complete-1: Updated no/sole msgs per new completion methods. +;; icicle-Completions-mouse-3-menu: Updated with the new command names. +;; Updated icicle-help-string-completion. +;; 2009/10/24 dadams +;; icicle-(apropos|prefix)-complete-1: +;; Removed code treating empty dir via *-any-*-p and (""). +;; When only one candidate, set *-last-completion-candidate to: +;; If file-name completion: +;; If empty input, the input; if dir candidate, input + /; else the sole candidate. +;; Else the sole candidate. +;; 2009/10/22 dadams +;; icicle-insert-input, icicle-candidate-action-1, icicle-keep-only-past-inputs, +;; icicle-apropos-complete-and-(narrow|widen): +;; Use icicle-file-name-directory, not file-name-directory. +;; 2009/10/21 dadams +;; icicle-prefix-complete-1: +;; For empty dir we use "" as pseudo-cand. Ensure not "" when later test for / last char. +;; 2009/10/12 dadams +;; Added: icicle-input-is-a-completion-p. +;; icicle-minibuffer-complete-and-exit, icicle-input-is-a-completion-p: +;; Use icicle-input-is-a-completion-p. +;; icicle-prefix-complete-1: +;; For file-name input: Set, and use, current input without substituting env vars. +;; When sole candidate ends in /, add a / to current input also. +;; 2009/09/26 dadams +;; icicle-narrow-candidates(-with-predicate): Bind icicle-progressive-completing-p to t. +;; 2009/09/25 dadams +;; icicle-prefix-complete-1, icicle-transform-sole-candidate: +;; Use icicle-current-input, not (car icicle-completion-candidates). +;; Don't set icicle-current-input to (car icicle-completion-candidates) if no-catch. +;; 2009/09/12 dadams +;; icicle-delete-candidate-object: Message if no candidates, in non-ALLP case also. +;; icicle-delete-candidate-object-1: Bind icicle-completion-candidates to save & restore it. +;; icicle-candidate-action-1, icicle-remove-candidate-display-others, +;; icicle-delete-candidate-object, icicle-help-on-candidate, +;; icicle-candidate-read-fn-invoke: +;; Bind icicle-help-in-mode-line-flag to nil, to avoid help-display delay. +;; icicle-update-and-next: Do nothing if user hit another key and there are more candidates. +;; 2009/09/05 dadams +;; icicle-narrow-candidates: Don't raise an error if no candidates. E.g. C-~. +;; Use backward and forward as the values of icicle-cycling-command prop for nav commands. +;; Apply renaming of icicle-acting-on-next/prev (removed -p). +;; icicle-successive-action: Bind it to value of icicle-cycling-command (nav direction). +;; icicle-all-candidates-list-alt-action: Raise error if null icicle-completion-candidates. +;; icicle-search-define-replacement: Prevent immediate incremental completion kicking in. +;; icicle-(widen|narrow)-candidates(-with-predicate): +;; Use literal text for (S-)TAB in error message, to avoid S-iso-*. +;; 2009/09/02 dadams +;; icicle-(prefix|apropos)-complete-1, icicle-narrow-candidates(-with-predicate): +;; Impose icicle-top-level-when-sole-completion-delay when *-flag is non-nil. +;; 2009/08/27 dadams +;; icicle-goto/kill-failed-input: Do nothing if the overlay is nowhere. +;; icicle-mouse-yank-secondary: If yank-secondary is defined, then pass prefix arg also. +;; 2009/08/23 dadams +;; icicle-narrow-candidates-with-predicate: Added optional arg PREDICATE. +;; 2009/08/20 dadams +;; icicle-successive-action: Don't call icicle-show-help-in-mode-line unless string arg. +;; 2009/08/11 dadams +;; icicle-all-candidates-action-1: Added ALTP arg. Use in call to *-candidate-action-1. +;; icicle-all-candidates(-list)-alt-action: Use new ALTP arg in call with *-alt-action-fn. +;; icicle-successive-action: Bind icicle-acting-on-next/prev-p around call to action fn. +;; icicle(-mouse)-candidate-action-1: +;; No longer bind icicle-* to selves. You must do it in the action fn if you need it. +;; icicle-help-string-completion: C-| -> M-| for Replace all. +;; icicle-change-history-variable: Protect with boundp: *-populate-interactive-history-flag. +;; Wrap require of icicles-var.el in eval-and-compile. +;; 2009/08/01 dadams +;; icicle-change-history-variable: +;; Add icicle-interactive-history to choices only if *-populate-interactive-history-flag. +;; 2009/07/29 dadams +;; icicle-other-history: +;; Call icicle-use-interactive-command-history only if Emacs 23+ and non-nil history. +;; 2009/07/27 dadams +;; icicle-help-string-completion: Mention icicle-other-history. +;; 2009/07/26 dadams +;; Added: icicle-change-history-variable, icicle-other-history, +;; icicle-use-interactive-command-history. +;; icicle-history: +;; Use icicle-cycling-p instead of get icicle-cycling-command, to avoid completion cmds. +;; 2009/07/02 dadams +;; icicle-candidate-set-save-1: If icicle-get-alist-candidate-function returns nil, use CAND +;; 2009/06/26 dadams +;; icicle-doremi-zoom-Completions, icicle-doremi-candidate-width-factor: +;; Use new key-list options, doremi-...-keys (not -key). You will need the latest DoReMi. +;; 2009/06/18 dadams +;; doremi-buffer-font-size: Changed increment (doremi-*-key) bindings to =, -, M-=, M-i. +;; icicle-help-string-completion: Added icicle-doremi-zoom-Completions. +;; 2009/06/17 dadams +;; Added: icicle-doremi-zoom-Completions. +;; icicle-doremi-candidate-width-factor: If no candidates, show message; don't use colors. +;; 2009/06/07 dadams +;; icicle-get-alist-candidate -> funcall icicle-get-alist-candidate-function. +;; 2009/05/27 dadams +;; icicle-minibuffer-complete-and-exit: +;; Don't exit if any completion is done, unless icicle-require-match-p is t. +;; 2009/05/22 dadams +;; Require icicles-mac.el if load-library doesn't find it. +;; 2009/05/18 dadams +;; icicle-candidate-set-save-selected-1: If empty inactive region and MOREP, raise error. +;; 2009/05/17 dadams +;; icicle-toggle-C-for-actions: Use icicle-toggle-icicle-mode-twice, not icy-mode calls. +;; 2009/05/15 dadams +;; icicle-(prefix|apropos)-complete-1: Fit minibuffer frame after inserting current input. +;; 2009/05/11 dadams +;; icicle-upcase-if-ignore-case, icicle-next-apropos-match-function: Use icicle-upcase. +;; 2009/05/09 dadams +;; Added: icicle-looking(-back)-at-anychar-regexp-p, icicle-(forward|backward)-char-dots, +;; icicle-backward-delete-char-untabify-dots, icicle-delete-backward-char-dots, +;; icicle-delete-char-dots, icicle-transpose-chars-dots. icicle-insert-dot(-command), +;; icicle-anychar-regexp, icicle-toggle-dot, icicle-convert-dots. +;; icicle-backward-delete-char-untabify, icicle-delete-backward-char, icicle-delete-char, +;; icicle-transpose-chars: Handle dots. +;; icicle-prefix-complete: Convert dots and set icicle-dot-string-internal. +;; icicle-goto/kill-failed-input: Use overlay. +;; icicle-help-string-completion, icicle-Completions-mouse-3-menu: +;; Added dot toggling. Changed binding for icicle-toggle-hiding-common-match. +;; 2009/05/08 dadams +;; icicle-(prefix|apropos)-complete-1: Fixed typo introduced 2009-05-05. +;; 2009/05/07 dadams +;; icicle-retrieve-(previous|last)-input: Call icicle-place-cursor with optional second arg. +;; 2009/05/05 dadams +;; toggle-icicle-case-sensitivity: Treat read-buffer-completion-ignore-case also (Emacs 23). +;; 2009/05/03 dadams +;; icicle-(prefix|apropos)-complete-1: +;; Don't stop cycling if last command was an action (treat as if it was a cycling cmd). +;; icicle-all-candidates(-list)(-alt)-action, icicle(-mouse)-candidate(-alt)-action, +;; icicle-delete-candidate-object, icicle(-mouse)-help-on-candidate: +;; Put property icicle-action-command. +;; 2009/05/02 dadams +;; icicle-candidate-alt-action: Respect icicle-alternative-actions-alist. +;; icicle-minibuffer-help: Corrected wrt alt action-for-all keys. +;; 2009/04/30 dadams +;; icicle-next-(prefix|apropos)-candidate, icicle-(prefix|apropos)-complete-1, +;; icicle-successive-action: +;; Reset icicle-next-(apropos|prefix)-complete-cycles-p to nil, as appropriate. +;; icicle-prefix-complete-1: Show mode-line help only at very end, and even after cycling. +;; 2009/04/29 dadams +;; icicle-apply-to-saved-candidate: +;; Pass no-error-no-msg to icicle-get-alist-candidate function. +;; If icicle-get-alist-candidate finds no function, get function from car of entry. +;; icicle-apropos-complete-and-(narrow|widen): Handle icicle-apropos-complete-no-display. +;; 2009/04/27 dadams +;; icicle-(prefix|apropos)-complete-1: +;; Set icicle-last-completion-command to icicle-*-complete-no-display if arg NO-DISPLAY. +;; icicle-history: If icicle-last-completion-command is nil, call icicle-apropos-complete. +;; 2009/04/26 dadams +;; Wrap load of icicles-mac in eval-when-compile, and use load-library, not require. +;; Require icicles-opt before icicles-var (not important). +;; 2009/04/20 dadams +;; Added: icicle-(previous|next)-candidate-per-mode-alt-action. +;; 2009/03/19 dadams +;; mouse-choose-completion: Don't fset unless standard function is defined. +;; Use when/unless instead of or for fset's. (cosmetic) +;; 2009/04/15 dadams +;; Added: icicle-(next|previous)-candidate-per-mode-help. +;; icicle-successive-action: Set mode only if known. Leave it alone for per-mode functions. +;; icicle-(apropos|prefix)-complete-1: +;; Don't show help in mode-line when icicle-top-level-when-sole-completion-flag = t. +;; 2009/04/12 dadams +;; icicle-successive-action: Inhibit help in mode line until after action is finished. +;; 2009/04/06 dadams +;; icicle-(prefix|apropos)-complete-1, icicle-candidate-set-retrieve-1, +;; icicle-keep-only-past-inputs: +;; Call icicle-show-help-in-mode-line for completed input. +;; icicle-(prefix|apropos)-complete-1: +;; Don't highlight complete input or show help if icicle-*-complete-and-exit-p is bound. +;; 2009/04/04 dadams +;; Renamed: icicle-sort-by-last-use to icicle-sort-by-last-use-as-input. +;; icicle-change-sort-order: Purge any nil entries from icicle-sort-functions-alist. +;; icicle-current-sort-functions: Respect icicle-buffer-name-sort-predicate. +;; icicle-reverse-sort-order: Echo icicle-current-sort-order. +;; 2009/03/16 dadams +;; icicle-candidate-action-1: Respect icicle-use-candidates-only-once-alt-p. +;; 2009/03/10 dadams +;; icicle-remove-Completions-window: Wrap with condition-case, to ignore "Attempt..." error. +;; 2009/03/01 dadams +;; Added: icicle-completing-read+insert, icicle-read+insert-file-name. +;; 2009/02/28 dadams +;; No soft require of subr-21.el now, since provide replace-regexp-in-string for Emacs 20. +;; 2009/02/23 dadams +;; icicle-mouse-choose-completion, icicle-(prefix|apropos)-complete-1, +;; icicle-insert-completion, icicle-mouse-candidate-action-1, icicle-update-and-next, +;; icicle-narrow-candidates(-with-predicate), icicle-keep-only-past-inputs, +;; icicle-insert-input: +;; Protect dir insertion with icicle-extra-candidates-dir-insert-p. +;; icicle-choose-completion: Use icicle-extra-candidates-dir-insert-p to reset base-size=0. +;; 2009/02/20 dadams +;; Added: icicle-sort-extra-candidates-first. +;; icicle-candidate-action-1: Use function icicle-require-match-p, not variable. +;; 2009/02/17 dadams +;; icicle-exit-minibuffer: Don't put nil face property on input. Thx to Daniel Clemente. +;; 2009/02/04 dadams +;; icicle-(prefix|apropos)-complete-1: +;; Do not set icicle-current-input to icicle-last-input unless also icicle-cycling-p. +;; Do not cycle unless also was already cycling or icicle-next-*-complete-cycles-p. +;; Set icicle-next-*-complete-cycles-p, at end, to save whether input was completed some. +;; 2009/02/01 dadams +;; Added: icicle-up-directory, icicle-replace-input-w-parent-dir. +;; 2009/01/24 dadams +;; icicle-narrow-candidates(-with-predicate): +;; Bind icicle-apropos-complete-match-fn to icicle-last-apropos-complete-match-fn. +;; icicle-next-apropos-match-function: Save new value as *-last-apropos-complete-match-fn. +;; 2009/01/18 dadams +;; icicle-(prefix|apropos)-complete-1: +;; Don't set icicle-current-input to icicle-last-input if icicle-edit-update-p. +;; 2009/01/17 dadams +;; icicle-next-apropos-match-function: +;; Add Levenshtein distance in message: (1). +;; Don't do icicle-complete-again-update - too slow. +;; 2009/01/14 dadams +;; icicle-remove-cand-from-lists: Treat icicle-remove-dups-if-extras also. +;; 2009/01/13 dadams +;; icicle-delete-windows-on: Delete frame even if it has a minibuffer, if it's not active. +;; 2008/12/26 dadams +;; Added: icicle-widen-candidates, icicle-apropos-complete-and-widen. +;; Added icicle-widen-candidates to icicle-Completions-mouse-3-menu. +;; 2008/12/25 dadams +;; icicle-retrieve-previous-input: Corrected logic following cycling. +;; Remember whether repeated C-l calls follow cycling: local var was-cycling-p. +;; If so, then use current raw input for second C-l. Otherwise use previous raw input. +;; Use icicle-cycling-p instead of testing if this command is a cycling command. +;; Handle case of "" raw input, which is never in list of saved raw inputs. +;; Restore current raw input after re-completing. +;; icicle-(prefix|apropos)-complete-1: Reset icicle-cycling-p (new var) to nil. +;; icicle-regexp-quote-input: Reset icicle-expand-input-to-common-match-flag to nil. +;; 2008/12/22 dadams +;; Added: icicle-regexp-quote-input. +;; Added it to icicle-help-string-completion, icicle-Completions-mouse-3-menu. +;; 2008/12/21 dadams +;; icicle-minibuffer-complete-and-exit: +;; Rewrote to fit new Emacs 23 behavior. Thx to Daniel Clemente. +;; Test minibuffer-completion-confirm first, before we auto-complete. +;; icicle-last-input -> icicle-current-input (bug fix bc of call to *-no-display). +;; icicle-prefix-complete-1: Bind free var word-complete-input. +;; icicle-(apropos|prefix)-complete-1: No messages if NO-DISPLAY-P is 'no-msg. +;; 2008/12/20 dadams +;; icicle-(apropos|prefix)-complete-1, icicle-narrow-candidates(-with-predicate): +;; Expand file-name choice if thrown to icicle-read-top. +;; 2008/12/10 dadams +;; icicle-(apropos|prefix)-complete-1: Don't pick up icicle-last-input unless also: +;; (1) same completion mode, (2) icicle-completion-candidates is not nil. +;; icicle-prefix-complete-1: If WORD-P, don't pick up icicle-last-input unless same command. +;; Bind minibuffer-message-timeout to 0 during minibuffer-complete-word. +;; icicle-apropos-complete-1: +;; Typo in last cond clause: prefix -> apropos, in i-apropos-completing-command. +;; 2008/12/06 dadams +;; icicle-prefix-complete-1: Fixes for word completion. +;; Don't initialize *-current-input to *-last-input if word-p and icicle-edit-update-p. +;; Recompute candidates after word complete also if editing or didn't repeat last command. +;; Cycle if last command was not a prefix completion and input doesn't end in `-'. +;; 2008/12/05 dadams +;; Let repeated completion commands cycle. Thx to Andrey Zhdanov for the suggestion. +;; icicle-(apropos| prefix)-complete-1: +;; Call icicle-next-candidate, not scroll, when repeated. Special treatment for word. +;; icicle-(apropos|prefix)-complete*: +;; Put icicle(-apropos|-prefix)-cycling-command property on command symbols. +;; 2008/12/02 dadams +;; icicle-minibuffer-complete-and-exit: +;; Updated for Emacs 23's minibuffer-confirm-exit-commands. +;; 2008/11/29 dadams +;; icicle-prefix-word-complete: +;; Redefined to use (new) icicle-prefix-complete-1. +;; Put property icicle-completing-command. +;; icicle-prefix-complete-1: +;; Useful now also for icicle-prefix-word-complete. Added arg word-p. +;; icicle-(prefix|apropos)-complete-1, icicle-switch-to-Completions-buf: +;; Test property icicle-prefix-completing-command, not eq cmds. +;; icicle-(prefix|apropos)(-word)-complete(-no-display): +;; Put property icicle-(prefix|apropos)-completing-command. +;; icicle-next-candidate-per-mode: Use case, not cond. +;; icicle-end-of-line+: Bind inhibit-field-text-motion, call end-of-line to get past prompt. +;; 2008/11/18 dadams +;; icicle-minibuffer-complete-and-exit: Allow exit if input matches a current candidate. +;; icicle-exit-minibuffer: Remove all Icicles minibuffer faces, but only those. +;; 2008/11/14 dadams +;; Added: icicle-toggle-hiding-common-match. +;; icicle-help-string-completion, icicle-Completions-mouse-3-menu: Mention it. +;; 2008/11/10 dadams +;; icicle-minibuffer-complete-and-exit: +;; Use icicle-exit-minibuffer, not old-exit-minibuffer, so remove *Completions*. +;; 2008/11/09 dadams +;; icicle-maybe-multi-completion-completing-p, icicle-transform-sole-candidate: +;; Don't test icicle-list-join-string (always non-nil). +;; 2008/11/03 dadams +;; icicle-(apropos|prefix)-complete-1: Added message Computing completion candidates... +;; 2008/11/02 dadams +;; icicle-upcase-if-ignore-case: condition-case, to prevent error on bad chars (Emacs 20). +;; 2008/10/27 dadams +;; Added: icicle-upcase-if-ignore-case. +;; icicle-minibuffer-complete-and-exit, icicle-(prefix|apropos)-complete-1: +;; Use icicle-upcase-if-ignore-case. +;; 2008/10/24 dadams +;; icicle-minibuffer-complete-and-exit: If icicle-candidates-alist, then just filter it. +;; 2008/10/18 dadams +;; Replaced customize-save-variable by funcall icicle-customize-save-variable-function. +;; 2008/10/14 dadams +;; Added: icicle-help-string(-non)-completion. +;; icicle-help-string-completion: +;; Renamed from icicle-update-help-string in icicles-mode.el. +;; Moved common part to icicles-var.el as icicle-general-help-string. +;; Renamed: icicle-completion-help to icicle-minibuffer-help. +;; icicle-minibuffer-help: If not completing, use icicle-help-string-non-completion. +;; Move Send an Icicles bug report to the bottom. +;; 2008/10/11 dadams +;; icicle-(next|previous)-line: Fixed so it highlights also candidates in first column. +;; icicle-kill-failed-input: Made it two-stage. Renamed to icicle-goto/kill-failed-input. +;; 2008/10/10 dadams +;; Added: icicle-(next|previous)-candidate-per-mode-action. +;; 2008/10/09 dadams +;; Updated icicle-Completions-mouse-3-menu for C-<. +;; 2008/10/08 dadams +;; Added: icicle-candidate-set-retrieve-more, icicle-candidate-set-retrieve-1. +;; icicle-candidate-set-retrieve: Use icicle-candidate-set-retrieve-1. +;; icicle-insert-string-at-point: +;; Use icicle-pre-minibuffer-buffer, not (cadr (buffer-list)). Thx to Andrey Zhdanov. +;; icicle-beginning-of-line+: Don't move into prompt. Thx to Andrey Zhdanov. +;; 2008/10/06 dadams +;; icicle-self-insert: Do self-insert-command if executing-kbd-macro. Thx to Tomer Levin. +;; 2008/10/01 dadams +;; icicle-completion-help: Use icicle-update-help-string, not icicle-completion-help-string. +;; 2008/09/30 dadams +;; Renamed icicle-isearch-complete-1 to icicle-isearch-complete-past-string and moved it +;; to icicles-fn.el. +;; 2008/09/20 dadams +;; icicle-toggle-ignored-extensions: Append $ to each extension. +;; icicle-dispatch-C-.: Use icicle-searching-p as the condition, not *-file-name-input-p. +;; 2008/09/14 dadams +;; icicle-(minibuffer|apropos)-complete-and-exit: Set icicle-last-input to current input. +;; icicle-minibuffer-complete-and-exit: Use apropos completion if that's the current mode. +;; 2008/09/13 dadams +;; icicle-candidate-set-save-1: Save to fileset if zero prefix arg. +;; icicle-candidate-set-retrieve: Retrieve also from a fileset. +;; No default value for completing-read. +;; Added: icicle-add-file-to-fileset. +;; Renamed: +;; icicle-candidate-set-save-to-cache-file to icicle-candidate-set-save-persistently, +;; icicle-candidate-set-retrieve-from-cache-file to *-candidate-set-retrieve-persistent. +;; icicle-candidate-set-save-persistently: Added arg FILESETP. +;; icicle-add/update-saved-completion-set: No default value for completing-read. +;; icicle-retrieve-candidates-from-set: +;; Factored out code as icicle-get-candidates-from-saved-set - use it. Don't return name. +;; Moved to icicles-fn.el: icicle-readable-to-markers. +;; 2008/09/09 dadams +;; icicle-candidate-set-save(-selected-1): Added NO-ERROR-P arg. +;; icicle-candidate-set-save-selected: Call *-save-selected-1 with NO-ERROR-P arg. +;; icicle-candidate-set-save-1: Raise error if set to save is empty and not NO-ERROR-P. +;; 2008/09/08 dadams +;; icicle-apropos-complete-and-narrow: +;; If currently prefix completing, escape current input before apropos completing. +;; 2008/09/07 dadams +;; icicle-minibuffer-complete-and-exit: +;; Use *-prefix-complete-no-display and *-display-candidates-in-Completions when needed. +;; 2008/09/06 dadams +;; icicle-minibuffer-complete-and-exit: Rewrote, based on icicle-apropos-complete-and-exit. +;; icicle-prefix-complete-1: +;; Wrap most of single-candidate case in (boundp 'icicle-prefix-complete-and-exit-p). +;; 2008/09/04 dadams +;; icicle-minibuffer-complete-and-exit: Temporary bug workaround. +;; 2008/08/31 dadams +;; icicle-completion-help, icicle-pp-eval-expression-in-minibuffer, +;; icicle-delete-candidate-object-1, icicle-apply-to-saved-candidate, +;; icicle-toggle-highlight-all-current: +;; Select window before call select-frame-set-input-focus. +;; 2008/08/29 dadams +;; icicle-minibuffer-complete-and-exit: Update icicle-last-input to minibuffer contents. +;; 2008/08/28 dadams +;; icicle-(apropos|prefix)-complete-1, icicle-narrow-candidates(-with-predicate): +;; Update minibuffer-history-variable before throw result. +;; icicle-help-on-candidate: Renamed alacarte-menu-items-alist to lacarte-menu-items-alist. +;; 2008/08/27 dadams +;; icicle-kill-failed-input: Reverted mistaken change to use start of *Completions* (duh). +;; 2008/08/25 dadams +;; icicle-minibuffer-complete-and-exit: Call icicle-prefix-complete-no-display with no-msg +;; arg, instead of binding minibuffer-message-timeout to 0. +;; icicle-(apropos|prefix)-complete-no-display: Added optional NO-MSG-P arg. +;; 2008/08/24 dadams +;; icicle-minibuffer-complete-and-exit: Rewrote to not call original Emacs version. +;; Use today's renamings from icicles-fn.el. +;; icicle-raise-Completions-frame: Don't do anything unless one-window-p and option = t. +;; icicle-choose-completion, *-kill-failed-input, *-current-completion-in-Completions: +;; Check point wrt candidates start position, not bobp. +;; icicle-current-completion-in-Completions: +;; "No completion here" error after, not before, we set beg wrt mouse-face change. +;; icicle-mouse-candidate-action-1: Call icicle-update-and-next if there are still cands. +;; 2008/08/21 dadams +;; icicle-candidate-set-retrieve: If completing files, remove directory from candidates. +;; 2008/08/20 dadams +;; icicle-mouse-candidate-action-1: Remove mouse-face property from choice. +;; 2008/08/19 dadams +;; icicle-mouse-remove-candidate: +;; Set icicle-last-completion-candidate. Needed for *-remove-candidate-display-others. +;; icicle-mouse-candidate-action-1: Removed unused vars: buffer, base-size. +;; Added: icicle-delete-candidate-object-1, with explicit CAND arg and NO-DISPLAY-P option. +;; icicle-delete-candidate-object: Added optional ALLP arg. +;; icicle-delete-current-candidate-object: Added optional CAND arg. +;; icicle-update-and-next: Don't try to move to cand in *Completions* if number not known. +;; 2008/08/18 dadams +;; Added: icicle-remove-cand-from-lists, icicle-update-and-next. +;; icicle-narrow-candidates-with-predicate: Update predicate correctly, with lexical-let. +;; icicle-remove-candidate, icicle-delete(-current)-candidate-object: +;; Removed stuff from doc string about removing all that match. +;; icicle-delete-candidate-object, icicle-remove-candidate-display-others: +;; Use icicle-remove-cand-from-lists (with mctized candidate) and icicle-update-and-next. +;; icicle-delete-current-candidate-object: Changed first condition: +;; (and icicle-candidates-alist (consp (car val))) to +;; (or icicle-whole-candidate-as-text-prop-p icicle-candidates-alist) +;; icicle-remove-candidate-display-others: +;; Added optional ALLP arg. +;; Reinitialize icicle-last-completion-candidate properly (as elsewhere). +;; icicle(-mouse)-candidate-action-1: Use ALLP arg for *-remove-candidate-display-others. +;; icicle-history: Don't set minibuffer-completion-predicate if it is nil. +;; Use renamings from icicles-fn.el: +;; icicle-complete-again-update, icicle-remove-if, icicle-put-whole-cand-prop. +;; icicle-narrow-candidates: Do not bind icicle-whole-candidate-as-text-prop-p to nil. +;; icicle-Completions-mouse-3-menu: Removed icicle-scroll-Completions from menu. +;; 2008/08/17 dadams +;; icicle-narrow-candidates-with-predicate: +;; (read-file-name|minibuffer-completion)-predicate: Removed `, in front. +;; icicle-scroll-Completions: Added optional arg (for mouse wheel reversal). +;; Added: icicle-scroll-Completions-up. +;; 2008/08/03 dadams +;; Added: icicle-all-candidates-list(-alt)-action. +;; icicle-all-candidates(-alt)-action: +;; Act on saved candidates, if any. Use list function, if normal is nil. +;; icicle-all-candidates-action-1: +;; Use icicle-candidate-action-1 (with cand arg (new)), not funcall, to apply fn-var. +;; Act on saved candidates, if any. +;; Do not call icicle-abort-recursive-edit at the end. +;; icicle-candidate-action-1: +;; Added optional CAND arg. +;; Save stuff before funcall, in case FN-VAR does its own completion. +;; icicle-mouse-candidate-action-1: Save stuff before funcall, in case FN-VAR completes. +;; icicle-remove-candidate-display-others: +;; When no candidates left, just call icicle-abort-recursive-edit. +;; icicle-help-on-candidate: Added optional CAND arg. +;; Renamed: icicle-candidate-alternative-action-fn to icicle-candidate-alt-action-fn. +;; 2008/07/27 dadams +;; Added: icicle-sort-by-2nd-parts-alphabetically, icicle-maybe-multi-completion-*. +;; icicle-current-sort-functions: Treat icicle-multi-completion-sort-predicate property. +;; icicle-dispatch-C-comma: Call icicle-change-sort-order interactively (bug fix). +;; icicle-reverse-sort-order: Display candidates, possibly in reverse order (bug fix). +;; Moved from here to icicles-fn.el: icicle-transform-multi-completion. +;; 2008/07/16 dadams +;; icicle-mouse-choose-completion: No error if minibuffer is not active. +;; icicle-completion-help and top-level: Don't require help-mode.el unless Emacs 22+. +;; eval-when-compile require's of fit-frame.el, linkd.el. +;; 2008/06/24 dadams +;; icicle-narrow-candidates: Emacs < 22: Set minibuffer-completing-file-name to nil. +;; 2008/06/21 dadams +;; icicle(-mouse)-choose-completion, icicle-current-completion-in-Completions, +;; icicle-mouse-candidate-action-1: +;; buffer-substring-no-properties -> buffer-substring. +;; *NOTE*: THIS REVERSES A FIX made on 2008/02/03. Dunno why that fix was made. +;; 2008/06/03 dadams +;; Added: icicle-toggle-C-for-actions. +;; icicle-Completions-mouse-3-menu: Added icicle-toggle-C-for-actions. +;; 2008/06/01 dadams +;; Added: icicle-current-sort-functions. Predicate tests various contexts using properties. +;; icicle-change-sort-order: Use icicle-current-sort-functions. +;; Added new sort order, defining function icicle-sort-special-candidates-first. +;; 2008/05/27 dadams +;; icicle-isearch-complete-1: Use ring symbols, not their values. +;; 2008/05/25 dadams +;; icicle-isearch-complete: Rewrote. Handle minibuffer search. +;; Added: icicle-isearch-complete-1, from stuff in icicle-isearch-complete. +;; Treat string case. Allow recursive minibuffers. Don't use icicle-isearch-resume. +;; Removed: icicle-isearch-resume. +;; 2008/05/22 dadams +;; icicle-toggle-case-sensitivity: Added prefix arg and update lighter. +;; 2008/05/03 dadams +;; icicle-history: Bind minibuffer-completing-file-name to nil. +;; 2008/05/02 dadams +;; (put 'icicle(-mouse)-yank-secondary 'delete-selection 'yank) +;; 2008/04/25 dadams +;; Added: icicle-toggle-remote-file-testing. +;; icicle-Completions-mouse-3-menu: +;; Added icicle-toggle-remote-file-testing (C-^). +;; icicle-toggle-ignored-space-prefix is now bound to M-_, not C-^. +;; icicle-dispatch-C-^: +;; icicle-toggle-remote-file-testing, not icicle-toggle-ignored-space-prefix. +;; 2008/04/18 dadams +;; Renamed icicle-init-value-flag to icicle-default-value. +;; 2008/04/13 dadams +;; icicle-pp-eval-expression-in-minibuffer: Treat prefix arg (added optional arg). +;; icicle-apply-to-saved-candidate: Use icicle-pp-eval-expression, not pp-eval-expression. +;; 2008/04/02 dadams +;; icicle-apropos-complete-and-narrow: No longer bind icicle-top-level-when-*-flag to t. +;; 2008/03/31 dadams +;; icicle-apropos-complete-1: Allow for no completion type, for No completion msg. +;; 2008/03/29 dadams +;; icicle-pp-eval-expression-in-minibuffer, icicle-narrow-candidates(-with-predicate): +;; Removed binding of icicle-reminder-prompt-flag. +;; 2008/03/25 dadams +;; icicle-(apropos|prefix)-complete-1: +;; When not regexp-matching, use substitute-in-file-name on input, to convert \ to /. +;; 2008/03/23 dadams +;; icicle-scroll-Completions: Respect and update icicle-scroll-Completions-backward-p. +;; 2008/03/19 dadams +;; Added: icicle-insert-newline-in-minibuffer. +;; Renamed i*-pp-eval-expression to *-in-minibuffer. Calls new icicle-pp-eval-expression. +;; 2008/03/12 dadams +;; icicle-completion-help: Add buttons for Commentary (icicles-doc*.el). +;; 2008/03/11 dadams +;; icicle-add/update-saved-completion-set: Clarify error msg for unwritable file. +;; 2008/03/07 dadams +;; Renamed icicle-abort-minibuffer-input to icicle-abort-recursive-edit. +;; 2008/03/02 dadams +;; icicle-describe-file: +;; Use default dir if arg is nil. Error if no readable file. Removed save-excursion. +;; 2008/02/24 dadams +;; icicle-apropos-complete-1: Use icicle-apropos-match-fns-alist lookup for message. +;; icicle-Completions-mouse-3-menu: Added item for icicle-next-apropos-match-function. +;; Added: icicle-next-apropos-match-function. +;; 2008/02/22 dadams +;; icicle-retrieve-candidates-from-set: +;; Like logic for alist in icicle-completing-read: +;; Do icicle-readable-to-markers, then copy car and replace cdr with whole candidate. +;; Removed RAW arg from call to find-file-noselect. +;; Wrap Lisp read in condition-case. +;; Renamed, added un: icicle(-mouse)-save-candidate to icicle(-mouse)-save/unsave-candidate. +;; icicle-add/update-saved-completion-set: Changed default name to just add .icy. +;; icicle-candidate-set-save-1, icicle-retrieve-candidates-from-set: +;; Wrap write/read to/from cache file in condition-case. +;; 2008/02/16 dadams +;; icicle-retrieve-candidates-from-set: +;; Convert alist cands to propertized strings, using i*-put-alist-* and i*-readable-to-*. +;; Set icicle-candidates-alist to reconstituted retrieved candidates. +;; icicle-candidate-set-save-1: +;; Convert to readable alist from propertized text, using i*-markers-to-*, i*-get-alist-*. +;; Added: icicle-readable-to-markers, icicle-markers-to-readable. +;; 2008/02/15 dadams +;; icicle-delete-windows-on: +;; Enable recursive minibuffers for interactive use. Thx to Simon Marshall. +;; 2008/02/14 dadams +;; icicle-add/update-saved-completion-set: Remove properties from completion-set string. +;; icicle-change-sort-order, icicle-retrieve-previous-input, +;; icicle-insert-string-from-variable, icicle(-mouse)-candidate-read-fn-invoke, +;; icicle-narrow-candidates, icicle-save-predicate-to-variable, +;; icicle-candidate-set-retrieve, icicle-candidate-set-save-1, +;; icicle-add/update-saved-completion-set, icicle-isearch-complete: +;; Bind icicle-whole-candidate-as-text-prop-p to nil. +;; 2008/02/07 dadams +;; icicle-delete-windows-on: +;; Delete frame if one-window-p and not a standalone minibuffer. Thx to Simon Marshall. +;; 2008/02/03 dadams +;; icicle-mouse-choose-completion: +;; Use absolute file name for choice and prepend dir in minibuffer. Set base-size to 0. +;; Don't remove *Completions* window. +;; icicle-mouse-candidate-action-1: Use absolute file name for choice. +;; icicle-mouse-choose-completion, icicle-mouse-candidate-action-1, +;; icicle-current-completion-in-Completions: buffer-substring -> *-no-properties. +;; icicle-nb-of-candidate-in-Completions: Update last-nb before the test, in loop. +;; icicle-prefix-complete-1: If input matches empty dir, use that dir as sole completion. +;; Don't remove *Completions* window until after minibuffer msg. +;; icicle-move-to-next-completion: Use icicle-show-Completions-help-flag, not hard-coded 3. +;; icicle-candidate-action-1: For require-match case also, remove cand and display others. +;; Added: icicle-choose-completion. +;; 2008/01/30 dadams +;; Added: icicle-yank-secondary, icicle-mouse-yank-secondary. +;; 2008/01/29 dadams +;; icicle-(apropos|prefix)-complete-1: +;; If icicle-incremental-completion-flag is explicit*, treat like incremental completion. +;; icicle-apropos-complete-1: +;; Distinguish non-existent dir from empty dir: icicle-apropos-any-file-name-candidates-p. +;; icicle-highlight-input-noncompletion takes no args now. +;; 2008/01/13 dadams +;; icicle-mouse-choose-completion, icicle-insert-completion, +;; icicle-mouse-candidate-action-1, icicle-mouse-save-candidate: +;; Do not use icicle-transform-multi-completion. +;; icicle-retrieve-last-input, icicle-(apropos|prefix)-complete-1: +;; Do not treat handle-switch-frame. +;; icicle-mouse-candidate-action-1: Add back \n only if it has property icicle-keep-newline. +;; icicle-mouse-remove-candidate: Removed cruft. +;; icicle-remove-candidate-display-others: save-selected-window around Completions display. +;; icicle-help-on-candidate: Rewrote. +;; Do not use icicle-transform-multi-completion except where appropriate. +;; Always use icicle-candidate-help-fn as first priority, if defined. +;; Give help for prefix keys too during key completion. +;; icicle-help-on-candidate-symbol: No call to icicle-candidate-help-fn here. +;; 2008/01/04 dadams +;; icicle-mouse-choose-completion, icicle-current-completion-in-Completions: +;; Add candidate's final \n only if it has property icicle-keep-newline. +;; 2007/01/01 dadams +;; icicle-narrow-candidates: For Emacs < 22, don't tack dir onto file name if absolute. +;; icicle-candidate-set-save-1: Only redisplay candidates if *Completions* was displayed. +;; 2007/12/31 dadams +;; icicle-mouse-choose-completion, icicle-mouse-candidate-action-1: +;; Add back candidate's final \n that is missing mouse-face. +;; Return icicle-candidate-nb, as doc string says. +;; icicle-mouse-candidate-action-1: Delete current input from minibuffer before acting. +;; Added: icicle-insert-list-join-string. +;; Don't mention that C-o is bound to icicle-candidate-action. +;; 2007/12/26 dadams +;; icicle-transform-multi-completion: Empty input after join string means empty part. +;; icicle-help-on-candidate: Don't call icicle-raise-Completions-frame. +;; 2007/12/11 dadams +;; icicle-change-sort-order: +;; Don't include icicle-proxy-candidate-first-p unless icicle-add-proxy-candidates-flag. +;; 2007/12/10 dadams +;; icicle-exit-minibuffer, icicle-kill-failed-input: +;; Face icicle-input-completion-fail-lax also. +;; 2007/12/09 dadams +;; icicle-exit-minibuffer: Remove icicle-input-completion-fail face from input. +;; icicle-kill-failed-input: Rehighlight after deleting highlighted part. +;; 2007/12/08 dadams +;; icicle-(next|previous)-line: Rewrote for variable number of columns. +;; Added: , icicle-(beginning|end)-of-line+. +;; 2007/12/03 dadams +;; Renamed longest common match (lcm) to expanded common match (ecm). +;; 2007/11/30 dadams +;; icicle-help-on-candidate-symbol: +;; Use fboundp, not functionp, to get describe-function for macros too. +;; 2007/11/28 dadams +;; Renamed describe-bindings-in-map to describe-keymap. +;; icicle-toggle-proxy-candidates: Swap values for saved and unsaved. +;; 2007/11/25 dadams +;; Added: icicle-sort-by-abbrev-frequency. +;; icicle-help-on-candidate-symbol: Treat command abbrevs via apropos for their commands. +;; 2007/11/24 dadams +;; Added: icicle-sort-proxy-candidates-first. +;; 2007/11/22 dadams +;; icicle-help-on-candidate-symbol: Use describe-bindings-in-map for a keymap. +;; 2007/11/17 dadams +;; Added: icicle-toggle-proxy-candidates. Added to icicle-Completions-mouse-3-menu also. +;; 2007/11/04 dadams +;; Require subr-21 if replace-regexp-in-string is not defined. +;; Require icicles-mac (don't wrap in eval-when-compile). +;; icicle-Completions-mouse-3-menu: Added the latest toggle commands. +;; 2007/10/28 dadams +;; Added: icicle-toggle-expand-to-common-match, icicle-toggle-search-replace-common-match. +;; icicle-retrieve-last-input: +;; Treat prefix completion like non-nil expand-input-to-common-match-flag. +;; icicle-search-define-replacement: Bind icicle-update-input-hook to nil. +;; icicle-toggle-highlight-all-current: +;; Save icicle-candidate-nb around rehighlighting. +;; Call icicle-search-action to get back to current candidate and highlight it. +;; 2007/10/27 dadams +;; icicle-search-define-replacement: +;; Bind candidates, input, and cand #, to restore after read replacement string. +;; 2007/10/26 dadams +;; icicle-toggle-highlight-all-current: select-frame-set-input-focus to minibuffer. +;; 2007/10/22 dadams +;; icicle-doremi-*: Use 4 arrows - one command hands off to the other. +;; 2007/10/21 dadams +;; Added: icicle-doremi-inter-candidates-min-spaces, icicle-doremi-candidate-width-factor. +;; 2007/10/14 dadams +;; Updated doc strings to reflect icicle-act-before-cycle-flag. +;; 2007/10/13 dadams +;; icicle-candidate-action-1: +;; Don't set icicle-last-completion-candidate if string. Used for repeated C-next. +;; icicle-remove-candidate-display-others, icicle-history: +;; Treat also the case where cand is a string, not a consp. +;; 2007/10/07 dadams +;; icicle-delete-candidate-object: Respect icicle-deletion-action-flag. +;; 2007/10/02 dadams +;; icicle-(apropos|prefix)-complete-1: +;; Apply abbreviate-file-name to file-name input. Thx to Joonhwan Lee. +;; icicle-toggle-fuzzy-completion: Removed soft require of fuzzy-match+.el. +;; 2007/09/29 dadams +;; Added: icicle-toggle-fuzzy-completion. +;; icicle-Completions-mouse-3-menu: Added icicle-toggle-fuzzy-completion. +;; icicle-prefix-complete-1: Adjust feedback messages for fuzzy completion. +;; icicle-(apropos|prefix)-complete-1: +;; Only set icicle-default-directory if (icicle-file-name-input-p). +;; 2007/09/25 dadams +;; icicle-narrow-candidates: Treat icicle-whole-candidate-as-text-prop-p case. +;; icicle-kill-failed-input: Rewrote. +;; 2007/09/21 dadams +;; icicle-narrow-candidates: +;; Emacs<22, file-name completion: Append directory to each candidate. Thx Ian Perryman. +;; 2007/09/14 dadams +;; icicle-(apropos|prefix)-complete-1, icicle-prefix-word-complete: +;; Wrapped condition-case around candidates computation. +;; 2007/08/25 dadams +;; icicle-mouse-candidate-action-1: Use buffer-substring, not buffer-*-no-properties. +;; 2007/08/21 dadams +;; icicle-(apropos|prefix)-complete-1: +;; Reset icicle-input-fail-pos. Call icicle-highlight-input-noncompletion when no match. +;; 2007/08/19 dadams +;; Added: icicle-kill-failed-input. +;; 2007/08/18 dadams +;; icicle-previous-apropos-candidate-alt-action: Fixed typo. Thx to Hadron Quark. +;; 2007/07/29 dadams +;; icicle-apply-to-saved-candidate: +;; Added use-icicle-candidates-alist-p arg. Use icicle-get-alist-candidate. +;; Report original error message also. +;; icicle-candidate-action-1: Do nothing if icicle-last-completion-candidate not a string. +;; 2007/07/27 dadams +;; icicle-successive-action: +;; icicle-act-first-then-navigate-p -> icicle-act-before-cycle-flag. +;; 2007/07/08 dadams +;; icicle-all-candidates(-alt)-action: +;; Use icicle-all-candidates(-alternative)-action-fn if defined. +;; icicle-all-candidates-action-1: Added listp arg. +;; icicle-mouse-save-candidate: +;; Deactivate mark and redisplay completions, to show save highlight. +;; 2007/07/07 dadams +;; Added: icicle-candidate-set-save(-more)-selected(-1), +;; icicle-mouse-candidate-set-save(-more), icicle-mouse-save-then-kill. +;; icicle-insert-completion: If no current completion, return to minibuffer anyway. +;; Update icicle-current-input with inserted candidate. +;; icicle-Completions-mouse-3-menu: +;; Added icicle-candidate-set-save-(more(-selected)|-selected). +;; icicle-save-candidate: If no defined icicle-candidate-nb, then just display message. +;; icicle-candidate-set-save(-more): +;; Use icicle-candidate-set-save-1: Intern variable in standard obarray also. Redisplay +;; candidates and reselect minibuffer after reading file/var name. Put eof error in +;; minibuf. Deactivate mark and redisplay completions. Separate msg if reset. +;; icicle-candidate-set-retrieve: If nothing to restore, don't restore nothing. +;; If single candidate to restore, no *Completions* display. +;; Else, update candidate display. +;; 2007/07/04 dadams +;; icicle-Completions-mouse-3-menu: Added icicle-retrieve-(next|\previous)-input. +;; 2007/07/03 dadams +;; Added: icicle-insert-history-element, icicle-retrieve-(next|previous)-input. +;; icicle-history, icicle-keep-only-past-inputs: +;; Don't retrieve last input unless following a cycling command. +;; icicle-history: +;; Do an initial icicle-apropos-complete unless icicle-last-completion-command. +;; If not following a cycling command, call icicle-last-completion-command (don't set it +;; to empty string) and reset icicle-last-input to nil. +;; icicle-Completions-mouse-3-menu: +;; icicle-retrieve-(next|previous)-input, not icicle-retrieve-last-input. +;; Redefined next-history-element, instead of using defadvice. +;; 2007/06/23 dadams +;; icicle-search-define-replacement: Use icicle-completing-read-history, not read-string. +;; Use icicle-search-replacement-history. +;; 2007/06/17 dadams +;; Added: icicle-toggle-WYSIWYG-Completions. +;; icicle-switch-to-Completions-buf, icicle-move-to-next-completion: +;; Added priority in call to icicle-place-overlay. +;; 2007/06/13 dadams +;; Added: icicle-candidate-set-save-more. +;; icicle-candidate-set-save: Unify messages. +;; 2007/06/12 dadams +;; Added: icicle(-mouse)-save-candidate. +;; icicle-candidate-set-retrieve: Insert candidate if there is only one retrieved. +;; icicle-insert-completion: Added optional completion arg for non-interactive insertion. +;; 2007/06/10 dadams +;; icicle-candidate-action-1: Treat icicle-require-match-p. +;; 2007/06/09 dadams +;; icicle-candidate-action-1, icicle-mouse-candidate-action-1: +;; Remove candidate if icicle-use-candidates-only-once-flag. +;; icicle-candidate-action-1: +;; Let users act on non-candidate too (arbitrary input). +;; 2007/06/07 dadams +;; Renamed: icicle-function-history to icicle-function-name-history, +;; icicle-variable-history to icicle-variable-name-history. +;; Use standard history variable if bound, else use Icicles history variable: +;; function-name-history, variable-name-history +;; 2007/06/01 dadams +;; icicle-erase-minibuffer-or-history-element, icicle-history: +;; Ensure value of minibuffer-history-variable is bound. +;; icicle-keep-only-past-inputs: If value of minibuffer-history-variable unbound, set nil. +;; icicle-keep-only-past-inputs, icicle-history: +;; Assume value of minibuffer-history-variable is a symbol - don't test that. +;; 2007/05/29 dadams +;; icicle-insert-thing: Added optional arg no-replace-p. Make sure end points are defined. +;; icicle-insert-string-from-variable: Call icicle-insert-thing with no-replace-p arg. +;; icicle-minibuffer-complete-and-exit: Set window-point to end of minibuffer. +;; 2007/05/15 dadams +;; icicle-completion-help and top level: +;; Soft require help-mode, not (featurep 'help-mode) and (fboundp 'define-button-type). +;; 2007/05/08 dadams +;; Added: icicle-save-predicate-to-variable. +;; icicle-Completions-mouse-3-menu: Added icicle-save-predicate-to-variable to menu. +;; icicle-narrow-candidates-with-predicate: Quoted the predicate that is read. +;; 2007/05/07 dadams +;; Added: icicle-narrow-candidates-with-predicate. +;; icicle-Completions-mouse-3-menu: Added icicle-narrow-candidates-with-predicate (M-&). +;; 2007/05/06 dadams +;; icicle-completion-help: Updated text at top of help buffer. +;; icicle-customize-button: Capitalized group Icicles. +;; Changed S-C- to C-S- and M-C- to C-M- in doc. +;; 2007/05/04 dadams +;; icicle-candidate-read-fn-invoke, icicle-keep-only-*-inputs, icicle-retrieve-last-input, +;; icicle-candidate-set-(retrieve|save|swap|difference|union|intersection|complement), +;; icicle-all-candidates(-alt)-action, icicle-pp-eval-expression, +;; icicle-insert-string-from-variable: +;; Can call from *Completions* too, so can choose from mouse-3 menu during multi-command. +;; icicle-candidate-set-save, icicle-retrieve-last-input, icicle-insert-*-from-variable: +;; Select minibuffer window. +;; icicle-toggle-case-sensitivity: Use setq-default for case-fold-search. +;; icicle-switch-to-Completions-buf: +;; Use read-file-name-completion-ignore-case, if completing file name. +;; Added empty defvars for Emacs 22 standard vars, to quiet byte compiler. +;; 2007/05/02 dadams +;; Added: icicle-dispatch-M-q, icicle-toggle-search-whole-word. +;; Removed: icicle-dispatch-C-backquote. +;; 2007/04/29 dadams +;; Added: icicle-sort-by-last-file-modification-time (sort order). +;; 2007/04/19 dadams +;; icicle-successive-action: No longer interactive. Moved barfing to calling commands. +;; 2007/04/17 dadams +;; Added: icicle-dispatch-M-comma, icicle-search-define-replacement, +;; icicle-dispatch-C-backquote, icicle-toggle-literal-replacement. +;; 2007/04/08 dadams +;; Added: icicle-all-candidates-alt-action, icicle-all-candidates-action-1. +;; icicle-candidate-action-1, icicle-delete-candidate-object, icicle-help-on-candidate, +;; icicle-candidate-read-fn-invoke: +;; Use negative test for prefix mode, not positive test for apropos. +;; 2007/04/07 dadams +;; Added: icicle-successive-action, icicle-toggle-search-replace-whole, +;; icicle-dispatch-C-comma. +;; Defined navigating action and help functions using icicle-successive-action. +;; 2007/03/31 dadams +;; icicle-(apropos|prefix)-complete-1: +;; Accept sole completion if icicle-top-level-when-sole-completion-flag. +;; icicle-narrow-candidates: +;; Use read-file-name only for Emacs 22 or later. +;; Accept sole completion only if icicle-top-level-when-sole-completion-flag. +;; icicle-apropos-complete-and-narrow: Bind icicle-top-level-when-*-flag to t. +;; 2007/03/30 dadams +;; icicle-narrow-candidates: Suppress sole-completion minibuffer-message. +;; 2007/03/23 dadams +;; Added: icicle-apropos-complete-and-narrow. Thx to Marian Schubert for the suggestion. +;; icicle-narrow-candidates: Use icicle-require-match-p as REQUIRE-MATCH arg. +;; 2007/03/09 dadams +;; Changed require to eval-when-compile require for icicles-mac.el. +;; 2007/03/08 dadams +;; icicle-delete-current-candidate-object: Rewrote. +;; Value of var can be an arbitrary alist, a list of strings, or a list of symbols. +;; icicle-remove-candidate-display-others: Rewrote. +;; Set icicle-last-completion-candidate based on icicle-candidate-nb or 0. +;; Delete icicle-last-completion-candidate completely from icicle-completion-candidates. +;; Update minibuffer-completion-predicate or read-file-name-predicate to remove for +;; completion. +;; Use with-current-buffer, not save-window-excursion, to visit *Completions*. +;; icicle-remove-candidate: +;; Updated doc string to mention Emacs < 22 limitation for file-name candidates. +;; icicle-retrieve-last-input: Don't reset icicle-last-completion-command if interactive. +;; 2007/03/07 dadams +;; icicle-switch-to-Completions-buf, icicle-remove-candidate-display-others, +;; icicle-help-on-candidate, icicle-delete-windows-on: +;; Use 0, not t, as frame arg to get-buffer-window. +;; 2007/03/06 dadams +;; icicle-remove-candidate: Don't reset to first cand matching input if no last cand. +;; icicle-change(alternative)-sort-order, icicle-reverse-sort-order, +;; icicle-keep-only-past-inputs, icicle-toggle-sorting: Respect icicle-inhibit-sort-p. +;; Renamed icicle-get-current-candidate to icicle-get-alist-candidate. +;; 2007/03/04 dadams +;; icicle-remove-candidate-display-others: +;; Use local var for cand-nb, because icicle-candidate-nb can change. +;; If no last candidate, reset to first candidate matching input. +;; Allow for icicle-candidate-nb not being defined here: +;; Use icicle-get-current-candidate. Move to next completion only if cand-nb defined. +;; Use mapconcat only when delete multi-completion. +;; Move to next completion in *Completions* only if icicle-candidate-nb was defined. +;; Insert default-directory too, if icicle-file-name-input-p. +;; icicle-insert-completion: Insert default-directory too, if icicle-file-name-input-p. +;; icicle-(apropos|prefix)-complete-1, icicle-keep-only-past-inputs: +;; Don't include directory when set icicle-last-completion-candidate. +;; icicle-(apropos|prefix)-complete-1: +;; Don't include directory when testing input membership in icicle-completion-candidates. +;; 2007/03/02 dadams +;; icicle-delete-candidate-object: +;; Corrected message target (object). Added sit-for. +;; Use local var for cand-nb, because icicle-candidate-nb can change. +;; 2007/02/27 dadams +;; icicle-delete-candidate-object: Added message. +;; icicle-delete-current-candidate-object: Don't erase minibuffer or update completions. +;; 2007/02/24 dadams +;; Added: icicle(-mouse)-candidate-alt-action, icicle(-mouse)-candidate-action-1, +;; icicle-(previous|next)-(apropos|prefix)-candidate-alt-action, +;; icicle(-mouse)-remove-candidate, icicle-remove-candidate-display-others, +;; icicle-delete-candidate-object, icicle-delete-current-candidate-object. +;; icicle-insert-completion: +;; Invoke icicle-transform-multi-completion. Use with-current-buffer (window-buffer). +;; icicle(-mouse)-candidate-action: Use icicle(-mouse)-candidate-action-1. +;; 2007/02/06 dadams +;; icicle-completion-help: Added extra help if completing and if multi-command. +;; 2007/02/03 dadams +;; Renamed icicle-icompleting-p to icicle-edit-update-p. +;; 2007/02/02 dadams +;; Updated doc strings of toggle commands to mention the minibuffer bindings. +;; 2007/01/29 dadams +;; icicle-change-sort-order: Don't sort icicle-sort-functions-alist entries for use. +;; Define alphabetical sort order using icicle-case-string-less-p, not string-lessp. +;; 2007/01/23 dadams +;; Added: icicle-toggle-highlight-historical-candidates. +;; icicle-Completions-mouse-3-menu: Updated wrt toggles. +;; 2007/01/21 dadams +;; icicle-narrow-candidates: +;; Use minibuffer-history-variable, not regexp-history. Thx to Jost for bug report. +;; 2007/01/20 dadams +;; icicle-mouse-(choose-completion|candidate-action): +;; Use icicle-transform-multi-completion. +;; 2007/01/15 dadams +;; Added: icicle-change(-alternative)-sort-order, icicle-reverse-sort-order, +;; icicle-current-sort-order, icicle-sort-*. +;; icicle-transform-sole-candidate: Set icicle-last-*-candidate to transformed cand. +;; icicle-help-on-candidate: Use icicle-transform-multi-completion. +;; icicle-Completions-mouse-3-menu: Updated with new sort-order bindings. +;; icicle-toggle-alternative-sorting: Better message. +;; Require icicles-mac.el. +;; 2007/01/14 dadams +;; Added: icicle-transform-multi-completion, icicle-transform-sole-candidate. +;; icicle-(apropos|prefix)-complete-1: Use icicle-transform-sole-candidate. Thx Rubikitch. +;; icicle-help-on-candidate(-symbol): +;; Use with-current-buffer to describe mode in Emacs 20 also. +;; 2007/01/13 dadams +;; Added: icicle-describe-file, icicle-help-on-candidate-symbol. +;; icicle-help-on-candidate: +;; If existing symbol, describe it. Else if buffer or file, describe it. Else, convert +;; string to symbol and describe it. Use icicle-help-on-candidate-symbol. +;; 2007/01/10 dadams +;; icicle-switch-to/from-minibuffer: Error message if minibuffer is not active. +;; 2007/01/06 dadams +;; icicle-(apropos|prefix)-complete-1: +;; expand-file-name -> icicle-abbreviate-or-expand-file-name. +;; Added: icicle-toggle-~-for-home-dir. +;; icicle-prefix-complete-1: +;; Set icicle-default-directory only if also icicle-file-name-input-p. +;; 2007/01/01 dadams +;; icicle-add/update-saved-completion-set: Use icicle-assoc-delete-all, not delete of assoc. +;; Runtime, not compile-time, require of icicles-var.el, icicles-opt.el. +;; 2006/12/29 dadams +;; icicle-insert-string-at-point: +;; Treat nil return of alternative text-grabbing function. +;; Echo the text-grabbing function when icicle-default-thing-insertion = alternatives. +;; icicle-ensure-overriding-map-is-bound: Separate treatment for diff Emacs versions. +;; 2006/12/25 dadams +;; icicle-keep-only-past-inputs: +;; Added optional recent-first arg: Use icicle-most-recent-first-p as sort function. +;; Update cands list if repeat. Do not scroll Completions; update it unconditionally. +;; Added: icicle-candidate-set-truncate. +;; Uncommented describe-mode code, since RMS fixed Emacs bug that caused infinite recursion. +;; 2006/12/24 dadams +;; Added: icicle-Completions-mouse-3-menu. +;; 2006/12/23 dadams +;; icicle-narrow-candidates: Bug fix: Treat file-name completion with read-file-name. +;; icicle-help-on-candidate: Call non-nil icicle-candidate-help-fn on candidate. +;; 2006/12/18 dadams +;; icicle-apply-to-saved-candidate: Remove print arg and use current-prefix-arg instead. +;; icicle-ensure-overriding-map-is-bound: Protect overriding-map-is-bound with boundp. +;; Bug fix for Emacs 21: protect help-xref with get type button-category-symbol. +;; 2006/12/17 dadams +;; Added: icicle(-mouse)-candidate-read-fn-invoke, icicle-apply-to-saved-candidate. +;; 2006/12/10 dadams +;; Created from minibuffer and *Completions* commands in icicles-cmd.el. + +;;;(@* "CHANGE LOG FOR `icicles-mode.el'") +;; +;; 2010/07/17 dadams +;; w3m - > url. Add URL jump bindings. Replace w3m by url otherwise. +;; 2010/06/11 dadams +;; icicle-define-minibuffer-maps: Bind/restore C-c + to icicle-make-directory in file-name maps. +;; 2010/06/04 dadams +;; icicle-mode doc string: Mention missing doremi commands. +;; icicle-define-icicle-maps: Added Swank items and Max # of Completions, :visible for separator. +;; icicle-(bind|restore)-completion-keys: Bind icicle-doremi-increment-max-candidates+ to C-x #. +;; Apply renamings of icicle-doremi* (added +). +;; 2010/05/26 dadams +;; Add to command-history only if an interned symbol. Thx to Michael Heerdegen. +;; 2010/05/22 dadams +;; icicle-(bind|restore)-completion-keys: Bind icicle-candidate-read-fn-invoke to ESC C-m also. +;; 2010/05/17 dadams +;; icicle-define-icicle-maps: Changed :enable conditions for *-goto*-marker. Thx to M. Heerdegen. +;; 2010/05/15 dadams +;; icicle-mode: Updated doc string for bookmark commands. +;; 2010/05/09 dadams +;; Key-binding changes: icicle-change-sort-order is C-, icicle-dispatch-M-_ is M-_. +;; 2010/04/21 dadams +;; icicle-(redefine|restore)-std-completion-fns: Added icicle-sit-for for Emacs 23. +;; 2010/04/02 dadams +;; icicle-mode: Updated doc string: list of commands. +;; 2010/04/02 dadams +;; icicle-mode: Update doc string for change from regions to bookmarks. +;; icicle-define-icicle-maps: +;; Remove Icicles region stuff from menus. +;; Added to menus: icicle-search-bookmarks-together, icicle-search-bookmark, +;; icicle-select-bookmarked-region. +;; 2010/03/28 dadams +;; Applied renaming: icicle-search-all-regions to icicle-search-region. +;; Use icicle-search-region-bookmark in menus. +;; 2010/03/14 dadams +;; icicle-define-minibuffer-maps: Use featurep, not soft-require, for bookmark+.el. +;; Added bookmark+ to final dolist for eval-after-load. +;; 2010/03/13 dadams +;; icicle-define-icicle-maps: +;; Bound icicle-toggle-show-multi-completion to M-m in minibuffer, and added to menus. +;; Applied renaming of icicle-add-buffer-name-flag to icicle-show-multi-completion-flag. +;; 2010/02/17 dadams +;; Applied rename of icicl-redefined-functions to icicle-inhibit-advice-functions. +;; 2010/02/13 dadams +;; icicle-mode: +;; Fill icicle-advice-info-list from advised fns among icicle-redefined-functions. +;; Reactivate advised fns (in icicle-advice-info-list) when turn mode off. +;; Added to doc string: icicle-bookmark-(dired|desktop|bookmark-list|man)-other-window. +;; icicle-define-icicle-maps: Use (featurep 'recentf) instead of soft-requiring it. +;; icicle(-bookmark)-menu-map: Added type-specific bookmark jump commands. +;; eval-after-load's: Add (when (featurep 'icicles-mode)...) to ensure this file was loaded. +;; 2010/01/28 dadams +;; icicle-define-minibuffer-maps, icicle-restore-completion-keys: +;; Restore C-g correctly if delete-selection-mode. +;; 2009/12/25 dadams +;; icicle-mode: Call completion-ignored-build-disable to disable the advice. +;; 2009/12/21 dadams +;; Final dolist: Move loaded-library test outside of eval-after-load. +;; Update the test for Emacs 22+ (not just assoc). Thx to Kevin Ryde. +;; Combine eval-after-load's for dired-x. Remove eval-after-load for simple.el (preloaded). +;; fset -> defalias. +;; 2009/12/13 dadams +;; icicle-define-minibuffer-maps: +;; Bind C-x m to icicle-bookmark-file-other-window in file-name completion maps. +;; 2009/11/29 dadams +;; Don't reference minibuffer-local-must-match-filename-map unless bound (obsolete in 23.2). +;; 2009/11/27 dadams +;; icicle-(bind|restore)-completion-keys: Bind/restore C-x 1, C-x 2. +;; 2009/11/07 dadams +;; Applied doremi cmd renamings (added +). +;; 2009/10/25 dadams +;; icicle-mode, icicle-define-icicle-maps, icicle-bind-completion-keys: +;; Updated doc string, menus, keys for completion-method command renamings. +;; 2009/09/26 dadams +;; icicle-minibuffer-setup: Don't complete if icicle-progressive-completing-p. +;; 2009/09/16 dadams +;; icy-mode: Add icicle-insert-buffer to doc string. +;; icicle-define-icicle-maps: Added icicle-insert-buffer to icicle-menu-map. +;; 2009/09/10 dadams +;; icicle-bind-key-completion-keys-in-keymaps-from: Don't exclude menu maps. +;; 2009/09/03 dadams +;; icicle-add-menu-item-to-cmd-history: Wrap in condition-case, since on pre-command-hook. +;; 2009/08/18 dadams +;; icicle-add-menu-item-to-cmd-history: +;; Ensure this-command-keys-vector is not empty. Thx to Kai Tetzlaff and Lennart Borgman. +;; 2009/08/09 dadams +;; icicle-minibuffer-setup: Set region background for recursive minibuffers too. +;; icicle-restore-region-face: Don't restore unless going back to top level. +;; 2009/08/01 dadams +;; Added: icicle-add-menu-item-to-cmd-history. Thx to Lennart Borgman. +;; icy-mode: add/remove pre-command-hook, respecting icicle-menu-items-to-history-flag. +;; call-interactively defadvice: Do not save let savehist save icicle-interactive-history. +;; 2009/07/29 dadams +;; Change advice for call-interactively: +;; Use it only for Emacs 23+. Disable it to begin with. +;; Add only (non-mouse command) symbols to history. +;; icy-mode (Emacs 23+): +;; Enable/disable advice icicle-save-to-history when mode is turned on/off. +;; Enable the advics only if non-nil icicle-populate-interactive-history-flag. +;; icy-mode (Emacs 20-21): Remove advice icicle-save-to-history. +;; 2009/07/26 dadams +;; Advise call-interactively to save command to icicle-interactive-history. +;; icicle-(bind|restore)-completion-keys: Bind/restore C-M-pause as icicle-other-history. +;; 2009/07/13 dadams +;; Emacs 22+: +;; Added describe-face defadvice (icicle-respect-WYSIWYG). icicle-mode: (de)activate it. +;; 2009/06/18 dadams +;; icicle-mode: Added icicle-doremi-zoom-Completions to doc string. +;; 2009/06/17 dadams +;; icicle-(bind|restore)-completion-keys: Bind icicle-doremi-zoom-Completions to C-x -. +;; icicle-define-icicle-maps: +;; Add icicle-doremi-zoom-Completions to Options menu. +;; Change visible condition for all doremi stuff to ensure *Completions* is showing. +;; 2009/05/27 dadams +;; icicle-retrieve-(next|previous)-input: Removed unused (always nil) arg DONT-COMPLETE-P. +;; 2009/05/22 dadams +;; icicle-define-icicle-maps: Added icicle-Info-virtual-book to menu. +;; Require icicles-cmd[12].el. +;; 2009/05/17 dadams +;; dolist eval-after-load at end: Use icicle-toggle-icicle-mode-twice, not icy-mode calls. +;; 2009/05/09 dadams +;; icicle-define-icicle-maps: Added icicle-toggle-dot to options menu. Updated C-x . key. +;; icicle-(bind|restore)-completion-keys: +;; Bind *-toggle-dot to C-M-., *-toggle-hiding-common-match to C-x ., +;; *-insert-dot-command to .. +;; icy-mode: Mention icicle-toggle-dot in doc string. +;; 2009/05/02 dadams +;; icicle-minibuffer-setup: Set icicle-cmd-reading-input to this-command. +;; 2009/04/30 dadams +;; icicle-minibuffer-setup: Reset icicle-next-(prefix|apropos)-complete-cycles-p to nil. +;; 2009/04/20 dadams +;; icicle-bind-completion-keys: Don't bind C-S-(up|down|next|prior) explicitly. +;; icicle-restore-completion-keys: +;; Restore: icicle-(prefix|apropos)-cycle-(previous|next)-alt-action-keys, +;; icicle-modal-cycle-(up|down)-alt-action-keys. +;; Don't restore C-S-(up|down|next|prior) explicitly. +;; icicle-define-cycling-keys: +;; Bind/Restore: icicle-(prefix|apropos)-cycle-(previous|next)-alt-action-keys, +;; icicle-modal-cycle-(up|down)-alt-action-keys. +;; 2009/04/19 dadams +;; icicle-redefine-standard-commands: Added defalias for customize-apropos-options-of-type. +;; eval-after-loads: Use when/unless instead of and/or for fset's. (cosmetic) +;; 2009/04/18 dadams +;; icicle-mode: Mention in doc string: you might want to customize keys if no window mgr. +;; 2009/04/16 dadams +;; icicle-restore-completion-keys, icicle-define-cycling-keys: +;; Use icicle-(prefix|apropos)-cycle-(previous|next)-help-keys. +;; 2009/04/15 dadams +;; icicle-bind-completion-keys: Removed bindings for C-M-(up|down|prior|next). +;; icicle-restore-completion-keys: Unbind icicle-modal-cycle-(up|down)-help-keys. +;; icicle-define-cycling-keys: Bind/unbind all help keys (including modal ones). +;; 2009/03/27 dadams +;; icicle-(redefine|restore)-standard-commands: +;; Added icicle-minibuffer-default-add-completions. +;; 2009/03/16 dadams +;; icicle-define-icicle-maps: Use :visible for Icicle submenus themselves. +;; icicle-(redefine|restore)-standard-commands: Added icicle-recentf-make-menu-items. +;; Added eval-after load for recentf.el. +;; 2009/03/15 dadams +;; icicle-mode: Added to doc string: icicle-recompute-shell-command-candidates, +;; icicle-remove-file-from-recentf-list. +;; icicle-define-icicle-maps: Added icicle-remove-file-from-recentf-list to menus. +;; 2009/03/10 dadams +;; icicle-mode: Don't reset icicle-shell-*-cache if icicle-guess-commands-in-path is load. +;; Applied renaming: icicle-shell-command-candidates to *-cache +;; 2009/03/01 dadams +;; icicle-define-minibuffer-maps: +;; Bind icicle-completing-read+insert, icicle-read+insert-file-name. Add to Minibuf menu. +;; 2009/02/28 dadams +;; fset old-dired-smart-shell-command after load Dired-X. +;; 2009/02/20 dadams +;; icicle-mode: Reset icicle-shell-command-candidates to nil. +;; icicle-minibuffer-setup: +;; Use function icicle-require-match-p, not var. +;; Do not reset icicle-completing-p to nil (reset by icicle-require-match-p). +;; icicle-(redefine|restore)-standard-commands: +;; Redefine dired-read-shell-command, not dired-guess-shell-command. +;; Redefine: dired-smart-shell-command, shell-command(-on-region). +;; Added eval-after load for dired-read-shell-command for dired-aux.el (and for dired-x.el). +;; eval-after-load for read-shell-command: Don't do it only when mailcap can be loaded. +;; 2009/02/01 dadams +;; icicle-define-minibuffer-maps: Bind C-backspace to icicle-up-directory. +;; 2009/01/25 dadams +;; icicle-(redefine|restore)-standard-commands: +;; Aliases for dired-guess-shell-command, read-shell-command. Also eval-after-load's. +;; 2009/01/23 dadams +;; icicle-(bind|restore)-other-keymap-keys: +;; For sh-mode-map, remap comint-dynamic-complete, don't (un)bind TAB. Thx to Seb Luque. +;; 2009/01/18 dadams +;; Renamed Open Dired for Saved Completion Candidates to Open Dired for Chosen Files. +;; 2009/01/06 dadams +;; Added to dolist of eval-after-load's: net-utils, rlogin, idlw-shell. +;; 2009/01/05 dadams +;; icicle-(bind|restore)-other-keymap-keys: Treat keys for Shell Script, Ielm, Tcl, and GUD. +;; icicle-(redefine|restore)-standard-commands: +;; Handle: comint-dynamic-complete-filename, gud-gdb-complete-command. +;; Added eval-after-load for gud. +;; Added to dolist of eval-after-load's: ielm, gud, sh-script, tcl. +;; 2009/01/04 dadams +;; Added ESS support: +;; icicle-(redefine|restore)-standard-commands: +;; Added: (icicle|old)-comint-replace-by-expanded-filename, +;; (icicle|old)-ess-complete-object-name. +;; Added eval-after-load for ess-site and for old-comint-replace-by-expanded-filename. +;; Thx to Sebastian Luque. +;; 2008/12/30 dadams +;; icicle-mode: Don't add/remove hook icicle-shell-hook-fn. +;; Don't call icicle-(un)bind-isearch-keys. +;; Renamed: icicle-rebind-other-keymap-keys to icicle-bind-other-keymap-keys. +;; icicle-(bind|restore)-other-keymap-keys: +;; Call icicle-(un)bind-isearch-keys here. +;; Bind/restore icicle-comint-command here. +;; Don't use eval-after-load. Instead, define keys if the maps are defined. +;; Bind/restore shell keys only if icicle-redefine-standard-commands-flag is true. +;; icicle-minibuffer-setup: +;; Remove redundant code that calls icicle-define-cycling-keys for each minibuffer map. +;; icicle-define-minibuffer-maps: +;; Restore C-g to abort-recursive-edit in minibuffer-local-must-match-map. +;; icicle-(redefine|restore)-standard-commands: +;; Test fboundp of old-*, not *, for bbdb and comint. +;; Do not defalias comint-dynamic-complete-filename or shell-dynamic-complete-*. +;; icicle-remap: Moved to icicles-opt.el. +;; At end of file: +;; eval-after-load comint and bbdb: Turn off icy-mode before fset old-*. +;; eval-after-load each of the other keymap libraries: Toggle icy-mode. +;; 2008/12/26 dadams +;; Bind icicle-widen-candidates to M-+, and add it to Minibuf menu. +;; Bind icicle-apropos-complete-and-widen to S-backspace. +;; 2008/12/22 dadams +;; Forgot to add/remove icicle-shell-hook-fn to shell-mode-hook for Emacs 20. +;; icicle-bind-completion-keys, icicle-define-icicle-maps: Added icicle-regexp-quote-input. +;; 2008/12/21 dadams +;; icicle-(redefine|restore)-standard-commands: Added comint-*, shell-*. +;; Renamed *-(rebind|restore)-non-completion-keys to *-(rebind|restore)-other-keymap-keys. +;; icy-mode: Add/remove icicle-shell-hook-fn to shell-mode-hook. +;; icicle--(rebind|restore)-other-keymap-keys: +;; Don't rebind Info keys unless icicle-redefine-standard-commands-flag. +;; Wrap Dired key bindings in eval-after-load. +;; icicle-restore-other-keymap-keys: Corrected (updated) Dired keys. +;; 2008/12/07 dadams +;; icicle-minibuffer-setup: +;; Add completing prompt prefix here, using icicle-completion-prompt-overlay. +;; Removed icicle-prompt. +;; 2008/12/05 dadams +;; icicle-(bind|restore)-completion-keys: Bind C-v, M-v to scroll *Completions* window. +;; 2008/11/14 dadams +;; icicle-toggle-hiding-common-match: +;; icy-mode: Mention it in doc string, icicle-define-icicle-maps: Add it to menus. +;; icicle-bind-completion-keys: Bind it to C-M-. +;; icicle-minibuffer-setup: +;; Use (cadr (buffer-list)), not other-buffer, for icicle-pre-minibuffer-buffer +;; 2008/11/04 dadams +;; icicle-define-icicle-maps: No longer bind icicle-generic-S-tab keys (obsolete). +;; Renamed: +;; *-(un)bind-S-TAB-in-keymaps-from to *-(un)bind-key-completion-keys-in-keymaps-from, +;; *-(un)bind-S-TAB-for-map-variable to *-(un)bind-key-completion-keys-for-map-var. +;; icicle-(un)bind-key-completion-keys-in-keymaps-from: +;; icicle-generic-S-tab-keys -> icicle-key-complete-keys. +;; Respect icicle-complete-key-anyway-flag. +;; icicle-define-minibuffer-maps: *-generic-S-tab-keys -> *-previous-candidate-keys. +;; icicle-(bind|restore)-completion-keys: *-generic-S-tab-keys -> *-apropos-complete-keys. +;; icicle-(un)bind-isearch-keys: *-generic-S-tab-keys -> *-search-from-isearch-keys. +;; 2008/11/03 dadams +;; Applied renamings from icicles-cmd.el. +;; 2008/11/01 dadams +;; Require cl.el at compile time for all Emacs versions, not just 20. +;; 2008/10/14 dadams +;; icy-mode: No longer call icicle-update-help-string. +;; Renamed: *-update-help-string to *-help-string-completion and moved to icicles-mcmd.el. +;; Renamed: icicle-rebind-completion-maps to icicle-define-minibuffer-maps. +;; Applied renaming from icicles-mcmd.el: icicle-completion-help to icicle-minibuffer-help. +;; icicle-define-minibuffer-maps: +;; Bound icicle-minibuffer-help also in non-completion minibuffer maps and *Completions*. +;; Bound icicle-yank-secondary in minibuffer-local-isearch-map also. +;; icicle-(bind|restore)-completion-keys: Only bind icicle-minibuffer-help if not inherited. +;; 2008/10/12 dadams +;; icicle-rebind-non-completion-keys (and undo in icicle-restore-non-completion-keys): +;; Ibuffer mode: Bind M-s i to icicle-search-ibuffer-marked and add to Operate menu. +;; Buffer Menu mode: Bind M-s i to icicle-search-buff-menu-marked. +;; Dired mode: Change binding of icicle-search-dired-marked from M-s to M-s i. +;; Removed vestigial binding to C-M-r. +;; Make eval-after-load for "info" unconditional. +;; 2008/10/11 dadams +;; icicle-update-help-string, icicle-(bind|restore)-completion-keys: +;; icicle-kill-failed-input -> icicle-goto/kill-failed-input. +;; icicle-define-cycling-keys: Typo: icicle-apropos-cycle-previous-keys -> *-action*. +;; 2008/10/10 dadams +;; icicle-minibuffer-setup: +;; Make icicle-current-completion-mode respect *-cycling-respects-completion-mode-flag. +;; Initial *Completions* display respects icicle-cycling-respects-completion-mode-flag. +;; icicle-minibuffer-setup, icicle-bind-completion-keys: Use icicle-define-cycling-keys. +;; icicle-restore-completion-keys: Restore (C-)up, (C-)down, (C-)next, (C-)prior. +;; Added: icicle-define-cycling-keys. +;; 2008/10/08 dadams +;; icicle-bind-completion-keys: +;; Bind icicle-candidate-set-retrieve-more to C-<. Add to Minibuf menu. +;; icicle-define-icicle-maps, icicle-update-help-string: Remove C-< for angle brackets. +;; icicle-minibuffer-setup: +;; Set icicle-pre-minibuffer-buffer to (other-buffer nil t), not (cadr (buffer-list). +;; 2008/10/04 dadams +;; icicle-(redefine|restore)-std-completion-fns: +;; Substitute Icicles version of completing-read-multiple and maps. Thx to Per Nordlow. +;; icy-mode doc string: Typo - thx to Richard Kim. +;; 2008/10/01 dadams +;; icicle-update-help-string: Added current values for toggles. Moved toggles near top. +;; Added: icicle-S-iso-lefttab-to-S-TAB. +;; 2008/09/30 dadams +;; icicle-bind-isearch-keys: For icicle-generic-S-tab-keys, read the search string using +;; icicle-isearch-complete-past-string. +;; 2008/09/13 dadams +;; Use renamings from icicles-mcmd.el: +;; icicle-candidate-set-save-to-cache-file to icicle-candidate-set-save-persistently, +;; icicle-candidate-set-retrieve-from-cache-file to *-candidate-set-retrieve-persistent. +;; 2008/09/11 dadams +;; icicle-define-icicle-maps: Added icicle-grep-saved-file-candidates to menus. +;; 2008/09/09 dadams +;; Use renamings from icicles-cmd.el: +;; icicle-candidate-set-dired-marked-save-* to icicle-dired-save-marked-*. +;; Bind: icicle-dired-save-marked-* to C(-M)->, not C(-M)-), +;; icicle-dired-saved-file-candidates-other-window to C-M-<, not C-M-r, +;; icicle-dired-save-marked-(to-variable|as-project) to C-M-}, C-}, +;; icicle-dired-project-other-window to C-{. +;; Add to Dired > Multiple (or Operate) > Icicles menu: icicle-dired-save-marked-as-project. +;; Add to Dired > Dir and File > Icicles menus: icicle-dired-project-other-window. +;; Removed from File > Icicles menu: icicle-dired-saved-file-candidates. +;; 2008/08/22 dadams +;; icicle-update-help-string: Removed mention of icicle-Completions-window-default-width. +;; 2008/08/21 dadams +;; icicle-define-icicle-maps: Replace icicle-find-file(-*) with icicle-file. +;; icicle-mode doc string, icicle-update-help-string: Updated for new cmds icicle-file etc. +;; Define BBDB aliase only if BBDB is loaded. +;; 2008/08/17 dadams +;; icicle-rebind-completion-maps: Bind mouse wheel for completion-list-mode-map. +;; 2008/08/12 dadams +;; icicle-define-icicle-maps: Add :keys for icicle-goto(-global)-marker. +;; 2008/08/08 dadams +;; icicle-define-icicle-maps: +;; Added icicle-goto(-global)-marker to icicle-(bookmark|search)-menu-map. +;; Soft require of menu-bar+.el, instead of just eval-when-compile. +;; 2008/08/07 dadams +;; icicle-(redefine|restore)-*: Don't use symbol-function for target of defalias. +;; 2008/08/04 dadams +;; Use condition-case when require mb-depth+.el. +;; icicle-(rebind|restore)-completion-maps, icicle-bind-completion-keys: +;; Updated Minibuf menu to add icicle-clear-current-history. +;; icicle-restore-completion-keys: +;; Added: (alt-)action(-list)-all, icicle-save-predicate-to-variable. +;; 2008/08/03 dadams +;; icicle-mode: Updated doc string. +;; icicle-update-help-string: Added clear-history stuff and changed bindings. +;; icicle-rebind-completion-maps: Added binding: icicle-clear-current-history (M-i). +;; icicle-bind-completion-keys: +;; Added to Minibuf menu: icicle-all-candidates(-list)(-alt)-action. +;; Added bindings: icicle-all-candidates-list-action (M-!), +;; icicle-all-candidates-list-alt-action (M-|), +;; icicle-clear-current-history (M-i). +;; Changed bindings: +;; icicle-all-candidates-alt-action (C-S-insert to C-|) +;; icicle-toggle-expand-to-common-match (C-| to C-;), +;; icicle-toggle-search-replace-common-match (C-M-| to M-;), +;; +;; 2008/08/01 dadams +;; icicle-mode: Std mb-depth.el renamed *-indicate-depth-mode to *-depth-indicate-mode. +;; 2008/07/30 dadams +;; icicle-update-help-string: Make C-M-) more obvious for clearing saved candidates. +;; 2008/07/23 dadams +;; Renamed: icicle-map to icicle-apply. +;; 2008/07/21 dadams +;; icicle-(redefine|restore)-standard-commands: Added icicle-bbdb-complete. +;; 2008/06/03 dadams +;; icy-mode: Added icicle-toggle-C-for-actions to doc string. +;; icicle-define-icicle-maps: Added icicle-toggle-C-for-actions to menus. +;; icicle-update-help-string: +;; Mention icicle-insert-history-element, icicle-toggle-C-for-actions. +;; icicle-bind-completion-keys: Bindings according to icicle-use-C-for-actions-flag. +;; icicle-(bind|restore)-completion-keys: Bind/unbind M-g. +;; 2008/05/27 dadams +;; Renamed: icicle-(un)bind-isearch-completion-keys to icicle-(un)bind-isearch-keys. +;; icicle-bind-isearch-keys: Bind S-TAB to icicle-search, C-o to isearch-(m)occur. +;; Likewise, icicle-unbind-isearch-keys. +;; 2008/05/25 dadams +;; Renamed: icicle-bind-isearch-keys to icicle-bind-isearch-completion-keys. +;; Added: icicle-unbind-isearch-completion-keys. +;; icy-mode: icicle-(un)bind-isearch-completion-keys instead of updating isearch-mode-hook. +;; icicle-bind-isearch-completion-keys: +;; Don't bind anything in minibuffer-local-isearch-map (overridden by icicle-mode-map). +;; 2008/05/22 dadams +;; icicle-update-help-string: Mention C-u for read-file-name-completion-ignore-case. +;; 2008/05/11 dadams +;; Moved icicle-bind-top-level-commands to icicles-opt.el (and added optional arg). +;; Renamed icicle-fit-Completions-window to icicle-fit-completions-window. +;; 2008/05/10 dadams +;; Renamed: icicle-bind-top-level-commands-alist to icicle-top-level-key-bindings. +;; icicle-bind-top-level-commands: Don't eval the key (binding). +;; 2008/05/07 dadams +;; icicle-define-icicle-maps: Use icicle-bind-top-level-commands instead of hard-coding. +;; icicle-update-help-string: icicle-bind-*-flag -> icicle-bind-*-alist. +;; 2008/04/25 dadams +;; icicle-(redefine|restore)-std-completion-fns: +;; Never set icicle-old-read-file-name-fn to icicle-read-file-name. +;; Thx to Alexey Romanov and Per Nordlow. +;; icicle-define-icicle-maps, icicle-(bind|restore)-completion-keys: +;; Bound icicle-toggle-remote-file-testing (C-^). +;; icicle-toggle-ignored-space-prefix is now bound to M-_, not C-^. +;; icicle-update-help-string: Updated bindings accordingly. +;; 2008/04/18 dadams +;; Renamed icicle-init-value-flag to icicle-default-value. +;; 2008/03/30 dadams +;; icicle-(redefine|restore)-std-completion-fns: +;; Set and swap read-file-name-function and icicle-old-read-file-name-fn for Emacs 22+. +;; Top-level: +;; Moved fset old-read-file-name here, renamed it orig-read-file-name. Not for Emacs 22. +;; 2008/03/29 dadams +;; icicle-mode: No longer use icicle-control-reminder-prompt on kill-emacs-hook. +;; icicle-update-help-string: +;; Removed: icicle-completing(-mustmatch)-prompt-prefix, icicle-reminder-prompt-flag. +;; icicle-rebind-completion-maps: Remove code setting icicle-prompt-suffix (removed). +;; 2008/03/26 dadams +;; Added icicle-Info-menu to icicle-mode doc string and icicle-update-help-string. +;; icicle-define-icicle-maps: Added icicle-Info-menu to menus. +;; icicle-(rebind|restore)-non-completion-keys: Bind/restore icicle-Info-menu-cmd. +;; 2008/03/23 dadams +;; Added: icicle-handle-switch-frame. +;; icicle-(rebind|restore)-non-completion-keys: +;; Bind switch-frame to icicle-handle-switch-frame globally, and restore. +;; 2008/03/19 dadams +;; Remap (pp-)eval-expression to new icicle-pp-eval-expression. +;; Replace lambdas by icicle-pp-eval-expression-in-minibuffer. +;; Use icicle-pp-eval-expression-in-minibuffer (new) in help string. +;; icicle-rebind-completion-maps: Bind M-: to icicle-pp-eval-expression-in-minibuffer. +;; Bind icicle-insert-newline-in-minibuffer in all minibuffer maps (likewise, non-icy). +;; Bind C-g in minibuffer-local-must-match-map, even if inherit. +;; icicle-bind-completion-keys: Don't bind in must-match if it inherits: +;; C-a, C-e, C-=, M-k, M-o, M-., M-:, C-M-y, M-S-(backspace|delete) +;; 2008/03/09 dadams +;; icicle-mode: Add icicle-unhighlight-lighter to minibuffer-exit-hook. +;; 2008/03/07 dadams +;; icicle-abort-minibuffer-input: Thx to Damon Permezel. +;; Make it always call abort-recursive-edit. Renamed to icicle-abort-recursive-edit. +;; 2008/02/28 dadams +;; icicle-define-icicle-maps: Don't bind pop-tag-mark (M-*) in icicle-mode-map for Emacs 21. +;; 2008/02/26 dadams +;; Remapped where-is to icicle-where-is. +;; Added to Describe > Icicles menu: icicle-describe-option-of-type, icicle-where-is. +;; Bound icicle-select-frame to C-x 5 o in Icicle mode. +;; 2008/02/24 dadams +;; icicle-define-icicle-maps: Bound icicle-next-apropos-match-function to M-(. +;; Add icicle-next-apropos-match-function to icicle-update-help-string and mode doc string. +;; 2008/02/23 dadams +;; Renamed: icicle-search-tag to icicle-find-tag, +;; icicle-find-tag(-other-window) to icicle-find-first-tag(-other-window). +;; icicle-define-icicle-maps: Added icicle-tags-search to Tags menu and Search menu. +;; 2008/02/22 dadams +;; Renamed: icicle(-mouse)-save-candidate to icicle(-mouse)-save/unsave-candidate. +;; 2008/02/13 dadams +;; Remapped: find-tag (M-.) to icicle-search-tag, instead of icicle-find-tag +;; pop-tag-mark (M-*) to icicle-pop-tag-mark. +;; icicle-define-icicle-maps: +;; Added icicle-search-tag and icicle-pop-tag-mark to menus. +;; Removed icicle-find-tag from menu. Renamed icicle-find-tag-other-window menu item. +;; 2008/02/07 dadams +;; icicle-(redefine|restore)-std-completion-fns: Protect read-number with fboundp. +;; 2008/02/03 dadams +;; icicle-(redefine|restore)-std-completion-fns: Added (icicle|old)-choose-completion. +;; 2008/01/30 dadams +;; Bound icicle-yank-secondary and icicle-mouse-yank-secondary. +;; 2008/01/15 dadams +;; Require dired.el. Soft-require dired+.el. Thx to Fabrice Knevez. +;; 2008/01/13 dadams +;; icicle-(rebind|restore)-non-completion-keys: +;; Bound [handle-switch-frame] to icicle-skip-this-command globally. +;; Added: icicle-skip-this-command. +;; 2008/01/02 dadams +;; icicle-(rebind|restore)-non-completion-keys: Bound icicle-search-dired-marked to M-s. +;; icicle-define-icicle-maps: Added icicle-search-dired-marked to Dired>Multiple>Icicles. +;; 2008/01/01 dadams +;; icicle-*-non-completion-keys: Bound icicle-candidate-set-dired-marked-save(-more). +;; icicle-define-icicle-maps: Added Icicles submenu for Dired > Multiple (Operate) menu. +;; 2007/12/31 dadams +;; Bound icicle-insert-list-join-string to C-M-j. Update icicle-update-help-string. +;; 2007/12/24 dadams +;; icicle-rebind-completion-maps: Bound C-j to also refit the minibuffer frame. +;; 2007/12/20 dadams +;; Bound icicle-dired-saved-file-candidates-other-window in Dired to C-M-r. +;; Bound icicle-describe-option-of-type to C-h C-o, not C-h M-o. +;; 2007/12/18 dadams +;; icicle-define-icicle-maps: Bind icicle-describe-option-of-type to C-h M-o. +;; 2007/12/14 dadams +;; icicle-mode: Only add to kill-emacs-hook if icicle-customize-save-flag is non-nil. +;; 2007/12/13 dadams +;; icicle-update-help-string: spell out options, don't abbreviate using *. +;; 2007/12/08 dadams +;; Bound icicle-(beginning|end)-of-line+. +;; 2007/12/07 dadams +;; icicle-rebind-completion-maps: Removed obsolete stuff from doc string. +;; 2007/12/03 dadams +;; Renamed longest common match (lcm) to expanded common match (ecm). +;; 2007/11/29 dadams +;; icicle-minibuffer-setup: If icicle-add-proxy-candidates-flag is nil, swap candidate sets. +;; Reset icicle-saved-proxy-candidates to nil. +;; 2007/11/27 dadams +;; icicle-(redefine|restore)-std-completion-fns: Added read-number. +;; 2007/11/25 dadams +;; icicle-define-icicle-maps: Bound icicle-command-abbrev to C-x SPC. +;; icicle-mode: Use icicle-command-abbrev-save on kill-emacs-hook. +;; Changed binding of icicle-doremi-inter-candidates-min-spaces from C-x SPC to C-x |. +;; 2007/11/23 dadams +;; icicle-rebind-completion-maps: +;; Use icicle-prefix-cycle-(next|previous)-keys, instead of hardcoding. +;; icicle-(bind|restore)-completion-keys: +;; Use icicle-(apropos|prefix)-cycle-(next|previous)-keys, instead of hardcoding. +;; Restore explicit vanilla bindings last. +;; 2007/11/22 dadams +;; icicle-(bind|restore)-completion-keys: +;; Explicitly bind/restore (C-)up, (C-)down, (C-)next, (C-)(C-)prior, instead of +;; remapping next-line etc. +;; 2007/11/21 dadams +;; icicle-rebind-completion-maps: Explicitly bind C-j to icicle-self-insert. +;; icicle-(bind|restore)-completion-keys, icicle-update-help-string: +;; Removed C-o binding for icicle-candidate-action. +;; 2007/11/17 dadams +;; Added doc, menus, bindings (C-M-_): icicle-toggle--proxy-candidates. +;; 2007/11/05 dadams +;; icicle-define-icicle-maps: Moved [Icy] items to Icicles submenus. +;; Added: icicle-(bookmark|custom|describe|edit|file|frames|info|search(-tags))-menu-map. +;; 2007/11/03 dadams +;; icicle-define-icicle-maps, icicle-bind-S-TAB-in-keymaps-from, +;; icicle-unbind-S-TAB-in-keymaps-from, icicle-rebind-completion-maps, +;; icicle-bind-completion-keys: +;; Bind icicle-generic-S-tab-keys instead of hard-coded S-(iso-left)tab. +;; icicle-(bind|restore)-completion-keys: +;; Bind/restore icicle-prefix-complete-keys, +;; icicle-(apropos|prefix)-complete-keys-no-display, not hard-coded keys. +;; icicle-bind-isearch-keys: Bind icicle-isearch-complete-keys, not hard-coded. +;; Renamed icicle-modal-cycle-(up|down)-key to icicle-modal-cycle-(up|down)-keys, +;; icicle-word-completion-key to icicle-word-completion-keys. +;; 2007/10/31 dadams +;; icicle-define-icicle-maps: +;; Moved options to new Icicles submenu of Options menu, and removed [Icy]. Added :keys. +;; Added: icicle-options-menu-map. +;; 2007/10/28 dadams +;; Added doc, menus, bindings (C-|, C-M-|): +;; icicle-toggle-(expand-to-common-match|search-replace-common-match). +;; 2007/10/21 dadams +;; icicle-(bind|restore)-completion-keys: Bind C-x w and C-x SPC. +;; icicle-define-icicle-maps: Add Do Re Mi items. +;; icicle-mode, icicle-update-help-string: Mention C-x w and C-x SPC. +;; 2007/09/29 dadams +;; icicle-mode, icicle-define-icicle-maps, icicle-update-help-string: +;; Added icicle-toggle-fuzzy-completion (and icicle-fuzzy-completion-flag to help string). +;; icicle-(bind|restore)-completion-keys: Bind/unbind icicle-toggle-fuzzy-completion to C-(. +;; 2007/09/20 dadams +;; icicle-(bind|restore)-completion-keys: Bind C-j to icicle-self-insert / exit-minibuffer. +;; 2007/09/18 dadams +;; Added: icicle-update-help-string. Use in icy-mode, not in icicle-rebind-completion-maps. +;; Removed icicle-toggle-WYSIWYG-Completions (it has no minibuffer binding). +;; 2007/08/25 dadams +;; icy-mode, icicle-completion-help-string: +;; icicle-clear-option -> clear-option. Added toggle alias. +;; 2007/08/21 dadams +;; icicle-completion-help-string: Mention C-M-l. +;; 2007/08/19 dadams +;; icicle-minibuffer-setup: Reset icicle-input-fail-pos. +;; icicle-(bind|restore)-completion-keys: +;; (Re|un)map reposition-window to icicle-kill-failed-input. +;; 2007/08/03 dadams +;; icicle-mode: Remove icicle* hooks from local, not global, hooks. +;; 2007/07/22 dadams +;; icicle-(redefine|restore)-standard-commands: Added customize-face(-other-window). +;; Moved icicle-completing-p to icicles-fn.el. +;; Require icicles-cmd.el. +;; 2007/07/06 dadams +;; icicle-rebind-completion-maps: +;; Moved icicle-Completions-mouse-3-menu to C-mouse-3. +;; Added icicle(-mouse)-candidate-set-save(-more)-selected, icicle-candidate-set-retrieve, +;; icicle-retrieve-previous-input. +;; icicle-completion-help-string: Added icicle-candidate-set-save(-more)-selected. +;; icicle-bind-completion-maps: +;; Removed icicle-insert-history-element (inherited). +;; Added: icicle-candidate-set-save-more(-selected), icicle-mouse-save-then-kill. +;; 2007/07/04 dadams +;; icicle-rebind-completion-maps, icicle-(bind|restore)-completion-keys: +;; Added icicle-insert-history-element to Minibuf menu. +;; icicle-(bind|restore)-completion-keys: +;; Added icicle-retrieve-(next|previous)-input to Minibuf menu. +;; 2007/07/03 dadams +;; icicle-rebind-completion-maps, icicle-bind-completion-keys: +;; Bind icicle-insert-history-element to M-o in all minibuffer maps. +;; icicle-bind-completion-keys, icicle-completion-help-string: +;; icicle-retrieve-(next|previous)-input, not icicle-retrieve-last-input. +;; icicle-(redefine|restore)-std-completion-fns: +;; defalias next-history-element to icicle-next-history-element. +;; Removed defadvice for next-history-element. Redefine in icicles-mcmd.el instead. +;; 2007/06/22 dadams +;; Bound icicle-search-keywords and added to menus and help strings. +;; 2007/06/20 dadams +;; Removed M-o binding for icicle-toggle-WYSIWYG-Completions. +;; 2007/06/19 dadams +;; icicle-bind-completion-keys: Add icicle-save-predicate-to-variable to menus. +;; icicle-completion-help-string: +;; Mention icicle-save-predicate-to-variable and icicle-insert-string-from-variable. +;; 2007/06/18 dadams +;; icy-mode doc string, icicle-completion-help-string: Added icicle-customize-face. +;; icicle-define-icicle-maps: Added icicle-customize-face to menus. +;; 2007/06/17 dadams +;; Bound icicle-toggle-WYSIWYG-Completions to M-o. +;; icicle-minibuffer-setup: Reinitialize icicle-saved-candidate-overlays. +;; 2007/06/16 dadams +;; icicle-(bind|restore)-completion-keys: Bound C-M-(help|f1). +;; 2007/06/15 dadams +;; icicle-completion-help-string: Added and cleaned up set stuff. +;; icicle-(bind|restore)-completion-keys: Cleanup. Added menu items. +;; 2007/06/14 dadams +;; Swap bindings for C-insert and insert. +;; 2007/06/13 dadams +;; Bound C-insert and C-> to icicle-save-candidate and icicle-candidate-set-save-more. +;; 2007/06/12 dadams +;; icicle-rebind-completion-maps: Bound icicle-mouse-save-candidate to M-S-mouse-2. +;; 2007/06/10 dadams +;; icicle-mode: comint-mode-hook, compilation(-minor)-mode-hook, temp-buffer-show-hook. +;; 2007/06/08 dadams +;; icy-mode: Added icicle-find-tag* to doc string. +;; icicle-define-icicle-maps: +;; Added icicle-find-tag*. Remap find-tag* to icicle-find-tag*. +;; Corrected Info menu. +;; icicle-completion-help-string: Added icicle-find-tag*. +;; 2007/05/28 dadams +;; icicle-restore-non-completion-keys: Unbind S-tab. +;; Added: icicle-unbind-S-TAB-for-map-variable, icicle-unbind-S-TAB-in-keymaps-from. +;; icicle-bind-S-TAB-in-keymaps-from: Treat S-tab and S-iso-lefftab separately. +;; icicle-define-icicle-maps: Added icicle-imenu-* to Icicles/Search menus. +;; 2007/05/22 dadams +;; Make [Icy] menu items invisible when not in Icicle mode. Add :keys where appropriate. +;; icicle-define-icicle-maps, icicle-rebind-completion-maps, +;; icicle-(bind|restore)-completion-keys: +;; icicle-menu-item-any-version -> menu-item. Explicit put of enable property -> :enable. +;; Don't require icicles-mac.el. +;; icicle-bind-completion-keys: Added icicle-narrow-candidates, and corrected :enable forms. +;; 2007/05/21 dadams +;; icicle-define-icicle-maps: +;; Remap minibuffer-keyboard-quit to icicle-abort-minibuffer-input. Needed, even though +;; local-must-match inherits from local-completion in Emacs 22, because delsel.el binds +;; C-g to minibuffer-keyboard-quit in minibuffer maps. +;; menu-item-any-version -> icicle-menu-item-any-version. +;; Added Icicles/Search menu items: +;; Search (Buffer|File|Saved Region|All Saved Regions|Definition|Text Property). +;; Renamed: Search a Region -> Search Saved Region, Choose a Region -> Choose Saved Region, +;; Add Current Region to List -> Save Current Region. +;; 2007/05/20 dadams +;; Enable menu-bar Minibuf: +;; icicle-rebind-completion-maps: +;; Use menu-item-any-version. +;; Don't define menu for maps if it is defined by parent map. +;; Add Enter and Help items for *-local-map. +;; Add Enter, Help and Quit items for *-local-(ns|isearch)-map. +;; icicle-bind-completion-keys: +;; Use menu-item-any-version. +;; Add Enter item for *-local-completion-map, unless defined by parent map. +;; icicle-restore-completion-keys: +;; Use menu-item-any-version. +;; Add Enter and Quit items for *-local-completion-map, unless defined by parent map. +;; Do not unmap kill-region(-wimpy). +;; Bind [(control pause)] to nil. +;; 2007/05/13 dadams +;; icicle-restore-completion-keys: Restore some forgotten minibuf menu items. +;; 2007/05/08 dadams +;; Bound icicle-save-predicate-to-variable to C-M-&. +;; 2007/05/06 dadams +;; icicle-rebind-completion-maps: Updated icicle-completion-help-string. +;; Added defvars to quiet byte compiler. +;; Changed S-C- to C-S- and M-C- to C-M- in doc. +;; 2007/05/03 dadams +;; Remap icicle-yank-function, not yank. +;; icicle-define-icicle-maps: Bind icicle-search-word. +;; icicle-mode, icicle-completion-help-string: Add icicle-search-word to doc. +;; 2007/05/02 dadams +;; Bound M-q to icicle-dispatch-M-q, not to icicle-insert-key-description. +;; Bound C-` to icicle-toggle-regexp-quote, not to icicle-dispatch-C-backquote. +;; Bound C-M-` to icicle-toggle-literal-replacement. +;; Update icicle-completion-help-string. +;; 2007/04/20 dadams +;; icicle-minibuffer-setup: Don't reset icicle-search-context-level here. +;; 2007/04/17 dadams +;; Bound M-, to icicle-dispatch-M-comma, not to icicle-change-alternative-sort-order. +;; Bound C-` to icicle-dispatch-C-backquote, not to icicle-toggle-regexp-quote. +;; 2007/04/10 dadams +;; icicle-minibuffer-setup: Initialize icicle-search-context-level. +;; 2007/04/09 dadams +;; Bound icicle-imenu to C-c =. +;; 2007/04/08 dadams +;; Bound icicle-all-candidates-alt-action to C-S-insert. +;; 2007/04/07 dadams +;; icicle-completion-help-string: Updated. +;; Bound icicle-dispatch-C-comma to C-,. +;; Bound in menu: icicle-toggle-search-replace-whole. +;; Bound icicle-(next|previous)-(apropos|prefix)-candidate-alt-action (forgot). +;; 2007/04/02 dadams +;; Bound icicle-search-text-property to C-c ". Added it to icicle-completion-help-string. +;; 2007/03/23 dadams +;; Bound icicle-apropos-complete-and-narrow to S-SPC. Mention in *-completion-help-string. +;; 2007/03/14 dadams +;; Added: icicle-top-level-prep. +;; Removed: icicle-reset-candidates-alist. +;; Do top-level stuff in icicle-minibuffer-setup, not in icicle-mode. +;; icicle-minibuffer-setup: Add icicle-top-level-prep to pre-command-hook. +;; icicle-mode: Remove icicle-top-level-prep from pre-command-hook. +;; 2007/03/07 dadams +;; icicle-cancel-Help-redirection: Use 0, not t, as frame arg to get-buffer-window. +;; 2007/03/02 dadams +;; icicle-bind-S-TAB-in-keymaps-from: Bound S-iso-lefttab also. +;; 2007/03/02 dadams +;; icicle-define-icicle-maps: +;; Bound S-iso-lefttab also to icicle-generic-S-tab. Thx to Shreevatsa R. +;; 2007/02/28 dadams +;; Added: icicle-reset-candidates-alist. +;; icicle-mode: Use icicle-reset-candidates-alist. +;; 2007/02/27 dadams +;; icicle-minibuffer-setup: Wait icicle-incremental-completion-delay before initial display. +;; 2007/02/24 dadams +;; Bound: delete, S-mouse-2 to icicle(-mouse)-remove-candidate, +;; C-S-RET, C-S-mouse-2 to icicle(-mouse)-candidate-alt-action, +;; S-delete to icicle-delete-candidate-object. +;; Don't remap icicle-kill-region(-wimpy) to delete key. +;; 2007/02/17 dadams +;; Added: icicle-bind-S-TAB-in-keymaps-from, icicle-bind-S-TAB-for-map-variable. +;; icicle-rebind-non-completion-keys: +;; Bind S-TAB to keymaps in icicle-keymaps-for-key-completion. +;; 2007/02/02 dadams +;; icicle-completing-p: Cache the value in variable icicle-completing-p. +;; icicle-minibuffer-setup: Reset icicle-completing-p to nil. +;; icicle-activate-mark: Use var, not function, icicle-completing-p, but after minibuf test. +;; 2007/01/23 dadams +;; icicle-(redefine|restore)-std-completion-fns: +;; Added icicle-read-face-name, icicle-face-valid-attribute-values. +;; icicle-define-icicle-maps, icicle-rebind-completion-maps: +;; Updated wrt toggles. Added icicle*-highlight-historical-candidates*. +;; icicle-bind-completion-keys: Added icicle-toggle-highlight-historical-candidates. +;; 2007/01/22 dadams +;; Renamed icicle-regions to icicle-region-alist (forgot occurrences here). +;; 2007/01/20 dadams +;; icicle-(redefine|restore)-std-completion-fns: Added icicle-display-completion-list. +;; 2007/01/15 dadams +;; Moved C-, binding from icicle-toggle-sorting to icicle-change-sort-order. +;; Moved icicle-toggle-alternative-sorting from M-, to C-M-,. +;; Bound icicle-change-alternative-sort-order to M-,. +;; Updated list of options in icicle-completion-help-string. +;; 2007/01/12 dadams +;; Removed: icicle-override-maps-w-minibuffer-map, icicle-restore-overriding-local-map. +;; Not used in minibuffer hooks. +;; Removed [pause] bindings from minibuffer maps. +;; Removed remap of yank in minibuffer maps. +;; No longer bind icicle-remove-Completions-window in minibuffer maps. +;; 2007/01/11 dadams +;; Renamed: icicle-define-icicle-mode-map to icicle-define-icicle-maps. +;; icicle-define-icicle-maps: Use icicle-menu-map. Don't recreate it. +;; Bound [pause] to icicle-switch-to/from-minibuffer in all minibuffer maps. +;; 2007/01/10 dadams +;; Added: icicle-override-maps-w-minibuffer-map, icicle-restore-overriding-local-map, +;; icicle-(rebind|restore)-non-completion-keys. +;; Added: icicle-rebind-global: This used to be called icicle-remap. +;; icicle-(remap|unmap): Different purpose and use now. Redefined to use remapping when +;; available (as was done before for self-insert-command). +;; icicle-mode: +;; Add, remove as minibuffer setup and exit hooks: icicle-override-maps-w-minibuffer-map, +;; icicle-restore-overriding-local-map. +;; Call icicle-(rebind|restore)-non-completion-keys. +;; icicle-define-icicle-mode-map: +;; Use icicle-remap where previously used substitute-key-definition for top-level cmds. +;; Moved to icicle-(rebind|restore)-non-completion-keys: +;; binding of Info commands in Info map and S-tab in all keymaps (to *-rebind-* only). +;; icicle-(bind|restore)-completion-keys: Use new icicle-(remap|unmap) where possible. +;; Use icicle-rebind-global and substitute-key-definition for keys defined in vanilla +;; completion maps. +;; 2007/01/06 dadams +;; icicle-mode: Update doc and bind icicle-toggle-~-for-home-dir to M-~. +;; 2007/01/01 dadams +;; Moved assq-delete-all to icicles-fn.el. +;; Require at runtime, not compile-time: icicles-var.el, icicles-fn.el. +;; 2006-12-31 dadams +;; icicle-define-icicle-mode-map: Delete icicle-mode entry from minor-mode-map-alist. +;; icicle-mode: Unbind icicle-mode-map when the mode is turned off. +;; Added assq-delete-all for Emacs 20. +;; Use current-global-map function, not global-map variable. +;; 2006/12/25 dadams +;; Bound icicle-candidate-set-truncate to M-$. +;; 2006/12/24 dadams +;; icicle-bind-completion-keys: transpose-yank(-pop) -> yank(-pop): typo. +;; Bound mouse-3 to icicle-Completions-mouse-3-menu in completion-list-mode-map. +;; 2006/12/22 dadams +;; Bound icicle-exchange-point-and-mark. +;; :group 'icicles -> :group 'Icicles-Miscellaneous. +;; 2006/12/17 dadams +;; Bound icicle(-mouse)-candidate-read-fn-invoke. +;; 2006/12/16 dadams +;; icicle-define-icicle-mode-map: Protect icicle-kmacro with fboundp. +;; 2006/12/12 dadams +;; Added icicle-customize-*-group, icicle-kill-buffer, icicle-delete-windows to I. menu. +;; Added + to multi-command menu items. +;; 2006/12/11 dadams +;; Added icicle-customize-apropos* and icicle-Info-* to menu-bar menus. +;; 2006/12/10 dadams +;; Updated user options list in icicle-completion-help-string. +;; Updated list of icicle-opt stuff used here. +;; 2006/12/06 +;; icicle-select-minibuffer-contents: +;; Use icicle-minibuffer-prompt-end, not point-min. Thx to Erik Postma. +;; 2006/11/26 dadams +;; Added icicle-regions stuff. +;; 2006/11/24 dadams +;; icicle-redefine-standard-options: Treat icicle-kmacro-ring-max. +;; Bind icicle-kmacro to f5 +;; Replaced icicle-select-window-or-frame by icicle-other-window-or-frame. +;; Removed binding of icicle-select-frame. +;; Do not require mb-depth+.el for Emacs 21 (do it only for Emacs 22). +;; 2006/11/23 dadams +;; Bound icicle-execute-named-keyboard-macro to C-x M-e. +;; 2006/11/18 dadams +;; Soft require mb-depth+.el instead of minibuf-depth.el. +;; 2006/11/17 dadams +;; Bind icicle-select-window-or-frame to whatever other-window(-or-frame) is bound to. +;; Bind icicle-select-frame to whatever other-frame is bound to. +;; 2006/11/09 dadams +;; Bind icicle-dispatch-C-^, not icicle-toggle-ignored-space-prefix, to C-^. +;; icicle-rebind-completion-maps: Updated doc string for icicle-dispatch-C-^. +;; 2006/11/05 dadams +;; Bound icicle-occur to C-c '. Added it to menu-bar menus. +;; 2006/10/18 dadams +;; icy-mode: Invoke icicle-define-icicle-mode-map unconditionally, not just first time. +;; 2006/10/16 dadams +;; icicle-define-icicle-mode-map: Try to avoid binding S-TAB to menu maps. +;; 2006/10/15 dadams +;; icicle-define-icicle-mode-map: Simplified, corrected binding of S-TAB for key completion. +;; Use a separate map for the menu bar. +;; Moved here from icicles-fn.el: +;; icicle-bind-isearch-keys, icicle-rebind-completion-maps, +;; icicle-(redefine|restore)-standard-(commands|options), +;; icicle-(redefine|restore)-std-completion-fns, icicle-(re|un)map, +;; icicle-(bind|restore)-completion-keys, icicle-minibuffer-setup, +;; icicle-cancel-*Help*-redirection, icicle-activate-mark, +;; icicle-run-icicle-(pre|post)-command-hook, icicle-set-calling-cmd, +;; icicle-undo-std-completion-faces icicle-update-ignored-extensions-regexp, +;; icicle-completing-p, icicle-restore-region-face. +;; Renamed: icicle-cancel-*Help*-redirection to icicle-cancel-Help-redirection. +;; Moved here from icicles-cmd.el: icicle-select-minibuffer-contents, next-history-element. +;; Moved to icicles-cmd.el: icicle-generic-S-tab. +;; Require icicles-opt.el. +;; Added eval-when-compile's and defvars to quite byte compiler. +;; 2006/09/23 dadams +;; icicle-define-icicle-mode-map: Corrected binding of icicle-yank-insert. +;; 2006/09/22 dadams +;; icicle-minibuffer-setup: Set this-command and last-command, for scrolling *Completions*. +;; 2006/09/18 dadams +;; icicle-mode: Picked up all global prefixes for S-TAB. +;; 2006/09/17 dadams +;; Added: icicle-generic-S-tab. Bound to S-TAB. +;; icicle-mode: +;; Bound icicle-complete-keys to prefix keys followed by S-TAB. +;; Added run-hooks for Emacs 22 version. +;; 2006/09/12 dadams +;; Bound icicle-switch-to/from-minibuffer to [pause]. +;; 2006/08/27 dadams +;; Bound icicle-abort-minibuffer-input to what abort-recursive-edit is normally bound to. +;; And add it to Icicle menu. +;; 2006/08/23 dadams +;; Bound icicle-delete-window to what delete-window and delete-windows-for are normally +;; bound to. +;; Put use of Info-mode-map inside an eval-after-load. +;; 2006/08/18 dadams +;; Added icicle-Info-goto-node-cmd to icicle-mode doc string. +;; Substitute it for Info-goto-node binding. +;; 2006/08/13 dadams +;; Added icicle-Info-index-cmd to icicle-mode doc string. +;; Substitute it for Info-index binding. +;; 2006/08/04 dadams +;; Added icicle-plist to menus. +;; icicle-doc treats faces too now. +;; 2006/08/03 dadams +;; Bound icicle-insert-yank to what yank is normally bound to. +;; icicle-mode: Updated doc string. +;; 2006/07/29 dadams +;; icy-mode, icicle-define-icicle-mode-map: Added missing toggle commands. +;; 2006/07/22 dadams +;; Changed binding of C-c C-s for icicle-search to C-c ` for icicle-search-generic. +;; Removed: add-hooks for icicle-compilation-search - see icicles-cmd.el. +;; 2006/06/08 dadams +;; Converted global bindings in icicles-keys.el to icicle-mode-map bindings here. +;; Added f10 binding for icicle-execute-menu-command. +;; 2006/05/19 dadams +;; icicle-mode: (add-hook 'kill-emacs-hook 'icicle-control-reminder-prompt). +;; 2006/05/18 dadams +;; Change :init-value to nil, per new Emacs convention. +;; 2006/05/13 dadams +;; icicle-mode: Updated doc string. +;; 2006/05/10 dadams +;; icicle-define-icicle-mode-map: Added menu item Send Bug Report. +;; 2006/04/03 dadams +;; icicle-define-icicle-mode-map: Added icicle-toggle-(regexp-quote|incremental-completion). +;; 2006/03/16 dadams +;; icicle-mode: Turn on minibuffer-indicate-depth-mode (Emacs 22 only). +;; Added soft require of minibuf-depth.el for Emacs 22. +;; 2006/03/14 dadams +;; Do not use icicle-reset-icicle-completing-p as minibuffer-exit-hook. +;; 2006/03/07 dadams +;; Corrected menu items for icicle-doc (no name regexp input, just doc regexp). +;; 2006/03/05 dadams +;; Moved here from icicle-opt.el: icicle-mode, icicle-mode-hook. +;; Moved here from icicle-fn.el: icicle-mode-map. +;; Added: icicle-define-icicle-mode-map. + +;;;(@* "CHANGE LOG FOR `icicles-opt.el'") +;; +;; 2010/07/17 dadams +;; icicle-top-level-key-bindings: Added *url-jump(-other-window). +;; 2010/06/18 dadams +;; Renamed: bookmarkp-* to bmkp-*. +;; 2010/06/09 dadams +;; icicle-isearch-complete-keys: +;; Added [escape tab] to default binding (isearch bizarrie). Added C-M-TAB for all platforms. +;; 2010/06/08 dadams +;; icicle-bookmark-refresh-cache-flag: Changed the default value to t to avoid confusion. +;; 2010/06/05 dadams +;; Set icicle-top-level-when-sole-completion-delay to 0.7 from 0.0. +;; 2010/06/04 dadams +;; Added: icicle-(buffers|files)-ido-like-flag, icicle-max-candidates. +;; icicle-ignored-directories: Protect default value with boundp. +;; icicle-type-actions-alist: Added (maximize|restore|toggle-max)-frame(-horizontally|-vertically). +;; 2010/05/30 dadams +;; Added: icicle-ignored-directories. +;; 2010/05/15 dadams +;; icicle-top-level-key-bindings: Updated Icicles versions of bookmark jump commands. +;; icicle-keymaps-for-key-completion: Added bookmarkp-jump-map bookmarkp-jump-other-window-map. +;; 2010/04/30 dadams +;; Added: icicle-no-match-hook. +;; 2010/04/09 dadams +;; Remap find-file-read-only(-other-window) to icicle-find-file-read-only(-other-window). +;; 2010/04/02 dadams +;; Removed: icicle-region-alist, icicle-region-auto-open-files-flag, +;; icicle-region-bookmarks-flag, icicle-regions-name-length-max. +;; icicle-top-level-key-bindings: Removed bookmarkp-bookmark-list-jump-other-window. +;; bookmarkp*: Use condition (featurep 'bookmark+). +;; 2010/03/31 dadams +;; Removed extra code redefining some bookmark commands. +;; 2010/03/28 dadams +;; Removed: icicle-region-alist, icicle-region-auto-open-files-flag, +;; icicle-region-bookmarks-flag, icicle-regions-name-length-max. +;; 2010/03/14 dadams +;; Added: icicle-bookmark-refresh-cache-flag. +;; 2010/03/13 sadams +;; Renamed icicle-add-buffer-name-flag to icicle-show-multi-completion-flag. Doc string. +;; 2010/03/09 dadams +;; icicle-color-themes: Initialize to (). Do real init in cmd icicle-color-theme. +;; 2010/03/03 dadams +;; Renamed: icicle-sort-function to icicle-sort-comparer, +;; icicle-sort-functions-alist to icicle-sort-orders-alist +;; icicle-alternative-sort-function to icicle-alternative-sort-comparer. +;; Redefined to allow multi-sorting: icicle-sort-comparer, icicle-sort-orders-alist. +;; 2010/02/17 dadams +;; Moved icicle-redefined-functions here from icicles-var.el +;; and renamed to icicle-inhibit-advice-functions. +;; Moved to icicles-face.el: icicle-increment-color-(hue|saturation). +;; So now require icicles-face.el. +;; Corrected alphabetical order. +;; 2010/02/13 dadams +;; icicle-top-level-key-bindings: Bound icicle-bookmark-*-jump-other-window. +;; 2010/01/24 dadams +;; icicle-thing-at-point-functions: +;; Use region-or-word-nearest-point, not word-nearest-point. Change order. +;; 2010/01/17 dadams +;; icicle-top-level-key-bindings: Added Icicles remappings for bookmarkp-*-jump-other-*. +;; 2009/12/25 dadams +;; icicle-top-level-key-bindings: Bind ESC-M-x to lacarte-execute-command. +;; 2009/12/13 dadams +;; icicle-top-level-key-bindings: Map dired(-other-window) to icicle-dired(-other-window). +;; 2009/12/07 dadams +;; icicle-guess-commands-in-path: Changed default value to nil. +;; 2009/11/27 dadams +;; Added: icicle-swank-prefix-length, icicle-swank-timeout. +;; icicle-TAB-completion-methods: Treat swank method also. +;; 2009/11/24 dadams +;; Added: icicle-completions-format. +;; icicle-color-themes: Fix: delete singleton list with string, not symbol bury-buffer. +;; 2009/11/22 dadams +;; icicle-color-themes: Use color-theme-initialize instead of load-library, to load themes. +;; 2009/11/21 dadams +;; icicle-color-themes: (load-library "color-theme-library"), for color theme version 6.6.0. +;; 2009/10/25 dadams +;; Added: icicle-TAB-completion-methods. +;; Removed: icicle-fuzzy-completion-flag, icicle-prefix-completion-is-basic-flag. +;; Renamed: icicle-apropos-match-fns-alist to icicle-S-TAB-completion-methods-alist. +;; 2009/10/12 dadams +;; icicle-top-level-key-bindings: Added bindings for icicle-bookmark(-other-window). +;; icicle-prefix-completion-is-basic-flag: Make it a constant for pre-Emacs 23. +;; 2009/10/06 dadams +;; icicle-keymaps-for-key-completion: Added bookmark-bmenu-mode-map to default value. +;; icicle-sort-functions-alist: Use a separate defcustom for Emacs 20, since no :type alist. +;; 2009/09/25 dadams +;; Added: icicle-prefix-completion-is-basic-flag. +;; Changed default value of: +;; icicle-candidate-width-factor from 70 to 80 +;; icicle-Completions-text-scale-decrease from 0.8 to 0.66. +;; 2009/09/16 dadams +;; icicle-top-level-key-bindings: Added remap for icicle-insert-buffer. +;; 2009/09/05 dadams +;; icicle-keymaps-for-key-completion: Added facemenu-keymap. +;; icicle-search-replace-common-match-flag: Fixed doc string: C-M-| -> M-;. +;; icicle-expand-input-to-common-match-flag: Fixed doc string: C-| -> C-;. +;; 2009/09/02 dadams +;; Added: icicle-region-bookmarks-flag, icicle-top-level-when-sole-completion-delay. +;; icicle-region-alist: Updated doc string. Added :group Icicles-Searching. +;; 2009/08/19 dadams +;; icicle-bookmark-name-length-max: +;; Changed default value from 40 to 70. It is now the total name length. Updated doc. +;; 2009/08/01 dadams +;; Added: icicle-menu-items-to-history-flag. +;; 2009/07/29 dadams +;; Added: icicle-populate-interactive-history-flag. +;; 2009/06/17 dadams +;; Added: icicle-Completions-text-scale-decrease. +;; 2009/05/20 dadams +;; icicle-keymaps-for-key-completion: Added prefix-key maps senator-mode-map, +;; srecode-mode-map, jde-mode-map, jde-jdb-mode-map. Thx to Daniel Clemente. +;; 2009/05/17 dadams +;; icicle-type-actions-alist: Updated to reflect thumb-frm.el name changes. +;; 2009/05/10 dadams +;; icicle-list-join-string: Don't set display property for Emacs 21 (Emacs bug). +;; 2009/05/09 dadams +;; Added: icicle-dot-string, icicle-dot-show-regexp-flag, icicle-anychar-regexp, +;; 2009/05/07 dadams +;; icicle-list-join-string: Use copy-sequence in default value, so users see original sexp. +;; 2009/05/02 dadams +;; Added: icicle-alternative-actions-alist. +;; 2009/05/01 dadams +;; Added function to icicle-type-actions-alist: icicle-shell-command-on-file. +;; 2009/04/26 dadams +;; Added: icicle-type-actions-alist, icicle-use-anything-candidates-flag. +;; 2009/04/20 dadams +;; Added: icicle-(prefix|apropos)-cycle-(next|previous)-alt-action-keys, +;; icicle-modal-cycle-(down|up)-alt-action-keys. +;; 2009/04/18 dadams +;; Soft-require hexrgb.el unconditionally, not just when there is a window-system. +;; icicle-region-background: If frame background is unspecified, consider it white. +;; Don't use frame background unless it is a valid color name. +;; Use region background if cannot compute saturation. +;; 2009/04/16 dadams +;; Added: icicle-(prefix|apropos)-cycle-(next|previous)-help-keys. +;; 2009/04/15 dadams +;; Added: icicle-modal-cycle-(up|down)-help-keys. +;; 2009/04/05 dadams +;; Added: icicle-help-in-mode-line-flag. +;; 2009/03/10 dadams +;; Moved here from icicles-fn.el: icicle-shell-command-candidates. +;; Moved here from icicles-var.el: icicle-shell-command-candidates. +;; Renamed: icicle-shell-command-candidates (fn) to icicle-compute-shell-command-candidates, +;; icicle-shell-command-candidates (var) to icicle-shell-command-candidates-cache, +;; icicle-guess-cmds-in-path-flag to icicle-guess-commands-in-path. +;; icicle-guess-commands-in-path: Boolean -> choice. Default is now first-use. +;; icicle-compute-shell-command-candidates: Don't update cache variable here. +;; icicle-shell-command-candidates-cache: Initialize per icicle-guess-commands-in-path. +;; 2009/03/08 dadams +;; Added: icicle-quote-shell-file-name-flag. +;; 2009/03/01 dadams +;; Added: icicle-completing-read+insert-keys, icicle-read+insert-file-name-keys. +;; Removed: icicle-complete-on-demand-keys. +;; 2009/02/20 dadams +;; Added: icicle-complete-on-demand-keys (not yet used). +;; Renamed: icicle-dired-guess-all-shell-cmds-flag to icicle-guess-cmds-in-path-flag. +;; 2009/01/25 dadams +;; Added: icicle-dired-guess-all-shell-cmds-flag. +;; 2009/01/17 dadams +;; Added: icicle-levenshtein-distance. +;; icicle-apropos-match-fns-alist: Added icicle-levenshtein(-strict)-match. +;; 2009/01/05 dadams +;; Added ess-complete-* to icicle-comint-dynamic-complete-replacements. +;; 2009/01/01 dadams +;; Added: icicle-comint-dynamic-complete-replacements. +;; 2008/12/30 dadams +;; Moved icicle-remap here from icicles-mode.el. +;; 2008/12/06 dadams +;; icicle-incremental-completion-flag: Changed :type to choice from boolean. +;; 2008/12/02 dadams +;; Removed: icicle-file-ignore-space-prefix-flag. +;; 2008/11/28 dadams +;; Moved here from icicles-var.el: icicle-apropos-match-fns-alist. +;; 2008/11/14 dadams +;; Added: icicle-hide-common-match-in-Completions-flag. +;; 2008/11/04 dadams +;; Removed: icicle-generic-S-tab-keys. +;; Added (split icicle-generic-S-tab-keys in 4): +;; icicle-apropos-complete-keys, icicle-key-complete-keys, icicle-previous-candidate-keys, +;; icicle-search-from-isearch-keys. +;; Added: icicle-complete-key-anyway-flag. +;; 2008/11/03 dadams +;; Applied renamings from icicles-cmd.el. +;; 2008/10/26 dadams +;; Added: icicle-file-*. +;; 2008/10/18 dadams +;; Added: icicle-customize-save-variable-function. +;; 2008/10/17 dadams +;; Added: icicle-bookmark-name-length-max. +;; icicle-top-level-key-bindings: Remapped bookmark-set to icicle-bookmark-cmd. +;; 2008/10/11 dadams +;; icicle-highlight-input-completion-failure: Updated doc string. +;; 2008/10/10 dadams +;; Added: icicle-(apropos|prefix)-cycle-(next|previous)-action-keys, +;; icicle-modal-cycle-(down|up)-action-keys. +;; icicle-cycling-respects-completion-mode-flag: +;; Renamed to icicle-cycling-respects-completion-mode. +;; It's now a choice of nil, t, apropos, prefix. Thx to Andrey Zhdanov. +;; 2008/09/30 dadams +;; icicle-highlight-input-completion-failure: Changed default value to implicit-strict. +;; 2008/09/13 dadams +;; Added: icicle-filesets-as-saved-completion-sets-flag. +;; 2008/08/28 dadams +;; icicle-top-level-key-bindings: +;; Renamed alacarte-execute-menu-command to lacarte-execute-menu-command. +;; 2008/08/22 dadams +;; Removed: icicle-Completions-window-default-width (obsolete). +;; 2008/08/21 dadams +;; icicle-top-level-key-bindings: +;; Replace icicle-find-file(-other-window) with icicle-file(-other-window). +;; icicle-generic-S-tab-keys: Mention bug workaround in doc string. Thx to Kevin Rodgers. +;; 2008/08/20 dadams +;; Added: icicle-inhibit-ding-flag. +;; 2008/08/12 dadams +;; icicle-top-level-key-bindings: +;; Remap set-mark-command (C-SPC) and pop-global-mark (C-x C-SPC). +;; 2008/08/11 dadams +;; icicle-key-definition, icicle-top-level-key-bindings: +;; Change :match-alternatives to (symbolp) from (commandp). +;; icicle-top-level-key-bindings: Added condition for minibuffer-keyboard-quit. +;; 2008/08/06 dadams +;; Bind icicle-kmacro to S-f4, not f5. Thx to Andrew Hyatt. +;; 2008/06/22 dadams +;; Added: icicle-unpropertize-completion-result-flag. +;; 2008/06/03 dadams +;; Added: icicle-use-C-for-actions-flag. +;; 2008/05/27 dadams +;; icicle-isearch-complete-keys: Removed S-TAB, added M-o. +;; 2008/05/25 dadams +;; icicle-isearch-complete-keys: Added M-TAB and C-M-TAB (if Windows). +;; Change [] notation to `' notation for keys in doc strings. +;; 2008/05/24 dadams +;; icicle-isearch-complete-keys: Use explicit ([S-tab] [S-iso-lefttab]) for Emacs < 22. +;; 2008/05/19 dadams +;; icicle-generic-S-tab-keys: Use explicit ([S-tab] [S-iso-lefttab]) for Emacs < 22. +;; 2008/05/11 dadams +;; icicle-top-level-key-bindings: Added :set and :initialize. +;; Moved icicle-bind-top-level-commands here from icicles-mode.el, and added optional arg. +;; 2008/05/10 dadams +;; Added widget icicle-key-definition (new custom type). +;; Renamed: icicle-bind-top-level-commands-alist to icicle-top-level-key-bindings. +;; icicle-top-level-key-bindings: +;; Redefined: New :type, using icicle-key-definition or choice of restricted-sexp. +;; Changed order of entry elements. Use kbd. No eval for command to be remapped. +;; Don't bind f5 unless have kmacro. +;; Moved icicle-yank-function before icicle-top-level-key-bindings (needed by it). +;; 2008/05/07 dadams +;; icicle-region-alist, icicle-sort-functions-alist: +;; Removed Emacs 20 version (alist works for Emacs 20 also). +;; Replaced icicle-bind-top-level-commands-flag with icicle-bind-top-level-commands-alist. +;; icicle-isearch-complete-keys: +;; Changed default value from ([S-tab] [S-iso-lefttab]) to ([backtab]). +;; 2008/05/05 dadams +;; icicle-generic-S-tab-keys: +;; Changed default value from ([S-tab] [S-iso-lefttab]) to ([backtab]). +;; 2008/04/26 dadams +;; Added: icicle-test-for-remote-files-flag. Updated C-^ to M-_ +;; icicle-ignore-space-prefix-flag: Update doc string: M-_, not C-^. +;; 2008/04/18 dadams +;; Renamed icicle-init-value-flag to icicle-default-value. +;; icicle-default-value: Updated to reflect t value. +;; 2008/04/13 dadams +;; Added: icicle-pp-eval-expression-print-(length|level). +;; 2008/03/30 dadams +;; Added: icicle-highlight-lighter-flag. +;; 2008/03/29 dadams +;; Removed: icicle-completing(-mustmatch)-prompt-prefix, icicle-reminder-prompt-flag. +;; Updated doc string of icicle-customize-save-flag. +;; 2008/03/21 dadams +;; icicle-reminder-prompt-flag: Changed default value to nil. +;; 2008/02/23 dadams +;; icicle-init-value-flag: Added insert-start value. Renamed insert value to insert-end. +;; 2008/02/06 dadams +;; Added: icicle-highlight-input-completion-failure-(delay|threshold). +;; 2008/01/29 dadams +;; Removed: icicle-max-chars-noncompletion-highlight. +;; Renamed: icicle-*-input-completion-failure-flag to icicle-*-input-completion-failure. +;; icicle-*-input-completion-failure: Added values (implicit*, always) and renamed others. +;; 2007/12/31 dadams +;; icicle-list-join-string: Add display property to hide the ^G. +;; 2007/12/26 dadams +;; icicle-region-background: +;; Put initialization back inside defcustom. +;; Change test for color from Emacs version to widget test. +;; 2007/12/24 dadams +;; Added: icicle-option-type-prefix-arg-list. +;; 2007/12/14 dadams +;; Added: icicle-customize-save-flag. +;; 2007/12/09 dadams +;; Added: icicle-max-chars-noncompletion-highlight. +;; 2007/12/03 dadams +;; Renamed longest common match (lcm) to expanded common match (ecm). +;; 2007/11/25 dadams +;; Added: icicle-command-abbrev-(alist|match-all-parts-flag|priority-flag). +;; 2007/11/23 dadams +;; Added: icicle-(apropos|prefix)-cycle-(next|previous)-keys. +;; 2007/11/17 dadams +;; Added: icicle-add-proxy-candidates-flag. +;; 2007/11/02 dadams +;; Added: icicle-generic-S-tab-keys, icicle-prefix-complete-keys, +;; icicle-(apropos|prefix)-complete-no-display-keys, icicle-isearch-complete-keys. +;; Renamed icicle-modal-cycle-(up|down)-key to icicle-modal-cycle-(up|down)-keys, +;; icicle-word-completion-key to icicle-word-completion-keys. +;; 2007/10/29 dadams +;; icicle-define-alias-commands-flag, icicle-deletion-action-flag, +;; icicle-list-nth-parts-join-string: Added type and group. +;; 2007/10/28 dadams +;; Added: icicle-search-replace-common-match-flag. +;; 2007/10/23 dadams +;; icicle-highlight-input-initial-whitespace-flag: +;; Mention icicle-highlight-input-completion-failure-flag in doc string. +;; 2007/10/21 dadams +;; icicle-candidate-width-factor, icicle-inter-candidates-min-spaces: Mention Do Re Mi. +;; 2007/10/14 dadams +;; icicle-act-before-cycle-flag: Default value is now nil. +;; 2007/10/07 dadams +;; Added: icicle-deletion-action-flag. +;; 2007/09/28 dadams +;; Added: icicle-fuzzy-completion-flag. +;; 2007/08/25 dadams +;; Added: icicle-anything-transform-candidates-flag, icicle-define-alias-commands-flag. +;; 2007/08/19 dadams +;; Added: icicle-highlight-input-completion-failure-flag. +;; 2007/08/16 dadams +;; icicle-region-alist, icicle-sort-functions-alist: Use alist as :type for recent Emacs. +;; 2007/07/27 dadams +;; Added: Moved icicle-act-first-then-navigate-p here from icicles-var.el, as option *-flag. +;; Thx to Juri Linkov for suggestion. +;; 2007/07/03 dadams +;; Added: icicle-completion-history-max-length, icicle-C-l-uses-completion-flag. +;; icicle-expand-input-to-common-match-flag: Updated doc string accordingly. +;; 2007/06/20 dadams +;; icicle-WYSIWYG-Completions-flag: Use string value, not whole number, for sample text. +;; 2007/06/19 dadams +;; icicle-WYSIWYG-Completions-flag: Allow also a whole-number value, for separate swatch. +;; 2007/06/17 dadams +;; Added: icicle-WYSIWYG-Completions-flag. +;; 2007/06/12 dadams +;; icicle-region-background: Use different value for dark-background frames. +;; 2007/06/09 dadams +;; Added: icicle-use-candidates-only-once-flag. +;; 2007/06/05 dadams +;; Don't require hexrgb.el if no window system. +;; icicle-increment-color-*: Protected with featurep hexrgb and error message. +;; 2007/05/06 dadams +;; Added: icicle-search-context-match-predicate. +;; 2007/05/02 dadams +;; Added: icicle-search-whole-word-flag, icicle-yank-function. +;; icicle-regexp-quote-flag: Updated doc string to mention search. +;; 2007/04/20 dadams +;; Added: icicle-search-highlight-context-levels-flag, icicle-increment-color-saturation. +;; 2007/04/17 dadams +;; Added: icicle-search-replace-literally-flag. +;; 2007/04/15 dadams +;; icicle-search-replace-whole-candidate-flag: Changed default value to t. +;; 2007/04/07 dadams +;; Added: icicle-search-replace-whole-candidate-flag. +;; 2007/03/31 dadams +;; Added: icicle-top-level-when-sole-completion-flag. +;; icicle(-regexp)-search-ring-max: Default is 1/10th what it was. +;; 2007/03/30 dadams +;; Added: icicle-candidate-width-factor, icicle-inter-candidates-min-spaces. +;; 2007/03/12 dadams +;; Added: icicle-Completions-window-max-height. +;; icicle-show-Completions-help-flag: defvaralias it to completion-show-help (if bound). +;; 2007/03/10 dadams +;; Added: icicle-Completions-window-default-width. +;; 2007/02/27 dadams +;; Changed default value of icicle-incremental-completion-delay to 0.7. +;; 2007/02/22 dadams +;; icicle-buffer-sort: Use icicle-buffer-sort-*...*-last, not nil, as default value. +;; 2007/02/20 dadams +;; Changed icicle-region-auto-open-files-flag default value to nil. +;; 2007/02/19 dadams +;; icicle-region-alist: Added buffer's file to alist entry. +;; Added: icicle-region-auto-open-files-flag. +;; 2007/02/17 dadams +;; Added: icicle-keymaps-for-key-completion. +;; 2007/02/06 dadams +;; Added: icicle-add-buffer-name-flag. +;; 2007/01/29 dadams +;; icicle-sort-function: Use icicle-case-string-less-p as value, not string-lessp. +;; 2007/01/23 dadams +;; Added: icicle-highlight-historical-candidates-flag. +;; Updated doc strings of *-flag to mention toggles. +;; 2007/01/18 dadams +;; Renamed: icicle-regions to icicle-region-alist. +;; 2007/01/15 dadams +;; Added: icicle-change-sort-order-completion-flag, icicle-sort-functions-alist. +;; icicle-cycle-into-subdirs-flag, icicle-sort-function: Updated doc string. +;; 2007/01/14 dadams +;; Added: icicle-list-nth-parts-join-string. +;; 2007/01/08 dadams +;; icicle-reminder-prompt-flag: Reduced default value from 20 to 7 Emacs sessions. +;; 2007/01/06 dadams +;; Added: icicle-use-~-for-home-dir-flag. Thanks to Timothy Stotts for the suggestion. +;; 2006/12/29 dadams +;; icicle-thing-at-point-functions: Added ffap-guesser as first alternative text grabber. +;; icicle-default-thing-insertion: Changed default value to icicle-default-thing-insertion. +;; 2006/12/25 dadams +;; Moved to icicles-fn.el: icicle-historical-alphabetic-p. +;; 2006/12/22 dadams +;; Assigned Icicles subgroups, instead of group Icicles. +;; 2006/12/10 dadams +;; icicle-regions: Corrected (forgot repeat). +;; 2006/11/26 dadams +;; Added: icicle-regions(-name-length-max). +;; 2006/11/24 dadams +;; Added: icicle-kmacro-ring-max. +;; 2006/11/23 dadams +;; Added: icicle-TAB-shows-candidates-flag. Thx to Tamas Patrovics for the suggestion. +;; 2006/11/09 dadams +;; icicle-search-highlight-all-flag -> icicle-search-highlight-threshold. +;; Added: icicle-search-highlight-all-current-flag. +;; 2006/10/28 dadams +;; icicle-region-background: Changed :type to 'color for Emacs 21+. +;; icicle(-alternative)-sort-function, icicle-buffer-sort, icicle-transform-function: +;; function -> choice of nil or function. +;; icicle-buffer-configs: Added :tag's. +;; icicle-saved-completion-sets: Corrected doc string. +;; 2006/10/21 dadams +;; Added: icicle-complete-keys-self-insert-flag. +;; 2006/10/14 dadams +;; icicle-list-end-string: Added :type and :group. +;; Moved conditional eval-when-compile to top level. +;; 2006/10/04 dadams +;; Added: icicle-special-candidate-regexp. +;; 2006/10/03 dadams +;; icicle-list-join-string: Replaced ^G^J by \007\012, to be able to upload to Emacs Wiki. +;; 2006/10/01 dadams +;; icicle-alternative-sort-function: Updated doc string - it's now a general toggle. +;; 2006/09/30 dadams +;; Added: icicle-key-descriptions-use-*-flag. +;; 2006/09/16 dadams +;; Added: icicle-list-end-string. +;; 2006/09/03 dadams +;; Renamed icicle-show-Completions-help to icicle-show-Completions-help-flag. +;; 2006/08/13 dadams +;; Added: icicle-completing(-mustmatch)-prompt-prefix. +;; 2006/07/28 dadams +;; icicle-change-region-background-flag: +;; Default value takes no account of delete-selection mode. Improved doc string. +;; icicle-region-background: +;; Don't make region invisible if hexrgb.el was not loaded. +;; Change value, not hue, if grayscale frame background. Improved doc string. +;; 2006/07/23 dadams +;; Added: icicle-transform-function. +;; icicle-sort-function: Added Note to doc string. +;; 2006/07/20 dadams +;; Added: icicle-modal-cycle-(up|down)-key. +;; Renamed icicle-arrows-respect-* to icicle-cycling-respects-completion-mode-flag. +;; 2006/07/19 dadams +;; Applied patch from Damien Elmes : +;; Added: icicle-show-completions-help. Renamed it to icicle-show-Completions-help. +;; 2006/07/18 dadams +;; Added: icicle-Completions-display-min-input-chars. Thx to Damien Elmes. +;; 2006/07/10 dadams +;; icicle-historical-alphabetic-p: Fallback directory if no previous input. +;; 2006/07/07 dadams +;; Added: icicle-alternative-sort-function, icicle-historical-alphabetic-p. +;; 2006/07/04 dadams +;; icicle-expand-input-to-common-match-flag: Updated doc string. +;; 2006/06/09 dadams +;; icicle-region-background: Use nil in defcustom. Initialize separately. +;; 2006/06/08 dadams +;; icicle-bind-top-level-commands-flag: Updated doc string. +;; 2006/05/19 dadams +;; Renamed icicle-inhibit-reminder* to icicle-reminder*. +;; Changed its functionality to use a countdown. +;; 2006/05/16 dadams +;; Added: icicle-bind-top-level-commands-flag. +;; 2006/05/15 dadams +;; Renamed: icicle-completion-nospace-flag to icicle-ignore-space-prefix-flag. +;; Added: icicle-buffer-ignore-space-prefix-flag. +;; icicle-ignore-space-prefix-flag: Changed default value to nil. +;; 2006/05/09 dadams +;; icicle-incremental-completion-threshold: Updated doc string (msg "Displaying..."). +;; 2006/04/28 dadams +;; Added: icicle-highlight-input-initial-whitespace-flag. +;; 2006/04/14 dadams +;; Added: icicle-input-string, icicle-search-cleanup-flag, icicle-update-input-hook. +;; icicle-list-join-string: Added :type and :group. +;; 2006/04/09 dadams +;; Added: icicle-arrows-respect-completion-type-flag. +;; 2006/04/07 dadams +;; Added: icicle-search-highlight-all-flag. +;; 2006/04/02 dadams +;; Added: icicle-regexp-quote-flag. +;; 2006/03/24 dadams +;; Added: icicle-incremental-completion-(delay|threshold). +;; 2006/03/20 dadams +;; icicle-expand-input-to-common-match-flag: Changed default value to t. +;; 2006/03/19 dadams +;; Added: icicle-expand-input-to-common-match-flag. +;; 2006/03/17 dadams +;; Removed: icicle-cache-file. +;; Added: icicle-saved-completion-sets. +;; 2006/03/13 dadams +;; Added: icicle-cache-file. +;; 2006/03/08 dadams +;; icicle-default-thing-insertion: Use substitute-command-keys in :tag. +;; 2006/03/05 dadams +;; Moved from here to icicle-mode.el: icicle-mode, icicle-mode-hook. +;; Added: icicle-touche-pas-aux-menus-flag. +;; 2006/03/03 dadams +;; icicle-list-join-string: Changed value to ^G^J. Clarified doc string. + +;;;(@* "CHANGE LOG FOR `icicles-var.el'") +;; +;; 2010/06/18 dadams +;; Added: icicle-completions-format-internal. +;; 2010/06/08 dadams +;; Added: icicle-nb-candidates-before-truncation. +;; 2010/06/04 dadams +;; Added: icicle-lighter-truncation. +;; icicle-general-help-string: Mention missing doremi commands. +;; 2010/04/29 dadams +;; Added: icicle-remove-icicles-props-p. +;; 2010/04/02 dadams +;; icicle-general-help-string: Updated. +;; 2010/04/02 dadams +;; Added: icicle-bookmark-types. +;; icicle-general-help-string: Updated to reflect move from saved regions to bookmarks. +;; 2010/03/13 dadams +;; Added: icicle-transform-before-sort-p. +;; Removed: icicle-sorted-bookmark-alist. +;; Applied renaming of icicle-add-buffer-name-flag to icicle-show-multi-completion-flag. +;; 2010/03/03 dadams +;; Added: icicle-sorted-bookmark-alist, icicle-reverse-multi-sort-p. +;; Renamed: icicle-last-sort-function to icicle-last-sort-comparer. +;; icicle-general-help-string: Applied renaming to icicle-sort-orders-alist. +;; Applied renamings: icicle-sort-function to icicle-sort-comparer, +;; icicle-sort-functions-alist to icicle-sort-orders-alist, +;; icicle-alternative-sort-function to icicle-alternative-sort-comparer. +;; 2010/02/17 dadams +;; Moved icicle-redefined-functions to icicles-opt.el +;; and renamed to icicle-inhibit-advice-functions +;; 2010/02/14 dadams +;; Added: icicle-advice-info-list, icicle-redefined-functions. +;; 2009/11/07 dadams +;; Applied doremi cmd renamings (added +) to help text. +;; 2009/10/25 dadams +;; Added: icicle-current-TAB-method. +;; Updated icicle-general-help-string with new command names. +;; 2009/09/26 dadams +;; Added: icicle-progressive-completing-p. +;; 2009/09/25 dadams +;; Removed: icicle-respect-completion-styles-p. See option *-TAB-respects-*-styles-flag. +;; 2009/09/05 dadams +;; Added: icicle-minibuffer-message-ok-p. +;; Renamed icicle-acting-on-next/prev-p to icicle-acting-on-next/prev. +;; 2009/07/26 dadams +;; Added: icicle-command-abbrev-history (belated), icicle-interactive-history. +;; 2009/05/17 dadams +;; icicle-predicate-types-alist: Updated to reflect thumb-frm.el name changes. +;; 2009/05/11 dadams +;; Added: icicle-hist-cands-no-highlight. +;; 2009/05/09 dadams +;; Added: *-input-completion-fail-overlay, *-anychar-regexp, *-dot-string-internal. +;; 2009/05/02 dadams +;; Added: icicle-cmd-reading-input. +;; 2009/04/28 dadams +;; Renamed: icicle-object-predicate-types to icicle-predicate-types-alist. +;; icicle-predicate-types-alist: +;; Converted to alist, with cdr's from icicle-type-actions-alist. Added more entries. +;; Removed: icicle-object-named-types. +;; 2009/04/03 dadams +;; Added: icicle-filtered-default-value. +;; 2009-03/16 dadams +;; Added: icicle-use-candidates-only-once-alt-p. +;; 2009/03/15 dadams +;; icicle-general-help-string: Added: icicle-recompute-shell-command-candidates, +;; icicle-remove-file-from-recentf-list. +;; 2009/03/10 dadams +;; Moved icicle-shell-command-candidates to icicles-opt.el and renamed: *-cache. +;; 2009/03/01 dadams +;; Added: icicle-completing-read+insert-candidates. +;; Removed: icicle-complete-on-demand-cmd. +;; 2009/02/23 dadams +;; Added: icicle-extra-candidates-dir-insert-p. +;; 2009/02/20 dadams +;; Added: icicle-shell-command-candidates, icicle-complete-on-demand-cmd. +;; 2009/02/04 dadams +;; Added: icicle-next-prefix-complete-cycles-p, icicle-next-apropos-complete-cycles-p. +;; 2009/01/24 dadams +;; Added: icicle-last-apropos-complete-match-fn. +;; 2009/01/13 dadams +;; Added: icicle-respect-completion-styles-p (internal var, for now). +;; 2008/12/25 dadams +;; Added: icicle-cycling-p. +;; 2008/12/07 dadams +;; Added: icicle-completion-prompt-overlay. Removed: icicle-prompt. +;; 2008/12/02 dadams +;; Added: icicle-confirm-exit-commands. +;; 2008/11/28 dadams +;; Moved to icicles-opt.el: icicle-apropos-match-fns-alist. +;; 2008/11/22 dadams +;; Added: icicle-fancy-candidates-p, icicle-fancy-cands-internal-p. +;; 2008/11/03 dadams +;; Applied renamings from icicles-cmd.el. +;; 2008/11/02 dadams +;; Added: icicle-(doc|vardoc|fundoc|plist)-last-initial(-option)-cand-set. +;; 2008/10/14 dadams +;; Added: icicle-general-help-string. +;; Removed: icicle-completion-help-string. +;; 2008/10/06 dadams +;; icicle-ms-windows-drive-hash: Set it to nil if make-hash-table is undefined. +;; 2008/09/30 dadams +;; Added: icicle-ms-windows-drive-hash. +;; 2008/09/20 dadams +;; icicle-ignored-extensions-regexp: Append $ to each extension. +;; Added: icicle-abs-file-candidates. +;; 2008/08/28 dadams +;; Renamed: alacarte-menu-items-alist to lacarte-menu-items-alist. +;; 2008/08/18 dadams +;; Added: icicle-inhibit-try-switch-buffer. +;; 2008/08/12 dadams +;; Added: icicle-apply-nomsg. +;; 2008/08/10 dadams +;; Added: icicle-explore-final-choice, icicle-explore-final-choice-full. +;; 2008/08/03 dadams +;; Added: icicle-all-candidates-list-alt-action-fn. +;; Renamed: icicle-all-candidates-action-fn to icicle-all-candidates-list-action-fn, +;; icicle-candidate-alternative-action-fn to icicle-candidate-alt-action-fn. +;; 2008/03/30 dadams +;; Added: icicle-old-read-file-name-fn. +;; 2008/03/29 dadams +;; Removed: icicle-prompt-suffix. +;; 2008/03/23 dadams +;; Added: icicle-scroll-Completions-backward-p. +;; 2008/03/19 dadams +;; Added: icicle-read-expression-map. +;; 2008/03/10 dadams +;; Added: icicle-frame-alist. +;; 2008/02/24 dadams +;; Added: icicle-apropos-match-fns-alist. +;; 2008/02/21 dadams +;; Added: icicle-Info-only-rest-of-book-p. +;; 2008/02/03 dadams +;; Added: icicle-comp-base-is-default-dir-p, icicle-dir-candidate-can-exit-p. +;; 2008/01/18 dadams +;; Moved icicle-complete-keys-alist here from icicles-cmd.el +;; 2008/01/04 dadams +;; Added: icicle-doc-history. +;; 2007/12/27 dadams +;; Added: icicle-apropos-complete-match-fn. +;; 2007/12/05 dadams +;; icicle-proxy-candidate-regexp: Removed * doc-string prefix. +;; 2007/11/25 dadams +;; Added: icicle-commands-for-abbrev. +;; 2007/11/17 dadams +;; Added: icicle(saved)-proxy-candidates, icicle-proxy-candidate-regexp. +;; 2007/10/06 dadams +;; icicle-object-named-types: Added file type. +;; 2007/08/19 dadams +;; Added: icicle-input-fail-pos. +;; 2007/08/18 dadams +;; Added: icicle-whole-candidate-as-text-prop-p. +;; 2007/07/29 dadams +;; Added: icicle-object-named-types, icicle-object-predicate-types. +;; 2007/07/27 dadams +;; Moved icicle-act-first-then-navigate-p to icicles-opt.el as icicle-act-before-cycle-flag. +;; 2007/07/08 dadams +;; Added: icicle-all-candidates(-alternative)-action-fn. +;; 2007/07/03 dadams +;; Added: icicle-previous-raw(-non)-file-name-inputs. +;; 2007/06/23 dadams +;; Added: icicle-search-replacement-history. +;; 2007/06/17 dadams +;; Added: icicle-saved-candidate-overlays. +;; 2007/06/07 dadams +;; Added: icicle-face-name-history. +;; Renamed: frame-name-history to icicle-frame-name-history, +;; icicle-font-history to icicle-font-name-history, +;; icicle-function-history to icicle-function-name-history, +;; icicle-variable-history to icicle-variable-name-history. +;; 2007/05/29 dadams +;; icicle-insert-string-at-pt-*: Initialize to nil, not 0. +;; 2007/05/25 dadams +;; Added: icicle-char-property-value-history. +;; 2007/05/06 dadams +;; Added defvars to quiet byte compiler. +;; 2007/04/28 dadams +;; Added: icicle-search-in-context-fn. +;; 2007/04/20 dadams +;; Added: icicle-search-level-overlays. +;; 2007/04/15 dadams +;; Added: icicle-search-context-regexp. +;; 2007/04/10 dadams +;; Added: icicle-search-context-level. +;; 2007/04/08 dadams +;; Added: icicle-all-candidates-action-p. +;; icicle-candidate-action-fn: Corrected doc string: reversed success and failure values. +;; 2007/04/07 dadams +;; Added: icicle-search-replacement, icicle-searching-p, icicle-act-first-then-navigate-p. +;; 2007/04/02 dadams +;; Added: icicle-text-property-value-history. +;; Added: icicle-text-properties-alist (commented out). +;; 2007/03/23 dadams +;; Added: icicle-require-match-p. +;; 2007/03/14 dadams +;; Added: icicle-last-top-level-command. +;; 2007/03/06 dadams +;; Added: icicle-inhibit-sort-p. +;; icicle-candidates-alist: Improved doc string. +;; 2007/02/20 dadams +;; Added: icicle-delete-candidate-object, icicle-candidate-alternative-action-fn. +;; 2007/02/03 dadams +;; Renamed icicle-icompleting-p to icicle-edit-update-p. +;; 2007/02/02 dadams +;; Added: icicle-completing-p. +;; 2007/01/29 dadams +;; icicle-last-sort-function: Use icicle-case-string-less-p, not string-lessp. +;; 2007/01/19 dadams +;; Added: icicle-candidate-properties-alist. +;; 2007/01/15 dadams +;; Added: icicle-reverse-sort-p. +;; 2007/01/14 dadams +;; icicle-list-use-nth-parts: Updated doc string for new icicle-list-nth-parts-join-string. +;; 2007/01/12 dadams +;; Added: icicle-list-use-nth-parts. +;; Removed icicle-saved-overriding-local-map. +;; 2007/01/11 dadams +;; Added: icicle-menu-map, icicle-minor-mode-map-entry. +;; 2007/01/10 dadams +;; Added: icicle-saved-overriding-local-map. +;; 2007/01/05 dadams +;; icicle-initial-value: Updated doc string to mention you can bind it. +;; 2006/12/25 dadams +;; Added: icicle-saved-completion-candidates-internal. +;; 2006/12/23 dadams +;; Added: icicle-candidate-help-fn. +;; 2006/12/17 dadams +;; Added: icicle-saved-completion-candidate. +;; 2006/11/24 dadams +;; Added: icicle-universal-argument-map, icicle-kmacro-alist, icicle-saved-kmacro-ring-max, +;; icicle-kmacro-history. +;; 2006/11/18 dadams +;; Added: frame-name-history, icicle-bookmark-history, icicle-buffer-config-history, +;; icicle-color-history, icicle-color-theme-history, icicle-completion-set-history, +;; icicle-dictionary-history, icicle-font-history, icicle-function-history, +;; icicle-kill-history, icicle-search-history, icicle-variable-history, +;; 2006/11/09 dadams +;; icicle-search-refined-overlays: Updated doc string: icicle-search-highlight-threshold. +;; 2006/10/14 dadams +;; Moved conditional eval-when-compile to top level. +;; 2006/09/24 dadams +;; icicle-last-transform-function: Corrected default value. +;; 2006/09/12 dadams +;; Added: icicle-pre-minibuffer-buffer. +;; 2006/08/20 dadams +;; icicle-current-completion-mode: Updated doc string. +;; 2006/08/04 dadams +;; Removed icicle-apropos-completing-p (not used). +;; 2006/07/23 dadams +;; Added: icicle-last-transform-function. +;; 2006/07/22 dadams +;; Added: icicle-search-command, icicle-search-final-choice. +;; 2006/07/20 dadams +;; Renamed icicle-arrows-respect-* to icicle-cycling-respects-completion-mode-flag. +;; 2006/07/19 dadams +;; Applied patch from Damien Elmes : Added: icicle-current-completion-type. +;; Renamed: icicle-current-completion-type to icicle-current-completion-mode. +;; 2006/07/05 dadams +;; Renamed: icicle-current-regexp-input to icicle-current-raw-input. +;; 2006/06/18 dadams +;; Added: icicle-apropos-completing-p. +;; 2006/04/30 dadams +;; Added: icicle-candidate-entry-fn. +;; Renamed: icicle-search-candidates to icicle-candidates-alist. +;; 2006/04/14 dadams +;; Renamed icicle-search-refined-overlay to icicle-search-refined-overlays. +;; Added: icicle-search-candidates. +;; 2006/04/07 dadams +;; Added: icicle-search-overlays. +;; Renamed icicle-search-overlay to icicle-search-current-overlay. +;; 2006/03/27 dadams +;; Added: icicle-search-refined-overlay. +;; 2006/03/26 dadams +;; Added: icicle-search-overlay. +;; 2006/03/25 dadams +;; Added: icicle-saved-candidates-variables-obarray. +;; 2006/03/20 dadams +;; Added: icicle-common-match-string, icicle-current-regexp-input. +;; 2006/03/14 dadams +;; Removed: icicle-icicle-completing-p. +;; 2006/03/13 dadams +;; Added: icicle-re-no-dot. +;; 2006/03/05 dadams +;; Moved to icicles-mode.el: icicle-mode-map. +;; 2006/03/04 dadams +;; Moved options stuff to Options menu, when available. +;; Moved apropos stuff to Apropos menu, when available. +;; Moved describe stuff to Describe menu, when available. +;; 2006/03/03 dadams +;; Added to Icicles menu: icicle-complete-thesaurus-entry, icicle-apropos*, +;; option-setting cmds, buffer-config cmds icicle-(var|fun)doc. +;; Require apropos-fn+var.el. + +;;;(@* "CHANGE LOG FOR `icicles.el'") +;; +;; 2009/05/22 dadams +;; Require icicles-cmd[12]. +;; 2009/04/13 dadams +;; Removed the part of Thierry's text that mentioned emacsclient (no relation to Icicles). +;; 2008/12/02 dadams +;; Don't warn, if daemonp. Thx to Thierry Volpiatto. +;; 2007/07/22 dadams +;; Require icicles-cmd.el before icicles-mode.el. +;; 2007/06/07 dadams +;; Moved all doc to new files icicles-doc1.el and icicles-doc2.el. +;; 2007/05/12 dadams +;; Moved Search Enhancements subsections to top level: Isearch Completion, +;; Icicles Search Commands, Overview, Search and Replace. +;; 2007/05/06 dadams +;; Changed S-C- to C-S- and M-C- to C-M- in doc. +;; 2007/04/20 dadams +;; Require icicles-face.el after icicles-opt.el. +;; 2007/03/09 dadams +;; Renamed sections .*Removal of Duplicates to .*Removing Duplicates and +;; More on Multi-Commands to More About Multi-Commands. +;; 2007/02/24 dadams +;; Added section More on Multi-Commands. +;; Added subsection Chipping Away the Non-Elephant to Nutshell View. +;; 2007/02/03 dadams +;; Updated section Sorting Candidates and Removal of Duplicates. +;; 2007/01/28 dadams +;; Added: subsection Using Progressive ... Process of Elimination. +;; 2007/01/21 dadams +;; Added: section Text Properties in *Completions*. +;; 2007/01/19 dadams +;; Added: section Programming Multi-Completions. +;; 2007/01/16 dadams +;; Added linkd links. Cleanup. +;; 2007/01/15 dadams +;; Added: section Sorting Candidates and Removal of Duplicates. +;; Renamed: +;; icicle-sort-and-strip-ignored to icicle-strip-ignored-files-and-sort, +;; icicle-dirs-last-p to icicle-dirs-last-p, +;; icicle-sort-case-insensitively to *-case-insensitive-string-lessp. +;; 2007/01/12 dadams +;; Updated section Multi-Completions for icicle-list-use-nth-parts. +;; 2007/01/06 dadams +;; File-Name and Directory-Name Completion Tips: Mention icicle-use-~-for-home-dir-flag. +;; 2006/11/23 dadams +;; Added icicle-TAB-shows-candidates-flag. +;; 2006/11/10 dadams +;; Multi-Commands: Mention prompt prefix +. +;; 2006/11/05 dadams +;; icicle-occur is bound to C-c '. Search commands use multiple buffers. +;; Added Nutshell subsection Perform Multiple Operations In One Command. +;; 2006/10/19 dadams +;; Added Goggle Matching section. +;; 2006/10/16 dadams +;; Added key completion to Nutshell View. +;; 2006/10/14 dadams +;; Renamed: icicle-cancel-*Help*-* to icicle-cancel-Help-*. +;; Moved conditional eval-when-compile to top level. +;; 2006/10/01 dadams +;; Updated for new alternative-sort toggle: +;; History Enhancements, Key Completion, Customization *, Key Bindings. +;; 2006/09/30 dadams +;; Changed bindings of icicle-candidate-set-(save|retrieve) from C-<, C-> to C-M-<, C-M->. +;; Added icicle-key-descriptions-use-<>-flag in Customization section. +;; 2006/09/17 dadams +;; Added section Key Completion. +;; 2006/09/12 dadams +;; Added section Moving Between the Minibuffer and Other Buffers. +;; 2006/08/23 dadams +;; Added sections Icicles Mult M-x and Defining Icicles Multi M-x. +;; 2006/08/18 dadams +;; Added section Icicles Info Enhancements. +;; 2006/08/13 dadams +;; Documented icicle-completing(-mustmatch)-prompt-prefix. +;; 2006/06/17 dadams +;; Rewrote Multi-Commands, Defining Icicles Commands (Including Multi-Commands), and +;; Defining Multi-Commands the Hard Way. +;; Renamed: Defining Icicles Commands: + (Including Multi-Commands). +;; Defining Multi-Commands: + the Hard Way. +;; Added: Defining Multiple-Choice Menus. +;; 2006/06/08 dadams +;; Removed require of icicle-keys.el (obsolete). +;; 2006/05/26 dadams +;; Mention M-k as icicle-erase-minibuffer-or-history-element. +;; Don't mention M-S-backspace and M-S-delete any more. +;; 2006/05/19 dadams +;; Renamed icicle-inhibit-reminder* to icicle-reminder*. +;; Updated its doc to reflect new functionality. +;; 2006/05/18 dadams +;; Change install instructions to include turning on Icicle mode. +;; 2006/05/16 dadams +;; Require icicles-keys.el when icicle-bind-top-level-commands-flag. +;; Updated doc to reflect new library icicles-keys.el. +;; 2006/05/15 dadams +;; Renamed: ici*-nospace-flag to icicle-ignore-space-prefix-flag. +;; Updated doc of icicle-ignore-space-prefix-flag. +;; Added doc of icicle-buffer-ignore-space-prefix-flag. +;; 2006/04/14 dadams +;; Added section Inserting a Regexp from a Variable. +;; 2006/04/09 dadams +;; Added descriptions of icicle-arrows-respect-completion-type-flag. +;; 2006/03/19 dadams +;; Added description of icicle-expand-input-to-common-match-flag. +;; 2006/03/07 dadams +;; Correct the description of icicle-doc - match against only the doc, not the symbol name. +;; 2006/03/06 dadams +;; Reordered Commentary sections, putting Emacs-Lisp stuff later. +;; 2006/03/05 dadams +;; Mention icicle-touche-pas-aux-menus-flag. +;; 2006/03/03 dadams +;; Clarified Multi-Completions description. +;; 2006/03/01 dadams +;; Added: icicle-(complete|insert)-thesaurus-entry. +;; 2006/02/27 dadams +;; Split into multiple libraries: *-cmd, *-face, *-fn, *-mac, *-mode, *-opt, *-var. +;; 2006/02/25 dadams +;; Added: icicle-narrow-candidates (bound to M-*), icicle-icicle-completing-p, +;; icicle-set-calling-cmd, icicle-reset-icicle-completing-p, +;; icicle-run-icicle-(pre|post)-command-hook. +;; Add all hooks in icicle-mode only, except for minibuffer-local hooks (pre- and +;; post-command). +;; Remove all hooks when exit Icicle mode. +;; icicle-completing-read, icicle-read-file-name: +;; Add catch icicle-read-top. Set icicle-icicle-completing-p. +;; Separate case of not Icicle mode from other no-prompt cases. +;; Reordered some groups of functions. +;; 2006/02/24 dadams +;; icicle-candidate-set-1: Treat empty set. +;; 2006/02/21 dadams +;; icicle-prefix-complete: Implemented icompletion here, like icicle-apropos-complete-1. +;; icicle-call-then-update-Completions: +;; Use icicle-last-completion-command, not icicle-apropos-complete. +;; Renamed icicle-apropos-icompleting-p to icicle-icompleting-p. +;; Added: icicle-(kill|delete)(-backward)-*, icicle-yank etc. Bound them. +;; Added: icicle-call-then-update-Completions. +;; Added: icicle-incremental-completion-p. +;; Use instead of icicle-incremental-completion-flag everywhere. +;; Upgrade from t in icicle-display-candidates-in-Completions. +;; Reset in icicle-minibuffer-setup. +;; icicle-isearch-complete: Use search-ring symbol as history arg to completing-read. +;; icicle-display-candidates-in-Completions, icicle-keep-only-past-inputs, icicle-history: +;; Ensure that minibuffer-history-variable is a list. +;; Fixed typos: icicle-keep-past-inputs -> icicle-keep-only-past-inputs. +;; 2006/02/20 dadams +;; icicle-insert-string-at-point: Treat negative prefix arg. +;; Added: icicle-signum. +;; icicle-insert-thing: Remove text properties of string to insert. +;; 2006/02/19 dadams +;; icicle-thing-at-point-functions: Added function to grab successive text. +;; icicle-insert-string-at-point: Treat successive-grab fn and prefix arg. +;; Added: icicle-default-thing-insertion, icicle-default-thing-insertion-flipped-p, +;; icicle-insert-string-at-pt-(start|end), icicle-successive-grab-count, +;; icicle-insert-thing. +;; Renamed: icicle-insert-string-near-point to icicle-insert-string-at-point. +;; 2006/02/18 dadams +;; icicle-retrieve-last-input: Don't reset icicle-last-completion-command if not interactive +;; icicle-candidate-set-complement, icicle-keep-only-past-inputs: +;; Use icicle-retrieve-last-input. +;; icicle-keep-only-past-inputs: +;; Rewrote modeled on icicle-apropos-complete: +;; Take into account singleton and empty candidate set. +;; Provide input to icicle-display-ca*. +;; Set icicle-last-completion-command. +;; icicle-history: Force redisplay of *Completions*. Don't set this-command. +;; icicle-completing-read: Ensure icicle-initial-value is not nil. +;; icicle-save-or-restore-input: Don't restore empty input. +;; icicle-recompute-candidates: +;; Don't recompute if last completion cmd was icicle-keep-only-past-inputs. +;; Added: icicle-historical-candidate, icicle-keep-only-past-inputs. +;; icicle-display-candidates-in-Completions: Use icicle-historical-candidate. +;; Bind icicle-keep-only-past-inputs to M-pause in minibuffer completion maps. +;; 2006/02/17 dadams +;; Added: icicle-complete-input-overlay, icicle-highlight-complete-input, +;; icicle-complete-input. +;; icicle-(prefix|apropos)-complete(-1): Use icicle-highlight-complete-input. +;; Added icicle-inhibit-reminder-prompt-flag. Thx to Jonathan Simms for the suggestion. +;; icicle-completing-read, icicle-read-file-name: Use icicle-inhibit-reminder-prompt-flag. +;; 2006/02/12 dadams +;; icicle-read-string: Finished bug fix of 2/11. Thx to Andrey Zhdanov. +;; 2006/02/11 dadams +;; icicle-insert-string-near-point: Always start with first function. +;; read-from-minibuffer: Bug fix: don't use def if init is consp. Thx to Andrey Zhdanov. +;; 2006/02/09 dadams +;; Added: icicle-insert-string-near-point, icicle-thing-at-point-functions, +;; icicle-thing-at-pt-fns-pointer. +;; Bound icicle-insert-string-near-point. +;; Added Commentary section "Inserting Text Found Near the Cursor" +;; Require: thingatpt+.el, thingatpt.el. +;; Bug fix: icicle-execute-extended-command(-1): Take care of last-command and this-command. +;; 2006/02/08 dadams +;; icicle-completing-read: Treat consp case of initial-input. +;; icicle-read-file-name: Fixed bug introduced 02/02: +;; Don't ensure initial-input is not null. +;; 2006/02/07 dadams +;; Bug fix: Files menu find-file stuff was bound to *recent-file*. +;; 2006/02/03 dadams +;; icicle-init-value-flag: Use nil as the default value. +;; Added: icicle-read-from-minibuffer, icicle-read-string. +;; Use in icicle-(redefine|restore)-standard-commands. +;; 2006/02/02 dadams +;; icicle-completing-read, read-file-name: +;; Respect icicle-init-value-flag only if default value not nil. +;; read-file-name: Ensure initial-value is not null. Initialize icicle-initial-value. +;; Respect icicle-init-value-flag. +;; 2006/01/29 dadams +;; icicle-completing-read, icicle-read-file-name: Remove binding of ESC-TAB. +;; icicle-lisp-complete-symbol: Enable recursive minibuffers if in minibuffer. +;; Commentary: Combine lisp-complete-symbol with dabbrev. +;; Updated bindings listed in icicle-completion-help-string. +;; 2006/01/28 dadams +;; New feature: icicle-lisp-complete-symbol (added). Added to Commentary and moved section. +;; Corrected fix of 2005/12/14: +;; icicle-minibuffer-setup: Save region background at recursion level 1. +;; icicle-saved-region-background: defvar to nil. +;; Added: icicle-increment-color-hue. Use in icicle-region-background. +;; Added: icicle-(re)set-option-to-(nil|t), icicle-clear-option, icicle-toggle-option, +;; icicle-binary-option-p. +;; 2006/01/26 dadams +;; Added: icicle(-saved)(-regexp)-search-ring-max, +;; icicle-(redefine|restore)-standard-options. +;; icicle-mode: Use icicle-(redefine|restore)-standard-options. +;; Use icicle-(redefine|restore)-standard-commands for Emacs 21+ also (forgot?) +;; icicle-(redefine|restore)-*: Use defalias, not fset. +;; 2006/01/24 dadams +;; New feature: icicle-isearch-complete. +;; Added: icicle-isearch-complete, icicle-isearch-resume, icicle-bind-isearch-keys. +;; icicle-mode: add/remove isearch-mode-hook. +;; Minor bug fix: initial value was treated as icicle-last-completion-candidate. +;; Added: icicle-initial-value. +;; icicle-completing-read, icicle-read-file-name: +;; Set icicle-initial-value, not icicle-last-completion-candidate. +;; icicle-next-candidate: +;; Initialize icicle-last-completion-candidate to icicle-initial-value. +;; icicle-save-or-restore-input: +;; Don't change icicle-current-input if = icicle-initial-value +;; Renamed: icicle-init-value to icicle-init-value-flag. +;; 2006/01/23 dadams +;; Use command remapping for self-insert-command in Emacs 22. +;; Changed icicle-(re|un)map to defsubst. +;; Removed Commentary section on icicle-execute-extended-command. +;; icicle-apropos-complete-and-exit, icicle-apropos-complete-1: +;; Use flag icicle-apropos-complete-and-exit-p to suppress minibuffer-message. +;; 2006/01/22 dadams +;; Added: icicle-execute-extended-command*. +;; completing-read, icicle-read-file-name: +;; Corrected nil case for icicle-require-match-flag (bug fix). +;; Hard-code bindings, instead of using \\[...], so the simpler bindings are shown. +;; Changed C-o to C-RET for consistency (C-o still works too). +;; icicle-(bind|restore)-completion-keys: Added C-RET binding. +;; 2006/01/21 dadams +;; icicle-mouse-choose-completion: +;; Don't save selected window if it's *Completions*. +;; Added more Commentary about icicle-retrieve-last-input. +;; 2006/01/20 dadams +;; icicle-sort-and-strip-ignored: Don't ignore names if only ignored extensions match. +;; Added: icicle-apropos-complete-and-exit. Bound it in icicle-rebind-completion-maps. +;; icicle-minibuffer-setup: Don't reset icicle-require-match-flag. +;; icicle-apropos-complete: Return the list of candidates. +;; 2006/01/19 dadams +;; Added: icicle(-buffer)-require-match-flag. Thanks to Mathias Dahl for feedback. +;; Use in completing-read, read-file-name, and icicle-minibuffer-setup. +;; Re-alphabetized defcustoms. +;; 2006/01/07 dadams +;; Added :link. +;; 2005/12/31 dadams +;; Added: icicle-fix-default-directory. +;; icicle-read-file-name: Use icicle-fix-default-directory hack to fix bug. +;; 2005/12/26 dadams +;; Added icicle-sort-case-insensitively. +;; Added more parent groups for icicles group. +;; 2005/12/14 dadams +;; icicle-minibuffer-setup: Only save region background when at top level. +;; Added: icicle-Completions-frame-at-right-flag. Use in icicle-candidate-action. +;; Added: defvars for font-lock-keyword-face, font-lock-function-name-face. +;; 2005/12/09 dadams +;; Fontify icicle-define* in emacs-lisp-mode. +;; 2005/12/02 dadams +;; Added: icicle-customize-apropos*. Use in icicle-(redefine|restore)-standard-commands. +;; 2005/12/01 dadams +;; Added: icicle-repeat-complex-command, icicle-redefine-standard-commands-flag, +;; icicle-(redefine|restore)-standard-commands. +;; 2005/11/30 dadams +;; Added: icicle-apropos-zippy. +;; icicle-apropos-command, icicle-apropos-variable: +;; Corrected completing-read for do-all arg. +;; icicle-apropos-command, *-apropos-option: My version must not respect apropos-do-all. +;; 2005/11/29 dadams +;; Added: icicle-apropos*. +;; icicle-help-on-candidate: Treat plists. Message "No help" is the default. +;; 2005/11/25 dadams +;; Added: icicle-dabbrev-completion. +;; Renamed names with "*Completions*" to use "Completions", for coherence with XEmacs port. +;; 2005/11/24 dadams +;; icicle-mouse-choose-completion: Delete *Completions* window systematically. +;; 2005/11/21 dadams +;; icicle-delete-windows-on: Avoid error Attempt to delete minibuffer or sole ... window. +;; icicle-prefix-complete, icicle-apropos-complete-1, icicle-next-candidate: +;; Use icicle-delete-windows-on, not delete-window. +;; icicle-candidate-set-save: Use map in doc string. +;; icicle-compilation-search: Tidied up doc string. +;; Use #' for clarity. +;; 2005/11/20 dadams +;; icicle-completing-read: Added treatment of completions that are lists of strings. +;; Updated Commentary: new section on completions that are lists. +;; Added: icicle-list-join-string, icicle-doc, icicle-fundoc, icicle-vardoc. +;; 2005/11/15 dadams +;; Temporarily removed defadvice of next-history-element for Emacs 22. Bug reported. +;; icicle-minibuffer-prompt-end: Changed from defsubst to defun. +;; 2005/11/13 dadams +;; icicle-mouse-candidate-action: buffer-substring -> buffer-substring-no-properties. +;; icicle-completing-read: Bind, don't set, minibuffer-completion-table. +;; icicle-buffer*: Use other buffer for DEF, not INIT-VALUE. +;; Added: icicle-preselect-init-value-flag, icicle-(add|remove)-buffer-*, +;; icicle-read-from-minibuf-nil-default, icicle-buffer-list, +;; icicle-select-minibuffer-contents, icicle-completing-p. +;; icicle-minibuffer-setup: +;; Select minibuf contents if icicle-preselect-init-value-flag. +;; Only display *Completions* if icicle-completing-p. +;; Advised next-history-element. +;; 2005/11/11 dadams +;; Added: icicle-show-*Completions*-initially-flag, icicle-display-*Completions*. +;; icicle-minibuffer-setup: If icicle-show-*Completions*-initially-flag, display it. +;; 2005/11/09 dadams +;; Added: icicle-mouse-candidate-action. Bind in icicle-rebind-completion-maps. +;; icicle-buffer(-other-window): Use buffer-name-history as HIST arg to completing-read. +;; 2005/11/08 dadams +;; Add/remove hook icicle-cancel-*Help*-redirection in icicle-mode, not at top level. +;; Removed icicle-reset-icicle-menu-items-alist. +;; Reset icicle-menu-items-alist in icicle-execute-menu-command of icicles-menu.el. +;; 2005/11/06 dadams +;; Include minibuffer-local-filename-completion-map. +;; 2005/11/05 dadams +;; icicle-display-candidates-in-*Completions*: Don't try to highlight root if it is "". +;; icicle-help-on-candidate: +;; Test null, not boundp icicle-menu-items-alist. +;; If menu item's command is a lambda, set cand-symb to nil. +;; icicle-mode: Use icicle-reset-icicle-menu-items-alist on minibuffer-exit-hook. +;; Added: icicle-reset-icicle-menu-items-alist. +;; Added defvar for icicle-menu-items-alist. +;; Added byte-compiler comments and defvars to quiet byte-compile. +;; 2005/11/04 dadams +;; icicle-display-candidates-in-*Completions: +;; Bug fix - use (functionp minibuffer-completion-table), not (icicle-file-name-input-p). +;; 2005/11/03 dadams +;; Added: icicle-filter-wo-input and vars icicle-must-*, icicle-extra*, icicle-buffer-*, +;; icicle-buffer-config*, icicle-buffer-sort*. +;; icicle-unsorted-*: Use icicle-filter-wo-input and icicle-extra-candidates. +;; Added Commentary section Global Filters. +;; icicle-buffer* commands: Added filter bindings. +;; icicle-define(-file)-command: Minor bug fix: Ensure buffer is live before switching back. +;; 2005/11/01 dadams +;; Added: icicle-must(-not)-match-regexp. Use in icicle-unsorted-*-candidates. +;; 2005/10/31 dadams +;; Added: icicle-use-default-as-init-value-flag. Use in completing-read. +;; icicle-find-file*: Minor bug fix - REQUIRE-MATCH should be nil. +;; 2005/10/29 dadams +;; icicle-display-candidates-in-*Completions: Minor bug fix - wrap in save-window-excursion. +;; icicle-minibuffer-contents-from-minibuffer: +;; Minor bug fix - do nothing if file & user erased minibuffer. +;; Menu-bar menus: +;; Enable Icicles menu items only in Icicle mode. Put search +;; stuff on Search menu, if available. Use "[Icy]" prefix for +;; Icicles items in menus other than "Icicles". +;; 2005/10/28 dadams +;; Added: icicle-define-file-command. +;; Use it to define icicle-delete-file, icicle-find-file*. +;; icicle-(next|previous)-(apropos|prefix)-candidate-action: +;; Do action before moving to next|prev. +;; icicle-candidate-action: Raise *Completions* frame, to keep it on top. +;; 2005/10/27 dadams +;; Added: icicle-define-command, icicle-find-file*, select-frame-set-input-focus. +;; Redefined using icicle-define-command: +;; icicle-bookmark, icicle-buffer*, icicle-color-theme, icicle-delete-file, +;; icicle-find-file*, icicle-font, icicle-frame-*, icicle-recent-file*. +;; icicle-all-candidates-action: Report failures, not successes. Use error msg. +;; Added Commentary sections: Special-Character Conflicts, Defining Icicles Commands. +;; Commentary section Act on All Candidates: Added delete-one-or-more-files example. +;; Added icicle-find-file* to menu-bar menus. +;; Inactivated top-level menu items when minibuffer is active. +;; Renamed: icicle-delete-file-1 to icicle-delete-file-or-directory. +;; 2005/10/25 dadams +;; Thx to Lennart Borgman for suggestion about select-frame-set-input-focus. +;; 2005/10/24 dadams +;; icicle-search: +;; 1) Bug fix - need to have mouse-choose-completion set icicle-candidate-nb. +;; 2) Show error message. +;; Default value of icicle-candidate-nb is now nil, not -1. +;; Added: icicle-mouse-choose-completion, icicle-nb-of-candidate-in-*Completions*. +;; icicle-move-to-(next|previous)-completion, icicle-increment-cand-nb+signal-end: +;; Reset candidate number to 0 if nil. +;; icicle-(redefine|restore)-std-completion-fns: Use icicle-mouse-choose-completion. +;; 2005/10/23 dadams +;; Added: icicle-mode-map. +;; icicle-(bind|restore)-completion-keys: Updated menu-bar menu. +;; icicle-compilation-search: Error if not in a compilation buffer. +;; 2005/10/21 dadams +;; icicle-remove-duplicates: redefined. +;; 2005/10/18 dadams +;; icicle-file-name-input-p doc string: +;; Mention why don't use minibuffer-completing-file-name. +;; 2005/10/16 dadams +;; Added: icicle-compilation-search, icicle-search-hook. +;; icicle-search: Run icicle-search-hook. Added optional sit-for-period arg. +;; icicle-mode: Added list of top-level commands to doc string. +;; icicle-scroll-or-update-*Completions*: Added msg arg - only display msg if don't scroll. +;; 2005/10/14 dadams +;; Allow for multisets of candidates. +;; Added: icicle-search, icicle-completion-nospace-flag, icicle-candidate-nb, +;; icicle-filter-alist, icicle-increment-cand-nb+signal-end. +;; Commentary: Updated for icicle-search. +;; icicle-next-candidate: Major rewrite. +;; Uses icicle-candidate-nb, icicle-increment-cand-nb+signal-end, +;; icicle-move-to-next-completion. +;; Use icicle-completion-nospace-flag in calls to all-completions. +;; icicle-previous-(apropos|prefix)-candidate, +;; icicle-(next|previous)-(apropos|prefix)-candidate-action: Added optional arg. +;; icicle-apropos-complete-1, icicle-next-candidate, icicle-recompute-candidates: +;; Added *-action commands to memq test. +;; icicle-move-to-next-completion: Added optional no-minibuffer-follow-p arg. +;; icicle-scroll-or-update-*Completions*: Update display even if handle-switch-frame. +;; 2005/10/12 dadams +;; Added: icicle-redefine-std-completion-fns, +;; icicle-restore-std-completion-fns, +;; icicle-delete-windows-on, icicle-frames-on. +;; icicle-mode: Use icicle-redefine-std-completion-fns, +;; icicle-restore-std-completion-fns. +;; Renamed to use icicle- prefix: choose-completion-string, +;; completing-read, completion-setup-function, exit-minibuffer, +;; minibuffer-complete-and-exit, read-file-name, +;; switch-to-completions. Added these and also old- versions. +;; icicle-history: Treat file names also. +;; remove-windows-on -> icicle-delete-windows-on. +;; 2005/10/11 dadams +;; Added: icicle-history, icicle-scroll-or-update-*Completions*, +;; icicle-undo-std-completion-faces. +;; Minor bug fixes: +;; icicle-remove-dots: Also match against "." and ".." (lack of slash in Emacs 21+). +;; icicle-save-or-*: Don't reset to last input if icicle-last-completion-candidate is "". +;; Update icicle-last-completion-candidate also to use current input. +;; Reset icicle-last-input in icicle-minibuffer-setup, not in +;; completing-read and read-file-name. +;; icicle-display-candidates-in-*Completions*, icicle-next-candidate: +;; Put candidate in consp before applying predicate. +;; icicle-recompute-candidates: Don't recompute unless icicle-last-completion-command. +;; icicle-retrieve-last-input: Use icicle-current-input, not icicle-last-input. +;; icicle-self-insert: Update icicle-current-input and set this-command to +;; icicle-apropos-complete. +;; icicle-apropos-complete: Use error-message-string. +;; icicle-apropos-complete-1: +;; Protect icicle-file-directory-p with +;; icicle-file-name-input-p. Unconditionally update +;; icicle-last-completion-command. +;; Moved undoing of std completion faces to icicle-mode. +;; Use icicle-scroll-or-update-*Completions* in icicle-candidate-set-1. +;; 2005/10/06 dadams +;; icicle-prefix-complete, icicle-apropos-complete-1: +;; Removed vestigial slash cruft - should have been removed in 2005/09/01 fix. +;; Added: icicle-remove-dots. Use in icicle-save-or-restore-input. +;; 2005/10/05 dadams +;; icicle-msg-maybe-in-minibuffer: use format-string arg. +;; 2005/10/04 dadams +;; Replace use of minibuffer-completion-help by +;; icicle-apropos-complete. +;; Added: icicle-recent-file*, icicle-toggle-ignored-extensions, +;; icicle-update-completions, icicle-msg-maybe-in-minibuffer, +;; icicle-saved-ignored-extensions. +;; Bound icicle-toggle-*. +;; icicle-toggle-sorting: Use icicle-update-completions, icicle-msg-maybe-in-minibuffer. +;; icicle-sort-and-strip-ignored: +;; icicle-ignored-extensions-regexp nil => nothing is ignored. +;; Reorder key bindings, so prompt shows S-tab, not S-iso-lefttab. +;; icicle-next-candidate: Fixed code to highlight candidate in *Completions*: restriction. +;; 2005/10/03 dadams +;; Regexps can now use backslash (it is no longer a directory separator on MS Windows). +;; icicle-minibuffer-contents-from-minibuffer, icicle-file-name-directory-w-default: +;; Escape backslash, so not used as directory separator on MS Windows. +;; Added: icicle-apropos-complete-1, icicle-file-name-nondirectory. +;; icicle-apropos-complete: Use icicle-apropos-complete-1. +;; Treat regexp error via message. +;; Use icicle-file-name-nondirectory everywhere, instead of file-name-nondirectory. +;; Can now use "?" for regexps; it no longer shows completion list. +;; Do icicle-update-ignored-extensions-regexp inside icicle-minibuffer-setup. +;; Added and bound: icicle-retrieve-last-input. +;; Updated icicle-completion-help-string with recent bindings. +;; Renamed: icicle-last-command to icicle-last-completion-command. +;; icicle-candidate-set-restore to icicle-candidate-set-retrieve. +;; 2005/10/01 dadams +;; Added: icicle-candidate-set-(define|restore|swap). +;; Changed binding of icicle-candidate-set-save to C->. +;; Bound new commands. +;; 2005/10/01 dadams +;; Major rewrite to add set operations: complement, difference, union, intersection. +;; Added: icicle-completion-candidates, icicle-current-input, icicle-candidate-set-*, +;; icicle-set-*, icicle-save-or-restore-input, icicle-recompute-candidates. +;; Bound icicle-candidate-set*. +;; Added Commentary for Sets of Completion Candidates. +;; icicle-(apropos|prefix)-complete: Update icicle-completion-candidates, only as needed. +;; icicle-next-candidate: +;; Reverse candidates only if switched to opposite-direction command of same type. +;; Likewise, for refresh of *Completions*. +;; Protect put-text-property for root (e.g. no match for complement). +;; icicle-(apropos|prefix)-complete, +;; icicle-prefix-word-complete, icicle-next-candidate: Use icicle-completion-candidates. +;; icicle-all-candidates-action: Use icicle-completion-candidates, not *-apropos-complete. +;; icicle-display-candidates-in-*Completions*: +;; Removed first arg (candidates). Update icicle-completion-candidates. +;; icicle-all-candidates-action: +;; Use icicle-completion-candidates, so act on completions of either kind. +;; 2005/09/30 dadams +;; Commented out resetting of minibuffer-completion-table to nil for icompletion. +;; Thx to Andrey for bug report on M-x M-r problem. +;; 2005/09/27 dadams +;; icicle-(bind|restore)-completion-keys: Bound [S-iso-lefttab] like [S-tab]. +;; 2005/09/26 dadams +;; Bug fix: Changed "\C-!" to [(control ?!)] (others similarly). +;; Bound [S-iso-lefttab] like [S-tab]. +;; 2005/09/16 dadams +;; Added: icicle-all-candidates-action, icicle-delete-file*, +;; icicle-rebind-completion-maps: Bound icicle-all-candidates-action to C-!. +;; icicle-(apropos|prefix)-complete: Return candidates list. +;; icicle-bookmark, icicle-buffer*, icicle-color-theme, +;; icicle-font, icicle-frame*: Return t for success, nil for failure. +;; Commentary: Added section Choose All Completion Candidates. +;; 2005/09/14 dadams +;; icicle-rebind-completion-maps: Bound TAB and S-TAB for navigation. +;; icicle-move-to-(next|previous)-completion, icicle-(next|previous)-line: Wrap around. +;; 2005/09/13 dadams +;; Major rewrite of file treatment, to treat directory candidates similarly to files. +;; Added: icicle-default-directory, icicle-file-directory-p, icicle-sort-function, +;; icicle-toggle-sorting, toggle-icicle-sorting. +;; Use icicle-file-directory-p everywhere, except choose-completion-string. +;; Removed: icicle-nondirectory-*. +;; icicle-next-candidate: If not icicle-cycle-into-subdirs-flag, then use relative +;; file/dir name, not nondirectory part. +;; icicle-(apropos|prefix)-complete: +;; Set icicle-default-directory if sole completion is a subdirectory. +;; icicle-sort-and-strip-ignored: Removed optional arg and treatment of subdirs. +;; icicle-next-(apropos|prefix)-candidate, icicle-(apropos|prefix)-complete: +;; Don't treat icicle-cycle-into-subdirs-flag here. +;; icicle-(apropos|prefix)-complete, icicle-next-candidate: +;; Set icicle-default-directory, if directory candidate. +;; icicle-minibuffer-setup: Set icicle-default-directory. +;; icicle-apropos-complete: Different message if icicle-apropos-icompleting-p. +;; icicle-sort-dirs-last: Treat other kinds of candidates, besides files and dirs. +;; Commentary and doc strings: Updated for icicle-sort-function, icicle-cycle-into-subdirs. +;; Let delete-selection mode work with icicle-self-insert. +;; icicle-display-candidates-in-*Completions*: Make *Completions* read-only. +;; 2005/09/09 dadams +;; choose-completion-string: bug fix for Emacs 21.3.1 - use Emacs 20 version for 21.3.1. +;; 2005/09/08 dadams +;; completion-setup-function: bug fix for Emacs 21.3.1 - use Emacs 20 version for 21.3.1. +;; Added: icicle-remap, icicle-unmap, icicle-(bind|restore)-completion-keys. +;; completing-read: Do not append suffix if not in Icicle mode. +;; icicle-rebind-completion-maps: +;; Clean-up. Use icicle-(bind|restore)-completion-keys. +;; Don't (suppress-keymap completion-list-mode-map). +;; 2005/09/06 dadams +;; Provided apropos icompletion. +;; Added: icicle-self-insert, icicle-incremental-completion-flag, +;; icicle-apropos-icompleting-p. +;; icicle-apropos-complete: Respect icicle-apropos-icompleting-p. +;; Commentary: Updated Icompletion and Customization sections. +;; Added Apropos Icompletion. +;; Changed default value of icicle-word-completion-key to M-SPC. +;; icicle-rebind-completion-maps: +;; Bind icicle-self-insert. Use self-insert for SPC. +;; Updated icicle-completion-help-string. Treat menu-bar menu for the minibuffer. +;; completion-setup-function: Add instruction2 only when icicle-mode. +;; icicle-display-candidates-in-*Completions*: Use save-restriction. +;; icicle-minibuffer-contents-from-minibuffer: +;; Allow for mixing $ of environment vars with $ of regexps. +;; 2005/09/02 dadams +;; Added: icicle-bookmark, icicle-buffer(-other-window), icicle-candidate-action, +;; icicle-candidate-action-fn, icicle-color-theme(s), icicle-font, +;; icicle-frame-(b|f)g. +;; Renamed: icicle-(next|previous)-(apropos|prefix)-*-help to +;; icicle-(next|previous)-(apropos|prefix)-*-action. +;; icicle-(apropos|prefix)-complete: Set icicle-last-completion-candidate. +;; In renamed functions: Use icicle-candidate-action, not icicle-help-on-candidate. +;; icicle-rebind-completion-maps: Bound C-o to icicle-candidate-action. +;; Added Commentary section on actions on candidates. +;; icicle-move-to-next-completion: Test line num, not char position (fix). +;; icicle-previous-line: 3 or 4, not 4 or 5 (fix). +;; 2005/09/01 dadams +;; Fixed major bug: file-name completion did not work at all in non-MS Windows! +;; icicle-file-name-(apropos|prefix)-candidates: +;; Removed code for case where input starts with "/". +;; icicle-nondirectory-file-name-(apropos|prefix)-candidates: +;; Removed code for case where input starts with "/". Bind default-directory. +;; icicle-(apropos|prefix)-complete: Treat case when icicle-cycle-into-subdirs-flag = nil. +;; icicle-next-candidate: Took out code that moved point when line is too long. +;; icicle-minibuffer-setup: Reset icicle-prompt. +;; 2005/08/23 dadams +;; Added: icicle-help-on-candidate, icicle-cancel-*Help*-redirection, +;; icicle-(previous|next)-(prefix|apropos)-candidate-help. Bound them all. +;; icicle-rebind-completion-maps: +;; Bound icicle-help-on-candidate, icicle-(previous|next)-(prefix|apropos)-candidate-help. +;; 2005/08/22 dadams +;; Unconditionally require cl.el when compile (because of case). +;; 2005/08/19 dadams +;; Renamed icicle-cursor-position-in-candidate to icicle-point-position-in-candidate. +;; Added: icicle-mark-position-in-candidate, icicle-minibuffer-prompt-end. +;; icicle-place-cursor: Position both point and mark. +;; icicle-point-position-in-candidate: Change values from bob, eob to input-start/end. +;; Removed: icicle-select-rest-of-completion-flag. +;; Use inequality test on point and mark. +;; 2005/08/16 dadams +;; Minbuffer messages: Differentiate prefix from apropos completion. +;; completing-read, read-file-name: Append icicle-prompt-suffix for Emacs 20 (oversight). +;; 2005/08/15 dadams +;; Bug fix: Only use face-spec-reset-face if target faces defined. +;; read-file-name: bug fix: +;; Use condition-case to get the correct number of args for +;; old-read-file-name. Thx to Mathias Dahl for both bug reports. +;; 2005/08/14 dadams +;; icicle-place-cursor: Narrow region to exclude minibuffer-prompt +;; 2005/08/13 dadams +;; Add regexp support (removed it when introduced highlighting). +;; icicle-next-candidate: Added regexp-p arg. Use in icicle-next-apropos-candidate. +;; icicle-place-cursor: Use regexp search. For root-start, go to match-beginning. +;; icicle-unsorted-file-name-apropos-candidates: Don't use regexp-quote. +;; icicle-switch-to-*Completions*: +;; Search in restriction of mouse-face zone; repeat. +;; Treat file case (use nondirectory part). Bind case-fold-search. +;; Protect (aref 0) against empty string. +;; member -> memq, for symbols. +;; 2005/08/12 dadams +;; Added: icicle-word-completion-key, icy-mode, icicle-insert-a-space. +;; icicle-rebind-completion-maps: Use icicle-word-completion-key and icicle-insert-a-space. +;; completing-read, icicle-rebind-completion-maps: Corrected bindings in doc string. +;; 2005/07/29 dadams +;; Added: icicle-change-region-background-flag, icicle-increment-color-value, +;; icicle-region-background, icicle-saved-region-background, +;; icicle-restore-region-face. +;; Added icicle-restore-region-face to minibuffer-exit-hook. +;; Require hexrgb.el. +;; Removed: icicle-select-rest-of-completion. +;; icicle-minibuffer-setup: +;; Save icicle-saved-region-background and use icicle-region-background. +;; 2005/07/28 dadams +;; Added: icicle-*Completions*-instruction-*. +;; completion-setup-function: +;; Use icicle-*Completions*-instruction-*. +;; Remove ? from instruction2. Put both instr on same line. +;; Use put-text-property, not *-w-face*. +;; ------ +;; Move all completion stuff here, from simple+.el: +;; choose-completion-string, completion-setup-function, switch-to-completions. +;; Wrap *Completions* window deletion in save-selected-window. +;; Added icicle-prefix-word-complete, and bound it to SPC. +;; completion-setup-function: +;; Renamed icicle-completing-read-prompt-suffix to icicle-prompt-suffix. +;; 2005/07/27 dadams +;; Renamed: icicle-completing-read-prompt* to icicle-prompt*. +;; Added: read-file-name, face +;; icicle-completing-read-prompt-suffix, icicle-remove-property, +;; icicle-select-rest-of-completion (simple, for now). +;; completing-read: Apply faces to prompt. +;; icicle-place-cursor: Use icicle-select-rest-of-completion. +;; Added (if icicle-mode (icicle-mode 1)) at end. +;; Reworded Commentary in terms of "input completion", not just completing-read. +;; 2005/07/26 dadams +;; rebind-minibuffer-completion-maps: Minor bug fix. +;; icicle-mode: Added " Icy" to mode line. +;; Wrapped Emacs 21 version of icicle-mode (with define-minor-mode) in (eval (quote...)), +;; so byte-compiling in Emacs 20 will produce a *.elc that works in Emacs 21. +;; 2005/07/25 dadams +;; Added: icicle-mode, icicle-*-hook, icicle-minibuffer-setup, icicle-activate-mark. +;; rebind-minibuffer-completion-maps: +;; Restore bindings when exit Icicle mode. +;; Added argument. Pick up everything bound to help-command. +;; Message only when mode is turned on. +;; 2005/07/24 dadams +;; Now leave region from end of root to end of completion, so you can easily replace it, +;; especially if you use delete-selection mode. (Suggestion by Lennart Borgman.) +;; Added: icicle-select-rest-of-completion-flag. +;; icicle-place-cursor: Create active region if icicle-select-rest-of-completion-flag +;; icicle-completion-help: Removed icicle-abort-minibuffer-input. +;; icicle-abort-minibuffer-input: Removed obsolete code & comment on icomplete-inhibit. +;; 2005/07/22 dadams +;; Major fixup: Treat file and directory names well, respect standard user options, more. +;; Renamed: +;; icicle-(next|previous)?-completion-candidate to icicle-*-prefix-candidate(s), +;; icicle*filename* to icicle*file-name*, +;; icicle-descend-into-subdirs to icicle-cycle-into-subdirs-flag. +;; Added: icicle-file-name-apropos-candidates, icicle-file-name-directory-w-default, +;; icicle-file-name-input-p, icicle-file-name-prefix-candidates, +;; icicle-nondirectory-file-name-apropos-candidates, +;; icicle-nondirectory-file-name-prefix-candidates, +;; icicle-sort-dirs-last, icicle-unsorted-apropos-candidates, +;; icicle-unsorted-file-name-apropos-candidates, +;; icicle-unsorted-file-name-prefix-candidates, icicle-unsorted-prefix-candidates, +;; icicle-last-command. +;; Respect insert-default-directory and completion-auto-help. +;; Use minibuffer-message instead of message. +;; Commentary: Added Customization & Tips section. +;; completing-read: Save icicle-last-input. Reset icicle-nb-of-other-cycle-candidates. +;; icicle-next-*-candidate: Branch to file-specific functions. +;; icicle-*-candidates: Use icicle-unsorted-*-candidates. +;; icicle-next-candidate: +;; Delete *Completions* window if no candidates. +;; Use icicle-file-name-directory, not file-name-directory. +;; icicle-minibuffer-contents-from-minibuffer: Use substitute-in-file-name. +;; icicle-*-complete: +;; Treat slashed file names (e.g. "/foo"). +;; Use icicle-file-name-*-candidates, icicle-file-name-directory-w-default for files. +;; Added messages [No completion], [Sole completion], [Complete, but not unique]. +;; Use icicle-last-command for repetition test. And set it. +;; icicle-rebind-completion-maps: Updated icicle-completion-help-string and message. +;; 2005/07/21 dadams +;; icicle-apropos-candidates: Use, not apropos, but delete-if-not on string-match. +;; Treat files too. +;; Removed icicle-intersection. +;; Added: icicle-descend-into-subdirs. +;; icicle-sort-and-strip-ignored: Use icicle-descend-into-subdirs. Don't use "." and "..". +;; icicle-next-candidate: +;; File names w/o dir. +;; Use regexp-quote on root for underlining file-name root. +;; Insert directory name for file. +;; icicle-place-cursor: Search past dir, then search for file-name w/o dir. +;; icicle-prefix-complete, icicle-apropos-complete, +;; icicle-switch-to-*Completions*: Use icicle-minibuffer-contents-from-minibuffer. +;; icicle-prefix-complete, icicle-apropos-complete: Insert dir when single candidate. +;; icicle-display-candidates-in-*Completions*: Underline file-name w/o dir. +;; 2005/07/20 dadams +;; icicle-next-candidate, *-display-candidates-in-*Completions*: Use set-buffer-modified-p. +;; icicle-next-candidate: Use ding when hit end of cycle. +;; Added: icicle-cursor-position-in-candidate, icicle-place-cursor. +;; Use in icicle-next-candidate to position cursor. +;; Added: defgroup icicles. +;; 2005/07/19 dadams +;; Initialize icicle-ignored-*. +;; Added: icicle-nb-of-other-cycle-candidates, icicle-minibuffer-contents-from-minibuffer. +;; completing-read: Reset icicle-last-completion-candidate to nil. +;; icicle-next-candidate: +;; Use icicle-minibuffer-contents-from-minibuffer. +;; Save icicle-nb-of-other-cycle-candidates for icomplete-completions (icomplete+). +;; Use copy of "next" string since change its text properties. +;; Use regexp-quote for underlined root. +;; Use put-text-property, so works in Emacs 20. +;; Update *Completions*, even if last command is repeated. +;; icicle-*-complete: Complete rewrite. +;; icicle-display-candidates-in-*Completions*: Do even if last command is repeated. +;; 2005/07/18 dadams +;; icicle-display-*: Highlight only first occurrence in each candidate. +;; icicle-next-candidate: Use completion-ignore-case. +;; 2005/07/17 dadams +;; Treat file names also. +;; Added: icicle-delete-if*, and use instead of delete-if-*. Removed require cl.el. +;; Added: icicle-ignored-extensions*, icicle-sort-and-strip-ignored, +;; icicle-filename-input-p, icicle-update-ignored-extensions-regexp, +;; icicle-prefix-complete. Bound icicle-prefix-complete. +;; Use icicle-update-ignored-extensions-regexp as minibuffer-setup-hook. +;; icicle-*-candidates: Use icicle-sort-and-strip-ignored. +;; icicle-next-candidate, icicle-display-candidates-in-*Completions*: +;; Don't use predicate on file-name candidates (icicle-filename-input-p). +;; icicle-next-candidate: +;; Use read-file-name-completion-ignore-case (Emacs 22) and file-name-nondirectory. +;; icicle-apropos-complete: Return t/nil. Treat single candidate as no-op. +;; Reset std completions-* faces, so they don't interfere with apropos highlighting. +;; 2005/07/16 dadams +;; Added: icicle-display-*, icicle-apropos-complete. +;; Use icicle-display-* in icicle-next-candidate and icicle-apropos-complete. +;; Bound icicle-apropos-complete to S-tab in completion maps. +;; icicle-switch-to-*Completions*: +;; Move to start of candidate. Highlight candidate, not regexp. +;; icicle-next-candidate: Underline the root that was completed. +;; Added: faces icicle-root-highlight-*. +;; Removed: faces: icicle-completion-help*. +;; Removed (not used): require of strings.el. +;; Commentary: Added Nutshell View. +;; 2005/07/15 dadams +;; Renamed: icicle-completion-help+ to icicle-completion-help. +;; Replaced: icicle-delete-lines by icicle-erase-minibuffer. +;; icicle-next-candidate: +;; Wrapped display-* and re-search-forward in condition-case. Use icicle-place-overlay. +;; Changed icicle-completion-help bindings to [f1]. +;; Added: icicle-*-line, icicle-switch-to-*, icicle-move-to-*-completion, +;; icicle-current-completion-in-*Completions*, icicle-place-overlay. +;; Added bindings for icicle-*-line, icicle-switch-to-*, icicle-move-to-*. +;; Bound q to icicle-abort-minibuffer-input in completion-list-mode-map. +;; icicle-completing-read-prompt-suffix: Mention both [f1] and ?. +;; Removed: icicle-fit-frame. +;; Commentary: Added How...Improves...(5). Updated Key Bindings. +;; 2005/07/14 dadams +;; icicle-next-candidate: +;; Update *Completions*, if displayed, to reflect current +;; candidates, but don't do it if this-command = last-command. +;; Reverse list as needed, to keep same order. Ensure current +;; *Completions* choice shows in window (recenter as needed). +;; For highlighting: Search with re-search-forward to be sure to get the right one. +;; Took test for presence of predicate out of loop. +;; Commentary: Added Note on pop-up-frames = t. +;; 2005/07/13 dadams +;; Rewrote icicle-apropos-candidates. +;; Added: icicle-intersection. +;; 2005/07/12 dadams +;; Added: icicle-(next|previous)-apropos-candidate, icicle-next-candidate, +;; icicle-apropos-candidates, icicle-completion-candidates. +;; Bound: icicle-(next|previous)-apropos-candidate. +;; Renamed: icicle-completion-help-(title-)face: Removed "-face". +;; icicle-next-completion-candidate: Redefined to use icicle-next-candidate. +;; icicle-rebind-completion-maps: Updated text to mention apropos completion. +;; icicle-completion-help+: Use icicle-abort-minibuffer-input, not abort-recursive-edit. +;; 2005/07/10 dadams +;; First version of icicles.el (previously called elect-mbuf.el). +;; Renamed: minibuffer-completion-help-string to icicle-completion-help-string, +;; completing-read-prompt to icicle-completing-read-prompt, +;; completing-read-prompt-suffix to icicle-completing-read-prompt-suffix, +;; mbuf-completion-help-face to icicle-completion-help-face, +;; mbuf-completion-help-title-face to icicle-completion-help-title-face, +;; minibuffer-last-default to icicle-last-completion-candidate, +;; command-calling-for-completion to icicle-cmd-calling-for-completion, +;; minibuffer-completion-help+ to icicle-completion-help+, +;; abort-minibuffer-input to icicle-abort-minibuffer-input, +;; next-default-input to icicle-next-completion-candidate, +;; previous-default-input to icicle-previous-completion-candidate, +;; rebind-minibuffer-completion-maps to icicle-rebind-completion-maps, +;; Added: minibuffer-complete-and-exit, icicle-fit-frame, icicle-last-input. +;; Moved delete-lines here from and renamed to icicle-delete-lines. +;; Removed: mod+ (unused). +;; icicle-completion-help+: Use *Help*, not *Completions*. Don't show completions. +;; icicle-next-completion-candidate: Use insert, not insert-string. +;; icicle-rebind-completion-maps: Made it interactive. +;; 2005/07/09 dadams +;; Removed: buffer-alist (not used). +;; 2005/05/15 dadams +;; Renamed: flash-ding-minibuffer-frame to 1on1-flash-ding-minibuffer-frame. +;; 2005/05/10 dadams +;; Hacked completing-read to remove *Completions* window at end if require-match is non-nil. +;; (Don't know why/when this became a problem.) +;; 2004/09/21 dadams +;; Updated to work in Emacs 21 (and 20): +;; next-default-input uses delete-minibuffer-contents for 21, but erase-buffer for 20. +;; minibuffer-completion-help+: bind inhibit-read-only to t around erase-buffer. +;; 2001/01/10 dadams +;; Protected remove-windows-on via fboundp. +;; 1999/09/03 dadams +;; Added: mbuf-completion-help-face, mbuf-completion-help-title-face. +;; minibuffer-completion-help+: Use mbuf-*-face's instead of hard-coding. +;; minibuffer-completion-help-string, completing-read-prompt-suffix: defconst -> defvar. +;; 1999/08/26 dadams +;; Protected faces via boundp. +;; 1999/04/13 dadams +;; Bound delete-lines to M-S-DEL and M-S-backspace. +;; 1999/03/17 dadams +;; protect calls with test fboundp. +;; 1996/04/26 dadams +;; Put escaped newlines on long-line strings. +;; 1996/03/26 dadams +;; minibuffer-completion-help+: concat -> concat-w-faces (color). +;; 1995/12/20 dadams +;; exit-minibuffer: Iconify *Completion* frame. +;; 1995/12/15 dadams +;; abort-minibuffer-input: Reset minibuffer-completion-table to avoid icompletion. +;; Defined replacement exit-minibuffer to do the same as #1. +;; 1995/12/01 dadams +;; abort-minibuffer-input: Incorporated delete-selection-mode code +;; rebind-minibuffer-completion-maps: +;; Added C-g bindings for minibuffer-local-map, minibuffer-local-ns-map, +;; minibuffer-local-isearch-map. +;; 1995/10/25 dadams +;; Put defvar of minibuffer-completion-help-string after do +;; rebind-minibuffer-completion-maps, so its doc string gives bindings. +;; 1995/10/24 dadams +;; Mention ESC-TAB completion in completing-read. +;; 1995/10/17 dadams +;; Let minibuffer use ESC-TAB for completion (Lisp symbols etc.) +;; completing-read: Minibuffer adopts current buffer's ESC-TAB binding. +;; Added command-calling-for-completion to memorize current command (done in +;; completion-setup-hook). +;; 1995/09/12 dadams +;; Added abort-minibuffer-input. +;; Define C-g as abort-minibuffer-input in completion-list-mode-map and +;; minibuffer-local-* maps. +;; No self-insertion for completion-list-mode-map. +;; 1995/08/16 dadams +;; next-default-input: Fixed bug - skip repeated alist entries. +;; 1995/08/10 dadams +;; Rewrote minibuffer-completion-help+: Provide help even if no completions. +;; So, added minibuffer-completion-help-string. +;; `?' defined correctly for minibuffer-local-must-match-map. +;; 1995/08/08 dadams +;; next-default-input: error msg: no hard coding of key seq. +;; 1995/08/02 dadams +;; Major rewrite. +;; No reminders in prompts. Added minibuffer-completion-help+ to provide help info for +;; *Completions*. +;; Log for functions that were previously in simple+.el: +;; choose-completion-string, completion-setup-function, switch-to-completions. +;; 2005/07/28 dadams +;; completion-setup-function: +;; Renamed icicle-completing-read-prompt-suffix to icicle-prompt-suffix. +;; 2005/07/15 dadams +;; choose-completion-string, completion-setup-function: Updated for Emacs 21+. +;; 2005/07/10 dadams +;; Renamed: command-calling-for-completion to icicle-cmd-calling-for-completion. +;; 2004/09/21 dadams +;; Only redefine choose-completion-string if prior to Emacs 21. +;; 1999/03/17 dadams +;; choose-completion-string: +;; Added doc string. Updated to correspond to Emacs 34.1. +;; completion-setup-function: diff prompt setups. face1 & face2 tests. +;; Added: switch-to-completions. +;; 1996/04/26 dadams +;; Put escaped newlines on long-line strings. + +;;;(@* "CHANGE LOG FOR `icicles-cmd.el'" - Deprecated file) +;; +;; 2009/05/22 dadams +;; Split in two: icicles-cmd1.el, icicles-cmd2.el. File too large to upload to Emacs Wiki. +;; 2009/05/20 dadams +;; Renamed: *-Info-build-node-completions-fix-* to *-Info-build-node-completions-1. +;; icicle-Info-goto-node: Plain C-u now prepends Info file name to candidates. +;; icicle-Info-goto-node-1: swapped arg order in call to Info-goto-node nodename (bug fix). +;; icicle-Info-read-node-name, icicle-Info-build-node-completions(-1): +;; Added optional arg INCLUDE-FILE-P. +;; 2009/05/11 dadams +;; icicle-complete-keys: Use icicle-local-keys-first-p as icicle-sort-function. +;; Bind icicle-hist-cands-no-highlight to (".."). +;; icicle-keys+cmds-w-prefix: Propertize candidate "..". +;; icicle-dabbrev-completion: Use icicle-upcase. +;; 2009/05/10 dadams +;; Added: icicle-search-(defs|lines|paragraphs|sentences|pages). +;; icicle-plist: Pretty-print, unless negative prefix arg (or Emacs 20). +;; icicle-search-regexp-scan: Fix to pick up candidate at eob: removed (not (eobp)) test. +;; 2009/05/05 dadams +;; icicle-find-file-(absolute|in-tags-table)(-other-window), +;; icicle-(recent|locate)-file(-other-window), icicle-describe-option-of-type, +;; icicle-(vardoc|fundoc|doc|plist), icicle-goto-global-marker: +;; Remove quote before face name, for icicle-candidate-properties-alist value. +;; icicle-buffer(-other-window|-list), icicle-kill-buffer, icicle-choose-candidate-of-type: +;; Bind completion-ignore-case, based on read-buffer-completion-ignore-case. +;; 2009/05/01 dadams +;; Added: icicle-shell-command-on-file. +;; Bind both icicle-all-candidates-list-alt-action-fn and icicle-candidate-alt-action-fn +;; to icicle-alt-act-fn-for-type for appropriate type - same commands as for 2009/04/26, +;; except removed these for *recent* (mistaken). +;; Use renaming from icicles-fn.el: *-choose-action-for-type -> *-alt-act-fn-for-type. +;; 2009/04/28 dadams +;; icicle-object-action: +;; At end, just apply the fn returned by icicle-choose-action-for-type to chosen object. +;; Use icicle-type-actions-alist, not icicle-object-named-types. +;; Update to use with icicle-predicate-types-alist (not flat list of preds). +;; icicle-choose-candidate-of-type: Handle color type too. +;; icicle-get-anything-actions-for-type: +;; Highlight Anything actions using face icicle-special-candidate. +;; 2009/04/26 dadams +;; icicle-marker+text, icicle-compilation-search-in-context-fn: +;; Bind inhibit-field-text-motion to t, to ensure real end-of-line. +;; Load icicles-mac (at compile time) using load-library, to ensure latest .elc. +;; Bind icicle-candidate-alt-action-fn, where appropriate, to icicle-choose-action-for-type: +;; *-lisp-complete-symbol, *-customize-face(-other-window), *-execute-extended-command, +;; *-command-abbrev, *-command-abbrev-command, *-execute-named-keyboard-macro, +;; *-set-option-to-t, *-reset-option-to-nil, *-toggle-option, *-select-frame, +;; *-delete-windows, *-kill-buffer, icicle-buffer(-other-window), +;; *-(add|remove)-buffer-candidate, *-(buffer|face|file|directory)-list, +;; *-find-file(-absolute|-in-tags-table)(-other-window), +;; *-(recent|locate)-file(-other-window), *-frame-(bg|fg), *-where-is, +;; *-apropos(-variable|option|function|command), *-apply, *-save-string-to-variable, +;; *--choose-candidate-of-type, *-read-var-value-satisfying, *-read-color. +;; icicle-execute-extended-command-1, icicle-command-abbrev-action: +;; Rebind icicle-candidate-alt-action-fn to nil so we don't override it for invoked cmd. +;; icicle-object-action: Respect icicle-use-anything-candidates-flag. +;; 2009/04/25 dadams +;; icicle-find-file-in-tags-table(-other-window): Fixed copy+paste typo. +;; 2009/04/24 dadams +;; Added: icicle-find-file-in-tags-table(-other-window). +;; 2009/04/19 dadams +;; icicle-customize-apropos-options-of-type, icicle-dabbrev-completion: +;; Don't fset unless standard function is defined. +;; Use when/unless instead of or for fset's. (cosmetic) +;; 2009/04/18 dadams +;; Soft-require hexrgb.el unconditionally, not just when there is a window-system. +;; icicle-read-color: Error if hexrgb is not loaded. +;; 2009/04/11 dadams +;; Added: icicle-region-add-short-help. +;; icicle-font-w-orig-size: Construct short help only if user will see it. +;; icicle-describe-opt-of-type-complete, icicle-marker+text, +;; icicle-(select|search|remove)-region, icicle-search-(regexp|char-property)-scan: +;; Add short help for mode-line and tooltip. +;; icicle-region-help: Corrected start/end order. +;; icicle-region-help, icicle-search-help: Removed unused help: No help. +;; 2009/04/10 dadams +;; icicle-font-w-orig-size: Provide help string. Set font to use orig-pointsize also. +;; icicle-font: Modify frame - don't use menu-bar-mode. Get orig menu-bar info from frame. +;; Save orig-pointsize also. +;; icicle-frame-(bg|fg): +;; Incorporate behavior of icicle-read-color: multi-completion etc. Added short help. +;; (Use icicle-make-color-candidate, icicle-color-completion-setup.) +;; icicle-read-color: +;; Factored out stuff as new function icicle-color-completion-setup. +;; Corrected handling of ARG > 2. +;; Moved to icicles-fn.el: +;; icicle-color-help, icicle-make-color-candidate, icicle-remove-color-duplicates. +;; 2009/04/09 dadams +;; Added: icicle-font-w-orig-size. +;; icicle-font: Use icicle-font-w-orig-size. No menu bar, to avoid Emacs frame-sizing bug. +;; 2009/04/04 dadams +;; icicle-kill-buffer, icicle-buffer(-other-window|-list), icicle-choose-candidate-of-type: +;; Bind icicle-sort-functions-alist for buffer names. +;; 2009/03/29 dadams +;; icicle-make-color-candidate: Use white or black foreground, depending on color value. +;; 2009/03/27 dadams +;; Renamed: icicle-default-buffer-name to icicle-default-buffer-names. +;; icicle-buffer(-other-window): +;; Bind bufflist, to make it available also to icicle-default-buffer-names. +;; icicle-default-buffer-names: Emacs 23: Provide first 4 buffers from bufflist. +;; 2009/03/26 dadams +;; Added: icicle-default-buffer-name. +;; icicle-buffer(-other-window), icicle-add-buffer-candidate: +;; Use icicle-default-buffer-name. +;; 2009/03/16 dadams +;; icicle-buffer(-other-window), icicle-buffer-list, icicle-kill-buffer, +;; icicle-add-buffer-candidate: Treat prefix arg buffers visiting files or frame-local. +;; icicle-recent-file(-other-window): Bind icicle-use-candidates-only-once-alt-p to t. +;; 2009/03/15 dadams +;; Added: icicle-remove-file-from-recentf-list, icicle-remove-from-recentf-candidate-action. +;; icicle-recent-file(-other-window): +;; Bind icicle-candidate-alt-action-fn to icicle-remove-from-recentf-candidate-action. +;; 2009/03/10 dadams +;; Added: icicle-recompute-shell-command-candidates. +;; 2009/02/28 dadams +;; icicle-find-file-absolute(-other-window): +;; Treat directory candidates as special candidates. +;; icicle-apropos: Treat functions as special candidates. +;; icicle-apropos-variable: Treat user options as special candidates. +;; icicle-apropos-function: Treat commands as special candidates. +;; icicle-apropos-command (non-apropos-fn+var version): Treat cmds as special candidates. +;; 2009/02/23 dadams +;; icicle-Info-goto-node-action: +;; Protect dir insertion with icicle-extra-candidates-dir-insert-p. +;; 2009/02/17 dadams +;; icicle-lisp-complete-symbol: +;; Added predicate arg. Updated wrt Emacs 23 (better var completion). +;; 2009/02/01 dadams +;; icicle-(find-file-absolute|(recent|locate)-file)(-other-window): +;; Bind C-backspace to icicle-up-directory. +;; 2009/01/18 dadams +;; icicle-dired-saved-file-candidates(-other-window): +;; If there is no saved set, then use icicle-file-list to let user choose a set. +;; Added: icicle-dired-chosen-files(-other-window), as aliases. +;; 2009/01/14 dadams +;; Same commands as yesterday: icicle-remove-duplicates -> icicle-remove-dups-if-extras. +;; 2009/01/13 dadams +;; icicle-kill-buffer, icicle-buffer(-other-window), icicle-(buffer|file|directory)-list, +;; icicle-find-file(-absolute)(-other-window), icicle-(recent|locate)-file(-other-window), +;; icicle-choose-candidate-of-type: +;; Bind icicle-transform-function to icicle-remove-duplicates. +;; 2009/01/05 dadams +;; Added: icicle-gud-gdb-complete-command. +;; icicle-shell-dynamic-complete(-as)-environment-variable: (require 'shell) +;; icicle-shell-dynamic-complete-as-command: Added candidate help for shell commands. +;; 2009/01/04 dadams +;; Added ESS support: +;; Added: icicle-comint-replace-by-expanded-filename, icicle-ess-complete-filename, +;; icicle-ess(-internal)-complete-object-name, icicle-ess-R-complete-object-name. +;; Thx to Sebastian Luque. +;; Improved some doc strings. +;; 2009/01/02 dadams +;; icicle-comint-dynamic-complete-as-filename, icicle-comint-dynamic-simple-complete: +;; Fixed for comint-completion-autolist, absolute directories. Thx to Sebastian Luque. +;; 2009/01/01 dadams +;; icicle-comint-replace-orig-completion-fns: +;; Use icicle-comint-dynamic-complete-replacements instead of hard-coded list. +;; icicle-comint-dynamic-simple-complete: Fix for Emacs 20: map #'list over completions. +;; 2008/12/30 dadams +;; Removed: shell-hook-fn. +;; Removed fset here for: old-comint-dynamic-*, old-shell-dynamic-*, old-bbdb-complete-name. +;; icicle-comint-dynamic-simple-complete: Map #'list over candidates (for Emacs 20). +;; icicle-comint-hook-fn: +;; Don't bind icicle-comint-command here - do it in icicle-bind-other-keymap-keys. +;; 2008/12/27 dadams +;; Removed: icicle-find-file(-other-window)-w-wildcards. +;; Removed soft require of dired+.el. +;; icicle-find-file(-other-window): +;; Use just find-file* with wildcards arg, not *-w-wildcards, as action fn. +;; Bind icicle-default-value so that it won't insert the default value. +;; icicle-find-file(-other-window), icicle-choose-candidate-of-type: +;; Use nil as 3rd read-file-name arg, if not in Dired on a file name. +;; 2008/12/23 dadams +;; icicle-comint-dynamic-complete-as-filename: Bind use-dialog-box to nil. +;; 2008/12/22 dadams +;; icicle-comint-dynamic-complete-as-filename: Use INIT and PRED in read-file-name call. +;; 2008/12/21 dadams +;; Added: icicle-shell-hook-fn, (icicle|old)-comint-dynamic-complete(-filename), +;; (icicle|old)-shell-dynamic-complete-(command|filename|environment-variable), +;; icicle-comint-replace-orig-completion-fns, icicle-comint-dynamic-simple-complete, +;; icicle-comint-dynamic-complete-as-filename, +;; icicle-shell-dynamic-complete-as-(command|environment-variable). +;; Renamed: icicle-comint-send-input to icicle-comint-search-send-input, +;; icicle-comint-get-final-choice to icicle-comint-search-get-final-choice, +;; icicle-comint-get-minibuffer-input to icicle-comint-search-get-minibuffer-input. +;; Require shell.el at compile time. +;; Use fn, not var, confirm-nonexistent-file-or-buffer. Thx to Daniel Clemente. +;; 2008/12/02 dadams +;; Removed all use of icicle-file-ignore-space-prefix-flag (removed). +;; 2008/11/23 dadams +;; Updated wrt Emacs 23: +;; find-file-confirm-nonexistent-file -> confirm-nonexistent-file-or-buffer. +;; icicle-buffer*, icicle-add-buffer-candidate, icicle-choose-candidate-of-type: +;; Added confirm-nonexistent-file-or-buffer. +;; 2008/11/22 dadams +;; icicle-command-abbrev, icicle-remove-buffer-config-action, icicle-find-file-absolute*, +;; icicle-(recent|locate)-file*, icicle-describe-option-of-type, +;; icicle-(vardoc|fundoc|plist|doc), icicle-complete-keys-1, icicle-read-color: +;; Put icicle-fancy-candidates property on prompt when appropriate. +;; icicle-(find|recent|locate)-file(-absolute)(-other-window): +;; Support find-file-confirm-nonexistent-file (Emacs 23). +;; 2008/11/17 dadams +;; Added: icicle-find-first-tag-action, icicle-find-first-tag-other-window-action. +;; icicle-find(-first)-tag(-other-window), icicle-find-tag-action: Crosshairs highlighting. +;; icicle-find-first-tag(-other-window): Use icicle-find-first-tag(-other-window)-action. +;; Mention crosshairs.el in doc strings of commands that use it. +;; 2008/11/14 dadams +;; icicle-locate-file*: Use face icicle-candidate-part only for negative prefix arg. +;; 2008/11/09 dadams +;; icicle-explore: When only 1 candidate, no completion. Thx to Hannes Janetzek. +;; 2008/11/04 dadams +;; Removed compile-time require of palette.el or eyedropper.el. Thx to Andrey Zhdanov. +;; icicle-read-color: Moved soft require of palette.el or eyedropper.el to beginning. +;; Removed: icicle-generic-S-tab. +;; icicle-add-key+cmd: Removed test for icicle-generic-S-tab. +;; 2008/11/03 dadams +;; icicle-insert-for-yank: push-mark first. Thx to Fabrice Knevez. +;; Renamed: icicle-insert-kill to icicle-completing-yank, +;; icicle-yank-insert to icicle-yank-maybe-completing. +;; icicle-search: Restored binding of icicle-searching-p (somehow, accidentally removed it). +;; 2008/11/02 dadams +;; icicle-(doc|vardoc|fundoc|plist): +;; Prefix arg uses candidates cache. Tighten scope of condition-case. +;; icicle-doc: +;; Show all of fn, var, and face doc that are available. Thx to Fabrice Knevez. +;; Use multi-completion: added symbol name and type. +;; icicle-doc-action: (intern (icicle-transform-multi-completion...)), not assoc. +;; 2008/10/27 dadams +;; icicle-find(-first)-tag*: Bind case-fold-search too. +;; 2008/10/26 dadams +;; icicle-(file|directory)-list, icicle-find-file(-absolute)(-other-window), +;; icicle-(locate|recent)-file(-other-window): Bind to icicle-file-* options. +;; icicle-locate-file*, icicle-recent-file*: +;; Bind icicle-abs-file-candidates, icicle-delete-candidate-object. +;; Move init code into bindings. +;; icicle-find-first-tag*: Move init code into bindings. +;; 2008/10/24 dadams +;; Find-tag fixes. Thx to Per Nordlow. +;; icicle-find-tag: Bind completion-ignore-case also for call to icicle-explore. +;; icicle-find-tag-define-candidates-1: +;; Look for regexp followed by DEL, through eol. Move to bol, then next line. +;; icicle-explore: Call icicle-get-alist-candidate with NO-ERROR-P arg. +;; 2008/10/23 dadams +;; icicle-find-tag: Use nil for REQUIRE-MATCH in call to icicle-explore. +;; 2008/10/21 dadams +;; icicle-search-read-context-regexp: Bound icicle-candidate-(action|help)-fn to nil. +;; icicle-search-define-candidates-1: Added error message - better than generic explore msg. +;; Moved enable-recursive-minibuffers from *-search-region to *-search-region-action. +;; icicle-search-region-action: Added message if no such file. +;; 2008/10/18 dadams +;; Replaced customize-save-variable by funcall icicle-customize-save-variable-function. +;; icicle-bookmark(-other-window): Use icicle-bookmark-cleanup. Removed completion default. +;; Added: icicle-bookmark-cleanup: Select orig-window at end. Thx to Andrey Zhdanov. +;; 2008/10/17 dadams +;; Added: icicle-bookmark-cmd. +;; 2008/10/16 dadams +;; icicle-bookmark-jump-1: Fixed for Emacs 23. Thx to Andrey Zhdanov. +;; 2008/10/12 dadams +;; Added: icicle-search-ibuffer-marked, icicle-search-buff-menu-marked. +;; icicle-search-dired-marked: Removed unused let binding. +;; 2008/10/11 dadams +;; icicle-Info-index-20: Use symbol at point as default index topic. +;; 2008/10/05 dadams +;; icicle-Info-read-node-name: Use lax completion. Thx to Richard Kim. +;; 2008/09/22 dadams +;; icicle-dired-project(-other-window): +;; Map expand-file-name over absolute file names, to expand ~ in fileset entries. +;; 2008/09/20 dadams +;; icicle-find-file-absolute(-other-window): abs-file-list -> icicle-abs-file-list. +;; 2008/09/19 dadams +;; icicle-add-entry-to-saved-completion-set: +;; Use only the fileset name, not the whole fileset, in the (:fileset...) entry. +;; icicle-remove-entry-from-saved-completion-set: Rewrote. +;; Either the entry to remove or the set to remove it from can now be a fileset. +;; icicle-dired-save-marked-persistently: Added FILESETP arg, so you can save in a fileset. +;; icicle-dired-project(-other-window): Include filesets as project candidates. +;; Renamed: icicle-dired-save-marked-to-cache-file to icicle-dired-save-marked-persistently. +;; Moved icicle-kill-a-buffer to icicles-fn.el. +;; 2008/09/15 dadams +;; icicle-(add|remove)-candidate-(to|from)-saved-completion-set: Use :fileset keyword. +;; icicle-search-where-arg, icicle-search-where-arg: +;; Wrap icicle-(file|buffer)-list with save-selected-window. +;; 2008/09/14 dadams +;; Renamed: icicle-(add|remove)-candidate-(to|from)-saved-completion-set to +;; icicle-(add|remove)-entry-(to|from)-saved-completion-set. +;; icicle-add-entry-to-saved-completion-set: Treat fileset entries, not just strings. +;; icicle-(add|remove)-entry-(to|from)-saved-completion-set, +;; icicle-remove-saved-completion-set, icicle-dired-project(-other-window): +;; No default value for completing-read. +;; 2008/09/13 dadams +;; Use renamings from icicles-mcmd.el: +;; icicle-candidate-set-save-to-cache-file to icicle-candidate-set-save-persistently, +;; icicle-candidate-set-retrieve-from-cache-file to *-candidate-set-retrieve-persistent. +;; 2008/09/11 dadams +;; Added: icicle-grep-saved-file-candidates. +;; 2008/09/09 dadams +;; Added: icicle-remove-saved-set-action: No longer set minibuffer-completion-table or call +;; icicle-complete-again-update. +;; icicle-dired-save-marked-(to-(variable|cache-file)|as-project), +;; icicle-dired-project(-other-window). +;; Renamed: icicle-candidate-set-dired-marked-save(-more) to icicle-dired-save-marked(-more) +;; icicle-remove-saved-completion-set: +;; Prompt and delete cache file. Use icicle-remove-saved-set-action as action function. +;; Bind: icicle-whole-candidate-as-text-prop-p, icicle-use-candidates-only-once-flag. +;; Remove *Completions* window at end. +;; 2008/09/08 dadams +;; icicle-dired-saved-file-candidates(-other-window): +;; Don't change to relative file names - use whichever form (abs, rel) is saved. +;; icicle-find-tag-define-candidates-1: Make sure tag is not empty before (aref tag 0). +;; icicle-find-file-absolute(-other-window): +;; Use default-directory as init value and default value. +;; 2008/09/03 dadams +;; icicle-bookmark(-other-window), icicle-goto-marker-1: +;; Use crosshairs-unhighlight, not icicle-unhighlight-crosshairs+cleanup. +;; icicle-goto-marker-1: Bind orig-buff. +;; *-bookmark-jump-1, *-goto-marker-1-action, *-compilation-search-in-context-fn: +;; Use crosshairs-highlight, not icicle-highlight-crosshairs. +;; 2008/09/02 dadams +;; Added: icicle-dabbrev--abbrev-at-point. +;; icicle-dabbrev-completion: Use icicle-dabbrev--abbrev-at-point. Thx to Tomer Levin. +;; 2008/09/01 dadams +;; Added: icicle-bookmark-jump(-other-window), icicle-bookmark-jump-1. +;; Removed: icicle-bookmark-other-window-action. +;; icicle-bookmark(-other-window): Use icicle-bookmark-jump(-other-window) as action fn. +;; Clean up crosshairs highlighting at end. +;; icicle-goto-marker-1: +;; Don't bind minibuffer-exit-hook. Don't require crosshairs.el or hl-line+.el. +;; Use icicle-unhighlight-crosshairs+cleanup for the cleanup. +;; icicle-compilation-search: Don't require hl-line+.el. +;; icicle-compilation-search-in-context-fn: Use icicle-highlight-crosshairs. +;; 2008/08/31 dadams +;; icicle-goto-marker-1-action: +;; Use col-highlight-(un)highlight, not crosshairs-flash. Force redisplay. +;; Add col-highlight-unhighlight to pre-command-hook. +;; Use hl-line-highlight-now, not hl-line-flash. +;; icicle-goto-marker-1: Remove col-highlight-unhighlight from pre-command-hook at end. +;; icicle-customize-face(-other-window, icicle-execute-extended-command-1, +;; icicle-find-tag-action, icicle-insert-thesaurus-entry, icicle-apply(-list)-action, +;; icicle-search-action, icicle-tags-search, icicle-choose-anything-candidate: +;; Select window before call select-frame-set-input-focus. +;; 2008/08/25 dadams +;; icicle-find-file-absolute(-other-window), icicle-(recent|locate)-file(-other-window): +;; Use lax completion and provide WILDCARDS arg to find-file. +;; 2008/08/24 dadams +;; Use renaming from icicles-fn.el: icicle-minibuffer-contents to icicle-minibuf-input. +;; 2008/08/23 dadams +;; icicle-clear-history: Wrap default value, minibuffer-history-variable, with symbol-name. +;; 2008/08/21 dadams +;; Added: icicle-file(-other-*), icicle-find-file-absolute(-other-*). Thx to Glauber M4. +;; Soft-require bbdb-com.el at compile time. Don't require bbdb.el at load time - define +;; old-bbdb-* only if original is already defined. +;; icicle-bbdb-complete-name: Raise error if BBDB not loaded. +;; 2008/08/20 dadams +;; icicle-bbdb-complete-name, icicle-clear-current-history: Replaced ding by icicle-ding. +;; 2008/08/18 dadams +;; icicle-clear-history: +;; Moved icicle-use-candidates-only-once-flag binding to icicle-clear-history-1. +;; icicle-delete-windows: Bind icicle-inhibit-try-switch-buffer. +;; icicle-insert-kill: Bind icicle-sort-function to nil. +;; icicle-recent-file(-other-window): +;; Bind *-candidate-properties-alist and *-list-use-nth-parts to nil if no prefix arg. +;; icicle-goto(-global)-marker: +;; Bind icicle-sort-function(s-alist) differently in each - don't bind in *-goto-marker-1. +;; icicle-remove-region: Use just icicle-delete-region-from-alist as action function. +;; icicle-delete-region-from-alist: +;; Use the propertized region name, not just reg-name in the cons to delete. +;; Moved icicle-cdr-less-p to icicles-fn.el and renamed to icicle-cdr-lessp. +;; Moved icicle-remove-candidate-display-others to icicles-mcmd.el. +;; Use renamings from icicles-fn.el: icicle-complete-again-update, icicle-remove-if-not. +;; icicle-explore, icicle-find-tag, icicle-complete-keys: +;; Renamed local orig-* vars. Use explore's in *-search-(quit-or-error|cleanup|action). +;; 2008/08/14 dadams +;; icicle-apply: Handle multi-completion alist entries. +;; icicle-goto-global-marker: Treat icicle-add-buffer-name-flag: Use multi-completions. +;; icicle-marker+text: Added optional arg. Annotate text with buffer name if appropriate. +;; icicle-goto-marker-1: Pass global-ring-p to icicle-marker+text, so it can annotate. +;; 2008/08/13 dadams +;; icicle-goto-marker-1: Don't add marker to ring markers if global ring. +;; icicle-goto-marker-1-action: select-frame-set-input-focus. +;; icicle-bbdb-complete-name: let -> let* (duh!) for completing-read. +;; 2008/08/12 dadams +;; Added: icicle-goto(-global)-marker-or-(set-mark-command|pop-global-mark), +;; icicle-goto-marker-1-action (factored out from icicle-goto-marker-1). +;; icicle-goto-marker-1: +;; Add mark-marker to list of markers in ring. +;; Use icicle-goto-marker-1-action. +;; Go directly to marker if only one. Message if same as point. +;; Better test for type of ring, for error msg. +;; icicle-apply: Use icicle-explore-final-choice-full in final result (not void var). +;; Added optional arg NOMSG; bind icicle-apply-nomsg. +;; icicle-apply-action: Respect icicle-apply-nomsg. Removed vestigial cruft. +;; icicle-bbdb-complete-name: Bind icicle-bbdb-complete-name to t and use strict completion. +;; 2008/08/11 dadams +;; icicle-search-highlight-context-levels: Increase overlay priority for each context level. +;; icicle-search-highlight-all-input-matches, icicle-search-highlight-input-matches-here: +;; Made of current-input overlay higher than any context-level overlay: 204 -> 220. +;; 2008/08/10 dadams +;; Added: icicle-explore, icicle-find-tag-define-candidates (renamed old to *-1), +;; icicle-search-define-candidates (renamed old to *-1), icicle-search-cleanup, +;; icicle-(find-tag|search)-(final-act|quit-or-error). +;; Renamed: icicle-find-tag-define-candidates to icicle-find-tag-define-candidates-1, +;; icicle-search-define-candidates to icicle-search-define-candidates-1. +;; Redefined to use icicle-explore: icicle-find-tag, icicle-apply, icicle-search. +;; icicle-comint-get-final-choice: Use icicle-explore-final-choice (not icicle-search-*). +;; 2008/08/08 dadams +;; Added: icicle-goto-marker-1 (from icicle-goto-marker): +;; Use unwind-protect and minibuffer-exit-hook to unhighlight crosshairs. +;; Provide S-delete: bind icicle-delete-candidate-object. +;; Require crosshairs.el, hl-line+.el. Use crosshairs-flash. +;; icicle-goto(-global)-marker: Use icicle-goto-marker-1. +;; 2008/08/06 dadams +;; icicle-kmacro(-action): +;; Better prefix arg treatment. +;; kmacro-end-or-call-macro if still defining. +;; No-exit require-match. +;; Default value if only one. +;; Minor bug fix (extra candidate). +;; Name macros just 1, 2..., not macro #1, macro #2... +;; 2008/08/03 dadams +;; Added: icicle-clear(-current)-history(-1|-entry), icicle-apply-list-action. +;; icicle-apply: Bind icicle-all-candidates-list-action-fn to icicle-apply-list-action. +;; Renamed: icicle-all-candidates-action-fn to icicle-all-candidates-list-action-fn, +;; icicle-candidate-alternative-action-fn to icicle-candidate-alt-action-fn. +;; 2008/07/27 dadams +;; icicle-recent-file*, icicle-locate-file*: Added date multi-completion, with prefix arg. +;; Added: icicle-make-file+date-candidate. +;; 2008/07/23 dadams +;; Renamed: icicle-map(-action) to icicle-apply(-action). Added defalias for icicle-map. +;; 2008/07/21 dadams +;; Added: icicle-bbdb-complete-name. Thx to Ian Swainson. require of bbdb.el for compile. +;; 2008/07/19 dadams +;; icicle-Info-menu: Corrected regexp to pick up menu-item default, for Emacs 20. +;; 2008/07/15 dadams +;; eval-when-compile require of: anything, cookie1, etags, eyedropper/palette, yow. +;; icicle-customize-apropos-options-of-type: Typo: help-remove-duplicates -> icicle-*. +;; icicle-send-bug-report: Include emacs-version. +;; 2008/05/16 dadams +;; icicle-find-first-tag*, icicle-find-tag: Use tags-lazy-completion-table for Emacs 23. +;; 2008/04/25 dadams +;; icicle-execute-extended-command-1: +;; Add msg about binding if suggest-key-bindings. Thx to Jonathan Arkell. +;; 2008/04/14 dadams +;; icicle-pp-eval-expression: Treat negative prefix arg. +;; 2008/04/13 dadams +;; icicle-pp-eval-expression: +;; Treat prefix arg (added optional arg). +;; Respect eval-expression-debug-on-error and icicle-pp-eval-*. +;; 2008/04/09 dadams +;; icicle-apropos-(function|command), icicle-imenu-non-interactive-function-p, +;; icicle-complete-keys-help: Use fboundp, not functionp, to also pick up macros. +;; 2008/04/04 dadams +;; icicle-bookmark: Bind completion-ignore-case to bookmark-completion-ignore-case. +;; Added: icicle-bookmark-other-window(-action). +;; 2008/04/01 dadams +;; icicle-describe-option-of-type: Bind icicle-apropos-complete-match-fn to nil. +;; icicle-describe-opt-of-type-complete: +;; Moved icicle-current-completion-mode test out of icicle-delete-if-not (iterates). +;; 2008/03/31 dadams +;; icicle-locate-file(-other-window), icicle-plist, icicle-describe-option-of-type, +;; icicle-(var|fun)doc: icicle-highlight-lighter, before gather candidates. +;; icicle-plist, icicle-describe-option-of-type, icicle-vardoc, icicle-fundoc: +;; Simplified doc string and prompt wrt C-M-j. +;; 2008/03/30 dadams +;; icicle-Info-menu: Treat also pseudo-menu at Top. Thx to William Xu. +;; 2008/03/26 dadams +;; Added: icicle-Info-menu(-cmd). +;; 2008/03/22 dadams +;; icicle-other-window-or-frame: Rewrote to use icicle-select-window for all frames or one. +;; icicle-select-window: +;; Rewrote: Similar to icicle-select-frame (unique window names). All frames or one. +;; Added: icicle-select-window-by-name, icicle-make-window-alist. +;; 2008/03/19 dadams +;; Added: icicle-pp-eval-expression (old version in icicles-mcmd.el was renamed). +;; 2008/03/11 dadams +;; icicle-repeat-complex-command: Rewrote doc string. +;; 2008/03/10 dadams +;; icicle-select-frame: Rewrote to use icicle-select-frame-by-name (unique frame names). +;; icicle-choose-candidate-of-type: Use icicle-make-frame-alist, not make-frame-alist. +;; Added: icicle-select-frame-by-name, icicle-make-frame-alist. +;; 2008/03/09 dadams +;; icicle-dabbrev-completion, icicle-find-tag-define-candidates, +;; icicle-Info-build-node-completions, icicle-search, icicle-read-color: +;; Call icicle-highlight-lighter. +;; 2008/03/05 dadams +;; icicle-map: Don't inhibit sorting. +;; icicle-goto(-global)-marker: Provide sorting choices. Highlight target line. +;; Added: icicle-cdr-less-p. +;; 2008/02/26 dadams +;; Added: icicle-where-is. +;; 2008/02/23 dadams +;; icicle-lisp-complete-symbol: +;; Wrap completing-read in save-excursion, because of icicle-top-level-*-completion-flag. +;; icicle-search: Use NOWARN arg with find-file-noselect. +;; Added: icicle-tags-search. +;; Renamed: icicle-search-tag* to icicle-find-tag*, +;; icicle-find-tag(-other-window) to icicle-find-first-tag(-other-window). +;; 2008/02/21 dadams +;; icicle-Info-goto-node: Added .. node for book order. +;; Use global var icicle-Info-only-rest-of-book-p. Call icicle-Info-goto-node-1. +;; icicle-Info-read-node-name: Remove REST-P arg. +;; icicle-Info-goto-node-action: When rest-of-book-p: +;; Update node completion table and then completions, and set current candidate number. +;; Added: icicle-Info-goto-node-1, icicle-Info-build-node-completions(-fix-*). +;; 2008/02/17 dadams +;; icicle-Info-goto-node: +;; Moved let to interactive spec, and added two args. Use icicle-Info-read-node-name. +;; Negative prefix arg means completions are limited to rest of book. +;; Add icicle-Info-book-order-p to icicle-sort-functions-alist. +;; New doc string, to explain everything. +;; Added: icicle-Info-book-order-p, icicle-Info-read-node-name. +;; 2008/02/16 dadams +;; icicle-(select|remove|search)-region: +;; Removed extraneous (setq icicle-candidates-alist) in let binding. +;; 2008/02/13 dadams +;; Added: icicle-search-tag, icicle-search-tag-define-candidates, icicle-search-tag-action, +;; icicle-search-tag-help, icicle-pop-tag-mark. +;; Updated doc string of icicle-find-tag(-other-window). +;; 2008/02/08 dadams +;; icicle-compilation-search-in-context-fn: +;; Simplified and corrected. Dropped let, with-current-buffer. Narrow to whole line. +;; Different code for Emacs 22+: Set current error; call compilation-next-error-function. +;; Removed: icicle-compilation-search-hl-line. +;; icicle-compilation-search: Soft require hl-line+. +;; Don't bind next-error-hook to icicle-*-search-hl-line. +;; Renamed: icicle-directories-list to icicle-directory-list. +;; 2008/02/07 dadams +;; icicle-search-action: +;; Moved icicle-highlight-candidate-* to after icicle-search-in-context-fn call. +;; icicle-compilation-search-in-context-fn: +;; Use buffer of marker. Removed code using overlay buffer. +;; icicle-compilation-search: Bound icicle-compilation-search-hl-line as next-error-hook. +;; Added: icicle-compilation-search-hl-line. +;; 2008/02/03 dadams +;; icicle-file-list: Rewrote using icicle-define-file-command. +;; icicle-(re)set-option-*: Added boundp before user-variable-p and icicle-binary-option-p. +;; Added: icicle-directories-list. +;; 2008/01/18 dadams +;; Moved icicle-complete-keys-alist to icicles-var.el +;; 2008/01/13 dadams +;; icicle-customize-face(-other-window), icicle-face-list, icicle-read-color: +;; Use icicle-transform-multi-completion. +;; icicle-(vardoc|fundoc): Use icicle-funvardoc-action as action fn and as help fn. +;; icicle-doc: Use icicle-doc-action as action fn and as help fn. +;; Added: icicle-funvardoc-action, icicle-doc-action. +;; icicle-search-replace-search-hit: Simplified bind/restore of Icicles completion vars. +;; 2008/01/11 dadams +;; icicle-search-highlight-and-maybe-replace: +;; Don't call icicle-update-completions or icicle-display-candidates-in-Completions here. +;; icicle-search-in-context-default-fn, icicle-compilation-search-in-context-fn: +;; Call icicle-update-completions (at the end), since not done in i*-and-maybe-replace. +;; 2008/01/08 dadams +;; icicle-describe-opt-of-type-complete: Treat 3rd arg. Treat prefix completion. +;; 2008/01/06 dadams +;; icicle-read-color: Provide color help for C-M-. Added: icicle-color-help. +;; 2008/01/04 dadams +;; icicle-doc, icicle-fundoc, icicle-vardoc: Use history variable icicle-doc-history. +;; 2008/01/02 dadams +;; Added: icicle-search-dired-marked. +;; 2008/01/01 dadams +;; icicle-(buffer|face|file)-list: Reverse list, so C-! keeps order. +;; icicle-dired-saved-file-candidates(-other-window): +;; Convert candidates to relative file names before opening Dired using them. +;; Error if any candidate is not a file in directory. +;; Added: icicle-candidate-set-dired-marked-save(-more). +;; 2007/12/31 dadams +;; Added: icicle-fn-doc-minus-sig. +;; icicle-fundoc, icicle-doc: Use icicle-fn-doc-minus-sig. +;; icicle-doc: Bind icicle-transform-function, not icicle-whole-candidate-as-text-prop-p. +;; 2007/12/27 dadams +;; icicle-describe-option-of-type: +;; Bind icicle-apropos-complete-match-fn to nil to prevent automatic input match. +;; 2007/12/26 dadams +;; icicle-describe-opt-of-type-complete: Pretty-print types. Bind icicle-candidate-help-fn. +;; Added: icicle-describe-opt-action. +;; 2007/12/24 dadams +;; icicle-describe-option-of-type: +;; Rewrote for different kinds of type matching. TYPE can be a regexp or type sexp. +;; Diff prefix args for diff behaviors. Handle type inheritance and value-checking. +;; Added: icicle-describe-opt-of-type-complete. +;; 2007/12/21 dadams +;; icicle-customize-apropos-options-of-type: help-var-is-* -> icicle-var-is-*. +;; 2007/12/20 dadams +;; icicle-dired-saved-file-candidates(-*): +;; Use substitute-command-keys in error msg. Use generate-new-buffer name, not y-or-n-p. +;; 2007/12/15 dadams +;; Added: icicle-customize-apropos-options-of-type. +;; 2007/12/11 dadams +;; icicle-read-color: Don't leave out variable proxies if don't have eyedropper. +;; 2007/12/07 dadams +;; Added: icicle-describe-option-of-type. +;; icicle-doc: +;; Choose kind of doc, instead of showing all (overwriting). +;; Removed binding of icicle-candidate-properties-alist. +;; icicle-read-color: Single-quote proxies, don't wrap with `_'. +;; 2007/12/06 dadams +;; icicle-doc: Forgot to include face doc. +;; 2007/12/03 dadams +;; Renamed icicle-longest-common-match to icicle-expanded-common-match. +;; 2007/12/02 dadams +;; icicle-read-color: Include color-valued variables as proxy candidates. +;; 2007/11/30 dadams +;; icicle-command-abbrev: +;; Use only membership in icicle-proxy-candidates, not icicle-proxy-candidate property. +;; So predicate is just commandp, since proxies are not part of regular candidates. +;; icicle-command-abbrev-action: +;; Bind to save/restore: icicle-add-proxy-candidates-flag, icicle-proxy-candidates. +;; icicle-command-abbrev-command: Bind icicle-add-proxy-candidates-flag to nil, to reset. +;; 2007/11/29 dadams +;; icicle-command-abbrev: Treat icicle-add-proxy-candidates-flag, icicle-proxy-candidates. +;; icicle-read-color: Don't test icicle-add-proxy-candidates-flag. +;; 2007/11/27 dadams +;; icicle-command-abbrev: Remove icicle-proxy-candidate property in unwind-protect. +;; 2007/11/26 dadams +;; icicle-get-anything-candidates: Fixed for try-completion and test-completion cases. +;; icicle-choose-anything-candidate: Bind icicle-candidates-alist to actions (two places). +;; 2007/11/25 dadams +;; Added: icicle-command-abbrev(-action|-command|-matching-commands|-record|regexp). +;; 2007/11/24 dadams +;; icicle-execute-extended-command: Bind use-file-dialog to nil. +;; 2007/11/17 dadams +;; icicle-read-color: +;; Respect icicle-add-proxy-candidates-flag. Convert proxy multi-completions to strings. +;; 2007/11/03 dadams +;; icicle-generic-S-tab: Doc string - mention icicle-generic-S-tab-keys. +;; 2007/10/28 dadams +;; icicle-search: Don't bind icicle-expand-input-to-common-match-flag. Updated doc string. +;; icicle-search-highlight-all-input-matches: +;; Don't set icicle-search-lcm unless icicle-expand-input-to-common-match-flag. +;; icicle-search-highlight-and-maybe-replace: +;; Match the lcm if icicle-search-replace-common-match-flag is non-nil. +;; Save icicle-candidate-nb around icicle-update-completions. +;; Set icicle-candidate-nb to 0 if nil. +;; icicle-search-highlight-input-matches-here: +;; Don't delete icicle-search-refined-overlays if icicle-*-all-current-flag. +;; 2007/10/26 dadams +;; icicle-search-highlight-all-input-matches: Loop through overlays twice, to get the lcm. +;; icicle-search-highlight-input-matches-here: Highlight the lcm, if available. +;; icicle-search: Bind icicle-search-lcm. +;; 2007/10/22 dadams +;; icicle-read-color: Use special-candidate face for pseudo color candidates. +;; icicle-add-key+cmd: Don't include keys bound to undefined. +;; 2007/10/20 dadams +;; icicle-read-color, icicle-remove-color-duplicates: +;; Treat pseudo colors too (e.g. *point foreground*). +;; icicle-make-color-candidate: Added optional HEX-RGB arg. +;; 2007/10/16 dadams +;; icicle-vardoc: Prefix arg means use only user options. +;; 2007/10/14 dadams +;; Updated doc strings to reflect new icicle-act-before-cycle-flag change. +;; 2007/10/13 dadams +;; icicle-get-anything-candidates: +;; If candidates is a fn, return fn that's useful for all-completions. Filter by input. +;; icicle-choose-anything-candidate: +;; Don't sort or transform cands. Respect Anything's require-pattern and delayed +;; settings. Bind icicle-candidates-alist to candidates, if that's a function. +;; icicle-get-anything-candidates-of-type: Don't use mapcar if candidates is a function. +;; Added: icicle-get-anything-req-pat-chars, icicle-get-anything-input-delay. +;; 2007/10/06 dadams +;; icicle-choose-candidate-of-type: Added entry for file type. +;; 2007/09/25 dadams +;; icicle-doc: Bind icicle-whole-candidate-as-text-prop-p to treat full candidates. +;; 2007/09/04 dadams +;; icicle-read-color: Added optional PROMPT arg. +;; 2007/08/31 dadams +;; icicle-buffer-list: Prefix arg means only buffers visiting files are candidates. +;; icicle-search-where-arg, icicle-occur: +;; Prefix arg 99 means only buffers visiting files are candidates. +;; Added: icicle-search-choose-buffers. +;; 2007/08/27 dadams +;; icicle-search-action: Fixed for return value. Display the error message. +;; 2007/08/25 dadams +;; icicle-choose-candidate-of-type: Removed (> emacs-major-version 21) restriction. +;; 2007/08/25 dadams +;; Added: a, any, buffer, file, icicle-get-anything-(types|(default-)actions-for-type| +;; candidates-of-type|(cached-)candidates), icicle-anything(-candidate-value), +;; what-which-how, icicle-choose-anything-candidate. +;; Renamed icicle-clear-option to clear-option. +;; icicle-object-action: Treat Anything stuff. +;; Added optional type arg. Use vars icicle-object-(named|predicate)-types. +;; Move icicle-read-var-value-satisfying call here from icicle-choose-candidate-of-type. +;; icicle-choose-candidate-of-type: Create buffer if needed. +;; Protected alias definitions with icicle-define-alias-commands-flag. +;; icicle-map(-action): +;; Use icicle-whole-candidate-as-text-prop-p and new icicle-get-alist-candidate. +;; icicle-(select|remove|search)-region, icicle-search: +;; Bind/use icicle-whole-candidate-as-text-prop-p. +;; icicle-occur: Require buffer names to match existing buffers. Thx to Hadron Quark. +;; 2007/08/15 dadams +;; Added command toggle as alias for icicle-toggle-option. +;; 2007/08/09 dadams +;; Soft require kmacro. Define icicle-kmacro* if kmacro gets loaded. +;; 2007/07/27 dadams +;; icicle-search: Renamed icicle-act-first-then-navigate-p to icicle-act-before-cycle-flag. +;; 2007/07/22 dadams +;; icicle-customize-face: Added prefix arg to give vanilla completion. +;; Added: icicle-customize-face-other-window. +;; Replace standard customize-face(-other-window) by icicle-customize-face(-other-window). +;; No longer require icicles-mode.el. +;; Require cus-edit.el (not just at compile time). +;; 2007/07/08 dadams +;; Added: icicle-customize-faces. +;; icicle-customize-face: Bind icicle-all-candidates-action-fn to icicle-customize-faces. +;; 2007/06/23 dadams +;; icicle-search-read-context-regexp, icicle-search-read-word, icicle-search-property-args, +;; icicle-add-region, icicle-save-string-to-variable: +;; Use icicle-completing-read-history, not read-from-minibuffer or read-string. +;; icicle-face-list: Bound icicle-list-nth-parts-join-string etc. +;; Moved to icicles-fn.el: icicle-read-from-minibuf-nil-default. +;; 2007/06/22 dadams +;; Added: icicle-group-regexp, icicle-keyword-list, icicle-search-keywords. +;; 2007/06/21 dadams +;; icicle-plist, icicle-(var|fun)doc, icicle-region-add-buffers, icicle-search-regexp-scan, +;; icicle-search-char-property-scan: +;; Use face icicle-candidate-part, not icicle-special-candidate. +;; icicle-add-key+cmd: Highlight key side of the pair (key = binding). +;; 2007/06/18 dadams +;; Added: icicle-customize-face. +;; 2007/06/17 dadams +;; icicle-make-color-candidate: Respect icicle-WYSIWYG-Completions-flag. +;; icicle-search-action: Added priority in call to icicle-place-overlay. +;; 2007/06/12 dadams +;; icicle-execute-extended-command(-1): +;; i-e-e-c-1 prepares the new last command, but i-e-e-c sets it, at end, to this-command. +;; 2007/06/10 dadams +;; Added: icicle-comint-hook-fn, icicle-compilation-hook-fn. +;; Removed unconditional add-hooks for comint-mode-hook and compilation(minor)-mode-hook. +;; 2007/06/09 dadams +;; icicle-set-option-to-t, icicle-reset-option-to-nil, icicle-delete-windows, +;; icicle-add-buffer-candidate, icicle-remove-buffer-candidate, icicle-buffer-list, +;; icicle-remove-buffer-config, icicle-face-list, icicle-file-list, +;; icicle-remove-all-regions-in-buffer, icicle-delete-file: +;; Bind icicle-use-candidates-only-once-flag to t. +;; icicle-set-option-to-t, icicle-clear-option: Candidate vars must have value nil/non-nil. +;; icicle-search-regexp-scan: Added eobp test and empty hit-string test. +;; icicle-select-(frame|window), icicle-delete-windows: +;; Removed extra t arg to icicle-define-command. +;; 2007/06/08 dadams +;; Added icicle-find-tag(-other-window). +;; 2007/06/07 dadams +;; Renamed: icicle-font-history to icicle-font-name-history, +;; icicle-function-history to icicle-function-name-history, +;; icicle-variable-history to icicle-variable-name-history. +;; Use standard history variable if bound, else use Icicles history variable: +;; bookmark-history, color-history, color-theme-history, face-name-history, +;; font-name-history, frame-name-history, function-name-history, variable-name-history +;; 2007/06/05 dadams +;; Don't require hexrgb.el if no window system. +;; icicle-read-color: Use featurep, not require, for hexrgb. +;; icicle-make-color-candidate: Error if hexrgb is not loaded. +;; 2007/05/31 dadams +;; icicle-execute-extended-command-1: Set, don't bind this-command. +;; icicle-execute-extended-command, icicle-execute-named-keyboard-macro: +;; Simpler save and restore of last-command. +;; 2007/05/28 dadams +;; icicle-imenu: Use same prefix-arg behavior as icicle-search (search multiple...). +;; Added: icicle-imenu-(command|non-interactive-function(-p)). +;; icicle-search-highlight-context-levels: +;; Wrapped loop in condition-case. Took max-levels determination out of loop. +;; 2007/05/25 dadams +;; Added: icicle-face-list, icicle-next-single-char-property-change, +;; icicle-search-(where-arg|property-args|char-property(-scan)|overlay-property), +;; icicle-char-properties-in-buffer(s). +;; Removed: icicle-text-properties-in-buffer(s), icicle-search-text-property-scan. +;; icicle-search(-word): Use icicle-search-where-arg. +;; 2007/05/21 dadams +;; Added: icicle-search-(buffer|file|all-regions). +;; icicle-imenu: Fixed treatment of prefix arg. +;; icicle-imenu-command-p: Fix to work also with Emacs 22 and 21. +;; 2007/05/14 dadams +;; icicle-execute-extended-command-1: Error if empty command name. +;; 2007/05/12 dadams +;; icicle-imenu: Added prefix arg for search for commands and non-cmds in Emacs-Lisp mode. +;; Added: icicle-imenu-command-p. +;; 2007/05/11 dadams +;; icicle-search-define-candidates: +;; Move scan-fn-or-regexp to 4th arg from 2nd. Removed &optional. +;; Apply icicle-search-regexp-scan to args also. +;; icicle-search-regexp-scan: Treat predicate. +;; Move regexp to 3rd arg from 2nd, and add predicate arg. Removed &optional. +;; icicle-search-regexp-scan, icicle-search-text-property-scan: +;; Add lengths of temp-list and icicle-candidates-alist. +;; icicle-search-text-property(-scan): Added predicate argument. +;; icicle-search-region-action: Bind icicle-candidate-action-fn to icicle-search-action. +;; icicle-(select|search|remove)-region: Removed temp var bound to (icicle-region-sorted). +;; icicle-search: Mention predicate in no-match message. +;; 2007/05/07 dadams +;; icicle-add-buffer-config: Added history args for icicle-read-from-minibuf-nil-default. +;; 2007/05/06 dadams +;; icicle-search: Bind icicle-must-pass-predicate to icicle-search-context-match-predicate. +;; icicle-search-read-context-regexp: Don't accept an empty regexp. +;; Changed S-C- to C-S- and M-C- to C-M- in doc. +;; 2007/05/04 dadams +;; icicle-(re)set-option-to-(nil|t), icicle-toggle-option: Enable recursive minibuffers. +;; 2007/05/02 dadams +;; icicle-search-read-word: Updated doc string. +;; icicle-search: Respect icicle-search-whole-word-flag and icicle-regexp-quote-flag. +;; Single message for non-existent buffers. +;; icicle-select-region-action: Message for non-existent file. +;; Added empty defvars for Emacs 22 standard vars, to quiet byte compiler. +;; 2007/05/01 dadams +;; icicle-execute-extended-command-1: +;; Don't bind icicle-candidate-action-fn if we have already read command name. +;; icicle-search-*-scan: Fill, reverse temp list, then append to icicle-candidates-alist. +;; Added: icicle-search-word, icicle-search-read-word. +;; 2007/04/29 dadams +;; icicle-search, icicle-search-text-property, icicle-text-properties-in-buffers: +;; Allow search of multiple files. Change prefix arg accordingly. +;; 2007/04/28 dadams +;; Added: icicle-compilation-search-in-context-fn, icicle-search-in-context-default-fn, +;; icicle-search-highlight-and-maybe-replace. +;; icicle-search-action: Move code to the new functions. Use icicle-search-in-context-fn. +;; icicle-compilation-search: Rewrote. +;; No longer use compile-goto-error as icicle-search-hook. +;; Use icicle-compilation-search-in-context-fn. +;; Cannot-replace error msg if not Emacs 22, since no compilation-highlight-overlay. +;; Provide .* regexp and do not highlight - as in icicle-occur. +;; 2007/04/22 dadams +;; icicle-search: Allow for pre-bound icicle-candidate(-alternative)-action-fn. +;; icicle-search-replace-search-hit: +;; Call icicle-candidate-action-fn, not necessarily icicle-search-action. +;; 2007/04/20 dadams +;; Added: icicle-search-highlight-context-levels. Use in icicle-search-action. +;; icicle-search-highlight-cleanup: Delete icicle-search-level-overlays. +;; icicle-search: Set icicle-search-context-regexp nil if scan-fn-or-regexp is not string. +;; icicle-search-replace-fixed-case-p: Return nil if arg is nil. +;; icicle-search-read-context-regexp: Use default with read-number; protect with fboundp. +;; Added soft require of strings.el. +;; 2007/04/18 dadams +;; Added: icicle-search-replace-fixed-case-p. Use in icicle-search-action. +;; icicle-search-action: +;; Set match data to region when icicle-search-replace-whole-candidate-flag is t. +;; Don't search for icicle-search-context-regexp. +;; icicle-search-replace-match: Added fixedcase arg. +;; Use icicle-search-replace-literally-flag. +;; Use replace-match-maybe-edit (Emacs 22), not replace-match, and save and restore stuff. +;; icicle-search-replace-search-hit: +;; Use regexp-history in read-string. Use icicle-search-define-replacement. +;; 2007/04/17 dadams +;; Added: icicle-search-replace-match. Treat Emacs<22 also. Use in icicle-search-action. +;; icicle-search-replace-search-hit: Use regexp-history in read-string. +;; 2007/04/16 dadams +;; icicle-search-action: Use replace-count. +;; icicle-search: Initialize replace-count to 0. +;; 2007/04/15 dadams +;; icicle-search-action: Allow \,... etc. replacement. +;; Use query-replace-compile-replacement and replace-match, with error treatment. +;; Removed unwind-protect. Removed %s from error-msg return. +;; icicle-search: Save search string as icicle-search-context-regexp. +;; Use "%s" for error message in failure error call. +;; Updated doc string for lisp-eval replacement etc. +;; *(-all)-input-matches(-here): save-match-data around input matching. +;; icicle-search-highlight-input-matches-here: Added not eobp to loop test. +;; 2007/04/13 dadams +;; icicle-search-highlight-input-matches-here: Bound free var ov. +;; 2007/04/10 dadams +;; icicle-search-regexp-scan: +;; Use match indicated by icicle-search-context-level as context. +;; Added: icicle-search-read-context-regexp. +;; icicle-search(-region|-regexp-scan): Use icicle-search-read-context-regexp. +;; 2007/04/08 dadams +;; icicle-map-action, icicle-search-action: +;; Return nil for success, error msg for failure (it was reversed). +;; Use icicle-highlight-candidate-in-Completions. +;; icicle-map-action: Moved minibuffer frame selection to unwind-protect final clause. +;; icicle-search: Give focus to original frame, in unwinding clause (C-g). +;; Added: icicle-search-highlight-input-matches-here. +;; icicle-search-highlight-all-input-matches: Highlight all input matches in candidate. +;; icicle-search-replace-search-hit: +;; Use 0 if icicle-candidate-nb is nil. Display completions. +;; Save and restore: icicle-last-completion-command, icicle-last-input. +;; Prevent using same string as candidate for replacement. +;; icicle-search-action: Rewrote. Enable repeated replacment of input matches. +;; Save and restore icicle-candidate-nb. Wrap it around if at end. +;; Warn about empty input for whole-candidate replacement. +;; Update icicle-last-completion-candidate. Display completions. +;; 2007/04/07 dadams +;; icicle-search: Added query-replace functionality. +;; Navigate first, then act (C-next). +;; Give focus to last frame searched. +;; Bind: icicle-candidate-alternative-action-fn, icicle-inhibit-sort-p, +;; icicle-searching-p, icicle-expand-input-to-common-match-flag. +;; Bind icicle-buffer-require-match-flag to partial-match-ok in interactive spec. +;; icicle-search-action: +;; Added optional replace arg: if non-nil, then fn becomes a replace action. +;; Added: icicle-search-replace-search-hit, icicle-search-replace-candidate, +;; icicle-buffer-list: Bind all the stuff that is bound in icicle-buffer. +;; 2007/04/06 dadams +;; icicle-execute-extended-command-1: +;; Bind this-command, but only around call to cmd - don't set it. +;; 2007/04/02 dadams +;; Added: icicle-search-text-property, icicle-search-text-property-scan, +;; icicle-text-properties-in-buffer(s). +;; icicle-search: +;; Added &rest args. Updated doc string. Don't read regexp or reverse alist here. +;; Use icicle-search-define-candidates, not icicle-search-regexp-scan. +;; icicle-search-regexp-scan: Read regexp here. Reverse alist here. +;; Moved to icicles-fn.el: icicle-filter-alist, icicle-first-matching-candidate. +;; Renamed: icicle-search-region-beg-end to icicle-region-or-buffer-limits. +;; 2007/04/01 dadams +;; icicle-repeat-complex-command: +;; Remove duplicates and sort entries, but only for reading command to eval. +;; 2007/03/31 dadams +;; icicle-lisp-complete-symbol: Bind icicle-top-level-when-sole-completion-flag to t. +;; 2007/03/27 dadams +;; icicle-search: Hard-code C-next key in message. +;; icicle-search-regexp-scan: Initialize last-beg for first time. +;; 2007/03/23 dadams +;; icicle-execute-extended-command-1: +;; Don't restore last-command. Run (pre|post)-command-hook. Set, don't bind, +;; this-command. enable-recursive-minibuffers for interactive call of cmd. +;; icicle-execute-extended-command, icicle-execute-named-keyboard-macro: +;; Restore last-command at end. +;; 2007/03/20 dadams +;; icicle-execute-extended-command-1: When wrong-number-of-args, icicle-help-on-candidate. +;; 2007/03/14 dadams +;; icicle-dired-saved-file-candidates, icicle-buffer, icicle-(find|locate|recent)-file: +;; Put 200 as value of property icicle-Completions-window-max-height. +;; Added ;;;###autoload for icicle-define*. +;; 2007/03/09 dadams +;; icicle-search, icicle-map, icicle-(remove|search|select)-region, icicle-imenu, +;; icicle-occur, icicle-compilation-search: +;; Bound icicle-transform-function to nil if interactive-p. +;; icicle-comint-search: Updated doc string to mention false positives in command matching. +;; Removed eval-when-compile from requires of Icicles libraries (except icicle-mac.el). +;; 2007/03/08 dadams +;; icicle-insert-kill: Bound icicle-delete-candidate-object. +;; 2007/03/07 dadams +;; icicle-delete-windows, icicle-map-action, icicle-search-action, +;; icicle-choose-candidate-of-type, icicle-complete-keys-help: +;; Use 0, not t, as frame arg to get-buffer-window. +;; 2007/03/06 dadams +;; icicle-search, icicle-map, icicle-(remove|search|select)-region: +;; Bind icicle-inhibit-sort-p to non-nil to prevent user sorting. +;; Update doc string to mention that you cannot sort candidates. +;; icicle-(remove|search|select)-region: Sort candidates by buffer and then by tag. +;; icicle-search-region: Bound icicle-delete-candidate-object. +;; icicle-search, icicle-map: Don't add or subtract one from candidate # if use action fn. +;; icicle-search: +;; If require-match, set icicle-completion-candidates and marker to reflect final choice. +;; Renamed: icicle-get-current-candidate to icicle-get-alist-candidate. +;; Added: icicle-region-sorted, icicle-region-add-buffers. +;; 2007/03/04 dadams +;; icicle-get-current-candidate: Return nil if icicle-candidates-alist is nil. +;; 2007/03/02 dadams +;; icicle-remove-buffer-config, icicle-remove-buffer-candidate: Removed extraneous quote. +;; icicle-(find|recent)-file(-other-window): Bound icicle-delete-candidate-object. +;; 2007/02/28 dadams +;; icicle-buffer-list, icicle-color-theme: Bound icicle-delete-candidate-object. +;; 2007/02/27 dadams +;; icicle-recent-file(-other-window): Changed INITIAL-INPUT completing-read arg to nil. +;; 2007/02/25 dadams +;; Added: icicle-remove-buffer-candidate-action, icicle-remove-buffer-config-action. +;; icicle-add-buffer-candidate, icicle-bookmark, icicle-buffer-config: +;; Bound icicle-delete-candidate-object. +;; 2007/02/24 dadams +;; Added: icicle-kill-a-buffer-and-update-completions (was kill-a-buffer), +;; icicle-delete-region-from-alist. +;; icicle-delete-window: Use icicle-kill-a-buffer...-completions, not icicle-kill-a-buffer. +;; icicle-buffer(-other-window), icicle-choose-candidate-of-type: +;; Bind icicle-delete-candidate-object to icicle-kill-a-buffer. +;; Bind icicle-sort-function to self if icicle-buffer-sort-function is nil. +;; icicle-select-region: +;; Bind icicle-delete-candidate-object to icicle-delete-region-from-alist. +;; icicle-remove-region: Rewrote. +;; Use icicle-delete-region-from-alist. +;; Use icicle-remove-candidate-display-others, but don't redisplay unless completing. +;; Respect icicle-add-buffer-name-flag (append buffer names). +;; 2007/02/20 dadams +;; Added: icicle-search-region-action. Open file associated with candidate. +;; icicle-search-region: +;; Use icicle-search-region-action. Updated doc string. Bind icicle-list-*. +;; Fix default completing-read value. Respect icicle-add-buffer-name-flag. +;; icicle-select-region-action: Open file associated with candidate. +;; icicle-region-open-all-files: Ignore files that are not readable. +;; icicle-regions: Remove only non-existent buffers that are not associated with files. +;; 2007/02/19 dadams +;; Added: icicle-region-open-all-files. +;; icicle-(search|select)-region, icicle-search: Use icicle-region-open-all-files. +;; icicle-add-region: Add file name to region entry in alist. +;; icicle-select-region-action, icicle-region-help, icicle-search: +;; Updated selectors for point and mark, because of addition of file name. +;; icicle-region-help: Add file name to help message. +;; 2007/02/18 dadams +;; Added: icicle-first-matching-candidate. +;; icicle-get-current-candidate: Use icicle-first-matching-candidate, not assoc. +;; 2007/02/07 dadams +;; icicle-search-action: Make *Completions* window dedicated. Thx to Peter Povinec. +;; 2007/02/07 dadams +;; icicle-search: pop-to-buffer and raise frame. Don't select orig-window. +;; 2007/02/06 dadams +;; icicle-search, icicle-select-region, icicle-search-regexp-scan: +;; Respect icicle-add-buffer-name-flag. +;; icicle-search: Bound icicle-show-Completions-initially-flag to t. +;; Bound icicle-candidate-help-fn to icicle-search-help. +;; icicle-search-regexp-scan: nil BUFFER arg means current buffer now. +;; icicle-search-action, icicle-filter-alist: Treat multi-completion case also. +;; Added: icicle-search-help. +;; icicle-map-action, icicle-search-action: Removed unused local var, curr-cand-string. +;; icicle-select-region, icicle-remove-region, icicle-search-region: +;; Use icicle-candidates-alist, not regions-w-buffers (but bind it locally too). +;; Renamed: icicle-get-current-region-candidate to icicle-get-current-candidate. +;; icicle-region-help: Provide region limits also. +;; Added note to some doc strings that the command is for Icicle mode only. +;; 2007/02/02 dadams +;; icicle-search: Test for buffers, not buffer names, in WHERE. Thx to Peter Povinec. +;; icicle-buffer-list: Return the list of buffers. +;; 2007/01/28 dadams +;; icicle-complete-keys: +;; Bind icicle-sort-functions-alist, using icicle-command-names-alphabetic-p. +;; 2007/01/22 dadams +;; icicle-read-color: +;; Removed free var NTH-PARTS. +;; Bound icicle-list-nth-parts-join-string the same as icicle-list-join-string. +;; Remove duplicates: AliceBlue and alice blue etc.: downcase and remove whitespace. +;; Added: icicle-remove-color-duplicates. +;; Added soft require of hexrgb.el. +;; icicle-*doc, icicle-plist: Bound icicle-candidate-properties-alist. +;; 2007/01/21 dadams +;; Added: icicle-read-color, icicle-make-color-candidate. +;; 2007/01/18 dadams +;; Added: icicle-get-current-region-candidate. +;; Use current cand if cycled or `mouse-2'. Else if single match, use that. Else error. +;; icicle-remove-region, icicle-search-region, icicle-region-help: +;; Use icicle-get-current-region-candidate. +;; icicle-add-region: Added optional TAG arg and prefix arg treatment. +;; icicle-remove-region: Update completions list. Bind regions-w-buffers. +;; icicle-remove-all-regions-in-buffer: Use current buffer name as default. +;; Added: icicle-select-region-action. +;; icicle-select-region: Use icicle-select-region-action. +;; Renamed: option icicle-regions to icicle-region-alist. +;; icicle-regions: Sort entries. +;; 2007/01/17 dadams +;; icicle-filter-alist: Reversed arg order. Return alist arg if filter-keys arg is empty. +;; 2007/01/12 dadams +;; icicle-delete-window: Do icicle-remove-Completions-window if in minibuffer. +;; icicle-yank-insert: Do icicle-yank if in minibuffer. +;; icicle-(fundoc|vardoc|doc|plist): Added condition-case: protect symbols that error. +;; 2007/01/01 dadams +;; Added: icicle-(add|remove)-candidate-(to|from)-saved-completion-set. +;; icicle-add-buffer-config: Use nil, not "nil" as default, if icicle-buffer-sort is nil. +;; Use icicle-define-add-to-alist-command to define it. +;; icicle-remove-buffer-config, icicle-remove-saved-completion-set: +;; Use icicle-assoc-delete-all, not delete of assoc. +;; icicle-remove-saved-completion-set: Update display after removal. +;; Reformatted icicle-define(-file)-command, based on setup.el's lisp-indentation-hack. +;; 2006/12/25 dadams +;; Bug fix: icicle-search-action: Use icicle-filter-alist on icicle-candidates-alist. +;; icicle-(select|search)-region: Use pop-to-buffer and raise-frame, not set-buffer. +;; icicle-select-region: Activate the region. +;; 2006/12/23 dadams +;; Added: icicle-region-help. Use in icicle-*-region. +;; Added: icicle-remove-all-regions-in-buffer, icicle-remove-all-regions-action. +;; icicle-(select|search)-region: Ignore regions in non-existent buffers. +;; icicle-remove-region: Update the persistent value of icicle-regions. +;; 2006/12/22 dadams +;; Added: icicle-exchange-point-and-mark. +;; icicle-customize-icicles-group: icicles -> Icicles (group name). +;; 2006/12/18 dadams +;; icicle-object-action: Remove print arg. icicle-apply-to-* uses current-prefix-arg now. +;; 2006/12/17 dadams +;; Added: icicle-object-action, icicle-choose-candidate-of-type, +;; icicle-read-var-value-satisfying. +;; 2006/12/16 dadams +;; icicle-map-action: Bug fix: Use icicle-candidate-nb, not assoc. +;; Added: icicle-goto(-global)-marker, icicle-marker+text, icicle-markers. +;; 2006/12/10 dadams +;; Moved minibuffer and *Completions* commands to new file, icicles-mcmd.el. +;; Require icicles-opt.el. +;; icicle-buffer-list: Added final message. +;; 2006/11/26 dadams +;; icicle-search-action: Bug fix: Use icicle-candidate-nb, not assoc, to get cand+mrker. +;; icicle-*-complete-1: Bug fix: Don't set icicle-current-input to icicle-last-input if nil. +;; Renamed: icicle-search-region to icicle-search-region-beg-end. +;; Added: icicle-(add|remove|select|search)-region. +;; icicle-search: Use icicle-regions for numeric prefix arg. Updated doc string. +;; Added: icicle-Info-index-20 - thx to Tamas Patrovics. Use it in icicle-Info-index. +;; 2006/11/25 dadams +;; icicle-search: After final selection, select orig-window and give its frame input focus. +;; 2006/11/24 dadams +;; Added: icicle-ensure-overriding-map-is-bound, icicle-universal-argument, +;; icicle-universal-argument-more, icicle-negative-argument, icicle-digit-argument, +;; icicle-universal-argument-other-key, icicle-universal-argument-minus, +;; icicle-kmacro(-action). +;; icicle-dabbrev-completion: Don't stop at common root, and use lax completion. +;; Replaced icicle-select-window-or-frame by icicle-other-window-or-frame (respects C-u 0). +;; 2006/11/23 dadams +;; icicle-prefix-complete-1: Respect icicle-TAB-shows-candidates-flag. +;; icicle-execute-extended-command-1: Treat named keyboard macros too. +;; Added: icicle-execute-named-keyboard-macro. +;; 2006/11/18 dadams +;; icicle-add/update-saved-completion-set, icicle-apropos*, icicle-bookmark, +;; icicle-buffer-config, icicle-candidate-set-retrieve, icicle-candidate-set-save, +;; icicle-color-theme, icicle-comint-command, icicle-complete-thesaurus-entry, +;; icicle-customize-apropos*, icicle-delete-windows, icicle-font, icicle-frame-bg, +;; icicle-frame-fg, icicle-insert-kill, icicle-insert-string-from-variable, +;; icicle-insert-thesaurus-entry, icicle-locate-file*, icicle-map, icicle-narrow-candidates, +;; icicle-remove-buffer-config, icicle-remove-saved-completion-set, +;; icicle-reset-option-to-nil, icicle-save-string-to-variable, icicle-search, +;; icicle-select-window, icicle-set-option-to-t, icicle-toggle-option: +;; Use a specific history variable. +;; 2006/11/17 dadams +;; Added: icicle-select-(frame|window), icicle-select-window-or-frame. +;; 2006/11/10 dadams +;; icicle-mouse-candidate-action: read-event to swallow mouse up event. +;; icicle-map-action: +;; Don't use icicle-filter-alist - find string in icicle-candidates-alist. +;; Unwind-protect to reselect minibuffer frame. Don't bind case-fold-search. +;; icicle-map: enable-recursive-minibuffers. +;; 2006/11/09 dadams +;; icicle-nb-of-candidate-in-Completions: Redefined using binary search, for performance. +;; icicle-toggle-ignored-space-prefix: Update doc string to use icicle-dispatch-C-^. +;; icicle-search: +;; Bind icicle-update-input-hook unconditionally, after icicle-search-regexp-scan. +;; icicle-search-regexp-scan: Highlight up to icicle-search-highlight-threshold. +;; icicle-search-highlight-all-input-matches: +;; Only update input and highlight if icicle-search-highlight-all-current-flag. +;; icicle-search-action: +;; Don't use icicle-filter-alist - find string in icicle-candidates-alist. +;; icicle-search-highlight-cleanup: Bind inhibit-quit to t. +;; 2006/11/07 dadams +;; Added: icicle-toggle-highlight-all-current. +;; 2006/11/06 dadams +;; icicle-search-action: +;; Highlight icicle-current-input, not icicle-current-raw-input (not updated). +;; Renamed icicle-search-highlight-all-flag to icicle-search-highlight-threshold. +;; 2006/11/05 dadams +;; Added: icicle-search-regexp-scan. +;; icicle-search: +;; Added buffers arg. Updated doc string. +;; Use icicle-search-regexp-scan: Scan each buffer in buffers. +;; Add marker, not position, to icicle-candidates-alist. +;; Go to candidate in its buffer. +;; Added progress message. +;; icicle-search-action: Pop to buffer of candidate (marker) and raise frame. +;; icicle-occur: +;; Added buffers arg. Updated doc string. Call icicle-search-highlight-cleanup. +;; icicle-search-highlight-all-input-matches: set-buffer for each ov in dolist (minor opt.). +;; icicle-search-highlight-cleanup: Added progress messages. Minor optimization. +;; 2006/10/22 dadams +;; icicle-complete-keys-action: +;; Set last-nonmenu-event to non-mouse info, to ignore *Completions* click. +;; icicle-complete-keys-1: Don't use a default value for completing-read. +;; 2006/10/21 dadams +;; Added: icicle-insert-char. +;; icicle-add-key+cmd: Respect icicle-complete-keys-self-insert-flag. +;; 2006/10/20 dadams +;; icicle-map, icicle-delete-window: Corrected doc string. +;; 2006/10/16 dadams +;; icicle-add-key+cmd: Protect :enable's eval with condition-case. +;; icicle-complete-keys-1: +;; No longer use icicle-extra-candidates. +;; Use default value of .. for completing-read (except at top level). +;; icicle-complete-keys-action: Correct no-match case: must match whole and part. +;; icicle-keys+cmds-w-prefix: Add .. to icicle-complete-keys-alist unless at top level. +;; 2006/10/15 dadams +;; icicle-complete-keys: +;; Bind icicle-complete-keys-action, not icicle-complete-keys-help, to icicle-*-action-fn. +;; Bind orig-buff, orig-window, and icicle-completing-keys-p, for use elsewhere. +;; Added: icicle-complete-keys-action using code from icicle-complete-keys. +;; icicle-complete-keys-action: +;; Use orig-buff and orig-window; restore to originally selected window. +;; Error if candidate doesn't match template xxx = yyy. +;; icicle-complete-keys-1: +;; Call icicle-complete-keys-action on chosen candidate. +;; icicle-help-on-candidate: Treat key completion also. +;; Added from cus-edit+.el: custom-variable-p. +;; Moved to icicles-mode.el: icicle-select-minibuffer-contents, next-history-element. +;; Moved here from icicles-mode.el: icicle-generic-S-tab. +;; icicle-generic-S-tab (bug fix): Do not set last-command to icicle-apropos-complete. +;; Added: eval-when-compile's. +;; 2006/10/13 dadams +;; icicle-add-key+cmd: +;; Add actual key to icicle-complete-keys-alist. Thx to Stefan Monnier. +;; Don't filter out index (Imenu) keymap. +;; Treat :enable condition. +;; icicle-complete-keys-1: +;; Use actual key recorded in icicle-*-keys-alist. Don't convert to key description. +;; Treat digit-argument and negative-argument. +;; icicle-complete-keys-alist: Updated doc string for new structure. +;; 2006/10/08 dadams +;; Added: icicle-add-key+cmd, icicle-read-single-key-description. +;; Added: icicle-complete-keys-alist. +;; Use in icicle-complete-keys-1, icicle-keys+cmds-w-prefix, icicle-add-key+cmd. +;; icicle-add-key+cmd: Update binding, depending on its type (menu item etc.). +;; Push (cons candidate binding), not just candidate, onto icicle-complete-keys-alist. +;; icicle-complete-keys-1: +;; Use binding, not just command name. Call it and put it in (this|last)-command. +;; Flipped (corrected) use of icicle-key-descriptions-use-<>-flag. +;; Use icicle-read-single-key-description. +;; icicle-prefix-keys-first-p, icicle-complete-keys-1, icicle-complete-keys-help, +;; icicle-keys+cmds-w-prefix: Don't use icicle-list-*-string. +;; 2006/10/05 dadams +;; icicle-complete-keys-1: Remove icicle-special-candidate property from all candidates. +;; icicle-keys+cmds-w-prefix: +;; Intern candidate and, if local binding, put icicle-special-candidate property on it. +;; Use single string for candidate (don't use multi-completion). +;; 2006/10/03 dadams +;; icicle-complete-keys-1: Treat "..". +;; icicle-complete-keys: Updated doc string accordingly. +;; icicle-prefix-keys-first-p: ".." is less than all other strings. Don't hard-code "= ". +;; icicle-keys+cmds-w-prefix: +;; Filtered out shadowed bindings, icicle-generic-S-tab, and icicle-complete-keys. +;; Use only map-keymap & lookup-key, not accessible-keymaps, current-active-maps, +;; map-keymap. +;; 2006/10/01 dadams +;; icicle-complete-keys: Bind sort functions, to put prefix keys first, by default. +;; Set last-command, before recursing. +;; Replaced icicle-alternative-sort with icicle-toggle-alternative-sorting (new). +;; icicle-(apropos|prefix)-complete-1: +;; Ensure icicle-(current|last)-input are strings, before compare. +;; icicle-keys+cmds-w-prefix: Tolerate empty local and global maps. +;; 2006/09/30 dadams +;; Added: icicle-read-kbd-macro, icicle-edmacro-parse-keys, icicle-toggle-angle-brackets. +;; icicle-complete-keys-1, icicle-dabbrev-completion: +;; key-description -> icicle-key-description, with icicle-key-descriptions-use-<>-flag. +;; icicle-complete-keys-1: +;; read-kbd-macro -> icicle-read-kbd-macro, with icicle-key-descriptions-use-<>-flag. +;; Got rid of extra space in prompt before colon, when no prefix. +;; icicle-keys+cmds-w-prefix: Use single-key-description with icicle-*-use-<>-flag. +;; icicle-insert-key-description: +;; Change arg to a toggle, and use icicle-key-descriptions-use-<>-flag. +;; Bind icicle-candidate-set-(retrieve|save) to C-M-<, C-M->, not C-<, C->. +;; icicle-dired-saved-file-candidates*: +;; Changed doc strings and messages to use dynamic binding of icicle-candidate-set-save. +;; 2006/09/24 dadams +;; Added: icicle-complete-keys-help. +;; icicle-complete-keys: +;; Bind icicle-*-action-fn to icicle-complete-keys-help. Mention help keys in docstring. +;; icicle-complete-keys-1: +;; Set last-command to command, so completion doesn't think candidate was last-command. +;; icicle-keys+cmds-w-prefix: Provide placeholder for future use of generic characters. +;; 2006/09/23 dadams +;; icicle-complete-keys-1: +;; Error if there are no keys for the prefix. +;; Error, not self-insert-command, for key read-kbd-macro can't convert. condition-case. +;; Report error if calling cmd fails. +;; Use vconcat for recursive call. +;; Read cmd, don't intern it - it might be a lambda or byte-compiled function. +;; Remove duplicates. +;; Provide KEYS arg to call-interactively, for error reporting. +;; Don't bind icicle-must-not-match-regexp to "^Character set .*= self-insert-command". +;; icicle-keys+cmds-w-prefix: +;; Treat also local keymap and current minor maps. +;; Do nothing if keys+maps is nil. +;; Only map-keymap if the target is a keymap. +;; Use keymapp, not functionp, as the binding test. +;; Only add binding if it is a command or keymap. +;; Only add self-insert-command binding if the key is char-valid-p. +;; Use format %S, not %s for a command binding. +;; icicle-insert-key-description: Added no-angle-brackets-p arg. +;; 2006/09/22 dadams +;; icicle-complete-keys-1: +;; Filter out keys described "Character set ...= self-insert-command". +;; 2006/09/20 dadams +;; icicle-complete-keys-1: Treat self-insert-command specially. +;; 2006/09/17 dadams +;; Added: icicle-complete-keys(-1), icicle-*-keys-prefix, icicle-keys+cmds-w-prefix, +;; icicle-doc: Removed one \n from each candidate. +;; 2006/09/12 dadams +;; Renamed icicle-switch-to-minibuffer to icicle-insert-completion. +;; Added: icicle-switch-to/from-minibuffer. +;; icicle-completion-help: Keep focus in the minibuffer after displaying help. +;; 2006/09/02 dadams +;; icicle-help-on-(next|previous)-(apropos|prefix)-candidate, +;; icicle-(next|previous)-(apropos|prefix)-candidate-action: +;; Use save-selected-window, not save-window-excursion. +;; icicle-find-file*: In Dired, ignore errors picking up current-line's file name. +;; icicle-mouse-choose-completion: Error if minibuffer is not active. +;; 2006/08/27 dadams +;; icicle-abort-minibuffer-input: If minibuffer not active, just kill buffer *Completions*. +;; icicle-execute-extended-command-1, icicle-insert-thesaurus-entry, icicle-search-action: +;; Ensure orig-window is live before using it. +;; 2006/08/23 dadams +;; Added: icicle-delete-window(s). +;; Added soft require of frame-cmds.el. +;; 2006/08/22 dadams +;; icicle-execute-extended-command-1: Bind this-command, don't set it (fixes C-next). +;; icicle-help-on-candidate: If no last candidate, then reset to first matching candidate. +;; icicle-*-candidate-action, icicle-help-on-*-candidate: save-window-excursion. +;; 2006/08/20 dadams +;; icicle-find-file*: Use diredp-find-a-file* in Dired mode (Emacs 22 or later). +;; Bug fix: icicle-candidate-action: Use icicle-*-candidates, not icicle-next-*-candidate. +;; icicle-next-*-candidate(-action): Set icicle-current-completion-mode. +;; 2006/08/18 dadams +;; Added: icicle-Info-goto-node(-(action|cmd)). +;; icicle-candidate-action: If no icicle-last-completion-candidate, use first candidate. +;; 2006/08/15 dadams +;; Added: icicle-help-on-*-*-candidate,icicle-mouse-help-on-candidate. +;; No longer put icicle-candidate-action-command property on symbols (not used). +;; Added: icicle-raise-Completions-frame. +;; icicle*-candidate-action, icicle-help-on-candidate: Use icicle-raise-Completions-frame. +;; icicle-help-on-candidate: Can use it from *Completions* too now. +;; Use icicle-barf-if-outside-Completions-and-minibuffer. +;; 2006/08/13 dadams +;; Added: icicle-Info-index(-(action|cmd)). +;; 2006/08/04 dadams +;; icicle-*-complete-1, icicle-prefix-word-complete, icicle-keep-only-past-inputs: +;; Set icicle-last-completion-command to the explicit command, not this-command. +;; icicle-history: Call icicle-last-completion-command, not icicle-apropos-complete. +;; icicle-apropos-complete-1, icicle-narrow-candidates: +;; Removed binding of icicle-apropos-completing-p (not used). +;; Added: icicle-plist, icicle-remove-Completions-window, icicle-pp-eval-expression. +;; Added soft require of pp+.el. +;; icicle-exit-minibuffer, icicle-minibuffer-complete-and-exit, +;; icicle-mouse-choose-completion, icicle-abort-minibuffer-input, +;; icicle-(apropos|prefix)-complete-1, icicle-keep-only-past-inputs, +;; icicle-insert-thesaurus-entry-cand-fn: Use icicle-remove-Completions-window. +;; icicle-doc: Treat doc of faces also. +;; icicle-non-whitespace-string-p: Added doc string. +;; 2006/08/03 dadams +;; Added: +;; icicle-comint-command, icicle-insert-kill, icicle-insert-for-yank,icicle-yank-insert. +;; Bound icicle-comint-command to C-c TAB in comint-mode. +;; icicle-search, icicle-comint-search: Cleaned up doc string. +;; 2006/08/02 dadams +;; icicle-comint-search: Mention *-prompt-pattern. Thx to Kevin Rodgers. +;; icicle-insert-string-from-variable: Added more variables to the completing-read alist. +;; 2006/07/29 dadams +;; Added: icicle-dispatch-C-., toggle-icicle-search-cleanup, icicle-toggle-search-cleanup. +;; 2006/07/23 dadams +;; Added: icicle-toggle-transforming. +;; icicle-comint-search: Bind icicle-transform-function to icicle-remove-duplicates. +;; 2006/07/22 dadams +;; Added: icicle-comint-search, icicle-comint-send-input, icicle-comint-get-*-input, +;; icicle-comint-get-final-choice, icicle-search-generic. +;; icicle-search: Added require-match arg for non-interactive calls. +;; Run the hooks if no match and no match required, and if we didn't cycle. +;; Return final choice as value (not used yet). +;; icicle-insert-string-from-variable: Use buffer-local value of variable, if there is one. +;; icicle-insert-string-from-variable: +;; Make sure we use the buffer-local value of the variable, if there is one +;; Added comint-prompt-regexp to regexp list. +;; Added mode hooks for icicle-compilation-search and icicle-comint-send-input. +;; 2006/07/20 dadams +;; Renamed icicle-arrows-respect-* to icicle-cycling-respects-completion-mode-flag. +;; 2006/07/19 dadams +;; Applied patch from Damien Elmes : +;; Added: icicle-(next|previous)-context-candidate, icicle-scroll-completions. +;; icicle-switch-to-completions, icicle-switch-to-Completions-buf, +;; icicle-move-to-next-completion, icicle-map-action, icicle-search-action: +;; Use icicle-start-of-completions. +;; icicle-(apropos|prefix)-complete-1: +;; Set icicle-current-completion-type vs use icicle-arrows-respect-*-flag. +;; Use icicle-scroll-completions. +;; icicle-current-completion-in-Completions: Use point-min if no previous prop change. +;; icicle-keep-only-past-inputs: Use icicle-scroll-completions. +;; Renamed icicle-start-of-completions to icicle-start-of-candidates-in-Completions, +;; icicle-current-completion-type to icicle-current-completion-mode, +;; icicle-*-context-candidate to icicle-(next|previous)-candidate-per-mode, +;; icicle-scroll-completions to icicle-scroll-Completions. +;; icicle-(next|previous)-context-candidate: Use icicle-barf-if-outside-minibuffer. +;; icicle-scroll-Completions: Changed with-selected-window to Emacs 20 equivalent. +;; 2006/07/18 dadams +;; icicle-search: Bind completion-ignore-case to case-fold-search. +;; icicle-search-highlight-all-input-matches, icicle-search-action: +;; Put search inside condition-case, for bad regexp. +;; Added: icicle-toggle-case-sensitivity, toggle-icicle-case-sensitivity. +;; 2006/07/10 dadams +;; Added: icicle-search-region. Use in search functions. Thx to Le Wang. +;; 2006/07/08 dadams +;; icicle-search-highlight-all-input-matches: Use *-current-*, not *-current-raw-*. +;; icicle-execute-extended-command-1: +;; First try a string candidate as arg, then read it to convert it to symbol or number. +;; Reset focus back to the minibuffer, in action function. +;; 2006/07/07 dadams +;; Added: icicle-alternative-sort. +;; icicle-imenu: Show *Completions* initially for submenu choice (only). +;; icicle-execute-extended-command: +;; Echo prefix arg in prompt. Thx: *.dhcp.mdsn.wi.charter.com +;; 2006/07/06 dadams +;; Added (eval-when-compile (require 'icicles-mac)). +;; 2006/07/05 dadams +;; Renamed: icicle-current-regexp-input to icicle-current-raw-input. +;; icicle-prefix-complete-1: Don't set icicle-current-raw-input. +;; 2006/07/04 dadams +;; icicle-prefix-complete-1: No longer calculate common prefix and set current input to it. +;; Added plist entries to categorize commands: +;; icicle-(cycling|completing|candidate-action)-command. +;; icicle-(apropos|prefix)-complete-1, icicle-prefix-word-complete, +;; icicle-switch-to-Completions-buf, icicle-keep-only-past-inputs, icicle-history: +;; Use icicle-cycling-command property. +;; icicle-apropos-complete-1: Removed regexp-p arg in call to icicle-save-or-restore-input. +;; 2006/07/03 dadams +;; icicle-(apropos|prefix)-complete-1: deactivate mark after inserting current input. +;; 2006/06/18 dadams +;; icicle-apropos-complete-1, icicle-narrow-candidates: Bind icicle-apropos-completing-p. +;; 2006/06/09 dadams +;; Bug fixes: Picked up matching subdir as default dir, even if there other files match. +;; Thx to Andrey Zhdanov. +;; Empty directory not treated as a match. +;; icicle-(apropos|prefix)-complete-1: +;; If input matches an empty directory, then use that directory as the sole completion. +;; Do not expand file-name input before call icicle-file-name-*-candidates. +;; icicle-retrieve-last-input: Use insert, not icicle-insert-input (no longer used). +;; (Input backslashes reverted to slashes.) +;; 2006/06/08 dadams +;; Bug fix: Could not complete after cycling file names. Thx to Andrey Zhdanov. +;; icicle-insert-input: Use icicle-expand-file-name. +;; icicle-prefix-complete-1: +;; Expand file-name input before call icicle-file-name-prefix-candidates. +;; Expand icicle-last-completion-candidate if it is a directory name. +;; 2006/05/30 dadams +;; icicle-erase-minibuffer-or-history-element: Fix for consecutive deletions. +;; 2006/05/26 dadams +;; Added: icicle-erase-minibuffer-or-history-element. +;; 2006/05/19 dadams +;; Renamed icicle-inhibit-reminder* to icicle-reminder*. +;; icicle-narrow-candidates: Bind icicle-reminder-prompt-flag to nil, not t. +;; 2006/05/16 dadams +;; Added: icicle-kill(-a)-buffer. +;; 2006/05/15 dadams +;; Renamed: icicle-completion-nospace-flag to icicle-ignore-space-prefix-flag. +;; icicle-candidate-set-complement: Put back icicle-ignore-space-prefix-flag. +;; icicle-buffer(-other-window): Bind icicle-buffer-ignore-space-prefix-flag. +;; Added: icicle-toggle-ignored-space-prefix, toggle-icicle-ignored-space-prefix. +;; 2006/05/13 dadams +;; icicle-occur: Make icicle-search-main-regexp-others unnoticeable instead of +;; setting icicle-search-highlight-all-flag to nil. +;; icicle-candidate-set-complement: Use nil, not icicle-completion-nospace-flag. +;; Renamed: icicle-search-imenu to icicle-imenu, +;; icicle-search-imenu-in-buffer-p to icicle-imenu-in-buffer-p. +;; 2006/05/12 dadams +;; icicle-search-imenu: Remove unmatched submenus. Error if no imenu for the buffer. +;; Added: icicle-search-imenu-in-buffer-p. +;; icicle-insert-string-at-point: Use icicle-barf-if-outside-minibuffer. +;; Moved to icicles-fn.el: icicle-barf-if-outside-*. +;; Moved some commands to minibuffer-cmds section from top-level cmds section. +;; 2006/05/09 dadams +;; Added: icicle-customize-icicles-group, icicle-send-bug-report, icicle-customize-button. +;; 2006/04/30 dadams +;; Added: icicle-map, icicle-map-action. +;; icicle-filter-alist: Corrected and simplified. +;; icicle-search: Corrected cand-nb adjustment when cycle with action fns. +;; Renamed: icicle-search-action-fn to icicle-search-action, +;; icicle-search-candidates to icicle-candidates-alist. +;; 2006/04/28 dadams +;; icicle-retrieve-last-input, icicle-(apropos|prefix)-complete-1: +;; Use icicle-highlight-initial-whitespace. +;; 2006/04/25 dadams +;; icicle-completion-help: Emacs 21.3's help-insert-xref-button signature is different. +;; 2006/04/16 dadams +;; Added: icicle-search-imenu. +;; icicle-search: Bug fixes: +;; Treat completion without cycling: error or singleton go-to. +;; Only subtract one from candidate number for C- cycling, not regular cycling. +;; 2006/04/14 dadams +;; icicle-search: +;; Bug fix: Position was off by one. +;; Highlight input match inside each main regexp match (or not). +;; Bind icicle-update-input-hook and icicle-incremental-completion-flag. +;; Extract code to define icicle-search-action-fn. +;; Use icicle-search-candidates instead of local variable search-candidates. +;; Respect icicle-search-cleanup-flag. +;; Added: icicle-search-highlight-*, icicle-search-action-fn, +;; icicle-(insert|save)-text-(from|to)-variable. +;; Renamed icicle-search-refined-regexp to icicle-search-current-input. +;; 2006/04/09 dadams +;; icicle-(apropos|prefix)-complete-1: Deal with icicle-arrows-respect-*-flag. +;; Moved here from icicles-fn.el: icicle-customize-apropos*, icicle-repeat-complex-command. +;; 2006/04/07 dadams +;; icicle-search: Highlight all occurrences at once (like isearch highlight, but not lazy). +;; Error if no match for initial regexp. +;; icicle-occur: Bind icicle-search-highlight-all-flag to nil: don't highlight each line. +;; 2006/04/02 dadms +;; Added: icicle-toggle-regexp-quote, icicle-find-file*-w-wildcards. +;; icicle-find-file*: Use icicle-find-file*-w-wildcards. +;; 2006/03/31 dadams +;; icicle-search: Wrap action function with unwind-protect to select minibuffer frame. +;; Use completion-ignore-case when highlighting search hits. +;; Protect delete-overlay with overlayp. +;; Turn off region highlighting (so can see highlighting done here). +;; Removed sit-for-period argument. +;; icicle-candidate-set-save: Use prin1 instead of pp. +;; 2006/03/27 dadams +;; Added: icicle-occur. +;; icicle-search: Highlight also match of current regexp, inside that of regexp arg. +;; Use new faces icicle-search-*-regexp. +;; icicle-search, icicle-switch-to-Completions-buf, icicle-move-to-next-completion: +;; Use new, generic icicle-place-overlay. +;; Removed icicle-place-search-overlay. +;; 2006/03/26 dadams +;; icicle-search: Use icicle-search-overlay. Ensure don't match twice at same position. +;; Added regexp arg. Use 0 as sit-for default. +;; Added: icicle-place-search-overlay. +;; 2006/03/25 dadams +;; icicle-prefix-complete: Minor bug fix: Don't save try-completion if not a string. +;; icicle-candidate-set-(save|retrieve): Allow use of a variable to save/retrieve. +;; Added: icicle-candidate-set-(retrieve-from|save-to)-variable, icicle-*-no-display, +;; icicle-prefix-complete-1. +;; icicle-apropos-complete-1: Added no-display-p optional arg. +;; Use no-display-p arg in calls to icicle-display-candidates-in-Completions. +;; icicle-candidate-set-(retrieve-from|save-to)-cache-file: Pass a consp, not t. +;; icicle-candidate-set-retrieve: Don't display *Completions*. +;; 2006/03/24 dadams +;; Added icicle-delete-char. +;; 2006/03/23 dadams +;; icicle-candidate-set-define: Rewrote. Can also use at top level. +;; Error if wrong result type. Sort result. Use display-completion-list and +;; icicle-narrow-candidates (unless at top level). +;; icicle-narrow-candidates: Can call from top-level (but not interactively). +;; icicle-candidate-set-complement: Use icicle-maybe-sort-and-strip-candidates. +;; Mention in doc strings of minibuffer and *Completions* functions: where, key. +;; 2006/03/22 dadams +;; icicle-find-file*: Use default-directory as default, so opens directory on empty input. +;; icicle-prefix-complete: +;; Save icicle-current-regexp-input. +;; Set icicle-current-input to common prefix. Use it everywhere here. +;; Calls to icicle-display-candidates-in-Completions: no root arg now. +;; 2006/03/21 dadams +;; icicle-insert-input: Bug fix: Use directory of input, not default-directory. +;; Append a slash if input itself is a directory. +;; 2006/03/20 dadams +;; icicle-retrieve-last-input: Insert icicle-current-regexp-input if repeat C-l. +;; Added: icicle-insert-input. +;; 2006/03/19 dadams +;; icicle-apropos-complete-1: Call icicle-save-or-restore-input with non-nil regexp-p arg. +;; 2006/03/17 dadams +;; Added: icicle-add/update-saved-completion-set, icicle-remove-saved-completion-set, +;; icicle-retrieve-candidates-from-set. +;; Removed: icicle-cache-file. +;; icicle-candidate-set-retrieve: Read candidates set and use its cache file. +;; Enable recursive minibuffers. +;; icicle-candidate-set-save: Read candidates set and cache-file names. +;; Use icicle-add/update-saved-completion-set. +;; icicle-barf-if-outside-minibuffer: Move interactive test to calling functions. +;; icicle-files-within: Moved to icicle-fn.el. +;; 2006/03/16 dadams +;; Added: icicle*-saved-completion-set. +;; 2006/03/14 dadams +;; icicle-narrow-candidates: Handle no-catch error. Don't use icicle-completing-p. +;; icicle-candidate-set-complement: +;; Do what we do in icicle-candidate-set-retrieve: call icicle-narrow-candidates. +;; icicle-candidate-set-(retrieve|complement): Msg when display. +;; icicle-(apropos|prefix)-complete-1: +;; Removed test for last-command = icicle-candidate-set-complement. +;; 2006/03/13 dadams +;; Added: icicle-candidate-set-(retrieve-from|save-to)-cache-file. +;; icicle-candidate-set-(retrieve|save): C-u uses cache file. +;; 2006/03/12 dadams +;; Added: icicle-dired-saved-file-candidates(-other-window), icicle-locate-file*, +;; icicle-files-within. +;; 2006/03/11 dadams +;; icicle-find-file*, icicle-delete-file*: +;; Reverted to simple form (moved directory control to icicles-mac.el). +;; icicle-keep-only-past-inputs: Expand file name relative to directory of last input. +;; 2006/03/10 dadams +;; icicle-find-file*, icicle-delete-file*: Expand file name relative to dir of last input. +;; Renamed icicle-minibuffer-contents to icicle-minibuffer-contents-from-minibuffer. +;; 2006/03/09 dadams +;; icicle-barf-if-outside-*: Removed argument - use this-command instead. +;; 2006/03/08 dadams +;; icicle-bookmark: Use default value, not init value, for completing-read. +;; 2006/03/07 dadams +;; icicle-doc: Save table in minibuffer-completion-table, so can access via C-RET too. +;; icicle-insert-thesaurus-entry, icicle-*doc: +;; Removed binding of icicle-incremental-completion-flag to nil. +;; Added: icicle-barf-if-outside-(minibuffer|Completions). Use in appropriate commands. +;; Added: icicle-non-whitespace-string-p. Use in icicle-*doc. +;; 2006/03/06 dadams +;; Update doc strings of *-thesaurus*. +;; 2006/03/05 dadams +;; Added: icicle-toggle-incremental-completion, toggle-icicle-incremental-completion. +;; 2006/03/03 dadams +;; icicle-*doc: Clarified doc strings. Updated prompts. +;; Added: icicle-help-button. Use in icicle-completion-help. +;; 2006/03/02 dadams +;; icicle-insert-thesaurus-entry, icicle-complete-thesaurus-entry: +;; Use synonyms-ensure-synonyms-read-from-cache. Clarified doc strings. +;; icicle-complete-thesaurus-entry: Error if no word at point. Correct looking-at regexp. +;; 2006/03/01 dadams +;; Added: icicle-insert-thesaurus-entry, icicle-insert-thesaurus-entry-cand-fn, +;; icicle-complete-thesaurus-entry. +;; icicle-(previous|next)-(apropos|prefix)-candidate-action: Wrap in save-excursion. +;; Use icicle-clear-minibuffer instead of icicle-erase-minibuffer non-interactively. +;; icicle-erase-minibuffer: Use icicle-call-then-update-Completions. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Code: + +;; You need not load this file. It contains only documentation. + +(provide 'icicles-chg) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-chg.el ends here diff --git a/.emacs.d/icicles/icicles-cmd1.el b/.emacs.d/icicles/icicles-cmd1.el new file mode 100644 index 0000000..a6af40f --- /dev/null +++ b/.emacs.d/icicles/icicles-cmd1.el @@ -0,0 +1,6036 @@ +;;; icicles-cmd1.el --- Top-level commands for Icicles +;; +;; Filename: icicles-cmd1.el +;; Description: Top-level commands for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2010, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:25:04 2006 +;; Version: 22.0 +;; Last-Updated: Tue Jul 20 13:44:22 2010 (-0700) +;; By: dradams +;; Update #: 21254 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-cmd1.el +;; Keywords: 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', `avoid', `cl', `cus-edit', +;; `cus-face', `cus-load', `cus-start', `doremi', `easymenu', +;; `el-swank-fuzzy', `ffap', `ffap-', `frame-cmds', `frame-fns', +;; `fuzzy-match', `hexrgb', `icicles-face', `icicles-fn', +;; `icicles-mcmd', `icicles-opt', `icicles-var', `kmacro', +;; `levenshtein', `misc-fns', `mwheel', `pp', `pp+', `ring', +;; `ring+', `strings', `thingatpt', `thingatpt+', `wid-edit', +;; `wid-edit+', `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; top-level commands (and a few non-interactive functions used in +;; those commands). Library `icicles-cmd2.el' is a continuation of +;; this file (a single file for all top-level commands would be too +;; large to upload to Emacs Wiki). +;; +;; For commands to be used mainly in the minibuffer or buffer +;; *Completions*, see `icicles-mcmd.el'. +;; +;; For Icicles documentation, see `icicles-doc1.el' and +;; `icicles-doc2.el'. +;; +;; If you use the byte-compiled version of this library, +;; `icicles-cmd1.elc', in Emacs 23, then it must be byte-compiled +;; using Emacs 23. Otherwise, Icicles key completion (and perhaps +;; other things?) will not work correctly. +;; +;; Macros defined here: +;; +;; `icicle-define-bookmark-command', +;; `icicle-define-bookmark-command-1', +;; `icicle-define-bookmark-other-window-command'. +;; +;; Commands defined here - (+) means a multi-command: +;; +;; (+)`clear-option', (+)`icicle-add-buffer-candidate', +;; (+)`icicle-add-buffer-config', +;; `icicle-add-entry-to-saved-completion-set', +;; `icicle-bbdb-complete-name', (+)`icicle-bookmark', +;; (+)`icicle-bookmark-all-tags', +;; (+)`icicle-bookmark-all-tags-other-window', +;; (+)`icicle-bookmark-all-tags-regexp', +;; (+)`icicle-bookmark-all-tags-regexp-other-window', +;; (+)`icicle-bookmark-bookmark-list', +;; `icicle-bookmark-bookmark-list-narrow', +;; (+)`icicle-bookmark-cmd', (+)`icicle-bookmark-desktop', +;; `icicle-bookmark-desktop-narrow', (+)`icicle-bookmark-dired', +;; (+)`icicle-bookmark-dired-other-window', +;; `icicle-bookmark-dired-narrow', +;; (+)`icicle-bookmarked-buffer-list', +;; (+)`icicle-bookmarked-file-list', (+)`icicle-bookmark-file', +;; (+)`icicle-bookmark-file-other-window', +;; `icicle-bookmark-file-narrow', (+)`icicle-bookmark-gnus', +;; (+)`icicle-bookmark-gnus-other-window', +;; `icicle-bookmark-gnus-narrow', +;; (+)`icicle-bookmark-info-other-window', +;; `icicle-bookmark-info-narrow', `icicle-bookmark-jump', +;; `icicle-bookmark-jump-other-window', (+)`icicle-bookmark-list', +;; (+)`icicle-bookmark-local-file', +;; (+)`icicle-bookmark-local-file-other-window', +;; `icicle-bookmark-local-file-narrow', (+)`icicle-bookmark-man', +;; (+)`icicle-bookmark-man-other-window', +;; `icicle-bookmark-man-narrow', (+)`icicle-bookmark-non-file', +;; (+)`icicle-bookmark-non-file-other-window', +;; `icicle-bookmark-non-file-narrow', +;; (+)`icicle-bookmark-other-window', (+)`icicle-bookmark-region', +;; (+)`icicle-bookmark-region-other-window', +;; `icicle-bookmark-region-narrow', +;; (+)`icicle-bookmark-remote-file', +;; (+)`icicle-bookmark-remote-file-other-window', +;; `icicle-bookmark-remote-file-narrow', `icicle-bookmark-set', +;; (+)`icicle-bookmark-some-tags', +;; (+)`icicle-bookmark-some-tags-other-window', +;; (+)`icicle-bookmark-some-tags-regexp', +;; (+)`icicle-bookmark-some-tags-regexp-other-window', +;; (+)`icicle-bookmark-specific-buffers', +;; `icicle-bookmark-specific-buffers-narrow', +;; (+)`icicle-bookmark-specific-buffers-other-window', +;; (+)`icicle-bookmark-specific-files', +;; `icicle-bookmark-specific-files-narrow', +;; (+)`icicle-bookmark-specific-files-other-window', +;; (+)`icicle-bookmark-this-buffer', +;; `icicle-bookmark-this-buffer-narrow', +;; (+)`icicle-bookmark-this-buffer-other-window', +;; (+)`icicle-bookmark-url', `icicle-bookmark-url-narrow', +;; (+)`icicle-bookmark-url-other-window', (+)`icicle-bookmark-w3m', +;; (+)`icicle-bookmark-w3m-other-window', +;; `icicle-bookmark-w3m-narrow', (+)`icicle-buffer', +;; (+)`icicle-buffer-config', (+)`icicle-buffer-list', +;; (+)`icicle-buffer-other-window', `icicle-cd-for-abs-files', +;; `icicle-cd-for-loc-files', (+)`icicle-clear-history', +;; (+)`icicle-clear-current-history', (+)`icicle-color-theme', +;; `icicle-comint-dynamic-complete', +;; `icicle-comint-dynamic-complete-filename', +;; `icicle-comint-replace-by-expanded-filename', +;; (+)`icicle-command-abbrev', (+)`icicle-command-abbrev-command', +;; (+)`icicle-completing-yank', `icicle-customize-apropos', +;; `icicle-customize-apropos-faces', +;; `icicle-customize-apropos-groups', +;; `icicle-customize-apropos-options', +;; `icicle-customize-apropos-options-of-type', +;; (+)`icicle-customize-face', +;; (+)`icicle-customize-face-other-window', +;; `icicle-customize-icicles-group', `icicle-dabbrev-completion', +;; (+)`icicle-delete-file', (+)`icicle-delete-window', +;; (+)`icicle-delete-windows', (+)`icicle-directory-list', +;; (+)`icicle-dired', `icicle-dired-chosen-files', +;; `icicle-dired-chosen-files-other-window', +;; (+)`icicle-dired-other-window', `icicle-dired-project', +;; `icicle-dired-project-other-window', +;; `icicle-dired-saved-file-candidates', +;; `icicle-dired-saved-file-candidates-other-window', +;; `icicle-dired-save-marked', +;; `icicle-dired-save-marked-as-project', +;; `icicle-dired-save-marked-more', +;; `icicle-dired-save-marked-persistently', +;; `icicle-dired-save-marked-to-variable', +;; `icicle-doremi-increment-variable+', +;; `icicle-ess-complete-filename', +;; `icicle-ess-complete-object-name', +;; `icicle-ess-internal-complete-object-name', +;; `icicle-ess-R-complete-object-name', +;; (+)`icicle-execute-extended-command', +;; (+)`icicle-execute-named-keyboard-macro', (+)`icicle-face-list', +;; (+)`icicle-file', (+)`icicle-file-list', +;; (+)`icicle-file-other-window', (+)`icicle-find-file', +;; (+)`icicle-find-file-absolute', +;; (+)`icicle-find-file-absolute-other-window', +;; (+)`icicle-find-file-in-tags-table', +;; (+)`icicle-find-file-in-tags-table-other-window', +;; (+)`icicle-find-file-other-window', +;; (+)`icicle-find-file-read-only', +;; (+)`icicle-find-file-read-only-other-window', +;; (+)`icicle-find-first-tag', +;; (+)`icicle-find-first-tag-other-window', (+)`icicle-find-tag', +;; `icicle-grep-saved-file-candidates', +;; `icicle-gud-gdb-complete-command', (+)`icicle-increment-option', +;; (+)`icicle-increment-variable', (+)`icicle-insert-buffer', +;; (+)`icicle-kill-buffer', (+)`icicle-kmacro', +;; `icicle-lisp-complete-symbol', (+)`icicle-locate-file', +;; (+)`icicle-locate-file-no-symlinks', +;; (+)`icicle-locate-file-no-symlinks-other-window', +;; (+)`icicle-locate-file-other-window', +;; (+)`icicle-other-window-or-frame', `icicle-pop-tag-mark', +;; `icicle-pp-eval-expression', (+)`icicle-recent-file', +;; (+)`icicle-recent-file-other-window', +;; `icicle-recompute-shell-command-candidates', +;; (+)`icicle-remove-buffer-candidate', +;; (+)`icicle-remove-buffer-config', +;; `icicle-remove-entry-from-saved-completion-set', +;; (+)`icicle-remove-file-from-recentf-list', +;; (+)`icicle-remove-saved-completion-set', +;; `icicle-repeat-complex-command', +;; (+)`icicle-reset-option-to-nil', +;; (+)`icicle-select-bookmarked-region', (+)`icicle-select-frame', +;; `icicle-select-frame-by-name', (+)`icicle-select-window', +;; `icicle-select-window-by-name', `icicle-send-bug-report', +;; (+)`icicle-set-option-to-t', `icicle-shell-command-on-file', +;; `icicle-shell-dynamic-complete-command', +;; `icicle-shell-dynamic-complete-environment-variable', +;; `icicle-shell-dynamic-complete-filename', +;; (+)`icicle-toggle-option', (+)`icicle-yank-maybe-completing', +;; (+)`toggle'. +;; +;; Non-interactive functions defined here: +;; +;; `custom-variable-p', `icicle-binary-option-p', +;; `icicle-bookmark-cleanup', `icicle-bookmark-cleanup-on-quit', +;; `icicle-bookmark-delete-action', `icicle-bookmark-help-string', +;; `icicle-bookmark-jump-1', `icicle-clear-history-1', +;; `icicle-clear-history-entry', +;; `icicle-comint-dynamic-complete-as-filename', +;; `icicle-comint-dynamic-simple-complete', +;; `icicle-comint-replace-orig-completion-fns', +;; `icicle-command-abbrev-action', +;; `icicle-command-abbrev-matching-commands', +;; `icicle-command-abbrev-record', `icicle-command-abbrev-regexp', +;; `icicle-customize-faces', `icicle-dabbrev--abbrev-at-point', +;; `icicle-default-buffer-names', +;; `icicle-delete-file-or-directory', +;; `icicle-execute-extended-command-1', `icicle-explore', +;; `icicle-find-first-tag-action', +;; `icicle-find-first-tag-other-window-action', +;; `icicle-find-tag-action', `icicle-find-tag-define-candidates', +;; `icicle-find-tag-define-candidates-1', +;; `icicle-find-tag-final-act', `icicle-find-tag-help', +;; `icicle-find-tag-quit-or-error', `icicle-insert-for-yank', +;; `icicle-kill-a-buffer-and-update-completions', +;; `icicle-kmacro-action', (+)`icicle-locate-file-1', +;; `icicle-locate-file-action', +;; `icicle-locate-file-other-window-action', +;; `icicle-make-file+date-candidate', `icicle-make-frame-alist', +;; `icicle-make-window-alist', +;; `icicle-bookmark-propertize-candidate', +;; `icicle-pp-display-expression', +;; `icicle-remove-buffer-candidate-action', +;; `icicle-remove-buffer-config-action', +;; `icicle-remove-from-recentf-candidate-action', +;; `icicle-remove-saved-set-action', +;; `icicle-shell-dynamic-complete-as-command', +;; `icicle-shell-dynamic-complete-as-environment-variable'. +;; +;; +;; ***** NOTE: The following functions defined in `dabbrev.el' have +;; been REDEFINED HERE: +;; +;; `dabbrev-completion' - Use Icicles minibuffer completion when there +;; are multiple candidates. +;; +;; +;; ***** NOTE: The following functions defined in `bbdb-com.el' have +;; been REDEFINED HERE: +;; (BBDB is available here: http://bbdb.sourceforge.net/.) +;; +;; `bbdb-complete-name' - Use Icicles minibuffer completion when there +;; are multiple candidates. +;; +;; +;; ***** NOTE: The following functions defined in `lisp.el' have +;; been REDEFINED in Icicles: +;; +;; `lisp-complete-symbol' - Selects *Completions* window even if on +;; another frame. +;; +;; +;; ***** NOTE: The following function defined in `simple.el' has +;; been REDEFINED HERE: +;; +;; `repeat-complex-command' - Use `completing-read' to read command. +;; +;; +;; ***** NOTE: The following functions defined in `cus-edit.el' have +;; been REDEFINED HERE: +;; +;; `customize-apropos', `customize-apropos-faces', +;; `customize-apropos-groups', `customize-apropos-options' - +;; Use `completing-read' to read the regexp. +;; `customize-face', `customize-face-other-window' - Multi-commands. +;; +;; +;; 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. +;; +;; (@> "Icicles Top-Level Commands, Part 1") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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 3, 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)) ;; pushnew + ;; plus, for Emacs < 21: dolist, push +(eval-when-compile (when (>= emacs-major-version 21) (require 'recentf))) ;; recentf-mode +(eval-when-compile (require 'dabbrev)) + ;; dabbrev-case-fold-search, dabbrev-upcase-means-case-search, dabbrev--last-obarray, + ;; dabbrev--last-completion-buffer, dabbrev--last-abbreviation, dabbrev--check-other-buffers, + ;; dabbrev-case-replace, dabbrev--reset-global-variables, dabbrev--minibuffer-origin, + ;; dabbrev--find-all-expansions, dabbrev--substitute-expansion +(eval-when-compile (require 'bookmark)) + ;; bookmark-all-names, bookmark-buffer-name, bookmark-current-bookmark +(eval-when-compile (require 'comint)) + ;; comint-completion-addsuffix, comint-completion-autolist, comint-completion-fignore, + ;; comint-completion-recexact, comint-directory, comint-dynamic-complete-filename, + ;; comint-dynamic-complete-functions, comint-line-beginning-position, + ;; comint-match-partial-filename, comint-quote-filename +(eval-when-compile (require 'shell)) ;; shell-backward-command, shell-completion-execonly, + ;; shell-dynamic-complete-command, shell-dynamic-complete-environment-variable, + ;; shell-dynamic-complete-filename, shell-match-partial-variable +(eval-when-compile (require 'etags)) + ;; file-of-tag, find-tag, find-tag-default, find-tag-default-function, + ;; find-tag-marker-ring, find-tag-other-window, goto-tag-location-function, snarf-tag-function, + ;; tag-find-file-of-tag-noselect, tags-case-fold-search, + ;; tags-lazy-completion-table, tags-table-files, visit-tags-table-buffer + +;; Commented out because `synonyms.el' soft-requires Icicles. +;; (eval-when-compile (require 'synonyms nil t)) ;; (no error if not found): + ;; synonyms-ensure-synonyms-read-from-cache, synonyms-obarray +(eval-when-compile (require 'misc-cmds nil t)) ;; (no error if not found): + ;; kill-buffer-and-its-windows +(eval-when-compile (require 'bbdb nil t) (require 'bbdb-com nil t)) ;; (no error if not found): + ;; bbdb-auto-fill-function, bbdb-complete-name, bbdb-complete-name-allow-cycling, + ;; bbdb-complete-name-cleanup, bbdb-complete-name-hooks, bbdb-completion-display-record, + ;; bbdb-completion-predicate, bbdb-completion-type, bbdb-display-records-1, + ;; bbdb-dwim-net-address, bbdb-expand-mail-aliases, bbdb-extract-address-components-func, + ;; bbdb-gag-messages, bbdb-hashtable, bbdb-mapc, bbdb-pop-up-bbdb-buffer, bbdb-record-aka, + ;; bbdb-record-name, bbdb-record-net, bbdb-search-intertwingle, bbdb-string-trim +(require 'cus-edit) + ;; customize-apropos, customize-apropos-faces, customize-apropos-groups, + ;; customize-apropos-options, custom-buffer-create, custom-buffer-order-groups, customize-face, + ;; customize-face-other-window, custom-sort-items +(require 'misc-fns nil t) ;; (no error if not found): another-buffer +(require 'frame-cmds nil t) ;; (no error if not found): delete-windows-on (my version) + +(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-define-command, icicle-define-file-command, icicle-define-add-to-alist-command +(require 'icicles-mcmd) ;; icicle-yank +(require 'icicles-var) + ;; icicle-candidate-action-fn, icicle-candidate-nb, icicle-candidates-alist, + ;; icicle-completion-candidates, icicle-current-input, icicle-extra-candidates, + ;; icicle-get-alist-candidate-function, icicle-incremental-completion-p, icicle-kmacro-alist, + ;; icicle-must-match-regexp, icicle-must-not-match-regexp, icicle-must-pass-predicate, + ;; icicle-re-no-dot, icicle-saved-completion-candidates +(require 'icicles-opt) + ;; icicle-add-proxy-candidates-flag, icicle-buffer-configs, icicle-buffer-extras, + ;; icicle-buffer-ignore-space-prefix-flag, icicle-buffer-match-regexp, + ;; icicle-buffer-no-match-regexp, icicle-buffer-predicate, icicle-buffer-require-match-flag, + ;; icicle-buffer-sort, icicle-color-themes, icicle-saved-completion-sets, + ;; icicle-sort-comparer, icicle-transform-function +(require 'icicles-fn) + ;; icicle-assoc-delete-all, icicle-highlight-lighter, icicle-read-from-minibuf-nil-default + + + +;; 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 21) + (defvar eval-expression-debug-on-error)) + +(when (< emacs-major-version 22) + (defvar icicle-kmacro-alist) ; In `icicles-var.el' + (defvar kmacro-ring) ; In `kmacro.el' + (defvar read-file-name-completion-ignore-case) ; In `minibuffer.el' + (defvar recentf-list) ; In `recentf.el' + (defvar tags-case-fold-search)) ; In `etags.el' + +(when (< emacs-major-version 23) + (defvar read-buffer-completion-ignore-case)) + +(defvar bbdb-complete-name-allow-cycling) ; In `bbdb-com.el' +(defvar bbdb-extract-address-components-func) ; In `bbdb-com.el' +(defvar bbdb-expand-mail-aliases) ; In `bbdb-com.el' +(defvar bbdb-complete-name-hooks) ; In `bbdb-com.el' +(defvar bbdb-completion-display-record) ; In `bbdb.el' +(defvar bbdb-completion-type) ; In `bbdb.el' +(defvar bbdb-hashtable) ; In `bbdb.el' +(defvar bmkp-prompt-for-tags-flag) ; In `bookmark+.el' +(defvar color-theme) ; In `color-theme.el' +(defvar color-theme-initialized) ; In `color-theme.el' +(defvar ess-current-process-name) ; In `ess-inf.el' +(defvar ess-mode-syntax-table) ; In `ess-cust.el' +(defvar ess-use-R-completion) ; In `ess-cust.el' +(defvar filesets-data) ; In `filesets.el' +(defvar find-tag-default-function) ; In `etags.el' +(defvar find-tag-marker-ring) ; In `etags.el' +(defvar goto-tag-location-function) ; In `etags.el' +(defvar icicle-clear-history-hist) ; In `icicle-clear-history-1',`icicle-clear-current-history' +(defvar icicle-window-alist) ; In `icicle-select-window' +(defvar shell-completion-execonly) ; In `shell.el' +(defvar snarf-tag-function) ; In `etags.el' +(defvar w3m-current-title) ; In `w3m.el'. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Icicles Top-Level Commands, Part 1") +;;; Icicles Top-Level Commands, Part 1 . . . . . . . . . + + +;; REPLACE ORIGINAL `pp-eval-expression' defined in `pp.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; This is essentially the same as `pp-eval-expression' defined in `pp+.el'. +;; +;; 1. Read with completion, using `icicle-read-expression-map'. +;; 2. Progress message added. +;; 3. Added optional arg and insertion behavior. +;; 4. Respect `icicle-pp-eval-expression-print-length', `icicle-pp-eval-expression-print-level', +;; and `eval-expression-debug-on-error'. +;; 5. Adjusted to work in different Emacs releases. +;; +;;;###autoload +(defun icicle-pp-eval-expression (expression ; Bound to `M-:' in Icicle mode. + &optional insert-value) + "Evaluate Emacs-Lisp sexp EXPRESSION, and pretty-print its value. +Add the value to the front of the variable `values'. +With a prefix arg, insert the value into the current buffer at point. + With a negative prefix arg, if the value is a string, then insert it + into the buffer without double-quotes (`\"'). +With no prefix arg: + If the value fits on one line (frame width) show it in the echo area. + Otherwise, show the value in buffer `*Pp Eval Output*'. + +This command respects user options +`icicle-pp-eval-expression-print-length', +`icicle-pp-eval-expression-print-level', and +`eval-expression-debug-on-error'. + +Emacs-Lisp mode completion and indentation bindings are in effect. + +By default, Icicle mode remaps all key sequences that are normally +bound to `eval-expression' or `pp-eval-expression' to +`icicle-pp-eval-expression'. If you do not want this remapping, then +customize option `icicle-top-level-key-bindings'." + (interactive + (list (read-from-minibuffer "Eval: " nil icicle-read-expression-map t 'read-expression-history) + current-prefix-arg)) + (message "Evaluating...") + (if (or (not (boundp 'eval-expression-debug-on-error)) + (null eval-expression-debug-on-error)) + (setq values (cons (eval expression) values)) + (let ((old-value (make-symbol "t")) + new-value) + ;; Bind debug-on-error to something unique so that we can + ;; detect when evaled code changes it. + (let ((debug-on-error old-value)) + (setq values (cons (eval expression) values) + new-value debug-on-error)) + ;; If evaled code has changed the value of debug-on-error, + ;; propagate that change to the global binding. + (unless (eq old-value new-value) + (setq debug-on-error new-value)))) + (let ((print-length icicle-pp-eval-expression-print-length) + (print-level icicle-pp-eval-expression-print-level)) + (cond (insert-value + (message "Evaluating...done. Value inserted.") + (setq insert-value (prefix-numeric-value insert-value)) + (if (or (not (stringp (car values))) (wholenump insert-value)) + (pp (car values) (current-buffer)) + (princ (car values) (current-buffer)))) + (t (icicle-pp-display-expression (car values) "*Pp Eval Output*"))))) + + +;; REPLACE ORIGINAL in `pp.el': +;; 1. Use no `emacs-lisp-mode-hook' or `change-major-mode-hook'. +;; 2. Call `font-lock-fontify-buffer'. +;; +(defun icicle-pp-display-expression (expression out-buffer-name) + "Prettify and show EXPRESSION in a way appropriate to its length. +If a temporary buffer is needed for representation, it is named +OUT-BUFFER-NAME." + (let* ((old-show-function temp-buffer-show-function) + ;; Use this function to display the buffer. + ;; This function either decides not to display it at all + ;; or displays it in the usual way. + (temp-buffer-show-function + #'(lambda (buf) + (with-current-buffer buf + (goto-char (point-min)) + (end-of-line 1) + (if (or (< (1+ (point)) (point-max)) + (>= (- (point) (point-min)) (frame-width))) + (let ((temp-buffer-show-function old-show-function) + (old-selected (selected-window)) + (window (display-buffer buf))) + (goto-char (point-min)) ; expected by some hooks ... + (make-frame-visible (window-frame window)) + (unwind-protect + (progn (select-window window) + (run-hooks 'temp-buffer-show-hook)) + (select-window old-selected) + (message "Evaluating...done. See buffer `%s'." + out-buffer-name))) + (message "%s" (buffer-substring (point-min) (point)))))))) + (with-output-to-temp-buffer out-buffer-name + (pp expression) + (with-current-buffer standard-output + (setq buffer-read-only nil) + (let ((emacs-lisp-mode-hook nil) + (change-major-mode-hook nil)) + (emacs-lisp-mode)) + (set (make-local-variable 'font-lock-verbose) nil) + (font-lock-fontify-buffer))))) + +;;;###autoload +(defun icicle-shell-command-on-file (file) + "Read a shell command and invoke it, passing FILE as an argument." + (dired-run-shell-command + (dired-shell-stuff-it (icicle-read-shell-command (format "! on `%s': " file)) (list file) nil))) + +;;;###autoload +(defun icicle-recompute-shell-command-candidates (&optional savep) + "Update option `icicle-shell-command-candidates-cache'. +Recompute the available shell commands using your search path. +Return the new option value. +With a prefix argument, the updated option is saved persistently. + +If the value of option `icicle-guess-commands-in-path' is not `load', +then turning on Icicle mode (again) resets the cache value to (). +If the value of `icicle-guess-commands-in-path' is `first-use', then +the cache is updated when you next use it, but it is not saved." + (interactive "P") + (setq icicle-shell-command-candidates-cache (icicle-compute-shell-command-candidates)) + (when savep (funcall icicle-customize-save-variable-function + 'icicle-shell-command-candidates-cache + icicle-shell-command-candidates-cache)) + icicle-shell-command-candidates-cache) + + +;; REPLACE ORIGINAL `comint-dynamic-complete' defined in `comint.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses Icicles completion when there are multiple candidates. +;; +;;;###autoload +(defun icicle-comint-dynamic-complete () ; Bound to `TAB' in Comint (and Shell) mode. + "Dynamically perform completion at point. +Calls the functions in `comint-dynamic-complete-functions', but with +Icicles functions substituted, to perform completion until a function +returns non-nil, at which point completion is assumed to have +occurred. + +Uses Icicles completion." + (interactive) + ;; Need a symbol for `run-hook-with-args-until-success', so bind one. + (let ((hook (icicle-comint-replace-orig-completion-fns))) + (run-hook-with-args-until-success 'hook))) + +(defun icicle-comint-replace-orig-completion-fns () + "Return `comint-dynamic-complete-functions', but with Icicles functions." + (let ((old comint-dynamic-complete-functions) + (new ()) + pair) + (dolist (fn old) + (if (setq pair (assoc fn icicle-comint-dynamic-complete-replacements)) + (push (eval (cadr pair)) new) + (push fn new))) + (nreverse new))) + +;;;###autoload +(defun icicle-comint-dynamic-complete-filename () + "Dynamically complete the filename at point. +Completes if after a filename. See `comint-match-partial-filename' and +`icicle-comint-dynamic-complete-as-filename'. +This function is similar to `comint-replace-by-expanded-filename', except that +it won't change parts of the filename already entered in the buffer; it just +adds completion characters to the end of the filename. A completions listing +may be shown in a help buffer if completion is ambiguous. + +Completion is dependent on the value of `comint-completion-addsuffix', +`comint-completion-recexact' and `comint-completion-fignore', and the timing of +completions listing is dependent on the value of `comint-completion-autolist'. + +Returns t if successful. + +Uses Icicles completion." + (interactive) + (when (comint-match-partial-filename) + (unless (window-minibuffer-p (selected-window)) (message "Completing file name...")) + (icicle-comint-dynamic-complete-as-filename))) + +(defun icicle-comint-dynamic-complete-as-filename () + "Dynamically complete at point as a filename. +See `icicle-comint-dynamic-complete-filename'. +Returns t if successful." + (let* ((completion-ignore-case (if (boundp 'read-file-name-completion-ignore-case) + read-file-name-completion-ignore-case + (memq system-type '(ms-dos windows-nt cygwin)))) + (completion-ignored-extensions comint-completion-fignore) + (minibuffer-p (window-minibuffer-p (selected-window))) + (success t) + (dirsuffix (cond ((not comint-completion-addsuffix) "") + ((not (consp comint-completion-addsuffix)) "/") + (t (car comint-completion-addsuffix)))) + (filesuffix (cond ((not comint-completion-addsuffix) "") + ((not (consp comint-completion-addsuffix)) " ") + (t (cdr comint-completion-addsuffix)))) + (filename (comint-match-partial-filename)) + (filename-beg (if filename (match-beginning 0) (point))) + (filename-end (if filename (match-end 0) (point))) + (filename (or filename "")) + (filedir (file-name-directory filename)) + (filenondir (file-name-nondirectory filename)) + (directory (if filedir (comint-directory filedir) default-directory)) + (completion (file-name-completion filenondir directory))) + (cond ((null completion) + (if minibuffer-p + (minibuffer-message (format " [No completions of `%s']" filename)) + (message "No completions of `%s'" filename)) + (setq success nil)) + ((eq completion t) ; Already completed: "the-file". + (insert filesuffix) + (unless minibuffer-p (message "Sole completion"))) + ((string-equal completion "") ; A directory: "dir/" - complete it. + (condition-case nil + (let* ((icicle-show-Completions-initially-flag t) + (icicle-incremental-completion-p 'display) + (icicle-top-level-when-sole-completion-flag t) + (choice + (save-excursion + (save-window-excursion (read-file-name "Complete: " directory nil t))))) + (when (and choice (not (string= choice directory))) + (insert (comint-quote-filename + (file-name-nondirectory (directory-file-name choice)))) + (insert (if (file-directory-p choice) dirsuffix filesuffix)))) + (error nil))) + (t ; COMPLETION is the common prefix string. + (let ((file (concat (file-name-as-directory directory) completion)) + (use-dialog-box nil)) ; Inhibit use of open-file dialog box if called from menu. + ;; Insert completion. The completion string might have a different case from + ;; what's in the prompt, if `read-file-name-completion-ignore-case' is non-nil. + (delete-region filename-beg filename-end) + (if filedir (insert (comint-quote-filename filedir))) + (insert (comint-quote-filename (directory-file-name completion))) + (cond ((symbolp (file-name-completion completion directory)) + ;; We inserted a unique completion. Add suffix. + (insert (if (file-directory-p file) dirsuffix filesuffix)) + (unless minibuffer-p (message "Completed"))) + ((and comint-completion-recexact comint-completion-addsuffix + (string-equal filenondir completion) + (file-exists-p file)) + ;; It's not unique, but user wants shortest match. + (insert (if (file-directory-p file) dirsuffix filesuffix)) + (unless minibuffer-p (message "Completed shortest"))) + ((or comint-completion-autolist (string-equal filenondir completion)) + (condition-case nil ; It's not unique. Let user choose a completion. + (let* ((icicle-show-Completions-initially-flag t) + (icicle-incremental-completion-p 'display) + (icicle-top-level-when-sole-completion-flag t) + (choice + (save-excursion + (save-window-excursion + (read-file-name + "Complete: " directory completion nil completion + (and (> emacs-major-version 21) + #'(lambda (f) (string-match completion f)))))))) + (when choice + (delete-backward-char (length completion)) + (insert (comint-quote-filename + (file-name-nondirectory (directory-file-name choice)))) + (insert (if (file-directory-p choice) dirsuffix filesuffix)))) + (error nil))) + (t (unless minibuffer-p (message "Partially completed"))))))) + success)) + +;;;###autoload +(defun icicle-shell-dynamic-complete-command () + "Dynamically complete the command at point. +Similar to `icicle-comint-dynamic-complete-filename', but this +searches `exec-path' (minus the trailing Emacs library path) for +completion candidates. Note that this may not be the same as the +shell's idea of the path. + +Completion is dependent on the value of `shell-completion-execonly', +plus those that effect file completion. +See `icicle-shell-dynamic-complete-as-command'. + +Returns t if successful. + +Uses Icicles completion." + (interactive) + (let ((filename (comint-match-partial-filename))) + (if (and filename + (save-match-data (not (string-match "[~/]" filename))) + (eq (match-beginning 0) (save-excursion (shell-backward-command 1) (point)))) + (prog2 (unless (window-minibuffer-p (selected-window)) + (message "Completing command name...")) + (icicle-shell-dynamic-complete-as-command))))) + +(defun icicle-shell-dynamic-complete-as-command () + "Dynamically complete text at point as a command. +See `icicle-shell-dynamic-complete-filename'. +Return t if successful." + (let* ((filename (or (comint-match-partial-filename) "")) + (filenondir (file-name-nondirectory filename)) + (path-dirs (cdr (reverse exec-path))) + (cwd (file-name-as-directory (expand-file-name default-directory))) + (ignored-extensions + (and comint-completion-fignore + (mapconcat #'(lambda (x) (concat (regexp-quote x) "$")) + comint-completion-fignore "\\|"))) + (dir "") + (comps-in-dir ()) + (file "") + (abs-file-name "") + (completions ())) + (while path-dirs ; Go thru each dir in the search path, finding completions. + (setq dir (file-name-as-directory (comint-directory (or (car path-dirs) "."))) + comps-in-dir (and (file-accessible-directory-p dir) + (file-name-all-completions filenondir dir))) + (while comps-in-dir ; Go thru each completion, to see whether it should be used. + (setq file (car comps-in-dir) + abs-file-name (concat dir file)) + (when (and (not (member file completions)) + (not (and ignored-extensions (string-match ignored-extensions file))) + (or (string-equal dir cwd) (not (file-directory-p abs-file-name))) + (or (null shell-completion-execonly) (file-executable-p abs-file-name))) + (setq completions (cons file completions))) + (setq comps-in-dir (cdr comps-in-dir))) + (setq path-dirs (cdr path-dirs))) + (let ((success (let ((comint-completion-addsuffix nil) + (icicle-candidate-help-fn + #'(lambda (cand) + (shell-command (concat "apropos " (shell-quote-argument cand)) + "*Help*")))) + (icicle-comint-dynamic-simple-complete filenondir completions)))) + (when (and (memq success '(sole shortest)) comint-completion-addsuffix + (not (file-directory-p (comint-match-partial-filename)))) + (insert " ")) + success))) + +;;;###autoload +(defun icicle-comint-replace-by-expanded-filename () + "`comint-replace-by-expanded-filename', but uses Icicles completion. +Dynamically complete, expand, and canonicalize the filename at point." + (interactive) + (let ((filename (comint-match-partial-filename))) + (when filename + (replace-match (expand-file-name filename) t t) + (icicle-comint-dynamic-complete-filename)))) + +(defun icicle-comint-dynamic-simple-complete (stub candidates) + "Dynamically complete STUB from CANDIDATES list. +Inserts completion characters at point by completing STUB from the +strings in CANDIDATES. Uses Icicles completion if completion is +ambiguous. + +Returns nil if no completion was inserted. +Returns `sole' if completed with the only completion match. +Returns `shortest' if completed with the shortest of the completion matches. +Returns `partial' if completed as far as possible with the completion matches. +Returns `listed' if a completion listing was shown. + +See also `icicle-comint-dynamic-complete-filename'." + (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) + (minibuffer-p (window-minibuffer-p (selected-window))) + (suffix (cond ((not comint-completion-addsuffix) "") + ((not (consp comint-completion-addsuffix)) " ") + (t (cdr comint-completion-addsuffix)))) + (candidates (mapcar #'list candidates)) + (completions (all-completions stub candidates))) + (cond ((null completions) + (if minibuffer-p + (minibuffer-message (format " [No completions of `%s']" stub)) + (message "No completions of `%s'" stub)) + nil) + ((= 1 (length completions)) + (let ((completion (car completions))) + (if (string-equal completion stub) + (unless minibuffer-p (message "Sole completion")) + (insert (substring completion (length stub))) + (unless minibuffer-p (message "Completed"))) + (insert suffix) + 'sole)) + (t ; There's no unique completion. + (let ((completion (try-completion stub candidates))) + ;; Insert the longest substring. + (insert (substring completion (length stub))) + (cond ((and comint-completion-recexact comint-completion-addsuffix + (string-equal stub completion) + (member completion completions)) + (insert suffix) ; User wants shortest match. + (unless minibuffer-p (message "Completed shortest")) + 'shortest) + ((or comint-completion-autolist (string-equal stub completion)) + (condition-case nil ; Let user choose a completion. + (let* ((icicle-show-Completions-initially-flag t) + (icicle-incremental-completion-p 'display) + (icicle-top-level-when-sole-completion-flag t) + (choice (save-excursion + (completing-read "Complete: " (mapcar #'list completions) + nil t nil nil completion)))) + (when choice + (delete-backward-char (length completion)) + (insert choice suffix))) + (error nil)) + 'listed) + (t + (unless minibuffer-p (message "Partially completed")) + 'partial))))))) + +;;;###autoload +(defun icicle-shell-dynamic-complete-filename () + "Dynamically complete the filename at point. +Completes only if point is at a suitable position for a filename +argument." + (interactive) + (let ((opoint (point)) + (beg (comint-line-beginning-position))) + (when (save-excursion + (goto-char (if (re-search-backward "[;|&]" beg t) (match-end 0) beg)) + (re-search-forward "[^ \t][ \t]" opoint t)) + (icicle-comint-dynamic-complete-as-filename)))) + +;;;###autoload +(defun icicle-shell-dynamic-complete-environment-variable () + "`shell-dynamic-complete-environment-variable' but uses Icicles completion." + (interactive) + (require 'shell) + (let ((variable (shell-match-partial-variable))) + (if (and variable (string-match "^\\$" variable)) + (prog2 (unless (window-minibuffer-p (selected-window)) + (message "Completing variable name...")) + (icicle-shell-dynamic-complete-as-environment-variable))))) + +(defun icicle-shell-dynamic-complete-as-environment-variable () + "`shell-dynamic-complete-as-environment-variable' but uses Icicles completion." + (require 'shell) + (let* ((var (or (shell-match-partial-variable) "")) + (variable (substring var (or (string-match "[^$({]\\|$" var) 0))) + (variables (mapcar #'(lambda (x) (substring x 0 (string-match "=" x))) + process-environment)) + (addsuffix comint-completion-addsuffix) + (comint-completion-addsuffix nil) + (success (icicle-comint-dynamic-simple-complete variable variables))) + (if (memq success '(sole shortest)) + (let* ((var (shell-match-partial-variable)) + (variable (substring var (string-match "[^$({]" var))) + (protection (cond ((string-match "{" var) "}") + ((string-match "(" var) ")") + (t ""))) + (suffix (cond ((null addsuffix) "") + ((file-directory-p + (comint-directory (getenv variable))) "/") + (t " ")))) + (insert protection suffix))) + success)) + +;;;###autoload +(defun icicle-ess-complete-object-name (&optional listcomp) + "`ess-complete-object-name', but uses Icicles completion. +Complete `ess-language' object preceding point. +This is `icicle-ess-R-complete-object-name' if `ess-use-R-completion', +and `icicle-ess-internal-complete-object-name' otherwise." + (interactive "P") + (if ess-use-R-completion + (icicle-ess-R-complete-object-name) + (icicle-ess-internal-complete-object-name listcomp))) + +;;;###autoload +(defun icicle-ess-internal-complete-object-name (&optional listcomp) + "`ess-internal-complete-object-name', but uses Icicles completion. +Complete `ess-language' object preceding point." + (interactive "P") + (ess-make-buffer-current) + (if (memq (char-syntax (preceding-char)) '(?w ?_)) + (let* ((comint-completion-addsuffix nil) + (end (point)) + (buffer-syntax (syntax-table)) + (beg (unwind-protect + (save-excursion + (set-syntax-table ess-mode-syntax-table) + (backward-sexp 1) + (point)) + (set-syntax-table buffer-syntax))) + (full-prefix (buffer-substring beg end)) + (pattern full-prefix) + (listname ; See if we're indexing a list with `$' + (and (string-match "\\(.+\\)\\$\\(\\(\\sw\\|\\s_\\)*\\)$" full-prefix) + (setq pattern (if (not (match-beginning 2)) + "" + (substring full-prefix (match-beginning 2) (match-end 2)))) + (substring full-prefix (match-beginning 1) (match-end 1)))) + (classname ; Are we trying to get a slot via `@' ? + (and (string-match "\\(.+\\)@\\(\\(\\sw\\|\\s_\\)*\\)$" full-prefix) + (setq pattern (if (not (match-beginning 2)) + "" + (substring full-prefix (match-beginning 2) (match-end 2)))) + (progn (ess-write-to-dribble-buffer (format "(ess-C-O-Name : slots..) : patt=%s" + pattern)) + (substring full-prefix (match-beginning 1) (match-end 1))))) + (components + (if listname + (ess-object-names listname) + (if classname + (ess-slot-names classname) + ;; Default case: It hangs here when options (error=recoves): + (ess-get-object-list ess-current-process-name))))) + ;; Return non-nil to prevent history expansions + (or (icicle-comint-dynamic-simple-complete pattern components) 'none)))) + +(defun icicle-ess-complete-filename () + "`ess-complete-filename', but uses Icicles completion. +Do file completion only within strings, or when `!' call is used." + (if (comint-within-quotes + (1- (process-mark (get-buffer-process (current-buffer)))) (point)) + (progn (if (featurep 'xemacs) + (icicle-comint-dynamic-complete-filename) ; Work around XEmacs bug. GNU Emacs and + (icicle-comint-replace-by-expanded-filename)) ; a working XEmacs return t in a string + t))) + +;;;###autoload +(defun icicle-ess-R-complete-object-name () + "`ess-R-complete-object-name', but uses Icicles completion. +Completion in R." + (interactive) + (ess-make-buffer-current) + (let* ((comint-completion-addsuffix nil) + (beg-of-line (save-excursion (comint-bol nil) (point))) + (end-of-line (point-at-eol)) + (line-buffer (buffer-substring beg-of-line end-of-line)) + (NS (if (ess-current-R-at-least '2.7.0) + "utils:::" + "rcompgen:::")) + (token-string ; Setup, including computation of the token + (progn + (ess-command (format (concat NS ".assignLinebuffer('%s')\n") line-buffer)) + (ess-command (format (concat NS ".assignEnd(%d)\n") (- (point) beg-of-line))) + (car (ess-get-words-from-vector (concat NS ".guessTokenFromLine()\n"))))) + (possible-completions ; Compute and retrieve possible completions + (progn + (ess-command (concat NS ".completeToken()\n")) + (ess-get-words-from-vector (concat NS ".retrieveCompletions()\n"))))) + (or (icicle-comint-dynamic-simple-complete token-string possible-completions) 'none))) + +;;;###autoload +(defun icicle-gud-gdb-complete-command (&optional command a b) + "`gud-gdb-complete-command', but uses Icicles completion. +Perform completion on the GDB command preceding point." + (interactive) + (if command + (setq command (concat "p " command)) ; Used by gud-watch in mini-buffer. + (let ((end (point))) ; Used in GUD buffer. + (setq command (buffer-substring (comint-line-beginning-position) end)))) + (let* ((command-word + ;; Find the word break. This match will always succeed. + (and (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command) + (substring command (match-beginning 2)))) + (complete-list + (gud-gdb-run-command-fetch-lines (concat "complete " command) + (current-buffer) + ;; From string-match above. + (match-beginning 2)))) + ;; Protect against old versions of GDB. + (and complete-list + (string-match "^Undefined command: \"complete\"" (car complete-list)) + (error "This version of GDB doesn't support the `complete' command")) + ;; Sort the list like readline. + (setq complete-list (sort complete-list (function string-lessp))) + ;; Remove duplicates. + (let ((first complete-list) + (second (cdr complete-list))) + (while second + (if (string-equal (car first) (car second)) + (setcdr first (setq second (cdr second))) + (setq first second + second (cdr second))))) + ;; Add a trailing single quote if there is a unique completion + ;; and it contains an odd number of unquoted single quotes. + (and (= (length complete-list) 1) + (let ((str (car complete-list)) + (pos 0) + (count 0)) + (while (string-match "\\([^'\\]\\|\\\\'\\)*'" str pos) + (setq count (1+ count) + pos (match-end 0))) + (and (= (mod count 2) 1) + (setq complete-list (list (concat str "'")))))) + ;; Let comint handle the rest. + (icicle-comint-dynamic-simple-complete command-word complete-list))) + + +;; REPLACE ORIGINAL `dabbrev-completion' defined in `dabbrev.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; You can complete from an empty abbrev also. +;; Uses Icicles completion when there are multiple candidates. +;; +(when (and (fboundp 'dabbrev-completion) (not (fboundp 'old-dabbrev-completion))) +(defalias 'old-dabbrev-completion (symbol-function 'dabbrev-completion))) + +;;;###autoload +(defun icicle-dabbrev-completion (&optional arg) ; Bound to `C-M-/' globally. + "Completion on current word. +Like \\[dabbrev-expand], but finds all expansions in the current buffer +and presents suggestions for completion. + +With a prefix argument, it searches all buffers accepted by +`dabbrev-friend-buffer-function', to find the completions. + +If the prefix argument is 16 (which comes from `C-u C-u'), then it +searches *ALL* buffers. + +With no prefix argument, it reuses an old completion list +if there is a suitable one already." + (interactive "*P") + (unless (featurep 'dabbrev) + (unless (require 'dabbrev nil t) (error "Library `dabbrev' not found")) + (icicle-mode 1)) ; Redefine `dabbrev-completion' to Icicles version. + (dabbrev--reset-global-variables) + (let* ((dabbrev-check-other-buffers (and arg t)) ; Must be t + (dabbrev-check-all-buffers (and arg (= (prefix-numeric-value arg) 16))) + (abbrev (icicle-dabbrev--abbrev-at-point)) + (ignore-case-p (and (if (eq dabbrev-case-fold-search 'case-fold-search) + case-fold-search + dabbrev-case-fold-search) + (or (not dabbrev-upcase-means-case-search) + (string= abbrev (downcase abbrev))))) + (my-obarray dabbrev--last-obarray) + init) + ;; If new abbreviation to expand, then expand it. + (save-excursion + (unless (and (null arg) + my-obarray + (or (eq dabbrev--last-completion-buffer (current-buffer)) + (and (window-minibuffer-p (selected-window)) + (eq dabbrev--last-completion-buffer (dabbrev--minibuffer-origin)))) + dabbrev--last-abbreviation + (>= (length abbrev) (length dabbrev--last-abbreviation)) + (string= dabbrev--last-abbreviation + (substring abbrev 0 (length dabbrev--last-abbreviation))) + (setq init (try-completion abbrev my-obarray))) + (setq dabbrev--last-abbreviation abbrev) + (let ((completion-list (dabbrev--find-all-expansions abbrev ignore-case-p)) + (completion-ignore-case ignore-case-p)) + ;; Make an obarray with all expansions + (setq my-obarray (make-vector (length completion-list) 0)) + (unless (> (length my-obarray) 0) + (error "No dynamic expansion for \"%s\" found%s" abbrev + (if dabbrev--check-other-buffers "" " in this-buffer"))) + (dolist (string completion-list) + (cond ((or (not ignore-case-p) (not dabbrev-case-replace)) + (intern string my-obarray)) + ((string= abbrev (icicle-upcase abbrev)) + (intern (icicle-upcase string) my-obarray)) + ((string= (substring abbrev 0 1) (icicle-upcase (substring abbrev 0 1))) + (intern (capitalize string) my-obarray)) + (t (intern (downcase string) my-obarray)))) + (setq dabbrev--last-obarray my-obarray + dabbrev--last-completion-buffer (current-buffer) + ;; Find the expanded common string. + init (try-completion abbrev my-obarray))))) + ;; Let the user choose between the expansions + (unless (stringp init) (setq init abbrev)) + (cond + ((and (not (string-equal init "")) + (not (string-equal (downcase init) (downcase abbrev))) + (<= (length (all-completions init my-obarray)) 1)) + (message "Completed (no other completions)") + (if (< emacs-major-version 21) + (dabbrev--substitute-expansion nil abbrev init) + (dabbrev--substitute-expansion nil abbrev init nil)) + (when (window-minibuffer-p (selected-window)) (message nil))) +;;$$ ;; Complete text only up through the common root. NOT USED. +;; ((and icicle-dabbrev-stop-at-common-root-p +;; (not (string-equal init "")) +;; (not (string-equal (downcase init) (downcase abbrev)))) +;; (message "Use `%s' again to complete further" +;; (icicle-key-description (this-command-keys) +;; (not icicle-key-descriptions-use-<>-flag))) +;; (if (< emacs-major-version 21) +;; (dabbrev--substitute-expansion nil abbrev init) +;; (dabbrev--substitute-expansion nil abbrev init nil)) +;; (when (window-minibuffer-p (selected-window)) (message nil))) ; $$ NEEDED? + (t + ;; String is a common root already. Use Icicles completion. + (icicle-highlight-lighter) + (message "Making completion list...") + (search-backward abbrev) + (replace-match "") + (condition-case nil + (let* ((icicle-show-Completions-initially-flag t) + (icicle-incremental-completion-p 'display) + (minibuffer-completion-table my-obarray) + (choice + (completing-read "Complete: " my-obarray nil nil init nil init))) + (when choice (insert choice))) + (quit (insert abbrev))))))) + +(defun icicle-dabbrev--abbrev-at-point () + "Like `dabbrev--abbrev-at-point', but returns \"\" if there is no match. +Vanilla `dabbrev--abbrev-at-point' raises an error if no match." + (let ((abv "")) + (setq dabbrev--last-abbrev-location (point)) ; Record the end of the abbreviation. + (unless (bobp) + (save-excursion ; Return abbrev at point + ;; If we aren't right after an abbreviation, move point back to just after one. + ;; This is so the user can get successive words by typing the punctuation followed by M-/. + (save-match-data + (when (and (save-excursion + (forward-char -1) + (not (looking-at + (concat "\\(" (or dabbrev-abbrev-char-regexp "\\sw\\|\\s_") "\\)+")))) + (re-search-backward (or dabbrev-abbrev-char-regexp "\\sw\\|\\s_") nil t)) + (forward-char 1))) + (dabbrev--goto-start-of-abbrev) ; Now find the beginning of that one. + (setq abv (buffer-substring-no-properties dabbrev--last-abbrev-location (point))))) + abv)) + + +;; REPLACE ORIGINAL `bbdb-complete-name' defined in `bbdb-com.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Note: BBDB, the Insidious Big Brother Database, is available here: +;; http://bbdb.sourceforge.net/. +;; +;; Uses Icicles completion when there are multiple candidates. +;; +;; Free vars here: `bbdb-*' are bound in `bbdb-com.el'. +;;;###autoload +(defun icicle-bbdb-complete-name (&optional start-pos) + "Complete the user full-name or net-address before point. +Completes only up to the preceding newline, colon, or comma, or the +value of START-POS. + +If what has been typed is unique, insert an entry of the form \"User +Name \" (but see `bbdb-dwim-net-address-allow-redundancy'). +If it is a valid completion but not unique, you can choose from the +list of completions using Icicles completion. + +If your input is completed and `bbdb-complete-name-allow-cycling' is +true, then you can repeat to cycle through the nets for the matching +record. + +When called with a prefix arg, display a list of all nets. You can +control completion behaviour using `bbdb-completion-type'." + (interactive) + (unless (and (require 'bbdb nil t) (require 'bbdb-com nil t)) + (error "`icicle-bbdb-complete-name' requires BBDB")) + (let* ((end (point)) + (beg (or start-pos (save-excursion (re-search-backward + "\\(\\`\\|[\n:,]\\)[ \t]*") + (goto-char (match-end 0)) (point)))) + (orig (buffer-substring beg end)) + (typed (downcase orig)) + (pattern (bbdb-string-trim typed)) + ;; DADAMS - + ;; Replaced `(bbdb-hashtable)' by its expansion (bbdb-with-db-buffer ... bbdb-hashtable), + ;; to avoid the silly macro altogether and simplify user byte-compiling a little. + (ht (bbdb-with-db-buffer (bbdb-records nil t) bbdb-hashtable)) + ;; Make a list of possible completion strings (all-the-completions), and a flag to + ;; indicate if there's a single matching record or not (only-one-p). + (only-one-p t) + (all-the-completions ()) + (pred + #'(lambda (sym) + (and (bbdb-completion-predicate sym) + (progn + (when (and only-one-p all-the-completions + (or + ;; Not sure about this. More than one record attached to the symbol? + ;; Does that happen? + (> (length (symbol-value sym)) 1) + ;; This is the doozy. Multiple syms which all match the same record. + (delete t (mapcar #'(lambda (x) + (equal (symbol-value x) (symbol-value sym))) + all-the-completions)))) + (setq only-one-p nil)) + (if (memq sym all-the-completions) + nil + (setq all-the-completions (cons sym all-the-completions))))))) + (completion (progn (all-completions pattern ht pred) + (try-completion pattern ht))) + (exact-match (eq completion t))) + (cond + ;; No matches found OR you're trying completion on an already-completed record. + ;; In the latter case, we might have to cycle through the nets for that record. + ((or (null completion) + (and bbdb-complete-name-allow-cycling + exact-match ; Which is a net of the record + (member orig (bbdb-record-net (car (symbol-value (intern-soft pattern ht))))))) + (bbdb-complete-name-cleanup) ; Clean up the completion buffer, if it exists + (unless (catch 'bbdb-cycling-exit ; Check for cycling + ;; Jump straight out if we're not cycling + (unless bbdb-complete-name-allow-cycling (throw 'bbdb-cycling-exit nil)) + ;; Find the record we're working on. + (let* ((addr (funcall bbdb-extract-address-components-func orig)) + (rec (and (listp addr) + ;; For now, we ignore the case where this returns more than + ;; one record. Ideally, the last expansion would be stored + ;; in a buffer-local variable, perhaps. + (car (bbdb-search-intertwingle (caar addr) + (car (cdar addr))))))) + (unless rec (throw 'bbdb-cycling-exit nil)) + (if current-prefix-arg + ;; Use completion buffer + (let ((standard-output (get-buffer-create "*Completions*"))) + ;; A previously existing buffer has to be cleaned first + (with-current-buffer standard-output + (setq buffer-read-only nil) + (erase-buffer)) + (display-completion-list + (mapcar #'(lambda (n) (bbdb-dwim-net-address rec n)) + (bbdb-record-net rec))) + (delete-region beg end) + (switch-to-buffer standard-output)) + ;; Use next address + (let* ((addrs (bbdb-record-net rec)) + (this-addr (or (cadr (member (car (cdar addr)) addrs)) + (nth 0 addrs)))) + (if (= (length addrs) 1) + (throw 'bbdb-cycling-exit t) ; No alternatives. don't signal an error. + ;; Replace with new mail address + (delete-region beg end) + (insert (bbdb-dwim-net-address rec this-addr)) + (run-hooks 'bbdb-complete-name-hooks) + (throw 'bbdb-cycling-exit t)))))) + ;; FALL THROUGH. Check mail aliases + (when (and (or (not bbdb-expand-mail-aliases) (not (expand-abbrev))) + bbdb-complete-name-hooks) + (message "No completion for `%s'" pattern) (icicle-ding)))) ; no matches + + ;; Match for a single record. If cycling is enabled then we don't + ;; care too much about the exact-match part. + ((and only-one-p (or exact-match bbdb-complete-name-allow-cycling)) + (let* ((sym (if exact-match (intern-soft pattern ht) (car all-the-completions))) + (recs (symbol-value sym)) + the-net match-recs lst primary matched) + (while recs + (when (bbdb-record-net (car recs)) + ;; Did we match on name? + (let ((b-r-name (or (bbdb-record-name (car recs)) ""))) + (if (string= pattern (substring (downcase b-r-name) 0 + (min (length b-r-name) (length pattern)))) + (setq match-recs (cons (car recs) match-recs) + matched t))) + ;; Did we match on aka? + (unless matched + (setq lst (bbdb-record-aka (car recs))) + (while lst + (if (string= pattern (substring (downcase (car lst)) 0 + (min (length (downcase (car lst))) + (length pattern)))) + (setq match-recs (append match-recs (list (car recs))) + matched t + lst ()) + (setq lst (cdr lst))))) + ;; Name didn't match name so check net matching + (unless matched + (setq lst (bbdb-record-net (car recs)) + primary t) ; primary wins over secondary... + (while lst + (if (string= pattern (substring (downcase (car lst)) 0 + (min (length (downcase (car lst))) + (length pattern)))) + (setq the-net (car lst) + lst () + match-recs (if primary + (cons (car recs) match-recs) + (append match-recs (list (car recs)))))) + (setq lst (cdr lst) + primary nil)))) + (setq recs (cdr recs) ; Next rec for loop. + matched nil)) + (unless match-recs (error "Only exact matching record has net field")) + ;; Replace the text with the expansion + (delete-region beg end) + (insert (bbdb-dwim-net-address (car match-recs) the-net)) + ;; If we're past fill-column, wrap at the previous comma. + (when (and (bbdb-auto-fill-function) (>= (current-column) fill-column)) + (let ((p (point)) + bol) + (save-excursion + (beginning-of-line) + (setq bol (point)) + (goto-char p) + (when (search-backward "," bol t) (forward-char 1) (insert "\n "))))) + ;; Update the *BBDB* buffer if desired. + (when bbdb-completion-display-record + (let ((bbdb-gag-messages t)) + (bbdb-pop-up-bbdb-buffer) + (bbdb-display-records-1 match-recs t))) + (bbdb-complete-name-cleanup) + ;; Call the exact-completion hook + (run-hooks 'bbdb-complete-name-hooks))) + + ;; Partial match. Note: we can't use the trimmed version of the pattern here or + ;; we'll recurse infinitely on e.g. common first names. + ((and (stringp completion) (not (string= typed completion))) + (delete-region beg end) + (insert completion) + (setq end (point)) + (let ((last "") + (bbdb-complete-name-allow-cycling nil)) + (while (and (stringp completion) (not (string= completion last)) + (setq last completion + pattern (downcase orig) + completion (progn (all-completions pattern ht pred) + (try-completion pattern ht)))) + (when (stringp completion) (delete-region beg end) (insert completion))) + (bbdb-complete-name beg))) ; RECURSE <================ + + ;; Exact match, but more than one record + (t + (unless (eq (selected-window) (minibuffer-window)) (message "Making completion list...")) + (let (dwim-completions uniq nets net name akas) + ;; Collect all the dwim-addresses for each completion, but only once for each record. + ;; Add if the net is part of the completions. + (bbdb-mapc #'(lambda (sym) + (bbdb-mapc + #'(lambda (rec) + (unless (member rec uniq) + (setq uniq (cons rec uniq) + nets (bbdb-record-net rec) + name (downcase (or (bbdb-record-name rec) "")) + akas (mapcar 'downcase (bbdb-record-aka rec))) + (while nets + (setq net (car nets)) + (when (cond + ((and (member bbdb-completion-type ; Primary + '(primary primary-or-name)) + (member (intern-soft (downcase net) ht) + all-the-completions)) + (setq nets ()) + t) + ((and name (member bbdb-completion-type ; Name + '(nil name primary-or-name)) + (let ((cname (symbol-name sym))) + (or (string= cname name) + (member cname akas)))) + (setq name nil) + t) + ((and (member bbdb-completion-type '(nil net)) ; Net + (member (intern-soft (downcase net) ht) + all-the-completions))) + ;; (name-or-)primary + ((and (member bbdb-completion-type + '(name-or-primary)) + (let ((cname (symbol-name sym))) + (or (string= cname name) + (member cname akas)))) + (setq nets ()) + t)) + (setq dwim-completions + (cons (bbdb-dwim-net-address rec net) + dwim-completions)) + (when exact-match (setq nets ()))) + (setq nets (cdr nets))))) + (symbol-value sym))) + all-the-completions) + (cond ((and dwim-completions (null (cdr dwim-completions))) ; Insert the unique match. + (delete-region beg end) (insert (car dwim-completions)) (message "")) + (t ; More than one match. Use Icicles minibuffer completion. + (condition-case nil + (let* ((icicle-show-Completions-initially-flag t) + (icicle-incremental-completion-p 'display) + (icicle-top-level-when-sole-completion-flag t) + (completion-ignore-case t) + (choice + (save-excursion + (completing-read "Complete: " (mapcar #'list dwim-completions) + nil t pattern nil pattern)))) + (when choice + (delete-region beg end) + (insert choice))) + (error nil)) + (unless (eq (selected-window) (minibuffer-window)) + (message "Making completion list...done"))))))))) + + +;; REPLACE ORIGINAL `lisp-complete-symbol' defined in `lisp.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Selects *Completions* window even if on another frame. +;; +(unless (fboundp 'old-lisp-complete-symbol) +(defalias 'old-lisp-complete-symbol (symbol-function 'lisp-complete-symbol))) + +;;;###autoload +(defun icicle-lisp-complete-symbol (&optional predicate) ; `M-TAB' (`C-M-i', `ESC-TAB'), globally. + "Complete the Lisp symbol preceding point against known Lisp symbols. +If there is more than one completion, use the minibuffer to complete. + +When called from a program, optional arg PREDICATE is a predicate +determining which symbols are considered, e.g. `commandp'. + +If PREDICATE is nil, the context determines which symbols are +considered. If the symbol starts just after an open-parenthesis, only +symbols with function definitions are considered. Otherwise, all +symbols with function definitions, values or properties are +considered." + (interactive) + (let* ((end (point)) + (buffer-syntax (syntax-table)) + (beg (unwind-protect + (save-excursion + (set-syntax-table emacs-lisp-mode-syntax-table) + (backward-sexp 1) + (while (= (char-syntax (following-char)) ?\') (forward-char 1)) + (point)) + (set-syntax-table buffer-syntax))) + (pattern (buffer-substring beg end)) + (new (try-completion pattern obarray))) + (unless (stringp new) (setq new pattern)) + (delete-region beg end) + (insert new) + (setq end (+ beg (length new))) + (if (and (not (string= new "")) (not (string= (downcase new) (downcase pattern))) + (< (length (all-completions new obarray)) 2)) + (message "Completed (no other completions)") + ;; Use minibuffer to choose a completion. + (let* ((enable-recursive-minibuffers (active-minibuffer-window)) + (icicle-top-level-when-sole-completion-flag t) + (orig-window (selected-window)) ; For alt actions. + (alt-fn nil) + (icicle-show-Completions-initially-flag t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (setq alt-fn (icicle-alt-act-fn-for-type "symbol")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn + (icicle-alt-act-fn-for-type "symbol"))) + (predicate + (or predicate + (save-excursion + (goto-char beg) + (if (not (eq (char-before) ?\( )) + #'(lambda (sym) ;why not just nil ? -sm + (or (boundp sym) (fboundp sym) (symbol-plist sym))) + ;; If first element of parent list is not an open paren, assume that this is a + ;; funcall position: use `fboundp'. If not, then maybe this is a variable in + ;; a `let' binding, so no predicate: use nil. + (and (not (condition-case nil + (progn (up-list -2) (forward-char 1) (eq (char-after) ?\( )) + (error nil))) + 'fboundp)))))) + (setq new (save-excursion (completing-read "Complete Lisp symbol: " + obarray predicate t new))))) + (delete-region beg end) + (insert new))) + +;;;###autoload +(defun icicle-customize-icicles-group () + "Customize Icicles options and faces. View their documentation." + (interactive) + (customize-group-other-window 'Icicles)) + +;;;###autoload +(defun icicle-send-bug-report () + "Send a bug report about an Icicles problem." + (interactive) + (browse-url (format (concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\ +Icicles bug: \ +&body=Describe bug below, using a precise recipe that starts with `emacs -Q' or `emacs -q'. \ +Each Icicles file has a header `Update #' that you can use to identify it.\ +%%0A%%0AEmacs version: %s.") + (emacs-version)))) + + +;; REPLACE ORIGINAL `customize-face' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Multi-command version. +;; +(unless (fboundp 'old-customize-face) +(defalias 'old-customize-face (symbol-function 'customize-face))) + +;;;###autoload +(defun icicle-customize-face (face) + "Customize face FACE. +Input-candidate completion and cycling are available. While cycling, +these keys with prefix `C-' are active: + +`C-mouse-2', `C-RET' - Act on current completion candidate only +`C-down' - Move to next prefix-completion candidate and act +`C-up' - Move to previous prefix-completion candidate and act +`C-next' - Move to next apropos-completion candidate and act +`C-prior' - Move to previous apropos-completion candidate and act +`M-!' - Act on *all* candidates (or all that are saved): + Customize all in the same buffer. +`C-!' - Act on *all* candidates (or all that are saved): + Customize each in a separate buffer. + +When candidate action and cycling are combined (e.g. `C-next'), option +`icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, +or `C-g' to quit. + +With a prefix argument, you can enter multiple faces at the same time +with `RET' (in Emacs 22 or later). This gives you the completion +behavior of `customize-face' in vanilla Emacs. The advantage is that +the default value is the list of all faces under the cursor. The +disadvantage is that face candidates are not WYSIWYG in buffer +*Completions*. + +This is an Icicles command - see command `icicle-mode'." + (interactive + (list (let* ((icicle-list-use-nth-parts '(1)) + (icicle-candidate-action-fn + #'(lambda (x) + (old-customize-face (intern (icicle-transform-multi-completion x))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)))) + (icicle-all-candidates-list-action-fn 'icicle-customize-faces) + (orig-window (selected-window)) ; For alt actions. + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (setq alt-fn (icicle-alt-act-fn-for-type "face")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn + alt-fn (icicle-alt-act-fn-for-type "face")))) + (if (and (> emacs-major-version 21) current-prefix-arg) + (read-face-name "Customize face: " "all faces" t) + (read-face-name "Customize face: "))))) + (old-customize-face face)) + + +;; REPLACE ORIGINAL `customize-face-other-window' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Multi-command version. +;; +(unless (fboundp 'old-customize-face-other-window) +(defalias 'old-customize-face-other-window (symbol-function 'customize-face-other-window))) + +;;;###autoload +(defun icicle-customize-face-other-window (face) + "Customize face FACE in another window. +Same as `icicle-customize-face' except it uses a different window." + (interactive + (list (let* ((icicle-list-use-nth-parts '(1)) + (icicle-candidate-action-fn + #'(lambda (x) + (old-customize-face-other-window (intern (icicle-transform-multi-completion x))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)))) + (icicle-all-candidates-list-action-fn 'icicle-customize-faces) + (orig-window (selected-window)) ; For alt actions. + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (setq alt-fn (icicle-alt-act-fn-for-type "face")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn + alt-fn (icicle-alt-act-fn-for-type "face")))) + (if (and (> emacs-major-version 21) current-prefix-arg) + (read-face-name "Customize face: " "all faces" t) + (read-face-name "Customize face: "))))) + (old-customize-face-other-window face)) + +(defun icicle-customize-faces (faces) + "Open Customize buffer on all faces in list FACES." + (let ((icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1))) + (custom-buffer-create + (custom-sort-items + (mapcar #'(lambda (f) (list (intern (icicle-transform-multi-completion f)) 'custom-face)) + faces) + t custom-buffer-order-groups) + "*Customize Apropos*"))) + + +;; REPLACE ORIGINAL `customize-apropos' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the regexp. +;; +(unless (fboundp 'old-customize-apropos) +(defalias 'old-customize-apropos (symbol-function 'customize-apropos))) + +;;;###autoload +(defun icicle-customize-apropos (regexp &optional all) + "Customize all user options matching REGEXP. +If ALL is `options', include only options. +If ALL is `faces', include only faces. +If ALL is `groups', include only groups. +If ALL is t (interactively, with prefix arg), include options which + are not user-settable, as well as faces and groups. + +Use `S-TAB', [next], and [prior], to match regexp input - this lets +you see what items will be available in the customize buffer." + (interactive + (let ((pref-arg current-prefix-arg)) + (list (completing-read "Customize (regexp): " obarray + #'(lambda (symbol) + (or (get symbol 'custom-group) + (custom-facep symbol) + (and (boundp symbol) + (or (get symbol 'saved-value) + (custom-variable-p symbol) + (if (null pref-arg) + (user-variable-p symbol) + (get symbol 'variable-documentation)))))) + nil nil 'regexp-history) + pref-arg))) + (let ((found nil)) + (mapatoms #'(lambda (symbol) + (when (string-match regexp (symbol-name symbol)) + (when (and (not (memq all '(faces options))) ; groups or t + (get symbol 'custom-group)) + (push (list symbol 'custom-group) found)) + (when (and (not (memq all '(options groups))) ; faces or t + (custom-facep symbol)) + (push (list symbol 'custom-face) found)) + (when (and (not (memq all '(groups faces))) ; options or t + (boundp symbol) + (or (get symbol 'saved-value) + (custom-variable-p symbol) + (if (memq all '(nil options)) + (user-variable-p symbol) + (get symbol 'variable-documentation)))) + (push (list symbol 'custom-variable) found))))) + (if (not found) + (error "No matches") + (custom-buffer-create (custom-sort-items found t custom-buffer-order-groups) + "*Customize Apropos*")))) + +;; Define this for Emacs 20 and 21 +(unless (fboundp 'custom-variable-p) + (defun custom-variable-p (variable) + "Return non-nil if VARIABLE is a custom variable." + (or (get variable 'standard-value) (get variable 'custom-autoload)))) + + +;; REPLACE ORIGINAL `customize-apropos-faces' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the regexp. +;; +(unless (fboundp 'old-customize-apropos-faces) +(defalias 'old-customize-apropos-faces (symbol-function 'customize-apropos-faces))) + +;;;###autoload +(defun icicle-customize-apropos-faces (regexp) + "Customize all user faces matching REGEXP. +Use `S-TAB', [next], and [prior], to match regexp input - this lets +you see what items will be available in the customize buffer." + (interactive + (list (completing-read "Customize faces (regexp): " obarray 'custom-facep nil nil + 'regexp-history))) + (customize-apropos regexp 'faces)) + + +;; REPLACE ORIGINAL `customize-apropos-groups' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the regexp. +;; +(unless (fboundp 'old-customize-apropos-groups) +(defalias 'old-customize-apropos-groups (symbol-function 'customize-apropos-groups))) + +;;;###autoload +(defun icicle-customize-apropos-groups (regexp) + "Customize all user groups matching REGEXP. +Use `S-TAB', [next], and [prior], to match regexp input - this lets +you see what items will be available in the customize buffer." + (interactive + (list (completing-read "Customize groups (regexp): " obarray + #'(lambda (symbol) (get symbol 'custom-group)) nil nil 'regexp-history))) + (customize-apropos regexp 'groups)) + + +;; REPLACE ORIGINAL `customize-apropos-options' defined in `cus-edit.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the regexp. +;; +(unless (fboundp 'old-customize-apropos-options) +(defalias 'old-customize-apropos-options (symbol-function 'customize-apropos-options))) + +;;;###autoload +(defun icicle-customize-apropos-options (regexp &optional arg) + "Customize all user options matching REGEXP. +With prefix argument, include options which are not user-settable. + +Use `S-TAB', [next], and [prior], to match regexp input - this lets +you see what items will be available in the customize buffer." + (interactive + (let ((pref-arg current-prefix-arg)) + (list (completing-read "Customize options (regexp): " obarray + #'(lambda (symbol) + (and (boundp symbol) + (or (get symbol 'saved-value) + (custom-variable-p symbol) + (if (null pref-arg) + (user-variable-p symbol) + (get symbol 'variable-documentation))))) + nil nil 'regexp-history) + pref-arg))) + (customize-apropos regexp (or arg 'options))) + + +;; REPLACE ORIGINAL `customize-apropos-options-of-type' defined in `cus-edit+.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the regexp. +;; +(when (and (fboundp 'customize-apropos-options-of-type) + (not (fboundp 'old-customize-apropos-options-of-type))) +(defalias 'old-customize-apropos-options-of-type + (symbol-function 'customize-apropos-options-of-type))) + +;;;###autoload +(defun icicle-customize-apropos-options-of-type (type regexp) + "Customize all loaded customizable options of type TYPE that match REGEXP. +With no prefix arg, each option is defined with `defcustom' type TYPE. +With a prefix arg, either each option is defined with `defcustom' type + TYPE or its current value is compatible with TYPE. + +If TYPE is nil (the default value) then all `defcustom' variables are +potential candidates. + +Use `S-TAB', `next', and `prior', to match regexp input - this lets +you see which options will be available in the customize buffer." + (interactive + (let ((typ (car (condition-case err + (read-from-string + (let ((types ())) + (mapatoms + #'(lambda (cand) + (when (custom-variable-p cand) + (push (list (format "%s" + (format "%S" (get cand 'custom-type)))) + types)))) + (completing-read "Customize all options of type: " + (icicle-remove-duplicates types) + nil nil nil nil "nil"))) + (end-of-file (error "No such custom type"))))) + (pref-arg current-prefix-arg)) + (list typ + (completing-read + "Customize options matching (regexp): " obarray + #'(lambda (symb) + (and (boundp symb) + (or (not (fboundp 'indirect-variable)) (eq (indirect-variable symb) symb)) + (or (get symb 'saved-value) (custom-variable-p symb)) + (or (not typ) ; `typ' = nil means use all types. + (if pref-arg + (icicle-var-is-of-type-p symb (list typ)) + (equal (get symb 'custom-type) typ))))) + nil nil 'regexp-history)))) + (custom-buffer-create (custom-sort-items + (mapcar #'(lambda (s) (list (intern s) 'custom-variable)) + icicle-completion-candidates) + t "*Customize Apropos*"))) + + +;; REPLACE ORIGINAL `repeat-complex-command' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Uses `completing-read' to read the command to repeat, letting you use `S-TAB' and +;; `TAB' to see the history list and `C-,' to toggle sorting that display. +;; +(unless (fboundp 'old-repeat-complex-command) +(defalias 'old-repeat-complex-command (symbol-function 'repeat-complex-command))) + +;;;###autoload +(defun icicle-repeat-complex-command (arg) ; Bound to `C-x ESC ESC', `C-x M-:' in Icicle mode. + "Edit and re-evaluate the last complex command, or ARGth from last. +A complex command is one that used the minibuffer. +ARG is the prefix argument numeric value. + +You can edit the past command you choose before executing it. The +Lisp form of the command is used. If the command you enter differs +from the previous complex command, then it is added to the front of +the command history. + +Icicles completion is available for choosing a past command. You can +still use the vanilla Emacs bindings `\\\\[next-history-element]' and \ +`\\[previous-history-element]' to cycle inputs, +and `\\[repeat-matching-complex-command]' to match regexp input, but Icicles input cycling (`up', +`down',`next', `prior') and apropos completion (`S-TAB') are superior +and more convenient." + (interactive "p") + (let ((elt (nth (1- arg) command-history)) + newcmd) + (if elt + (progn + (setq newcmd + (let ((print-level nil) + (minibuffer-history-position arg) + (minibuffer-history-sexp-flag (1+ (minibuffer-depth)))) + (unwind-protect + (let ((icicle-transform-function 'icicle-remove-duplicates)) + (read (completing-read + "Redo: " (mapcar #'(lambda (entry) (list (prin1-to-string entry))) + command-history) + nil nil (prin1-to-string elt) (cons 'command-history arg) + (prin1-to-string elt)))) + ;; If command was added to command-history as a string, get rid of that. + ;; We want only evaluable expressions there. + (if (stringp (car command-history)) + (setq command-history (cdr command-history)))))) + ;; If command to be redone does not match front of history, add it to the history. + (or (equal newcmd (car command-history)) + (setq command-history (cons newcmd command-history))) + (eval newcmd)) + (if command-history + (error "Argument %d is beyond length of command history" arg) + (error "There are no previous complex commands to repeat"))))) + +;;;###autoload +(defun icicle-add-entry-to-saved-completion-set (set-name entry type) + "Add ENTRY to saved completion-candidates set SET-NAME. +ENTRY is normally a single candidate (a string). + With a prefix arg, however, and if option + `icicle-filesets-as-saved-completion-sets-flag' is non-nil, then + ENTRY is the name of an Emacs fileset (Emacs 22 or later). +TYPE is the type of entry to add: `Fileset' or `Candidate'." + (interactive + (let ((typ (if (and current-prefix-arg icicle-filesets-as-saved-completion-sets-flag + (prog1 (or (require 'filesets nil t) + (error "Feature `filesets' not provided")) + (filesets-init)) + filesets-data) + 'Fileset + 'Candidate))) + (list + (save-selected-window + (completing-read "Saved completion set: " icicle-saved-completion-sets nil t nil + 'icicle-completion-set-history)) + (if (eq typ 'Fileset) + (list ':fileset ; Just save the fileset name, not the data. + (car (assoc (completing-read "Fileset to add: " filesets-data nil t) + filesets-data))) + (completing-read "Candidate to add: " (mapcar #'list icicle-saved-completion-candidates))) + typ))) + (let ((file-name (cdr (assoc set-name icicle-saved-completion-sets)))) + (unless (icicle-file-readable-p file-name) (error "Cannot read cache file `%s'" file-name)) + (let ((list-buf (find-file-noselect file-name 'nowarn 'raw)) + candidates newcands entry-type) + (unwind-protect + (condition-case icicle-add-entry-to-saved-completion-set + (when (listp (setq newcands (setq candidates (read list-buf)))) + (message "Set `%s' read from file `%s'" set-name file-name)) + (error (error "Bad cache file. %s" + (error-message-string icicle-add-entry-to-saved-completion-set)))) + (kill-buffer list-buf)) + (unless (consp newcands) (error "Bad data in cache file `%s'" file-name)) + (pushnew entry newcands :test #'equal) + (setq entry (if (eq type 'Fileset) (caar entry) entry)) + (if (= (length candidates) (length newcands)) + (message "%s `%s' is already in saved set `%s', file `%s'" type entry set-name file-name) + (with-temp-message (format "Writing entry to cache file `%s'..." file-name) + (with-temp-file file-name (prin1 newcands (current-buffer)))) + (message "%s `%s' added to saved set `%s', file `%s'" type entry set-name file-name))))) + +;;;###autoload +(defun icicle-remove-entry-from-saved-completion-set (set-name) + "Remove an entry from saved completion-candidates set SET-NAME. +SET-NAME can be an Icicles saved completions set (cache file) or the +name of an Emacs fileset. + +The entry to remove can be a single completion candidate (a string) or +an Emacs fileset. You can thus remove a file name from a fileset or +remove a fileset from an Icicles saved completion set. (You can also +remove a file name from a saved completion set.) If a saved set has +both a file and a fileset of the same name, then both are removed. + +To use filesets here, use Emacs 22 or later, load library `filesets', +use `(filesets-init)', and ensure that option +`icicle-filesets-as-saved-completion-sets-flag' is non-nil." + (interactive + (list (completing-read "Saved completion set: " + (if (and icicle-filesets-as-saved-completion-sets-flag + (featurep 'filesets) filesets-data) + (append filesets-data icicle-saved-completion-sets) + icicle-saved-completion-sets) + nil t nil 'icicle-completion-set-history))) + (let* ((file-name (cdr (assoc set-name icicle-saved-completion-sets))) + (candidates (icicle-get-candidates-from-saved-set + set-name 'dont-expand)) + (icicle-whole-candidate-as-text-prop-p t) + (entry + (funcall icicle-get-alist-candidate-function + (completing-read + "Candidate to remove: " + (mapcar #'(lambda (e) + (cond ((icicle-saved-fileset-p e) ; Swap `:fileset' with fileset name + `(,(cadr e) ,(car e) ,@(cddr e))) + ((consp e) e) + (t (list e)))) ; Listify naked string. + candidates) + nil t)))) + (when (and (consp entry) (eq (cadr entry) ':fileset)) ; Swap back again: `:fileset' and name. + (setq entry `(,(cadr entry) ,(car entry) ,@(cddr entry)))) + (when (and (consp entry) (null (cdr entry))) (setq entry (car entry))) ; Use just the string. + ;; Delete any such candidate, then remove text properties used for completion. + (setq candidates (mapcar #'icicle-unpropertize (delete entry candidates))) + (cond (file-name + (with-temp-message ; Remove from cache file. + (format "Writing remaining candidates to cache file `%s'..." file-name) + (with-temp-file file-name (prin1 candidates (current-buffer))))) + ((icicle-saved-fileset-p (list ':fileset set-name)) ; Remove from fileset. + (unless (require 'filesets nil t) (error "Feature `filesets' not provided")) + (filesets-init) + (let ((fst (and filesets-data (assoc set-name filesets-data)))) ; The fileset itself. + (unless fst (error "No such fileset: `%s'" set-name)) + (let ((fst-files (filesets-entry-get-files fst))) + (if (car (filesets-member entry fst-files :test 'filesets-files-equalp)) + (if fst-files ; Similar to code in `filesets-remove-buffer'. + (let ((new-fst (list (cons ':files (delete entry fst-files))))) + (setcdr fst new-fst) + (filesets-set-config set-name 'filesets-data filesets-data)) + (message "Cannot remove `%s' from fileset `%s'" entry set-name)) + (message "`%s' not in fileset `%s'" entry set-name)))))) + (icicle-msg-maybe-in-minibuffer + (concat (format "`%s' removed from %s `%s'" + (if (icicle-saved-fileset-p entry) (cadr entry) entry) + (if (icicle-saved-fileset-p entry) "fileset" "saved set") + set-name) + (and file-name (format ", file `%s'" file-name)))))) + +;;;###autoload +(icicle-define-command icicle-remove-saved-completion-set ; Command name + "Remove an entry from `icicle-saved-completion-sets'. +Save the updated option. +You are prompted to also delete the associated cache file. +You can add entries to `icicle-saved-completion-sets' using command +`icicle-add/update-saved-completion-set'." ; Doc string + icicle-remove-saved-set-action + "Remove set of completion candidates named: " ; `completing-read' args + icicle-saved-completion-sets nil t nil 'icicle-completion-set-history nil nil + ((icicle-whole-candidate-as-text-prop-p t) ; Additional bindings + (icicle-use-candidates-only-once-flag t)) + nil nil (icicle-remove-Completions-window)) ; First code, undo code, last code + +(defun icicle-remove-saved-set-action (set-name) + "Remove saved set SET-NAME from `icicle-saved-completion-sets'." + (let ((enable-recursive-minibuffers t) + (sets icicle-saved-completion-sets) + set cache) + (save-selected-window + (select-window (minibuffer-window)) + (while (setq set (assoc set-name sets) + cache (cdr set)) + (when (file-exists-p cache) + (if (y-or-n-p (format "Delete cache file `%s'? " cache)) + (when (condition-case err + (progn (delete-file cache) t) + (error (progn (message (error-message-string err)) nil))) + (message "DELETED `%s'" cache) (sit-for 1)) + (message "OK, file NOT deleted") (sit-for 1))) + (setq sets (delete set sets))))) + (setq icicle-saved-completion-sets + (icicle-assoc-delete-all set-name icicle-saved-completion-sets)) + (funcall icicle-customize-save-variable-function + 'icicle-saved-completion-sets + icicle-saved-completion-sets) + (message "Candidate set `%s' removed" set-name)) + +;;;###autoload +(defun icicle-dired-save-marked (&optional arg) ; Bound to `C-M->' in Dired. + "Save the marked file names in Dired as a set of completion candidates. +Saves file names in variable `icicle-saved-completion-candidates', by +default. +With a plain prefix arg (`C-u'), save candidates in a cache file. +With a non-zero numeric prefix arg (`C-u N'), save candidates in a + variable for which you are prompted. +With a zero prefix arg (`C-0'), save candidates in a fileset (Emacs 22 + or later). Use this only for file-name candidates, obviously. + To subsequently use a fileset for candidate retrieval, option + `icicle-filesets-as-saved-completion-sets-flag' must be non-nil. + +You can retrieve the saved set of file-name candidates during +completion using `\\\\[icicle-candidate-set-retrieve]'. +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from a Dired buffer." + (interactive "P") + (unless (eq major-mode 'dired-mode) + (error "Command `icicle-dired-save-marked' must be called from a Dired buffer")) + (icicle-candidate-set-save-1 (dired-get-marked-files) arg)) + +;;;###autoload +(defun icicle-dired-save-marked-more (&optional arg) ; Bound to `C->' in Dired. + "Add the marked file names in Dired to the saved candidates set. +Add candidates to `icicle-saved-completion-candidates', by default. +A prefix argument acts the same as for `icicle-candidate-set-save'. + +The existing saved candidates are still saved. The current candidates +are added to those already saved. + +You can retrieve the saved set of candidates with `C-M-<'. +You can use the saved set of candidates for operations such as" + (interactive "P") + (unless (eq major-mode 'dired-mode) + (error "`icicle-dired-save-marked-more' must be called from a Dired buffer")) + (icicle-candidate-set-save-1 (dired-get-marked-files) arg t)) + +;;;###autoload +(defun icicle-dired-save-marked-to-variable () ; Bound to `C-M-}' in Dired. + "Save the marked file names in Dired as a candidate set to a variable. +You can retrieve the saved set of file-name candidates during +completion using `\\\\[icicle-candidate-set-retrieve]'. +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from a Dired buffer." + (interactive) + (icicle-candidate-set-save-1 (dired-get-marked-files) 99)) + +(defalias 'icicle-dired-save-marked-as-project ; Bound to `C-}' in Dired. + 'icicle-dired-save-marked-persistently) +;;;###autoload +(defun icicle-dired-save-marked-persistently (filesetp) + "Save the marked file names in Dired as a persistent set. +With no prefix arg, save in a cache file. +With a prefix arg, save in an Emacs fileset (Emacs 22 or later). + +You can retrieve the saved set of file-name candidates during +completion using `\\\\[icicle-candidate-set-retrieve]'. +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from a Dired buffer." + (interactive "P") + (icicle-candidate-set-save-1 (dired-get-marked-files) (if filesetp 0 '(1)))) + + +(put 'icicle-dired-saved-file-candidates 'icicle-Completions-window-max-height 200) +(defalias 'icicle-dired-chosen-files 'icicle-dired-saved-file-candidates) +;;;###autoload +(defun icicle-dired-saved-file-candidates (prompt-for-dir-p) + "Open Dired on a set of files and directories of your choice. +If you have saved a set of file names using \\\ +`\\[icicle-candidate-set-save]', then it is used. +If not, you are prompted to choose the files. +With a prefix argument, you are prompted for the default directory to use. +Otherwise, the current value of `default-directory' is used. +Names that do not correspond to existing files are ignored. +Existence of files with relative names is checked in the Dired +directory (default directory)." + (interactive "P") + ;; $$$$$$$ Maybe filter sets to get only file-name candidate sets? + (unless icicle-saved-completion-candidates + (error (substitute-command-keys "No saved completion candidates. \ +Use \\`\\[icicle-candidate-set-save]' to save candidates"))) + (let* ((default-directory (if prompt-for-dir-p + (read-file-name "Directory: " nil default-directory nil) + default-directory)) + (icicle-list-use-nth-parts '(1)) + (file-names (icicle-remove-if + #'(lambda (fil) (or (null fil) (not (file-exists-p fil)))) + (or (and icicle-saved-completion-candidates + (mapcar #'icicle-transform-multi-completion + icicle-saved-completion-candidates)) + (icicle-file-list))))) + (dired (cons (generate-new-buffer-name "Icy File Set") (nreverse file-names))))) + +(defalias 'icicle-dired-chosen-files-other-window 'icicle-dired-saved-file-candidates-other-window) +;;;###autoload +(defun icicle-dired-saved-file-candidates-other-window (prompt-for-dir-p) ; Bound `C-M-<' in Dired. + "Open Dired in other window on set of files & directories of your choice. +If you have saved a set of file names using \\\ +`\\[icicle-candidate-set-save]', then it is used. +If not, you are prompted to choose the files. +With a prefix arg, you are prompted for the default directory to use. +Otherwise, the current value of `default-directory' is used. +Names that do not correspond to existing files are ignored. +Existence of files with relative names is checked in the Dired +directory (default directory)." + (interactive "P") + ;; $$$$$$$ Maybe filter sets to get only file-name candidate sets? + (let* ((default-directory (if prompt-for-dir-p + (read-file-name "Directory: " nil default-directory nil) + default-directory)) + (icicle-list-use-nth-parts '(1)) + (file-names (icicle-remove-if + #'(lambda (fil) (or (null fil) (not (file-exists-p fil)))) + (or (and icicle-saved-completion-candidates + (mapcar #'icicle-transform-multi-completion + icicle-saved-completion-candidates)) + (icicle-file-list))))) + (dired-other-window (cons (generate-new-buffer-name "Icy File Set") (nreverse file-names))))) + +(put 'icicle-dired-project 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-dired-project (prompt-for-dir-p) + "Open Dired on a saved project. +A project is either a persistent completion set or an Emacs fileset. +With a prefix argument, you are prompted for the directory. +Otherwise, the default directory is assumed. + +Project file names that do not correspond to existing files are +ignored. Existence of files with relative names is checked in the +directory. + +You can use `C-x m' during completion to access Dired bookmarks, if +you use library `bookmark+.el'." + (interactive "P") + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-dired-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-dired-other-window)) + (unwind-protect + ;; $$$$$$$ Maybe filter sets to get only file-name candidate sets? + (let ((set-name (completing-read "Project (saved file names): " + (if (and icicle-filesets-as-saved-completion-sets-flag + (featurep 'filesets) filesets-data) + (append filesets-data icicle-saved-completion-sets) + icicle-saved-completion-sets) + nil nil nil 'icicle-completion-set-history))) + (icicle-retrieve-candidates-from-set set-name) + (let* ((default-directory (if prompt-for-dir-p + (read-file-name "Dired directory: " nil + default-directory nil) + default-directory)) + (file-names ())) + (dolist (f icicle-saved-completion-candidates) + (when (file-exists-p f) (push f file-names))) + (unless file-names (error "No files in project `%s' actually exist" set-name)) + (dired (cons (generate-new-buffer-name set-name) + (nreverse (mapcar #'(lambda (file) + (if (file-name-absolute-p file) + (expand-file-name file) + file)) + file-names)))))) + (define-key minibuffer-local-completion-map "\C-xm" nil))) + +;;;###autoload +(defun icicle-dired-project-other-window (prompt-for-dir-p) ; Bound to `C-{' in Dired. + "Open Dired on a saved project in another window. +A project is either a persistent completion set or an Emacs fileset. +With a prefix argument, you are prompted for the directory. +Otherwise, the default directory is assumed. + +Project file names that do not correspond to existing files are +ignored. Existence of files with relative names is checked in the +directory. + +You can use `C-x m' during completion to access Dired bookmarks, if +you use library `bookmark+.el'." + (interactive "P") + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-dired-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-dired-other-window)) + (unwind-protect + ;; $$$$$$$ Maybe filter sets to get only file-name candidate sets? + (let ((set-name (completing-read "Project (saved file names): " + (if (and icicle-filesets-as-saved-completion-sets-flag + (featurep 'filesets) filesets-data) + (append filesets-data icicle-saved-completion-sets) + icicle-saved-completion-sets) + nil nil nil 'icicle-completion-set-history))) + (icicle-retrieve-candidates-from-set set-name) + (let* ((default-directory (if prompt-for-dir-p + (read-file-name "Dired directory: " nil + default-directory nil) + default-directory)) + (file-names ())) + (dolist (f icicle-saved-completion-candidates) + (when (file-exists-p f) (push f file-names))) + (unless file-names (error "No files in project `%s' actually exist" set-name)) + (dired-other-window (cons (generate-new-buffer-name set-name) + (nreverse (mapcar #'(lambda (file) + (if (file-name-absolute-p file) + (expand-file-name file) + file)) + file-names)))))) + (define-key minibuffer-local-completion-map "\C-xm" nil))) + +;;;###autoload +(defun icicle-grep-saved-file-candidates (command-args) + "Run `grep' on the set of completion candidates saved with \\\ +`\\[icicle-candidate-set-save]'. +Saved names that do not correspond to existing files are ignored. +Existence of files with relative names is checked in the default +directory." + (interactive + (list + (let ((file-names ())) + (unless icicle-saved-completion-candidates + (error (substitute-command-keys "No saved completion candidates. \ +Use \\`\\[icicle-candidate-set-save]' to save candidates"))) + (unless grep-command (grep-compute-defaults)) + (dolist (f icicle-saved-completion-candidates) (when (file-exists-p f) (push f file-names))) + (let ((default (and (fboundp 'grep-default-command) (grep-default-command)))) + (read-from-minibuffer + "grep : " + (let ((up-to-files (concat grep-command " "))) + (cons (concat up-to-files (mapconcat #'identity icicle-saved-completion-candidates " ")) + (- (length up-to-files) 2))) + nil nil 'grep-history default))))) + (grep command-args)) + +;; Utility function. Use it to define multi-commands that navigate. +(defun icicle-explore (define-candidates-fn final-action-fn quit-fn error-fn cleanup-fn prompt + &rest compl-read-args) + "Icicle explorer: explore complex completion candidates. +Navigate among locations or other entities represented by a set of +completion candidates. See `icicle-search' for a typical example. + +Arguments: + DEFINE-CANDIDATES-FN: + Function of no args called to fill `icicle-candidates-alist' with + the candidates. + FINAL-ACTION-FN: + Function of no args called after the final choice of candidate + (after both `icicle-explore-final-choice' and + `icicle-explore-final-choice-full' have been set). Typically uses + `icicle-explore-final-choice-full', the full candidate. + QUIT-FN: Function of no args called if user uses `C-g'. + ERROR-FN: Function of no args called if an error is raised. + CLEANUP-FN: Function of no args called after exploring. + PROMPT: Prompt string for `completing-read'. + COMPL-READ-ARGS: `completing-read' args other than PROMPT and + COLLECTION. + +If there is only one candidate, then FINAL-ACTION-FN is called +immediately. The candidate is not available to act on (e.g. using +``C-S-RET'). + +Returns: + The result of executing FINAL-ACTION-FN, if that arg is non-nil. + Otherwise, `icicle-explore-final-choice-full'. + +To use `icicle-explore' to define a multi-command, you must also bind +`icicle-candidate-action-fn'. + +Though `icicle-explore' is typically used to define navigation +commands, it need not be. It can be useful anytime you need to use +`completing-read' and also provide specific behavior for quitting +\(`C-g'), completion errors, and final actions." + (let ((icicle-incremental-completion-flag 'always) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-act-before-cycle-flag icicle-act-before-cycle-flag) + (orig-pt-explore (point-marker)) + (orig-win-explore (selected-window)) + result) + (setq icicle-act-before-cycle-flag nil + icicle-candidates-alist nil + icicle-explore-final-choice nil + icicle-explore-final-choice-full nil) + (icicle-highlight-lighter) + (message "Finding candidates...") + (when define-candidates-fn (funcall define-candidates-fn)) + (unless icicle-candidates-alist (error "No candidates defined")) + (when (= (length icicle-candidates-alist) 1) + (setq icicle-explore-final-choice (icicle-display-cand-from-full-cand + (car icicle-candidates-alist)))) + (unwind-protect + (condition-case failure + (progn + (unless icicle-explore-final-choice + (setq icicle-explore-final-choice + (let ((icicle-remove-icicles-props-p nil)) ; Keep Icicles text properties. + (apply #'completing-read prompt icicle-candidates-alist compl-read-args)))) + (setq icicle-explore-final-choice-full + (funcall icicle-get-alist-candidate-function + icicle-explore-final-choice 'no-error-p)) + (unless icicle-explore-final-choice-full (error "No such occurrence")) + (setq result (if final-action-fn + (funcall final-action-fn) + icicle-explore-final-choice-full))) + (quit (if quit-fn (funcall quit-fn) (keyboard-quit))) + (error (when error-fn (funcall error-fn)) + (error "%s" (error-message-string failure)))) + (setq result (icicle-unpropertize result)) ; Finally remove any Icicles text properties. + (when cleanup-fn (funcall cleanup-fn))) + result)) + +;;;###autoload +(icicle-define-command icicle-execute-extended-command ; Bound to `M-x' in Icicle mode. + "Read command name, then read its arguments and call it. +This is `execute-extended-command', turned into a multi-command. + +By default, Icicle mode remaps all key sequences that are normally +bound to `execute-extended-command' to +`icicle-execute-extended-command'. If you do not want this remapping, +then customize option `icicle-top-level-key-bindings'." ; Doc string + icicle-execute-extended-command-1 ; Function to perform the action + (format "Execute command%s: " ; `completing-read' args + (if current-prefix-arg + (format " (prefix %d)" (prefix-numeric-value current-prefix-arg)) + "")) + obarray 'commandp t nil 'extended-command-history nil nil + (;; Bindings + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "command")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "command"))) + (use-file-dialog nil) ; `mouse-2' in *Completions* shouldn't use file dialog box. + (last-command last-command) ; Save and restore the last command. + new-last-cmd) ; Set in `icicle-execute-extended-command-1'. + nil nil + (setq this-command new-last-cmd)) ; Final code: this will update `last-command'. + +;; Free vars here: `orig-buff' and `orig-window' are bound by `icicle-define-command'. +;; `new-last-cmd' is bound in `icicle-execute-extended-command'. +(defun icicle-execute-extended-command-1 (cmd-name) + "Action function to execute command or named keyboard macro CMD-NAME." + (when (get-buffer orig-buff) (set-buffer orig-buff)) + (when (window-live-p orig-window) (select-window orig-window)) + (when (string= "" cmd-name) (error "No command name")) + + (let* ((cmd (intern cmd-name)) + ;; Rebind `icicle-candidate-action-fn' to a function that calls the + ;; candidate CMD-NAME on a single argument that it reads. This is + ;; used only if CMD-NAME is a command that, itself, reads an input + ;; argument with completion. When that is the case, you can use + ;; completion on that input, and if you do that, you can use `C-RET' + ;; to use command CMD-NAME as a multi-command. In other words, this + ;; binding allows for two levels of multi-commands. + (icicle-candidate-action-fn + (and icicle-candidate-action-fn ; This is nil after the command name is read. + #'(lambda (arg) + (condition-case nil + (funcall cmd arg) ; Try to use string candidate `arg'. + ;; If that didn't work, use a symbol or number candidate. + (wrong-type-argument (funcall cmd (car (read-from-string arg)))) + (wrong-number-of-arguments ; Punt - show help. + (funcall #'icicle-help-on-candidate))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame))))) + (fn (symbol-function cmd)) + (count (prefix-numeric-value current-prefix-arg)) + ;; Rebind alternative action functions to nil, so we don't override the command we call. + (icicle-candidate-alt-action-fn nil) + (icicle-all-candidates-list-alt-action-fn nil)) + ;; Message showing what `cmd' is bound to. This is pretty much a transcription of C code in + ;; `keyboard.c'. Not sure it DTRT when there is already a msg in the echo area. + (when (and suggest-key-bindings (not executing-kbd-macro)) + (let* ((bindings (where-is-internal cmd overriding-local-map t)) + (curr-msg (current-message)) + (wait-time (if curr-msg + (or (and (numberp suggest-key-bindings) suggest-key-bindings) 2) + 0))) + (when (and bindings (not (and (vectorp bindings) (eq (aref bindings 0) 'mouse-movement)))) + (when (and (sit-for wait-time) (atom unread-command-events)) + (let ((message-log-max nil)) ; Don't log this message. + (message "You can run the command `%s' with `%s'" + (symbol-name cmd) + (key-description bindings))) + (when (and (sit-for wait-time) curr-msg) (message curr-msg)))))) + (cond ((arrayp fn) + (let ((this-command cmd)) (execute-kbd-macro fn count)) + (when (> count 1) (message "(%d times)" count))) + (t + (run-hooks 'post-command-hook) + (run-hooks 'pre-command-hook) + (let ((enable-recursive-minibuffers t) + ;; Bind, don't set `this-command'. When you use `C-next', `this-command' needs + ;; to be `cmd' during the `C-RET' part, but `last-command' must not be `cmd' + ;; during the `next' part. + (this-command cmd)) + (call-interactively cmd 'record-it)))) + ;; After `M-x' `last-command' must be the command finally entered with `RET' or, if you end + ;; with `C-g', the last command entered with `C-RET'. + (setq new-last-cmd cmd))) + +;; Inspired by Emacs partial completion and by library `exec-abbrev-cmd.el' (Tassilo Horn +;; ). The idea of command abbreviation is combined here with normal +;; command invocation, in an Icicles multi-command. +;;;###autoload +(icicle-define-command icicle-command-abbrev ; Bound to `C-x SPC' in Icicle mode. + "Read command name or its abbreviation, read command args, call command. +Read input, then call `icicle-command-abbrev-action' to act on it. + +If `icicle-add-proxy-candidates-flag' is non-nil, then command +abbreviations, as well as commands, are available as completion +candidates. Otherwise, only commands are available. You can toggle +this user option using `\\\\[icicle-toggle-proxy-candidates]'\ +in the minibuffer. + +When an abbreviation is available, you can treat it just like a +command. The rest of this description covers the behavior of choosing +an abbreviation. + +If an abbreviation matches a single command name, then that command is +invoked. If it matches more than one, then you can use completion to +choose one. + +Hyphens (`-') in command names divide them into parts. For example, +`find-file' has two parts: `find' and `file'. Each character of a +command abbreviation corresponds to one part of each of the commands +that match the abbreviation. For example, abbreviation `ff' matches +commands `find-file' and `focus-frame', and abbreviation `fg' matches +`find-grep'. + +User option `icicle-command-abbrev-match-all-parts-flag' = nil means +that an abbreviation need not match all parts of a command name; it +need match only a prefix. For example, nil means that abbreviation +`ff' also matches `find-file-other-window' and `fg' also matches +`find-grep-dired'." ; Doc string + icicle-command-abbrev-action ; Function to perform the action + prompt obarray 'commandp ; `completing-read' args + nil nil 'icicle-command-abbrev-history nil nil + ((icicle-sort-comparer 'icicle-command-abbrev-used-more-p) ; Bindings. + (prompt "Command or abbrev: ") + (icicle-proxy-candidates (let ((ipc ()) + abv) + (dolist (entry icicle-command-abbrev-alist ipc) + (setq abv (symbol-name (cadr entry))) + (unless (member abv ipc) (push abv ipc))))) + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "command")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "command"))) + (use-file-dialog nil) ; `mouse-2' in *Completions* shouldn't use file dialog box. + (last-command last-command)) ; Save and restore the last command. + (when icicle-proxy-candidates ; First code + (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + nil (setq icicle-proxy-candidates nil)) ; Undo code, last code + +(defun icicle-command-abbrev-action (abbrev-or-cmd) + "Action function for `icicle-command-abbrev'. +If ABBREV-OR-CMD is a command, call it. +If ABBREV-OR-CMD is an abbreviation for a single command, invoke it. +If ABBREV-OR-CMD is an abbreviation for multiple commands, call +`icicle-command-abbrev-command', to let user choose commands. +If ABBREV-OR-CMD is not an abbreviation or a command, raise an error." + (setq abbrev-or-cmd (intern abbrev-or-cmd)) + (let* ((not-cmdp (not (commandp abbrev-or-cmd))) + (regexp (and (or not-cmdp icicle-command-abbrev-priority-flag) + (icicle-command-abbrev-regexp abbrev-or-cmd))) + (icicle-commands-for-abbrev (and (or not-cmdp icicle-command-abbrev-priority-flag) + (icicle-command-abbrev-matching-commands regexp))) + (icicle-add-proxy-candidates-flag icicle-add-proxy-candidates-flag) + (icicle-proxy-candidates icicle-proxy-candidates) + ;; Rebind alternative action functions to nil, so we don't override command we call. + (icicle-candidate-alt-action-fn nil) + (icicle-all-candidates-list-alt-action-fn nil)) + (cond ((and not-cmdp (null icicle-commands-for-abbrev)) + (error "No such command or abbreviation `%s'" abbrev-or-cmd)) + (icicle-commands-for-abbrev + (let* ((icicle-sort-comparer 'icicle-command-abbrev-used-more-p) + (cmd + (if (null (cdr icicle-commands-for-abbrev)) + (prog1 (intern (caar icicle-commands-for-abbrev)) + (push (caar icicle-commands-for-abbrev) extended-command-history) + (call-interactively (intern (caar icicle-commands-for-abbrev)) t)) + (let ((enable-recursive-minibuffers t)) + (icicle-remove-Completions-window) + (icicle-command-abbrev-command))))) + (icicle-command-abbrev-record abbrev-or-cmd cmd))) + ((not not-cmdp) (call-interactively abbrev-or-cmd))))) + +(defun icicle-command-abbrev-regexp (abbrev) + "Return the command-matching regexp for ABBREV." + (let ((char-list (append (symbol-name abbrev) ())) + (str "^")) + (dolist (c char-list) (setq str (concat str (list c) "[^-]*-"))) + (concat (substring str 0 (1- (length str))) + (if icicle-command-abbrev-match-all-parts-flag "$" ".*$")))) + +(defun icicle-command-abbrev-matching-commands (regexp) + "Return a completion alist of commands that match REGEXP." + (mapcar #'list (icicle-remove-if-not + #'(lambda (strg) (string-match regexp strg)) + (let ((cmds ())) + (mapatoms #'(lambda (symb) + (when (commandp symb) (push (symbol-name symb) cmds)))) + cmds)))) + +;;;###autoload +(icicle-define-command icicle-command-abbrev-command + "Read command name, then read its arguments and call command." ; Doc string + icicle-execute-extended-command-1 ; Function to perform the action + (format "Command abbreviated%s%s: " ; `completing-read' arguments + (cond ((and icicle-current-input (not (string= "" icicle-current-input))) + (format " `%s'" icicle-current-input)) + (icicle-candidate-nb + (format " `%s'" (elt icicle-completion-candidates icicle-candidate-nb))) + (t "")) + (if current-prefix-arg + (format " (prefix %d)" (prefix-numeric-value current-prefix-arg)) + "")) + icicle-commands-for-abbrev nil t nil 'extended-command-history nil nil + (;; Bindings + (use-file-dialog nil) ; `mouse-2' in *Completions* shouldn't use file dialog. + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "command")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "command"))) + (icicle-add-proxy-candidates-flag nil) ; No abbrevs - just commands here. + (last-command last-command) ; Save and restore the last command. + new-last-cmd) ; Set in `icicle-execute-extended-command-1'. + nil nil + (setq this-command new-last-cmd) ; Final code: this will update `last-command'. + 'NON-INTERACTIVE) ; This is not a real command. + +(defun icicle-command-abbrev-record (abbrev command) + "Record ABBREV and COMMAND in `icicle-command-abbrev-alist'." + (let ((entry (assq command icicle-command-abbrev-alist))) + (when (and abbrev command) + (if entry + (setq icicle-command-abbrev-alist (cons (list command abbrev (1+ (car (cddr entry)))) + (delete entry icicle-command-abbrev-alist))) + (push (list command abbrev 1) icicle-command-abbrev-alist))))) + +;;;###autoload +(icicle-define-command icicle-execute-named-keyboard-macro ; Bound to `C-x M-e' in Icicle mode. + "Read the name of a keyboard macro, then execute it." + icicle-execute-extended-command-1 ; Function to perform the action + (format "Execute keyboard macro%s: " ; `completing-read' args + (if current-prefix-arg + (format " (prefix %d)" (prefix-numeric-value current-prefix-arg)) + "")) + obarray #'(lambda (fn) (and (commandp fn) (arrayp (symbol-function fn)))) + t nil 'icicle-kmacro-history nil nil + ((alt-fn nil) + (icicle-candidate-alt-action-fn ; Bindings + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "command")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "command"))) + (last-command last-command))) ; Save and restore the last command. + +;;;###autoload +(when (require 'kmacro nil t) + (icicle-define-command icicle-kmacro ; Bound to `S-f4' in Icicle mode (Emacs 22+). + "Execute a keyboard macro according to its position in `kmacro-ring'. +Macros in the keyboard macro ring are given names `1', `2', and so on, +for use as completion candidates. + +With prefix argument, repeat macro that many times (but see below). +If a macro is still being defined, end it first, then execute it. + +Since this is a multi-command, you can execute any number of macros +any number of times in a single invocation. In particular, you can +execute a given macro repeatedly using `C-RET' (be sure you use `TAB' +first, to make it the current candidate). + +If you use a prefix arg for `icicle-kmacro', then each multi-command +action (e.g. `C-RET') repeats the macro that number of times. However +if you use a prefix arg for an individual action, then the action +repeats the macro that number of times. Without its own prefix arg, +an action uses the base prefix arg you used for `icicle-kmacro'." + icicle-kmacro-action ; Function to perform the action + (format "Execute keyboard macro%s: " ; `completing-read' args + (if current-prefix-arg + (format " (prefix %s)" (prefix-numeric-value current-prefix-arg)) + "")) + (let ((count 0)) + (setq icicle-kmacro-alist + (mapcar #'(lambda (x) (cons (format "%d" (setq count (1+ count))) x)) + (reverse (if nil kmacro-ring (cons (kmacro-ring-head) kmacro-ring)))))) + nil 'no-exit-wo-match nil 'icicle-kmacro-history + (and (kmacro-ring-head) (null kmacro-ring) "1") nil + ((pref-arg current-prefix-arg)) ; Additional bindings + (progn ; First code + (when defining-kbd-macro (kmacro-end-or-call-macro current-prefix-arg) (error "Done")) + (unless (or (kmacro-ring-head) kmacro-ring) (error "No keyboard macro defined")))) + + ;; Free vars here: `orig-buff' and `orig-window' are bound by `icicle-define-command'. + (defun icicle-kmacro-action (cand) + "Action function for `icicle-kmacro'." + (when (get-buffer orig-buff) (set-buffer orig-buff)) + (when (window-live-p orig-window) (select-window orig-window)) + (let* ((count (if current-prefix-arg (prefix-numeric-value current-prefix-arg) pref-arg)) + (macro (cadr (assoc cand icicle-kmacro-alist)))) + (unless macro (error "No such macro: `%s'" cand)) + (execute-kbd-macro macro count #'kmacro-loop-setup-function) + (when (> count 1) (message "(%d times)" count))))) + +;;;###autoload +(icicle-define-command icicle-set-option-to-t ; Command name + "Set option to t. This makes sense for binary (toggle) options. +By default, completion candidates are limited to user options that +have `boolean' custom types. However, there are many \"binary\" options +that allow other non-nil values than t. + +You can use a prefix argument to change the set of completion +candidates, as follows: + + - With a non-negative prefix arg, all user options are candidates. + - With a negative prefix arg, all variables are candidates." ; Doc string + (lambda (opt) (set (intern opt) t) (message "`%s' is now t" opt)) ; Action function + "Set option to t: " obarray ; `completing-read' args + (cond ((and current-prefix-arg (wholenump (prefix-numeric-value current-prefix-arg))) + #'(lambda (x) (and (boundp x) (user-variable-p x) (eq nil (symbol-value x))))) + (current-prefix-arg + #'(lambda (x) (and (boundp x) (eq nil (symbol-value x))))) + (t + #'(lambda (x) (and (boundp x) (icicle-binary-option-p x) (eq nil (symbol-value x)))))) + 'must-confirm nil + (if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil + ((enable-recursive-minibuffers t) ; Bindings + (icicle-use-candidates-only-once-flag t) + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "option")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "option"))))) + +;;;###autoload +(icicle-define-command icicle-clear-history + "Clear a minibuffer history of selected entries. +You are prompted for the history to clear, then you are prompted for +the entries to delete from it. You can use multi-command completion +for both inputs. That is, you can act on multiple histories and +delete multiple entries from each. + +For convenience, you can use `S-delete' the same way as `C-RET': Each +of them deletes the current entry candidate from the history. + +With a prefix argument, empty the chosen history completely +\(you are not prompted to choose history entries to delete). + +`icicle-act-before-cycle-flag' is bound to t here during completion of +history entries, so `C-next' and so on act on the current candidate." + icicle-clear-history-1 ; Function to perform the action + "History to clear: " icicle-clear-history-hist-vars ; `completing-read' args + nil t nil nil (symbol-name minibuffer-history-variable) nil + ((pref-arg current-prefix-arg) ; Bindings + (enable-recursive-minibuffers t) + (icicle-transform-function 'icicle-remove-duplicates) + (icicle-clear-history-hist-vars `((,(symbol-name minibuffer-history-variable)) + (,(symbol-name 'icicle-previous-raw-file-name-inputs)) + (,(symbol-name 'icicle-previous-raw-non-file-name-inputs)))) + (icicle-delete-candidate-object 'icicle-clear-history-entry)) + (mapatoms #'(lambda (x) (when (and (boundp x) (consp (symbol-value x)) ; First code + (stringp (car (symbol-value x))) + (string-match "-\\(history\\|ring\\)\\'" (symbol-name x))) + (push (list (symbol-name x)) icicle-clear-history-hist-vars))))) + +;; Free vars here: `pref-arg' is bound in `icicle-clear-history'. +(defun icicle-clear-history-1 (hist) + "Action function for `icicle-clear-history' history-variable candidates." + (setq hist (intern hist)) + (if (not pref-arg) + (let* ((icicle-candidate-action-fn 'icicle-clear-history-entry) + (icicle-transform-function 'icicle-remove-duplicates) + (icicle-clear-history-hist hist) + (icicle-use-candidates-only-once-flag t) + (icicle-show-Completions-initially-flag t) + (icicle-act-before-cycle-flag t)) + (when hist ; Maybe there are no more, due to deletion actions. + (funcall icicle-candidate-action-fn + (completing-read "Clear input: " (mapcar #'list (symbol-value hist)) nil t)))) + (set hist nil)) + (unless hist (message "History `%s' is now empty" hist)) + nil) + +;; Free vars here: `icicle-clear-history-hist' is bound in `icicle-clear-history-1' +;; and in `icicle-clear-current-history'. +(defun icicle-clear-history-entry (cand) + "Action function for history entry candidates in `icicle-clear-history'." + (unless (string= "" cand) + (set icicle-clear-history-hist + (icicle-remove-if + #'(lambda (x) + (string= (icicle-substring-no-properties cand) (icicle-substring-no-properties x))) + (symbol-value icicle-clear-history-hist))) + ;; We assume here that CAND was in fact present in the history originally. + (message "`%s' deleted from history `%s'" cand icicle-clear-history-hist)) + nil) + +;;;###autoload +(icicle-define-command icicle-clear-current-history ; Bound to `M-i' in minibuffer. + "Clear current minibuffer history of selected entries. +You are prompted for the history entries to delete. + +With a prefix argument, however, empty the history completely +\(you are not prompted to choose history entries to delete). + +`icicle-act-before-cycle-flag' is bound to t here during completion of +history entries, so `C-next' and so on act on the current candidate." + icicle-clear-history-entry ; Action function + "Clear input: " (mapcar #'list (symbol-value icicle-clear-history-hist)) ; `completing-read' args + nil t nil nil nil nil + ((pref-arg current-prefix-arg) ; Bindings + (enable-recursive-minibuffers t) + (icicle-transform-function 'icicle-remove-duplicates) + (icicle-use-candidates-only-once-flag t) + (icicle-show-Completions-initially-flag t) + (icicle-clear-history-hist minibuffer-history-variable)) + (when pref-arg ; Use `error' just to exit and make sure message is seen. + (icicle-ding) + (if (not (yes-or-no-p (format "Are you sure you want to empty `%s' completely? " + minibuffer-history-variable))) + (error "") + (set minibuffer-history-variable nil) + (error "History `%s' is now empty" minibuffer-history-variable)))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'clear-option))) + (defalias 'clear-option 'icicle-reset-option-to-nil)) +;;;###autoload +(icicle-define-command icicle-reset-option-to-nil ; Command name + "Set option to nil. This makes sense for binary and list options. +By default, the set of completion candidates is limited to user +options. Note: it is *not* limited to binary and list options. +With a prefix arg, all variables are candidates." ; Doc string + (lambda (opt) (set (intern opt) nil) (message "`%s' is now nil" opt)) ; Action function + "Clear option (set it to nil): " obarray ; `completing-read' args + (if current-prefix-arg + #'(lambda (x) (and (boundp x) (symbol-value x))) + #'(lambda (x) (and (boundp x) (user-variable-p x) (symbol-value x)))) + t nil (if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) + nil nil + ((enable-recursive-minibuffers t) ; Bindings + (icicle-use-candidates-only-once-flag t) + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "option")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "option"))))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'toggle))) + (defalias 'toggle 'icicle-toggle-option)) +;;;###autoload +(icicle-define-command icicle-toggle-option ; Command name + "Toggle option's value. This makes sense for binary (toggle) options. +By default, completion candidates are limited to user options that +have `boolean' custom types. However, there are many \"binary\" options +that allow other non-nil values than t. + +You can use a prefix argument to change the set of completion +candidates, as follows: + + - With a non-negative prefix arg, all user options are candidates. + - With a negative prefix arg, all variables are candidates." ; Doc string + (lambda (opt) ; Action function + (let ((sym (intern opt))) + (set sym (not (eval sym))) (message "`%s' is now %s" opt (eval sym)))) + "Toggle value of option: " obarray ; `completing-read' args + (cond ((and current-prefix-arg (wholenump (prefix-numeric-value current-prefix-arg))) + 'user-variable-p) + (current-prefix-arg 'boundp) + (t 'icicle-binary-option-p)) + 'must-confirm nil + (if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil + ((enable-recursive-minibuffers t) ; Bindings + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "option")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "option"))))) + +(defun icicle-binary-option-p (symbol) + "Non-nil if SYMBOL is a user option that has custom-type `boolean'." + (eq (get symbol 'custom-type) 'boolean)) + +;;;###autoload +(icicle-define-command icicle-increment-option ; Command name + "Increment option's value using the arrow keys (`up', `down'). +Completion candidates are limited to options that have `integer', +`float', and `number' custom types. +This command needs library `doremi.el'." ; Doc string + (lambda (opt) ; Action function + (let ((sym (intern opt))) + (icicle-doremi-increment-variable+ sym (icicle-read-number "Increment (amount): ") t) + (message "`%s' is now %s" opt (eval sym)))) + "Increment value of option: " obarray ; `completing-read' args + (lambda (symbol) (memq (get symbol 'custom-type) '(number integer float))) + 'must-confirm nil + (if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil + ((enable-recursive-minibuffers t) ; Bindings + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "option")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "option")))) + (unless (require 'doremi nil t) (error "This command needs library `doremi.el'."))) ; First code + +;;;###autoload +(icicle-define-command icicle-increment-variable ; Command name + "Increment variable's value using the arrow keys (`up', `down'). +With a prefix arg, only numeric user options are candidates. +This command needs library `doremi.el'." ; Doc string + (lambda (opt) ; Action function + (let ((sym (intern opt))) + (icicle-doremi-increment-variable+ sym (icicle-read-number "Increment (amount): ") prefix-arg) + (message "`%s' is now %s" opt (eval sym)))) + "Increment value of variable: " obarray ; `completing-read' args + (if prefix-arg + (lambda (symbol) (memq (get symbol 'custom-type) '(number integer float))) + 'boundp) + 'must-confirm nil + (if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil + ((enable-recursive-minibuffers t) ; Bindings + (prefix-arg current-prefix-arg) + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (setq alt-fn (icicle-alt-act-fn-for-type (if prefix-arg "option" "variable"))))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn + (icicle-alt-act-fn-for-type (if prefix-arg "option" "variable"))))) + (unless (require 'doremi nil t) (error "This command needs library `doremi.el'."))) ; First code + +;;;###autoload +(defun icicle-doremi-increment-variable+ (variable &optional increment optionp) + "Increment VARIABLE by INCREMENT (default 1). +Use `up', `down' or mouse wheel to increase or decrease. You can use +the `Meta' key (e.g. `M-up') to increment in larger steps. + +Interactively, you can choose VARIABLE using completion. +With a prefix arg, only user options are available to choose from. +Raises an error if VARIABLE's value is not a number." + (interactive + (let ((symb (or (and (fboundp 'symbol-nearest-point) (symbol-nearest-point)) + (and (symbolp (variable-at-point)) (variable-at-point)))) + (enable-recursive-minibuffers t)) + (list (intern (completing-read "Increment variable: " obarray + (if current-prefix-arg 'user-variable-p 'boundp) + t nil nil (and symb (symbol-name symb)) t)) + (icicle-read-number "Increment (amount): ") + current-prefix-arg))) + (unless (require 'doremi nil t) (error "This command needs library `doremi.el'.")) + (unless increment (setq increment 1)) + (unless (numberp (symbol-value variable)) + (error "Variable's value is not a number: %S" (symbol-value variable))) + (doremi (lambda (new-val) + (set variable new-val) + new-val) + (symbol-value variable) + increment)) + +;;;###autoload +(icicle-define-command icicle-bookmark-list ; Command name + "Choose a list of bookmark names. +If `icicle-bookmark-types' is non-nil, then it is a list of bookmark +types and only bookmarks of those types are candidates. + +You can use `S-delete' during completion to delete a candidate bookmark. +The list of bookmark names (strings) is returned." ; Doc string + (lambda (name) (push (icicle-substring-no-properties (icicle-transform-multi-completion name)) + bmk-names)) ; Action function + "Choose bookmark (`RET' when done): " icicle-candidates-alist nil ; `completing-read' args + (not icicle-show-multi-completion-flag) + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + (and (boundp 'bookmark-current-bookmark) bookmark-current-bookmark) nil + ((enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on disk... + (completion-ignore-case bookmark-completion-ignore-case) + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (types icicle-bookmark-types) + (icicle-candidates-alist ()) + (bmk-names ()) + (icicle-sort-orders-alist + (append '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p)) + (and (featurep 'bookmark+) + (append + '(("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p)) + (and (icicle-set-intersection types '("info" "region")) + '(("by Info location" (bmkp-info-cp) icicle-alpha-p))) + (and (icicle-set-intersection types '("gnus" "region")) + '(("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p))) + (and (icicle-set-intersection types '("url" "region")) + '(("by URL" (bmkp-url-cp) icicle-alpha-p))) + (and (icicle-set-difference types + '("bookmark-list" "desktop" "gnus" "info" "man" "url")) + '(("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + (and (icicle-set-difference + types '("bookmark-list" "desktop" "dired" "non-file")) + '(("by file name" (bmkp-file-alpha-cp) icicle-alpha-p))) + (and (icicle-set-intersection types + '("local-file" "file" "dired" "region")) + '(("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" + (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p))) + (and (not (equal types '("desktop"))) + '(("by last buffer or file access" + (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p))) + (and (get-buffer "*Bookmark List*") + '(("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p))))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when (and (featurep 'bookmark+) icicle-show-multi-completion-flag) + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if (featurep 'bookmark+) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)) + (icicle-msg-maybe-in-minibuffer (icicle-bookmark-help-string cand)))))) + (progn + (message "Gathering bookmarks...") + (unless types (setq types '(all))) + (dolist (type types) ; First code + (setq icicle-candidates-alist + (nconc icicle-candidates-alist + (if (not (featurep 'bookmark+)) + (mapcar #'(lambda (cand) (list (icicle-candidate-short-help + (icicle-bookmark-help-string cand) + (icicle-bookmark-propertize-candidate cand)))) + (if (eq type 'all) + bookmark-alist + (funcall (intern (format "bmkp-%s-alist-only" type))))) + (bookmark-maybe-load-default-file) ; Load bookmarks, define `bookmark-alist'. + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad bookmark. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf + (if (and buf + (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + (cons `(,(icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + ,file/buf + ,@(and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad bookmark. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (bmkp-sort-and-remove-dups + (if (eq type 'all) + bookmark-alist + (funcall (intern (format "bmkp-%s-alist-only" type))))))))))) + (icicle-bookmark-cleanup-on-quit) ; Undo code + (prog1 (setq bmk-names (nreverse (delete "" bmk-names))) ; Last code - return the list. + (icicle-bookmark-cleanup) + (when (interactive-p) (message "Bookmarks: %S" bmk-names)))) + +;;;###autoload +(defun icicle-bookmark-cmd (&optional parg) ; Bound to what `bookmark-set' is bound to (`C-x r m'). + "Set bookmark or visit bookmark(s). +With a negative prefix arg, visit bookmark(s), using + `icicle-bookmark-other-window' (see that command for more info). + +Otherwise, set a bookmark, as follows: + +* No prefix arg: Prompt for the bookmark name. + + If feature `bookmark+' is present: + + . You can use (lax) completion for the bookmark name. + The candidates are bookmarks in the current buffer (or all + bookmarks if there are none in this buffer). + + . If the region is active and nonempty, then use the buffer name + followed by the region prefix as the default name. + + If feature `bookmark+' is not present, then completion is not + available, and the default bookmark name is the last one used in + this buffer. + + Note: You can use command `icicle-bookmark-set' with a numeric + prefix arg if you want to complete against all bookmark names, + instead of those for the current buffer. + +* Plain prefix arg (`C-u'): Same as no prefix arg, but do not + overwrite any existing bookmark that has the same name. + +* Non-negative numeric prefix arg: Do not prompt for bookmark name. + If feature `bookmark+' is present and the region is active and + nonempty, then use the buffer name followed by a prefix of the + region text as the bookmark name. + Otherwise, use the buffer name followed by the text of the current + line, starting at point. + Use at most `icicle-bookmark-name-length-max' chars, in either case. + If the prefix arg is 0, then do not overwrite any existing bookmark + that has the same name. + +By default, Icicle mode remaps all key sequences that are normally +bound to `bookmark-set' to `icicle-bookmark-cmd'. If you do not want +this remapping, then customize option `icicle-top-level-key-bindings'. +In particular, you might prefer to remap `bookmark-set' to +`icicle-bookmark-set' (see Note, above)." + (interactive "P") + (if (and parg (< (prefix-numeric-value parg) 0)) + (icicle-bookmark-other-window) + (if (or (not parg) (consp parg)) + (icicle-bookmark-set nil parg 'PSEUDO-INTERACTIVEP) + (let* ((regionp (and (featurep 'bookmark+) transient-mark-mode mark-active + (not (eq (region-beginning) (region-end))))) + (name-beg (if regionp (region-beginning) (point))) + (name-end (if regionp (region-end) (save-excursion (end-of-line) (point)))) + (def-name (concat (buffer-name) ": " (buffer-substring name-beg name-end))) + (trim-name (replace-regexp-in-string + "\n" " " (substring def-name 0 (min icicle-bookmark-name-length-max + (length def-name)))))) + (message "Setting bookmark `%s'" trim-name) (sit-for 2) + (bookmark-set trim-name (and parg (or (consp parg) + (zerop (prefix-numeric-value parg))))))))) + +;;;###autoload +(defun icicle-bookmark-set (&optional name parg interactivep) ; `C-x r m' + "With Bookmark+, this is `bookmark-set' with Icicles multi-completions. +In particular, you can use (lax) completion for the bookmark name. +Without library `bookmark+.el', this is the same as vanilla Emacs +`bookmark-set'." + (interactive (list nil current-prefix-arg t)) + (if (not (featurep 'bookmark+)) + (bookmark-set name parg) + (unwind-protect + (let ((enable-recursive-minibuffers t) ; In case read input, e.g. File changed... + (completion-ignore-case bookmark-completion-ignore-case) + (prompt "Bookmark: ") + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (and (not (interactive-p)) + icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-sort-orders-alist + (append '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p)) + (and (featurep 'bookmark+) + '(("by last bookmark access" (bmkp-bookmark-last-access-cp) + icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) + icicle-alpha-p) + ("by last buffer or file access" + (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p) + ("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by file name" (bmkp-file-alpha-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" + (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" + (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p) + ("by Info location" (bmkp-info-cp) icicle-alpha-p) + ("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p) + ("by URL" (bmkp-url-cp) icicle-alpha-p) + ("by bookmark type" + (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when (and (featurep 'bookmark+) icicle-show-multi-completion-flag) + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if (featurep 'bookmark+) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)) + (icicle-msg-maybe-in-minibuffer (icicle-bookmark-help-string cand))))) + (icicle-candidates-alist + (if (not (featurep 'bookmark+)) + (mapcar #'(lambda (cand) + (list (icicle-candidate-short-help + (icicle-bookmark-help-string cand) + (icicle-bookmark-propertize-candidate cand)))) + (bookmark-all-names)) ; Loads bookmarks file. + (bookmark-maybe-load-default-file) ; Loads bookmarks file. + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (tags (bmkp-get-tags bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf + (if (and buf (equal file bmkp-non-file-filename)) + buf + file))) + (cons `(,(icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + ,file/buf + ,@(and tags (list (format "%S" tags)))) + guts))) + #'(lambda (bmk) + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)))) + (bmkp-sort-and-remove-dups + (and (or (not parg) (consp parg)) ; No numeric PARG: all bookmarks. + (or (bmkp-specific-buffers-alist-only) + bookmark-alist))))))) + (require 'bookmark) + (when (featurep 'bookmark+) + ;; Bind keys to narrow bookmark candidates by type. Lax is for multi-completion case. + (dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map)) + (define-key (symbol-value map) "\C-\M-b" 'icicle-bookmark-non-file-narrow) ; `C-M-b' + (define-key (symbol-value map) "\C-\M-d" 'icicle-bookmark-dired-narrow) ; `C-M-d' + (define-key (symbol-value map) "\C-\M-f" 'icicle-bookmark-file-narrow) ; `C-M-f' + (define-key (symbol-value map) "\C-\M-g" 'icicle-bookmark-gnus-narrow) ; `C-M-g' + (define-key (symbol-value map) "\C-\M-m" 'icicle-bookmark-man-narrow) ; `C-M-m' + (define-key (symbol-value map) "\C-\M-r" 'icicle-bookmark-region-narrow) ; `C-M-r' + (define-key (symbol-value map) "\C-\M-u" 'icicle-bookmark-url-narrow) ; `C-M-u' + (define-key (symbol-value map) "\C-\M-w" 'icicle-bookmark-w3m-narrow) ; `C-M-w' + (define-key (symbol-value map) "\C-\M-@" 'icicle-bookmark-remote-file-narrow) ; C-M-@ + (define-key (symbol-value map) [(control meta ?=) ?b] ; `C-M-= b' + 'icicle-bookmark-specific-buffers-narrow) + (define-key (symbol-value map) [(control meta ?=) ?f] ; `C-M-= f' + 'icicle-bookmark-specific-files-narrow) + (define-key (symbol-value map) [(control meta ?\.)] ; `C-M-= .' + 'icicle-bookmark-this-buffer-narrow) + (define-key (symbol-value map) [(control meta ?B)] ; `C-M-B' + 'icicle-bookmark-bookmark-list-narrow) + (define-key (symbol-value map) [(control meta ?F)] ; `C-M-F' + 'icicle-bookmark-local-file-narrow) + (define-key (symbol-value map) [(control meta ?I)] ; `C-M-I' + 'icicle-bookmark-info-narrow) + (define-key (symbol-value map) [(control meta ?K)] ; `C-M-K' + 'icicle-bookmark-desktop-narrow))) + (setq bookmark-current-point (point) + bookmark-current-buffer (current-buffer)) + (save-excursion (skip-chars-forward " ") (setq bookmark-yank-point (point))) + (let* ((record (bookmark-make-record)) + (regionp (and transient-mark-mode mark-active (not (eq (mark) (point))))) + (regname (concat (buffer-name) ": " + (buffer-substring (if regionp (region-beginning) (point)) + (if regionp + (region-end) + (save-excursion (end-of-line) (point)))))) + (defname (bmkp-replace-regexp-in-string + "\n" " " + (cond (regionp + (save-excursion + (goto-char (region-beginning)) + (skip-chars-forward " ") (setq bookmark-yank-point (point))) + (substring regname 0 (min bmkp-bookmark-name-length-max + (length regname)))) + ((eq major-mode 'w3m-mode) w3m-current-title) + ((eq major-mode 'gnus-summary-mode) + (elt (gnus-summary-article-header) 1)) + ((memq major-mode '(Man-mode woman-mode)) + (buffer-substring (point-min) (save-excursion + (goto-char (point-min)) + (skip-syntax-forward "^ ") + (point)))) + (t (car record))))) + (bname (or name + (icicle-transform-multi-completion + (bmkp-completing-read-lax "Set bookmark " defname + icicle-candidates-alist + nil bookmark-history))))) + (when (string-equal bname "") (setq bname defname)) + (bookmark-store bname (cdr record) (consp parg)) + (when (and bmkp-prompt-for-tags-flag interactivep) + (bmkp-add-tags bname (bmkp-read-tags-completing))) + (case (and (boundp 'bmkp-auto-light-when-set) bmkp-auto-light-when-set) + (autonamed-bookmark (when (bmkp-autonamed-bookmark-p bname) + (bmkp-light-bookmark bname))) + (non-autonamed-bookmark (unless (bmkp-autonamed-bookmark-p bname) + (bmkp-light-bookmark bname))) + (any-bookmark (bmkp-light-bookmark bname)) + (autonamed-in-buffer (bmkp-light-bookmarks + (bmkp-remove-if-not + #'bmkp-autonamed-bookmark-p + (bmkp-this-buffer-alist-only)) nil 'MSG)) + (non-autonamed-in-buffer (bmkp-light-bookmarks + (bmkp-remove-if + #'bmkp-autonamed-bookmark-p + (bmkp-this-buffer-alist-only)) nil 'MSG)) + (all-in-buffer (bmkp-light-bookmarks-this-buffer nil 'MSG))) + (run-hooks 'bmkp-after-set-hook) + (if bookmark-use-annotations + (bookmark-edit-annotation bname) + (goto-char bookmark-current-point)))) + (icicle-bookmark-cleanup)))) + +;;;###autoload +(icicle-define-command icicle-bookmark ; Command name + "Jump to a bookmark. +With a plain prefix argument (`C-u'), reverse the effect of option +`icicle-bookmark-refresh-cache-flag'. + +During completion, you can use `S-delete' on a bookmark to delete it. + +If you also use library `bookmark+.el', then: + + * `C-M-RET' shows detailed info about the current bookmark candidate. + `C-u C-M-RET' shows the complete, internal info for the bookmark. + Likewise, for the other candidate help keys: `C-M-down' etc. + (And the mode line always shows summary info about the bookmark.) + + * You can use `C-,' to sort bookmarks in many different ways, + according to their properties. + + * In *Completions*, the candidate bookmarks are highlighted according + to their type. You can customize the highlighting faces used: + + `bmkp-bad-bookmark' - possibly bad bookmark + `bmkp-bookmark-list' - bookmark list + `bmkp-buffer' - buffer + `bmkp-desktop' - desktop + `bmkp-function' - function bookmark + `bmkp-gnus' - Gnus article + `bmkp-info' - Info node + `bmkp-local-directory' - local directory + `bmkp-local-file-with-region' - local file with a region + `bmkp-local-file-without-region' - local file without a region + `bmkp-man' - `man' page + `bmkp-non-file' - non-file (no current buffer) + `bmkp-remote-file' - remote-file + `bmkp-sequence' - sequence bookmark + `bmkp-url' - URL + + * In *Completions*, if option `icicle-show-multi-completion-flag' is + non-nil, then each completion candidate is a multi-completion: + + a. the bookmark name + b. the bookmark file or buffer name + c. any tags + + You can match any parts of the multi-completion. You can toggle + the option (for the next command) using `M-m' during completion. + For example, you can match all bookmarks that have tags by typing: + + C-M-j . * C-M-j S-TAB + + (Each `C-M-j' inserts `^G\n', which is `icicle-list-join-string'.) + + * You can narrow the current completion candidates to bookmarks of a + given type: + + `C-M-b' - non-file (buffer) bookmarks + `C-M-B' - bookmark-list bookmarks + `C-M-d' - Dired bookmarks + `C-M-f' - file bookmarks + `C-M-F' - local-file bookmarks + `C-M-g' - Gnus bookmarks + `C-M-I' - Info bookmarks + `C-M-K' - desktop bookmarks + `C-M-m' - `man' pages + `C-M-r' - bookmarks with regions + `C-M-u' - URL bookmarks + `C-M-w' - W3M (URL) bookmarks + `C-M-@' - remote-file bookmarks + `C-M-.' - bookmarks for the current buffer + `C-M-= b' - bookmarks for specific buffers + `C-M-= f' - bookmarks for specific files + + See also the individual multi-commands for different bookmark + types: `icicle-bookmark-info-other-window' etc. + +If you also use library `crosshairs.el', then the visited bookmark +position is highlighted." ; Doc string + (lambda (cand) (icicle-bookmark-jump (icicle-transform-multi-completion cand))) ; Action + prompt icicle-candidates-alist nil (not icicle-show-multi-completion-flag) ; `completing-read' args + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + (and (boundp 'bookmark-current-bookmark) bookmark-current-bookmark) nil + ((enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on disk... + (completion-ignore-case bookmark-completion-ignore-case) + (prompt "Bookmark: ") + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (icicle-sort-orders-alist + (append '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p)) + (and (featurep 'bookmark+) + '(("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p) + ("by last buffer or file access" (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p) + ("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by file name" (bmkp-file-alpha-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p) + ("by Info location" (bmkp-info-cp) icicle-alpha-p) + ("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p) + ("by URL" (bmkp-url-cp) icicle-alpha-p) + ("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when (and (featurep 'bookmark+) icicle-show-multi-completion-flag) + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if (featurep 'bookmark+) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)) + (icicle-msg-maybe-in-minibuffer (icicle-bookmark-help-string cand))))) + (icicle-candidates-alist + (if (not (featurep 'bookmark+)) + (mapcar #'(lambda (cand) + (list (icicle-candidate-short-help (icicle-bookmark-help-string cand) + (icicle-bookmark-propertize-candidate cand)))) + (bookmark-all-names)) ; Loads bookmarks file, defining `bookmark-alist'. + (bookmark-maybe-load-default-file) ; Loads bookmarks file, defining `bookmark-alist'. + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf (if (and buf (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + (cons `(,(icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + ,file/buf + ,@(and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (or (and (or (and (not icicle-bookmark-refresh-cache-flag) + (not (consp current-prefix-arg))) + (and icicle-bookmark-refresh-cache-flag (consp current-prefix-arg))) + bmkp-sorted-alist) + (setq bmkp-sorted-alist + (bmkp-sort-and-remove-dups bookmark-alist))))))) + (progn ; First code + (require 'bookmark) + (when (featurep 'bookmark+) + ;; Bind keys to narrow bookmark candidates by type. Lax is for multi-completion case. + (dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map)) + (define-key (symbol-value map) "\C-\M-b" 'icicle-bookmark-non-file-narrow) ; `C-M-b' + (define-key (symbol-value map) "\C-\M-d" 'icicle-bookmark-dired-narrow) ; `C-M-d' + (define-key (symbol-value map) "\C-\M-f" 'icicle-bookmark-file-narrow) ; `C-M-f' + (define-key (symbol-value map) "\C-\M-g" 'icicle-bookmark-gnus-narrow) ; `C-M-g' + (define-key (symbol-value map) "\C-\M-m" 'icicle-bookmark-man-narrow) ; `C-M-m' + (define-key (symbol-value map) "\C-\M-r" 'icicle-bookmark-region-narrow) ; `C-M-r' + (define-key (symbol-value map) "\C-\M-u" 'icicle-bookmark-url-narrow) ; `C-M-u' + (define-key (symbol-value map) "\C-\M-w" 'icicle-bookmark-w3m-narrow) ; `C-M-w' + (define-key (symbol-value map) "\C-\M-@" 'icicle-bookmark-remote-file-narrow) ; `C-M-@' + (define-key (symbol-value map) [(control meta ?=) ?b] ; `C-M-= b' + 'icicle-bookmark-specific-buffers-narrow) + (define-key (symbol-value map) [(control meta ?=) ?f] ; `C-M-= f' + 'icicle-bookmark-specific-files-narrow) + (define-key (symbol-value map) [(control meta ?\.)] ; `C-M-= .' + 'icicle-bookmark-this-buffer-narrow) + (define-key (symbol-value map) [(control meta ?B)] ; `C-M-B' + 'icicle-bookmark-bookmark-list-narrow) + (define-key (symbol-value map) [(control meta ?F)] ; `C-M-F' + 'icicle-bookmark-local-file-narrow) + (define-key (symbol-value map) [(control meta ?I)] ; `C-M-I' + 'icicle-bookmark-info-narrow) + (define-key (symbol-value map) [(control meta ?K)] ; `C-M-K' + 'icicle-bookmark-desktop-narrow)))) + (icicle-bookmark-cleanup-on-quit) ; Undo code + (icicle-bookmark-cleanup)) ; Last code + +;;;###autoload +(icicle-define-command icicle-bookmark-other-window ; Command name + "Jump to a bookmark in another window. +Same as `icicle-bookmark', but uses another window." ; Doc string + (lambda (cand) (icicle-bookmark-jump-other-window (icicle-transform-multi-completion cand))) + prompt icicle-candidates-alist nil (not icicle-show-multi-completion-flag) ; `completing-read' args + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + (and (boundp 'bookmark-current-bookmark) bookmark-current-bookmark) nil + ((enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on disk... + (completion-ignore-case bookmark-completion-ignore-case) + (prompt "Bookmark: ") + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (icicle-sort-orders-alist + (append '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p)) + (and (featurep 'bookmark+) + '(("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p) + ("by last buffer or file access" (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p) + ("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by file name" (bmkp-file-alpha-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p) + ("by Info location" (bmkp-info-cp) icicle-alpha-p) + ("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p) + ("by URL" (bmkp-url-cp) icicle-alpha-p) + ("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when (and (featurep 'bookmark+) icicle-show-multi-completion-flag) + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if (featurep 'bookmark+) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)) + (icicle-msg-maybe-in-minibuffer (icicle-bookmark-help-string cand))))) + (icicle-candidates-alist + (if (not (featurep 'bookmark+)) + (mapcar #'(lambda (cand) + (list (icicle-candidate-short-help (icicle-bookmark-help-string cand) + (icicle-bookmark-propertize-candidate cand)))) + (bookmark-all-names)) ; Loads bookmarks file, defining `bookmark-alist'. + (bookmark-maybe-load-default-file) ; Loads bookmarks file, defining `bookmark-alist'. + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf (if (and buf (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + (cons `(,(icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + ,file/buf + ,@(and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (or (and (or (and (not icicle-bookmark-refresh-cache-flag) + (not (consp current-prefix-arg))) + (and icicle-bookmark-refresh-cache-flag (consp current-prefix-arg))) + bmkp-sorted-alist) + (setq bmkp-sorted-alist + (bmkp-sort-and-remove-dups bookmark-alist))))))) + (progn ; First code + (require 'bookmark) + (when (featurep 'bookmark+) + ;; Bind keys to narrow bookmark candidates by type. Lax is for multi-completion case. + (dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map)) + (define-key (symbol-value map) "\C-\M-b" 'icicle-bookmark-non-file-narrow) ; `C-M-b' + (define-key (symbol-value map) "\C-\M-d" 'icicle-bookmark-dired-narrow) ; `C-M-d' + (define-key (symbol-value map) "\C-\M-f" 'icicle-bookmark-file-narrow) ; `C-M-f' + (define-key (symbol-value map) "\C-\M-g" 'icicle-bookmark-gnus-narrow) ; `C-M-g' + (define-key (symbol-value map) "\C-\M-m" 'icicle-bookmark-man-narrow) ; `C-M-m' + (define-key (symbol-value map) "\C-\M-r" 'icicle-bookmark-region-narrow) ; `C-M-r' + (define-key (symbol-value map) "\C-\M-u" 'icicle-bookmark-url-narrow) ; `C-M-u' + (define-key (symbol-value map) "\C-\M-w" 'icicle-bookmark-w3m-narrow) ; `C-M-w' + (define-key (symbol-value map) "\C-\M-@" 'icicle-bookmark-remote-file-narrow) ; `C-M-@' + (define-key (symbol-value map) [(control meta ?=) ?b] ; `C-M-= b' + 'icicle-bookmark-specific-buffers-narrow) + (define-key (symbol-value map) [(control meta ?=) ?f] ; `C-M-= f' + 'icicle-bookmark-specific-files-narrow) + (define-key (symbol-value map) [(control meta ?\.)] ; `C-M-= .' + 'icicle-bookmark-this-buffer-narrow) + (define-key (symbol-value map) [(control meta ?B)] ; `C-M-B' + 'icicle-bookmark-bookmark-list-narrow) + (define-key (symbol-value map) [(control meta ?F)] ; `C-M-F' + 'icicle-bookmark-local-file-narrow) + (define-key (symbol-value map) [(control meta ?I)] ; `C-M-I' + 'icicle-bookmark-info-narrow) + (define-key (symbol-value map) [(control meta ?K)] ; `C-M-K' + 'icicle-bookmark-desktop-narrow)))) + (icicle-bookmark-cleanup-on-quit) ; Undo code + (icicle-bookmark-cleanup)) ; Last code + +(defun icicle-bookmark-delete-action (cand) + "Delete bookmark candidate CAND, then update `bmkp-sorted-alist'." + (bookmark-delete (icicle-transform-multi-completion cand)) + (when (or (and (not icicle-bookmark-refresh-cache-flag) + (not (consp current-prefix-arg))) + (and icicle-bookmark-refresh-cache-flag (consp current-prefix-arg))) + (setq bmkp-sorted-alist (bmkp-sort-and-remove-dups bookmark-alist)))) + +(defun icicle-bookmark-propertize-candidate (cand) + "Return bookmark name CAND, with a face indicating its type." + (when (featurep 'bookmark+) + (put-text-property + 0 (length cand) 'face + (cond ((bmkp-sequence-bookmark-p cand) 'bmkp-sequence) + ((bmkp-function-bookmark-p cand) 'bmkp-function) + ((bmkp-bookmark-list-bookmark-p cand) 'bmkp-bookmark-list) + ((bmkp-desktop-bookmark-p cand) 'bmkp-desktop) + ((bmkp-info-bookmark-p cand) 'bmkp-info) + ((bmkp-man-bookmark-p cand) 'bmkp-man) + ((bmkp-gnus-bookmark-p cand) 'bmkp-gnus) + ((bmkp-url-bookmark-p cand) 'bmkp-url) + ((bmkp-remote-file-bookmark-p cand) 'bmkp-remote-file) + ((and (bmkp-file-bookmark-p cand) + (file-directory-p + (bookmark-get-filename cand))) 'bmkp-local-directory) + ((and (bmkp-local-file-bookmark-p cand) + (bmkp-region-bookmark-p cand)) 'bmkp-local-file-with-region) + ((bmkp-local-file-bookmark-p cand) 'bmkp-local-file-without-region) + ((and (bmkp-get-buffer-name cand) + (get-buffer (bmkp-get-buffer-name cand)) + (equal (bookmark-get-filename cand) + bmkp-non-file-filename)) 'bmkp-buffer) + ((not (bmkp-file-bookmark-p cand)) 'bmkp-non-file) + (t 'bmkp-bad-bookmark)) + cand)) + cand) + +(defun icicle-bookmark-jump (bookmark) + "Jump to BOOKMARK. +If `crosshairs.el' is loaded, then highlight the target position. +You probably don't want to use this. Use `icicle-bookmark' instead." + (interactive (list (bookmark-completing-read "Jump to bookmark" bookmark-current-bookmark))) + (icicle-bookmark-jump-1 bookmark)) + +(defun icicle-bookmark-jump-other-window (bookmark) + "Jump to BOOKMARK in another window. +If `crosshairs.el' is loaded, then highlight the target position. +You probably don't want to use this. Use +`icicle-bookmark-other-window' instead." + (interactive (list (bookmark-completing-read "Jump to bookmark (other window)" + bookmark-current-bookmark))) + (icicle-bookmark-jump-1 bookmark 'other-window)) + +(defun icicle-bookmark-jump-1 (bookmark &optional other-window-p) + "Helper function for `icicle-bookmark-jump(-other-window)'." + (unless bookmark (error "No bookmark specified")) + (bookmark-maybe-historicize-string bookmark) + (if (fboundp 'bookmark--jump-via) + (bookmark--jump-via bookmark (if other-window-p 'pop-to-buffer 'switch-to-buffer)) + (let ((cell (bookmark-jump-noselect bookmark))) ; Emacs < 23 and without `bookmark+.el'. + (when cell + (if other-window-p + (pop-to-buffer (car cell) 'other-window) + (switch-to-buffer (car cell))) + (goto-char (cdr cell)) + (progn (run-hooks 'bookmark-after-jump-hook) t) + ;; If there is an annotation for this bookmark, show it in a buffer. + (when bookmark-automatically-show-annotations (bookmark-show-annotation bookmark))))) + ;; Unless `bmkp-use-region' and bookmark has a region, show position using crosshairs. + (unless (and (boundp 'bmkp-use-region) bmkp-use-region + (fboundp 'bmkp-get-end-position) (bmkp-get-end-position bookmark) + (/= (bookmark-get-position bookmark) (bmkp-get-end-position bookmark))) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight)))) +;; $$$$$$ (select-window (minibuffer-window)) +;; $$$$$$ (select-frame-set-input-focus (selected-frame))) + +(defun icicle-bookmark-help-string (bookmark-name) + "Return a help string for BOOKMARK-NAME." ; `bmkp-*' functions are defined in `bookmark+.el'. + ;; Use BOOKMARK-NAME, not full bookmark BMK, as arg to vanilla bookmark functions, for Emacs < 23. + (let* ((bmk (bookmark-get-bookmark bookmark-name)) + (buf (and (fboundp 'bmkp-get-buffer-name) (bmkp-get-buffer-name bmk))) + (file (bookmark-get-filename bookmark-name)) + (start (bookmark-get-position bookmark-name)) + (end (and (fboundp 'bmkp-get-end-position) (bmkp-get-end-position bmk))) + (annot (bookmark-get-annotation bookmark-name)) + (sequence-p (and (fboundp 'bmkp-sequence-bookmark-p) + (bmkp-sequence-bookmark-p bmk))) + (function-p (and (fboundp 'bmkp-function-bookmark-p) + (bmkp-function-bookmark-p bmk))) + (blist-p (and (fboundp 'bmkp-bookmark-list-bookmark-p) + (bmkp-bookmark-list-bookmark-p bmk))) + (desktop-p (and (fboundp 'bmkp-desktop-bookmark-p) + (bmkp-desktop-bookmark-p bmk))) + (dired-p (and (fboundp 'bmkp-dired-bookmark-p) (bmkp-dired-bookmark-p bmk))) + (gnus-p (and (fboundp 'bmkp-gnus-bookmark-p) (bmkp-gnus-bookmark-p bmk))) + (info-p (and (fboundp 'bmkp-info-bookmark-p) (bmkp-info-bookmark-p bmk))) + (man-p (and (fboundp 'bmkp-man-bookmark-p) (bmkp-man-bookmark-p bmk))) + (url-p (and (fboundp 'bmkp-url-bookmark-p) (bmkp-url-bookmark-p bmk))) + type-info-p no-position-p) + (when (or sequence-p function-p) (setq no-position-p t)) + (concat (setq type-info-p + (cond (sequence-p (format "Sequence: %S" (bookmark-prop-get bmk 'sequence))) + (function-p (let ((fn (bookmark-prop-get bmk 'function))) + (if (symbolp fn) (format "Function: `%s'" fn) "Function"))) + (desktop-p "Desktop, ") + (dired-p (format "Dired %s, " file)) + (gnus-p "Gnus, ") + (info-p "Info, ") + (man-p (let ((man-args (bookmark-prop-get bmk 'man-args))) + (if man-args + (format "`man %s', " man-args) + ;; WoMan has no variable for the cmd name. + (format "%s, " (bookmark-prop-get bmk 'buffer-name))))) + (url-p "URL, ") + (t nil))) + (and (not dired-p) + (or (and file (or (not (boundp 'bmkp-non-file-filename)) + (not (equal file bmkp-non-file-filename))) + (format (if type-info-p "file `%s', " "File `%s', ") file)) + (and buf (format (if type-info-p "buffer `%s', " "Buffer `%s', ") buf)))) + (and (not no-position-p) + (if (and end (> (- end start) 0)) + (format "from %d to %d (%d chars)" start end (- end start)) + (format "position %d" start))) + (and annot (format ", %s" annot))))) + +;;; MUST keep this synchronized with any general Icicle-mode `C-M-' bindings in `icicles-mode.el'. +;; That includes things like `icicle-read+insert-file-name-keys'. +(defun icicle-bookmark-cleanup () + "Cleanup code for `icicle-bookmark'. +Remove crosshairs highlighting and unbind filtering keys." + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)) + (when (featurep 'bookmark+) + (dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map)) + (define-key (symbol-value map) "\C-\M-b" nil) ; `C-M-b' + (define-key (symbol-value map) [(control meta ?B)] nil) ; `C-M-B' + (define-key (symbol-value map) "\C-\M-d" nil) ; `C-M-d' + (define-key (symbol-value map) "\C-\M-f" nil) ; `C-M-f' + (define-key (symbol-value map) [(control meta ?F)] nil) ; `C-M-F' + (dolist (key icicle-read+insert-file-name-keys) ; `C-M-F' - overrides previous. + (define-key (symbol-value map) key 'icicle-read+insert-file-name)) + (define-key (symbol-value map) "\C-\M-g" nil) ; `C-M-g' + (define-key (symbol-value map) [(control meta ?I)] nil) ; `C-M-I' (`C-M-i' is `ESC TAB') + (define-key (symbol-value map) [(control meta ?K)] nil) ; `C-M-K' + (define-key (symbol-value map) "\C-\M-m" nil) ; `C-M-m' + (define-key (symbol-value map) "\C-\M-r" nil) ; `C-M-r' + (define-key (symbol-value map) "\C-\M-w" nil) ; `C-M-w' + (define-key (symbol-value map) "\C-\M-@" nil) ; `C-M-@' + (define-key (symbol-value map) [(control meta ?\.)] ; `C-M-.' + 'icicle-toggle-dot) ; `icicles-mode.el'. + (define-key (symbol-value map) [(control meta ?=) ?b] nil) ; `C-M-= b' + (define-key (symbol-value map) [(control meta ?=) ?f] nil)))) ; `C-M-= f' + +(defun icicle-bookmark-cleanup-on-quit () + "Do `icicle-bookmark-cleanup', then return to original window." + (icicle-bookmark-cleanup) + (when (window-live-p orig-window) ; `orig-window' is free here. + (select-window orig-window) + (select-frame-set-input-focus (selected-frame)))) + +;;; These are minibuffer commands, but we define them here instead of in `icicles-mcmd.el'. + +(defun icicle-bookmark-bookmark-list-narrow () ; Bound to `C-M-B' in minibuffer for completion. + "Narrow the bookmark candidates to bookmark-list bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-bookmark-list-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-desktop-narrow () ; Bound to `C-M-K' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to desktop bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-desktop-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-dired-narrow () ; Bound to `C-M-d' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to Dired bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-dired-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-file-narrow () ; Bound to `C-M-f' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to file bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-file-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-gnus-narrow () ; Bound to `C-M-g' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to Gnus bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-gnus-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-info-narrow () ; Bound to `C-M-I' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to Info bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-info-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-local-file-narrow () ; Bound to `C-M-F' for bookmark completion. + "Narrow the bookmark candidates to local-file bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-local-file-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-man-narrow () ; Bound to `C-M-m' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to `man'-page bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-man-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-non-file-narrow () ; Bound to `C-M-b' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to non-file (buffer-only) bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-non-file-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-region-narrow () ; Bound to `C-M-r' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to bookmarks with regions." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-region-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-remote-file-narrow () ; Bound to `C-M-@' in minibuf for bookmark completion. + "Narrow the bookmark candidates to remote-file bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-remote-file-bookmark-p + (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-specific-buffers-narrow (buffers) ; `C-M-= b' for bookmark completion. + "Narrow the bookmark candidates to bookmarks for specific BUFFERS. +You are prompted for the BUFFERS." + (interactive (let ((icicle-completion-candidates icicle-completion-candidates)) + (list (icicle-bookmarked-buffer-list)))) + (icicle-narrow-candidates-with-predicate + `(lambda (x) + (member (bmkp-get-buffer-name (funcall icicle-get-alist-candidate-function (car x))) + ',buffers)))) + +(defun icicle-bookmark-specific-files-narrow (files) ; `C-M-= f' in minibuf for bookmark completion. + "Narrow the bookmark candidates to bookmarks for specific FILES. +You are prompted for the FILES." + (interactive (list (icicle-bookmarked-file-list))) + (icicle-narrow-candidates-with-predicate + `(lambda (x) + (member (bookmark-get-filename (funcall icicle-get-alist-candidate-function (car x))) + ',files)))) + +(defun icicle-bookmark-this-buffer-narrow () ; `C-M-.' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to bookmarks for the current buffer." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) + (with-current-buffer orig-buff + (bmkp-this-buffer-p (funcall icicle-get-alist-candidate-function (car x))))))) + +(defun icicle-bookmark-url-narrow () ; Bound to `C-M-u' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to URL bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-url-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defun icicle-bookmark-w3m-narrow () ; Bound to `C-M-w' in minibuffer for bookmark completion. + "Narrow the bookmark candidates to W3M (URL) bookmarks." + (interactive) + (icicle-narrow-candidates-with-predicate + #'(lambda (x) (bmkp-w3m-bookmark-p (funcall icicle-get-alist-candidate-function (car x)))))) + +(defmacro icicle-define-bookmark-command-1 (otherp type prompt args) + "Helper macro for `icicle-define*-bookmark-command' macros. +The command defined raises an error unless library `bookmark+.el' can +be loaded." + `(icicle-define-command + ,(intern (format "icicle-bookmark-%s%s" type (if otherp "-other-window" ""))) ; Command name + ,(format "Jump to %s bookmark%s. +Like `icicle-bookmark%s', but with %s bookmarks only. +You need library `bookmark+.el' for this command." + type (if otherp " in other window" "") + (if otherp "-other-window" "") type) ; Doc string + (lambda (cand) (,(if otherp 'icicle-bookmark-jump-other-window 'icicle-bookmark-jump) + (icicle-transform-multi-completion cand))) + prompt1 icicle-candidates-alist nil ; `completing-read' args + (not icicle-show-multi-completion-flag) + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + nil nil + ((IGNORED1 (unless (require 'bookmark+ nil t) + (error "You need library `bookmark+.el' for this \ +command"))) + (IGNORED2 (bookmark-maybe-load-default-file)) ; `bookmark-alist'. + (enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on disk... + (completion-ignore-case bookmark-completion-ignore-case) ; Additional bindings + (prompt1 ,(or prompt + (format "%s%s bookmark: " + (capitalize (substring type 0 1)) + (substring type 1 (length type))))) + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (icicle-sort-orders-alist + (append + '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p) + ("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p)) + (and (member ,type '("info" "region")) + '(("by Info location" (bmkp-info-cp) icicle-alpha-p))) + (and (member ,type '("gnus" "region")) + '(("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p))) + (and (member ,type '("url" "region")) + '(("by URL" (bmkp-url-cp) icicle-alpha-p))) + (and (not (member ,type '("bookmark-list" "desktop" "gnus" "info" "man" "url"))) + '(("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + (and (not (member ,type '("bookmark-list" "desktop" "dired" "non-file"))) + '(("by file name" (bmkp-file-alpha-cp) icicle-alpha-p))) + (and (member ,type '("local-file" "file" "dired" "region")) + '(("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p))) + (and (not (string= ,type "desktop")) + '(("by last buffer or file access" (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p))) + (and (get-buffer "*Bookmark List*") + '(("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when icicle-show-multi-completion-flag + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)))) + (icicle-candidates-alist + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf (if (and buf (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + ;; Emacs 20 byte-compiler bug prevents using backslash syntax here. + (cons (append (list (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + file/buf) + (and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (bmkp-sort-and-remove-dups + (funcall ',(intern (format "bmkp-%s-alist-only" type)) ,@args))))) + nil ; First code + (icicle-bookmark-cleanup-on-quit) ; Undo code + (icicle-bookmark-cleanup))) ; Last code + +(defmacro icicle-define-bookmark-command (type &optional prompt &rest args) + "Define an Icicles multi-command for jumping to bookmarks of type TYPE. +TYPE is a string to be used for the doc string, default prompt, and in + function names. It should be lowercase and contain no spaces. +Optional arg PROMPT is the completion prompt. +ARGS is a list of any additional arguments to be passed to the +appropriate `bmkp-TYPE-alist-only' function." + `(icicle-define-bookmark-command-1 nil ,type ,prompt ,args)) + +(defmacro icicle-define-bookmark-other-window-command (type &optional prompt &rest args) + "Same as `icicle-define-bookmark-command', but command uses other window." + `(icicle-define-bookmark-command-1 t ,type ,prompt ,args)) + +;; The following sexps macro-expand to define these commands: +;; `icicle-bookmark-bookmark-list', +;; `icicle-bookmark-desktop', +;; `icicle-bookmark-dired', `icicle-bookmark-dired-other-window', +;; `icicle-bookmark-file', `icicle-bookmark-file-other-window', +;; `icicle-bookmark-gnus', `icicle-bookmark-gnus-other-window', +;; `icicle-bookmark-info', `icicle-bookmark-info-other-window', +;; `icicle-bookmark-local-file', `icicle-bookmark-local-file-other-window', +;; `icicle-bookmark-man', `icicle-bookmark-man-other-window', +;; `icicle-bookmark-non-file', `icicle-bookmark-non-file-other-window', +;; `icicle-bookmark-region', `icicle-bookmark-region-other-window', +;; `icicle-bookmark-remote-file', `icicle-bookmark-remote-file-other-window', +;; `icicle-bookmark-specific-buffers', `icicle-bookmark-specific-buffers-other-window' +;; `icicle-bookmark-specific-files', `icicle-bookmark-specific-files-other-window' +;; `icicle-bookmark-all-tags', `icicle-bookmark-all-tags-other-window' +;; `icicle-bookmark-all-tags-regexp', `icicle-bookmark-all-tags-regexp-other-window' +;; `icicle-bookmark-some-tags', `icicle-bookmark-some-tags-other-window' +;; `icicle-bookmark-some-tags-regexp', `icicle-bookmark-some-tags-regexp-other-window' +;; `icicle-bookmark-this-buffer', `icicle-bookmark-this-buffer-other-window' +;; `icicle-bookmark-url', `icicle-bookmark-url-other-window' +;; `icicle-bookmark-w3m', `icicle-bookmark-w3m-other-window' + +;; Other-window means nothing for a bookmark list or a desktop. +(icicle-define-bookmark-command "non-file") ; `C-x j b' +(icicle-define-bookmark-other-window-command "non-file") ; `C-x 4 j b' +(icicle-define-bookmark-command "bookmark-list") ; `C-x j B' +(icicle-define-bookmark-command "dired") ; `C-x j d' +(icicle-define-bookmark-other-window-command "dired") ; `C-x 4 j d' +(icicle-define-bookmark-command "file") ; `C-x j f' +(icicle-define-bookmark-other-window-command "file") ; `C-x 4 j f' +(icicle-define-bookmark-command "gnus") ; `C-x j g' +(icicle-define-bookmark-other-window-command "gnus") ; `C-x 4 j g' +(icicle-define-bookmark-command "info") ; `C-x j i' +(icicle-define-bookmark-other-window-command "info") ; `C-x 4 j i' +(icicle-define-bookmark-command "desktop") ; `C-x j K' +(icicle-define-bookmark-command "local-file") ; `C-x j l' +(icicle-define-bookmark-other-window-command "local-file") ; `C-x 4 j l' +(icicle-define-bookmark-command "man") ; `C-x j m' +(icicle-define-bookmark-other-window-command "man") ; `C-x 4 j m' +(icicle-define-bookmark-command "remote-file") ; `C-x j n' +(icicle-define-bookmark-other-window-command "remote-file") ; `C-x 4 j n' +(icicle-define-bookmark-command "region" "Select region: ") ; `C-x j r' +(icicle-define-bookmark-other-window-command "region" "Select region: ") ; `C-x 4 j r' +(icicle-define-bookmark-command "all-tags" nil ; `C-x j t *' + (bmkp-read-tags-completing)) +(icicle-define-bookmark-other-window-command "all-tags" nil ; `C-x 4 j t *' + (bmkp-read-tags-completing)) +(icicle-define-bookmark-command "some-tags" nil ; `C-x j t +' + (bmkp-read-tags-completing)) +(icicle-define-bookmark-other-window-command "some-tags" nil ; `C-x 4 j t +' + (bmkp-read-tags-completing)) +(icicle-define-bookmark-command "all-tags-regexp" nil ; `C-x j t % *' + (read-string "Regexp for tags: ")) +(icicle-define-bookmark-other-window-command "all-tags-regexp" nil ; `C-x 4 j t % *' + (read-string "Regexp for tags: ")) +(icicle-define-bookmark-command "some-tags-regexp" nil ; `C-x j t % +' + (read-string "Regexp for tags: ")) +(icicle-define-bookmark-other-window-command "some-tags-regexp" nil ; `C-x 4 j t % +' + (read-string "Regexp for tags: ")) +(icicle-define-bookmark-command "url") ; `C-x j u' +(icicle-define-bookmark-other-window-command "url") ; `C-x 4 j u' +(icicle-define-bookmark-command "w3m") ; `C-x j w' +(icicle-define-bookmark-other-window-command "w3m") ; `C-x 4 j w' +(icicle-define-bookmark-command "this-buffer") ; `C-x j .' +(icicle-define-bookmark-other-window-command "this-buffer") ; `C-x 4 j .' +(icicle-define-bookmark-command "specific-buffers" nil ; `C-x j = b' + (icicle-bookmarked-buffer-list)) +(icicle-define-bookmark-other-window-command "specific-buffers" nil ; `C-x 4 j = b' + (icicle-bookmarked-buffer-list)) +(icicle-define-bookmark-command "specific-files" nil ; `C-x j = f' + (icicle-bookmarked-file-list)) +(icicle-define-bookmark-other-window-command "specific-files" nil ; `C-x 4 j = f' + (icicle-bookmarked-file-list)) +(defalias 'icicle-select-bookmarked-region 'icicle-bookmark-region-other-window) + +;;;###autoload +(defun icicle-bookmarked-buffer-list () + "`icicle-buffer-list', but only for bookmarked buffers." + (interactive) + (let ((icicle-buffer-predicate (lambda (buf) (member buf (bmkp-buffer-names))))) + (icicle-buffer-list))) + +;;;###autoload +(defun icicle-bookmarked-file-list () + "`icicle-buffer-list', but only for bookmarked buffers." + (interactive) + (let ((use-file-dialog nil) + (icicle-file-predicate (lambda (file) (member (expand-file-name file) (bmkp-file-names))))) + (icicle-file-list))) + +;;;###autoload +(icicle-define-command icicle-find-first-tag ; Command name + "Find first tag in current tags table whose name matches your input. +This is similar to standard command `find-tag', with these +differences: + +* This is a multi-command, so you can visit any number of tags. + +* Only the first tag of several identical tags is a candidate, so you + cannot visit the others. That is, there is no equivalent to using + `M-,' (`tags-loop-continue') after `find-tag' to find additional, + identical tags. + +* If `crosshairs.el' is loaded, the target position is highlighted. + +To browse all tags (including duplicates) in all tags tables, use the +more powerful Icicles multi-command `icicle-find-tag'. + +By default, Icicle mode remaps all key sequences that are normally +bound to `find-tag-other-window' to `icicle-find-first-tag'. If you +do not want this remapping, then customize option +`icicle-top-level-key-bindings'." ; Doc string + icicle-find-first-tag-action ; Action function + "Find tag: " ; `completing-read' args + (if (fboundp 'tags-lazy-completion-table) (tags-lazy-completion-table) 'tags-complete-tag) + nil nil nil nil (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) + 'find-tag-default)) + nil + ((completion-ignore-case (progn (require 'etags) + (if (and (boundp 'tags-case-fold-search) ; Bindings + (memq tags-case-fold-search '(t nil))) + tags-case-fold-search + case-fold-search))) + (case-fold-search completion-ignore-case)) + nil ; First, undo, last code. + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)) + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch))) + +(defun icicle-find-first-tag-action (cand) + "Action function for `icicle-find-first-tag'." + (find-tag cand) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight))) + +;;;###autoload +(icicle-define-command icicle-find-first-tag-other-window ; Command name + "Find first tag in current tags table whose name matches your input. +Same as `icicle-find-first-tag' except it uses a different window." ; Doc string + icicle-find-first-tag-other-window-action ; Action function + "Find tag other window: " ; `completing-read' args + (if (fboundp 'tags-lazy-completion-table) (tags-lazy-completion-table) 'tags-complete-tag) + nil nil nil nil (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) + 'find-tag-default)) + nil + ((completion-ignore-case (progn (require 'etags) + (if (and (boundp 'tags-case-fold-search) ; Bindings + (memq tags-case-fold-search '(t nil))) + tags-case-fold-search + case-fold-search))) + (case-fold-search completion-ignore-case)) + nil ; First, undo, last code. + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)) + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch))) + +(defun icicle-find-first-tag-other-window-action (cand) + "Action function for `icicle-find-first-tag-other-window'." + (find-tag-other-window cand) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight))) + +;;;###autoload +(defun icicle-find-tag (regexp &optional arg) + "Navigate among all tags that match REGEXP. +You are prompted for the REGEXP to match. Enter REGEXP with `RET'. +You can use completion to choose a tag in the current tags table as +REGEXP. You can use `\\[icicle-pop-tag-mark]' to return to your starting point. + +All matching tags are shown, including duplicate tags from the same or +different source files. This means that you do not need `M-,' - you +see all tags as candidates to visit. + +By default: + +* Tags from all tags files are candidates. +* The source file name is shown after a tag, in buffer *Completions*. + +A prefix argument changes this default behavior, as follows: + +* ARG = 0 or ARG > 0: only the current tag table is used +* ARG = 0 or ARG < 0: source file names are not shown + +By default, Icicle mode remaps all key sequences that are normally +bound to `find-tag' to `icicle-find-tag'. If you do not want this +remapping, then customize option `icicle-top-level-key-bindings'. + +If `crosshairs.el' is loaded, then the target position is highlighted." + (interactive + (let* ((completion-ignore-case (if (and (boundp 'tags-case-fold-search) + (memq tags-case-fold-search '(t nil))) + tags-case-fold-search + case-fold-search)) + (case-fold-search completion-ignore-case)) + (require 'etags) + (list (completing-read "Find tag matching regexp: " + ;; $$$ Or should we just read a regexp against `regexp-history'? + (if (fboundp 'tags-lazy-completion-table) + (tags-lazy-completion-table) ; Emacs 23+ + 'tags-complete-tag) ; Emacs < 23 + nil nil nil 'find-tag-history + (funcall (or find-tag-default-function + (get major-mode 'find-tag-default-function) + 'find-tag-default))) + current-prefix-arg))) + + (unwind-protect + (let* ((icicle-whole-candidate-as-text-prop-p t) + (icicle-sort-comparer nil) + (icicle-inhibit-sort-p t) + (icicle-candidate-action-fn 'icicle-find-tag-action) + (icicle-candidate-help-fn 'icicle-find-tag-help) + (completion-ignore-case (if (and (boundp 'tags-case-fold-search) + (memq tags-case-fold-search + '(t nil))) + tags-case-fold-search + case-fold-search)) + (case-fold-search completion-ignore-case) + (orig-pt-find-tag (point-marker))) + + (ring-insert find-tag-marker-ring orig-pt-find-tag) ; Record starting point. + (icicle-explore #'(lambda () (icicle-find-tag-define-candidates regexp arg)) + #'icicle-find-tag-final-act #'icicle-find-tag-quit-or-error + #'icicle-find-tag-quit-or-error nil + "Choose a tag: " nil nil nil 'find-tag-history)) + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)))) + +;;;###autoload +(defun icicle-pop-tag-mark () + "Like `pop-tag-mark', but uses `pop-to-buffer', not `switch-to-buffer'. +By default, Icicle mode remaps all key sequences that are normally +bound to `pop-tag-mark' to `icicle-pop-tag-mark'. If you do not want +this remapping, then customize option +`icicle-top-level-key-bindings'." + (interactive) + (require 'etags) + (when (ring-empty-p find-tag-marker-ring) (error "No previous locations for find-tag invocation")) + (let ((marker (ring-remove find-tag-marker-ring 0))) + (pop-to-buffer (or (marker-buffer marker) (error "The marked buffer has been deleted"))) + (goto-char (marker-position marker)) + (set-marker marker nil nil))) + +(defun icicle-find-tag-define-candidates (regexp arg) + "Define candidates for `icicle-find-tag'. +See `icicle-explore', argument DEFINE-CANDIDATES-FN." + (save-excursion + (let ((first-time t) + (morep t)) + (setq icicle-candidates-alist ()) + (while (and morep (visit-tags-table-buffer (not first-time))) + (when (and arg (wholenump (prefix-numeric-value arg))) (setq morep nil)) + (setq first-time nil + icicle-candidates-alist (append icicle-candidates-alist + (nreverse + (icicle-find-tag-define-candidates-1 + regexp (> (prefix-numeric-value arg) + 0))))))))) + +(defun icicle-find-tag-define-candidates-1 (regexp show-file-p) + "Helper function for `icicle-find-tag-define-candidates'. +Returns completion alist of tag information for tags matching REGEXP. +Include file name (label) if SHOW-FILE-P is non-nil. + +If SHOW-FILE-P is nil, then alist items look like this: + + (TAG TAG-INFO FILE-PATH GOTO-FUNC) + +If SHOW-FILE-P is non-nil, then alist items look like this: + + ((TAG FILE-LABEL) TAG-INFO FILE-PATH GOTO-FUNC) or + + (FILE-LABEL TAG-INFO FILE-PATH GOTO-FUNC) if no matching TAG. + +TAG-INFO is what `snarf-tag-function' (e.g. `etags-snarf-tag') +returns. It is a cons (TEXT LINE . POSITION). + +TEXT is the initial part of a line containing the tag. +LINE is the line number. +POSITION is the (one-based) char position of TEXT within the file. + +If TEXT is t, it means the tag refers to exactly LINE or POSITION, +whichever is present, LINE having preference, no searching. +Either LINE or POSITION can be nil. POSITION is used if present." + (icicle-highlight-lighter) + (message "Gathering tags...") + (goto-char (point-min)) + (let ((temp-list ())) + (while (re-search-forward (concat regexp ".*\177*") nil t) ; Look before the DEL character. + (beginning-of-line) + (let* ((goto-func goto-tag-location-function) ; e.g. `etags-goto-tag-location'. + ;; TAG-INFO: If no specific tag, (t nil (point-min)). Else, (TEXT LINE . STARTPOS). + ;; e.g. TEXT = "(defun foo ()" or just "foo" (if explicit), + ;; LINE = "148", STARTPOS = "1723" + (tag-info (save-excursion (funcall snarf-tag-function))) ; e.g. `etags-snarf-tag'. + (tag (if (eq t (car tag-info)) nil (car tag-info))) + ;; FILE-PATH is absolute. FILE-LABEL is relative to `default-directory'. + (file-path (save-excursion + (if tag (file-of-tag) (save-excursion (next-line 1) (file-of-tag))))) + (file-label (expand-file-name file-path (file-truename default-directory)))) + (when (and tag (not (string= "" tag)) (= (aref tag 0) ?\( )) + (setq tag (concat tag " ...)"))) + (when (file-readable-p file-path) + ;; Add item to alist. + ;; Item looks like this: ((TAG FILE-LABEL) TAG-INFO FILE-PATH GOTO-FUNC) + ;; or like this, if no matching tag: ((FILE-LABEL) TAG-INFO FILE-PATH GOTO-FUNC) + (cond (tag + (push `(,(if show-file-p + (list tag ; Make multi-completion cons: add file name to candidate. + (progn (put-text-property 0 (length file-label) 'face + 'icicle-candidate-part file-label) + file-label)) + tag) + ,tag-info ,file-path ,goto-func) + temp-list)) + (show-file-p ; No tag. Use only the FILE-LABEL. + (push `((,(progn (put-text-property 0 (length file-label) 'face + 'icicle-candidate-part file-label) + file-label)) + ,tag-info ,file-path ,goto-func) + temp-list))))) + (forward-line)) + temp-list)) ; Return the alist for this TAGS file. + +(defun icicle-find-tag-action (ignored-string) + "Action function for `icicle-find-tag'." + ;; Ignore (TAG FILE-LABEL) part. Use only (TAG-INFO FILE-PATH GOTO-FUNC) part. + (let* ((cand (cdr (elt (icicle-filter-alist icicle-candidates-alist + icicle-completion-candidates) + icicle-candidate-nb))) + (tag-info (nth 0 cand)) + (goto-func (nth 2 cand))) + (switch-to-buffer-other-window ; Go to source file at FILE-PATH. + (if (fboundp 'tag-find-file-of-tag-noselect) + (tag-find-file-of-tag-noselect (nth 1 cand)) + (find-file-noselect (nth 1 cand)))) + (widen) + (condition-case err + (funcall goto-func tag-info) ; Go to text at TAG-INFO. + (error (message (error-message-string err)) (sit-for 2) nil))) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight)) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame))) + +(defun icicle-find-tag-help (cand) + "Use as `icicle-candidate-help-fn' for `icicle-find-first-tag'." + (let* ((cand (cdr (elt (icicle-filter-alist icicle-candidates-alist + icicle-completion-candidates) + icicle-candidate-nb))) + (tag-info (nth 0 cand))) + (message (if (eq t (car tag-info)) + "No tag - file name itself matches" + (format "Line: %d, Position: %d, File: %s" + (cadr tag-info) (cddr tag-info) (nth 1 cand)))) + (sit-for 4))) + +(defun icicle-find-tag-final-act () + "Go to the final tag choice." + (let ((cand (cdr icicle-explore-final-choice-full))) + (unless cand (error "No such occurrence: %s" cand)) + (switch-to-buffer-other-window ; Go to source file at FILE-PATH. + (if (fboundp 'tag-find-file-of-tag-noselect) + (tag-find-file-of-tag-noselect (nth 1 cand)) + (find-file-noselect (nth 1 cand)))) + (widen) + (funcall (nth 2 cand) (nth 0 cand)))) ; Go to text at TAG-INFO. + +(defun icicle-find-tag-quit-or-error () + "Pop back to the last tag visited." + (icicle-pop-tag-mark) + (raise-frame)) + +;;;###autoload +(defun icicle-other-window-or-frame (arg) ; Bound to `C-x o' in Icicle mode. + "Select a window or frame, by name or by order. +This command combines Emacs commands `other-window' and `other-frame', +together with Icicles multi-commands `icicle-select-window', and +`icicle-select-frame'. Use the prefix argument to choose, as follows: + + With no prefix arg or a non-zero numeric prefix arg: + If the selected frame has multiple windows, then this is + `other-window'. Otherwise, it is `other-frame'. + + With a zero prefix arg (e.g. `C-0'): + If the selected frame has multiple windows, then this is + `icicle-select-window' with windows in the frame as candidates. + Otherwise (single-window frame), this is `icicle-select-frame'. + + With plain `C-u': + If the selected frame has multiple windows, then this is + `icicle-select-window' with windows from all visible frames as + candidates. Otherwise, this is `icicle-select-frame'. + +By default, Icicle mode remaps all key sequences that are normally +bound to `other-window' to `icicle-other-window-or-frame'. If you do +not want this remapping, then customize option +`icicle-top-level-key-bindings'." + (interactive "P") + (let ((numarg (prefix-numeric-value arg))) + (cond ((consp arg) + (if (one-window-p) (icicle-select-frame) (icicle-select-window))) + ((zerop numarg) + (if (one-window-p) + (icicle-select-frame) + (let ((current-prefix-arg nil)) (icicle-select-window)))) + (t + (if (one-window-p) (other-frame numarg) (other-window numarg)))))) + +;;;###autoload +(icicle-define-command icicle-select-frame ; Bound to `C-x 5 o' in Icicle mode. + "Select frame by its name and raise it. +A frame name in this context is suffixed as needed by [NUMBER], to +make it unique. For example, in a context where frames are named for +their buffers and you have two frames showing buffer *Help*, one of +the frames will be called `*Help*[2]' for use with this command." ; Doc string + icicle-select-frame-by-name ; Action function + "Select frame: " ; `completing-read' args + icicle-frame-alist nil t nil + (if (boundp 'frame-name-history) 'frame-name-history 'icicle-frame-name-history) + (cdr (assq 'name (frame-parameters (next-frame (selected-frame))))) nil + ((icicle-frame-alist (icicle-make-frame-alist)) ; Bindings + (alt-fn nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (setq alt-fn (icicle-alt-act-fn-for-type "frame")))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn alt-fn (icicle-alt-act-fn-for-type "frame"))))) + +;;;###autoload +(defun icicle-select-frame-by-name (name &optional frame-alist) + "Select the frame named NAME, and raise it. +Optional argument FRAME-ALIST is an alist of frames to choose from. +Each element has the form (FNAME . FRAME), where FNAME names FRAME. +See `icicle-make-frame-alist' for more about FNAME." + (interactive (let* ((alist (icicle-make-frame-alist)) + (default (car (rassoc (selected-frame) alist))) + (input (completing-read "Select Frame: " alist nil t nil + 'frame-name-history default))) + (list (if (= (length input) 0) default input) + alist))) + (unless frame-alist (setq frame-alist (or (and (boundp 'icicle-frame-alist) icicle-frame-alist) + (icicle-make-frame-alist)))) + (let ((frame (cdr (assoc name frame-alist)))) + (unless frame (error "No such frame: `%s'" name)) + (make-frame-visible frame) + (select-frame-set-input-focus frame))) + +(defun icicle-make-frame-alist () + "Return an alist of entries (FNAME . FRAME), where FNAME names FRAME. +Frame parameter `name' is used as FNAME, unless there is more than one +frame with the same name. In that case, FNAME includes a suffix +\[NUMBER], to make it a unique name. The NUMBER order among frame +names that differ only by their [NUMBER] is arbitrary." + (let ((fr-alist ()) + (count 2) + fname new-name) + (dolist (fr (frame-list)) + (setq fname (frame-parameter fr 'name)) + (if (not (assoc fname fr-alist)) + (push (cons fname fr) fr-alist) + (setq new-name fname) + (while (assoc new-name fr-alist) + (setq new-name (format "%s[%d]" fname count) + count (1+ count))) + (push (cons new-name fr) fr-alist)) + (setq count 2)) + fr-alist)) + +;; Free vars here: `icicle-window-alist' is bound in Bindings form. +;;;###autoload +(icicle-define-command icicle-select-window ; Command name + "Select window by its name. +With no prefix arg, candidate windows are those of the selected frame. +With a prefix arg, windows of all visible frames are candidates. + +A window name is the name of its displayed buffer, but suffixed as +needed by [NUMBER], to make the name unique. For example, if you have +two windows showing buffer *Help*, one of the windows will be called +`*Help*[2]' for use with this command." ; Doc string + icicle-select-window-by-name ; Action function + "Select window: " ; `completing-read' args + icicle-window-alist nil t nil nil + (buffer-name (window-buffer (other-window 1))) nil + ((icicle-window-alist (icicle-make-window-alist current-prefix-arg)))) ; Bindings + +;; Free vars here: `icicle-window-alist' is bound in `icicle-select-window'. +(defun icicle-select-window-by-name (name &optional window-alist) + "Select the window named NAME. +Optional argument WINDOW-ALIST is an alist of windows to choose from. + +Interactively: + A prefix arg means windows from all visible frames are candidates. + No prefix arg means windows from the selected frame are candidates. + +Each alist element has the form (WNAME . WINDOW), where WNAME names +WINDOW. See `icicle-make-window-alist' for more about WNAME. + +If `crosshairs.el' is loaded, then the target position is highlighted." + (interactive (let* ((alist (icicle-make-window-alist current-prefix-arg)) + (default (car (rassoc (selected-window) alist))) + (input (completing-read "Select Window: " alist nil t nil nil default))) + (list (if (= (length input) 0) default input) alist))) + (unless window-alist + (setq window-alist (or (and (boundp 'icicle-window-alist) icicle-window-alist) + (icicle-make-window-alist)))) + (let ((window (cdr (assoc name window-alist)))) + (unless window (error "No such window: `%s'" name)) + (select-window window) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight)) + (select-frame-set-input-focus (selected-frame)))) + +(defun icicle-make-window-alist (&optional all-p) + "Return an alist of entries (WNAME . WINDOW), where WNAME names WINDOW. +The name of the buffer in a window is used as its name, unless there +is more than one window displaying the same buffer. In that case, +WNAME includes a suffix [NUMBER], to make it a unique name. The +NUMBER order among window names that differ only by their [NUMBER] is +arbitrary. + +Non-nil argument ALL-P means use windows from all visible frames. +Otherwise, use only windows from the selected frame." + (let ((win-alist ()) + (count 2) + wname new-name) + (walk-windows #'(lambda (w) + (setq wname (buffer-name (window-buffer w))) + (if (not (assoc wname win-alist)) + (push (cons wname w) win-alist) + (setq new-name wname) + (while (assoc new-name win-alist) + (setq new-name (format "%s[%d]" wname count) + count (1+ count))) + (push (cons new-name w) win-alist)) + (setq count 2)) + 'no-mini + (if all-p 'visible 'this-frame)) + win-alist)) + +;;;###autoload +(icicle-define-command icicle-delete-windows ; Command name + "Delete windows showing a buffer, anywhere." ; Doc string + delete-windows-on ; Action function + "Delete windows on buffer: " ; `completing-read' args + (let ((cand-bufs nil)) + (dolist (buf (buffer-list)) + (when (get-buffer-window buf 0) (push (list (buffer-name buf)) cand-bufs))) + cand-bufs) + nil t nil 'buffer-name-history (buffer-name (current-buffer)) nil + ((icicle-use-candidates-only-once-flag t) ; Bindings + (icicle-inhibit-try-switch-buffer t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))))) + +;;;###autoload +(defun icicle-delete-window (bufferp) ; Bound to `C-x 0' in Icicle mode. + "`delete-window' or prompt for buffer and delete all its windows. +When called from the minibuffer, remove the *Completions* window. + +Otherwise: + With no prefix argument, delete the selected window. + With a prefix argument, prompt for a buffer and delete all windows, + on any frame, that show that buffer. + + With a prefix argument, this is an Icicles multi-command - see + command `icicle-mode'. Input-candidate completion and cycling are + available. While cycling, these keys with prefix `C-' are active: + + `C-RET' - Act on current completion candidate only + `C-down' - Move to next prefix-completion candidate and act + `C-up' - Move to previous prefix-completion candidate and act + `C-next' - Move to next apropos-completion candidate and act + `C-prior' - Move to previous apropos-completion candidate and act + `C-!' - Act on *all* candidates (or all that are saved), + successively (careful!) + + With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', + `C-M-RET', `C-M-down', and so on) provide help about candidates. + + Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, + or `C-g' to quit. + +By default, Icicle mode remaps all key sequences that are normally +bound to `delete-window' to `icicle-delete-window'. If you do not +want this remapping, then customize option +`icicle-top-level-key-bindings'." + (interactive "P") + (if (window-minibuffer-p (selected-window)) + (icicle-remove-Completions-window) + (if bufferp (icicle-delete-windows) (delete-window)))) + +;;;###autoload +(icicle-define-command icicle-kill-buffer ; Bound to `C-x k' in Icicle mode. + "Kill a buffer. +With a positive prefix arg, only buffers visiting files are candidates. +With a negative prefix arg, only buffers associated with the selected +frame are candidates. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names + `icicle-buffer-extras' - Extra buffers to display + `icicle-buffer-match-regexp' - Regexp that buffers must match + `icicle-buffer-no-match-regexp' - Regexp buffers must not match + `icicle-buffer-predicate' - Predicate buffer must satisfy + `icicle-buffer-sort' - Sort function for candidates + +By default, Icicle mode remaps all key sequences that are normally +bound to `kill-buffer' to `icicle-kill-buffer'. If you do not want +this remapping, then customize option +`icicle-top-level-key-bindings'. + +Note: The prefix arg is tested, even when this is called +noninteractively. Lisp code can bind `current-prefix-arg' to control +the behavior." ; Doc string + icicle-kill-a-buffer-and-update-completions ; Action function + "Kill buffer: " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) bufflist) nil ; `bufflist' is free here. + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. + nil 'buffer-name-history (buffer-name (current-buffer)) nil + (icicle-buffer-bindings)) ; Bindings + +(defun icicle-kill-a-buffer-and-update-completions (buf) + "Kill buffer BUF and update the set of completions." + (setq buf (get-buffer buf)) + (if buf + (condition-case err + (if (not (buffer-live-p buf)) + (message "Buffer already deleted: `%s'" buf) + (if (fboundp 'kill-buffer-and-its-windows) + (kill-buffer-and-its-windows buf) ; Defined in `misc-cmds.el'. + (kill-buffer buf)) + ;; Update the set of completions, then update *Completions*. + (setq minibuffer-completion-table (mapcar #'(lambda (buf) (list (buffer-name buf))) + (buffer-list))) + (icicle-complete-again-update)) + (error nil)) + (message "No such live buffer: `%s'" buf))) + +(put 'icicle-buffer 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-buffer ; Bound to `C-x b' in Icicle mode. + "Switch to a different buffer. +With a positive prefix arg, only buffers visiting files are candidates. +With a negative prefix arg, only buffers associated with the selected +frame are candidates. + +You can use `C-x m' during completion to access buffer (non-file) + bookmarks, if you use library `bookmark+.el'. +You can use `S-delete' during completion to kill a candidate buffer. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names + `icicle-buffer-extras' - Extra buffers to display + `icicle-buffer-match-regexp' - Regexp that buffers must match + `icicle-buffer-no-match-regexp' - Regexp buffers must not match + `icicle-buffer-predicate' - Predicate buffer must satisfy + `icicle-buffer-sort' - Sort function for candidates + +For example, to show only buffers that are associated with files, set +`icicle-buffer-predicate' to (lambda (buf) (buffer-file-name buf)). + +Option `icicle-buffer-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-buffers-ido-like' non-nil gives this command a more +Ido-like behavior. + +See also command `icicle-buffer-config'. + +By default, Icicle mode remaps all key sequences that are normally +bound to `switch-to-buffer' to `icicle-buffer'. If you do not want +this remapping, then customize option +`icicle-top-level-key-bindings'. + +Note: The prefix arg is tested, even when this is called +noninteractively. Lisp code can bind `current-prefix-arg' to control +the behavior." ; Doc string + switch-to-buffer ; Action function + "Switch to buffer: " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) bufflist) nil ; `bufflist' is free here. + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. + nil 'buffer-name-history (icicle-default-buffer-names) nil + (icicle-buffer-bindings) ; Bindings + (progn ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-non-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-non-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-non-file-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;; Free var here: `bufflist' is bound by `icicle-buffer-bindings'. +(defun icicle-default-buffer-names () + "Default buffer names (Emacs 23+) or name (< Emacs 23)." + (let ((bname (buffer-name (if (fboundp 'another-buffer) ; In `misc-fns.el'. + (another-buffer nil t) + (other-buffer (current-buffer)))))) + (if (> emacs-major-version 22) ; Emacs 23 accepts a list of default values. + (cons bname + (mapcar #'buffer-name + (delete (current-buffer) ; Just keep the first 4. (This could be an option.) + (icicle-first-N 4 (if (boundp 'bufflist) bufflist (buffer-list)))))) + bname))) + +;;;###autoload +(icicle-define-command icicle-insert-buffer + "Multi-command version of `insert-buffer'. +With a positive prefix arg, only buffers visiting files are candidates. +With a negative prefix arg, only buffers associated with the selected +frame are candidates. + +You can use `S-delete' during completion to kill a candidate buffer. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names + `icicle-buffer-extras' - Extra buffers to display + `icicle-buffer-match-regexp' - Regexp that buffers must match + `icicle-buffer-no-match-regexp' - Regexp buffers must not match + `icicle-buffer-predicate' - Predicate buffer must satisfy + `icicle-buffer-sort' - Sort function for candidates + +For example, to show only buffers that are associated with files, set +`icicle-buffer-predicate' to (lambda (buf) (buffer-file-name buf)). + +Option `icicle-buffer-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +See also command `icicle-buffer-config'. + +Note: The prefix arg is tested, even when this is called +noninteractively. Lisp code can bind `current-prefix-arg' to control +the behavior." ; Doc string + insert-buffer ; Action function + "Buffer: " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) bufflist) nil ; `bufflist' is free here. + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. + nil 'buffer-name-history (icicle-default-buffer-names) nil + (icicle-buffer-bindings)) ; Bindings + +;;;###autoload +(icicle-define-command icicle-buffer-other-window ; Bound to `C-x 4 b' in Icicle mode. + "Switch to a different buffer in another window. +Same as `icicle-buffer' except it uses a different window." ; Doc string + switch-to-buffer-other-window ; Action function + "Switch to buffer in other window: " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) bufflist) nil ; `bufflist' is free here. + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. + nil 'buffer-name-history (icicle-default-buffer-names) nil + (icicle-buffer-bindings) ; Bindings + (progn ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-non-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-non-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-non-file-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;;;###autoload +(icicle-define-command icicle-add-buffer-candidate ; Command name + "Add buffer as an always-show completion candidate. +Add the buffer to `icicle-buffer-extras'. Save the updated option. +With a positive prefix arg, only buffers visiting files are candidates. +With a negative prefix arg, only buffers associated with the selected +frame are candidates. + +You can use `S-delete' on any completion candidate to remove it from +`icicle-buffer-extras'. + +Note: The prefix arg is tested, even when this is called +noninteractively. Lisp code can bind `current-prefix-arg' to control +the behavior." ; Doc string + (lambda (buf) + (add-to-list 'icicle-buffer-extras buf) ; Action function + (funcall icicle-customize-save-variable-function 'icicle-buffer-extras icicle-buffer-extras) + (message "Buffer `%s' added to always-show buffers" buf)) + "Buffer candidate to show always: " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) bufflist) nil ; `bufflist' is free here. + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. + nil 'buffer-name-history (icicle-default-buffer-names) nil + (icicle-buffer-bindings ((icicle-use-candidates-only-once-flag t)))) ; Bindings + +;;;###autoload +(icicle-define-command icicle-remove-buffer-candidate ; Command name + "Remove buffer as an always-show completion candidate. +Remove the buffer from `icicle-buffer-extras'. +Save the updated option." ; Doc string + icicle-remove-buffer-candidate-action ; Action function + "Remove buffer from always-show list: " ; `completing-read' args + (mapcar #'list icicle-buffer-extras) nil t nil 'buffer-name-history (car icicle-buffer-extras) nil + ((icicle-use-candidates-only-once-flag t) ; Bindings + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "buffer")))) + (unless icicle-buffer-extras (error "`icicle-extra-buffers' is empty"))) ; First code + +(defun icicle-remove-buffer-candidate-action (buf) + "Action function for command `icicle-remove-buffer-candidate'." + (setq icicle-buffer-extras (delete buf icicle-buffer-extras)) + (funcall icicle-customize-save-variable-function 'icicle-buffer-extras icicle-buffer-extras) + (message "Buffer `%s' removed from always-show buffers" buf)) + +;;;###autoload +(icicle-define-command icicle-buffer-config ; Command name + "Choose a configuration of user options for `icicle-buffer'. +You can use `S-delete' on any configuration during completion to +remove it. See user option `icicle-buffer-configs'. +See also commands `icicle-add-buffer-config' and +`icicle-remove-buffer-config'." ; Doc string + (lambda (config-name) ; Action function + (let ((config (assoc config-name icicle-buffer-configs))) + (setq icicle-buffer-match-regexp (elt config 1) + icicle-buffer-no-match-regexp (elt config 2) + icicle-buffer-predicate (elt config 3) + icicle-buffer-extras (elt config 4) + icicle-buffer-sort (elt config 5)))) + "Configuration: " icicle-buffer-configs nil t nil ; `completing-read' args + 'icicle-buffer-config-history nil nil + ((icicle-delete-candidate-object 'icicle-remove-buffer-config-action))) ; Bindings + +;;;###autoload +(icicle-define-add-to-alist-command icicle-add-buffer-config ; Command name + "Add buffer configuration to `icicle-buffer-configs'. +You are prompted for the buffer configuration components. +For the list of extra buffers to always display, you can choose them +using `C-mouse-2', `C-RET', and so on, just as you would make any +Icicles multiple choice." + #'(lambda () + (let ((name (read-from-minibuffer "Add buffer configuration. Name: ")) + (match-regexp (icicle-read-from-minibuf-nil-default + "Regexp to match: " nil nil nil 'regexp-history + icicle-buffer-match-regexp)) + (nomatch-regexp (icicle-read-from-minibuf-nil-default + "Regexp not to match: " nil nil nil 'regexp-history + icicle-buffer-no-match-regexp)) + (pred (icicle-read-from-minibuf-nil-default + "Predicate to satify: " nil nil nil + (if (boundp 'function-name-history) + 'function-name-history + 'icicle-function-name-history) + icicle-buffer-predicate)) + (sort-fn (icicle-read-from-minibuf-nil-default + "Sort function: " nil nil t + (if (boundp 'function-name-history) + 'function-name-history + 'icicle-function-name-history) + (and icicle-buffer-sort (symbol-name icicle-buffer-sort)))) + (extras (progn (message "Choose extra buffers to show...") (sit-for 1) + (icicle-buffer-list)))) ; Do last, for convenience. + (list name match-regexp nomatch-regexp pred extras sort-fn))) + icicle-buffer-configs) + +;;;###autoload +(icicle-define-command icicle-buffer-list ; Command name + "Choose a list of buffer names. +With a positive prefix arg, only buffers visiting files are candidates. +With a negative prefix arg, only buffers associated with the selected +frame are candidates. + +You can use `S-delete' during completion to kill a candidate buffer. +The list of names (strings) is returned. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names + `icicle-buffer-extras' - Extra buffers to display + `icicle-buffer-match-regexp' - Regexp that buffers must match + `icicle-buffer-no-match-regexp' - Regexp buffers must not match + `icicle-buffer-predicate' - Predicate buffer must satisfy + `icicle-buffer-sort' - Sort function for candidates + +Note: The prefix arg is tested, even when this is called +noninteractively. Lisp code can bind `current-prefix-arg' to control +the behavior." ; Doc string + (lambda (name) (push name buf-names)) ; Action function + "Choose buffer (`RET' when done): " ; `completing-read' args + (mapcar #'(lambda (buf) (list (buffer-name buf))) + (if current-prefix-arg + (if (wholenump (prefix-numeric-value current-prefix-arg)) + (icicle-remove-if-not #'(lambda (bf) (buffer-file-name bf)) (buffer-list)) + (cdr (assq 'buffer-list (frame-parameters)))) + (buffer-list))) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'buffer-name-history nil nil + ((buf-names ()) ; Bindings + (completion-ignore-case (or (and (boundp 'read-buffer-completion-ignore-case) + read-buffer-completion-ignore-case) + completion-ignore-case)) + (icicle-must-match-regexp icicle-buffer-match-regexp) + (icicle-must-not-match-regexp icicle-buffer-no-match-regexp) + (icicle-must-pass-predicate icicle-buffer-predicate) + (icicle-extra-candidates icicle-buffer-extras) + (icicle-transform-function 'icicle-remove-dups-if-extras) + (icicle-sort-comparer (or icicle-buffer-sort icicle-sort-comparer)) + (icicle-sort-orders-alist + (append (list '("by last access") ; Renamed from "turned OFF'. + '("*...* last" . icicle-buffer-sort-*...*-last) + '("by buffer size" . icicle-buffer-smaller-p) + '("by major mode name" . icicle-major-mode-name-less-p) + (and (fboundp 'icicle-mode-line-name-less-p) + '("by mode-line mode name" . icicle-mode-line-name-less-p)) + '("by file/process name" . icicle-buffer-file/process-name-less-p)) + (delete '("turned OFF") icicle-sort-orders-alist))) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-delete-candidate-object 'icicle-kill-a-buffer) ; `S-delete' kills current buffer. + (icicle-require-match-flag icicle-buffer-require-match-flag) + (icicle-ignore-space-prefix-flag icicle-buffer-ignore-space-prefix-flag) + (icicle-use-candidates-only-once-flag t)) + nil nil ; First code, undo code + (prog1 (setq buf-names (nreverse (delete "" buf-names))) ; Last code - return the list of buffers + (when (interactive-p) (message "Buffers: %S" buf-names)))) + +;;;###autoload +(icicle-define-command icicle-remove-buffer-config ; Command name + "Remove buffer configuration from `icicle-buffer-configs'. +Save the updated option." ; Doc string + icicle-remove-buffer-config-action ; Action function + "Remove buffer configuration: " ; `completing-read' args + (mapcar #'(lambda (config) (list (car config))) icicle-buffer-configs) + nil t nil 'icicle-buffer-config-history (caar icicle-buffer-configs) nil + ((icicle-use-candidates-only-once-flag t))) ; Bindings + +(defun icicle-remove-buffer-config-action (config-name) + "Action function for command `icicle-remove-buffer-config'." + (setq icicle-buffer-configs (icicle-assoc-delete-all config-name icicle-buffer-configs)) + (funcall icicle-customize-save-variable-function 'icicle-buffer-configs icicle-buffer-configs) + (message "Buffer configuration `%s' removed" config-name)) + +;;;###autoload +(icicle-define-command icicle-face-list ; Command name + "Choose a list of face names. The list of names (strings) is returned." ; Doc string + (lambda (name) (push (icicle-transform-multi-completion name) face-names)) ; Action function + prompt ; `completing-read' args + (mapcar #'icicle-make-face-candidate (face-list)) + nil (not (stringp icicle-WYSIWYG-Completions-flag)) nil + (if (boundp 'face-name-history) 'face-name-history 'icicle-face-name-history) + nil nil + ((prompt "Choose face (`RET' when done): ") ; Bindings + (icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1)) + (icicle-use-candidates-only-once-flag t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "face"))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "face"))) + (face-names ())) + (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + nil ; Undo code + (prog1 (setq face-names (nreverse (delete "" face-names))) ; Last code - return list of faces + (when (interactive-p) (message "Faces: %S" face-names)))) + +;;;###autoload +(icicle-define-command icicle-color-theme ; Command name + "Change color theme. +You can use `S-delete' during completion to remove the current +candidate from the list of color themes. + +If you use `C-g' during this command, the previous color-theme +snapshot is used to restore that color theme. + +Remember too that you can use the pseudo-theme [Reset] to restore the +last theme: `M-x color-theme-select [Reset]'. + +By default, each time you invoke this command, a snapshot is first +made of the current color theme (or current colors, if no theme is +used). Thus, by default, if you use `C-g', the colors restored are +those used before you changed themes using this command. + +However, if you use a prefix arg, then this command takes no new +snapshot, unless no snapshot has ever been taken during this Emacs +session. This can be useful when experimenting, to restore not to the +state just before this command invocation, but to some previous +snapshot. + +To use this command, you must have loaded library `color-theme.el', +available from http://www.emacswiki.org/cgi-bin/wiki.pl?ColorTheme." ; Doc string + (lambda (theme) + (when (string= "" theme) (error "No theme name entered (empty input)")) + (funcall (intern theme))) ; Action function: just call the theme. + "Theme: " icicle-color-themes nil t nil ; `completing-read' args + (if (boundp 'color-theme-history) 'color-theme-history 'icicle-color-theme-history) + nil nil + ((icicle-delete-candidate-object 'icicle-color-themes) ; Bindings + (prefix-arg current-prefix-arg)) + (progn (unless (prog1 (require 'color-theme nil t) ; First code + (when (and (fboundp 'color-theme-initialize) (not color-theme-initialized)) + ;; NOTE: We need the `condition-case' because of a BUG in `directory-files' + ;; for Emacs 20. Bug reported to `color-theme.el' maintainer 2009-11-22. The + ;; problem is that the default value of `color-theme-libraries' concats + ;; `file-name-directory', which ends in `/', with `/themes', not with `themes'. + ;; So the result is `...//themes'. That is tolerated by Emacs 21+ + ;; `directory-files', but not for Emacs 20. Until this `color-theme.el' bug is + ;; fixed, Emacs 20 users will need to manually load `color-theme-libraries.el'. + (condition-case nil + (let ((color-theme-load-all-themes t)) + (color-theme-initialize) + (setq color-theme-initialized t)) + (error nil)))) + (error "This command requires library `color-theme.el'")) + (unless icicle-color-themes + (setq icicle-color-themes + (delete '("bury-buffer") + (mapcar (lambda (entry) (list (symbol-name (car entry)))) + color-themes)))) + ;; Create the snapshot, if not available. Do this so users can also undo using + ;; pseudo-theme `[Reset]'. + (when (or (not prefix-arg) + (not (assq 'color-theme-snapshot color-themes)) + (not (commandp 'color-theme-snapshot))) + (fset 'color-theme-snapshot (color-theme-make-snapshot)) + (setq color-themes (delq (assq 'color-theme-snapshot color-themes) color-themes) + color-themes (delq (assq 'bury-buffer color-themes) color-themes) + color-themes (append '((color-theme-snapshot + "[Reset]" "Undo changes, if possible.") + (bury-buffer "[Quit]" "Bury this buffer.")) + color-themes)))) + (color-theme-snapshot)) ; Undo code + +;; Bound to `C-- C-y' via `icicle-yank-maybe-completing'. +;;;###autoload +(icicle-define-command icicle-completing-yank + "Yank an entry from the `kill-ring', choosing it using completion. +This is like `yank', but it does not rotate the `kill-ring'. +The mark is pushed first, so the yanked text becomes the region. +You can sort the candidates to yank - use `C-,'. +You can use `S-delete' during completion to remove a candidate entry +from the `kill-ring'." ; Doc string + icicle-insert-for-yank ; Action function + "Insert: " (mapcar #'list kill-ring) nil t nil 'icicle-kill-history ; `completing-read' args + (car kill-ring) nil + ((icicle-transform-function 'icicle-remove-duplicates) ; Bindings + (icicle-sort-comparer nil) + (icicle-delete-candidate-object 'kill-ring))) + +(defun icicle-insert-for-yank (string) + "`insert-for-yank', if defined; else, `insert' with `read-only' removed. +Pushes the mark first, so the inserted text becomes the region." + (push-mark) + (if (fboundp 'insert-for-yank) ; Defined in `subr.el' (not required). + (insert-for-yank string) + (let ((opoint (point))) + (insert string) + (let ((inhibit-read-only t)) (remove-text-properties opoint (point) '(read-only nil)))))) + +;;;###autoload +(defun icicle-yank-maybe-completing (&optional arg) ; Bound to `C-y' (or what `yank' was bound to). + "`icicle-completing-yank', `icicle-yank', or `icicle-yank-function'. +If called from the minibuffer, call `icicle-yank'. +Otherwise: + With a negative prefix argument, call `icicle-completing-yank'. + Otherwise, call the value of user option `icicle-yank-function' (by + default, `yank')." + (interactive "*P") + (if (window-minibuffer-p (selected-window)) + (icicle-yank arg) + (if (wholenump (prefix-numeric-value arg)) + (funcall icicle-yank-function arg) + (icicle-completing-yank)))) + +;;;###autoload +(icicle-define-file-command icicle-delete-file ; Command name + "Delete a file or directory." ; Doc string + icicle-delete-file-or-directory ; Function to perform the action + "Delete file or directory: " default-directory nil t nil nil ; `read-file-name' args + (icicle-file-bindings)) ; Bindings + +(defun icicle-delete-file-or-directory (file) + "Delete file or (empty) directory FILE." + (condition-case i-delete-file + (if (eq t (car (file-attributes file))) + (delete-directory file) + (delete-file file)) + (error (message (error-message-string i-delete-file)) + (error (error-message-string i-delete-file))))) + +;; $$$$$ (icicle-define-command icicle-file-list ; Command name +;; "Choose a list of file names. +;; You can use `S-delete' during completion to delete a candidate file. +;; The list of names (strings) is returned." ; Doc string +;; (lambda (name) (push name file-names)) ; Function to perform the action +;; "Choose file (`RET' when done): " ; `completing-read' args +;; (mapcar #'list (directory-files default-directory nil icicle-re-no-dot)) +;; nil nil nil 'file-name-history nil nil +;; ((file-names nil) ; Additional bindings +;; (icicle-delete-candidate-object 'icicle-delete-file-or-directory) ; `S-delete' deletes file. +;; (icicle-use-candidates-only-once-flag t)) +;; nil nil ; First code, undo code +;; (prog1 (setq file-names (nreverse (delete "" file-names))) ; Last code - return files list +;; (when (interactive-p) (message "Files: %S" file-names)))) + +;;;###autoload +(icicle-define-file-command icicle-file-list ; Command name + "Choose a list of file and directory names. +Use multi-command action keys (e.g. `C-RET', `C-mouse-2') to choose, +and a final-choice key (e.g. `RET', `mouse-2') to choose the last one. +You can navigate the directory tree, picking files and directories +anywhere in the tree. + +You can use `S-delete' during completion to delete a candidate file. + Careful: This deletes the file, it does not just remove it as a + candidate. +The list of file names (strings) is returned. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000)) + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (name) (push name file-names)) ; Function to perform the action + "Choose file (`RET' when done): " ; `read-file-name' args + nil nil t nil nil + (icicle-file-bindings ; Bindings + ((file-names nil) + (icicle-comp-base-is-default-dir-p t) + ;; $$$$$ (icicle-dir-candidate-can-exit-p (not current-prefix-arg)) + )) + nil nil ; First code, undo code + (prog1 (setq file-names (nreverse (delete "" file-names))) ; Last code - return list of files + (when (interactive-p) (message "Files: %S" file-names)))) + +;;;###autoload +(when (> emacs-major-version 21) + (icicle-define-file-command icicle-directory-list ; Command name + "Choose a list of directory names. +Use multi-command action keys (e.g. `C-RET', `C-mouse-2') to choose, +and a final-choice key (e.g. `RET', `mouse-2') to choose the last one. +You can navigate the directory tree, picking directories anywhere in +the tree. + +You can use `S-delete' during completion to delete a candidate (empty) +directory. + Careful: This deletes the directory, it does not just remove it as a + candidate. +The list of directory names (strings) is returned. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra directory names to display + `icicle-file-match-regexp' - Regexp directory names must match + `icicle-file-no-match-regexp' - Regexp dir names must not match + `icicle-file-predicate' - Predicate dir names must satisfy + `icicle-file-sort' - Sort function for candidates + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (name) (push name dir-names)) ; Function to perform the action + "Choose directory (`RET' when done): " ; `read-file-name' args + ;; $$$$$$ nil nil t nil #'(lambda (file) (eq t (car (file-attributes file)))) ; PREDICATE + nil nil t nil #'file-directory-p ; PREDICATE + (icicle-file-bindings ; Bindings + ((dir-names nil) + (icicle-comp-base-is-default-dir-p t) + ;; $$$$$ (icicle-dir-candidate-can-exit-p (not current-prefix-arg)) + )) + nil nil ; First code, undo code + (prog1 (setq dir-names (nreverse (delete "" dir-names))) ; Last code - return the list of dirs + (when (interactive-p) (message "Directories: %S" dir-names))))) + +;;;###autoload +(icicle-define-file-command icicle-dired + "Multi-command version of `dired'. +During completion: + You can use `C-x m' to access Dired bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory." ; Doc string + (lambda (dir) (dired dir switches)) ; Function to perform the action + "Dired (directory): " nil default-directory nil nil nil ; `read-file-name' args + (icicle-file-bindings ; Bindings + ((switches (and current-prefix-arg + (read-string "Dired listing switches: " dired-listing-switches))) + (icicle-file-sort (or icicle-file-sort 'icicle-dirs-first-p)) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (unless (boundp 'minibuffer-local-filename-completion-map) ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-dired-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-dired-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-dired-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;;;###autoload +(icicle-define-file-command icicle-dired-other-window + "Multi-command version of `dired-other-window'. +During completion: + You can use `C-x m' to access Dired bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory." ; Doc string + (lambda (dir) (dired-other-window dir switches)) ; Function to perform the action + "Dired in other window (directory): " nil default-directory nil nil nil ; `read-file-name' args + (icicle-file-bindings ; Bindings + ((switches (and current-prefix-arg + (read-string "Dired listing switches: " dired-listing-switches))) + (icicle-file-sort (or icicle-file-sort 'icicle-dirs-first-p)) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (unless (boundp 'minibuffer-local-filename-completion-map) ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-dired-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-dired-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-dired-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + + +(put 'icicle-file 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-file (arg) ; Bound to `C-x C-f' in Icicle mode. + "Visit a file or directory. +With no prefix argument, use relative file names + (`icicle-find-file'). +With a prefix argument, use absolute file names + (`icicle-find-file-absolute'). +With a negative prefix argument, you can choose also by date: + Completion candidates include the last modification date. + +Note that when you use a prefix argument completion matches candidates +as ordinary strings. It knows nothing of file names per se. In +particular, you cannot use remote file-name syntax if you use a prefix +argument. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +By default, Icicle mode remaps all key sequences that are normally bound +to `find-file' to `icicle-file'. If you do not want this remapping, +then customize option `icicle-top-level-key-bindings'." + (interactive "P") + (if arg + (if (wholenump (prefix-numeric-value arg)) + (let ((current-prefix-arg nil)) (icicle-find-file-absolute)) + (icicle-find-file-absolute)) + (icicle-find-file))) + + +(put 'icicle-file-other-window 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-file-other-window (arg) ; Bound to `C-x 4 f' in Icicle mode. + "Visit a file or directory in another window. +With no prefix argument, use relative file names + (`icicle-find-file-other-window'). +With a prefix argument, use absolute file names + (`icicle-find-file-absolute-other-window'). +With a negative prefix argument, you can choose also by date: + Completion candidates include the last modification date. + +Note that when you use a prefix argument completion matches candidates +as ordinary strings. It knows nothing of file names per se. In +particular, you cannot use remote file-name syntax if you use a prefix +argument. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +By default, Icicle mode remaps all key sequences that are normally +bound to `find-file-other-window' to `icicle-file-other-window'. If +you do not want this remapping, then customize option +`icicle-top-level-key-bindings'." + (interactive "P") + (if arg + (if (wholenump (prefix-numeric-value arg)) + (let ((current-prefix-arg nil)) (icicle-find-file-absolute-other-window)) + (icicle-find-file-absolute-other-window)) + (icicle-find-file-other-window))) + + +(put 'icicle-find-file-absolute 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-find-file-absolute ; Command name + "Visit a file or directory, given its absolute name. +Unlike `icicle-find-file', the completion candidates are absolute, not +relative, file names. By default, the completion candidates are files +in the current directory, but you can substitute other candidates by +retrieving a saved candidate set. + +Note that completion here matches candidates as ordinary strings. It +knows nothing of file names per se. In particular, you cannot use +remote file-name syntax. + +Remember that you can use `\\\ +\\[icicle-toggle-hiding-common-match]' to hide the common match portion of +each candidate. That can be particularly helpful for files that are +in a common directory. + +With a prefix argument, you can choose also by date: Completion +candidates include the last modification date. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c C-d' (think `cd') to change the `default-directory'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000)) + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (f) (find-file (icicle-transform-multi-completion f) 'WILDCARDS)) ; Action function + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + default-directory 'file-name-history default-directory nil + (icicle-file-bindings ; Bindings + ((prompt "File or directory: ") + (icicle-abs-file-candidates + (mapcar #'(lambda (file) (if (file-directory-p file) (concat file "/") file)) + (directory-files default-directory 'full nil 'nosort))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))) + (icicle-special-candidate-regexp (or icicle-special-candidate-regexp ".+/$")) + (icicle-candidate-properties-alist (and current-prefix-arg '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (define-key minibuffer-local-completion-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-completion-map "\C-c\C-d" 'icicle-cd-for-abs-files) + (define-key minibuffer-local-must-match-map "\C-c\C-d" 'icicle-cd-for-abs-files) + (define-key minibuffer-local-completion-map "\C-c+" 'icicle-make-directory) + (define-key minibuffer-local-must-match-map "\C-c+" 'icicle-make-directory) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Undo code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Last code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + + +(put 'icicle-find-file-absolute-other-window 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-find-file-absolute-other-window ; Command name + "Visit a file or directory in another window, given its absolute name. +Same as `icicle-find-file-absolute' except uses a different window." ; Doc string + (lambda (f) (find-file-other-window (icicle-transform-multi-completion f) 'WILDCARDS)) ; Action + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + default-directory 'file-name-history default-directory nil + (icicle-file-bindings ; Bindings + ((prompt "File or directory: ") + (icicle-abs-file-candidates + (mapcar #'(lambda (file) (if (file-directory-p file) (concat file "/") file)) + (directory-files default-directory 'full nil 'nosort))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))) + (icicle-special-candidate-regexp (or icicle-special-candidate-regexp ".+/$")) + (icicle-candidate-properties-alist (and current-prefix-arg '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (define-key minibuffer-local-completion-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-completion-map "\C-c\C-d" 'icicle-cd-for-abs-files) + (define-key minibuffer-local-must-match-map "\C-c\C-d" 'icicle-cd-for-abs-files) + (define-key minibuffer-local-completion-map "\C-c+" 'icicle-make-directory) + (define-key minibuffer-local-must-match-map "\C-c+" 'icicle-make-directory) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Undo code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Last code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + + +;; This is a minibuffer command. It is in this file because it is used only here. +;;;###autoload +(defun icicle-cd-for-abs-files (dir) + "Change `default-directory' during `icicle-find-file-absolute'." + (interactive + ;; Should not need to bind `minibuffer-completion-predicate'. Emacs 23.2 bug, per Stefan. + (let ((enable-recursive-minibuffers t) + (minibuffer-completion-predicate minibuffer-completion-predicate)) + (list (funcall (if (fboundp 'read-directory-name) + #'read-directory-name + #'read-file-name) + "Change default directory: " nil nil + (and (member cd-path '(nil ("./"))) (null (getenv "CDPATH"))))))) + (cd dir) + (let* ((icicle-abs-file-candidates + (mapcar #'(lambda (file) (if (file-directory-p file) (concat file "/") file)) + (directory-files default-directory 'full nil 'nosort))) + (collection + (mapcar (if icicle-list-use-nth-parts #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates))) + (setq minibuffer-completion-table + (car (icicle-mctize-all collection minibuffer-completion-predicate))))) + + +(put 'icicle-find-file 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-file-command icicle-find-file + "Visit a file or directory. +If you use a prefix argument when you act on a candidate file name, +then you visit the file in read-only mode. + +If you use a prefix arg for the command itself, this reverses the +effect of using a prefix arg on individual candidates. That is, with +a prefix arg for the command, files are visited in read-only mode by +default and a prefix arg for an individual file visits it without +read-only mode. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra absolute file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000)) + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (file) ; Function to perform the action + (let* ((r-o (if (eq this-command 'icicle-candidate-action) + (or (and init-pref-arg (not current-prefix-arg)) + (and (not init-pref-arg) current-prefix-arg)) + init-pref-arg)) + (fn (if r-o 'find-file-read-only 'find-file))) + (funcall fn file 'WILDCARDS))) + (concat "File or directory" (and init-pref-arg " (read-only)") ": ") ; `read-file-name' args + nil (if (and (eq major-mode 'dired-mode) (fboundp 'dired-get-file-for-visit)) ; Emacs 22+. + (condition-case nil ; E.g. error because not on file line (ignore) + (abbreviate-file-name (dired-get-file-for-visit)) + (error nil)) + default-directory) + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil nil + (icicle-file-bindings ; Bindings + ((init-pref-arg current-prefix-arg) + (icicle-all-candidates-list-alt-action-fn ; `M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (unless (boundp 'minibuffer-local-filename-completion-map) ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;;;###autoload +(icicle-define-file-command icicle-find-file-other-window + "Visit a file or directory in another window. +Same as `icicle-find-file' except it uses a different window. + +Note: Unlike standard `find-file-other-window', in Dired the file or +directory on the current line is the default value. Like +`find-file-other-window', if you just hit `RET' without entering any +text, that is the same as if you first use `M-n' to retrieve the +default value and then hit `RET'. Thus, if you just want to visit, in +a different window, the current directory instead of the file or +directory of the current line, you should use `\\\ +\\[icicle-erase-minibuffer-or-history-element]' to first empty the +minibuffer. Or you can just use a different command, such as `\\[dired]', +to visit the current directory." ; Doc string + (lambda (file) ; Function to perform the action + (let* ((r-o (if (eq this-command 'icicle-candidate-action) + (or (and init-pref-arg (not current-prefix-arg)) + (and (not init-pref-arg) current-prefix-arg)) + init-pref-arg)) + (fn (if r-o 'find-file-read-only-other-window 'find-file-other-window))) + (funcall fn file 'WILDCARDS))) + (concat "File or directory" (and init-pref-arg " (read-only)") ": ") ; `read-file-name' args + nil (if (and (eq major-mode 'dired-mode) (fboundp 'dired-get-file-for-visit)) ; Emacs 22+. + (condition-case nil ; E.g. error because not on file line (ignore) + (abbreviate-file-name (dired-get-file-for-visit)) + (error nil)) + default-directory) + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil nil + (icicle-file-bindings ; Bindings + ((init-pref-arg current-prefix-arg) + (icicle-all-candidates-list-alt-action-fn ; `M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (unless (boundp 'minibuffer-local-filename-completion-map) ; First code + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Undo code + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map "\C-xm" nil) ; Last code + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + + +(put 'icicle-find-file-read-only 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-find-file-read-only () ; Bound to `C-x C-r' in Icicle mode. + "Visit a file or directory in read-only mode. +If you use a prefix argument when you act on a candidate file name, +then visit the file without read-only mode. + +If you use a prefix arg for the command itself, this reverses the +effect of using a prefix arg on individual candidates. That is, with +a prefix arg for the command, files are not visited in read-only mode +by default and a prefix arg for an individual file visits it in +read-only mode." + (interactive) + (let ((current-prefix-arg (not current-prefix-arg))) + (icicle-find-file))) + +;;;###autoload +(defun icicle-find-file-read-only-other-window () ; Bound to `C-x 4 r' in Icicle mode. + "Visit a file or directory in read-only mode in another window. +Same as `icicle-find-file-read-only' except use a different window." + (interactive) + (let ((current-prefix-arg (not current-prefix-arg))) + (icicle-find-file-other-window))) + + +(put 'icicle-recent-file 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-recent-file ; Command name + "Open a recently used file. +With a prefix argument, you can choose also by date: Completion +candidates include the last modification date. + +Note that completion here matches candidates as ordinary strings. It +knows nothing of file names per se. In particular, you cannot use +remote file-name syntax. + +Remember that you can use `\\\ +\\[icicle-toggle-hiding-common-match]' to hide the common match portion of +each candidate. That can be particularly helpful for files that are +in a common directory. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +You can use any of the alternative-action keys, such as `C-S-RET', to +remove a candidate file from the recent files list, `recentf-list'. +\(The file itself is not deleted.) + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra absolute file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000)) + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (f) (find-file (icicle-transform-multi-completion f) 'WILDCARDS)) ; Action function + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'file-name-history (car recentf-list) nil + (icicle-file-bindings ; Bindings + ((prompt "Recent file: ") + (icicle-abs-file-candidates (progn (unless (boundp 'recentf-list) (require 'recentf)) + (when (fboundp 'recentf-mode) (recentf-mode 99)) + (unless (consp recentf-list) + (error "No recently accessed files")) + recentf-list)) + (icicle-candidate-alt-action-fn 'icicle-remove-from-recentf-candidate-action) + (icicle-use-candidates-only-once-alt-p t) + (icicle-candidate-properties-alist (and current-prefix-arg + '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") + (mapcar #'icicle-transform-multi-completion + files)))))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (define-key minibuffer-local-completion-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-completion-map "\C-c+" 'icicle-make-directory) + (define-key minibuffer-local-must-match-map "\C-c+" 'icicle-make-directory) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Undo code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Last code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;;;###autoload +(icicle-define-command icicle-recent-file-other-window ; Command name + "Open a recently used file in another window. +Same as `icicle-recent-file' except it uses a different window." ; Doc string + (lambda (f) (find-file-other-window (icicle-transform-multi-completion f) 'WILDCARDS)) ; Action + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'file-name-history (car recentf-list) nil + (icicle-file-bindings ; Bindings + ((prompt "Recent file: ") + (icicle-abs-file-candidates (progn (unless (boundp 'recentf-list) (require 'recentf)) + (when (fboundp 'recentf-mode) (recentf-mode 99)) + (unless (consp recentf-list) + (error "No recently accessed files")) + recentf-list)) + (icicle-candidate-alt-action-fn 'icicle-remove-from-recentf-candidate-action) + (icicle-use-candidates-only-once-alt-p t) + (icicle-candidate-properties-alist (and current-prefix-arg + '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") + (mapcar #'icicle-transform-multi-completion + files)))))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (define-key minibuffer-local-completion-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-completion-map "\C-c+" 'icicle-make-directory) + (define-key minibuffer-local-must-match-map "\C-c+" 'icicle-make-directory) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Undo code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Last code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil))) + +;;;###autoload +(icicle-define-command icicle-remove-file-from-recentf-list + "Remove file from `recentf-list' - the list of recently used files." + icicle-remove-from-recentf-candidate-action + "Remove from recent files list, `recentf-list': " + (mapcar #'list (progn (unless (boundp 'recentf-list) (require 'recentf)) + (when (fboundp 'recentf-mode) (recentf-mode 99)) + (unless (consp recentf-list) (error "No recently accessed files")) + recentf-list)) + nil (and (fboundp 'confirm-nonexistent-file-or-buffer) ; Emacs23. + (confirm-nonexistent-file-or-buffer)) + nil 'file-name-history (car recentf-list) nil + ((icicle-use-candidates-only-once-flag t))) + +(defun icicle-remove-from-recentf-candidate-action (file) + "Action function for command `icicle-remove-file-from-recentf-list'." + (setq recentf-list (delete file recentf-list)) + (message "`%s' removed from `recentf-list'" file)) + + +(put 'icicle-locate-file 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-locate-file () + "Visit a file within a directory or its subdirectories. +With a non-negative (>= 0) prefix argument, you are prompted for the +directory. Otherwise, the current directory is used. + +With a non-positive (<= 0) prefix argument, you can choose also by +date: Completion candidates include the last modification date. + +The absolute names of all files within the directory and all of its +subdirectories are targets for completion. Regexp input is matched +against all parts of the absolute name, not just the file-name part. + +Remember that you can use `\\\ +\\[icicle-toggle-hiding-common-match]' to hide the common match portion of +each candidate. That can be particularly helpful for files that are +in a common directory. + +You can use this command to find all files within your file system +that match a regexp, but be aware that gathering and matching the file +names will take some time. + +See also command `icicle-locate-file-no-symlinks', which does the same +thing but without following symbolic links. + +Remember that you can save the set of files matching your input using +`\\[icicle-candidate-set-save]' or \ +`\\[icicle-candidate-set-save-persistently]'. You can then retrieve quickly them later using +`\\[icicle-candidate-set-retrieve]' or \ +`\\[icicle-candidate-set-retrieve-persistent]'. + +Note that completion here matches candidates as ordinary strings. It +knows nothing of file names per se. In particular, you cannot use +remote file-name syntax. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `C-c C-d' (think `cd') to change the `default-directory'. + You can use `C-c +' to create a new directory. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +Directories in `icicle-ignored-directories' are ignored (skipped). In +addition, these options control candidate matching and filtering: + + `icicle-file-extras' - Extra file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-require-match-flag' - See `icicle-require-match-flag' + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000))" + (interactive) + (let ((icicle-locate-file-action-fn 'icicle-locate-file-action) + (no-symlinks-p nil)) + (icicle-locate-file-1))) + +;;;###autoload +(defun icicle-locate-file-other-window () + "Same as `icicle-locate-file' except visit file in a different window. +See also command `icicle-locate-file-no-symlinks-other-window', which +does not follow symbolic links." + (interactive) + (let ((icicle-locate-file-action-fn 'icicle-locate-file-other-window-action) + (no-symlinks-p nil)) + (icicle-locate-file-1))) + +(put 'icicle-locate-file-no-symlinks 'icicle-Completions-window-max-height 200) +;;;###autoload +(defun icicle-locate-file-no-symlinks () + "`icicle-locate-file' except do not follow symlinks." + (interactive) + (let ((icicle-locate-file-action-fn 'icicle-locate-file-other-window-action) + (no-symlinks-p t)) + (icicle-locate-file-1))) + +;;;###autoload +(defun icicle-locate-file-no-symlinks-other-window () + "`icicle-locate-file-no-symlinks' except visit file in different window." + (interactive) + (let ((icicle-locate-file-action-fn 'icicle-locate-file-other-window-action) + (no-symlinks-p t)) + (icicle-locate-file-1))) + +(defun icicle-locate-file-action (file) + "Action function for `icicle-locate-file'." + (find-file (icicle-transform-multi-completion file) 'WILDCARDS)) + +(defun icicle-locate-file-other-window-action (file) + "Action function for `icicle-locate-file-other-window'." + (find-file-other-window (icicle-transform-multi-completion file) 'WILDCARDS)) + +;;;###autoload +(icicle-define-command icicle-locate-file-1 + "Helper function for `icicle-locate-file(-other-window)'." ; Doc string + ;; `icicle-locate-file-action-fn' is free here. + (lambda (f) (funcall icicle-locate-file-action-fn f)) ; Action function + prompt ; `completing-read' args + (mapcar (if (<= (prefix-numeric-value current-prefix-arg) 0) + #'icicle-make-file+date-candidate + #'list) + icicle-abs-file-candidates) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'file-name-history nil nil + (icicle-file-bindings ; Bindings + ((prompt "File: ") + (dir (if (and current-prefix-arg + (wholenump (prefix-numeric-value + current-prefix-arg))) + (read-file-name "Locate under which directory: " nil + default-directory nil) + default-directory)) + (IGNORED--FOR-SIDE-EFFECT (progn + (icicle-highlight-lighter) + (message "Gathering files within `%s' (this could take \ +a while)..." dir))) + (icicle-abs-file-candidates ; `no-symlinks-p' is free here. + (icicle-files-within (directory-files dir 'full icicle-re-no-dot) nil no-symlinks-p)) + (use-dialog-box nil) + (icicle-candidate-properties-alist (and (<= (prefix-numeric-value current-prefix-arg) 0) + '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and (<= (prefix-numeric-value current-prefix-arg) 0) + '(1))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") + (mapcar #'icicle-transform-multi-completion + files)))))))) + (progn ; First code + (when (<= (prefix-numeric-value current-prefix-arg) 0) + (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (define-key minibuffer-local-completion-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-map [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-completion-map "\C-c\C-d" 'icicle-cd-for-loc-files) + (define-key minibuffer-local-must-match-map "\C-c\C-d" 'icicle-cd-for-loc-files) + (define-key minibuffer-local-completion-map "\C-c+" 'icicle-make-directory) + (define-key minibuffer-local-must-match-map "\C-c+" 'icicle-make-directory) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-file-other-window) + (define-key minibuffer-local-must-match-map "\C-xm" 'icicle-bookmark-file-other-window))) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Undo code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + (progn (define-key minibuffer-local-completion-map [(control backspace)] nil) ; Last code + (define-key minibuffer-local-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-completion-map "\C-c\C-d" nil) + (define-key minibuffer-local-must-match-map "\C-c\C-d" nil) + (define-key minibuffer-local-completion-map "\C-c+" nil) + (define-key minibuffer-local-must-match-map "\C-c+" nil) + (define-key minibuffer-local-completion-map "\C-xm" nil) + (define-key minibuffer-local-must-match-map "\C-xm" nil)) + 'NON-INTERACTIVE) ; This is not a real command. + +;; This is a minibuffer command. It is in this file because it is used only here. +;;;###autoload +(defun icicle-cd-for-loc-files (dir &optional no-symlinks-p) + "Change `default-directory' during `icicle-locate-file'. +Optional arg NO-SYMLINKS-P non-nil means do not follow symbolic links." + (interactive + (save-selected-window + ;; Should not need to bind `minibuffer-completion-predicate'. Emacs 23.2 bug, per Stefan. + (let ((minibuffer-completion-predicate minibuffer-completion-predicate)) + (list (funcall (if (fboundp 'read-directory-name) + #'read-directory-name + #'read-file-name) + "Change default directory: " nil nil + (and (member cd-path '(nil ("./"))) (null (getenv "CDPATH")))))))) + (cd dir) + (let* ((icicle-abs-file-candidates + (icicle-files-within (directory-files dir 'full icicle-re-no-dot) nil no-symlinks-p)) + (collection + (mapcar (if icicle-list-use-nth-parts #'icicle-make-file+date-candidate #'list) + icicle-abs-file-candidates))) + (setq minibuffer-completion-table + (car (icicle-mctize-all collection minibuffer-completion-predicate))))) + + +(put 'icicle-find-file-in-tags-table 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-find-file-in-tags-table ; Command name + "Visit a file listed in a tags table. +By default, the completion candidates are the file names listed in the +current tags table, but you can substitute other candidates by +retrieving a saved candidate set. The default candidates appear as +they did in the `etags' command that created the tags table, which +typically means without directory names. + +Completion here matches candidates as ordinary strings. It knows +nothing of file names per se. In particular, you cannot use remote +file-name syntax. If a candidate is an absolute file name then you +can complete against any and all parts of the name (including +directory components). + +`find-file' is called for the candidate(s) you choose, with the +directory of the tags file as `default-directory'. + +Remember that you can use `\\\ +\\[icicle-toggle-hiding-common-match]' to hide the common match portion of +each candidate. That can be particularly helpful for files that are +in a common directory. + +With a prefix argument, you can choose also by date: Completion +candidates include the last modification date. + +During completion: + You can use `C-x m' to access file bookmarks, if you use library + `bookmark+.el'. + You can use `M-|' to open Dired on the currently matching file names. + You can use `S-delete' to delete a candidate file or (empty) + directory. + +These options, when non-nil, control candidate matching and filtering: + + `icicle-file-extras' - Extra file names to display + `icicle-file-match-regexp' - Regexp that file names must match + `icicle-file-no-match-regexp' - Regexp file names must not match + `icicle-file-predicate' - Predicate file names must satisfy + `icicle-file-sort' - Sort function for candidates + +For example, to show only names of files larger than 5000 bytes, set +`icicle-file-predicate' to: + + (lambda (file) (> (nth 5 (file-attributes file)) 5000)) + +Option `icicle-file-require-match-flag' can be used to override +option `icicle-require-match-flag'. + +Option `icicle-files-ido-like' non-nil gives this command a more +Ido-like behavior." ; Doc string + (lambda (ff) + (visit-tags-table-buffer 'same) ; To pick up `default-directory' of TAGS table. + (find-file (icicle-transform-multi-completion ff) 'WILDCARDS)) ; Action function + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + (save-excursion (let ((enable-recursive-minibuffers t)) (visit-tags-table-buffer)) + (tags-table-files))) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'file-name-history nil nil + (icicle-file-bindings ; Bindings + ((prompt "File (in tags table): ") + (icicle-special-candidate-regexp (or icicle-special-candidate-regexp ".+/$")) + (icicle-candidate-properties-alist (and current-prefix-arg '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (unless (require 'etags nil t) (error "`etags.el' is required")))) + + +(put 'icicle-find-file-in-tags-table-other-window 'icicle-Completions-window-max-height 200) +;;;###autoload +(icicle-define-command icicle-find-file-in-tags-table-other-window ; Command name + "Visit a tags-table file in another window. +Same as `icicle-find-file-in-tags-table', but uses a different window." ; Doc string + (lambda (ff) + (visit-tags-table-buffer 'same) ; To pick up `default-directory' of TAGS table. + (find-file (icicle-transform-multi-completion ff) 'WILDCARDS)) ; Action function + prompt ; `completing-read' args + (mapcar (if current-prefix-arg #'icicle-make-file+date-candidate #'list) + (save-excursion (let ((enable-recursive-minibuffers t)) (visit-tags-table-buffer)) + (tags-table-files))) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ;Emacs23. + nil 'file-name-history nil nil + (icicle-file-bindings ; Bindings + ((prompt "File (in tags table): ") + (icicle-special-candidate-regexp (or icicle-special-candidate-regexp ".+/$")) + (icicle-candidate-properties-alist (and current-prefix-arg '((1 (face icicle-candidate-part))))) + (icicle-list-use-nth-parts (and current-prefix-arg '(1))) + (icicle-all-candidates-list-alt-action-fn ; M-|' + (lambda (files) (let ((enable-recursive-minibuffers t)) + (dired-other-window (cons (read-string "Dired buffer name: ") files))))))) + (progn ; First code + (when current-prefix-arg (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (unless (require 'etags nil t) (error "`etags.el' is required")))) + +(defun icicle-make-file+date-candidate (file) + "Return a multi-completion candidate: FILE + last modification date." + (list (list file (format-time-string "%Y %m %d %T " (nth 5 (file-attributes file)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-cmd1) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-cmd1.el ends here diff --git a/.emacs.d/icicles/icicles-cmd2.el b/.emacs.d/icicles/icicles-cmd2.el new file mode 100644 index 0000000..422be69 --- /dev/null +++ b/.emacs.d/icicles/icicles-cmd2.el @@ -0,0 +1,5312 @@ +;;; icicles-cmd2.el --- Top-level commands for Icicles +;; +;; Filename: icicles-cmd2.el +;; Description: Top-level commands for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Thu May 21 13:31:43 2009 (-0700) +;; Version: 22.0 +;; Last-Updated: Sat Jul 17 14:15:02 2010 (-0700) +;; By: dradams +;; Update #: 2197 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-cmd2.el +;; Keywords: 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', `avoid', `cl', `cus-edit', +;; `cus-face', `cus-load', `cus-start', `doremi', `easymenu', +;; `el-swank-fuzzy', `ffap', `ffap-', `frame-cmds', `frame-fns', +;; `fuzzy-match', `hexrgb', `icicles-cmd1', `icicles-face', +;; `icicles-fn', `icicles-mcmd', `icicles-opt', `icicles-var', +;; `kmacro', `levenshtein', `misc-fns', `mwheel', `pp', `pp+', +;; `ring', `ring+', `strings', `thingatpt', `thingatpt+', +;; `wid-edit', `wid-edit+', `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; top-level commands (and a few non-interactive functions used in +;; those commands). This is a continuation of library +;; `icicles-cmd1.el' (a single file for all top-level commands would +;; be too large to upload to Emacs Wiki). +;; +;; For commands to be used mainly in the minibuffer or buffer +;; *Completions*, see `icicles-mcmd.el'. +;; +;; For Icicles documentation, see `icicles-doc1.el' and +;; `icicles-doc2.el'. +;; +;; If you use the byte-compiled version of this library, +;; `icicles-cmd2.elc', in Emacs 23, then it must be byte-compiled +;; using Emacs 23. Otherwise, Icicles key completion (and perhaps +;; other things?) will not work correctly. +;; +;; Macros defined here: +;; +;; `icicle-define-search-bookmark-command'. +;; +;; Commands defined here - (+) means a multi-command: +;; +;; (+)`a', (+)`any', (+)`buffer', (+)`file', (+)`icicle-anything', +;; (+)`icicle-apply', `icicle-apropos', `icicle-apropos-command', +;; `icicle-apropos-function', `icicle-apropos-option', +;; `icicle-apropos-variable', `icicle-apropos-zippy', +;; (+)`icicle-comint-command', (+)`icicle-comint-search', +;; (+)`icicle-compilation-search', (+)`icicle-complete-keys', +;; `icicle-complete-thesaurus-entry', +;; (+)`icicle-describe-option-of-type', (+)`icicle-doc', +;; (+)`icicle-exchange-point-and-mark', (+)`icicle-font', +;; (+)`icicle-frame-bg', (+)`icicle-frame-fg', (+)`icicle-fundoc', +;; (+)`icicle-goto-global-marker', +;; (+)`icicle-goto-global-marker-or-pop-global-mark', +;; (+)`icicle-goto-marker', +;; (+)`icicle-goto-marker-or-set-mark-command', (+)`icicle-imenu', +;; (+)`icicle-imenu-command', +;; (+)`icicle-imenu-non-interactive-function', +;; `icicle-ido-like-mode', (+)`icicle-Info-goto-node', +;; (+)`icicle-Info-goto-node-cmd', (+)`icicle-Info-index', +;; (+)`icicle-Info-index-20', (+)`icicle-Info-index-cmd', +;; (+)`icicle-Info-menu', `icicle-Info-menu-cmd', +;; `icicle-Info-virtual-book', `icicle-insert-char', +;; (+)`icicle-insert-thesaurus-entry', (+)`icicle-keyword-list', +;; (+)`icicle-map', `icicle-non-whitespace-string-p', +;; (+)`icicle-object-action', (+)`icicle-occur', (+)`icicle-plist', +;; `icicle-read-color', `icicle-read-kbd-macro', +;; (+)`icicle-regexp-list', `icicle-save-string-to-variable', +;; (+)`icicle-search', (+)`icicle-search-all-tags-bookmark', +;; (+)`icicle-search-all-tags-regexp-bookmark', +;; (+)`icicle-search-bookmark', +;; (+)`icicle-search-bookmark-list-bookmark', +;; (+)`icicle-search-bookmarks-together', +;; (+)`icicle-search-buffer', (+)`icicle-search-buff-menu-marked', +;; (+)`icicle-search-char-property', (+)`icicle-search-defs', +;; (+)`icicle-search-desktop-bookmark', +;; (+)`icicle-search-dired-bookmark', +;; (+)`icicle-search-dired-marked', (+)`icicle-search-file', +;; (+)`icicle-search-file-bookmark', (+)`icicle-search-generic', +;; (+)`icicle-search-gnus-bookmark', +;; `icicle-search-highlight-cleanup', +;; (+)`icicle-search-ibuffer-marked', +;; (+)`icicle-search-info-bookmark', (+)`icicle-search-keywords', +;; (+)`icicle-search-lines', +;; (+)`icicle-search-local-file-bookmark', +;; (+)`icicle-search-man-bookmark', +;; (+)`icicle-search-non-file-bookmark', +;; (+)`icicle-search-overlay-property', +;; (+)`icicle-search-paragraphs', (+)`icicle-search-pages', +;; (+)`icicle-search-region-bookmark', +;; (+)`icicle-search-remote-file-bookmark', +;; (+)`icicle-search-sentences', +;; (+)`icicle-search-some-tags-bookmark', +;; (+)`icicle-search-some-tags-regexp-bookmark', +;; (+)`icicle-search-specific-buffers-bookmark', +;; (+)`icicle-search-specific-files-bookmark', +;; (+)`icicle-search-text-property', +;; (+)`icicle-search-this-buffer-bookmark', +;; (+)`icicle-search-url-bookmark', (+)`icicle-search-w3m-bookmark', +;; (+)`icicle-search-word', (+)`icicle-select-frame', +;; `icicle-select-frame-by-name', (+)`icicle-tags-search', +;; (+)`icicle-vardoc', (+)`icicle-where-is', (+)`what-which-how'. +;; +;; Non-interactive functions defined here: +;; +;; `icicle-add-key+cmd', `icicle-anything-candidate-value', +;; `icicle-apply-action', `icicle-apply-list-action', +;; `icicle-char-properties-in-buffer', +;; `icicle-char-properties-in-buffers', +;; `icicle-choose-anything-candidate', +;; `icicle-choose-candidate-of-type', `icicle-comint-hook-fn', +;; `icicle-comint-search-get-final-choice', +;; `icicle-comint-search-get-minibuffer-input', +;; `icicle-comint-search-send-input', `icicle-compilation-hook-fn', +;; `icicle-compilation-search-in-context-fn', +;; `icicle-complete-keys-1', `icicle-complete-keys-action', +;; `icicle-describe-opt-action', +;; `icicle-describe-opt-of-type-complete', `icicle-doc-action', +;; `icicle-edmacro-parse-keys', `icicle-flat-list', +;; `icicle-fn-doc-minus-sig', `icicle-font-w-orig-size', +;; `icicle-funvardoc-action', +;; `icicle-get-anything-actions-for-type', +;; `icicle-get-anything-cached-candidates', +;; `icicle-get-anything-candidates', +;; `icicle-get-anything-candidates-of-type', +;; `icicle-get-anything-default-actions-for-type', +;; `icicle-get-anything-input-delay', +;; `icicle-get-anything-req-pat-chars', +;; `icicle-get-anything-types', `icicle-goto-marker-1', +;; `icicle-goto-marker-1-action', `icicle-group-regexp', +;; `icicle-imenu-command-p', `icicle-imenu-in-buffer-p', +;; `icicle-imenu-non-interactive-function-p', +;; `icicle-Info-book-order-p', +;; `icicle-Info-build-node-completions', +;; `icicle-Info-build-node-completions-1', +;; `icicle-Info-goto-node-1', `icicle-Info-goto-node-action', +;; `icicle-Info-index-action', `icicle-Info-read-node-name', +;; `icicle-insert-thesaurus-entry-cand-fn', +;; `icicle-keys+cmds-w-prefix', `icicle-marker+text', +;; `icicle-markers', `icicle-next-single-char-property-change', +;; `icicle-read-single-key-description', +;; `icicle-read-var-value-satisfying', +;; `icicle-region-or-buffer-limits', `icicle-search-action', +;; `icicle-search-action-1', `icicle-search-bookmark-action', +;; `icicle-search-char-property-scan', +;; `icicle-search-choose-buffers', `icicle-search-cleanup', +;; `icicle-search-define-candidates', +;; `icicle-search-define-candidates-1', `icicle-search-final-act', +;; `icicle-search-help', +;; `icicle-search-highlight-all-input-matches', +;; `icicle-search-highlight-and-maybe-replace', +;; `icicle-search-highlight-input-matches-here', +;; `icicle-search-in-context-default-fn', +;; `icicle-search-property-args', `icicle-search-quit-or-error', +;; `icicle-search-read-context-regexp', `icicle-search-read-word', +;; `icicle-search-regexp-scan', +;; `icicle-search-replace-all-search-hits', +;; `icicle-search-replace-cand-in-alist', +;; `icicle-search-replace-cand-in-mct', +;; `icicle-search-replace-fixed-case-p', +;; `icicle-search-replace-match', +;; `icicle-search-replace-search-hit', `icicle-search-where-arg', +;; `icicle-this-command-keys-prefix'. +;; +;; +;; ***** NOTE: The following functions defined in `cus-edit.el' have +;; been REDEFINED HERE: +;; +;; `customize-face', `customize-face-other-window' - Multi-commands. +;; +;; +;; 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. +;; +;; (@> "Icicles Top-Level Commands, Part 2") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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 3, 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)) ;; loop + ;; plus, for Emacs < 21: dolist, push +(eval-when-compile (when (>= emacs-major-version 22) (require 'edmacro))) ;; edmacro-subseq +(eval-when-compile (require 'comint)) + ;; comint-check-proc, comint-copy-old-input, comint-get-old-input, comint-input-ring, + ;; comint-prompt-regexp, comint-send-input +(eval-when-compile (require 'imenu)) ;; imenu-syntax-alist +(eval-when-compile (require 'compile)) ;; compilation-find-buffer +(eval-when-compile (require 'info)) ;; Info-goto-node +(eval-when-compile (require 'etags)) ;; tags-case-fold-search, tags-table-files, + ;; visit-tags-table-buffer + +;; Commented out because `synonyms.el' soft-requires Icicles. +;; (eval-when-compile (require 'synonyms nil t)) ;; (no error if not found): + ;; synonyms-ensure-synonyms-read-from-cache, synonyms-obarray +(eval-when-compile (when (> emacs-major-version 21) + (require 'anything nil t))) ;; (no error if not found): + ;; anything-candidate-cache, anything-get-sources, anything-idle-delay, anything-pattern, + ;; anything-sources, anything-transform-candidates +(eval-when-compile (require 'yow nil t)) ;; (no error if not found): + ;; apropos-zippy, yow-after-load-message, yow-file, yow-load-message +(eval-when-compile (require 'cookie1 nil t)) ;; (no error if not found): cookie-cache +(require 'apropos-fn+var nil t) ;; (no error if not found): + ;; apropos-command, apropos-function, apropos-option, apropos-variable +(require 'hexrgb nil t) ;; (no error if not found): hexrgb-color-name-to-hex, hexrgb-read-color +(require 'strings nil t) ;; (no error if not found): read-number (my version) + +(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-define-command +(require 'icicles-mcmd) ;; icicle-search-define-replacement +(require 'icicles-var) + ;; icicle-candidate-action-fn, icicle-candidate-entry-fn, icicle-candidate-nb, + ;; icicle-candidates-alist, icicle-char-property-value-history, icicle-complete-keys-alist, + ;; icicle-completion-candidates, icicle-current-input, icicle-extra-candidates, + ;; icicle-get-alist-candidate-function, icicle-must-match-regexp, icicle-must-not-match-regexp, + ;; icicle-must-pass-predicate, icicle-saved-completion-candidates, icicle-search-command, + ;; icicle-search-current-overlay, icicle-search-final-choice, icicle-search-overlays, + ;; icicle-search-refined-overlays +(require 'icicles-opt) + ;; icicle-alternative-sort-comparer, icicle-buffer-extras, icicle-buffer-ignore-space-prefix-flag, + ;; icicle-buffer-match-regexp, icicle-buffer-no-match-regexp, icicle-buffer-predicate, + ;; icicle-buffer-require-match-flag, icicle-buffer-sort, icicle-complete-keys-self-insert-flag, + ;; icicle-ignore-space-prefix-flag, icicle-key-descriptions-use-<>-flag, + ;; icicle-require-match-flag, icicle-saved-completion-sets, + ;; icicle-search-cleanup-flag, icicle-search-highlight-all-current-flag, + ;; icicle-search-highlight-threshold, icicle-search-hook, icicle-sort-comparer, + ;; icicle-transform-function +(require 'icicles-fn) ;; icicle-candidate-short-help, icicle-completing-read-history, + ;; icicle-highlight-lighter, icicle-insert-cand-in-minibuffer, icicle-kill-a-buffer +(require 'icicles-cmd1) ;; custom-variable-p, icicle-bookmark-cleanup, + ;; icicle-bookmark-cleanup-on-quit, icicle-bookmark-cmd, icicle-bookmark-help-string, + ;; icicle-bookmark-history, icicle-bookmark-propertize-candidate, icicle-buffer-list, + ;; icicle-explore, icicle-face-list, icicle-file-list, icicle-make-frame-alist, + ;; icicle-select-bookmarked-region + + + +;; 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: + +(defvar anything-sources) ; In `anything.el' +(defvar anything-candidate-cache) ; In `anything.el' +(defvar anything-idle-delay) ; In `anything.el' +(defvar icicle-search-ecm) ; In `icicle-search' +(defvar icicle-track-pt) ; In `icicle-insert-thesaurus-entry' + +;; (< emacs-major-version 21) +(defvar tooltip-mode) ; In `tooltip.el' + +;; (< emacs-major-version 22) +(defvar compilation-current-error) +(defvar cookie-cache) +(defvar icicle-complete-keys-alist) ; In `icicles-var.el' +(defvar Info-menu-entry-name-re) ; In `info.el' +(defvar Info-read-node-completion-table) ; In `info.el' +(defvar tags-case-fold-search) ; In `etags.el' +(defvar yow-after-load-message) +(defvar yow-file) +(defvar yow-load-message) + +;; (> emacs-major-version 21) +(defvar Info-saved-nodes) ; In `info+.el' + +;; (< emacs-major-version 23) +(defvar read-buffer-completion-ignore-case) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Icicles Top-Level Commands, Part 2") +;;; Icicles Top-Level Commands, Part 2 . . . . . . . . . + + +;;;###autoload +(icicle-define-command icicle-font ; Command name + "Change font of current frame." ; Doc string + (lambda (font) (modify-frame-parameters orig-frame (list (cons 'font font)))) ; Action function + "Font: " ; `completing-read' args + (let ((fonts ()) + fws) + (dolist (ft (x-list-fonts "*") fonts) ; Just avoiding two traversals, one to remove nil elts. + (when (setq fws (icicle-font-w-orig-size ft)) (push fws fonts)))) ; Ignore nil entries. + nil t nil (if (boundp 'font-name-history) 'font-name-history 'icicle-font-name-history) nil nil + ((orig-frame (selected-frame)) ; Bindings + (orig-font (frame-parameter nil 'font)) + (orig-pixelsize (aref (x-decompose-font-name orig-font) xlfd-regexp-pixelsize-subnum)) + (orig-pointsize (aref (x-decompose-font-name orig-font) xlfd-regexp-pointsize-subnum)) + (orig-menu-bar (assq 'menu-bar-lines (frame-parameters orig-frame)))) + ;; First code - remove menu-bar, to avoid Emacs bug that resizes frame. + (modify-frame-parameters orig-frame (list '(menu-bar-lines . 0))) + (modify-frame-parameters orig-frame (list (cons 'font orig-font) orig-menu-bar)) ; Undo code. + (modify-frame-parameters orig-frame (list orig-menu-bar))) ; Last code. + +;; Free var here: `orig-pixelsize' is bound in `icicle-font'. +(defun icicle-font-w-orig-size (font) + "Return a font the same as FONT, but with pixel size `orig-pixelsize'. +Return nil if `x-decompose-font-name' returns nil for FONT. +`orig-pixelsize' is the original pixel size for `icicle-font'." + (let ((xlfd-fields (x-decompose-font-name font))) + (if (not xlfd-fields) ; Can't handle such font names - return nil. + nil + (aset xlfd-fields xlfd-regexp-pixelsize-subnum orig-pixelsize) + (aset xlfd-fields xlfd-regexp-pointsize-subnum orig-pointsize) + (let* ((sized-font (x-compose-font-name xlfd-fields)) + (font-info (and (or icicle-help-in-mode-line-flag ; Get it only if user will see it. + (and (boundp 'tooltip-mode) tooltip-mode)) + (font-info sized-font))) + (iii (if (< emacs-major-version 21) 3 2)) + (help-string (if font-info + (format "width: %s, height: %s, offset: %s, compose: %s" + (aref font-info iii) (aref font-info (+ iii 1)) + (aref font-info (+ iii 2)) (aref font-info (+ iii 3))) + "Font is not yet loaded (used)"))) + (icicle-candidate-short-help help-string sized-font) + (list sized-font))))) + +;;;###autoload +(icicle-define-command icicle-frame-bg ; Command name + "Change background of current frame. +Read color name or hex RGB color value #RRRRGGGGBBBB with completion. +In addition to standard color names and RGB (red, green, blue) hex +values, the following are also available as proxy color candidates, +provided `icicle-add-proxy-candidates-flag' is non-nil and library +`palette.el' or `eyedropper.el' is used. In each case, the +corresponding color is used. + +* `*copied foreground*' - last copied foreground, if available +* `*copied background*' - last copied background, if available +* `*point foreground*' - foreground under the text cursor +* `*point background*' - background under the text cursor + +\(You can copy a color using eyedropper commands such as +`eyedrop-pick-foreground-at-mouse'.) + +In addition, the names of user options (variables) whose custom type +is `color' are also proxy candidates, but with `'' as a prefix and +suffix. So, for example, option `icicle-region-background' appears as +proxy color candidate `'icicle-region-background''. + +As always, you can toggle the use of proxy candidates using `\\\ +\\[icicle-toggle-proxy-candidates]' in +the minibuffer. + +You can complete your input against the color name, the RGB value, or +both. + +Note: Duplicate color names are removed by downcasing and removing +whitespace. For example, \"AliceBlue\" and \"alice blue\" are both +treated as \"aliceblue\". Otherwise, candidates with different names +but the same RGB values are not considered duplicates, so, for +example, input can match either \"darkred\" or \"red4\", which both +have RGB #8b8b00000000. You can toggle duplicate removal at any time +using `C-$'. + +During completion, candidate help (e.g. `C-M-RET') shows you the RGB +and HSV (hue, saturation, value) color components. + +This command is intended only for use in Icicle mode." ; Doc string + (lambda (color) ; Action function + (modify-frame-parameters + orig-frame (list (cons 'background-color (icicle-transform-multi-completion color))))) + prompt named-colors nil t nil ; `completing-read' args + (if (boundp 'color-history) 'color-history 'icicle-color-history) nil nil + ((orig-frame (selected-frame)) ; Bindings + (orig-bg (frame-parameter nil 'background-color)) + (prompt "Background color: ") + (icicle-list-use-nth-parts '(2)) ; Use RGB part. + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "color"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "color"))) + + icicle-candidate-help-fn completion-ignore-case icicle-transform-function + icicle-sort-orders-alist icicle-list-nth-parts-join-string icicle-list-join-string + icicle-list-end-string icicle-proxy-candidate-regexp named-colors + icicle-proxy-candidates) + + (icicle-color-completion-setup) ; First code + (modify-frame-parameters orig-frame (list (cons 'background-color orig-bg))) ; Undo code + nil) ; Last code + +;;;###autoload +(icicle-define-command icicle-frame-fg ; Command name + "Change foreground of current frame. +See `icicle-frame-bg' - but this is for foreground, not background." ; Doc string + (lambda (color) ; Action function + (modify-frame-parameters + orig-frame (list (cons 'foreground-color (icicle-transform-multi-completion color))))) + prompt named-colors nil t nil ; `completing-read' args + (if (boundp 'color-history) 'color-history 'icicle-color-history) nil nil + ((orig-frame (selected-frame)) ; Bindings + (orig-bg (frame-parameter nil 'foreground-color)) + (prompt "Foreground color: ") + (icicle-list-use-nth-parts '(2)) ; Use RGB part. + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "color"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "color"))) + + icicle-candidate-help-fn completion-ignore-case icicle-transform-function + icicle-sort-orders-alist icicle-list-nth-parts-join-string icicle-list-join-string + icicle-list-end-string icicle-proxy-candidate-regexp named-colors + icicle-proxy-candidates) + + (icicle-color-completion-setup) ; First code + (modify-frame-parameters orig-frame (list (cons 'foreground-color orig-bg))) ; Undo code + nil) ; Last code + +;; Bind this, not `icicle-Info-index', to `i' in Info mode, +;; so plain `Info-index' will be used when not also in Icicle mode. +;;;###autoload +(defun icicle-Info-index-cmd () ; Bound to `i' in Info mode. + "If in Icicle mode, run `icicle-Info-index'; else, run `Info-index'. +Note: In Emacs versions prior to version 22, this runs `Info-index'." + (interactive) + (call-interactively (if icicle-mode 'icicle-Info-index 'Info-index))) + +;;;###autoload +(defun icicle-Info-index () + "Like `Info-index', but you can use Icicles keys `C-RET', `C-up' etc." + (interactive) + (when (and (boundp 'Info-current-file) (equal Info-current-file "dir")) + (error "The Info directory node has no index; use `m' to select a manual")) + (let ((info-buf (current-buffer)) + (info-window (selected-window)) + (icicle-candidate-action-fn 'icicle-Info-index-action) + (C-x-m (lookup-key minibuffer-local-completion-map "\C-xm"))) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-info-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-info-other-window)) + (unwind-protect + (call-interactively (if (> emacs-major-version 21) 'Info-index 'icicle-Info-index-20)) + (define-key minibuffer-local-completion-map "\C-xm" C-x-m)))) + +;; Thx to Tamas Patrovics for this Emacs 20 version. +;;;###autoload +(defun icicle-Info-index-20 () + "Like `Info-index', but you can use completion for the index topic." + (interactive) + (let* ((symb (or (and (fboundp 'symbol-nearest-point) ; Defined in `thingatpt+.el'. + (symbol-nearest-point)) + (symbol-at-point))) + (topic (and symb (symbol-name symb)))) + (Info-index "") + (let ((pattern "\\* +\\([^:]*\\):.") + (candidates ())) + (goto-char (point-min)) + (while (re-search-forward pattern nil t) (push (list (match-string 1)) candidates)) + (Info-index (completing-read "Index topic: " candidates nil t nil nil topic))))) + +;; Free vars here: `info-buf' and `info-window' are bound in `icicle-Info-index'. +(defun icicle-Info-index-action (topic) + "Completion action function for `icicle-Info-index'." + (let ((minibuf-win (selected-window))) + (set-buffer info-buf) + (select-window info-window) + (Info-index topic) + (select-window minibuf-win))) + +;; Bind this, not `icicle-Info-menu', to `m' in Info mode, +;; so plain `Info-menu' will be used when not also in Icicle mode. +;;;###autoload +(defun icicle-Info-menu-cmd () ; Bound to `m' in Info mode. + "In Icicle mode, run `icicle-Info-menu'; else, `Info-menu'." + (interactive) + (call-interactively (if icicle-mode 'icicle-Info-menu 'Info-menu))) + +;; Free vars here: `Info-menu-entry-name-re' is bound in `info.el'. +(icicle-define-command icicle-Info-menu + "Go to a menu node." ; Doc string + (lambda (m) (icicle-Info-goto-node (cdr (funcall icicle-get-alist-candidate-function m)))) ; Action + "Menu item: " icicle-candidates-alist ; `completing-read' args + nil t nil nil (save-excursion + (goto-char (point-min)) + (unless (search-forward "\n* menu:" nil t) (error "No menu in this node")) + (setq menu-eol (point)) + (and (< menu-eol opoint) + (save-excursion + (goto-char opoint) (end-of-line) + (and (re-search-backward (concat "\n\\* +\\(" + (if (boundp 'Info-menu-entry-name-re) + Info-menu-entry-name-re + "[^:\t\n]*") + "\\):") + menu-eol t) + (match-string-no-properties 1))))) + nil + ((opoint (point)) ; Bindings + (completion-ignore-case t) + (case-fold-search t) + (icicle-sort-comparer nil) + (icicle-whole-candidate-as-text-prop-p t) + (Info-complete-menu-buffer (current-buffer)) + (icicle-candidates-alist (mapcar #'(lambda (m) (cons m (Info-extract-menu-item m))) + (reverse + (all-completions "" 'Info-complete-menu-item)))) + menu-eol)) + +;; Bind this, not `icicle-Info-goto-node', to `g' in Info mode, +;; so plain `Info-goto-node' will be used when not also in Icicle mode. +;;;###autoload +(defun icicle-Info-goto-node-cmd () ; Bound to `g' in Info mode. + "In Icicle mode, run `icicle-Info-goto-node'; else, `Info-goto-node'." + (interactive) + (call-interactively (if icicle-mode 'icicle-Info-goto-node 'Info-goto-node))) + +;;;###autoload +(defun icicle-Info-goto-node (nodename &optional arg) + "Go to Info node named NODENAME. +NODENAME has the form NODE or (FILE)NODE-IN-FILE, where: + NODE names a node in the current Info file or one of its subfiles. + FILE names an Info file containing node NODE-IN-FILE. +Completion is available for node names in the current Info file. + +With a prefix argument: + + * Plain `C-u' means prepend the current Info file name (manual name) + to each node name. For example: `(emacs)Paragraphs' instead of + just `Paragraphs'. + + * A negative numeric prefix arg (e.g. `C--') means present completion + candidates in book order, and limit the candidates to the current + node and the rest of the book following it. In this case, the + first candidate is `..', which means go up. + + * A negative numeric prefix arg (e.g. `C-1') means show the target + node in a new Info buffer (not available prior to Emacs 21). + (This applies only to the final completion choice, not to + intermediate candidate actions using, e.g., `C-RET'.) + +In Lisp code, if optional argument ARG is a string, then show the node +in a new Info buffer named `*info-ARG*'. + +With no prefix argument, or with a non-negative prefix arg, you can +use `C-,' to choose how to sort completion candidates. By default, +they are sorted alphabetically. + +Input-candidate completion and cycling are available. While cycling, +these keys with prefix `C-' are active: + +`C-mouse-2', `C-RET' - Go to current completion candidate (node) +`C-down' - Go to next prefix-completion candidate +`C-up' - Go to previous prefix-completion candidate +`C-next' - Go to next apropos-completion candidate +`C-prior' - Go to previous apropos-completion candidate + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or +`C-g' to quit. + +This is an Icicles command - see command `icicle-mode'." + (interactive + (let* ((info-buf (current-buffer)) + (info-window (selected-window)) + (icicle-candidate-action-fn 'icicle-Info-goto-node-action) + (icicle-Info-only-rest-of-book-p (< (prefix-numeric-value current-prefix-arg) 0)) + (icicle-sort-orders-alist (cons '("in book order" . icicle-Info-book-order-p) + icicle-sort-orders-alist)) + (icicle-sort-comparer (if icicle-Info-only-rest-of-book-p + #'icicle-Info-book-order-p + icicle-sort-comparer))) + (list (icicle-Info-read-node-name "Go to node: " (consp current-prefix-arg)) + current-prefix-arg))) + (icicle-Info-goto-node-1 nodename arg)) + +(defun icicle-Info-goto-node-1 (nodename &optional arg) + "Same as `Info-goto-node', but go up for `..' pseudo-node." + (if (and (string= nodename "..") (Info-check-pointer "up")) + (Info-up) + (if (> emacs-major-version 20) + (Info-goto-node nodename (and (not icicle-Info-only-rest-of-book-p) arg)) + (Info-goto-node nodename)))) + +(defun icicle-Info-read-node-name (prompt &optional include-file-p) + "Read a node name, prompting with PROMPT. +Non-nil INCLUDE-FILE-P means include current Info file in the name. +You can use `C-x m' during completion to access Info bookmarks, if you + use library `bookmark+.el'." + (let ((C-x-m (lookup-key minibuffer-local-completion-map "\C-xm"))) + (when (and (require 'bookmark+ nil t) (fboundp 'icicle-bookmark-info-other-window)) + (define-key minibuffer-local-completion-map "\C-xm" 'icicle-bookmark-info-other-window)) + (unwind-protect + (let* ((completion-ignore-case t) + (Info-read-node-completion-table (icicle-Info-build-node-completions include-file-p)) + (nodename (completing-read prompt 'Info-read-node-name-1 + nil nil))) + (if (equal nodename "") (icicle-Info-read-node-name prompt) nodename)) + (define-key minibuffer-local-completion-map "\C-xm" C-x-m)))) + +(defun icicle-Info-build-node-completions (&optional include-file-p) + "Build completions list for Info nodes. +This takes `icicle-Info-only-rest-of-book-p' into account. +Non-nil INCLUDE-FILE-P means include current Info file in the name." + (icicle-highlight-lighter) + (if (or (not icicle-Info-only-rest-of-book-p) (string= Info-current-node "Top")) + (icicle-Info-build-node-completions-1 include-file-p) + (reverse (cons '("..") + (member (list Info-current-node) + (reverse (icicle-Info-build-node-completions-1 include-file-p))))))) + +(defun icicle-Info-build-node-completions-1 (&optional include-file-p) + "Helper function for `icicle-Info-build-node-completions'. +Use `Info-build-node-completions' to build node list for completion. +Non-nil INCLUDE-FILE-P means include current Info file in the name. +Remove pseudo-node `*'. (This just fixes a bug in Emacs 21 and 22.1.)" + (let ((comps (Info-build-node-completions))) + (when (equal (car comps) '("*")) (setq comps (cdr comps))) + (if include-file-p + (let ((file (concat "(" (cond ((stringp Info-current-file) + (replace-regexp-in-string + "%" "%%" (file-name-nondirectory Info-current-file))) + (Info-current-file (format "*%S*" Info-current-file)) + (t "")) + ")"))) + (mapcar #'(lambda (node) (cons (concat file (car node)) (cdr node))) comps)) + comps))) + +;; Free vars here: +;; `info-buf' and `info-window' are bound in `icicle-Info-goto-node'. +;; `Info-read-node-completion-table' is bound in `info.el'. +(defun icicle-Info-goto-node-action (node) + "Completion action function for `icicle-Info-goto-node'." + (set-buffer info-buf) + (select-window info-window) + (icicle-Info-goto-node-1 node) + (when icicle-Info-only-rest-of-book-p + (setq Info-read-node-completion-table (icicle-Info-build-node-completions) + icicle-current-input "") + (icicle-complete-again-update) + (if (and (string= Info-current-node "Top") Info-history) + (let* ((hist Info-history) + (last (car (cdr (car hist))))) + (while (string= "Top" (car (cdr (car hist)))) (pop hist)) + (setq icicle-candidate-nb + (1- (length (reverse (member (list (car (cdr (car hist)))) + (icicle-Info-build-node-completions-1))))))) + (setq icicle-candidate-nb 1)) ; Skip `..'. + + ;; $$$$$$ Maybe factor this out. Same thing in several places. However, here we don't do + ;; `icicle-maybe-sort-and-strip-candidates' at beginning of first clause. + (cond ((and icicle-completion-candidates (cdr icicle-completion-candidates)) ; > 1 left. + (message "Displaying completion candidates...") + (save-selected-window (icicle-display-candidates-in-Completions)) + (with-current-buffer "*Completions*" + (goto-char (icicle-start-of-candidates-in-Completions)) + (icicle-move-to-next-completion + (mod icicle-candidate-nb (length icicle-completion-candidates))) + (set-window-point (get-buffer-window "*Completions*" 0) (point)) + (setq icicle-last-completion-candidate (icicle-current-completion-in-Completions)) + (set-buffer-modified-p nil))) + (icicle-completion-candidates ; Single candidate left + (save-selected-window (icicle-remove-Completions-window)) + (let ((completion (icicle-transform-multi-completion + (car icicle-completion-candidates)))) + (select-window (active-minibuffer-window)) + (with-current-buffer (window-buffer) ; Need if *Completions* redirected to minibuffer. + (goto-char (icicle-minibuffer-prompt-end)) + (icicle-clear-minibuffer) + (insert (if (and (icicle-file-name-input-p) insert-default-directory + (or (not (member completion icicle-extra-candidates)) + icicle-extra-candidates-dir-insert-p)) + (icicle-file-name-directory-w-default icicle-current-input) + "") + completion)))) + (t ; No candidates left + (select-window (active-minibuffer-window)) + (with-current-buffer (window-buffer) ; Needed if *Completions* redirected to minibuffer. + (goto-char (icicle-minibuffer-prompt-end)) + (icicle-clear-minibuffer))))) + (select-window (active-minibuffer-window))) + +(defun icicle-Info-book-order-p (s1 s2) + "Non-nil if Info node S1 comes before node S2 in the book." + t) ; This just reverses the default order, which is reversed. + +(when (> emacs-major-version 21) + (defun icicle-Info-virtual-book (nodeset) + "Open Info on a virtual book of saved Info nodes. +You need library `info+.el' to use this command. +With a prefix arg, you are prompted to choose a persistent saved + completion set from `icicle-saved-completion-sets'. The set you + choose should be a set of saved Info node names. +With no prefix arg, use `icicle-saved-completion-candidates', which + should be a set of Info node names. If that is empty, then use + `Info-saved-nodes'. +Non-interactively, argument NODESET is a list of Info node names." + (interactive + (progn (unless (and (require 'info+ nil t) (fboundp 'Info-virtual-book)) + (error "You need library `info+.el' for this command")) + (list (if (not current-prefix-arg) + "Virtual Book" + (save-selected-window + (completing-read "Saved Info node set: " icicle-saved-completion-sets nil t nil + 'icicle-completion-set-history)))))) + (let ((nodes (and (consp nodeset) nodeset))) ; (), if interactive - NODESET is a string then. + (when (interactive-p) + (if (not current-prefix-arg) + (setq nodes icicle-saved-completion-candidates) + (let ((file-name (cdr (assoc nodeset icicle-saved-completion-sets)))) + (unless (icicle-file-readable-p file-name) + (error "Cannot read cache file `%s'" file-name)) + (let ((list-buf (find-file-noselect file-name 'nowarn 'raw))) + (unwind-protect + (condition-case icicle-Info-virtual-book + (when (listp (setq nodes (read list-buf))) + (message "Set `%s' read from file `%s'" nodeset file-name)) + (error (error "Bad cache file. %s" + (error-message-string icicle-Info-virtual-book)))) + (kill-buffer list-buf)) + (unless (consp nodes) (error "Bad data in cache file `%s'" file-name)))))) + (unless nodes (setq nodes Info-saved-nodes)) ; In `info+.el'. + (unless (and nodes (stringp (car nodes))) (error "No saved Info nodes")) ; Minimal check. + (unless (stringp nodeset) (setq nodeset "Virtual Book")) ; Non-interactive - NODESET is a list. + (Info-virtual-book nodeset nodes)))) + +;;;###autoload +(icicle-define-command icicle-insert-thesaurus-entry ; Command name + "Insert an entry from a thesaurus. +Library `synonyms.el' is needed for this. If you have never used +command `synonyms' before, then the first use of +`icicle-insert-thesaurus-entry' will take a while, because it will +build a cache file of synonyms that are used for completion. See +`synonyms.el'. + +Remember that you can use `\\\ +\\[icicle-toggle-incremental-completion] to toggle incremental completion." ; Doc string + icicle-insert-thesaurus-entry-cand-fn ; Action function + "Thesaurus entry to match: " synonyms-obarray ; `completing-read' args + nil nil nil 'icicle-dictionary-history nil nil + ((icicle-track-pt (point))) ; Bindings + (progn ; First code + (unless (or (boundp 'synonyms-obarray) (require 'synonyms nil t)) + (error "You must first load library `synonyms.el'")) + (synonyms-ensure-synonyms-read-from-cache)) + (when (window-live-p orig-window) ; Undo code + (select-window orig-window) + (select-frame-set-input-focus (selected-frame)) + (goto-char icicle-track-pt)) + (when (window-live-p orig-window) ; Last code + (select-window orig-window) + (select-frame-set-input-focus (selected-frame)) + (goto-char icicle-track-pt))) + +;; Free vars here: `orig-buff' is bound in `icicle-insert-thesaurus-entry'. +(defun icicle-insert-thesaurus-entry-cand-fn (string) + "Action function for `icicle-insert-thesaurus-entry'. +Insert STRING, followed by a space, at position TRACK-PT of buffer +ORIG-BUFF." + (set-buffer orig-buff) + (goto-char icicle-track-pt) + (insert string " ") + (setq icicle-track-pt (point)) + (with-current-buffer (window-buffer (minibuffer-window)) (icicle-clear-minibuffer)) + (save-selected-window (icicle-remove-Completions-window))) + +;;;###autoload +(defun icicle-complete-thesaurus-entry (word) ; Bound to `C-c /' in Icicle mode. + "Complete WORD to an entry from a thesaurus. +The default value of WORD is the word at the cursor. +Library `synonyms.el' is needed for this. If you have never used +command `synonyms' before, then the first use of +`icicle-insert-thesaurus-entry' will take a while, because it will +build a cache file of synonyms that are used for completion. See +`synonyms.el'." + (interactive (list (word-at-point))) + (unless word (error "No word at point to complete")) + (unless (or (boundp 'synonyms-obarray) (require 'synonyms nil t)) + (error "You must first load library `synonyms.el'")) + (synonyms-ensure-synonyms-read-from-cache) + (when (and (looking-at "\\b") (not (looking-at "\\s-"))) (forward-word 1)) + (delete-region (progn (forward-word -1) (point)) (progn (forward-word 1) (point))) + (insert (completing-read "Thesaurus entry to match: " synonyms-obarray + nil nil word 'icicle-dictionary-history word)) + (unless (looking-at "\\s-") (insert " "))) + +;;;###autoload +(icicle-define-command icicle-where-is ; Command name + "Show keyboard/menu/mouse sequences that invoke specified command. +This is a multi-command version of `where-is'. + +With no prefix argument, only commands actually bound to keys are +completion candidates. With a prefix argument, all commands are +candidates. + +With a plain (non-numeric) prefix argument, `C-u', insert the message +in the current buffer. + +By default, Icicle mode remaps all key sequences that are normally +bound to `where-is' to `icicle-where-is'. If you do not want this +remapping, then customize option `icicle-top-level-key-bindings'." ; Doc string + (lambda (x) (let ((symb (intern-soft x))) ; Action function + (where-is symb (and pref-arg (consp pref-arg))))) + "Where is command: " obarray ; `completing-read' args + (if pref-arg + 'commandp + #'(lambda (c) + (with-current-buffer orig-buff + (and (commandp c) (where-is-internal c overriding-local-map 'non-ascii))))) + t nil nil (let ((fn (or (and (fboundp 'symbol-nearest-point) (symbol-nearest-point)) + (function-called-at-point)))) + (and fn (symbol-name fn))) + t + ((pref-arg current-prefix-arg) ; Bindings + (icicle-candidate-help-fn + #'(lambda (c) + (with-current-buffer orig-buff + (let* ((keys (where-is-internal (intern-soft c) overriding-local-map)) + (keys1 (mapconcat 'key-description keys ", "))) + (message (if (string= "" keys1) + (format "`%s' is not on any key" c) + (format "`%s' is on `%s'" c keys1))) + (sit-for 3))))) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "command"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "command"))))) + +;;;###autoload +(icicle-define-command icicle-describe-option-of-type ; Bound to `C-h C-o'. Command name + "Describe a user option that was defined with a given `defcustom' type. +Enter patterns for the OPTION name and TYPE definition in the +minibuffer, separated by `icicle-list-join-string', which is \"^G^J\", +by default. (`^G' here means the Control-g character, input using +`C-h C-g'. Likewise, for `^J'.) + +OPTION is a regexp that is matched against option names. + +Depending on the prefix arg, TYPE is interpreted as either of these: + + - a regexp to match against the option type + + - a definition acceptable for `defcustom' :type, or its first symbol, + for example, (choice (integer) (regexp)) or `choice' + +In the second case, depending on the prefix arg, TYPE can be matched +against the option type, or it can be matched against either the +option type or one of its subtypes. + +In the second case also, depending on the prefix arg, if TYPE does not +match some option's type, that option might still be a candidate, if +its current value satisfies TYPE. + +In sum, the prefix arg determines the type-matching behavior, as +follows: + + - None: OPTION is defined with TYPE or a subtype of TYPE. + TYPE is a regexp. + + - `C-u': OPTION is defined with TYPE or a subtype of TYPE, + or its current value is compatible with TYPE. + TYPE is a type definition or its first symbol. + + - Negative: OPTION is defined with TYPE (exact match). + TYPE is a regexp. + + - Positive: OPTION is defined with TYPE, + or its current value is compatible with TYPE. + TYPE is a type definition or its first symbol. + + - Zero: OPTION is defined with TYPE or a subtype of TYPE. + TYPE is a type definition or its first symbol. + + - `C-u C-u': OPTION is defined with TYPE (exact match). + TYPE is a type definition or its first symbol. + +You can change these prefix-arg key sequences by customizing option +`icicle-option-type-prefix-arg-list'. For example, if you tend to use +the matching defined here for `C-u', you might want to make that the +default behavior (no prefix arg). You can assign any of the six +behaviors to any of the prefix-arg keys. + +If TYPE is nil, then *all* options that match OPTION are candidates. + +Note that options defined in libraries that have not been loaded can +be candidates, but their type will appear as nil, since it is not +known before loading the option definition. + +You can match your input against the option name or the type +definition or both. Use `C-M-j' (equivalent here to `C-q C-g C-j') to +input the default separator. + +For example, to match all Icicles options whose type matches `string' +\(according to the prefix arg), use `S-TAB' with this input: + +icicle.*^G +string$ + +If you instead want all Icicles options whose type definition contains +`string', as in (repeat string), then use this: + +icicle.*^G +\[^^G]*string + +Here, `[^^G]' matches any character except ^G, which includes newline. +If you use `.' here instead of `[^^G]', then only the first lines of +type definitions are searched for `string', because `.' matches any +character except a newline. (The first `^' in `[^^G]' is a circumflex +character. The second `^' is part of `^G', the printed representation +of a Control-g character.) + +Remember that you can use `\\\ +\\[icicle-toggle-incremental-completion] to toggle incremental completion." ; Doc string + icicle-describe-opt-action ; Action function + prompt ; `completing-read' args + 'icicle-describe-opt-of-type-complete nil nil nil nil nil nil + ((prompt "OPTION `C-M-j' TYPE (`RET' when done): ") ; Bindings + (icicle-candidate-properties-alist '((1 (face icicle-candidate-part)))) + ;; Bind `icicle-apropos-complete-match-fn' to nil to prevent automatic input matching + ;; in `icicle-unsorted-apropos-candidates' etc., because `icicle-describe-opt-of-type-complete' + ;; does everything. + (icicle-apropos-complete-match-fn nil) + (icicle-candidate-help-fn 'icicle-describe-opt-action) + ;; $$$ (icicle-highlight-input-completion-failure nil) + (pref-arg current-prefix-arg)) + (progn (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + (icicle-highlight-lighter) + (message "Gathering user options and their types..."))) + +(defun icicle-describe-opt-action (opt+type) + "Action function for `icicle-describe-option-of-type'." + (let ((icicle-list-use-nth-parts '(1))) + (describe-variable (intern (icicle-transform-multi-completion opt+type))))) + +;; Free var here: `pref-arg' - it is bound in `icicle-describe-option-of-type'. +(defun icicle-describe-opt-of-type-complete (strg pred completion-mode) + "Completion function for `icicle-describe-option-of-type'. +This is used as the value of `minibuffer-completion-table'." + (setq strg icicle-current-input) + ;; Parse strg into its option part and its type part: OPS and TPS. + ;; Make raw alist of all options and their types: ((a . ta) (b . tb)...). + (let* ((num-prefix (prefix-numeric-value pref-arg)) + (mode (cond ((not pref-arg) ; No prefix arg + (nth 4 icicle-option-type-prefix-arg-list)) + ((and (consp pref-arg) (= 16 num-prefix)) ; C-u C-u + (nth 0 icicle-option-type-prefix-arg-list)) + ((consp pref-arg) (nth 2 icicle-option-type-prefix-arg-list)) ; C-u + ((zerop num-prefix) (nth 1 icicle-option-type-prefix-arg-list)) ; C-0 + ((wholenump num-prefix) ; C-9 + (nth 3 icicle-option-type-prefix-arg-list)) + (t (nth 5 icicle-option-type-prefix-arg-list)))) ; C-- + (ops (let ((icicle-list-use-nth-parts '(1))) + (icicle-transform-multi-completion strg))) + (tps (let ((icicle-list-use-nth-parts '(2))) + (icicle-transform-multi-completion strg))) + (tp (and (not (string= "" tps)) + ;; Use regexp if no prefix arg or negative; else use sexp. + (if (memq mode '(inherit-or-regexp direct-or-regexp)) tps (read tps)))) + (result nil)) + (mapatoms + #'(lambda (symb) + (when (if (fboundp 'custom-variable-p) (custom-variable-p symb) (user-variable-p symb)) + (condition-case nil + (push (list symb (get symb 'custom-type)) result) + (error nil))))) + ;; Keep only candidates that correspond to input. + (setq result + (let ((ops-re (if (memq icicle-current-completion-mode '(nil apropos)) + ops + (concat "^" ops)))) + (icicle-remove-if-not + #'(lambda (opt+typ) + (and (string-match ops-re (symbol-name (car opt+typ))) + (or (null tp) + (icicle-var-is-of-type-p (car opt+typ) (list tp) + (case mode + ((inherit inherit-or-regexp) 'inherit) + ((direct direct-or-regexp) 'direct) + (inherit-or-value 'inherit-or-value) + (direct-or-value 'direct-or-value)))))) + result))) + ;; Change alist entries to multi-completions: "op^G^Jtp". Add short help for mode-line, tooltip. + (setq result + (mapcar #'(lambda (entry) + (let* ((opt+typ-string (concat (mapconcat #'(lambda (e) (pp-to-string e)) + entry icicle-list-join-string) + icicle-list-end-string)) + (doc ; Don't bother to look up doc, if user won't see it. + (and (or icicle-help-in-mode-line-flag + (and (boundp 'tooltip-mode) tooltip-mode)) + (documentation-property (car entry) 'variable-documentation t))) + (doc1 (and (stringp doc) + (string-match ".+$" doc) (match-string 0 doc)))) + (when doc1 (icicle-candidate-short-help doc1 opt+typ-string)) + opt+typ-string)) + result)) + (if completion-mode + result ; `all-completions', `test-completion' + (try-completion strg (mapcar #'list result) pred)))) ; `try-completion' + +;;;###autoload +(icicle-define-command icicle-vardoc ; Command name + "Choose a variable description. +Each candidate for completion is a variable name plus its +documentation. They are separated by `icicle-list-join-string' +\(\"^G^J\", by default). You can match an input regexp against the +variable name or the documentation or both. Use `C-M-j' (equivalent +here to `C-q C-g C-j') to input the default separator. + +For example, use input + +\"dired.*^G +\[^^G]*list\" + +with `S-TAB' to match all variables whose names contain \"dired\" and +whose documentation contains \"list\". Here, `[^^G]' matches any +character except ^G, which includes newline. If you use `.*' here, +instead, then only the first lines of doc strings are searched. + +With a non-negative prefix argument, use the same documentation that +was gathered the last time `icicle-vardoc' was called. Use a +non-negative prefix arg to save the time that would be needed to +gather the documentation. + +With a non-positive prefix arg, use only user variables (options) as +candidates. + +Remember that you can use `\\\ +\\[icicle-toggle-incremental-completion] to toggle incremental completion." ; Doc string + icicle-funvardoc-action ; Action function + prompt ; `completing-read' args + (let* ((num-arg (prefix-numeric-value pref-arg)) + (options-only-p (<= num-arg 0)) + (result (and pref-arg (>= num-arg 0) + (if options-only-p + icicle-vardoc-last-initial-option-cand-set + icicle-vardoc-last-initial-cand-set)))) + (unless result ; COLLECTION arg is an alist whose items are ((symb doc)). + (mapatoms #'(lambda (symb) ; Each completion candidate is a list of strings. + (when (and (boundp symb) + (or (wholenump (prefix-numeric-value pref-arg)) + (user-variable-p symb))) + (let ((doc (documentation-property symb 'variable-documentation))) + (when (icicle-non-whitespace-string-p doc) + (push (list (list (symbol-name symb) doc)) result)))))) + (if options-only-p + (setq icicle-vardoc-last-initial-option-cand-set result) + (setq icicle-vardoc-last-initial-cand-set result))) + result) + nil nil nil 'icicle-doc-history nil nil + ((prompt "VAR `C-M-j' DOC (`RET' when done): ") ; Bindings + (icicle-candidate-properties-alist '((1 (face icicle-candidate-part)))) + (icicle-candidate-help-fn 'icicle-funvardoc-action) + (pref-arg current-prefix-arg)) + (progn + (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + (icicle-highlight-lighter) + (message "Gathering variable descriptions..."))) + +(defun icicle-funvardoc-action (entry) + "Action function for `icicle-vardoc', `icicle-fundoc', `icicle-plist'." + (with-output-to-temp-buffer "*Help*" (princ entry))) + +;;;###autoload +(icicle-define-command icicle-fundoc ; Command name + "Choose a function description. +Each candidate for completion is a function name plus its +documentation. They are separated by `icicle-list-join-string' +\(\"^G^J\", by default). You can match an input regexp against the +function name or the documentation or both. Use `C-M-j' (equivalent +here to `C-q C-g C-j') to input the default separator. + +For example, use input + +\"dired.*^G +\[^^G]*file\" + +with `S-TAB' to match all functions whose names contain \"dired\" and +whose documentation contains \"file\". Here, `[^^G]' matches any +character except ^G, which includes newline. If you use `.*' here, +instead, then only the first lines of doc strings are searched. + +With a prefix argument, use the same documentation that was gathered +the last time `icicle-fundoc' was called. Use a prefix arg to save +the time that would be needed to gather the documentation. + +Remember that you can use `\\\ +\\[icicle-toggle-incremental-completion] to toggle incremental completion." ; Doc string + icicle-funvardoc-action ; Action function + prompt ; `completing-read' args + (let ((result (and pref-arg icicle-fundoc-last-initial-cand-set))) + (unless result ; COLLECTION arg is an alist whose items are ((symb doc)). + (mapatoms + #'(lambda (symb) ; Each completion candidate is a list of strings. + (when (fboundp symb) + ;; Ignore symbols that produce errors. Example: In Emacs 20, `any', which is defalias'd + ;; to `icicle-anything', raises this error: "Symbol's function definition is void: any". + ;; This is caused by the `after' advice `ad-advised-docstring' that is defined by Emacs + ;; itself for function `documentation'. It is not a problem for Emacs 22+. + (let ((doc (condition-case nil (documentation symb) (error nil)))) + (when (and doc (icicle-non-whitespace-string-p (icicle-fn-doc-minus-sig doc))) + (push (list (list (symbol-name symb) doc)) result)))))) + (setq icicle-fundoc-last-initial-cand-set result)) + result) + nil nil nil 'icicle-doc-history nil nil + ((prompt "FUNC `C-M-j' DOC (`RET' when done): ") ; Bindings + (icicle-candidate-properties-alist '((1 (face icicle-candidate-part)))) + (icicle-candidate-help-fn 'icicle-funvardoc-action) + (pref-arg current-prefix-arg)) + (progn + (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + (icicle-highlight-lighter) + (message "Gathering function descriptions..."))) + +(defun icicle-fn-doc-minus-sig (docstring) + "Return DOCSTRING minus the function signature (usage info)." + (let ((sig-p (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring))) + (if sig-p (substring docstring 0 (match-beginning 0)) docstring))) + +;;;###autoload +(icicle-define-command icicle-plist ; Command name + "Choose a symbol and its property list. +Each candidate for completion is a symbol name plus its property list +\(as a string). They are separated by `icicle-list-join-string' +\(^G^J, by default). You can match an input regexp against the symbol +name or the property list or both. Use `C-M-j' (equivalent here to +`C-q C-g C-j') to input the default separator. + +With a positive prefix argument, use the same initial set of +candidates that were gathered the last time `icicle-plist' was called. +Use a positive prefix arg to save the time that would be needed to +gather the plists. + +With a negative prefix arg, do not pretty-print each property list, in +buffers `*Help* and `*Completions*'. Generation of the complete set +of candidates is about twice as fast when not pretty-printed, but the +time to match your input and display candidates is the same, and the +match-and-display time for empty input,is much longer than the +generation time. + +The time to repeat (positive prefix arg) is the same, whether or not +candidates were pretty-printed the first time. + +Note: Plists are never pretty-printed for Emacs 20, because that seems +to cause an Emacs crash. + +Remember that you can use `\\\ +\\[icicle-toggle-incremental-completion] to toggle incremental completion." ; Doc string + icicle-funvardoc-action ; Action function + prompt ; `completing-read' args + (let ((result (and pref-arg (wholenump (prefix-numeric-value pref-arg)) + icicle-plist-last-initial-cand-set))) + (unless result ; COLLECTION arg: an alist with items ((symb plist-string)) + (mapatoms + #'(lambda (symb) ; Each completion candidate is a list of strings. + (condition-case nil ; Ignore symbols that produce errors. + (let ((plist (symbol-plist symb))) + (when plist + (push (list (list (symbol-name symb) + (if (or (< (prefix-numeric-value pref-arg) 0) + (< emacs-major-version 21)) ; Emacs 20 crash if pprint. + (format "%s" plist) + (pp-to-string plist)))) + result))) + (error nil)))) + (setq icicle-plist-last-initial-cand-set result)) + result) + nil nil nil nil nil nil + ((prompt "SYMB `C-M-j' PLIST (`RET' when done): ") ; Bindings + (icicle-candidate-properties-alist '((1 (face icicle-candidate-part)))) + (pref-arg current-prefix-arg)) + (progn + (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + (icicle-highlight-lighter) + (message "Gathering property lists..."))) + +;;;###autoload +(icicle-define-command icicle-doc ; Command name + "Choose documentation for a symbol. +Each candidate for completion is the description of a function, +variable, or face. Displays the documentation and returns the symbol. + +Each candidate for completion is a symbol name plus its type +\(FUNCTION, VARIABLE, or FACE) and its documentation. These candidate +components are separated by `icicle-list-join-string' (\"^G^J\", by +default). You can match an input regexp against the symbol name, +type, or the documentation or any combination of the three. Use +`C-M-j' (equivalent here to `C-q C-g C-j') to input the default +separator. + +With a prefix argument, use the same documentation that was gathered +the last time `icicle-doc' was called. Use a prefix arg to save the +time that would be needed to gather the documentation. + +Remember that you can use \\\ +`\\[icicle-toggle-incremental-completion]' to toggle incremental completion." ; Doc string + icicle-doc-action ; Action function: display the doc. + prompt ; `completing-read' args + (let ((result (and pref-arg icicle-doc-last-initial-cand-set)) + doc) ; Each completion candidate is a list of strings. + (unless result ; COLLECTION arg is an alist with items (doc . symb). + (mapatoms + #'(lambda (symb) + (progn + (when (and (functionp symb) ; Function's doc. + ;; Ignore symbols that produce errors. See comment for `icicle-fundoc'. + (setq doc (condition-case nil (documentation symb) (error nil))) + (setq doc (icicle-fn-doc-minus-sig doc)) + (icicle-non-whitespace-string-p doc) + (setq doc (concat doc "\n\n"))) + (push (cons (list (concat (symbol-name symb) icicle-list-join-string "FUNCTION") doc) + symb) + result)) + (when (and (boundp symb) ; Variable's doc (and keymap var's bindings if remove nil) + (setq doc (documentation-property symb 'variable-documentation)) + (icicle-non-whitespace-string-p doc)) + (when (and nil ; $$$ Remove nil to get keymaps, but it slows things down. + (fboundp 'describe-keymap) + (keymapp (symbol-value symb))) + (setq doc (concat (symbol-name symb) ":\n" doc "\n\n" ; Keymap variable's doc. + (substitute-command-keys + (concat "\\{" (symbol-name symb) "}")) + "\n\n"))) + (setq doc (concat doc "\n\n")) + (push (cons (list (concat (symbol-name symb) icicle-list-join-string "VARIABLE") doc) + symb) + result)) + (when (and (facep symb) + (setq doc (documentation-property symb 'face-documentation))) + (push (cons (list (concat (symbol-name symb) icicle-list-join-string "FACE") doc) + symb) + result))))) + (setq icicle-doc-last-initial-cand-set result)) + result) + nil nil nil 'icicle-doc-history nil nil + ((prompt "Find doc with regexp: ") ; Bindings + (icicle-candidate-properties-alist '((1 (face icicle-candidate-part)))) + (icicle-list-use-nth-parts '(1)) + (icicle-transform-function 'icicle-remove-duplicates) ; Duplicates are due to `fset's. + (icicle-candidate-help-fn 'icicle-doc-action) + (pref-arg current-prefix-arg)) + (progn + (put-text-property 0 1 'icicle-fancy-candidates t prompt) ; First code + (icicle-highlight-lighter) + (message "Gathering documentation..."))) + +(defun icicle-doc-action (entry) + "Completion action function for `icicle-doc': Display the doc." + (let ((symb (intern (icicle-transform-multi-completion entry)))) + (cond ((fboundp symb) (describe-function symb)) + ;; $$$ This works fine, but it slows things down: + ;; ((and (fboundp 'describe-keymap) (boundp symb) (keymapp (symbol-value symb))) + ;; (describe-keymap symb)) + ((and symb (boundp symb)) (describe-variable symb)) + ((facep symb) (describe-face symb))) + symb)) + +;;;###autoload +(defun icicle-non-whitespace-string-p (string) + "Return non-nil if STRING contains a non-whitespace character. +The `standard-syntax-table' definition of whitespace is used." + (interactive "s") + (let ((orig-syntable (syntax-table))) + (unwind-protect + (progn + (set-syntax-table (standard-syntax-table)) + (and (stringp string) (> (length string) 0) (string-match "\\S-" string))) + (set-syntax-table orig-syntable)))) + +;;;###autoload +(defun icicle-apropos (apropos-regexp &optional do-all) + "Like `apropos', but lets you see the list of matches (with `S-TAB'). +Function names are highlighted using face `icicle-special-candidate'." + (interactive + (list + (unwind-protect + (progn + (mapatoms #'(lambda (symb) (when (fboundp symb) (put symb 'icicle-special-candidate t)))) + (let ((icicle-fancy-candidates-p t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "symbol"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "symbol")))) + (completing-read "Apropos symbol (regexp or words): " obarray + nil nil nil 'regexp-history))) + (mapatoms #'(lambda (symb) (put symb 'icicle-special-candidate nil)))) + current-prefix-arg)) + (apropos apropos-regexp do-all)) + +;;;###autoload +(cond + ;; Use my versions of the `apropos*' commands, defined in `apropos-fn+var.el'. + ;; Note that unlike my versions of `apropos-option' and `apropos-command', the `icicle-' + ;; versions here do not respect `apropos-do-all': they always work with options and commands. + ((fboundp 'apropos-option) + (defun icicle-apropos-variable (pattern) + "Show variables that match PATTERN. +This includes variables that are not user options. +User options are highlighted using face `icicle-special-candidate'. +You can see the list of matches with `S-TAB'. +See `apropos-variable' for a description of PATTERN." + (interactive + (list + (unwind-protect + (progn + (mapatoms #'(lambda (symb) + (when (user-variable-p symb) (put symb 'icicle-special-candidate t)))) + (let ((icicle-fancy-candidates-p t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "variable"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "variable")))) + (completing-read + (concat "Apropos variable (regexp" (and (>= emacs-major-version 22) " or words") + "): ") obarray + #'(lambda (symbol) + (and (boundp symbol) (get symbol 'variable-documentation))) + nil nil 'regexp-history))) + (mapatoms #'(lambda (symb) (put symb 'icicle-special-candidate nil)))))) + (apropos-variable pattern)) + + (defun icicle-apropos-option (pattern) + "Show user options (variables) that match PATTERN. +You can see the list of matches with `S-TAB'. +See `apropos-option' for a description of PATTERN." + (interactive + (list (completing-read + (concat "Apropos user option (regexp" (and (>= emacs-major-version 22) " or words") + "): ") obarray 'user-variable-p nil nil 'regexp-history))) + (let ((apropos-do-all nil) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "option"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "option")))) + (apropos-option pattern))) + + (defun icicle-apropos-function (pattern) + "Show functions that match PATTERN. +This includes functions that are not commands. +Command names are highlighted using face `icicle-special-candidate'. +You can see the list of matches with `S-TAB'. +See `apropos-function' for a description of PATTERN." + (interactive + (list + (unwind-protect + (progn + (mapatoms #'(lambda (symb) + (when (commandp symb) (put symb 'icicle-special-candidate t)))) + (let ((icicle-fancy-candidates-p t) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "function"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "function")))) + (completing-read + (concat "Apropos function (regexp" (and (>= emacs-major-version 22) " or words") + "): ") obarray 'fboundp nil nil 'regexp-history))) + (mapatoms #'(lambda (symb) (put symb 'icicle-special-candidate nil)))))) + (apropos-function pattern)) + + (defun icicle-apropos-command (pattern) + "Show commands (interactively callable functions) that match PATTERN. +You can see the list of matches with `S-TAB'. +See `apropos-command' for a description of PATTERN." + (interactive + (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "command"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "command")))) + (list (completing-read + (concat "Apropos command (regexp" (and (>= emacs-major-version 22) " or words") + "): ") obarray 'commandp nil nil 'regexp-history)))) + (let ((apropos-do-all nil)) (apropos-command pattern)))) + + ;; My versions are not available. Use the vanilla Emacs versions of the `apropos...' commands. + (t + (defun icicle-apropos-variable (pattern &optional do-all) + "Show variables that match PATTERN. +You can see the list of matches with `S-TAB'. +See `apropos-variable' for a description of PATTERN. + +By default, only user options are candidates. With optional prefix +DO-ALL, or if `apropos-do-all' is non-nil, all variables are +candidates. In that case, the user-option candidates are highlighted +using face `icicle-special-candidate'." + (interactive + (list + (unwind-protect + (progn + (unless (or (boundp 'apropos-do-all) (require 'apropos nil t)) + (error "Library `apropos' not found")) + (when (or current-prefix-arg apropos-do-all) + (mapatoms #'(lambda (symb) + (when (user-variable-p symb) (put symb 'icicle-special-candidate t))))) + (let ((icicle-fancy-candidates-p (or current-prefix-arg apropos-do-all)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type (if icicle-fancy-candidates-p + "variable" + "option")))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type (if icicle-fancy-candidates-p + "variable" + "option"))))) + (completing-read + (concat "Apropos " (if (or current-prefix-arg apropos-do-all) + "variable" "user option") + " (regexp" (and (>= emacs-major-version 22) " or words") "): ") + obarray (if (or current-prefix-arg apropos-do-all) + #'(lambda (symbol) (and (boundp symbol) + (get symbol 'variable-documentation))) + 'user-variable-p) + nil nil 'regexp-history))) + (when (or current-prefix-arg apropos-do-all) + (mapatoms #'(lambda (symb) (put symb 'icicle-special-candidate nil))))) + current-prefix-arg)) + (apropos-variable pattern do-all)) + + (defun icicle-apropos-command (pattern &optional do-all var-predicate) + "Show commands (interactively callable functions) that match PATTERN. +You can see the list of matches with `S-TAB'. + +See `apropos-command' for a description of PATTERN. + +With \\[universal-argument] prefix, or if `apropos-do-all' is non-nil, +also show noninteractive functions. In that case, the command +candidates are highlighted using face `icicle-special-candidate'. + +If VAR-PREDICATE is non-nil, show only variables, and only those that +satisfy the predicate VAR-PREDICATE." + (interactive + (list + (unwind-protect + (progn + (unless (boundp 'apropos-do-all) + (unless (require 'apropos nil t) (error "Library `apropos' not found"))) + (when (or current-prefix-arg apropos-do-all) + (mapatoms #'(lambda (symb) + (when (commandp symb) (put symb 'icicle-special-candidate t))))) + (let ((icicle-fancy-candidates-p (or current-prefix-arg apropos-do-all)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type (if icicle-fancy-candidates-p + "function" + "command")))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type (if icicle-fancy-candidates-p + "function" + "command"))))) + (completing-read + (concat "Apropos " (if (or current-prefix-arg apropos-do-all) + "command or function" "command") + "(regexp" (and (>= emacs-major-version 22) " or words") "): ") + obarray (if current-prefix-arg 'fboundp 'commandp) nil nil 'regexp-history))) + (when (or current-prefix-arg apropos-do-all) + (mapatoms #'(lambda (symb) (put symb 'icicle-special-candidate nil))))) + current-prefix-arg)) + (apropos-command pattern do-all var-predicate)))) + +;;;###autoload +(defun icicle-apropos-zippy (regexp) + "Show all Zippy quotes matching the regular-expression input REGEXP. +Return the list of matches." + (interactive (progn (unless (boundp 'yow-file) + (unless (require 'yow nil t) (error "Library `yow' not found"))) + (cookie yow-file yow-load-message yow-after-load-message) + (let* ((case-fold-search t) + (cookie-table-symbol (intern yow-file cookie-cache)) + (string-table (symbol-value cookie-table-symbol)) + (table (nreverse (mapcar #'list string-table)))) + (list (completing-read "Apropos Zippy (regexp): " table + nil nil nil 'regexp-history))))) + (let ((matches (apropos-zippy icicle-current-input))) + (when (interactive-p) + (with-output-to-temp-buffer "*Zippy Apropos*" + (while matches + (princ (car matches)) + (setq matches (cdr matches)) + (and matches (princ "\n\n"))))) + matches)) ; Return matching Zippyisms. + +(defalias 'icicle-map 'icicle-apply) +;;;###autoload +(defun icicle-apply (alist fn &optional nomsg predicate initial-input hist def inherit-input-method) + "Selectively apply a function to elements in an alist. +Argument ALIST is an alist such as can be used as the COLLECTION +argument for Icicles `completing-read'. Its elements can represent +multi-completions, for example. Interactively, COLLECTION is a +variable (a symbol) whose value is an alist. + +Argument FN is a function. + +Optional argument NOMSG non-nil means do not display an informative +message each time FN is applied. If nil, then a message shows the key +of the alist element that FN is applied to and the result of the +application. + +The remaining arguments are optional. They are the arguments +PREDICATE, INITIAL-INPUT, HIST, DEF, and INHERIT-INPUT-METHOD for +`completing-read' (that is, all of the `completing-read' args other +than PROMPT, COLLECTION, and REQUIRE-MATCH). During `icicle-apply' +completion, a match is required (REQUIRE-MATCH is t). + +Interactively, you are prompted for both arguments. Completion is +available for each. The completion list for ALIST candidates is the +set of variables whose value is a cons. With no prefix argument, the +names of these variables must end with \"alist\". With a prefix +argument, the first car of each variable value must itself be a cons. + +After choosing the ALIST and FN, you are prompted to choose one or +more keys of the alist elements, and FN is applied to each element +that has a key that you choose. Multi-command completion is available +for choosing these candidates: you can apply FN to any number of +elements, any number of times. + +Examples: If ALIST is `auto-mode-alist' and FN is `cdr', then the +completion candidates are the keys of the alist, and the result of +applying FN to an alist element is simply the value of that key. If +you choose, for example, candidate \"\\.el\\'\", then the result is +`cdr' applied to the alist element (\"\\.el\\'\" . emacs-lisp-mode), +which is the symbol `emacs-lisp-mode'. In this case, the function +performs simple lookup. + +If FN were instead (lambda (x) (describe-function (cdr x))), then the +result of choosing candidate \"\\.el\\'\" would be to display the help +for function `emacs-lisp-mode'. + +NOTE: `icicle-apply' does not, by itself, impose any particular sort +order. Neither does it inhibit sorting. If you call this function +from Lisp code and you want it to use a certain sort order or you want +no sorting, then bind `icicle-sort-comparer' accordingly. + +During completion you can use multi-command keys. Each displays the +value of applying FN to an alist element whose key is a completion +candidate. + +`C-RET' - Act on current completion candidate only +`C-down' - Move to next prefix-completion candidate and act +`C-up' - Move to previous prefix-completion candidate and act +`C-next' - Move to next apropos-completion candidate and act +`C-prior' - Move to previous apropos-completion candidate and act +`C-!' - Act on *each* candidate (or each that is saved), in turn. +`M-!' - Act on the list of *all* candidates (or all saved). + +Note that `M-!' applies FN to the *list* of chosen alist elements, +whereas `C-!' applies FN to each chosen element, in turn. For +example, if FN is `length' and your input is `\.el', then `M-!' displays +the result of applying `length' to the list of chosen elements: + + ((\"\\.el\\'\" . emacs-lisp-mode) (\"\\.elc'\" . emacs-lisp-mode)) + +which is 2. + +When candidate action and cycling are combined (e.g. `C-next'), option +`icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or +`C-g' to quit. This is an Icicles command - see command +`icicle-mode'. + +`icicle-apply' overrides `icicle-ignore-space-prefix-flag', binding it +to nil so that candidates with initial spaces can be matched." + (interactive + (list (symbol-value + (intern + (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "variable"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "variable")))) + (completing-read "Alist (variable): " obarray + `(lambda (symb) + (and + (boundp symb) (consp (symbol-value symb)) + ,(if current-prefix-arg + '(consp (car (symbol-value symb))) + '(string-match "alist$" (symbol-name symb))))) + t nil (if (boundp 'variable-name-history) + 'variable-name-history + 'icicle-variable-name-history))))) + (read + (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "function"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "function")))) + (completing-read "Function: " obarray 'functionp nil nil + (if (boundp 'function-name-history) + 'function-name-history + 'icicle-function-name-history)))))) + + (setq icicle-candidate-entry-fn fn) ; Save in global variable - used by `icicle-apply-action'. + (let ((icicle-candidate-action-fn 'icicle-apply-action) + (icicle-all-candidates-list-action-fn 'icicle-apply-list-action) + (icicle-ignore-space-prefix-flag nil) + (icicle-apply-nomsg nomsg) + (enable-recursive-minibuffers t)) + (icicle-explore + #'(lambda () + (setq icicle-candidates-alist ; Ensure that keys of ALIST are strings or conses. + (mapcar #'(lambda (key+val) + (if (consp (car key+val)) + key+val ; Multi-completion candidate: (("aaa" "bbb") . ccc) + (cons (format "%s" (car key+val)) (cdr key+val)))) + alist))) + #'(lambda () + (let ((result (funcall icicle-candidate-entry-fn icicle-explore-final-choice-full))) + (unless nomsg + (message "Key: %s, Result: %s" (car icicle-explore-final-choice-full) result)) + result)) ; Return result. + nil nil nil "Choose an occurrence: " predicate t initial-input hist def inherit-input-method))) + +(defun icicle-apply-action (string) + "Completion action function for `icicle-apply'." + (unwind-protect + (condition-case icicle-apply-action + (progn + (icicle-highlight-candidate-in-Completions) + ;; Apply function to candidate element and display it. + (let* ((key+value (funcall icicle-get-alist-candidate-function string)) + (result (funcall icicle-candidate-entry-fn key+value))) + (unless icicle-apply-nomsg + (message "Key: %s, Result: %s" (car key+value) result))) + nil) ; Return nil for success. + (error "%s" (error-message-string icicle-apply-action))) ; Return error msg. + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)))) + +(defun icicle-apply-list-action (strings) + "Completion action list function for `icicle-apply'." + (unwind-protect + (condition-case icicle-apply-list-action + (progn ; Apply function to candidate element and display it. + (message "Result: %s" (funcall icicle-candidate-entry-fn + (mapcar icicle-get-alist-candidate-function strings))) + nil) ; Return nil for success. + (error "%s" (error-message-string icicle-apply-list-action))) ; Return error msg. + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)))) + +;;;###autoload +(defun icicle-goto-marker-or-set-mark-command (arg) ; Bound to `C-@', `C-SPC'. + "With prefix arg < 0, `icicle-goto-marker'; else `set-mark-command'. +By default, Icicle mode remaps all key sequences that are normally +bound to `set-mark-command' to +`icicle-goto-marker-or-set-mark-command'. If you do not want this +remapping, then customize option `icicle-top-level-key-bindings'." + (interactive "P") + (if (not (wholenump (prefix-numeric-value arg))) + (icicle-goto-marker) + (setq this-command 'set-mark-command) ; Let `C-SPC C-SPC' activate if not `transient-mark-mode'. + (set-mark-command arg))) + +;;;###autoload +(defun icicle-goto-global-marker-or-pop-global-mark (arg) ; Bound to `C-x C-@', `C-x C-SPC'. + "With prefix arg < 0, `icicle-goto-global-marker'; else `pop-global-mark'. +By default, Icicle mode remaps all key sequences that are normally +bound to `pop-global-mark' to +`icicle-goto-global-marker-or-pop-global-mark'. If you do not want +this remapping, then customize option +`icicle-top-level-key-bindings'." + (interactive "P") + (if (wholenump (prefix-numeric-value arg)) + (pop-global-mark) + (icicle-goto-global-marker))) + +;;;###autoload +(defun icicle-goto-marker () ; Bound to `C-- C-@', `C-- C-SPC'. + "Go to a marker in this buffer, choosing it by the line that includes it. +If `crosshairs.el' is loaded, then the target position is highlighted. + +By default, candidates are sorted in marker order, that is, with +respect to their buffer positions. Use `C-M-,' or `C-,' to change the +sort order. + +During completion you can use these keys: + +`C-RET' - Goto marker named by current completion candidate +`C-down' - Goto marker named by next prefix-completion candidate +`C-up' - Goto marker named by previous prefix-completion candidate +`C-next' - Goto marker named by next apropos-completion candidate +`C-prior' - Goto marker named by previous apropos-completion candidate +`S-delete' - Delete marker named by current completion candidate + +When candidate action and cycling are combined (e.g. `C-next'), option +`icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to choose a candidate as the final +destination, or `C-g' to quit. This is an Icicles command - see +command `icicle-mode'." + (interactive) + (let ((icicle-sort-orders-alist (cons '("by position" . icicle-cdr-lessp) + icicle-sort-orders-alist)) + (icicle-sort-comparer 'icicle-cdr-lessp)) + (icicle-goto-marker-1 mark-ring))) + +;;;###autoload +(defun icicle-goto-global-marker () ; Bound to `C-- C-x C-@', `C-- C-x C-SPC'. + "Like `icicle-goto-marker', but visits global, not local, markers. +If user option `icicle-show-multi-completion-flag' is non-nil, then +each completion candidate is annotated (prefixed) with the name of the +marker's buffer, to facilitate orientation." + (interactive) + (let ((icicle-list-nth-parts-join-string "\t") + (icicle-list-join-string "\t") + (icicle-list-end-string "") + (icicle-sort-orders-alist + (cons '("by buffer, then by position" . icicle-part-1-cdr-lessp) + icicle-sort-orders-alist)) + (icicle-sort-comparer 'icicle-part-1-cdr-lessp) + (icicle-candidate-properties-alist (and icicle-show-multi-completion-flag + '((1 (face icicle-candidate-part)))))) + (icicle-goto-marker-1 global-mark-ring))) + +(defun icicle-goto-marker-1 (ring) + "Helper function for `icicle-goto-marker', `icicle-goto-global-marker'. +RING is the marker ring to use." + (unwind-protect + (let* ((global-ring-p + (memq this-command '(icicle-goto-global-marker + icicle-goto-global-marker-or-pop-global-mark))) + (markers + (if (and (not global-ring-p) (marker-buffer (mark-marker))) + (cons (mark-marker) (icicle-markers ring)) + (icicle-markers ring))) + (icicle-delete-candidate-object + #'(lambda (cand) + (let ((mrkr+txt (funcall icicle-get-alist-candidate-function cand))) + (move-marker (cdr mrkr+txt) nil)))) + (icicle-alternative-sort-comparer nil) + (icicle-last-sort-comparer nil) + (orig-buff (current-buffer))) + (unless (consp markers) + (error (if global-ring-p "No global markers" "No markers in this buffer"))) + (cond ((cdr markers) + (icicle-apply (mapcar #'(lambda (mrkr) (icicle-marker+text mrkr global-ring-p)) + markers) + #'icicle-goto-marker-1-action + 'nomsg + (lambda (cand) + (marker-buffer (cdr cand))))) + ((= (point) (car markers)) (message "Already at marker: %d" (point))) + (t + (icicle-goto-marker-1-action (icicle-marker+text (car markers) global-ring-p))))) + (when (fboundp 'crosshairs-unhighlight) (crosshairs-unhighlight 'even-if-frame-switch)))) + +(defun icicle-goto-marker-1-action (cand) + "Action function for `icicle-goto-marker-1'." + (pop-to-buffer (marker-buffer (cdr cand))) + (select-frame-set-input-focus (selected-frame)) + (goto-char (cdr cand)) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight))) + +(defun icicle-marker+text (marker &optional globalp) + "Cons of text line that includes MARKER with MARKER itself. +If the marker is on an empty line, then text \"\" is used. +If both optional argument GLOBALP and option +`icicle-show-multi-completion-flag' are non-nil, then the text is +prefixed by MARKER's buffer name." + (with-current-buffer (marker-buffer marker) + (save-excursion + (goto-char marker) + (let ((line (let ((inhibit-field-text-motion t)) ; Just to be sure, for `end-of-line'. + (buffer-substring-no-properties (save-excursion (beginning-of-line) (point)) + (save-excursion (end-of-line) (point))))) + (buff (and globalp icicle-show-multi-completion-flag (buffer-name))) + (help (and (or icicle-help-in-mode-line-flag ; Get it only if user will see it. + (and (boundp 'tooltip-mode) tooltip-mode)) + (format "Line: %d, Char: %d" (line-number-at-pos) (point))))) + (when (string= "" line) (setq line "")) + (when help + (icicle-candidate-short-help help line) + (when (and globalp icicle-show-multi-completion-flag) + (icicle-candidate-short-help help buff))) + (if (and globalp icicle-show-multi-completion-flag) + (cons (list buff line) marker) + (cons line marker)))))) + +(defun icicle-markers (ring) + "Marks in mark RING that are in live buffers other than a minibuffer." + (let ((markers ())) + (dolist (mkr ring) + (when (and (buffer-live-p (marker-buffer mkr)) + (not (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" + (buffer-name (marker-buffer mkr))))) + (push mkr markers))) + markers)) + +;;;###autoload +(defun icicle-exchange-point-and-mark (&optional arg) ; Bound to `C-x C-x'. + "`exchange-point-and-mark' or save a region or select a saved region. +With no prefix arg, invoke `exchange-point-and-mark'. +If you use library `bookmark+.el', then you can use a prefix arg. + + * Plain `C-u': select (activate) one or more bookmarked regions. + + * Numeric prefix arg: bookmark (save) the active region using + `icicle-bookmark-cmd'. + + Arg < 0: Prompt for the bookmark name. + Arg > 0: Do not prompt for the bookmark name. Use the buffer name + plus a prefix of the region text as the bookmark name. + Arg = 0: Same as > 0, except do not overwrite any existing bookmark + with the same name. + +By default, Icicle mode remaps all key sequences that are normally +bound to `exchange-point-and-mark' to +`icicle-exchange-point-and-mark'. If you do not want this remapping, +then customize option `icicle-top-level-key-bindings'." + (interactive "P") + (let ((bplus (featurep 'bookmark+))) + (if (not arg) + (call-interactively #'exchange-point-and-mark) + (unless bplus (error "You must load library `bookmark+.el' to use a prefix arg")) + (cond ((atom arg) + (unless (and transient-mark-mode mark-active (not (eq (mark) (point)))) + (error "Cannot bookmark inactive region: you must activate it first")) + (icicle-bookmark-cmd (and (natnump (prefix-numeric-value arg)) 9))) + (t + (bookmark-maybe-load-default-file) + (unless (consp (bmkp-region-alist-only)) (error "No bookmarked regions")) + (call-interactively #'icicle-select-bookmarked-region)))))) + +;;;###autoload +(defun icicle-search-generic () ; Bound to `C-x `'. + "Run `icicle-search-command'. By default, this is `icicle-search'. +In Compilation and Grep modes, this is `icicle-compilation-search'. +In Comint, Shell, GUD, and Inferior Lisp modes, this is + `icicle-comint-search'." + (interactive) + (call-interactively icicle-search-command)) + +;;;###autoload +(defun icicle-search (beg end scan-fn-or-regexp require-match ; Bound to `C-c `'. + &optional where &rest args) + "Search for matches, with completion, cycling, and hit replacement. +Interactively, search for regexp matches. You are prompted for a +regexp, which you enter using `RET'. The search hits (matches) are +available as completion candidates. You can then use apropos +completion to filter the candidates using a different regexp, which +you can change dynamically (as always). You can replace individual +matches with another string, as in `query-replace' or +`query-replace-regexp'. By default, candidates appear in order of +buffer occurrence, but you can sort them in various ways. + +Non-interactively, search can be for regexp matches or any other kind +of matches. Argument SCAN-FN-OR-REGEXP is the regexp to match, or it +is a function that defines an alist of buffer zones to search. You +can navigate among the matching buffer zones (defined either as regexp +matches or via function), called search \"contexts\", and you can +match another regexp against the text in a search context. See the +end of this description for information about the other arguments. + +If the search-context regexp contains regexp subgroups, that is, +subexpressions of the form `\(...\)', then you are prompted for the +subgroup to use to define the search contexts. Subgroup 0 means the +context is whatever matches the whole regexp. Subgroup 1 means the +context is whatever matches the first subgroup, and so on. The +subgroup number is the number of occurrences of `\(', starting at the +beginning of the regexp. + +You can further limit the set of search contexts by setting user +option `icicle-search-context-match-predicate' to a predicate that +takes a search-context (string) argument. Only contexts that satisfy +the predicate are used. For example, if the predicate is (lambda (x) +\(commandp (intern-soft x))), then only contexts that name commands +are kept. + +Search respects `icicle-regexp-quote-flag' and +`icicle-search-whole-word-flag'. You can toggle these during search, +by using `C-`' and `M-q', respectively. If `icicle-regexp-quote-flag' +is non-nil, then regexp special characters are quoted, so that they +become non-special. If `icicle-search-whole-word-flag' is non-nil, +then whole-word searching is done. During word search, all characters +in the search string you type are treated as if they were word +constituents: the search string is matched literally, but only at word +boundaries. (You can also use `\\[icicle-search-word]' to perform +word search.) + + +Optional Behaviors: Prefix Argument +----------------------------------- + +By default, search only the current buffer. Search the active region, +or, if there is none, then search the entire buffer. + +With a prefix argument, you can search multiple buffers, files, or +bookmarks, as follows: + +- With a plain prefix arg (`C-u'), search bookmarks. This is the +same as command `icicle-search-bookmarks-together'. (To search +bookmarks one at a time instead of together, use multi-command +`icicle-search-bookmark'.) + +- With a non-negative numeric prefix arg, search multiple buffers +completely. You are prompted for the buffers to search - all of each +buffer is searched. Any existing buffers can be chosen. If the +prefix arg is 99, then only buffers visiting files are candidates. +This is the same as command `icicle-search-buffer'. + +- With a negative numeric prefix arg, search multiple files +completely. You are prompted for the files to search - all of each +file is searched. Any existing files in the current directory can be +chosen. This is the same as command `icicle-search-file'. + + +Navigation and Help +------------------- + +The use of completion for this command is special. It is not unusual +in this context to have multiple completion candidates that are +identical - only the positions of their occurrences in the search +buffer(s) differ. In that case, you cannot choose one simply by +completing it in the minibuffer, because the destination would be +ambiguous. That is, simply completing your input and entering the +completion with `RET' will not take you to its occurrence in the +search buffer, unless it is unique. + +Instead, choose search hits to visit using any of the candidate-action +keys: `C-RET', `C-mouse-2', `C-next', `C-prior', `C-down', and `C-up'. +The last four of these cycle among the search hits. The current +candidate in *Completions* corresponds to the current location +visited (it is not off by one, as is usually the case in Icicles). + +As always, the `C-M-' keys provide help on individual candidates: +`C-M-RET', `C-M-mouse-2', `C-M-next', `C-M-prior', `C-M-down', and +`C-M-up'. For `icicle-search', they indicate the buffer and position +of the search hit. + +You can cycle among candidates without moving to their occurrences in +the search buffer, using `next', `prior', `down', and `up' (no `C-'). + + +Highlighting +------------ + +In the search buffer (that is, where the hits are), `icicle-search' +does the following: + +- Highlights the current match (buffer zone) for the initial (context) + regexp, using face `icicle-search-main-regexp-current'. + +- Highlights the first `icicle-search-highlight-threshold' context + matches, using face `icicle-search-main-regexp-others'. + +- Highlights 1-8 context levels, within each search context. This + happens only if your initial (context) regexp has \\(...\\) groups + and option `icicle-search-highlight-context-levels-flag' is non-nil. + +- Highlights the match for your current input, using face + `icicle-search-current-input'. Highlights all such matches if + option `icicle-search-highlight-all-current-flag' is non-nil; + otherwise, highlights just the currently visited match. + You can toggle this option using `C-^'. + +If user option `icicle-search-cleanup-flag' is non-nil (the default), +then all search highlighting is removed from the search buffer when +you are finished searching. If it is nil, then you can remove this +highlighting later using command `icicle-search-highlight-cleanup'. +You can toggle `icicle-search-cleanup-flag' during Icicles search +using `C-.' in the minibuffer. + + +Search and Replace +------------------ + +You can replace the current search match by using any of the +alternative action keys: `C-S-RET', `C-S-mouse-2' (in *Completions*), +`C-S-next', `C-S-prior', `C-S-down', and `C-S-up'. You can use `M-|' +to replace all matches at once. (And remember that you can activate +the region to limit the search-and-replace space.) + + +At the first use of any of these, you are prompted for the replacement +string; it is used thereafter, or until you use `M-,' +\(`icicle-search-define-replacement') to change it (anytime). + +Unlike `query-replace', you need not visit search matches successively +or exhaustively. You can visit and replace selected matches in any +order. + +What is meant here by a \"search match\"? It can be either an entire +search context or just a part of the context that your current +minibuffer input matches. + +`C-,' toggles option `icicle-search-replace-whole-candidate-flag'. By +default, the entire current search context is replaced, that is, +whatever matches the context regexp that you entered initially using +`RET'. However, you can use `C-,' anytime during searching to toggle +between this default behavior and replacement of whatever your current +minibuffer input matches. + +Remember this: + + - If `icicle-search-replace-whole-candidate-flag' is non-nil, then + the granularity of replacement is a complete search context. In + this case, replacement behaves similarly to `query-replace-regexp'. + You can still use minibuffer input to filter the set of search + contexts, but replacement is on a whole-context basis. + + - If `icicle-search-replace-whole-candidate-flag' is nil, then you + can replace multiple input matches separately within a search + context (using `C-S-RET'). This behavior is unique to Icicles. + You cannot, however skip over one input match and replace the next + one in the same context - `C-S-RET' always replaces the first + available match. + +If `icicle-search-replace-whole-candidate-flag' is non-nil, then you +can use the navigational alternative action keys, `C-S-next', +`C-S-prior', `C-S-down', and `C-S-up', repeatedly to replace +successive search contexts. At the buffer limits, these commands +wraps around to the other buffer limit (last search context to first, +and vice versa). + +Search traversal using these go-to-next-context-and-replace keys is +always by search context, not by individual input match. This means +that you cannot use these keys to replace input matches within a +search context (except for the first such match, if +`icicle-search-replace-whole-candidate-flag' is nil). + +If your input matches multiple parts of a search context, and you want +to replace these in order, then use `C-S-RET' repeatedly. You can +traverse all matches of your input in the order they appear in the +buffer by repeating `C-S-RET' (provided the replacement text does not +also match your input - see below). At the buffer limits, repeating +`C-S-RET' wraps around too. + +`C-S-RET' always replaces the first input match in the current search +context or, if there are no matches, then the first input match in the +next context. This behavior has these important consequences: + +* If you repeat `C-S-RET' and the previous replacement no longer + matches your input, then `C-S-RET' moves on to the next input match + (which is now the first one) and replaces that. This is why you can + usually just repeat `C-S-RET' to successively replaces matches of + your input, including from one context to the next. + +* If, on the other hand, after replacement the text still matches your + input, then repeating `C-S-RET' will just replace that match. + For example, if you replace the input match `ab' by `abcd', then + repeating `C-S-RET' produces `abcd', then `abcdcd', then `abcdcd'... + +* You cannot replace an input match, skip the next match, and then + replace the following one, all in the same context. You can, + however, replace some matches and then skip (e.g. `C-next') to the + next context. + +What your input matches, hence what gets replaced if +`icicle-search-replace-whole-candidate-flag' is nil, depends on a few +Icicles options: + + - `icicle-regexp-quote-flag' determines whether to use regexp + matching or literal matching. + + - `icicle-search-highlight-all-current-flag', + `icicle-expand-input-to-common-match-flag' and + `icicle-search-replace-common-match-flag' together determine + whether to replace exactly what your input matches in the current + search hit or the expanded common match (ECM) of your input among + all search hits. If any of these options is nil, then your exact + input match is replaced; if they are all non-nil, then the ECM is + replaced. + +Finally, the replacement string can be nearly anything that is allowed +as a replacement by `query-replace-regexp'. In Emacs 22 or later, +this includes Lisp sexp evaluation via `\,' and constructs such as +`\#' and `\N' (back references). You can also use `\?', but it is not +very useful - you might as well use `M-,' instead, to change the +replacement text. + + +Using Regexps +------------- + +At any time, you can use `\\\ +\\[icicle-insert-string-from-variable]' (command +`icicle-insert-string-from-variable') to insert text (e.g. a regexp) +from a variable into the minibuffer. For example, you can search for +ends of sentences by using `C-u \\[icicle-insert-string-from-variable]' and choosing variable +`sentence-end' as the variable. And you can use +`\\[icicle-save-string-to-variable]' to save a string to a variable +for later use by `\\[icicle-insert-string-from-variable]'. + +When employed with useful regexps, `C-=' can turn `icicle-search' into +a general navigator or browser of code, mail messages, and many other +types of buffer. Imenu regexps work fine, for example - command +`icicle-imenu' simply uses `icicle-search' this way. See +`icicle-insert-string-from-variable' for more tips on inserting +regexps from variables. + + +Additional Information +---------------------- + +If user option `icicle-show-multi-completion-flag' is non-nil, then +each candidate is annotated with the name of the buffer where the +search hit occurs, to facilitate orientation. Note that even when the +value is nil, you can use `C-M-mouse-2' and so on to see the buffer +name, as well as the position of the hit in the buffer. + +Completion is lax if `icicle-show-multi-completion-flag' is non-nil; +otherwise, it is strict. + +After you visit a completion candidate, the hooks in variable +`icicle-search-hook' are run. + +`icicle-search' overrides `icicle-ignore-space-prefix-flag', binding +it to nil, so that candidates with initial spaces can be matched. + +`icicle-search' sets `icicle-search-final-choice' to the final user +choice, which might not be one of the search candidates if +REQUIRE-MATCH is nil. + + +Non-Interactive Use +------------------- + +Function `icicle-search' is not only a powerful command, it is also a +building block for creating your own Icicles search-and-replace +commands. When called non-interactively, these are the +`icicle-search' arguments: + +BEG is the beginning of the region to search; END is the end. +SCAN-FN-OR-REGEXP: Regexp or function that determines the set of + initial candidates (match zones). If a function, it is passed, as + arguments, the buffer to search, the beginning and end of the search + region in that buffer, and ARGS. +REQUIRE-MATCH is passed to `completing-read'. +Optional arg WHERE is a list of bookmarks, buffers, or files to be + searched. If nil, then search only the current buffer or region. + (To search bookmarks you must also use library `bookmark+.el'). +ARGS are arguments that are passed to function SCAN-FN-OR-REGEXP. + +Note that if SCAN-FN-OR-REGEXP is a regexp string, then function +`icicle-search-regexp-scan' is used to determine the set of match +zones. You can limit hits to regexp matches that also satisfy a +predicate, by using `(PREDICATE)' as ARGS: PREDICATE is then passed to +`icicle-search-regexp-scan' as its PREDICATE argument. + +This command is intended for use only in Icicle mode." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (setq icicle-search-context-regexp (and (stringp scan-fn-or-regexp) scan-fn-or-regexp)) + (let ((icicle-candidate-action-fn (or icicle-candidate-action-fn 'icicle-search-action)) + (icicle-candidate-help-fn 'icicle-search-help) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn 'icicle-search-replace-all-search-hits)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn 'icicle-search-replace-search-hit)) + (icicle-update-input-hook (list 'icicle-search-highlight-all-input-matches)) + (icicle-search-ecm nil) + (icicle-searching-p t) + (icicle-search-replacement nil) + (icicle-current-input "") + (icicle-list-nth-parts-join-string "\t") + (icicle-list-join-string "\t") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1)) + (icicle-sort-comparer nil) + + ;; Alternative: If we used `icicle-search-replace-cand-in-alist', then we would inhibit + ;; sorting, because we would be depending on the alist order. + ;; (icicle-inhibit-sort-p t) + + (icicle-no-match-hook icicle-no-match-hook) + (completion-ignore-case case-fold-search) + (replace-count 0)) ; Defined in `replace.el'. Used for replacement. + (add-hook 'icicle-no-match-hook (lambda () (when (overlayp icicle-search-current-overlay) + (delete-overlay icicle-search-current-overlay)))) + (setq icicle-search-final-choice + (icicle-explore #'(lambda () (icicle-search-define-candidates beg end scan-fn-or-regexp + require-match where args)) + #'icicle-search-final-act #'icicle-search-quit-or-error + #'icicle-search-quit-or-error #'icicle-search-cleanup + "Choose an occurrence: " nil require-match nil 'icicle-search-history)))) + +;; This is the same as `region-or-buffer-limits' in `misc-fns.el'. +(defun icicle-region-or-buffer-limits () + "Return the start and end of the region as a list, smallest first. +If the region is not active or is empty, then use bob and eob." + (if (or (not mark-active) (null (mark)) (= (point) (mark))) + (list (point-min) (point-max)) + (if (< (point) (mark)) (list (point) (mark)) (list (mark) (point))))) + +(defun icicle-search-read-context-regexp (&optional prompt pred init hist def i-i-m) + "Read context regexp and determine `icicle-search-context-level'. +Read the regexp using completion against previous regexp input. +The arguments are for use by `completing-read' to read the regexp. + HIST (or `regexp-history' if HIST is nil) is used for the + `completing-read' COLLECTION argument. + The REQUIRE-MATCH arg to `completing-read' is nil. + A default prompt is used if PROMPT is nil." + (setq hist (or hist 'regexp-history) + prompt (or prompt "Find (regexp): ")) + (let* ((icicle-candidate-action-fn nil) + (icicle-candidate-help-fn nil) + (regexp (icicle-completing-read-history + prompt 'regexp-history pred init def i-i-m))) + (while (string= "" regexp) + (message "Regexp cannot be empty. Try again...") (sit-for 2) + (setq regexp (icicle-completing-read-history prompt 'regexp-history pred init def i-i-m))) + (setq prompt "Subgroup to use as search context [0, 1, 2,...]: " + icicle-search-context-level (if (string-match "\\\\(" regexp) + (truncate (if (fboundp 'read-number) + (read-number prompt 0) + (read-from-minibuffer ; Hope for a number. + prompt nil nil nil nil 0))) + 0)) + regexp)) + +(defun icicle-search-where-arg () + "Return WHERE arg for `icicle-search*' commands, based on prefix arg." + (cond ((consp current-prefix-arg) + (unless (require 'bookmark+ nil t) (error "This requires library `bookmark+.el'")) + (message "Searching multiple bookmarks...") (sit-for 1) + (let ((icicle-show-Completions-initially-flag t) + (icicle-bookmark-types '(all))) + (save-selected-window (icicle-bookmark-list)))) + ((wholenump current-prefix-arg) + (message "Searching multiple buffers...") (sit-for 1) + (icicle-search-choose-buffers (= 99 (prefix-numeric-value current-prefix-arg)))) + (current-prefix-arg + (message "Searching multiple files...") (sit-for 1) + (let ((icicle-show-Completions-initially-flag t)) + (save-selected-window (icicle-file-list)))) + (t nil))) + +(defun icicle-search-choose-buffers (files-only-p) + "Choose multiple buffers to search. +FILES-ONLY-P non-nil means that only buffers visiting files are +candidates." + (let ((icicle-show-Completions-initially-flag t)) + (mapcar #'get-buffer (let ((icicle-buffer-require-match-flag 'partial-match-ok) + (current-prefix-arg files-only-p)) + (save-selected-window (icicle-buffer-list)))))) + +(defun icicle-search-read-word () + "Read a word to search for (whole-word search). +Regexp special characters within the word are escaped (quoted)." + (setq icicle-search-context-level 0) + (concat "\\b" + (regexp-quote (icicle-completing-read-history "Search for whole word: " + 'icicle-search-history)) + "\\b")) + +(defun icicle-search-final-act () + "Go to the final search hit choice, then run `icicle-search-hook'. +The hit's frame is raised and selected." + (let* ((marker (cdr icicle-explore-final-choice-full)) + (buf (marker-buffer marker))) + (unless (bufferp buf) (error "No such buffer: %s" buf)) + (pop-to-buffer buf) + (raise-frame) + (goto-char (marker-position marker)) + (select-frame-set-input-focus (selected-frame)) + (run-hooks 'icicle-search-hook))) + +;; Free vars here: `orig-pt-explore', `orig-win-explore' are bound in `icicle-explore'. +(defun icicle-search-quit-or-error () + "Return to the starting point." + (when (window-live-p orig-win-explore) + (select-window orig-win-explore) + (goto-char orig-pt-explore))) + +;; Free vars here: `orig-win-explore' is bound in `icicle-explore'. +(defun icicle-search-cleanup () + "Clean up search highlighting, if `icicle-search-highlight-cleanup'. +Select original window." + (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (when (window-live-p orig-win-explore) + (select-window orig-win-explore) + (select-frame-set-input-focus (selected-frame)))) + +(defun icicle-search-define-candidates (beg end scan-fn-or-regexp require-match where args) + "Define completion candidates for `icicle-search'. +The arguments are the same as for `icicle-search'." + (when (and icicle-regexp-quote-flag + (not icicle-search-whole-word-flag) + (stringp scan-fn-or-regexp)) + (setq scan-fn-or-regexp (regexp-quote scan-fn-or-regexp))) + (cond ((and (consp where) (bufferp (car where))) ; List of buffers - search buffers. + (dolist (buf where) + (icicle-search-define-candidates-1 buf nil nil scan-fn-or-regexp args))) + ((and (consp where) (stringp (car where)) ; List of files - search files. + (file-exists-p (car where))) + (dolist (file where) + (icicle-search-define-candidates-1 (find-file-noselect file 'nowarn) nil nil + scan-fn-or-regexp args))) + ((consp where) ; Search all bookmarked regions. + (unless (require 'bookmark+ nil t) (error "This requires library `bookmark+.el'")) + (let ((non-existent-buffers ()) + buf+beg buf beg end) + (dolist (bmk where) + (setq buf+beg (bookmark-jump-noselect bmk) + buf (car buf+beg) + beg (cdr buf+beg) + end (bmkp-get-end-position bmk)) + (if (bufferp buf) + (icicle-search-define-candidates-1 buf beg end scan-fn-or-regexp args) + (push buf non-existent-buffers))) + (when non-existent-buffers + (message "Skipping regions in non-existent buffers: `%s'" + (mapconcat #'identity (icicle-remove-duplicates non-existent-buffers) + "', `")) + (sit-for 3)))) + (t ; Search this buffer only. + (icicle-search-define-candidates-1 nil beg end scan-fn-or-regexp args))) + (unless icicle-candidates-alist (if (functionp scan-fn-or-regexp) + (error "No search hits") + (error "No search hits for `%s'" scan-fn-or-regexp)))) + +(defun icicle-search-define-candidates-1 (buffer beg end scan-fn-or-regexp args) + "Helper function for `icicle-search-define-candidates'. +BUFFER is a buffer to scan for candidates. +The other arguments are the same as for `icicle-search'." + (if (functionp scan-fn-or-regexp) + (apply scan-fn-or-regexp buffer beg end args) + (apply 'icicle-search-regexp-scan buffer beg end scan-fn-or-regexp args))) + +(defun icicle-search-regexp-scan (buffer beg end regexp &optional predicate) + "Scan BUFFER for REGEXP, pushing hits onto `icicle-candidates-alist'. +If BUFFER is nil, scan the current buffer. +If BEG and END are non-nil, scan only between positions BEG and END. +If REGEXP has subgroups, then use what the Nth subgroup matches as the + search context (hit), where N = `icicle-search-context-level'. + If N=0, then use the overall match of REGEXP as the search context. +PREDICATE is nil or a boolean function that takes these arguments: + - the search-context string + - a marker at the end of the search-context +If PREDICATE is non-nil, then push only the hits for which it holds. + +Highlight the matches in face `icicle-search-main-regexp-others'." + (setq regexp (or regexp (icicle-search-read-context-regexp))) + (let ((add-bufname-p (and buffer icicle-show-multi-completion-flag)) + (temp-list ()) + (last-beg nil)) + (unless buffer (setq buffer (current-buffer))) + (when (bufferp buffer) ; Do nothing if BUFFER is not a buffer. + (with-current-buffer buffer + (unless (and beg end) + (setq beg (point-min) + end (point-max))) + (condition-case icicle-search-regexp-scan + (save-excursion + (goto-char (setq last-beg beg)) + (while (and beg (< beg end) (not (eobp))) + (while (and (setq beg (re-search-forward regexp end t)) + (eq last-beg beg) + (not (eobp))) + (forward-char) (setq beg (1+ beg))) ; Matched again, same place. Advance 1 char. + (when beg + (unless (match-beginning icicle-search-context-level) + (error "Search context has no subgroup of level %d - try a lower number" + icicle-search-context-level)) + (let* ((hit-string (buffer-substring-no-properties + (match-beginning icicle-search-context-level) + (match-end icicle-search-context-level))) + (end-marker (copy-marker (match-end icicle-search-context-level)))) + (when (and (not (string= "" hit-string)) + (or (not predicate) + (save-match-data (funcall predicate hit-string end-marker)))) + (icicle-candidate-short-help + (concat (and add-bufname-p + (format "Buffer: `%s', " + (buffer-name (marker-buffer end-marker)))) + (format "Position: %d, Length: %d" + (marker-position end-marker) (length hit-string))) + hit-string) + ;; Add whole candidate to `temp-list'. Whole candidate is + ;; (`hit-string' . `end-marker') or ((`hit-string' BUFNAME) . `end-marker'). + (push (cons (if add-bufname-p + (list hit-string + (let ((string (copy-sequence (buffer-name)))) + (put-text-property 0 (length string) 'face + 'icicle-candidate-part string) + string)) + hit-string) + end-marker) + temp-list) + ;; Highlight search context in buffer. + (when (<= (+ (length temp-list) (length icicle-candidates-alist)) + icicle-search-highlight-threshold) + (let ((ov (make-overlay (match-beginning icicle-search-context-level) + (match-end icicle-search-context-level)))) + (push ov icicle-search-overlays) + (overlay-put ov 'priority 200) ; > ediff's 100+, < isearch-overlay's 1001. + (overlay-put ov 'face 'icicle-search-main-regexp-others)))))) + (setq last-beg beg)) + (setq icicle-candidates-alist (append icicle-candidates-alist (nreverse temp-list)))) + (quit (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup))) + (error (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (error (error-message-string icicle-search-regexp-scan)))))))) + +;; Free var here: `icicle-search-ecm' is bound in `icicle-search'. +(defun icicle-search-highlight-all-input-matches (&optional input) + "Highlight, inside each search context, what INPUT matches." + (save-excursion + ;; Update by deleting (if it exists) and then creating. + ;; If a single overlay exists, it means that the user just changed + ;; `icicle-search-highlight-threshold' to non-zero. + ;; Otherwise, it's nil or a list of overlays. + (when (overlayp icicle-search-refined-overlays) + (delete-overlay icicle-search-refined-overlays) + (setq icicle-search-refined-overlays ())) + (while icicle-search-refined-overlays + (delete-overlay (car icicle-search-refined-overlays)) + (setq icicle-search-refined-overlays (cdr icicle-search-refined-overlays)))) + (when icicle-search-highlight-all-current-flag + (setq input (or input icicle-current-input)) + (unless (or (string= "" input) (null icicle-search-overlays)) + (let ((hits ())) + (save-excursion + (dolist (ov icicle-search-overlays) + (set-buffer (overlay-buffer ov)) + (save-restriction ; Search within the current search context. + (narrow-to-region (overlay-start ov) (overlay-end ov)) + (goto-char (point-min)) + (when (condition-case nil (re-search-forward input nil 'move-to-end) (error nil)) + (push (buffer-substring-no-properties (point-min) (point-max)) hits)))) + (when (and icicle-expand-input-to-common-match-flag hits) + (setq icicle-search-ecm (icicle-expanded-common-match input hits))) + (dolist (ov icicle-search-overlays) + (set-buffer (overlay-buffer ov)) + (save-restriction ; Search within the current search context. + (narrow-to-region (overlay-start ov) (overlay-end ov)) + (when (member (buffer-substring-no-properties (point-min) (point-max)) hits) + (goto-char (point-min)) + (save-match-data + (while (condition-case nil + (re-search-forward (or icicle-search-ecm input) nil 'move-to-end) + (error nil)) + (setq ov (make-overlay (match-beginning 0) (match-end 0))) + (push ov icicle-search-refined-overlays) + (overlay-put ov 'priority 220) + (overlay-put ov 'face 'icicle-search-current-input))))))))))) + +(defun icicle-search-replace-search-hit (candidate) ; Bound to `C-S-RET' (`icicle-search'). + "Replace search hit CANDIDATE with `icicle-search-replacement'." + ;; NOTE: We allow side effects during replacement. + ;; In particular, `icicle-completion-candidates', `icicle-candidate-nb', and `icicle-last-input' + ;; can change. + + (let (;; (icicle-candidate-nb icicle-candidate-nb) + ;; (icicle-completion-candidates icicle-completion-candidates) + ;; (icicle-last-input icicle-last-input) + (icicle-last-completion-command icicle-last-completion-command) + (compl-win (get-buffer-window "*Completions*" 0))) + (unless (or icicle-candidate-nb icicle-all-candidates-action-p) + (error "No current candidate. Cycle or complete to get to a candidate")) + (unless icicle-search-replacement + (icicle-search-define-replacement) + (when (and compl-win icicle-completion-candidates) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list icicle-completion-candidates))))) + (setq icicle-candidate-nb (or icicle-candidate-nb 0)) ; Replace-all has nil, so use 0. + (funcall icicle-candidate-action-fn candidate icicle-search-replacement)) ; Call with second arg. + +(defun icicle-search-replace-all-search-hits (candidates) ; Bound to `M-|' (for `icicle-search'). + "Default alternative list action function for `icicle-search'. +CANDIDATES is a list of search-hit strings. They are all matched by +the initial regexp (context regexp)." + (let ((icicle-last-completion-command icicle-last-completion-command) + (compl-win (get-buffer-window "*Completions*" 0))) +;;; $$$$$$ These are now avoided always for all candidates, in `icicle-all-candidates-action-1'. +;;; (icicle-minibuffer-message-ok-p nil) ; Avoid delays from `icicle-msg-maybe-in-minibuffer'. +;;; (icicle-help-in-mode-line-flag nil)) ; Avoid delays for individual candidate help. + (unless icicle-search-replacement + (icicle-search-define-replacement) + (when (and compl-win icicle-completion-candidates) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list icicle-completion-candidates)))) + (dolist (cand+mrker (mapcar icicle-get-alist-candidate-function candidates)) + (icicle-search-action-1 cand+mrker icicle-search-replacement))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame))) + +(defun icicle-search-action (string &optional replace-string) ; Bound to `C-RET' (`icicle-search'). + "Default completion action function for `icicle-search'. +STRING is a search-hit string. It is matched by the initial regexp +\(context regexp). + +1. Move to the STRING occurrence in original buffer. Highlight it. +2. If `icicle-search-highlight-threshold' is zero, highlight what the + current input matches, inside the STRING occurrence. +3. If REPLACE-STRING is non-nil, replace the current match with it. + If `icicle-search-replace-whole-candidate-flag' is non-nil, replace + the entire STRING occurrence. Otherwise, replace only the part + that matches the current input. +4. Highlight the current candidate in *Completions*. + + Note: The replacement can be nearly anything allowed as a + replacement by `query-replace-regexp', including Lisp-evaluation + constructs (`\,...')." + (prog1 + (let* ((icicle-whole-candidate-as-text-prop-p t) + ;; Alternative: If we used `icicle-search-replace-cand-in-alist', then we would bind that + ;; to nil to force using the alist, because we would be performing side effects on it. + (cand+mrker (funcall icicle-get-alist-candidate-function string))) + (icicle-search-action-1 cand+mrker replace-string)) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)))) + +;; Free vars here: `orig-win-explore' is bound in `icicle-explore'. +(defun icicle-search-action-1 (cand+mrker &optional replace-string) + "Same as `icicle-search-action', but using full candidate, not string. +CAND+MRKER is a full alist completion-candidate entry, not just a +display string as in `icicle-search-action'." + (when icicle-completion-candidates + (condition-case icicle-search-action-1 + (progn + ;; Move cursor to the match in the original buffer and highlight it. + (let* ((candidate (if (consp (car-safe cand+mrker)) + (car-safe (car-safe cand+mrker)) + (car-safe cand+mrker))) + (marker (cdr-safe cand+mrker)) + (icicle-search-in-context-fn + (or icicle-search-in-context-fn 'icicle-search-in-context-default-fn))) + (unless marker (error "No such occurrence")) + (condition-case icicle-search-action-1-save-window + (save-selected-window + (when (window-live-p orig-win-explore) (select-window orig-win-explore)) + (let ((completion-ignore-case case-fold-search) + (buf (marker-buffer marker))) + (unless (bufferp buf) (error "No such buffer: %s" buf)) + (pop-to-buffer buf) + (raise-frame) + (goto-char marker) + (unless (pos-visible-in-window-p) (recenter -2)) + ;; Highlight current search context using `icicle-search-main-regexp-current'. + (icicle-place-overlay (- marker (length candidate)) marker + 'icicle-search-current-overlay + 'icicle-search-main-regexp-current + 202 buf) + (funcall icicle-search-in-context-fn cand+mrker replace-string) + (icicle-highlight-candidate-in-Completions) + (run-hooks 'icicle-search-hook))) + (error ; Ignore disappearance of `*Completions*'. + (unless (string-match "Wrong type argument: window-live-p," + (error-message-string icicle-search-action-1-save-window)) + (error (message (error-message-string icicle-search-action-1-save-window)) + (error-message-string icicle-search-action-1-save-window))))) + nil)) ; Return nil for success. + (error (message (error-message-string icicle-search-action-1)) + (error-message-string icicle-search-action-1))))) + +(defun icicle-search-in-context-default-fn (cand+mrker replace-string) + "Default value of `icicle-search-in-context-fn'." + (let ((candidate (if (consp (car-safe cand+mrker)) + (car-safe (car-safe cand+mrker)) + (car-safe cand+mrker))) + (marker (cdr-safe cand+mrker))) + ;; Highlight match and possibly replace. If replacement tried, then update the dialog state. + (when (save-excursion (save-restriction ; Search within the current search context. + (narrow-to-region (- marker (length candidate)) marker) + (icicle-search-highlight-and-maybe-replace cand+mrker replace-string))) + + ;; Update, since replacement might have changed the current candidate: + ;; Rehighlight current context, update last candidate, update candidate in minibuffer. + (if icicle-search-highlight-all-current-flag + (let ((icicle-search-highlight-all-current-flag nil)) + (icicle-search-highlight-input-matches-here)) + (let ((ov icicle-search-current-overlay)) + (save-restriction (narrow-to-region (overlay-start ov) (overlay-end ov)) + (icicle-search-highlight-input-matches-here)))) + (if (null icicle-completion-candidates) ; If have already replaced all, then no candidates. + (when (overlayp icicle-search-current-overlay) + (delete-overlay icicle-search-current-overlay)) + (let* ((cand+mrker (funcall icicle-get-alist-candidate-function + (setq icicle-last-completion-candidate + (elt icicle-completion-candidates icicle-candidate-nb)))) + (marker (cdr-safe cand+mrker))) + (with-current-buffer (marker-buffer marker) + (goto-char marker) + ;; Highlight current search context using `icicle-search-main-regexp-current'. + (icicle-place-overlay (- marker (if (consp (car cand+mrker)) + (length (caar cand+mrker)) + (length (car cand+mrker)))) + marker 'icicle-search-current-overlay + 'icicle-search-main-regexp-current 202 (current-buffer)) + (unless icicle-search-highlight-all-current-flag + (let ((ov icicle-search-current-overlay)) + (save-restriction (narrow-to-region (overlay-start ov) (overlay-end ov)) + (icicle-search-highlight-input-matches-here))))) + (save-selected-window + (select-window (minibuffer-window)) + (icicle-clear-minibuffer) + (setq icicle-nb-of-other-cycle-candidates (length icicle-completion-candidates)) + (icicle-insert-cand-in-minibuffer icicle-last-completion-candidate t) + (icicle-show-help-in-mode-line icicle-last-completion-candidate)))))) + (let ((icicle-candidate-nb icicle-candidate-nb)) + (icicle-complete-again-update))) + +;; Free var here: `icicle-search-ecm' is bound in `icicle-search'. +(defun icicle-search-highlight-and-maybe-replace (cand+mrker replace-string) + "Highlight within search context and replace using REPLACE-STRING. +If REPLACE-STRING is nil, no replacement occurs. +Arguments are the same as for `icicle-search-in-context-fn'. +Return non-nil if replacement occurred, nil otherwise." + (icicle-search-highlight-context-levels) + (icicle-search-highlight-input-matches-here) + (let ((replacement-p nil)) + (when replace-string + (setq replacement-p t) + (goto-char (point-min)) + (let ((candidate (if (consp (car-safe cand+mrker)) + (car-safe (car-safe cand+mrker)) + (car-safe cand+mrker))) + (ecm (and icicle-search-replace-common-match-flag icicle-search-ecm))) + (cond (icicle-search-replace-whole-candidate-flag + (cond ((string= candidate replace-string) ; Sanity check only. + (save-restriction (widen) (message "Replacement = candidate, and \ +current input matches candidate") (sit-for 2)) + (setq replacement-p nil)) + (t + (set-match-data (list (point-min) (point-max))) + (icicle-search-replace-match replace-string + (icicle-search-replace-fixed-case-p + icicle-search-context-regexp))))) + ((not (save-excursion (re-search-forward (or ecm icicle-current-input) nil t))) + (save-restriction (widen) + (message "Text to be replaced not found in candidate") (sit-for 2)) + (setq replacement-p nil)) + (t + (save-match-data + (let ((first-p t)) + ;; The condition order is important. Don't search unless first time (or all) + (while (and (or first-p icicle-all-candidates-action-p) + (re-search-forward (or ecm icicle-current-input) nil 'move-to-end)) + (setq first-p nil) + (icicle-search-replace-match replace-string + (icicle-search-replace-fixed-case-p + icicle-current-input))))))) + (when replacement-p + ;; Update the alist and `minibuffer-completion-table' with the new text. + + ;; An ALTERNATIVE approach would be to use `icicle-search-replace-cand-in-alist'. + ;; In that case we would: + ;; 1. Bind `icicle-whole-candidate-as-text-prop-p' to nil (in `icicle-search-action' + ;; and `icicle-search-help'). + ;; 2. Use these two lines, instead of calling `icicle-search-replace-cand-in-mct'. + ;; (icicle-search-replace-cand-in-alist cand+mrker + ;; (buffer-substring (point-min) (point-max))) + ;; (setq minibuffer-completion-table + ;; (car (icicle-mctize-all icicle-candidates-alist nil))) + ;; If we used that method (as we used to), then users could not sort the search hits. + + (icicle-search-replace-cand-in-mct cand+mrker (buffer-substring (point-min) (point-max))) + + ;; If we are replacing input matches within a search context, and there are no more matches + ;; in the current context, then this context is removed as a candidate. If the current + ;; action command is one that moves to the next or previous candidate, then we might need + ;; to adjust the current candidate number, to compensate for the removal. + ;; + ;; If the current action command is one (e.g. `C-S-next'), that moves to the next candidate + ;; to do its action, then move back one. If the current action acts on the previous + ;; candidate (e.g. `C-S-prior'), and that previous candidate is the last one, then move + ;; forward one candidate, to the first. + (when (and icicle-acting-on-next/prev + (not (save-excursion (goto-char (point-min)) + (re-search-forward icicle-current-input nil t)))) + (let ((nb-cands (1- (length icicle-completion-candidates)))) ; -1 for replaced one. + (unless (wholenump nb-cands) (setq nb-cands 0)) + (setq icicle-candidate-nb (cond ((not icicle-candidate-nb) 0) + ((eq icicle-acting-on-next/prev 'forward) + (if (zerop icicle-candidate-nb) + (1- nb-cands) + (1- icicle-candidate-nb))) + ((eq icicle-candidate-nb nb-cands) 0) + (t icicle-candidate-nb))) + (when (> icicle-candidate-nb nb-cands) (setq icicle-candidate-nb 0)) + (when (< icicle-candidate-nb 0) (setq icicle-candidate-nb nb-cands)))) + + (let ((icicle-candidate-nb icicle-candidate-nb) + (icicle-minibuffer-message-ok-p nil)) ; Inhibit no-candidates message. + (icicle-complete-again-update)) + + ;; If we are using `C-S-RET' and we are on the last candidate, then wrap to the first one. + (when (and (not icicle-acting-on-next/prev) + (or (not icicle-candidate-nb) + (>= icicle-candidate-nb (length icicle-completion-candidates)))) + (setq icicle-candidate-nb 0)) + (icicle-highlight-candidate-in-Completions) + (icicle-search-highlight-context-levels)))) + replacement-p)) ; Return indication of whether we tried to replace something. + +(defun icicle-search-replace-match (replace-string fixedcase) + "Replace current match with REPLACE-STRING, interpreting escapes. +Treat REPLACE-STRING as it would be treated by `query-replace-regexp'. +FIXEDCASE is as for `replace-match'. Non-nil means do not alter case." + (if (fboundp 'query-replace-compile-replacement) ; Emacs 22. + (let ((compiled + (save-match-data + (query-replace-compile-replacement replace-string + (not icicle-search-replace-literally-flag))))) + (condition-case icicle-search-replace-match1 + (let ((enable-recursive-minibuffers t) ; So we can read input from \?. + ;; Save and restore these, because we might read input from \?. + (icicle-last-completion-command icicle-last-completion-command) + (icicle-last-input icicle-last-input)) + (replace-match-maybe-edit + (if (consp compiled) + ;; `replace-count' is free here, bound in `icicle-search'. + (funcall (car compiled) (cdr compiled) (setq replace-count (1+ replace-count))) + compiled) + fixedcase icicle-search-replace-literally-flag nil (match-data))) + (buffer-read-only (ding) (error "Buffer is read-only")) + (error (icicle-remove-Completions-window) (error "No match for %s" replace-string)))) + (condition-case icicle-search-replace-match2 ; Emacs < 22. Try to interpret `\'. + (replace-match replace-string fixedcase icicle-search-replace-literally-flag) + (error (replace-match replace-string fixedcase t))))) ; If error, replace literally. + +(defun icicle-search-highlight-context-levels () + "Highlight context levels differently (up to 8 levels). +No such highlighting is done if any of these conditions holds: + * `icicle-search-context-level' is not 0 (search context < regexp). + * `icicle-search-highlight-context-levels-flag' is nil. + * `icicle-search-context-regexp' is nil (non-regexp searching)." + (unless (or (/= icicle-search-context-level 0) + (not icicle-search-highlight-context-levels-flag) + (not icicle-search-context-regexp)) ; E.g. text-property searching + (while icicle-search-level-overlays + (delete-overlay (car icicle-search-level-overlays)) + (setq icicle-search-level-overlays (cdr icicle-search-level-overlays))) + (save-match-data + (let ((level 1) + (max-levels (min (regexp-opt-depth icicle-search-context-regexp) 8))) + (goto-char (point-min)) + (re-search-forward icicle-search-context-regexp nil t) + (condition-case nil + (while (<= level max-levels) + (let ((ov (make-overlay (match-beginning level) (match-end level)))) + (push ov icicle-search-level-overlays) + (overlay-put ov 'priority (+ 205 level)) ; > ediff's 100+, < isearch-overlay's 1001. + (overlay-put ov 'face (intern (concat "icicle-search-context-level-" + (number-to-string level))))) + (setq level (1+ level))) + (error nil)))))) + +;; Free var here: `icicle-search-ecm' is bound in `icicle-search'. +(defun icicle-search-highlight-input-matches-here () + "Highlight all input matches in the current search context." + (unless (or (> 0 icicle-search-highlight-threshold) (string= "" icicle-current-input)) + (goto-char (point-min)) + (when (and (not icicle-search-highlight-all-current-flag) + (overlayp icicle-search-refined-overlays)) + (delete-overlay icicle-search-refined-overlays) + (setq icicle-search-refined-overlays nil)) + (unless icicle-search-highlight-all-current-flag + (while icicle-search-refined-overlays + (delete-overlay (car icicle-search-refined-overlays)) + (setq icicle-search-refined-overlays (cdr icicle-search-refined-overlays)))) + (let ((ov nil)) + (save-match-data + (while (and (not (eobp)) (re-search-forward (or icicle-search-ecm icicle-current-input) + nil 'move-to-end)) + (setq ov (make-overlay (match-beginning 0) (match-end 0))) + (push ov icicle-search-refined-overlays) + (overlay-put ov 'priority 220) ; Greater than any possible context-level priority (213). + (overlay-put ov 'face 'icicle-search-current-input)))))) + +(defun icicle-search-replace-fixed-case-p (from) + "Return non-nil if FROM should be replaced without transferring case. +FROM is a string or nil. If FROM is nil, then return nil. +Retuns non-nil if FROM is a string and one of the following holds: + * FROM is not all lowercase + * `case-replace' or `case-fold-search' is nil" + (and from (not (and case-fold-search case-replace (string= from (downcase from)))))) + +;; Not used for now - this could replace using mct. In that case, user must not be able to sort. +(defun icicle-search-replace-cand-in-alist (cand+mrker new-cand) + "In `icicle-candidates-alist', replace car of CAND+MRKER by NEW-CAND. +Replace only the first occurrence of CAND+MRKER in +`icicle-candidates-alist'. (There should be only one.)" + (let ((newlist icicle-candidates-alist)) + (catch 'icicle-search-replace-cand-in-alist + (while newlist + (when (equal (car newlist) cand+mrker) + (setcar newlist (cons new-cand (cdr-safe cand+mrker))) + (throw 'icicle-search-replace-cand-in-alist nil)) + (setq newlist (cdr newlist)))) + icicle-candidates-alist)) + +(defun icicle-search-replace-cand-in-mct (cand+mrker new-cand) + "Replace candidate in `minibuffer-completion-table'. +Update CAND+MRKER itself to use NEW-CAND (replacement string). +Any text properties on CAND+MRKER's string are preserved. +Use this only with a `minibuffer-completion-table' derived from an alist." + (let ((newlist minibuffer-completion-table)) + (catch 'icicle-search-replace-cand-in-mct + ;; CAND+MRKER: ("aa" . c) or (("aa" "bb") . c) + ;; `minibuffer-completion-table' entry: ("aa" "aa" . c) or ("aa^G^Jbb" . (("aa" "bb") . c)) + (while newlist + (when (equal (cdr (car newlist)) cand+mrker) + (let ((new-compl (if (consp (car cand+mrker)) ; New completion: "QQ" or ("QQ" "bb") + (cons new-cand (cdar cand+mrker)) + new-cand)) + (old-cand (if (consp (car cand+mrker)) (caar cand+mrker) (car cand+mrker))) + rep-cand) + (setcar newlist (icicle-mctized-full-candidate (cons new-compl (cdr-safe cand+mrker)))) + ;; NEWLIST is done. + ;; Now update CAND+MRKER to reflect the replacement but with the text properties it had. + ;; (cdar NEWLIST) is the new cand+mrker. Its car or caar is the replaced candidate. + ;; It is the first field of the multi-completion, in the latter case. + (setq rep-cand (if (consp (car cand+mrker)) (caar (cdar newlist)) (car (cdar newlist)))) + (let ((len-old (length old-cand)) + (len-rep (length rep-cand)) + (ii 0) + props) + (while (< ii len-old) + (setq props (text-properties-at ii old-cand)) + (when (<= ii len-rep) (add-text-properties ii (1+ ii) props rep-cand)) + (setq ii (1+ ii))) + (let ((last-props (text-properties-at (1- len-old) old-cand))) + (when (> len-rep len-old) + (add-text-properties len-old len-rep last-props rep-cand)))) + (if (consp (car cand+mrker)) + (setcar (car cand+mrker) rep-cand) + (setcar cand+mrker rep-cand))) + (throw 'icicle-search-replace-cand-in-mct nil)) + (setq newlist (cdr newlist)))) + minibuffer-completion-table)) + +(defun icicle-search-help (cand) + "Use as `icicle-candidate-help-fn' for `icicle-search' commands." + (icicle-msg-maybe-in-minibuffer + (let* ((icicle-whole-candidate-as-text-prop-p t) + ;; Alternative: If we used `icicle-search-replace-cand-in-alist', then we would bind that + ;; to nil to force using the alist, because we would be performing side effects on it. + (marker (cdr (funcall icicle-get-alist-candidate-function cand)))) + (concat "Buffer: `" (buffer-name (marker-buffer marker)) + (format "', Position: %d" (marker-position marker)))))) + +;;;###autoload +(defun icicle-search-keywords (beg end keywords require-match ; Bound to `C-c ^'. + &optional where &rest args) + "Search with one or more keywords, which can each be a regexp. +Text that matches *any* of the keywords is found. + +You can use completion to choose one or more previously entered +regexps (using `C-RET', `C-mouse-2', `C-next', and so on), or you can +enter new keywords (using `C-RET'). Use `RET' or `mouse-2' to choose +the last keyword. + +Keywords are interpreted as regexps. You can change to substring +completion instead, matching regexp special characters literally, by +using `C-`' during completion to toggle `icicle-regexp-quote-flag'. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the `icicle-search' +documentation." + (interactive + `(,@(icicle-region-or-buffer-limits) + ,(icicle-group-regexp (mapconcat #'icicle-group-regexp (icicle-keyword-list) "\\|")) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (icicle-search beg end keywords (not icicle-show-multi-completion-flag) where)) + +(defalias 'icicle-regexp-list 'icicle-keyword-list) +;;;###autoload +(icicle-define-command icicle-keyword-list ; Command name + "Choose a list of keywords. The list of keywords (strings) is returned. +You can choose from keywords entered previously or enter new keywords +using `C-RET'. Each keyword is a regexp. The regexps are OR'd, and +the resulting regexp is usable for `icicle-search'." ; Doc string + (lambda (name) ; Action function + (push name keywords) + (message "Added keyword `%s'" name)) + "Choose keyword (regexp) (`RET' when done): " ; `completing-read' args + (mapcar #'list (icicle-remove-duplicates regexp-history)) nil nil nil 'regexp-history nil nil + ((keywords nil) ; Bindings + (icicle-use-candidates-only-once-flag t)) + nil nil ; First code, undo code + (prog1 (setq keywords (nreverse (delete "" keywords))) ; Last code - return the list of keywords. + (when (interactive-p) (message "Keywords (regexps): %S" keywords)))) + +(defun icicle-group-regexp (regexp) + "Wrap REGEXP between regexp parens, as a regexp group." + (concat "\\(" regexp "\\)")) + +;;;###autoload +(icicle-define-command icicle-search-bookmark ; Command name + "Search bookmarked text. +If you use library `bookmark+.el', and a bookmark specifies a nonempty +region, then search only the text in that region. + +See also `icicle-search-bookmarks-together', which searches bookmarks +together instead of one at a time. + +1. Enter a context regexp, to define the possible search-hit contexts. +2. Choose a bookmark using completion. It is opened. +3. (Optional) Type some text to be matched in the search contexts. +4. Navigate to matches (search hits) using `C-next' etc. +5. Finish with that bookmark using `RET' (stay) or `C-g' (skip). +6. (Optional) Repeat steps 2-5 for other bookmarks." ; Doc string + icicle-search-bookmark-action ; Action function + prompt icicle-candidates-alist nil (not icicle-show-multi-completion-flag) ; `completing-read' args + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + (and (boundp 'bookmark-current-bookmark) bookmark-current-bookmark) nil + ((enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on disk... + (completion-ignore-case bookmark-completion-ignore-case) + (prompt "Search bookmark: ") + (regexp (icicle-search-read-context-regexp)) + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (bookmark-automatically-show-annotations nil) ; Do not show annotations + (icicle-sort-orders-alist + (append '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p)) + (and (featurep 'bookmark+) + '(("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p) + ("by last buffer or file access" (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p) + ("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by file name" (bmkp-file-alpha-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p) + ("by Info location" (bmkp-info-cp) icicle-alpha-p) + ("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p) + ("by URL" (bmkp-url-cp) icicle-alpha-p) + ("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when (and (featurep 'bookmark+) icicle-show-multi-completion-flag) + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if (featurep 'bookmark+) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)) + (icicle-msg-maybe-in-minibuffer (icicle-bookmark-help-string cand))))) + (icicle-candidates-alist + (if (not (featurep 'bookmark+)) + (mapcar #'(lambda (cand) + (list (icicle-candidate-short-help (icicle-bookmark-help-string cand) + (icicle-bookmark-propertize-candidate cand)))) + (bookmark-all-names)) ; Loads bookmarks file, defining `bookmark-alist'. + (bookmark-maybe-load-default-file) ; Loads bookmarks file, defining `bookmark-alist'. + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf (if (and buf (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + (cons `(,(icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + ,file/buf + ,@(and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (or (and (or (and (not icicle-bookmark-refresh-cache-flag) + (not (consp current-prefix-arg))) + (and icicle-bookmark-refresh-cache-flag (consp current-prefix-arg))) + bmkp-sorted-alist) + (setq bmkp-sorted-alist + (bmkp-sort-and-remove-dups bookmark-alist))))))) + (progn ; First code + (require 'bookmark) + (when (featurep 'bookmark+) + ;; Bind keys to narrow bookmark candidates by type. Lax is for multi-completion case. + (dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map)) + (define-key (symbol-value map) "\C-\M-b" 'icicle-bookmark-non-file-narrow) + (define-key (symbol-value map) "\C-\M-d" 'icicle-bookmark-dired-narrow) + (define-key (symbol-value map) "\C-\M-f" 'icicle-bookmark-file-narrow) + (define-key (symbol-value map) "\C-\M-g" 'icicle-bookmark-gnus-narrow) + (define-key (symbol-value map) "\C-\M-i" 'icicle-bookmark-info-narrow) + (define-key (symbol-value map) "\C-\M-m" 'icicle-bookmark-man-narrow) + (define-key (symbol-value map) "\C-\M-r" 'icicle-bookmark-region-narrow) + (define-key (symbol-value map) "\C-\M-u" 'icicle-bookmark-url-narrow) + (define-key (symbol-value map) "\C-\M-w" 'icicle-bookmark-w3m-narrow) + (define-key (symbol-value map) "\C-\M-@" 'icicle-bookmark-remote-file-narrow) + (define-key (symbol-value map) [(control meta ?B)] + 'icicle-bookmark-bookmark-list-narrow) ; `C-M-B' + (define-key (symbol-value map) [(control meta ?F)] + 'icicle-bookmark-local-file-narrow) ; `C-M-F' + (define-key (symbol-value map) [(control meta ?K)] + 'icicle-bookmark-desktop-narrow)))) ; `C-M-K' + (icicle-bookmark-cleanup-on-quit) ; Undo code + (icicle-bookmark-cleanup)) ; Last code + +(defun icicle-search-bookmark-action (bookmark-name) + "Action function for `icicle-search-bookmark'." + (setq bookmark-name (icicle-transform-multi-completion bookmark-name)) + (bookmark-jump-other-window bookmark-name) + (setq mark-active nil) ; Unhighlight region, so you can see search hits etc. + (let ((icicle-show-Completions-initially-flag t) + (icicle-candidate-action-fn 'icicle-search-action) + (enable-recursive-minibuffers t) + (beg + (or (and (featurep 'bookmark+) (bmkp-region-bookmark-p bookmark-name) + (bookmark-get-position bookmark-name)) + (point-min))) + (end + (or (and (featurep 'bookmark+) (bmkp-region-bookmark-p bookmark-name) + (bmkp-get-end-position bookmark-name)) + (point-max)))) + (when (= beg end) (setq beg (point-min) end (point-max))) + (icicle-search beg end regexp t)) + (with-current-buffer (window-buffer (minibuffer-window)) (icicle-erase-minibuffer))) + +;; Similar to `icicle-define-bookmark-command-1' in `icicles-cmd1.el'. Could combine them. +(defmacro icicle-define-search-bookmark-command (type &optional prompt &rest args) + "Define Icicles multi-command for searching bookmarks of type TYPE. +TYPE is a string to be used for the doc string, default prompt, and in + function names. It should be lowercase and contain no spaces. +Optional arg PROMPT is the completion prompt. +ARGS is a list of any additional arguments to be passed to the + appropriate `bmkp-TYPE-alist-only' function. + +The command defined raises an error unless library `bookmark+.el' can +be loaded." + `(icicle-define-command + ,(intern (format "icicle-search-%s-bookmark" type)) ; Command name + ,(format "Search %s bookmark text. +Like `icicle-search-bookmark', but with %s bookmarks only. +You need library `bookmark+.el' for this command." type type) ; Doc string + icicle-search-bookmark-action ; Action function + prompt1 icicle-candidates-alist nil ; `completing-read' args + (not icicle-show-multi-completion-flag) + nil (if (boundp 'bookmark-history) 'bookmark-history 'icicle-bookmark-history) + nil nil + ((IGNORED1 (unless (require 'bookmark+ nil t) ; Bindings + (error "You need library `bookmark+.el' for this \ +command"))) + (IGNORED2 (bookmark-maybe-load-default-file)) ; `bookmark-alist'. + (enable-recursive-minibuffers t) ; In case we read input, e.g. File changed on... + (completion-ignore-case bookmark-completion-ignore-case) + (prompt1 ,(or prompt (format "Search %s bookmark: " type))) + (icicle-list-use-nth-parts '(1)) + (icicle-candidate-properties-alist (if (not icicle-show-multi-completion-flag) + nil + (if (facep 'file-name-shadow) + '((2 (face file-name-shadow)) + (3 (face bookmark-menu-heading))) + '((3 (face bookmark-menu-heading)))))) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-whole-candidate-as-text-prop-p t) + (icicle-transform-before-sort-p t) + (icicle-delete-candidate-object 'icicle-bookmark-delete-action) + (regexp (icicle-search-read-context-regexp)) + (bookmark-automatically-show-annotations nil) ; Do not show annotations + (icicle-sort-orders-alist + (append + '(("in *Bookmark List* order") ; Renamed from "turned OFF'. + ("by bookmark name" . icicle-alpha-p) + ("by last bookmark access" (bmkp-bookmark-last-access-cp) icicle-alpha-p) + ("by bookmark visit frequency" (bmkp-visited-more-cp) icicle-alpha-p)) + (and (member ,type '("info" "region")) + '(("by Info location" (bmkp-info-cp) icicle-alpha-p))) + (and (member ,type '("gnus" "region")) + '(("by Gnus thread" (bmkp-gnus-cp) icicle-alpha-p))) + (and (member ,type '("url" "region")) + '(("by URL" (bmkp-url-cp) icicle-alpha-p))) + (and (not (member ,type '("bookmark-list" "desktop" "gnus" "info" "man" "url"))) + '(("by bookmark type" (bmkp-info-cp bmkp-url-cp bmkp-gnus-cp + bmkp-local-file-type-cp bmkp-handler-cp) + icicle-alpha-p))) + (and (not (member ,type '("bookmark-list" "desktop" "dired" "non-file"))) + '(("by file name" (bmkp-file-alpha-cp) icicle-alpha-p))) + (and (member ,type '("local-file" "file" "dired" "region")) + '(("by local file type" (bmkp-local-file-type-cp) icicle-alpha-p) + ("by local file size" (bmkp-local-file-size-cp) icicle-alpha-p) + ("by last local file access" (bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p) + ("by last local file update" (bmkp-local-file-updated-more-recently-cp) + icicle-alpha-p))) + (and (not (string= ,type "desktop")) + '(("by last buffer or file access" (bmkp-buffer-last-access-cp + bmkp-local-file-accessed-more-recently-cp) + icicle-alpha-p))) + (and (get-buffer "*Bookmark List*") + '(("marked before unmarked (in *Bookmark List*)" (bmkp-marked-cp) + icicle-alpha-p))) + '(("by previous use alphabetically" . icicle-historical-alphabetic-p) + ("case insensitive" . icicle-case-insensitive-string-less-p)))) + (icicle-candidate-help-fn + #'(lambda (cand) + (when icicle-show-multi-completion-flag + (setq cand (funcall icicle-get-alist-candidate-function cand)) + (setq cand (cons (caar cand) (cdr cand)))) + (if current-prefix-arg + (bmkp-describe-bookmark-internals cand) + (bmkp-describe-bookmark cand)))) + (icicle-candidates-alist + (mapcar (if icicle-show-multi-completion-flag + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let* ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk)) + (file (bookmark-get-filename bmk)) + (buf (bmkp-get-buffer-name bmk)) + (file/buf (if (and buf (equal file bmkp-non-file-filename)) + buf + file)) + (tags (bmkp-get-tags bmk))) + ;; Emacs 20 byte-compiler bug prevents using backslash syntax here. + (cons (append (list (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + file/buf) + (and tags (list (format "%S" tags)))) + guts)) + (error nil))) + #'(lambda (bmk) + (condition-case nil ; Ignore errors, e.g. from bad or stale bookmark records. + (let ((bname (bookmark-name-from-full-record bmk)) + (guts (bookmark-get-bookmark-record bmk))) + (cons (icicle-candidate-short-help + (icicle-bookmark-help-string bname) + (icicle-bookmark-propertize-candidate bname)) + guts)) + (error nil)))) + (bmkp-sort-and-remove-dups (funcall ',(intern (format "bmkp-%s-alist-only" type)) + ,@args))))) + nil ; First code + (icicle-bookmark-cleanup-on-quit) ; Undo code + (icicle-bookmark-cleanup))) ; Last code + +;; The following sexps macro-expand to define these commands: +;; `icicle-search-all-tags-bookmark' +;; `icicle-search-all-tags-regexp-bookmark' +;; `icicle-search-bookmark-list-bookmark' +;; `icicle-search-desktop-bookmark' +;; `icicle-search-dired-bookmark' +;; `icicle-search-file-bookmark' +;; `icicle-search-gnus-bookmark' +;; `icicle-search-info-bookmark' +;; `icicle-search-local-file-bookmark' +;; `icicle-search-man-bookmark' +;; `icicle-search-non-file-bookmark' +;; `icicle-search-region-bookmark' +;; `icicle-search-remote-file-bookmark' +;; `icicle-search-some-tags-bookmark' +;; `icicle-search-some-tags-regexp-bookmark' +;; `icicle-search-specific-buffers-bookmark' +;; `icicle-search-specific-files-bookmark' +;; `icicle-search-this-buffer-bookmark' +;; `icicle-search-url-bookmark' +;; `icicle-search-w3m-bookmark' + +(icicle-define-search-bookmark-command "all-tags" nil (bmkp-read-tags-completing)) +(icicle-define-search-bookmark-command "all-tags-regexp" nil (bmkp-read-tags-completing)) +(icicle-define-search-bookmark-command "bookmark-list") +(icicle-define-search-bookmark-command "desktop") +(icicle-define-search-bookmark-command "dired") +(icicle-define-search-bookmark-command "file") +(icicle-define-search-bookmark-command "gnus") +(icicle-define-search-bookmark-command "info") +(icicle-define-search-bookmark-command "local-file") +(icicle-define-search-bookmark-command "man") +(icicle-define-search-bookmark-command "non-file") +(icicle-define-search-bookmark-command "region" "Search region: ") +(icicle-define-search-bookmark-command "remote-file") +(icicle-define-search-bookmark-command "some-tags" nil (bmkp-read-tags-completing)) +(icicle-define-search-bookmark-command "some-tags-regexp" nil (bmkp-read-tags-completing)) +(icicle-define-search-bookmark-command "specific-buffers" nil (icicle-bookmarked-buffer-list)) +(icicle-define-search-bookmark-command "specific-files" nil (icicle-bookmarked-file-list)) +(icicle-define-search-bookmark-command "this-buffer") +(icicle-define-search-bookmark-command "url") +(icicle-define-search-bookmark-command "w3m") + +;;;###autoload +(defun icicle-search-char-property (beg end require-match + &optional where prop values predicate) + "Search for text that has a character property with a certain value. +If the property is `face' or `font-lock-face', then you can pick +multiple faces, using completion. Text is then searched that has a +face property that includes any of the selected faces. If you choose +no face (empty input), then text with any face is found. + +By \"character property\" is meant either an overlay property or a +text property. If you want to search for only an overlay property or +only a text property, then use `icicle-search-overlay-property' or +`icicle-search-text-property' instead. + +Non-interactively, arguments BEG, END, REQUIRE-MATCH, and WHERE are as +for `icicle-search'. Arguments PROP, VALUES, and PREDICATE are passed +to `icicle-search-char-property-scan' to define the search contexts. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the doc for command +`icicle-search'." + (interactive (icicle-search-property-args)) + (icicle-search beg end 'icicle-search-char-property-scan require-match where prop values nil + predicate)) + +;;;###autoload +(defun icicle-search-overlay-property (beg end require-match &optional where prop values predicate) + "Same as `icicle-search-char-property', except only overlay property. +That is, do not also search a text property." + (interactive (icicle-search-property-args)) + (icicle-search beg end 'icicle-search-char-property-scan require-match where prop values 'overlay + predicate)) + +;;;###autoload +(defun icicle-search-text-property (beg end require-match ; Bound to `C-c "'. + &optional where prop values predicate) + "Same as `icicle-search-char-property', except only text property. +That is, do not also search an overlay property." + (interactive (icicle-search-property-args)) + (icicle-search beg end 'icicle-search-char-property-scan require-match where prop values 'text + predicate)) + +(defun icicle-search-property-args () + "Read and return interactive arguments for `icicle-search-*-property'." + (let* ((where (icicle-search-where-arg)) + (beg+end (icicle-region-or-buffer-limits)) + (beg1 (car beg+end)) + (end1 (cadr beg+end)) + (props (mapcar #'(lambda (prop) (list (symbol-name prop))) + (icicle-char-properties-in-buffers where beg1 end1))) + (prop (intern (completing-read "Property to search: " props nil nil nil nil "face"))) + (values (if (memq prop '(face font-lock-face)) + (let ((faces (icicle-face-list))) + (if faces (mapcar #'intern faces) (face-list))) ; Default: all faces. + (list (intern (icicle-completing-read-history + "Property value: " 'icicle-char-property-value-history)))))) + `(,beg1 ,end1 ,(not icicle-show-multi-completion-flag) ,where ,prop ,values))) + +(defun icicle-char-properties-in-buffers (where beg end &optional type) + "List of all character properties in WHERE. +The other arguments are passed to `icicle-char-properties-in-buffer'. +Only the character properties are included, not their values. +WHERE is a list of buffers, a list of files, or a list of region + bookmarks (in which case you must also use library `bookmark+.el'). + If nil, then only the current buffer is used. +TYPE can be `overlay', `text', or nil, meaning overlay properties, +text properties, or both, respectively." + (cond ((and (consp where) (bufferp (car where))) ; List of buffers - search buffers. + (dolist (buf where) (icicle-char-properties-in-buffer buf nil nil type))) + ((and (consp where) ; List of files - search files. + (stringp (car where)) + (file-exists-p (car where))) + (dolist (file where) + (icicle-char-properties-in-buffer (find-file-noselect file) nil nil type))) + ((consp where) ; Search bookmarked regions. + (unless (require 'bookmark+ nil t) (error "This requires library `bookmark+.el'")) + (let (buf+beg buf beg end) + (dolist (bmk where) + (setq buf+beg (bookmark-jump-noselect bmk) + buf (car buf+beg) + beg (cdr buf+beg) + end (bmkp-get-end-position bmk)) + (when (bufferp buf) (icicle-char-properties-in-buffer (get-buffer buf) beg end type))))) + (t ; Search this buffer only. + (icicle-char-properties-in-buffer (current-buffer) beg end type)))) + +(defun icicle-char-properties-in-buffer (&optional buffer beg end type) + "List of all character properties in BUFFER between BEG and END. +Only the character properties are included, not their values. +TYPE can be `overlay', `text', or nil, meaning overlay properties, +text properties, or both, respectively." + (unless buffer (setq buffer (current-buffer))) + (let ((props ()) + ovrlays curr-props) + (when (bufferp buffer) ; Do nothing if BUFFER is not a buffer. + (with-current-buffer buffer + (unless (and beg end) + (setq beg (point-min) + end (point-max))) + (when (or (not type) (eq type 'overlay)) ; Get overlay properties. + (setq ovrlays (overlays-in beg end)) + (dolist (ovrly ovrlays) + (setq curr-props (overlay-properties ovrly)) + (while curr-props + (unless (memq (car curr-props) props) (push (car curr-props) props)) + (setq curr-props (cddr curr-props))))) + (when (or (not type) (eq type 'text)) ; Get text properties. + (while (< beg end) + (setq beg (or (next-property-change beg nil end) end) + curr-props (text-properties-at beg)) + (while curr-props + (unless (memq (car curr-props) props) (push (car curr-props) props)) + (setq curr-props (cddr curr-props))))))) + props)) + +(defun icicle-search-char-property-scan (buffer beg end prop values type predicate) + "Scan BUFFER from BEG to END for character property PROP with VALUES. +Push hits onto `icicle-candidates-alist'. +If BUFFER is nil, scan the current buffer. +Highlight the matches in face `icicle-search-main-regexp-others'. +If BEG and END are nil, scan entire BUFFER. + +Find text with a PROP value that overlaps with VALUES. That is, if +the value of PROP is an atom, then it must be a member of VALUES; if +it is a list, then at least one list element must be a member of +VALUES. + +TYPE is `overlay', `text', or nil, and specifies the type of character +property - nil means look for both overlay and text properties. + +If PREDICATE is non-nil, then push only the hits for which it holds. +PREDICATE is nil or a Boolean function that takes these arguments: + - the search-context string + - a marker at the end of the search-context" + (let ((add-bufname-p (and buffer icicle-show-multi-completion-flag)) + (temp-list ()) + (zone-end nil)) + (unless buffer (setq buffer (current-buffer))) + (when (bufferp buffer) ; Do nothing if BUFFER is not a buffer. + (with-current-buffer buffer + (unless (and beg end) + (setq beg (point-min) + end (point-max))) + (condition-case icicle-search-char-property-scan + (save-excursion + (while (and (< beg end) + (let* ((charval (and (or (not type) (eq type 'overlay)) + (get-char-property beg prop))) + (textval (and (or (not type) (eq type 'text)) + (get-text-property beg prop))) + (currval (icicle-flat-list charval textval))) + (not (icicle-set-intersection values currval)))) + (setq beg (icicle-next-single-char-property-change beg prop nil end))) + (while (and beg (< beg end)) + (setq zone-end (or (icicle-next-single-char-property-change beg prop nil end) end)) + (let* ((hit-string (buffer-substring-no-properties beg zone-end)) + (end-marker (copy-marker zone-end))) + (when (or (not predicate) + (save-match-data (funcall predicate hit-string end-marker))) + (icicle-candidate-short-help + (concat (and add-bufname-p + (format "Buffer: `%s', " (buffer-name (marker-buffer end-marker)))) + (format "Position: %d, Length: %d" + (marker-position end-marker) (length hit-string))) + hit-string) + (push (cons (if add-bufname-p + (list hit-string + (let ((string (copy-sequence (buffer-name)))) + (put-text-property 0 (length string) + 'face 'icicle-candidate-part string) + string)) + hit-string) + end-marker) + temp-list) + ;; Highlight search context in buffer. + (when (<= (+ (length temp-list) (length icicle-candidates-alist)) + icicle-search-highlight-threshold) + (let ((ov (make-overlay beg zone-end))) + (push ov icicle-search-overlays) + (overlay-put ov 'priority 200) ; > ediff's 100+, but < isearch overlays + (overlay-put ov 'face 'icicle-search-main-regexp-others))))) + (setq beg zone-end) + (while (and (< beg end) + (let* ((charval (and (or (not type) (eq type 'overlay)) + (get-char-property beg prop))) + (textval (and (or (not type) (eq type 'text)) + (get-text-property beg prop))) + (currval (icicle-flat-list charval textval))) + (not (icicle-set-intersection values currval)))) + (setq beg (icicle-next-single-char-property-change beg prop nil end)))) + (setq icicle-candidates-alist (append icicle-candidates-alist (nreverse temp-list)))) + (quit (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup))) + (error (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (error (error-message-string icicle-search-char-property-scan)))))))) + +(defun icicle-flat-list (val1 val2) + "Return a flat list with all values in VAL1 and VAL2." + (let ((result nil)) + (unless (listp val1) (setq val1 (list val1))) + (unless (listp val2) (setq val2 (list val2))) + (while val1 (add-to-list 'result (pop val1))) + (while val2 (add-to-list 'result (pop val2))) + result)) + +(if (fboundp 'next-single-char-property-change) + (defalias 'icicle-next-single-char-property-change 'next-single-char-property-change) + (defun icicle-next-single-char-property-change (position prop &optional object limit) + "Position of next change of PROP for text property or overlay change. +Scans characters forward from buffer position POSITION until property +PROP changes. Returns the position of that change. + +POSITION is a buffer position (integer or marker). + +Optional third arg OBJECT is ignored. It is present for compatibility + with Emacs 22. + +If optional fourth arg LIMIT is non-nil, search stops at position +LIMIT. LIMIT is returned if nothing is found before LIMIT. + +The property values are compared with `eq'. If the property is +constant all the way to the end of the buffer, then the last valid +buffer position is returned." + (save-excursion + (goto-char position) + (let ((propval (get-char-property (point) prop)) + (end (min limit (point-max)))) + (while (and (< (point) end) (eq (get-char-property (point) prop) propval)) + (goto-char (min (next-overlay-change (point)) + (next-single-property-change (point) prop nil end))))) + (point)))) + +;;;###autoload +(defun icicle-search-highlight-cleanup () + "Remove all highlighting from the last use of `icicle-search'." + (interactive) + (let ((inhibit-quit t)) + (message "Removing search highlighting...") + (while icicle-search-overlays + (delete-overlay (car icicle-search-overlays)) + (setq icicle-search-overlays (cdr icicle-search-overlays))) + (while icicle-search-level-overlays + (delete-overlay (car icicle-search-level-overlays)) + (setq icicle-search-level-overlays (cdr icicle-search-level-overlays))) + (when (overlayp icicle-search-current-overlay) + (delete-overlay icicle-search-current-overlay)) + (when (overlayp icicle-search-refined-overlays) + (delete-overlay icicle-search-refined-overlays) + (setq icicle-search-refined-overlays ())) + (while icicle-search-refined-overlays + (delete-overlay (car icicle-search-refined-overlays)) + (setq icicle-search-refined-overlays (cdr icicle-search-refined-overlays))) + (message "Removing search highlighting...done"))) + +;;;###autoload +(defun icicle-search-word (beg end word-regexp require-match ; Bound to `C-c $'. + &optional where &rest args) + "Search for a whole word. +Word search is literal: regexp special characters are treated as +non-special. In fact, they are also treated as if they were +word-constituent characters. That is, your typed input is searched +for literally, but matches must begin and end on a word boundary. +This also means that you can include whitespace within the \"word\" +being sought. + +At the prompt for a word, you can use completion against previous +Icicles search inputs to choose the word, or you can enter a new word. + +Non-interactively, WORD-REGEXP should be a regexp that matches a word. +The other arguments are the same as for `icicle-search'. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(icicle-search-read-word) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (icicle-search beg end word-regexp (not icicle-show-multi-completion-flag) where)) + +;;;###autoload +(defun icicle-search-bookmarks-together (scan-fn-or-regexp require-match &rest args) + "Search bookmarked regions (together). +The arguments are the same as for `icicle-search', but without +arguments BEG, END, and WHERE. + +This is the same as using a plain prefix arg, `C-u', with +`icicle-search'. + +You first choose all of the bookmarked regions to search. Then your +input is matched against a multi-completion composed of (a) the region +text that matches the regexp and (b) the region's buffer name. + +An alternative is multi-command `icicle-search-bookmark', which +searches the bookmarked regions you choose one at a time." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match + (let ((current-prefix-arg '(4))) (icicle-search-where-arg)) + args)) + +;;;###autoload +(defun icicle-search-buffer (scan-fn-or-regexp require-match &rest args) + "Search multiple buffers completely. +Same as using a non-negative numeric prefix arg, such as `C-9', with +`icicle-search'. You are prompted for the buffers to search. All of +each buffer is searched. Any existing buffers can be chosen. +Arguments are the same as for `icicle-search', but without arguments +BEG, END, and WHERE." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match + (let ((icicle-show-Completions-initially-flag t)) + (mapcar #'get-buffer (let ((icicle-buffer-require-match-flag 'partial-match-ok)) + (icicle-buffer-list)))) + args)) + +;;;###autoload +(defun icicle-search-file (scan-fn-or-regexp require-match &rest args) + "Search multiple files completely. +Same as using a negative numeric prefix arg, such as `C--', with +`icicle-search'. You are prompted for the files to search. All of +each file is searched. Any existing files in the current directory +can be chosen. Arguments are the same as for `icicle-search', but +without arguments BEG, END, and WHERE." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match + (let ((icicle-show-Completions-initially-flag t)) (icicle-file-list)) + args)) + +;;;###autoload +(defun icicle-search-dired-marked (scan-fn-or-regexp require-match &rest args) + "Search the marked files in Dired. +Arguments are the same as for `icicle-search', but without arguments +BEG, END, and WHERE." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (unless (eq major-mode 'dired-mode) + (error "Command `icicle-search-dired-marked' must be called from a Dired buffer")) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match (dired-get-marked-files) args)) + +;;;###autoload +(defun icicle-search-ibuffer-marked (scan-fn-or-regexp require-match &rest args) + "Search the marked buffers in Ibuffer, in order. +Arguments are the same as for `icicle-search', but without arguments +BEG, END, and WHERE." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (unless (eq major-mode 'ibuffer-mode) + (error "Command `icicle-search-ibuffer-marked' must be called from an Ibuffer buffer")) + (let ((marked-bufs (nreverse (ibuffer-get-marked-buffers)))) + (unless marked-bufs (setq marked-bufs (list (ibuffer-current-buffer t)))) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match marked-bufs args))) + +;;;###autoload +(defun icicle-search-buff-menu-marked (scan-fn-or-regexp require-match &rest args) + "Search the marked buffers in Buffer Menu, in order. +Arguments are the same as for `icicle-search', but without arguments +BEG, END, and WHERE." + (interactive `(,(if icicle-search-whole-word-flag + (icicle-search-read-word) + (icicle-search-read-context-regexp)) + ,(not icicle-show-multi-completion-flag))) + (unless (eq major-mode 'Buffer-menu-mode) + (error "Command `icicle-search-buff-menu-marked' must be called from a Buffer Menu buffer")) + (let ((marked-bufs ())) + (save-excursion + (Buffer-menu-beginning) + (while (re-search-forward "^>" nil t) (push (Buffer-menu-buffer t) marked-bufs))) + (setq marked-bufs (nreverse marked-bufs)) + (unless marked-bufs (setq marked-bufs (list (Buffer-menu-buffer t)))) + (apply #'icicle-search nil nil scan-fn-or-regexp require-match marked-bufs args))) + +(defalias 'icicle-search-lines 'icicle-occur) +;;;###autoload +(defun icicle-occur (beg end &optional buffers) ; Bound to `C-c ''. + "`icicle-search' with a regexp of \".*\". An `occur' with icompletion. +Type a regexp to match within each line of one or more buffers. Use +`S-TAB' to show matching lines. Use `C-RET' or `C-mouse-2' to go to +the line of the current candidate. Use `C-next', `C-prior', `C-down', +or`C-up' to cycle among the matching lines. + +By default, search only the current buffer. Search the active region, +or, if none, the entire buffer. With a prefix argument, you are +prompted for the buffers to search. You can choose buffers using +completion (`C-RET' and so on). If the prefix argument is 99, then +only buffers visiting files are candidates. + +You can use `M-*' to further narrow the match candidates, typing +additional regexps to match. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(and current-prefix-arg + (icicle-search-choose-buffers (= 99 (prefix-numeric-value + current-prefix-arg)))))) + (let ((fg (face-foreground 'icicle-search-main-regexp-others)) + (bg (face-background 'icicle-search-main-regexp-others)) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function))) + (unwind-protect + (progn (set-face-foreground 'icicle-search-main-regexp-others nil) + (set-face-background 'icicle-search-main-regexp-others nil) + (icicle-search beg end ".*" (not icicle-show-multi-completion-flag) buffers)) + (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (set-face-foreground 'icicle-search-main-regexp-others fg) + (set-face-background 'icicle-search-main-regexp-others bg)))) + +;;;###autoload +(defun icicle-search-sentences (beg end &optional buffers) + "`icicle-search' with sentences as contexts. +Type a regexp to match within each sentence of one or more buffers. +Use `S-TAB' to show matching sentences. Use `C-RET' or `C-mouse-2' to +go to the line of the current candidate. Use `C-next', `C-prior', +`C-down', or`C-up' to cycle among the matching sentences. + +By default, search only the current buffer. Search the active region, +or, if none, the entire buffer. With a prefix argument, you are +prompted for the buffers to search. You can choose buffers using +completion (`C-RET' and so on). If the prefix argument is 99, then +only buffers visiting files are candidates. + +You can use `M-*' to further narrow the match candidates, typing +additional regexps to match. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(and current-prefix-arg + (icicle-search-choose-buffers (= 99 (prefix-numeric-value + current-prefix-arg)))))) + (let ((fg (face-foreground 'icicle-search-main-regexp-others)) + (bg (face-background 'icicle-search-main-regexp-others)) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function))) + (unwind-protect + (progn (set-face-foreground 'icicle-search-main-regexp-others nil) + (set-face-background 'icicle-search-main-regexp-others nil) + (icicle-search beg end (concat "[A-Z][^.?!]+[.?!]") + (not icicle-show-multi-completion-flag) buffers)) + (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (set-face-foreground 'icicle-search-main-regexp-others fg) + (set-face-background 'icicle-search-main-regexp-others bg)))) + +;;;###autoload +(defun icicle-search-paragraphs (beg end &optional buffers) + "`icicle-search' with paragraphs as contexts. +Type a regexp to match within each paragraph of one or more buffers. +Use `S-TAB' to show matching paragraph. Use `C-RET' or `C-mouse-2' to +go to the line of the current candidate. Use `C-next', `C-prior', +`C-down', or`C-up' to cycle among the matching paragraphs. + +By default, search only the current buffer. Search the active region, +or, if none, the entire buffer. With a prefix argument, you are +prompted for the buffers to search. You can choose buffers using +completion (`C-RET' and so on). If the prefix argument is 99, then +only buffers visiting files are candidates. + +You can use `M-*' to further narrow the match candidates, typing +additional regexps to match. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(and current-prefix-arg + (icicle-search-choose-buffers (= 99 (prefix-numeric-value + current-prefix-arg)))))) + (let ((fg (face-foreground 'icicle-search-main-regexp-others)) + (bg (face-background 'icicle-search-main-regexp-others)) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function))) + (unwind-protect + (progn (set-face-foreground 'icicle-search-main-regexp-others nil) + (set-face-background 'icicle-search-main-regexp-others nil) + (icicle-search beg end "\\(.+\n\\)+" + (not icicle-show-multi-completion-flag) buffers)) + (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (set-face-foreground 'icicle-search-main-regexp-others fg) + (set-face-background 'icicle-search-main-regexp-others bg)))) + +;;;###autoload +(defun icicle-search-pages (beg end &optional buffers) + "`icicle-search' with pages as contexts. +Type a regexp to match within each page of one or more buffers. Use +`S-TAB' to show matching page. Use `C-RET' or `C-mouse-2' to go to +the line of the current candidate. Use `C-next', `C-prior', `C-down', +or`C-up' to cycle among the matching pages. + +By default, search only the current buffer. Search the active region, +or, if none, the entire buffer. With a prefix argument, you are +prompted for the buffers to search. You can choose buffers using +completion (`C-RET' and so on). If the prefix argument is 99, then +only buffers visiting files are candidates. + +You can use `M-*' to further narrow the match candidates, typing +additional regexps to match. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(and current-prefix-arg + (icicle-search-choose-buffers (= 99 (prefix-numeric-value + current-prefix-arg)))))) + (let ((fg (face-foreground 'icicle-search-main-regexp-others)) + (bg (face-background 'icicle-search-main-regexp-others)) + (icicle-transform-function (if (interactive-p) nil icicle-transform-function))) + (unwind-protect + (progn (set-face-foreground 'icicle-search-main-regexp-others nil) + (set-face-background 'icicle-search-main-regexp-others nil) + (icicle-search beg end "\\([^\f]*[\f]\\|[^\f]+$\\)" + (not icicle-show-multi-completion-flag) buffers)) + (when icicle-search-cleanup-flag (icicle-search-highlight-cleanup)) + (set-face-foreground 'icicle-search-main-regexp-others fg) + (set-face-background 'icicle-search-main-regexp-others bg)))) + +;;;###autoload +(defun icicle-comint-search (beg end) ; Bound to `C-x `' in `comint-mode'. + "Use `icicle-search' to pick up a previous input for reuse. +Use this in a `comint-mode' buffer, such as *shell* or +*inferior-lisp*. This searches your interactive history in the buffer +for a match to your current input, which you can change dynamically. +When you choose a previous input, it is copied to the current prompt, +for reuse. If the region is active, then only it is searched; +otherwise, the entire buffer is searched. + +Use `C-RET' or `C-mouse-2' to choose a previous input for reuse. Use +`C-next', `C-prior', `C-down', or `C-up' to cycle among your previous +inputs. + +As for other Icicles search commands, your current input narrows the +set of possible candidates. See `icicle-search' for more +information. + +You can use `M-*' to further narrow the match candidates, typing +additional regexps to match. + +Note that previous commands are identified by looking through the +shell buffer for a shell prompt. This is not foolproof. If, for +instance you use command `ls', the output includes an auto-save file +such as #foo.el#, and `#' in the first column represents a shell +prompt, then #foo.el# will be misinterpreted as a previous command. + +Also, depending on your shell, you might want to customize variables +such as the following: + +`shell-prompt-pattern',`telnet-prompt-pattern'. + +Being a search command, `icicle-comint-search' cannot give you access +to previous shell commands that are not visible in the current buffer. +See also \\\\[icicle-comint-command] for another way to reuse commands, +including those from previous sessions. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments, see the doc for command +`icicle-search'." + (interactive (icicle-region-or-buffer-limits)) + ;; Is there a better test we can use, to make sure the current mode inherits from `comint-mode'? + (unless (where-is-internal 'comint-send-input (keymap-parent (current-local-map))) + (error "Current mode must be derived from comint mode")) + (let ((orig-search-hook icicle-search-hook) + (icicle-transform-function 'icicle-remove-duplicates)) + (add-hook 'icicle-search-hook 'icicle-comint-search-send-input) + (unwind-protect + (icicle-search beg end + (concat comint-prompt-regexp "\\S-.*") nil) ; Match not required (edit). + (remove-hook 'icicle-search-hook 'icicle-comint-search-send-input))) + (goto-char (point-max))) + +(defun icicle-comint-search-send-input () + "Grab current completion input and use that for comint input." + (unless (comint-check-proc (current-buffer)) + (error "No live process associated with this buffer")) + (let ((comint-get-old-input + (if (minibuffer-window-active-p (minibuffer-window)) + 'icicle-comint-search-get-minibuffer-input ; Use minibuffer input (e.g. for action fn). + 'icicle-comint-search-get-final-choice))) ; Use final choice. + (comint-copy-old-input)) + (comint-send-input)) + +(defun icicle-comint-search-get-minibuffer-input () + "Return the minibuffer input, beyond the prompt." + (let* ((cand (icicle-minibuf-input)) + (input-start (and (string-match comint-prompt-regexp cand) (match-end 0)))) + (if input-start (substring cand input-start) cand))) + +(defun icicle-comint-search-get-final-choice () + "Return the final choice, beyond the prompt." + (let ((input-start (and (string-match comint-prompt-regexp icicle-explore-final-choice) + (match-end 0)))) + (if input-start + (substring icicle-explore-final-choice input-start) + icicle-explore-final-choice))) + +;;;###autoload +(icicle-define-command icicle-comint-command ; Bound to `C-c TAB' in `comint-mode'. + "Retrieve a previously used command. +Use this in a `comint-mode' buffer such as *shell* or *inferior-lisp*. + +Note, depending on your shell, you might want to customize variables +such as the following: + +`shell-prompt-pattern',`telnet-prompt-pattern'. + +See also \\\\[icicle-comint-search] for another way to reuse commands." ; Doc string + insert ; Action function + "Choose a previous command: " ; `completing-read' args + (mapcar #'list (cddr comint-input-ring)) nil nil nil 'shell-command-history + (aref (cddr comint-input-ring) 0) nil + ((icicle-transform-function 'icicle-remove-duplicates))) ; Bindings + +(defun icicle-comint-hook-fn () + "Hook to set up Comint mode for Icicles." + (set (make-local-variable 'icicle-search-command) 'icicle-comint-search)) + +;;;###autoload +(defun icicle-compilation-search (beg end) ; Bound to `C-c `' in `compilation(-minor)-mode'. + "Like `icicle-search', but show the matching compilation-buffer hit. +Use this in a compilation buffer, such as `*grep*', searching for a +regexp as with `icicle-search'. Use `C-RET' or `C-mouse-2' to show +the target-buffer hit corresponding to the current completion +candidate. Use `C-next', `C-prior', `C-down', or `C-up' to cycle +among the target-buffer hits. + +As for `icicle-search', you can further narrow the match candidates by +typing a second regexp to search for among the first matches. See +`icicle-search' for more information. + +Altogether, using this with `grep' gives you two or three levels of +regexp searching: 1) the `grep' regexp, 2) the major `icicle-search' +regexp, and optionally 3) the refining `icicle-search' regexp. + +In Emacs 22 and later, you can replace search-hit text, as in +`icicle-search'. In earlier Emacs versions, you cannot replace text. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments, see the doc for command +`icicle-search'." + (interactive (icicle-region-or-buffer-limits)) + (unless (condition-case nil (eq (current-buffer) (compilation-find-buffer)) (error nil)) + (error "Current buffer must be a compilation buffer")) + (save-excursion (goto-char (point-min)) + (compilation-next-error 1) + (setq beg (if beg (max beg (point)) (point)))) + (let ((icicle-transform-function (if (interactive-p) nil icicle-transform-function)) + (icicle-candidate-alt-action-fn + (if (boundp 'compilation-highlight-overlay) ; Emacs 22 test. + icicle-candidate-alt-action-fn + #'(lambda (cand) + (message "Cannot replace matching text in Emacs before version 22")))) + (next-error-highlight + ;; Highlight indefinitely. `until-move' should be part of Emacs (patch sent), but it's not. + (if (and (featurep 'compile+) (featurep 'simple+)) 'until-move 1000000)) + (icicle-search-in-context-fn 'icicle-compilation-search-in-context-fn) + (fg (face-foreground 'icicle-search-main-regexp-others)) + (bg (face-background 'icicle-search-main-regexp-others))) + (unwind-protect + (progn + (set-face-foreground 'icicle-search-main-regexp-others nil) + (set-face-background 'icicle-search-main-regexp-others nil) + (icicle-search beg end ".*" t)) + (set-face-foreground 'icicle-search-main-regexp-others fg) + (set-face-background 'icicle-search-main-regexp-others bg)))) + +(defun icicle-compilation-search-in-context-fn (cand+mrker replace-string) + "`icicle-search-in-context-fn' used for `icicle-compilation-search'. +If `crosshairs.el' is loaded, then the target position is highlighted." + (if (not (fboundp 'compilation-next-error-function)) + (compile-goto-error) ; Emacs 20, 21. + (setq compilation-current-error (point)) ; Emacs 22+. + (compilation-next-error-function 0 nil)) + (save-excursion + (save-restriction + (let ((inhibit-field-text-motion t)) ; Just to be sure, for `end-of-line'. + (narrow-to-region (progn (beginning-of-line) (point)) (progn (end-of-line) (point)))) + (icicle-search-highlight-and-maybe-replace cand+mrker replace-string))) + (when (fboundp 'crosshairs-highlight) (crosshairs-highlight 'line-only 'nomsg)) + (let ((icicle-candidate-nb icicle-candidate-nb)) (icicle-complete-again-update))) + +(defun icicle-compilation-hook-fn () + "Hook setting `icicle-search-command' for compilation modes. +Used on `compilation-mode-hook' and `compilation-minor-mode-hook'." + (set (make-local-variable 'icicle-search-command) 'icicle-compilation-search)) + +(defalias 'icicle-search-defs 'icicle-imenu) +;;;###autoload +(defun icicle-imenu (beg end require-match &optional where) ; Bound to `C-c ='. + "Go to an Imenu entry using `icicle-search'. +Recommended: Use library `imenu+.el' also. +In Emacs-Lisp mode, `imenu+.el' classifies definitions using these +submenus: + + 1. Keys - keys in the global keymap + 2. Keys in Maps - keys in keymaps other than global keymap + 3. Functions - functions, whether interactive or not + 4. Macros - macros defined with `defmacro' + 5. User Options - user variables, from `defcustom' + 6. Variables - other variables (non-options), from `defvar' + 7. Faces - faces, from `defface' + 8. Other - other definitions + +Note: If you use this command with a prefix argument, then the Imenu +mode (and `imenu-generic-expression') of the current buffer determines +what kinds of definitions are found. So, if you want to search for +definitions in a certain language, then invoke this command from a +buffer in that language. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (unless imenu-generic-expression (error "No Imenu for this buffer")) + (let ((case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) + (not (local-variable-p 'font-lock-defaults))) + imenu-case-fold-search + (nth 2 font-lock-defaults))) + (old-table (syntax-table)) + (table (copy-syntax-table (syntax-table))) + (slist imenu-syntax-alist)) + (dolist (syn slist) ; Modify the syntax table used while matching regexps. + (if (numberp (car syn)) + (modify-syntax-entry (car syn) (cdr syn) table) ; Single character. + (mapc #'(lambda (c) (modify-syntax-entry c (cdr syn) table)) (car syn)))) ; String. + (unwind-protect + (save-match-data + (set-syntax-table table) + (let* ((menus (icicle-remove-if-not + #'icicle-imenu-in-buffer-p ; Only use menus that match the buffer. + (mapcar #'(lambda (menu) ; Name an unlabeled menu `Others'. + (if (stringp (car menu)) menu (cons "Others" (cdr menu)))) + imenu-generic-expression))) + (submenu (let ((icicle-show-Completions-initially-flag t)) + (completing-read "Choose: " menus nil t))) + (regexp (cadr (assoc submenu menus))) + (icicle-transform-function + (if (interactive-p) nil icicle-transform-function))) + (unless (stringp regexp) (error "No match")) + (icicle-search beg end regexp require-match where))) + (set-syntax-table old-table)))) + +(defun icicle-imenu-in-buffer-p (menu) + "Return non-nil if the regexp in MENU has a match in the buffer." + (save-excursion (goto-char (point-min)) (re-search-forward (cadr menu) nil t))) + +(defun icicle-imenu-command (beg end require-match &optional where) + "Go to an Emacs command definition using `icicle-search'. +This uses `commandp', so it finds only currently defined commands. +That is, if the buffer has not been evaluated, then its function +definitions are not considered commands by `icicle-imenu-command'. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (unless (or where (eq major-mode 'emacs-lisp-mode)) + (error "This command is only for Emacs-Lisp mode")) + (let ((case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) + (not (local-variable-p 'font-lock-defaults))) + imenu-case-fold-search + (nth 2 font-lock-defaults))) + (old-table (syntax-table)) + (table (copy-syntax-table (syntax-table))) + (slist imenu-syntax-alist)) + (dolist (syn slist) ; Modify the syntax table used while matching regexps. + (if (numberp (car syn)) + (modify-syntax-entry (car syn) (cdr syn) table) ; Single character. + (mapc #'(lambda (c) (modify-syntax-entry c (cdr syn) table)) (car syn)))) ; String. + (unwind-protect + (save-match-data + (set-syntax-table table) + (let* ((menus (icicle-remove-if-not + #'icicle-imenu-in-buffer-p ; Only use menus that match the buffer. + (mapcar #'(lambda (menu) ; Name an unlabeled menu `Others'. + (if (stringp (car menu)) menu (cons "Others" (cdr menu)))) + (if (boundp 'emacs-lisp-imenu-generic-expression) + emacs-lisp-imenu-generic-expression + lisp-imenu-generic-expression)))) + (submenu (or (assoc "Functions" menus) (assoc "Others" menus) + (error "No command definitions in buffer"))) + (regexp (cadr (assoc (car submenu) menus))) + (icicle-transform-function + (if (interactive-p) nil icicle-transform-function))) + (unless (stringp regexp) (error "No command definitions in buffer")) + (icicle-search beg end regexp require-match where 'icicle-imenu-command-p))) + (set-syntax-table old-table)))) + +(defun icicle-imenu-non-interactive-function (beg end require-match &optional where) + "Go to an Emacs non-interactive function definition with `icicle-search'. +This uses `commandp' to distinguish currently defined commands from +other functions. This means that if the buffer has not yet been +evaluated, then all of its function definitions are considered +non-interactive by `icicle-imenu-non-interactive-function'. + +This command is intended only for use in Icicle mode. It is defined +using `icicle-search'. For more information, in particular for +information about the arguments and the use of a prefix argument to +search multiple regions, buffers, or files, see the doc for command +`icicle-search'." + (interactive `(,@(icicle-region-or-buffer-limits) + ,(not icicle-show-multi-completion-flag) + ,(icicle-search-where-arg))) + (unless (or where (eq major-mode 'emacs-lisp-mode)) + (error "This command is only for Emacs-Lisp mode")) + (let ((case-fold-search (if (or (local-variable-p 'imenu-case-fold-search) + (not (local-variable-p 'font-lock-defaults))) + imenu-case-fold-search + (nth 2 font-lock-defaults))) + (old-table (syntax-table)) + (table (copy-syntax-table (syntax-table))) + (slist imenu-syntax-alist)) + (dolist (syn slist) ; Modify the syntax table used while matching regexps. + (if (numberp (car syn)) + (modify-syntax-entry (car syn) (cdr syn) table) ; Single character. + (mapc #'(lambda (c) (modify-syntax-entry c (cdr syn) table)) (car syn)))) ; String. + (unwind-protect + (save-match-data + (set-syntax-table table) + (let* ((menus (icicle-remove-if-not + #'icicle-imenu-in-buffer-p ; Only use menus that match the buffer. + (mapcar #'(lambda (menu) ; Name an unlabeled menu `Others'. + (if (stringp (car menu)) menu (cons "Others" (cdr menu)))) + (if (boundp 'emacs-lisp-imenu-generic-expression) + emacs-lisp-imenu-generic-expression + lisp-imenu-generic-expression)))) + (submenu (or (assoc "Functions" menus) (assoc "Others" menus) + (error "No command definitions in buffer"))) + (regexp (cadr (assoc (car submenu) menus))) + (icicle-transform-function + (if (interactive-p) nil icicle-transform-function))) + (unless (stringp regexp) (error "No command definitions in buffer")) + (icicle-search beg end regexp require-match where + 'icicle-imenu-non-interactive-function-p))) + (set-syntax-table old-table)))) + +(defun icicle-imenu-command-p (ignored-hit-string ignored-marker) + "Return non-nil for a command definition. +Predicate for `icicle-search'. +Both arguments are ignored here." + (let ((indx (if (< emacs-major-version 21) 6 2))) + (commandp (intern-soft + (buffer-substring-no-properties (match-beginning indx) (match-end indx)))))) + +(defun icicle-imenu-non-interactive-function-p (ignored-hit-string ignored-marker) + "Return non-nil for a non-interactive function definition. +Predicate for `icicle-search'. +Both arguments are ignored here." + (let* ((indx (if (< emacs-major-version 21) 6 2)) + (fn (intern-soft + (buffer-substring-no-properties (match-beginning indx) (match-end indx))))) + (and (fboundp fn) (not (commandp fn))))) + +;;;###autoload +(defun icicle-tags-search (regexp &optional arg) + "Search all source files listed in tags tables for matches for REGEXP. +You are prompted for the REGEXP to match. Enter REGEXP with `RET'. +You do not need `M-,' - you see all matches as search hits to visit. + +All tags in a tags file are used, including duplicate tags from the +same or different source files. + +By default, all tags files are used, but if you provide a prefix +argument then only the current tag table is used. + +If your TAGS file references source files that no longer exist, those +files are listed. In that case, you might want to update your TAGS +file." + (interactive + (let ((completion-ignore-case (if (and (boundp 'tags-case-fold-search) + (memq tags-case-fold-search '(t nil))) + tags-case-fold-search + case-fold-search))) + (require 'etags) + (list (icicle-search-read-context-regexp "Search files with tags for regexp: ") + current-prefix-arg))) + (let ((files ())) + (save-excursion + (let ((first-time t) + (morep t)) + (while (and morep (visit-tags-table-buffer (not first-time))) + (when arg (setq morep nil)) + (setq first-time nil) + (let ((tail (last files))) + (if tail + (setcdr tail (mapcar 'expand-file-name (tags-table-files))) + (setq files (mapcar 'expand-file-name (tags-table-files)))))))) + (let ((tail files) ; Remove names of non-existent or unreadable files. + (unreadable-files ())) + (while tail + (if (file-readable-p (car tail)) + (setq tail (cdr tail)) + (push (car tail) unreadable-files) + (setcar tail (cadr tail)) + (setcdr tail (cddr tail)))) + (when unreadable-files + (with-output-to-temp-buffer "*Unreadable Files*" + (princ "These missing or unreadable files were ignored:") (terpri) (terpri) + (dolist (file unreadable-files) (princ file) (terpri))))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + (icicle-search nil nil regexp nil files))) + +;;;###autoload +(defun icicle-save-string-to-variable (askp) + "Save a string (text) to a variable. +You are prompted for the string to save. Typically, you store a +regexp or part of a regexp in the variable. + +By default, the variable is user option `icicle-input-string'. +To save to a different variable, use a prefix argument; you are then +prompted for the variable to use. + +You can use `\\\ +\\[icicle-insert-string-from-variable]' to insert a string from a +variable." + (interactive "P") + (let* ((enable-recursive-minibuffers t) + (var + (if askp + (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "variable"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "variable")))) + (intern (completing-read "Variable: " obarray 'boundp nil nil + (if (boundp 'variable-name-history) + 'variable-name-history + 'icicle-variable-name-history) + (symbol-name 'icicle-input-string)))) + 'icicle-input-string)) + (text (icicle-completing-read-history + (format "Text to save in `%s': " var)))) + (set var text))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'any))) + (defalias 'any 'icicle-anything)) +(when (> emacs-major-version 21) + (defun icicle-anything (type) + "Act on an object of type TYPE. +You are prompted for the type, then for an object of that type. The +type is either the declared `type' of an Anything source, or its +`name' if it has no `type'. + +This command is available only if you use library `anything.el'. + +This is an Icicles multi-command: You can act on multiple objects in +multiple ways during a single command invocation. When you choose an +object using `RET' or `mouse-2', the default action is applied to it. +The default action is also applied to the current completion candidate +when you use `C-RET', `C-mouse-2', and so on. + +You can apply a different action by using an alternative action key: +`C-S-RET', `C-S-mouse-2', and so on. This lets you choose the action +to apply using completion. You can use `C-RET', `C-mouse-2', and so +on, to perform multiple actions. + +This command is intended for use only in Icicle mode." + (interactive + (let ((icicle-show-Completions-initially-flag t) + (icicle-whole-candidate-as-text-prop-p icicle-anything-transform-candidates-flag)) + (unless (require 'anything nil t) (error "You must load library `anything.el' first")) + (list (intern (completing-read "What (type): " (icicle-remove-duplicates + (mapcar #'list (icicle-get-anything-types))) + nil t))))) + (icicle-object-action type))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'file))) + (defun file () + "Act on a file. You are prompted for the file and the action. +During file-name completion, you can delete the file named by the +current candidate, using `S-delete'. + +This is just `icicle-object-action' with type `file'." + (interactive) (icicle-object-action 'file))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'buffer))) + (defun buffer () + "Act on a buffer. You are prompted for the buffer and the action. +During buffer-name completion, you can kill the buffer named by the +current candidate, using `S-delete'. + +This is just `icicle-object-action' with type `buffer'." + (interactive) (icicle-object-action 'buffer))) + +(when (and icicle-define-alias-commands-flag (not (fboundp 'a))) + (defalias 'a 'icicle-object-action)) +(when (and icicle-define-alias-commands-flag (not (fboundp 'what-which-how))) + (defalias 'what-which-how 'icicle-object-action)) +;;;###autoload +(defun icicle-object-action (&optional type) + "Act on an object of type TYPE (a symbol). +You are prompted for the type (\"What\"), then for an object of that +type (\"Which\"), then for the action function to apply to the +object (\"How\"). For Anything types (see below), you are not +prompted for the action function. + +The \"type\" of an object is one of these: + +a. A type defining an entry `icicle-predicate-types-alist'. + These are type predicates, such as `bufferp', `keywordp', or `atom'. + +b. The `type' of an Anything source, or its `name' if it has no + `type'. This is available only if you use library `anything.el' + and option `icicle-use-anything-candidates-flag' is non-nil. + +c. A type defining an entry in user option + `icicle-type-actions-alist'. + +In the case of Anything types (only), this is a multi-command: +* `C-RET', `C-mouse-2', and so on perform the default action. +* `C-S-RET', `C-S-mouse-2', and so on let you choose the action using + completion. + +Though this is not a multi-command for non-Anything types, for types +`buffer' and `file' you can use `S-delete' during completion to delete +the object (buffer or file) named by the current completion candidate. + +Objects of types (b) and (c) are easily associated with names. Their +names are the completion candidates. So, for instance, if you choose +type `buffer', then you can act on a buffer by choosing its name. + +Objects of predicate type (type a) are not necessarily named. The +completion candidates for these objects are variables (symbols) whose +values are the objects acted upon. So, for instance, if you choose +type `bufferp', then you can choose a variable whose value is a +buffer, in order to act on that buffer. Whereas a buffer is always +named, an object of type `stringp' is not. The value of variable +`emacs-version' is one such string that you can act on. + +Anything types and Anything actions are highlighted when used as +candidates in *Completions*, using face `icicle-special-candidate'. + +Be aware that the action function you choose must accommodate the +object you choose as its only an argument. Also, completion of the +function candidate itself is not strict, so you can enter a lambda +form. + +With a prefix argument, the result of applying the function to the +object is pretty-printed using `icicle-pp-eval-expression'. +Otherwise, the function is called for its effect only, and its value +is not displayed. + +You can use a prefix argument similarly when you act on an individual +function (\"How\") candidate to apply it to the object, without ending +completion. That is, `C-u C-RET', `C-u C-mouse-2', and so on, will +pretty-print the result of the individual action. + +This command is intended for use only in Icicle mode." + (interactive) + (let* ((anything-loaded-p (and (> emacs-major-version 21) + icicle-use-anything-candidates-flag + (require 'anything nil t))) + (anything-types (and (not type) anything-loaded-p (icicle-get-anything-types))) + (typ + (or type + (let ((icicle-show-Completions-initially-flag t)) + (intern + (completing-read "What (type): " + (icicle-remove-duplicates (append (mapcar #'list anything-types) + icicle-type-actions-alist + icicle-predicate-types-alist)) + nil t))))) + (predicate-type-p (and (assoc (symbol-name typ) icicle-predicate-types-alist) + (not (memq (symbol-name typ) anything-types)))) + (anything-candidates (and anything-loaded-p (not predicate-type-p) + (icicle-get-anything-candidates-of-type typ))) + (anything-default-actions (and anything-candidates + (icicle-get-anything-default-actions-for-type typ))) + (anything-actions (and anything-candidates + (icicle-get-anything-actions-for-type typ))) + (icicle-saved-completion-candidate + (cond (predicate-type-p (icicle-read-var-value-satisfying typ)) + (anything-candidates + (icicle-choose-anything-candidate typ anything-candidates + anything-default-actions anything-actions)) + ((member (symbol-name typ) (and anything-loaded-p (icicle-get-anything-types))) + (error "No candidates for type `%s'" (symbol-name typ))) + (t (icicle-choose-candidate-of-type typ)))) + (icicle-candidate-action-fn ; For "how". + #'(lambda (fn) (icicle-apply-to-saved-candidate fn anything-candidates typ))) + (icicle-candidate-alt-action-fn ; For "how". + (and anything-candidates #'(lambda (fn) (icicle-apply-to-saved-candidate fn t typ))))) + (funcall (icicle-alt-act-fn-for-type + (if predicate-type-p + (or (cdr (assoc (symbol-name typ) icicle-predicate-types-alist)) (symbol-name typ)) + (symbol-name typ))) + icicle-saved-completion-candidate))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-types () + "Return list of types defined in `anything-sources'. See `anything.el'." + (and (boundp 'anything-sources) (consp anything-sources) + (let ((types ()) + type) + (dolist (source (anything-get-sources)) + (if (setq type (assoc-default 'type source)) + (push (symbol-name type) types) + (when (setq type (assoc-default 'name source)) (push type types)))) + (setq types + (mapcar #'(lambda (typ) + (setq typ (copy-sequence typ)) + (put-text-property 0 (length typ) 'face 'icicle-special-candidate typ) + typ) + (icicle-remove-duplicates types))))))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-candidates-of-type (type) + "Return list of Anything candidates for type TYPE. +Used only when `anything-sources' is non-nil - see `anything.el'." + (and (boundp 'anything-sources) (consp anything-sources) + (let ((anything-candidate-cache ()) + (candidates nil)) + (dolist (source (anything-get-sources)) + (let ((init-fn (assoc-default 'init source))) (when init-fn (funcall init-fn))) + (when (or (eq type (assoc-default 'type source)) + (string= (symbol-name type) (assoc-default 'name source))) + (setq candidates (icicle-get-anything-cached-candidates source)))) + (when (and (not (functionp candidates)) (consp candidates)) + (mapcar #'(lambda (cand) (if (consp cand) cand (list cand))) candidates)) + candidates)))) + +;; Similar to `anything-get-cached-candidates' in `anything.el', but ignores processes. +;; Free var here: `anything-candidate-cache'. +(when (> emacs-major-version 21) + (defun icicle-get-anything-cached-candidates (source) + "Return cached value of candidates for Anything SOURCE. +Cache the candidates if there is not yet a cached value." + (let* ((source-name (assoc-default 'name source)) + (candidate-cache (assoc source-name anything-candidate-cache)) + candidates) + (if candidate-cache + (setq candidates (cdr candidate-cache)) + (setq candidates (icicle-get-anything-candidates source)) + (when (processp candidates) (setq candidates ())) + (setq candidate-cache (cons source-name candidates)) + (push candidate-cache anything-candidate-cache)) + candidates))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-candidates (source) + "Return the list of candidates from Anything SOURCE." + (let* ((candidate-source (assoc-default 'candidates source)) + (candidates + (cond ((functionp candidate-source) + `(lambda (string pred mode) + (let ((anything-pattern icicle-current-input)) + (setq string anything-pattern) + (let ((all-cands (funcall ,candidate-source))) + (setq all-cands + (icicle-remove-if-not + #'(lambda (cand) + (string-match (if (eq 'prefix icicle-current-completion-mode) + (concat "^" (regexp-quote string)) + string) + cand)) + all-cands)) + (cond ((eq mode t) all-cands) + ((eq mode nil) + (icicle-expanded-common-match icicle-current-input all-cands)) + ((eq mode 'lambda) t)))))) + ((listp candidate-source) candidate-source) + ((and (symbolp candidate-source) (boundp candidate-source)) + (symbol-value candidate-source)) + (t + (error + (concat "Source `candidates' value is not a function, variable or list: %s") + candidate-source))))) + (if (or (not icicle-anything-transform-candidates-flag) (processp candidates)) + candidates + (anything-transform-candidates candidates source))))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-actions-for-type (type) + "Set and return `icicle-candidates-alist' of actions for type TYPE. +The display string for each action is highlighted using face +`icicle-special-candidate'." + (setq icicle-candidates-alist ()) + (let ((all-sources-actions ()) + this-source-actions faced-act) + (dolist (source (anything-get-sources)) + (when (or (eq type (assoc-default 'type source)) + (string= (symbol-name type) (assoc-default 'name source))) + (setq this-source-actions (assoc-default 'action source)) + (dolist (action this-source-actions) + (unless (member action all-sources-actions) + (setq faced-act (copy-sequence (car action))) ; Highlight Anything action. + (put-text-property 0 (length faced-act) 'face 'icicle-special-candidate faced-act) + (push (cons faced-act (cdr action)) all-sources-actions))))) + (setq icicle-candidates-alist (sort all-sources-actions + #'(lambda (a1 a2) + (funcall icicle-sort-comparer (car a1) (car a2)))))))) +(when (> emacs-major-version 21) + (defun icicle-choose-anything-candidate (type candidates default-actions actions) + "Read an Anything object of type TYPE with completion, and return it. +During completion, you can act on selected completion candidates, in +turn, using the action keys (`C-RET', `C-mouse-2', `C-down', etc.). +CANDIDATES is the list of candidates of type TYPE. +DEFAULT-ACTIONS is the list of default actions for type TYPE. +ACTIONS is the list of all actions for type TYPE." + (let* ((win (selected-window)) + (icicle-sort-comparer nil) + (icicle-transform-function nil) + (icicle-Completions-display-min-input-chars (icicle-get-anything-req-pat-chars type)) + (icicle-incremental-completion-delay (icicle-get-anything-input-delay type)) + (icicle-whole-candidate-as-text-prop-p icicle-anything-transform-candidates-flag) + (icicle-candidates-alist + (if (or (functionp candidates) icicle-whole-candidate-as-text-prop-p) + candidates + icicle-candidates-alist)) + (icicle-candidate-action-fn + #'(lambda (obj) + (when icicle-whole-candidate-as-text-prop-p + (setq obj (icicle-anything-candidate-value obj))) + (let ((enable-recursive-minibuffers t)) + (with-selected-window win + (if (null (cdr default-actions)) + (funcall (cdar default-actions) obj) + (funcall (completing-read "How (action): " default-actions nil t) obj)))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + (icicle-raise-Completions-frame))) + (icicle-candidate-alt-action-fn + `(lambda (obj) + (when icicle-whole-candidate-as-text-prop-p + (setq obj (icicle-anything-candidate-value obj))) + (let ((icicle-show-Completions-initially-flag t) + (icicle-saved-completion-candidate obj) + (icicle-candidates-alist actions) + (enable-recursive-minibuffers t)) + (with-selected-window win + (icicle-apply-to-saved-candidate + (let ((enable-recursive-minibuffers t) + (icicle-last-completion-candidate icicle-last-completion-candidate) + (icicle-candidate-alt-action-fn nil) + (icicle-candidate-action-fn + `(lambda (actn) (with-selected-window win + (let ((enable-recursive-minibuffers t) + (icicle-candidates-alist actions)) + (icicle-apply-to-saved-candidate actn t ,type)))))) + (completing-read "How (action): " actions nil t)) + t + ,type))))) + (orig-action-fn icicle-candidate-action-fn) + (icicle-candidate-help-fn + (if icicle-whole-candidate-as-text-prop-p + #'(lambda (obj) + (let ((icicle-candidate-help-fn nil)) + (icicle-help-on-candidate-symbol + (intern (icicle-anything-candidate-value obj))))) + icicle-candidate-help-fn)) + (icicle-candidate-action-fn + (if icicle-whole-candidate-as-text-prop-p + #'(lambda (obj) + (let ((icicle-last-input (icicle-anything-candidate-value obj))) + (funcall orig-action-fn obj))) + icicle-candidate-action-fn))) + (if icicle-whole-candidate-as-text-prop-p + (icicle-anything-candidate-value + (completing-read (concat "Which (" (symbol-name type) "): ") candidates nil t)) + (completing-read (concat "Which (" (symbol-name type) "): ") candidates nil t))))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-req-pat-chars (type) + "Return max `required-pattern' value for sources of type TYPE. +The value returned is also always at least as big as +`icicle-Completions-display-min-input-chars'." + (let ((req-pat icicle-Completions-display-min-input-chars) + (req-pat-this-source nil)) + (dolist (source (anything-get-sources)) + (when (and (or (eq type (assoc-default 'type source)) + (string= (symbol-name type) (assoc-default 'name source))) + (setq req-pat-this-source (assoc-default 'requires-pattern source))) + (setq req-pat (max req-pat req-pat-this-source)))) + req-pat))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-input-delay (type) + "Return max `delay' value for sources of type TYPE. +The value returned is also always at least as big as +`icicle-incremental-completion-delay'." + (let ((delay icicle-incremental-completion-delay) + (delay-this-source nil)) + (dolist (source (anything-get-sources)) + (when (and (or (eq type (assoc-default 'type source)) + (string= (symbol-name type) (assoc-default 'name source))) + (setq delay-this-source (and (assoc 'delayed source) anything-idle-delay))) + (setq delay (max delay delay-this-source)))) + delay))) + +(when (> emacs-major-version 21) + (defun icicle-anything-candidate-value (candidate) + "Return the real value associated with string CANDIDATE." + (or (cdr-safe (funcall icicle-get-alist-candidate-function candidate)) candidate))) + +(when (> emacs-major-version 21) + (defun icicle-get-anything-default-actions-for-type (type) + "Set and return `icicle-candidates-alist' of default actions for type TYPE." + (setq icicle-candidates-alist ()) + (let ((all-sources-actions ()) + this-source-actions) + (dolist (source (anything-get-sources)) + (when (or (eq type (assoc-default 'type source)) + (string= (symbol-name type) (assoc-default 'name source))) + (setq this-source-actions (assoc-default 'action source)) + (unless (memq (car this-source-actions) all-sources-actions) + (push (car this-source-actions) all-sources-actions)))) + (setq icicle-candidates-alist + (sort all-sources-actions ; Must sort, or `icicle-candidate-nb' will be wrong. + #'(lambda (a1 a2) (funcall icicle-sort-comparer (car a1) (car a2)))))))) + +(defun icicle-choose-candidate-of-type (type) + "Read an object of type TYPE (a symbol) with completion, and return it. +These options, when non-nil, control buffer candidate matching and +filtering: + `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names + `icicle-buffer-extras' - Extra buffers to display + `icicle-buffer-match-regexp' - Regexp that buffers must match + `icicle-buffer-no-match-regexp' - Regexp buffers must not match + `icicle-buffer-predicate' - Predicate buffer must satisfy + `icicle-buffer-sort' - Sort function for candidates" + (let ((orig-window (selected-window))) ; For alternative actions. + (case type + (buffer + (let ((completion-ignore-case (or (and (boundp 'read-buffer-completion-ignore-case) + read-buffer-completion-ignore-case) + completion-ignore-case)) + (icicle-must-match-regexp icicle-buffer-match-regexp) + (icicle-must-not-match-regexp icicle-buffer-no-match-regexp) + (icicle-must-pass-predicate icicle-buffer-predicate) + (icicle-extra-candidates icicle-buffer-extras) + (icicle-transform-function 'icicle-remove-dups-if-extras) + (icicle-sort-comparer (or icicle-buffer-sort icicle-sort-comparer)) + (icicle-sort-orders-alist + (append (list '("by last access") ; Renamed from "turned OFF'. + '("*...* last" . icicle-buffer-sort-*...*-last) + '("by buffer size" . icicle-buffer-smaller-p) + '("by major mode name" . icicle-major-mode-name-less-p) + (and (fboundp 'icicle-mode-line-name-less-p) + '("by mode-line mode name" . icicle-mode-line-name-less-p)) + '("by file/process name" . icicle-buffer-file/process-name-less-p)) + (delete '("turned OFF") icicle-sort-orders-alist))) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-delete-candidate-object 'icicle-kill-a-buffer) ; `S-delete' kills buffer. + (icicle-require-match-flag icicle-buffer-require-match-flag) + (icicle-ignore-space-prefix-flag icicle-buffer-ignore-space-prefix-flag)) + (get-buffer-create + (completing-read "Which (buffer): " (mapcar #'(lambda (buf) (list (buffer-name buf))) + (buffer-list)) + nil + (and (fboundp 'confirm-nonexistent-file-or-buffer) ; Emacs 23. + (confirm-nonexistent-file-or-buffer)) + nil 'buffer-name-history nil nil)))) + (color (icicle-read-color 1)) ; Use the color name (only). + (command (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "command"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "command")))) + (intern (completing-read "Which (command): " obarray 'commandp)))) + (face (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "face"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "face")))) + (intern (completing-read "Which (face): " (mapcar #'(lambda (x) (list (format "%s" x))) + (face-list)))))) + (file (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "file"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "file"))) + (icicle-delete-candidate-object 'icicle-delete-file-or-directory)) ; `S-delete' + (read-file-name "Which (file): " nil + (and (eq major-mode 'dired-mode) + (fboundp 'dired-get-file-for-visit) ; Emacs 22+. + (condition-case nil ; E.g. error because not on file line (ignore) + (abbreviate-file-name (dired-get-file-for-visit)) + (error nil)))))) + (frame (let ((frame-alist (icicle-make-frame-alist)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "frame"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "frame")))) + (cdr (assoc (completing-read "Which (frame): " frame-alist) frame-alist)))) + (function (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "function"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "function")))) + (intern (completing-read "Which (function): " obarray 'fboundp)))) + (option (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "option"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "option")))) + (intern (completing-read "Which (user option): " obarray 'user-variable-p)))) + (process (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "process"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "process")))) + (get-process + (completing-read + "Which (process): " (mapcar #'(lambda (proc) (list (process-name proc))) + (process-list)))))) + (symbol (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "symbol"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "symbol")))) + (intern (completing-read "Which (symbol): " obarray)))) + (variable (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "variable"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "variable")))) + (intern (completing-read "Which (variable): " obarray 'boundp)))) + (window (let ((icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "window"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "window"))) + (buffers ())) + (walk-windows #'(lambda (win) + (push (list (format "%s" (window-buffer win))) buffers)) + nil t) + (get-buffer-window (completing-read "Window showing buffer: " buffers) 0))) + (otherwise (error "Bad object type: %S" type))))) + +(defun icicle-read-var-value-satisfying (pred) + "Read a variable that satisfies predicate PRED and returns its value." + (symbol-value + (let ((orig-window (selected-window)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "variable"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "variable")))) + (intern (completing-read (format "Which (%s value of variable): " pred) obarray + `(lambda (symb) + (and (boundp symb) + (funcall ',pred (symbol-value symb))))))))) + +;;;###autoload +(when (fboundp 'map-keymap) ; Emacs 22. + + ;; This is a quick-and-dirty definition, not an efficient one. + ;; It gathers all key bindings and then throws most of them away! Good enough. + (defun icicle-insert-char () + "Insert a character, using key completion. +Keys bound to `self-insert-command' are completion candidates." + (interactive) + (barf-if-buffer-read-only) + (let ((icicle-complete-keys-self-insert-flag t) + (icicle-must-match-regexp "^.+ = self-insert-command")) + (icicle-complete-keys))) + + (defun icicle-complete-keys () ; Bound to prefix keys followed by `S-TAB' (unless defined). + "Complete a key sequence for the currently invoked prefix key. +Input-candidate completion and cycling are available. + +You can navigate the key-binding hierarchy (prefix-key hierarchy), +just as would navigate a file-system hierarchy (to complete directory +and file names) or a menu hierarchy (to complete submenu and menu-item +names). + +Completion candidates generally have the form `KEY = COMMAND'. + +If COMMAND is `...', then KEY is a prefix key; choosing it updates the +completion candidates list to the keys under that prefix. For +example, choosing `C-x = ...' changes the candidates to those with +prefix `C-x'. + +The special candidate `..' means to go up one level of the key-binding +hierarchy and complete candidates there. For example, if you are +currently completing prefix key `C-x 5', and you choose candidate +`..', then you will be completing prefix `C-x', the parent of `C-x 5'. + +Except at the top level, the default value for completion is `..'. + +If option `icicle-complete-keys-self-insert-flag' is non-nil, then +keys bound to `self-insert-command' are included as possible +completion candidates; otherwise (the default), they are not. Command +`icicle-insert-char' works like `icicle-complete-keys', but in +includes only keys bound to `self-insert-command' - use it to insert a +character that is difficult or impossible to type with your keyboard. + +You can use `C-M-,' at any time to switch between sorting with local +bindings first and sorting with prefix keys first. You can use `C-,' +at any time to change the sort order among these two and sorting by +command name. + +While cycling, these keys describe candidates: + +`C-RET' - Describe command of current completion candidate only +`C-down' - Move to next prefix-completion candidate and describe +`C-up' - Move to previous prefix-completion candidate and describe +`C-next' - Move to next apropos-completion candidate and describe +`C-prior' - Move to previous apropos-completion candidate and describe +`C-!' - Describe *all* candidates (or all that are saved), + successively - use the [back] button in buffer *Help* to + visit the descriptions + +When candidate action and cycling are combined (e.g. `C-next'), option +`icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or +`C-g' to quit. This is an Icicles command - see command +`icicle-mode'." + (interactive) + (let* ((icicle-transform-function 'icicle-remove-duplicates) + (orig-sort-orders-alist icicle-sort-orders-alist) ; For recursive use. + (orig-show-initially-flag icicle-show-Completions-initially-flag) + (icicle-show-Completions-initially-flag t) + (icicle-candidate-action-fn 'icicle-complete-keys-action) + (enable-recursive-minibuffers t) + ;; `orig-(buff|win)-key-complete' are used free in `icicle-complete-keys-action'. + (orig-buff-key-complete (current-buffer)) + (orig-win-key-complete (selected-window)) + (icicle-completing-keys-p t) ; Provide a condition to test key completion. + (icicle-sort-comparer 'icicle-local-keys-first-p) + (icicle-alternative-sort-comparer 'icicle-prefix-keys-first-p) + (icicle-sort-orders-alist + '(("by key name, local bindings first" . icicle-local-keys-first-p) + ("by key name, prefix keys first" . icicle-prefix-keys-first-p) + ("by command name" . icicle-command-names-alphabetic-p) + ("turned OFF"))) + (icicle-hist-cands-no-highlight '(".."))) + (icicle-complete-keys-1 (icicle-this-command-keys-prefix)))) + + (defun icicle-this-command-keys-prefix () + "Return the prefix of the currently invoked key sequence." + (let ((this-key (this-command-keys))) (substring this-key 0 (1- (length this-key))))) + + ;; Free vars here: `icicle-complete-keys-alist' is bound in `icicles-var.el'. + (defun icicle-complete-keys-1 (prefix) ; PREFIX is a free var in `icicle-complete-keys-action'. + "Complete a key sequence for prefix key PREFIX (a vector)." + (let ((orig-extra-cands icicle-extra-candidates)) ; Free in `icicle-complete-keys-action'. + (unwind-protect + (progn + (icicle-keys+cmds-w-prefix prefix) + (unless icicle-complete-keys-alist (error "No keys for prefix `%s'" prefix)) + (let* ((this-cmd-keys ; For error report - e.g. mouse cmd. + (this-command-keys-vector)) ; Free var in `icicle-complete-keys-action'. + (prefix-description + (icicle-key-description prefix (not icicle-key-descriptions-use-<>-flag))) + (prompt (concat "Complete keys" (and (not (string= "" prefix-description)) + (concat " " prefix-description)) + ": "))) + (put-text-property 0 1 'icicle-fancy-candidates t prompt) + (icicle-complete-keys-action + (completing-read prompt icicle-complete-keys-alist nil t nil nil + ;;$$ (if (equal [] prefix) nil "\\.\\.") + )))) + (mapc #'(lambda (cand) (put (car cand) 'icicle-special-candidate nil)) ; Reset the property. + icicle-complete-keys-alist)))) + + ;; Free vars here: + ;; `orig-buff-key-complete' and `orig-win-key-complete' are bound in `icicle-complete-keys'. + ;; `prefix', `orig-extra-cands', and `this-cmd-keys' are bound in `icicle-complete-keys-1'. + (defun icicle-complete-keys-action (candidate) + "Completion action function for `icicle-complete-keys'." + (let* ((key+binding (cdr-safe (assq (intern candidate) icicle-complete-keys-alist))) + (key (car-safe key+binding)) + (binding (cdr-safe key+binding)) + (cmd-name nil) + (action-window (selected-window))) + (unwind-protect + (progn + (set-buffer orig-buff-key-complete) + (select-window orig-win-key-complete) + (if (string= ".." candidate) + (setq cmd-name "..") + (unless (and (string-match "\\(.+\\) = \\(.+\\)" candidate) (match-beginning 2)) + (error "No match")) + (setq cmd-name (substring candidate (match-beginning 2) (match-end 2)))) + (cond ((string= ".." cmd-name) ; Go back up to parent prefix. + (setq last-command 'icicle-complete-keys) + (icicle-complete-keys-1 (vconcat (nbutlast (append prefix nil))))) + ((and key (string= "..." cmd-name)) ; Go down to prefix. + (setq last-command 'icicle-complete-keys) + (icicle-complete-keys-1 (vconcat prefix key))) + (t + (setq this-command binding + last-command binding + icicle-extra-candidates orig-extra-cands) ; Restore it. + (when (eq 'self-insert-command binding) + (unless key (error "Cannot insert `%s'" key)) + (setq last-command-char (aref key 0))) + (when (eq 'digit-argument binding) + (setq last-command-char (aref key 0)) + (icicle-msg-maybe-in-minibuffer "Numeric argument")) + (when (eq 'negative-argument binding) + (icicle-msg-maybe-in-minibuffer "Negative argument")) + (setq last-nonmenu-event 1) ; So *Completions* mouse-click info is ignored. + (condition-case try-command ; Bind so vanilla context when invoke chosen cmd. + (let ((icicle-show-Completions-initially-flag orig-show-initially-flag) + (icicle-candidate-action-fn nil) + (icicle-completing-keys-p nil) + (icicle-sort-orders-alist orig-sort-orders-alist) + (icicle-sort-comparer 'icicle-case-string-less-p) + (icicle-alternative-sort-comparer + 'icicle-historical-alphabetic-p)) + (call-interactively binding nil this-cmd-keys)) + (error (error (error-message-string try-command))))))) + (select-window action-window)))) + + (defun icicle-keys+cmds-w-prefix (prefix) + "Fill `icicle-complete-keys-alist' for prefix key PREFIX (a vector)." + (let ((prefix-map nil)) + (setq icicle-complete-keys-alist ()) + (dolist (map (current-active-maps t)) + (setq prefix-map (lookup-key map prefix)) + ;; NOTE: `icicle-add-key+cmd' uses `prefix' and `map' as free vars. + (when (keymapp prefix-map) (map-keymap #'icicle-add-key+cmd prefix-map))) + (unless (equal [] prefix) + (push (list (intern (propertize ".." 'face 'icicle-multi-command-completion))) + icicle-complete-keys-alist)) + icicle-complete-keys-alist)) + + ;; Free vars here: `prefix' and `map' are bound in `icicle-keys+cmds-w-prefix'. + (defun icicle-add-key+cmd (event binding) + "Add completion for EVENT and BINDING to `icicle-complete-keys-alist'." + (cond + ;; (menu-item ITEM-STRING): non-selectable item - skip it. + ((and (eq 'menu-item (car-safe binding)) + (null (cdr-safe (cdr-safe binding)))) + (setq binding nil)) ; So `keymapp' test, below, fails. + + ;; (ITEM-STRING): non-selectable item - skip it. + ((and (stringp (car-safe binding)) (null (cdr-safe binding))) + (setq binding nil)) ; So `keymapp' test, below, fails. + + ;; (menu-item ITEM-STRING REAL-BINDING . PROPERTIES) + ((eq 'menu-item (car-safe binding)) + (let ((enable-condition (memq ':enable (cdr-safe (cdr-safe (cdr-safe binding)))))) + (if (or (not enable-condition) + (condition-case nil ; Don't enable if we can't check the condition. + (eval (cadr enable-condition)) + (error nil))) + (setq binding (car-safe (cdr-safe (cdr-safe binding)))) + (setq binding nil)))) + + ;; (ITEM-STRING . REAL-BINDING) or + ;; (ITEM-STRING [HELP-STRING] . REAL-BINDING) or + ;; (ITEM-STRING [HELP-STRING] (KEYBD-SHORTCUTS) . REAL-BINDING) + ((stringp (car-safe binding)) + (setq binding (cdr binding)) + ;; Skip HELP-STRING + (when (stringp (car-safe binding)) (setq binding (cdr binding))) + ;; Skip (KEYBD-SHORTCUTS): cached key-equivalence data for menu items. + (when (and (consp binding) (consp (car binding))) (setq binding (cdr binding))))) + + ;; Follow indirections to ultimate symbol naming a command. + (while (and (symbolp binding) (fboundp binding) (keymapp (symbol-function binding))) + (setq binding (symbol-function binding))) + + ;; `prefix' and `map' are free here, bound in `icicle-keys+cmds-w-prefix'. + (cond ((and (or (keymapp binding) + (and (commandp binding) + (equal binding (key-binding (vconcat prefix (vector event)))) + (not (eq binding 'icicle-complete-keys)))) + (or (not (eq binding 'self-insert-command)) ; Command, keymap. + (and icicle-complete-keys-self-insert-flag ; Insert normal char. + (char-valid-p event)))) + (let* ((key-desc (propertize (single-key-description + event + (not icicle-key-descriptions-use-<>-flag)) + 'face 'icicle-candidate-part)) + (candidate (intern (concat key-desc " = " (if (keymapp binding) + "..." + (prin1-to-string binding)))))) + ;; Skip keys bound to `undefined'. + (unless (string= "undefined" (prin1-to-string binding)) + (push (cons candidate (cons (vector event) binding)) icicle-complete-keys-alist)) + (when (eq map (current-local-map)) (put candidate 'icicle-special-candidate t)))) + ((and (integerp event) (generic-char-p event) ; Insert generic char. + (eq 'self-insert-command binding)) + (ignore)))) ; Placeholder for future use. + + ;; $$ No longer used. Was used in `icicle-complete-keys-1'. + (defun icicle-read-single-key-description (string need-vector &optional no-angles) + "If STRING contains a space, then the vector containing the symbol named STRING. +Otherwise, call `icicle-read-kbd-macro'. +Other args are as for `icicle-read-kbd-macro'." + (cond ((and no-angles (string-match " " string)) (vector (intern string))) + ((string-match "^<\\([^>]* [^>]*\\)>" string) + (vector (intern (substring string (match-beginning 1) (match-end 1))))) + (t (icicle-read-kbd-macro string need-vector no-angles)))) + + ;; $$ No longer used. Was used as `icicle-candidate-action-fn' in `icicle-complete-keys'. + (defun icicle-complete-keys-help (candidate) + "Describe the command associated with the current completion candidate." + (interactive) ; Interactively, just describes itself. + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (string-match "\\(.+\\) = \\(.+\\)" candidate) + (let ((frame-with-focus (selected-frame)) + (cmd (intern-soft (substring candidate (match-beginning 2) (match-end 2))))) + (if (not (fboundp cmd)) + (icicle-msg-maybe-in-minibuffer "No help") + (describe-function cmd)) + (icicle-raise-Completions-frame) + ;; This is a hack for MS Windows - otherwise, we can't continue to get more candidates, + ;; because the *Help* frame takes the focus away from the minibuffer frame. + ;; MS Windows always gives focus to a newly created frame - in this case, *Help*. + (let* ((help-window (get-buffer-window "*Help*" 0)) + (help-frame (and help-window (window-frame help-window)))) + (when help-frame (redirect-frame-focus help-frame frame-with-focus)))) + (message nil)) ; Let minibuffer contents show immmediately. + + (defun icicle-read-kbd-macro (start &optional end no-angles) + "Read the region as a keyboard macro definition. +The region is interpreted as spelled-out keystrokes, e.g., \"M-x abc RET\". +See documentation for `edmacro-mode' for details. +Leading/trailing \"C-x (\" and \"C-x )\" in the text are allowed and ignored. +The resulting macro is installed as the \"current\" keyboard macro. + +In Lisp, may also be called with a single STRING argument in which case +the result is returned rather than being installed as the current macro. +The result will be a string if possible, otherwise an event vector. +Second argument NEED-VECTOR means to return an event vector always. + +Optional argument NO-ANGLES non-nil means to expect key +descriptions not to use angle brackets (<...>). For example: + + (icicle-read-kbd-macro \"\" t) returns [mode-line] + (icicle-read-kbd-macro \"mode-line\" t t) returns [mode-line]" + (interactive "r") + (if (stringp start) + (icicle-edmacro-parse-keys start end no-angles) + (setq last-kbd-macro + (icicle-edmacro-parse-keys (buffer-substring start end) nil no-angles)))) + + (defun icicle-edmacro-parse-keys (string &optional need-vector no-angles) + "Same as `edmacro-parse-keys', but with added NO-ANGLES argument. +NO-ANGLES is the same as for `icicle-read-kbd-macro'." + (let ((case-fold-search nil) + (pos 0) + (res [])) + (while (and (< pos (length string)) + (string-match "[^ \t\n\f]+" string pos)) + (let ((word (substring string (match-beginning 0) (match-end 0))) + (key nil) + (times 1)) + (setq pos (match-end 0)) + (when (string-match "\\([0-9]+\\)\\*." word) + (setq times (string-to-number (substring word 0 (match-end 1))) + word (substring word (1+ (match-end 1))))) + (cond ((string-match "^<<.+>>$" word) + (setq key (vconcat (if (eq (key-binding [?\M-x]) + 'execute-extended-command) + [?\M-x] + (or (car (where-is-internal + 'execute-extended-command)) + [?\M-x])) + (substring word 2 -2) "\r"))) + ((or (equal word "REM") (string-match "^;;" word)) + (setq pos (string-match "$" string pos))) + ((and (string-match (if no-angles + "^\\(\\([ACHMsS]-\\)*\\)\\(..+\\)$" + "^\\(\\([ACHMsS]-\\)*\\)<\\(..+\\)>$") + word) + (or (not no-angles) + (save-match-data (not (string-match "^\\([ACHMsS]-.\\)+$" word)))) + (progn + (setq word (concat (substring word (match-beginning 1) + (match-end 1)) + (substring word (match-beginning 3) + (match-end 3)))) + (not (string-match + "\\<\\(NUL\\|RET\\|LFD\\|ESC\\|SPC\\|DEL\\)$" + word)))) + (setq key (list (intern word)))) + (t + (let ((orig-word word) + (prefix 0) + (bits 0)) + (while (string-match "^[ACHMsS]-." word) + (incf bits (cdr (assq (aref word 0) + '((?A . ?\A-\^@) (?C . ?\C-\^@) + (?H . ?\H-\^@) (?M . ?\M-\^@) + (?s . ?\s-\^@) (?S . ?\S-\^@))))) + (incf prefix 2) + (callf substring word 2)) + (when (string-match "^\\^.$" word) + (incf bits ?\C-\^@) + (incf prefix) + (callf substring word 1)) + (let ((found (assoc word '(("NUL" . "\0") ("RET" . "\r") + ("LFD" . "\n") ("TAB" . "\t") + ("ESC" . "\e") ("SPC" . " ") + ("DEL" . "\177"))))) + (when found (setq word (cdr found)))) + (when (string-match "^\\\\[0-7]+$" word) + (loop for ch across word + for n = 0 then (+ (* n 8) ch -48) + finally do (setq word (vector n)))) + (cond ((= bits 0) + (setq key word)) + ((and (= bits ?\M-\^@) (stringp word) + (string-match "^-?[0-9]+$" word)) + (setq key (loop for x across word collect (+ x bits)))) + ((/= (length word) 1) + (error "%s must prefix a single character, not %s" + (substring orig-word 0 prefix) word)) + ((and (/= (logand bits ?\C-\^@) 0) (stringp word) + ;; We used to accept . and ? here, + ;; but . is simply wrong, + ;; and C-? is not used (we use DEL instead). + (string-match "[@-_a-z]" word)) + (setq key (list (+ bits (- ?\C-\^@) (logand (aref word 0) 31))))) + (t + (setq key (list (+ bits (aref word 0))))))))) + (when key + (loop repeat times do (callf vconcat res key))))) + (when (and (>= (length res) 4) + (eq (aref res 0) ?\C-x) + (eq (aref res 1) ?\() + (eq (aref res (- (length res) 2)) ?\C-x) + (eq (aref res (- (length res) 1)) ?\))) + (setq res (edmacro-subseq res 2 -2))) + (if (and (not need-vector) + (loop for ch across res + always (and (char-valid-p ch) + (let ((ch2 (logand ch (lognot ?\M-\^@)))) + (and (>= ch2 0) (<= ch2 127)))))) + (concat (loop for ch across res + collect (if (= (logand ch ?\M-\^@) 0) + ch (+ ch 128)))) + res)))) + +;;;###autoload +(when (fboundp 'define-minor-mode) ; Emacs 21+ ------------ + (eval '(define-minor-mode icicle-ido-like-mode + "Ido-like mode for use with Icicles. +No, this mode does not pretend to give you exactly the Ido behavior. + +Turning the mode ON sets these options to t: + `icicle-show-Completions-initially-flag' + `icicle-top-level-when-sole-completion-flag' +Turning the mode OFF sets those options to non-nil. + +A positive prefix arg turns the mode on and also sets option +`icicle-max-candidates' to the prefix-arg numeric value. By default, +that option is nil, meaning that there is no limit to the number of +completion candidates. + +Since Ido shows only a few completion candidates, you might want to +customize that option or use a prefix arg with this mode to set it. +You can also use `C-x #' in the minibuffer to increment or decrement +the option at any time during completion. + +Turning the mode off by toggling (no prefix arg) resets option +`icicle-max-candidates' to nil. If you have customized that option to +a non-nil value and do not want to lose that preference, then use a +zero or negative prefix arg to turn the mode off. + +See also these options, which control how much time you have to edit +input before automatic incremental completion and automatic acceptance +of a sole candidate kick in: + + `icicle-incremental-completion-delay' + `icicle-top-level-when-sole-completion-delay' + +When you use this mode, you might also want to use nil or t as the +value of option `icicle-default-value', in order to not insert the +default value in the minibuffer. If you want to change that option +dynamically for the mode, use `icicle-ido-like-mode-hook'. E.g.: + + (add-hook 'icicle-ido-like-mode-hook + (lambda () (setq icicle-default-value + (if icicle-ido-like-mode t 'insert-end))))" + nil nil nil :global t :group 'Icicles-Miscellaneous + (setq + icicle-show-Completions-initially-flag icicle-ido-like-mode + icicle-top-level-when-sole-completion-flag icicle-ido-like-mode) + (if icicle-ido-like-mode + (when (and current-prefix-arg (not (eq 'toggle current-prefix-arg))) + (setq icicle-max-candidates (prefix-numeric-value current-prefix-arg))) + (unless (and current-prefix-arg (not (eq 'toggle current-prefix-arg))) + (setq icicle-max-candidates nil)))))) + +;; See also `hexrgb-read-color' in `hexrgb.el'. +;;;###autoload +(defun icicle-read-color (&optional arg prompt) + "Read a color name or hex RGB color value #RRRRGGGGBBBB. +A string value is returned. +Interactively, optional argument ARG is the prefix arg. +Optional argument PROMPT is the prompt to use (default \"Color: \"). + +In addition to standard color names and RGB (red, green, blue) hex +values, the following are also available as proxy color candidates, +provided `icicle-add-proxy-candidates-flag' is non-nil and library +`palette.el' or `eyedropper.el' is used. In each case, the +corresponding color is used. + +* `*copied foreground*' - last copied foreground, if available +* `*copied background*' - last copied background, if available +* `*mouse-2 foreground*' - foreground where you click `mouse-2' +* `*mouse-2 background*' - background where you click `mouse-2' +* `*point foreground*' - foreground under the text cursor +* `*point background*' - background under the text cursor + +\(You can copy a color using eyedropper commands such as +`eyedrop-pick-foreground-at-mouse'.) + +In addition, the names of user options (variables) whose custom type +is `color' are also proxy candidates, but with `'' as a prefix and +suffix. So, for example, option `icicle-region-background' appears as +proxy color candidate `'icicle-region-background''. + +As always, you can toggle the use of proxy candidates using `\\\ +\\[icicle-toggle-proxy-candidates]' in +the minibuffer. + +With plain `C-u', use `hexrgb-read-color', which lets you complete a +color name or input any valid RGB hex value (without completion). + +With no prefix arg, return a string with both the color name and the +RGB value, separated by `icicle-list-nth-parts-join-string'. + +With a numeric prefix arg of 0 or 1, return the color name. With any +other numeric prefix arg, return the RGB value. + +In the plain `C-u' case, your input is checked to ensure that it +represents a valid color. + +In all other cases: + +- You can complete your input against the color name, the RGB value, + or both. + +- If you enter input without completing or cycling, the input is not + checked: whatever is entered is returned as the string value. + +From Emacs Lisp, ARG controls what is returned. If ARG is nil, +`icicle-list-use-nth-parts' can also be used to control the behavior. + +Note: Duplicate color names are removed by downcasing and removing +whitespace. For example, \"AliceBlue\" and \"alice blue\" are both +treated as \"aliceblue\". Otherwise, candidates with different names +but the same RGB values are not considered duplicates, so, for +example, input can match either \"darkred\" or \"red4\", which both +have RGB #8b8b00000000. You can toggle duplicate removal at any time +using `C-$'. + +During completion, candidate help (e.g. `C-M-RET') shows you the RGB +and HSV (hue, saturation, value) color components. + +This command is intended only for use in Icicle mode (but it can be +used with `C-u', with Icicle mode turned off)." + (interactive "P") + (unless (featurep 'hexrgb) (error "`icicle-read-color' requires library `hexrgb.el'")) + (let (color) + (if (consp arg) ; Plain `C-u': complete against color name only, + (setq color (hexrgb-read-color t)) ; and be able to input any valid RGB string. + + ;; Complete against name+RGB pairs, but user can enter invalid value without completing. + (let ((icicle-list-use-nth-parts + (or (and arg (if (< arg 2) '(1) '(2))) ; 1 or 2, by program or via `C-1' or `C-2'. + icicle-list-use-nth-parts ; Bound externally by program. + '(1 2))) ; Both parts, by default. + (mouse-pseudo-color-p nil) + + icicle-candidate-help-fn completion-ignore-case + icicle-transform-function icicle-sort-orders-alist + icicle-list-nth-parts-join-string icicle-list-join-string + icicle-list-end-string icicle-proxy-candidate-regexp + named-colors icicle-proxy-candidates) + ;; Copy the prompt string because `icicle-color-completion-setup' puts a text prop on it. + (setq prompt (copy-sequence (or prompt "Color: "))) + (icicle-color-completion-setup) + (setq icicle-proxy-candidates + (append icicle-proxy-candidates + (mapcar ; Convert multi-completions to strings. + #'(lambda (entry) + (concat (mapconcat #'identity (car entry) icicle-list-join-string) + icicle-list-end-string)) + '((("*mouse-2 foreground*")) (("*mouse-2 background*"))))) + color (icicle-transform-multi-completion + (let ((orig-window (selected-window)) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn + (icicle-alt-act-fn-for-type "color"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn + (icicle-alt-act-fn-for-type "color")))) + (completing-read prompt named-colors)))) + (when (fboundp 'eyedrop-foreground-at-point) + (cond ((string-match "^\*mouse-2 foreground\*" color) + (setq color (prog1 (eyedrop-foreground-at-mouse + (read-event + "Click `mouse-2' anywhere to choose foreground color")) + (read-event)) ; Discard mouse up event. + mouse-pseudo-color-p t)) + ((string-match "^\*mouse-2 background\*" color) + (setq color (prog1 (eyedrop-background-at-mouse + (read-event + "Click `mouse-2' anywhere to choose background color")) + (read-event)) ; Discard mouse up event. + mouse-pseudo-color-p t)))) + (when mouse-pseudo-color-p + (let ((icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts + (or (and arg (if (< arg 2) '(1) '(2))) ; 1 or 2, by program or via `C-1' or `C-2'. + icicle-list-use-nth-parts ; Bound externally by program. + '(1 2)))) ; Both parts, by default. + (setq color (icicle-transform-multi-completion + (concat color ": " (hexrgb-color-name-to-hex color)))))))) + (when (interactive-p) (message "Color: `%s'" color)) + color)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-cmd2) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-cmd2.el ends here diff --git a/.emacs.d/icicles/icicles-doc1.el b/.emacs.d/icicles/icicles-doc1.el new file mode 100644 index 0000000..cad1c1f --- /dev/null +++ b/.emacs.d/icicles/icicles-doc1.el @@ -0,0 +1,6617 @@ +;;; icicles-doc1.el --- Minibuffer input completion and cycling. +;; +;; Filename: icicles-doc1.el +;; Description: Minibuffer completion and cycling. +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Tue Aug 1 14:21:16 1995 +;; Version: 22.0 +;; Last-Updated: Tue Jul 20 13:52:44 2010 (-0700) +;; By: dradams +;; Update #: 25344 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-doc1.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: +;; +;; None +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; Icicles documentation, part 1. +;; +;; Files `icicles-doc1.el' and `icicles-doc2.el' contain the doc for +;; Icicles, including how to install and use Icicles. You can also +;; read the Icicles doc, in formatted form, on the Emacs-Wiki Web +;; site: http://www.emacswiki.org/cgi-bin/wiki/Icicles. Emacs Wiki +;; also has a few addtional pages about Icicles. In particular, if +;; you are new to Emacs, as well as Icicles, see this page: +;; http://www.emacswiki.org/cgi-bin/wiki/EmacsNewbieWithIcicles. + +;;(@* "Installing Icicles") +;; +;; To use this library: +;; +;; Add this to your initialization file (~/.emacs or ~/_emacs): +;; +;; (require 'icicles) ; Load this library. +;; (icicle-mode 1) ; Turn on Icicle mode. +;; +;; It is best to add this code *after* any code that creates or +;; changes key bindings, so Icicles can pick up all of your key +;; definitions (bindings). However, if you make new bindings, you +;; can always exit and then reenter Icicle mode to pick them up. +;; +;; You will need all of these libraries (loaded by `icicles.el'): +;; +;; `icicles-chg.el' (not loaded - change logs only) +;; `icicles-cmd1.el' +;; `icicles-cmd2.el' +;; `icicles-doc1.el' (not loaded - doc only) +;; `icicles-doc2.el' (not loaded - doc only) +;; `icicles-face.el' +;; `icicles-fn.el' +;; `icicles-mac.el' +;; `icicles-mcmd.el' +;; `icicles-mode.el' +;; `icicles-opt.el' +;; `icicles-var.el' +;; +;; The following libraries are optional (loaded by `icicles.el' if +;; in your `load-path'), but recommended. They are all available +;; at Emacs Wiki, http://www.emacswiki.org/cgi-bin/wiki/ElispArea. +;; +;; `bookmark+.el' - many bookmark enhancements +;; `col-highlight.el' - (required by `crosshairs.el') - Emacs 22+ +;; `crosshairs.el' - highlight target positions - Emacs 22+ +;; `hexrgb.el' - color manipulation +;; `hl-line+.el' - (required by `crosshairs.el') - Emacs 22+ +;; `icomplete+.el' - enhancements to `icomplete.el' +;; `lacarte.el' - keyboard access to the menubar menus +;; `vline.el' - (required by `crosshairs.el') - Emacs 22+ +;; +;; Depending on your platform, if you use Icicles in a text +;; terminal (that is, without a window system/manager), then you +;; might need to change some of the key bindings, if some of the +;; default bindings are not available to you. +;; +;; If on your platform, for example, Emacs in a text terminal does +;; not recognize a key such as `S-TAB' (as something different from +;; `TAB'), then you will want to change that key binding. To +;; customize Icicles key bindings, see +;; (@file :file-name "icicles-doc2.el" :to "Customizing Key Bindings"). +;; You might also want to customize some of the Icicles faces, +;; since a text terminal is sometimes limited in the colors it can +;; handle. +;; +;; It is of course best to byte-compile all of the libraries +;; (except `icicle-chg.el', `icicles-doc1.el', and +;; `icicles-doc2.el'). 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'. +;; +;; After startup, you can turn Icicle mode on or off at any time +;; interactively, using command `icy-mode' (aka `icicle-mode' - +;; prefix `icy' is unique to this command, so it is easier to +;; complete). +;; +;; Note: If you turn on Icicle mode in your init file, it's +;; generally best to do so as late as possible - after you or any +;; libraries that you load do any key binding. This is because +;; Icicles uses the current global key bindings to determine which +;; keys to bind for minibuffer completion and cycling. To pick up +;; the latest bindings at any time, you can of course enter Icicle +;; mode interactively using command `icy-mode' (if necessary, exit, +;; then re-enter). +;; +;; Note: Icicles redefines some functions when you are in Icicle +;; mode (it restores them when you leave Icicle mode). It +;; generally does not use `defadvice' to alter the functions; it +;; redefines them instead. Because of this, there can be +;; incompatibilities with other libraries that also change the same +;; functions (using `defadvice' or otherwise). An example is Viper +;; mode. If you load Viper before Icicles, then you will run into +;; problems with function `read-file-name' because it is tweaked by +;; both Viper and Icicles. If you load Icicles before Viper, you +;; should not encounter this problem (but you might encounter other +;; problems: both Icicles and Viper try to control the minibuffer). + +;;(@* "Index") +;; +;; 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 and render it more readable. Likewise, for +;; the cross-references and section headings throughout this file. +;; You can get `linkd.el' here: +;; http://www.emacswiki.org/cgi-bin/wiki/linkd.el. +;; +;; (@* "Documentation in File `icicles-doc1.el'") +;; ---------------------------------------------- +;; +;; (@> "Nutshell View of Icicles") +;; (@> "README for Non-Readers") +;; (@> "Toggle Options on the Fly") +;; (@> "Cycle Completion Candidates") +;; (@> "Display Completion Candidates") +;; (@> "Prefix Completion and Apropos Completion") +;; (@> "Chains of Simple Match Patterns - Progressive Completion") +;; (@> "Chip Away the Non-Elephant") +;; (@> "Choose Before You Act") +;; (@> "Help on Completion Candidates") +;; (@> "Perform Multiple Operations in One Command") +;; (@> "Perform Alternative Operations on the Fly") +;; (@> "Completion Status Indicators") +;; (@> "Icicles Search") +;; (@> "Complete Key Sequences Too") +;; (@> "Available for Almost Any Input") +;; (@> "Component Icicles Libraries") +;; (@> "If You Are an Emacs-Lisp Programmer") +;; +;; (@> "Inserting Text Found Near the Cursor") +;; (@> "Background on Vanilla Emacs Input Completion") +;; (@> "Cycling Completions") +;; (@> "Traversing Minibuffer Histories") +;; (@> "Apropos Completions") +;; (@> "Expanded-Common-Match Completion") +;; (@> "Progressive Completion") +;; (@> "`M-*': Matching Additional Regexps") +;; (@> "Successive Approximation...") +;; (@> "`M-&': Satisfying Additional Predicates") +;; +;; (@> "Regressive Completion") +;; (@> "Completion On Demand") +;; (@> "Moving Between the Minibuffer and Other Buffers") +;; (@> "Inserting a Regexp from a Variable or Register") +;; (@> "Special Characters in Input Patterns") +;; (@> "Exiting the Minibuffer Without Confirmation") +;; (@> "Ido and IswitchB") +;; (@> "*Completions* Display") +;; (@> "Icompletion") +;; (@> "icomplete+.el Displays the Number of Other Prefix Candidates") +;; (@> "Icicles Highlights the Input that Won't Complete") +;; (@> "Icompletion in *Completions*: Apropos and Prefix Completion") +;; +;; (@> "Sorting Candidates and Removing Duplicates") +;; (@> "Changing the Sort Order") +;; (@> "Defining New Sort Orders") +;; (@> "Different Sorts for Different Sorts of Uses") +;; (@> "Get Help on Candidates") +;; (@> "Use Candidate Help Like You Use Emacs Command `apropos'") +;; (@> "Other Icicles Apropos Commands") +;; +;; (@> "Multi-Commands") +;; (@> "What Is a Multi-Command?") +;; (@> "How Does a Multi-Command Work?") +;; +;; (@> "More about Multi-Commands") +;; (@> "Alternative Actions") +;; (@> "Deleting Objects") +;; (@* "Option `icicle-use-C-for-actions-flag'") +;; (@* "Accessing Saved Locations (Bookmarks) on the Fly") +;; +;; (@> "Icicles Tripping") +;; (@> "Highlighting the Destination") +;; +;; (@> "Key Completion") +;; (@> "Completing Keys") +;; (@> "`S-TAB' Is Everywhere - Start With It") +;; (@> "Completing Keys By Name") +;; (@> "Completing Prefix Keys") +;; (@> "Meta Key Bindings") +;; (@> "Navigate the Key-Binding Hierarchy") +;; (@> "Local Bindings Are Highlighted") +;; (@> "Completing Keys By Just Hitting Them") +;; (@> "Key and Command Help") +;; (@> "`S-TAB' Is a Multi-Command") +;; (@> "Possible Source of Confusion") +;; (@> "Three-Key Emacs") +;; (@> "Entering Special and Foreign Characters") +;; (@> "Handling Keymaps That Are Inaccessible From the Global Map") +;; +;; (@> "Icicles Multi `M-x'") +;; (@> "Examples of Using Multi `M-x'") +;; (@> "What about describe-variable and describe-function?") +;; (@> "Multi `M-x' Turns Every Command into a Multi-Command") +;; +;; (@> "Choose All Completion Candidates") +;; (@> "Sets of Completion Candidates") +;; (@> "Saving and Retrieving Completion Candidates") +;; (@> "Different Places for Saving and Retrieving Candidates") +;; (@> "Set Operations") +;; (@> "Google Matching") +;; (@> "Domain of Discourse") +;; (@> "Global Filtering") +;; (@> "Word Matching and String Matching") +;; (@> "AND Matching and OR Matching") +;; (@> "NOT Matching") +;; +;; (@> "File-Name Input and Locating Files Anywhere") +;; (@> "Function `read-file-name'") +;; (@> "Function `completing-read'") +;; (@> "Icicles Commands that Read File Names") +;; (@> "Absolute File Names and Different Directories") +;; +;; (@> "Persistent Sets of Completion Candidates") +;; (@> "Saving Candidates in Cache Files") +;; (@> "Filesets and Icicles Saved Completion Sets") +;; (@> "Improving Performance with Persistent Sets") +;; (@> "Avoid Remote File-Name Completion") +;; (@> "Avoid Generating A Large Completion Set") +;; +;; (@> "Dealing With Large Candidate Sets") +;; (@> "History Enhancements") +;; (@> "What Input, What History?") +;; (@> "Overview of Minibuffer History Enhancements") +;; (@> "Using Completion to Insert Previous Inputs: `M-o'") +;; (@> "Putting Previous Candidates First: `C-M-,'") +;; (@> "Matching Only Historical Candidates: `M-h' and `M-pause'") +;; (@> "Using Other Histories; Commands Any Which Way") +;; (@> "Completing Against All Interactive Commands") +;; (@> "Using an Alternative History") +;; (@> "Cleaning Up History Lists") +;; +;; (@> "Isearch Enhancements") +;; (@> "Launch Occur using the Isearch Search String") +;; (@> "Launch Icicles Search using the Isearch Search String") +;; +;; (@file :file-name "icicles-doc2.el" :to "Documentation in File `icicles-doc2.el'") +;; ----------------------------------------------------------- +;; +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; (@file :file-name "icicles-doc2.el" :to "Introduction: On Beyond Occur...") +;; (@file :file-name "icicles-doc2.el" :to "How Icicles Search Works") +;; (@file :file-name "icicles-doc2.el" :to "Why Use 2 Search Patterns?") +;; (@file :file-name "icicles-doc2.el" :to "Search Multiple Buffers, Files, and Bookmarks") +;; (@file :file-name "icicles-doc2.el" :to "User Options for Icicles Searching") +;; (@file :file-name "icicles-doc2.el" :to "Using Regexps with Icicles Search") +;; +;; (@file :file-name "icicles-doc2.el" :to "Search and Replace") +;; (@file :file-name "icicles-doc2.el" :to "Other Icicles Search Commands") +;; (@file :file-name "icicles-doc2.el" :to "Icicles Imenu") +;; (@file :file-name "icicles-doc2.el" :to "`icicle-imenu' Combines Benefits of Imenu and Emacs Tags") +;; +;; (@file :file-name "icicles-doc2.el" :to "Compile/Grep Search") +;; (@file :file-name "icicles-doc2.el" :to "Input Reuse in Interactive Interpreter Modes") +;; (@file :file-name "icicles-doc2.el" :to "Define Your Own Icicles Search Commands") +;; +;; (@file :file-name "icicles-doc2.el" :to "Icicles Bookmark Enhancements") +;; (@file :file-name "icicles-doc2.el" :to "Saving Regions and Selecting Them") +;; (@file :file-name "icicles-doc2.el" :to "Setting a Bookmark and Jumping to a Bookmark") +;; (@file :file-name "icicles-doc2.el" :to "Jumping to a Bookmark") +;; (@file :file-name "icicles-doc2.el" :to "Searching Bookmarked Objects") +;; (@file :file-name "icicles-doc2.el" :to "Icicles Tags Enhancements") +;; (@file :file-name "icicles-doc2.el" :to "`icicle-find-tag': Find Tags in All Tags Tables") +;; (@file :file-name "icicles-doc2.el" :to "`icicle-find-first-tag': Find First Tag in Current Table") +;; (@file :file-name "icicles-doc2.el" :to "`icicle-tags-search': Search and Replace Using Tags") +;; +;; (@file :file-name "icicles-doc2.el" :to "Icicles Shell-Command Enhancements") +;; (@file :file-name "icicles-doc2.el" :to "Icicles Dired Enhancements") +;; (@file :file-name "icicles-doc2.el" :to "Shell Commands on Marked Files") +;; (@file :file-name "icicles-doc2.el" :to "Search-and-Replace Marked Files") +;; (@file :file-name "icicles-doc2.el" :to "Save Marked Files as Completion Candidates") +;; (@file :file-name "icicles-doc2.el" :to "Open Dired for a Set of File Names") +;; (@file :file-name "icicles-doc2.el" :to "Marked Files as a Project") +;; +;; (@file :file-name "icicles-doc2.el" :to "Icicles Info Enhancements") +;; (@file :file-name "icicles-doc2.el" :to "Icicles Completion for Info") +;; (@file :file-name "icicles-doc2.el" :to "Virtual Info Books") +;; +;; (@file :file-name "icicles-doc2.el" :to "Using Icicle-Search With Info") +;; +;; (@file :file-name "icicles-doc2.el" :to "Support for Projects") +;; (@file :file-name "icicles-doc2.el" :to "Bookmarks for Project Access and Organization") +;; (@file :file-name "icicles-doc2.el" :to "A Tags File Can Define a Project") +;; (@file :file-name "icicles-doc2.el" :to "Navigating Among Code Definitions") +;; (@file :file-name "icicles-doc2.el" :to "Searching Project Files") +;; (@file :file-name "icicles-doc2.el" :to "Defining and Saving Sets of Files or Buffers") +;; (@file :file-name "icicles-doc2.el" :to "Retrieving and Reusing a Saved Project") +;; (@file :file-name "icicles-doc2.el" :to "Semantics? Roll Your Own?") +;; +;; (@file :file-name "icicles-doc2.el" :to "Using Complex Completion Candidates") +;; (@file :file-name "icicles-doc2.el" :to "Icicles OO: Object-Action Interaction") +;; (@file :file-name "icicles-doc2.el" :to "Apropos Completion as OO") +;; (@file :file-name "icicles-doc2.el" :to "M-RET") +;; (@file :file-name "icicles-doc2.el" :to "`icicle-object-action' and `icicle-anything'") +;; (@file :file-name "icicles-doc2.el" :to "Icicles with Anything") +;; +;; (@file :file-name "icicles-doc2.el" :to "Multi-Completions") +;; (@file :file-name "icicles-doc2.el" :to "Icicles Multi-Completion Commands") +;; (@file :file-name "icicles-doc2.el" :to "How Multi-Completions Work") +;; (@file :file-name "icicles-doc2.el" :to "Multi-Completions vs `completing-read-multiple'") +;; +;; (@file :file-name "icicles-doc2.el" :to "Dot, Dot, Dot") +;; (@file :file-name "icicles-doc2.el" :to "Fuzzy Completion") +;; (@file :file-name "icicles-doc2.el" :to "Partial Completion") +;; (@file :file-name "icicles-doc2.el" :to "Scatter-Match Completion") +;; (@file :file-name "icicles-doc2.el" :to "Swank (Fuzzy Symbol) Completion") +;; (@file :file-name "icicles-doc2.el" :to "Fuzzy-Match Completion") +;; +;; (@file :file-name "icicles-doc2.el" :to "Completion in Other Buffers") +;; (@file :file-name "icicles-doc2.el" :to "Dynamic Abbreviation") +;; (@file :file-name "icicles-doc2.el" :to "BBDB Completion") +;; (@file :file-name "icicles-doc2.el" :to "Thesaurus Completion") +;; (@file :file-name "icicles-doc2.el" :to "Completion in Comint Modes") +;; +;; (@file :file-name "icicles-doc2.el" :to "Customization and General Tips") +;; (@file :file-name "icicles-doc2.el" :to "Using Icicles with Delete Selection Mode") +;; (@file :file-name "icicles-doc2.el" :to "Icicles User Options and Faces") +;; +;; (@file :file-name "icicles-doc2.el" :to "File-Name and Directory-Name Completion Tips") +;; (@file :file-name "icicles-doc2.el" :to "Key Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Global Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Icicles-Mode Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Minibuffer Bindings") +;; +;; (@file :file-name "icicles-doc2.el" :to "Customizing Key Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Customizing Global Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Customizing Icicle Mode Bindings") +;; (@file :file-name "icicles-doc2.el" :to "Customizing Minibuffer Bindings") +;; +;; (@file :file-name "icicles-doc2.el" :to "Icicles Redefines Some Standard Commands") +;; (@file :file-name "icicles-doc2.el" :to "Programming with Fancy Candidates") +;; (@file :file-name "icicles-doc2.el" :to "Programming Multi-Completions") +;; (@file :file-name "icicles-doc2.el" :to "Variable icicle-list-use-nth-parts") +;; (@file :file-name "icicles-doc2.el" :to "Variable icicle-candidate-properties-alist") +;; (@file :file-name "icicles-doc2.el" :to "What You See Is Not What You Get") +;; +;; (@file :file-name "icicles-doc2.el" :to "Candidates with Text Properties") +;; (@file :file-name "icicles-doc2.el" :to "Using Property icicle-special-candidate") +;; (@file :file-name "icicles-doc2.el" :to "Applying Text Properties to a Candidate String") +;; +;; (@file :file-name "icicles-doc2.el" :to "Defining Icicles Commands (Including Multi-Commands)") +;; (@file :file-name "icicles-doc2.el" :to "Nothing To It!") +;; (@file :file-name "icicles-doc2.el" :to "Multi-Commands Are Easy To Define Too") +;; (@file :file-name "icicles-doc2.el" :to "Are Users Dependent on Icicles To Use Multi-Commands?") +;; +;; (@file :file-name "icicles-doc2.el" :to "Defining Icicles Tripping Commands") +;; (@file :file-name "icicles-doc2.el" :to "Defining Multiple-Choice Menus") +;; (@file :file-name "icicles-doc2.el" :to "Defining Icicles Multi `M-x'") +;; (@file :file-name "icicles-doc2.el" :to "How Multi `M-x' is Defined") +;; +;; (@file :file-name "icicles-doc2.el" :to "Defining Multi-Commands the Hard Way") +;; (@file :file-name "icicles-doc2.el" :to "Global Filters") +;; (@file :file-name "icicles-doc2.el" :to "Specifying Match Functions for Commands") +;; (@file :file-name "icicles-doc2.el" :to "Defining Buffer-Text Completion for Comint Modes") +;; (@file :file-name "icicles-doc2.el" :to "Note to Programmers") +;; (@file :file-name "icicles-doc2.el" :to "La Petite Histoire") +;; (@file :file-name "icicles-doc2.el" :to "Note on Non-nil `pop-up-frames' on MS Windows") + +;;(@* "Nutshell View of Icicles") +;; +;; Nutshell View of Icicles +;; ------------------------ +;; +;;(@* "README for NON-Readers") +;; ** README for NON-Readers ** +;; +;; Load library `icicles.el', turn on Icicle mode, and you're good to +;; go. You can turn Icicle mode off or on at any time with command +;; `icy-mode'. When you turn it off, you're back in vanilla Emacs. +;; +;; Beyond that, the most important thing to know about Icicles is +;; that you can get help on Icicle mode during minibuffer input. You +;; do that either by using item Help of the menu-bar Icicles menu or +;; Minibuf menu, or by hitting `C-?' (`icicle-minibuffer-help'). +;; +;; You now know enough to use Icicles. If you have doc-phobia or are +;; easily overwhelmed by explanations, then *read no more* - just try +;; it! +;; +;; If you want a little more explanation than the help page (`C-?'), +;; then read the rest of section (@> "Nutshell View of Icicles"), but +;; no more. It shows a sample of what you can do in Icicle mode. +;; +;; If you want to know more about Icicles by reading instead of just +;; trying, then read beyond section (@> "Nutshell View of Icicles"). +;; There is a lot you can learn, but there is not much that you need +;; to learn, to use Icicles usefully. Don't be afraid to get in and +;; get wet. Above all, don't be overwhelmed by the doc - if it +;; helps, fine. +;; +;; One good way to start is to explore menus `Icicles' and `Minibuf'; +;; you can access most Icicles features using these menus, without at +;; the same time struggling to learn new key bindings. The `Icicles' +;; menu is available all of the time (that is, whenever you are in +;; Icicle mode), and the `Minibuf' menu is available whenever the +;; minibuffer is active. +;; +;; During minibuffer input completion, you can also press Control and +;; right-click (`C-mouse-3') on a completion candidate in buffer +;; `*Completions*', and choose from a contextual popup menu, +;; `Completion Candidate'. Some of its menu items apply to the +;; clicked candidate; others apply to all candidates. This is a long +;; menu! Think of it as a learning device and a way to remind you of +;; operations on individual candidates and their key bindings . In +;; this it is similar to the help you get when you use `C-?' in the +;; minibuffer, but with the menu you can also act, not just be +;; reminded. +;; +;;(@* "Toggle Options on the Fly") +;; ** Toggle Options on the Fly ** +;; +;; There are many user options that affect the behavior of Icicles +;; features. Some of these are Boolean (on/off) or allow for simple +;; alternation or cycling of the possible values. Many of those +;; options are associated with toggle commands that are bound to keys +;; whenever the minibuffer is active, or at least active for +;; completion. +;; +;; Throughout this doc you will see references to such options and +;; their toggles. For example: "You can toggle case-sensitivity at +;; any time using `C-A' (that is, `C-S-a') in the minibuffer." +;; +;; The reason for making it so easy to change the values of these +;; options on the fly is that different kinds of completion, in +;; different contexts, can take advantage of different option values. +;; Icicles completion is very general, and a single option value is +;; not always optimal for all contexts. +;; +;; You will become acquainted with a few of these toggle keys and +;; remember them, but you will forget others. What is important to +;; point out here is that `C-?' (`icicle-minibuffer-help') is your +;; friend in the minibuffer. During completion, the help it displays +;; includes, near the top, a list of the toggle keys and the +;; corresponding current values of their options. +;; +;; Whenever you use an Icicles toggle command, a momentary message +;; shows you the new option value. So as an alternative to using +;; `C-?' to see the current value of an option, you can just toggle +;; it twice. +;; +;;(@* "Cycle Completion Candidates") +;; ** Cycle Completion Candidates ** +;; +;; M-x t o o l next +;; +;; That is, type "tool" and then hit the `next' key, which is often +;; labeled "Page Down". Each time you hit `next', another match for +;; your input (`tool') replaces it in the minibuffer: +;; +;; M-x ediff-toggle-use-toolbar next +;; M-x scroll-bar-toolkit-scroll next +;; M-x tool-bar-mode next +;; M-x tooltip-mode next +;; M-x ediff-toggle-use-toolbar ; Back to the beginning +;; +;; Keys `next' and `prior' ("Page Up") cycle among all of the +;; commands that contain (match) the minibuffer input - `tool', in +;; this case. Just hit `RET' (Return) when you get to the command +;; you want. +;; +;; (Note: The particular candidates shown here and in other examples +;; might be different from what you see, depending on your version of +;; Emacs and what other libraries you might have loaded.) +;; +;; You can use a regular expression, to narrow the field of matching +;; inputs: +;; +;; M-x i s e . + c h a r next +;; M-x isearch-delete-char next +;; M-x isearch-other-control-char next +;; ... +;; +;; See (@> "Cycling Completions") for more about cycling completion +;; candidates. +;; +;;(@* "Display Completion Candidates") +;; ** Display Completion Candidates ** +;; +;; You can display all of the matches for the current minibuffer +;; input, in the `*Completions*' buffer, with `S-TAB' (Shift TAB). +;; So, for instance, `S-TAB' with `M-x ise.+char' in the minibuffer +;; displays all commands whose names contain `ise' followed +;; (somewhere) by `char'. +;; +;; (The documentation always refers to the key that does this as +;; `S-TAB'. Actually, it is `S-TAB' only by default. You can +;; customize it, using option `icicle-apropos-complete-keys'.) +;; +;; See (@> "*Completions* Display") for more about using the +;; `*Completions*' window. +;; +;;(@* "Prefix Completion and Apropos Completion") +;; ** Prefix Completion and Apropos Completion ** +;; +;; You can get the standard Emacs "prefix" completion, instead of +;; this "apropos completion", by using `TAB' instead of `S-TAB'. You +;; can cycle prefix-completion candidates by using the `down' and +;; `up' arrow keys instead of `next' and `prior'. +;; +;; Some people prefer to always cycle using the same keys, for +;; example, `down' and `up', regardless of the completion mode +;; (prefix or apropos). You can get that behavior by customizing +;; user option `icicle-cycling-respects-completion-mode'. +;; +;; Instead of using `down' or `next', as an alternative you can cycle +;; candidates downward (forward) by just repeating the same +;; completion key: `TAB' or `S-TAB'. For example: +;; +;; M-x tool TAB ; Display candidates with prefix `tool' +;; M-x tool-bar-mode TAB +;; M-x tooltip-mode TAB +;; M-x tool-bar-mode ; Back to the beginning +;; +;; Or: +;; +;; M-x tool S-TAB ; Display matching candidates +;; M-x ediff-toggle-use-toolbar S-TAB +;; M-x scroll-bar-toolkit-scroll S-TAB +;; M-x tool-bar-mode S-TAB +;; M-x tooltip-mode S-TAB +;; M-x ediff-toggle-use-toolbar ; Back to the beginning +;; +;; Changing to a different completion key (`TAB' to `S-TAB' or vice +;; versa) always switches completion type and completes, but you can +;; then repeat that new completion key to cycle among the candidates. +;; +;; Note: In vanilla Emacs, repeating `TAB' scrolls the +;; `*Completions*' window. In Icicles, you can use `C-v' to scroll +;; `*Completions*' down and `M-v' to scroll up. You can also use the +;; mouse wheel to scroll. +;; +;; See (@> "Apropos Completions") for more about apropos and prefix +;; completion. +;; +;;(@* "Chains of Simple Match Patterns - Progressive Completion") +;; ** Chains of Simple Match Patterns - Progressive Completion ** +;; +;; To see which functions contain `char', `delete', and `back' in +;; their names, in any order: +;; +;; C-h f c h a r S-TAB - Display all function names that contain +;; `char'. +;; +;; M-* d e l e t e - Narrow that set of names to those that also +;; contain `delete'. +;; +;; M-* b a c k - Narrow the set of matching names further, to +;; those that also contain `back'. +;; +;; This displays a list of functions like this in buffer +;; `*Completions*' (your list might be somewhat different): +;; +;; backward-delete-char backward-delete-char-untabify +;; delete-backward-char icicle-backward-delete-char-untabify +;; icicle-delete-backward-char +;; quail-conversion-backward-delete-char +;; +;; Since you are completing input to `C-h f', you can then cycle to a +;; name using `next' and hit `RET', or click `mouse-2', to see the +;; doc for that function. If, instead, you were completing input to +;; `M-x', you could choose a command to execute. And so on. +;; +;; The thing to notice here is that you can use `M-*' to input chains +;; of multiple simple regexps, to narrow down the set of completion +;; candidates progressively. This is analogous to piping the result +;; of `grep' to another `grep', and piping that result to another +;; `grep'... +;; +;; Here are a couple others to try (I'm always forgetting the order +;; in these compound names): +;; +;; C-h f w i n d o w S-TAB M-* f r a m e +;; +;; C-h f w i n d o w S-TAB M-* b u f f e r +;; +;; As a shortcut, you can use just `S-SPC' instead of `S-TAB M-*'. +;; See (@> "Progressive Completion") for more about progressive +;; completion with `M-*'. +;; +;;(@* "Chip Away the Non-Elephant") +;; ** Chip Away the Non-Elephant ** +;; +;; There's a joke about a sculptor who, when asked how he created +;; such a life-like statue of an elephant, said that he just chipped +;; steadily away, removing marble that didn't resemble an elephant. +;; (Actually, Michelangelo supposedly said something similar.) +;; +;; Icicles lets you sculpt this way too - it is in fact a common +;; Icicles usage idiom. There are two ways to say, "I don't want +;; that" when it comes to possible completions: +;; +;; * The `delete' key or `S-mouse-2' says, "Get rid of this +;; completion candidate." +;; +;; * `C-~' says "I want all possible completions *except* those that +;; are the current matches." That is, "Remove all of this, and let +;; me see what's left." `C-~' takes the complement of the current +;; set of matches, using the initial set of possible candidates as +;; the universe of discourse. +;; +;; In other words, instead of coming up with input that you want a +;; completion to match, get rid of one or all of the candidates that +;; do match. You can keep clicking `mouse-2' while holding Shift, or +;; keep hitting `delete' (without Shift), to chip away at the set of +;; possible completions. If there are several candidates in a row +;; that you want to eliminate, just hold down the `delete' key until +;; they're gone. +;; +;; So that you can use `delete' this way to delete candidates one +;; after the other, in order, the next candidate is chosen each time +;; you delete one. This means that it becomes the current candidate +;; in the minibuffer. You can, however, use `M-k' to clear the +;; minibuffer or use `C-l' (bound to command +;; `icicle-retrieve-previous-input') to clear the minibuffer and +;; retrieve your last real input - see (@> "History Enhancements"). +;; +;; `delete' works well to delete isolated candidates or groups of +;; candidates that are in order (the current sort order), one right +;; after the other, and you can of course combine it with positive +;; matching. +;; +;; Note: In Emacs releases prior to Emacs 22, `delete' has no real +;; effect on file-name completion candidates (but it works fine on +;; non file-name candidates). It removes them temporarily, but they +;; are not really removed as possible candidates, so `TAB' and +;; `S-TAB' will still show them as candidates. +;; +;; `C-~' is particularly handy in combination with progressive +;; completion (`M-*') to narrow down a set of candidates, especially +;; when you are not exactly sure what you are looking for. You can +;; repeat `C-~' with different inputs to eliminate everything matched +;; by each of them. In other words, this is a variable-size chisel, +;; and you can use it to remove very large chips. +;; +;; For instance, suppose you are looking for a standard Emacs command +;; involving buffers. You try `M-x buff S-TAB', but that shows +;; zillions of matches. Suppose that you know you don't want a +;; command in some 3rd-party package. You proceed to eliminate +;; those, progressively, using something like this: +;; +;; M-* ediff C-~ ibuffer C-~ icicle C-~ Buffer-menu C-~ ps- C-~ +;; ido C-~ search-buffers C-~ moccur C-~ swbuff C-~ +;; +;; And so on. That is, instead of using `M-*' repeatedly to specify +;; multiple patterns that candidates must match, you use `C-~' +;; repeatedly (after an initial `M-*'), to chip away candidates you +;; don't want. You could, alternatively, hold down the `delete' key +;; to eliminate each of these groups of command names. There are +;; over 100 commands whose names begin with `ediff', however, so `M-* +;; C-~' can be quicker in that case. It can definitely be quicker +;; when apropos matching is involved. And you can of course combine +;; the fine chiseling of `delete' with the variable-size chiseling of +;; `C-~'. +;; +;; See (@> "Sets of Completion Candidates") for more about `C-~'. +;; +;;(@* "Choose Before You Act") +;; ** Choose Before You Act ** +;; +;; The opposite operation from chipping away at a set of candidates +;; to refine it is to build up a set of candidates that you want to +;; act on. This too is easy with Icicles. In some user interfaces, +;; including Dired in Emacs, you can mark items in a checklist and +;; then, when you've selected the items you want and verified the +;; list, act on those that are selected. You might do this, for +;; instance, if you were deleting some files. Icicles lets you +;; interact with completion candidates this same way. +;; +;; You do this by building up a saved set of candidates, and then +;; retrieving these saved candidates later. You can use the +;; retrieved candidates just as you would any current set of +;; candidates. One of the things you can do is act on all of them, +;; that is, act on each, in turn. You do that with `C-!'. +;; +;; Of course, if you can use a regexp to match exactly the candidates +;; you want to act on, then you need not bother to save and retrieve +;; them, before acting on them: you can see them all alone in buffer +;; `*Completions*'. Here's an exercise in choosing candidates to +;; save with the mouse in `*Completions*': +;; +;; C-x C-f i c i TAB - Match all file names that begin with `ici'. +;; +;; Click `mouse-1' inside (or to the left of) `icicles-face.el'. +;; Click `mouse-3' inside (or to the right of) `icicles-mode.el'. +;; Click `mouse-3' again, in the same place. +;; Click `M-S-mouse-2' on each of `icicles.el' and `icicles-cmd1.el'. +;; +;; The candidates that you selected - those between `icicles-face.el' +;; and `icicles-mode.el', inclusive, plus `icicles.el' and +;; `icicles-cmd1.el', are highlighted specially in buffer +;; `*Completions*', and feedback in the minibuffer tells you that +;; they were "saved", which you can also think of as "marked". +;; +;; Next, use `C-M-<'. This retrieves the set of saved candidates; +;; that is, it replaces the current set of candidates with the saved +;; candidates. If you now use `C-!', it applies the action to each +;; candidate. In this case, the action is to visit the file (`C-x +;; C-f'). +;; +;; The combination of saving (marking) candidates and then retrieving +;; only those you have saved is like progressive completion or +;; chipping away: it is another way of progressively narrowing the +;; set of candidates that you act on. +;; +;; See (@> "Choose All Completion Candidates") for more about `C-!'. +;; See (@> "Sets of Completion Candidates") for more about saving and +;; retrieving sets of candidates. +;; +;;(@* "Help on Completion Candidates") +;; ** Help on Completion Candidates ** +;; +;; Sometimes, you'd like to be able to ask for help about individual +;; completion candidates while you're in the process of choosing one. +;; That's the purpose of the Icicles `C-M-' key bindings available +;; during completion. +;; +;; The simplest such bindings are `C-M-RET' and `C-M-mouse2'. They +;; each do the same thing: provide help on the current candidate. +;; You can use them during cycling or whenever you've narrowed the +;; choice down to a single candidate. You can check this way, before +;; you execute a command you're unsure of. +;; +;; During completion, you can also cycle among the doc strings for +;; the candidates that match your input, using `C-M-down' and +;; `C-M-up' (for prefix matching), `C-M-next' and `C-M-prior' (for +;; apropos matching). This gives you a very useful on-the-fly +;; apropos feature - use it while you're completing a command, to +;; check the difference between several possible commands. Or just +;; use it to browse doc strings, to learn more about Emacs. +;; +;; See (@> "Get Help on Candidates") for more about this. +;; +;;(@* "Perform Multiple Operations in One Command") +;; ** Perform Multiple Operations in One Command ** +;; +;; C-x C-f i c i TAB - Find a file whose name starts with `ici'. +;; +;; down (that is, down arrow) ... until you get to candidate +;; `icicles-cmd1.el' +;; +;; RET - Open file `icicles-cmd1.el'. +;; +;; Nothing new here. Now try the same thing, but use `C-RET' instead +;; of `RET'. The command is not ended, and you can continue to +;; choose files to open: +;; +;; C-x C-f i c i TAB - Find a file whose name starts with `ici'. +;; +;; down ... until you get to `icicles-cmd1.el' +;; +;; C-RET - Open file `icicles-cmd1.el'. +;; +;; down ... until you get to `icicles-opt.el' +;; +;; C-RET - Open file `icicles-opt.el'. +;; +;; down ... until you get to `icicles.el' +;; +;; RET - Open file `icicles.el' (end). +;; +;; You just opened three files in a single command. Command +;; `icicle-file' (`C-x C-f') is an Icicles multi-command. You can +;; tell if a command is a multi-command when you execute it - if so, +;; the input prompt is prefixed by `+'. So, for example, when you +;; used `C-x C-f', the prompt was "+ File or directory:". Icicles +;; menu items that are multi-commands are also prefixed by `+'. +;; +;; In addition to using `down' (or `next') and choosing (acting on) +;; candidates with `C-RET', you can combine these operations by using +;; `C-down' (or `C-next'): act on candidates in succession. And, as +;; mentioned, you can use `C-!' to act on all candidates at once. +;; +;; There are many possible uses of multi-commands. They all make use +;; of the same key bindings, which begin with `C-'. These keys are +;; analogous to the `C-M-' keys that provide help on completion +;; candidates. +;; +;; See (@> "Multi-Commands") for more information about Icicles +;; multi-commands. +;; +;;(@* "Perform Alternative Operations on the Fly") +;; ** Perform Alternative Operations on the Fly ** +;; +;; (If this section seems a bit weird or advanced to you, just skip +;; it the first time through.) +;; +;; C-x C-f i c i TAB - Find a file whose name starts with `ici'. +;; +;; down ... until you get to candidate `icicles-cmd1.el' +;; +;; C-S-RET - You are prompted to choose a function to apply. +;; +;; f i n d e TAB RET - Choose function `finder-commentary'. +;; +;; down ... until you get to candidate `icicles-fn.el' +;; +;; C-S-RET TAB TAB ... until you get to `find-file-read-only'. +;; +;; RET - Visit file `icicles-fn.el' in read-only mode. +;; +;; C-k TAB - Kill rest of input, then complete the prefix `ici'. +;; +;; C-| b y t e - c TAB - Byte-compile all files matching `ici'. +;; +;; TAB ... until you get to `icicles-doc1.el', then RET to visit. +;; +;; What's going on? `C-S-RET' invokes an alternative action on the +;; current completion candidate. Here, you do this, in turn, for the +;; file-name candidates `icicles-cmd1.el' and `icicles-fn.el'. `C-|' +;; invokes an alternative action on *all* of the current completion +;; candidates. Here, you do this for all file names that begin with +;; `ici'. Finally, you cycle to `icicles-doc1.el' and hit RET to +;; visit that file. +;; +;; The alternative action for `C-x C-f' (command `icicle-file') +;; prompts you for a function to apply to the current completion +;; candidate (for `C-S-RET') or to all candidates (for `C-|'). +;; +;; Here, you choose function `finder-commentary' to visit the +;; Commentary of file `icicles-cmd1.el', function +;; `find-file-read-only' to visit file `icicles-fn.el' in read-only +;; mode, and function `byte-compile-file' to byte-compile all files +;; whose names start with `ici'. +;; +;; You can use `C-u' with a function you choose, to pretty-print its +;; result (in buffer `*Pp Eval Output*', if too large for the echo +;; area). That's useful for functions that have no side effects. +;; For this to work, use `C-RET', not `RET', to choose the function. +;; +;; Each command defines its own alternative action, but many Icicles +;; commands have the behavior described here for `icicle-file': their +;; alternative action is to let you apply any function that is +;; appropriate for the given type of candidate (here, file names). +;; +;; You can even enter an appropriate lambda expression, instead of +;; completing to one of the function candidates provided. For +;; example, you could use `C-|' with the following input to copy all +;; Icicles libraries to directory `ICICLES': +;; +;; (lambda (f) (copy-file f "ICICLES" t)) +;; +;; Note that function `copy-file' is effectively curried here, to +;; create a function of a single argument on the fly. +;; +;; See Also: (@* "Alternative Actions"). +;; +;; +;;(@* "Completion Status Indicators") +;; ** Completion Status Indicators ** +;; +;; You can always know whether completion is possible when you are +;; inputting text in the minibuffer and, if so, what kind of +;; completion. Completion status is indicated in two places: (1) at +;; the beginning of the minibuffer prompt and (2) in the `Icy' +;; minor-mode lighter in the mode line. The second is optional, +;; controlled by option `icicle-highlight-lighter-flag'. +;; +;; Whenever input completion is available, the prompt is prefixed by +;; `.' or `+', indicating simple or multi-command completion, +;; respectively. If completion is strict (your input must match one +;; of the candidates), then this character is enclosed in a box. If +;; completion is lax (permissive), there is no box. +;; +;; The `Icy' minor-mode lighter text is highlighted red during +;; completion. `+' is added to the lighter (`Icy+') for +;; multi-command completion, and the lighter is boxed for strict +;; completion. When minibuffer input is read without completion, the +;; lighter is not highlighted in any way. +;; +;; If the list of candidates shown in `*Completions*' is truncated +;; (because of option `icicle-max-candidates'), then the lighter text +;; is suffixed by `...'. So if you see `...' then you know that if +;; you increase `icicle-max-candidates' (e.g. by using `C-x #' during +;; completion) then more candidates will be available. See +;; (@file :file-name "icicles-doc2.el" :to "Customization and General Tips") +;; for info about `C-x #' and option `icicle-max-candidates'. +;; +;; In addition, the lighter text (with or without `+' and `...') is +;; `Icy' if completion is case-sensitive and `ICY' if not. You can +;; toggle case-sensitivity at any time using `C-A' (that is, `C-S-a') +;; in the minibuffer. +;; +;; The faces used for this highlighting in the minibuffer and the +;; mode line are `icicle-completion', +;; `icicle-multi-command-completion', and +;; `icicle-mustmatch-completion'. Consult their doc strings for more +;; information. These faces are combined to produce the various +;; highlighting effects - keep that in mind if you customize them. +;; +;; When you are inputting, keep an eye out for this highlighting. If +;; you don't see it when you are prompted for input, it means that +;; input completion is not available. This in turn means that +;; `S-TAB' is available, not for input completion, but for key +;; completion - see (@> "Key Completion"). +;; +;;(@* "Icicles Search") +;; ** Icicles Search ** +;; +;; Icicles provides a unique way of searching incrementally. Command +;; `icicle-search' (`C-c `') is a multi-command. In this case, the +;; completion candidates are the buffer occurrences that match a +;; regexp that you input. `C-RET' visits a search-hit candidate, and +;; `C-next' visits a candidate and prepares to visit the next in +;; succession. If you visit file `icicles-doc1.el', which contains +;; the text you are reading now, do this in that buffer: +;; +;; C-c ` +;; Find (regexp): . * r e c u r s i v e . * RET - Search for the +;; regexp `.*recursive.*'. +;; +;; Choose an occurrence: S-TAB - Show the search hits, in buffer +;; `*Completions*' (optional). +;; +;; C-next ... - Cycle among the search hits, navigating to them in +;; turn. +;; +;; S-TAB next ... - Cycle among the search hits without navigating. +;; +;; next ... C-RET next ... C-RET - Cycle to particular hits and +;; visit (only) those hits. +;; +;; next ... RET - Cycle to a hit and stay there (end). +;; +;; +;; C-c ` +;; Find (regexp): M-p RET - Search again for `.*recursive.*' +;; (input history). +;; +;; S-TAB e d i t C-next ... - Search for the substring `edit' +;; within all search hits for `.*recursive.*'. Cycle among the +;; matches. The substring `edit' is highlighted inside the +;; (differently) highlighted `.*recursive.*' hits. Whatever you +;; type filters the initial set of hits. +;; +;; M-k - Empty the minibuffer, then S-TAB. All `.*recursive.*' +;; hits are restored as candidates. Again, whatever your input is +;; (nothing, now), the set of candidates is dynamically updated to +;; match it. +;; +;; t \ w + n S-TAB C-next ... - Search for matches of the regexp +;; `t\w+n' within all search hits for `.*recursive.*' - that is, +;; `t' followed by at least one other word character, followed by +;; `n'. Whatever the regexp `t\w+n' matches (`thin', `then', +;; `traighten', `tion') is highlighted inside each candidate. +;; +;; RET - Stop searching at the current candidate (end). +;; +;; Now try the same thing, but first use `C-^' in the minibuffer +;; (e.g. after you enter `.*recursive.*'). That toggles an Icicles +;; search option for highlighting your input matches. The behavior +;; is the same as before, except that all matches to your input are +;; highlighted at once, not just the current match. And not only the +;; exact match is highlighted, but the longest common match among all +;; input matches is highlighted: If your input is `edi', then `edi' +;; is highlighted (there is no longer common match), but if you input +;; the four characters `e d i t', then ``abort-recursive-edit'' is +;; highlighted. You can use `C-^' at any time during searching to +;; change the highlighting behavior. +;; +;; Now try the same thing, but first select some text. The search is +;; confined to the active region (selection) instead of the entire +;; buffer. +;; +;; Now try the same thing (without a region), but use a negative +;; prefix argument such as `C--' with `C-c `'. This time, after you +;; input the regexp to search for, you are prompted for one or more +;; files to search. This too is multi-command input: you can input +;; any number of file names, using completion. +;; +;; C-- C-c ` +;; Find (regexp): . * r e c u r s i v e . * RET - Search for the +;; regexp `.*recursive.*'. +;; +;; Choose file (`RET' when done): i c i TAB - Choose among file +;; candidates that begin with `ici' (shown in `*Completions*'). +;; +;; C-! - Choose all matching file names: icicles-cmd1.el, +;; icicles-cmd2.el, icicles-doc1.el, icicles-doc2.el, +;; icicles-face.el, icicles-fn.el, icicles-mac.el, icicles-mcmd.el, +;; icicles-mode.el, icicles-opt.el, icicles-var.el, and icicles.el. +;; +;; Choose an occurrence: S-TAB - Show the hits in buffer +;; `*Completions*' (optional). +;; +;; C-next ... - Cycle among the search hits in all chosen +;; files... +;; +;; Just as you can choose particular search hits to visit, using +;; `C-RET', so you can use `C-RET' to choose particular files (whose +;; names match the input, e.g. ici) to search. Just as you can visit +;; search hits in order, using `C-next' (or `C-down'), so you can use +;; `C-next' (or `C-down') to choose files to visit, one after the +;; other. +;; +;; When you input the initial regexp (`.*recursive.*' in the example +;; above) to `icicle-search', you can use completion to retrieve a +;; regexp that you entered previously. +;; +;; You can use `C-`' in the minibuffer to toggle escaping of regexp +;; special characters. Use that if you want to find a literal string +;; - for example, if you want to search for the string `form.' and +;; not text that matches the regexp `form.' (`form' followed by any +;; character except newline). If you use `C-`' during Icicles +;; search, start the search over again for the toggle to take effect. +;; +;; Oh, can you use progressive completion with Icicles search? Sure. +;; And chipping away the non-elephant (complementing)? Yep. Try +;; using vanilla Emacs incremental search to find a line that +;; contains a given set of words in any (unknown) order and that also +;; does not contain another given set of words. No can do. But +;; that's simple using Icicles search. (Yes, you can do it using +;; `grep'.) +;; +;; And while you're searching, you can perform on-the-fly, on-demand +;; replacement. You tell Emacs whenever you want to replace text, +;; instead of replying to an endless litany of `query-replace' +;; queries. Unlike `query-replace', you need not visit search +;; matches successively or exhaustively. You can visit and replace +;; selected matches in any order. And you can even change the order +;; (using `C-,') in which search hits appear and are navigated +;; sequentially. +;; +;; In addition to Icicles search (which is also incremental), Icicles +;; offers some enhancements to the standard Emacs incremental search, +;; Isearch: +;; +;; * You can reuse a previous Isearch search string, choosing it +;; using Icicles completion. Hit `M-o' during Isearch, type some +;; input to complete against the search history, and hit `RET' or +;; click `mouse-2' to choose a string and continue Isearch with it. +;; +;; * You can start Icicles search from Isearch. The current Isearch +;; search string becomes the starting point for the Icicles search +;; regexp. You can edit it or type something different. And you +;; can complete what you type against the Isearch regexp history. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; for more about searching with Icicles. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Search and Replace") +;; for information about replacing selected search hits. +;; +;; * (@> "Expanded-Common-Match Completion") for more about Icicles +;; expansion of your input to a common match among all candidates. +;; +;; * (@> "Isearch Enhancements") +;; +;; * (@* "Using Completion to Insert Previous Inputs: `M-o'") for +;; more about `M-o' - you can use it anywhere to complete against +;; previous inputs. +;; +;;(@* "Complete Key Sequences Too") +;; ** Complete Key Sequences Too ** +;; +;; Try `S-TAB' at the top level (without first invoking a command +;; that reads input). Icicles presents all of the possible keys and +;; their bindings in the current context - for completion. For +;; example, if you are in Dired mode, the completion candidates +;; include all key sequences in the global map and the Dired-mode map +;; (and any current minor-mode maps, such as Icicle mode). +;; +;; (The documentation always refers to the key that performs key +;; completion as `S-TAB'. Actually, it is `S-TAB' only by default. +;; You can customize it, using option `icicle-key-complete-keys'.) +;; +;; You can then type part of a key name or a command name, and hit +;; `S-TAB' again to apropos-complete your input. You can navigate +;; down the key-sequence hierarchy by completing a key sequence piece +;; by piece: +;; +;; S-TAB to see the available keys at top level +;; +;; Click (using `mouse-2') candidate `C-x = ...', to see the keys +;; that start with `C-x' +;; +;; Click `r = ...', to see the keys that start with `C-x r' +;; +;; Click `b = bookmark-jump', to invoke that command and visit a +;; bookmark +;; +;; Whenever you're completing a prefix key, such as `C-x', you can +;; click `..' to navigate back up the key-sequence hierarchy. For +;; instance, if you are completing `C-x p', click `..' to go back to +;; completing `C-x', and then click `..' to go back to the top level. +;; +;; The available keys at any level include the following important +;; keys, which means that you can use Icicles key completion to do +;; almost anything in Emacs: +;; +;; * `M-x' - Execute an arbitrary command. +;; `M-x' is treated as `ESC-x', so complete first `ESC = ...', +;; then `x = icicle-execute-extended-command'. +;; +;; * `M-:' - Evaluate any Emacs-Lisp expression. +;; If command remapping is available (Emacs 22 or later), and if +;; option `icicle-top-level-key-bindings' remaps `eval-expression' +;; to `icicle-pp-eval-expression' (which it does, by default), then +;; complete first `remapped = ...', then `eval-expression = +;; icicle-pp-eval-expression'. Otherwise, complete first `ESC = +;; ...', then `: = eval-expression'. +;; +;; In Icicles, `M-:' gives you a quick pop-up mode for evaluating a +;; Lisp sexp. Most of the normal Emacs-Lisp mode bindings are in +;; effect, except that `RET' evaluates the minibuffer contents and +;; pretty-prints the result. You can also use it with a prefix arg +;; (`C-u M-:') to insert the result of such an on-the-fly Lisp +;; evaluation into the current buffer (including the minibuffer). +;; +;; * `menu-bar = ...' - Invoke any menu-bar menu. +;; Continue completing, to navigate the entire menu hierarchy. +;; +;; You can start directly with a key prefix, and then hit `S-TAB' to +;; complete it - you need not start with `S-TAB'. You can use +;; Icicles key completion to learn key bindings - `C-M-mouse-2' +;; displays help on any key. +;; +;; Instead of clicking a completion candidate with `mouse-2', you can +;; of course type part of the key name or command name, and then +;; complete the name and enter it. Gotcha: `S-TAB' uses apropos +;; completion, by default, so remember that typing `.' matches any +;; character (except a newline). To match only `..' (to go up a +;; level), either use prefix completion (`TAB') or escape the regexp +;; special character: `\.\.' (or use `^\.'). Or cycle to it. +;; +;; See (@> "Key Completion") for more about Icicles key completion. +;; +;;(@* "Available for Almost Any Input") +;; ** Available for Almost Any Input ** +;; +;; All of this works not only for the input of commands, with `M-x', +;; but for the input of nearly anything. For instance, you can use +;; `C-x b' (`switch-to-buffer') and cycle among buffer names. Or use +;; `C-h v' (`describe-variable') and cycle among variable names. It +;; works whenever a command reads input with completion. +;; +;; Whenever you're in Icicle mode, you see "Icy" in the mode-line. +;; +;;(@* "Component Icicles Libraries") +;; ** Component Icicles Libraries ** +;; +;; Icicles is composed of the following libraries. When you load the +;; driver library, `icicles.el', the others are all loaded +;; automatically . +;; +;; `icicles.el' - driver library +;; `icicles-doc1.el' - first part of the doc (this!) +;; `icicles-doc2.el' - second part of the doc +;; `icicles-cmd1.el' - top-level commands (part 1) +;; `icicles-cmd2.el' - top-level commands (part 2) +;; `icicles-face.el' - faces +;; `icicles-fn.el' - non-interactive functions +;; `icicles-mac.el' - macros +;; `icicles-mcmd.el' - minibuffer commands +;; `icicles-mode.el' - Icicle mode definition +;; `icicles-opt.el' - user options (variables) +;; `icicles-var.el' - internal variables +;; +;; Libraries `icicles-doc1.el' and `icicles-doc2.el' are not really +;; libraries. They contain only comments, with the Icicles doc. +;; +;; Library `lacarte.el' is not part of Icicles, but it is especially +;; useful when used with Icicles. +;; +;;(@* "If You Are an Emacs-Lisp Programmer") +;; ** If You Are an Emacs-Lisp Programmer ** +;; +;; If you are an Emacs-Lisp programmer, this is the no-brainer, +;; nutshell view of how to take advantage of Icicles in your own code +;; that calls `completing-read' or `read-file-name': +;; +;; Add this line to your library: (require 'icicles nil t) +;; +;; That's really all you need to do. And there is no consequence if +;; users don't have Icicles (no load error is raised, because of the +;; non-nil third argument). In other words, there is no reason not +;; to add this soft `require', unless your library somehow conflicts +;; with Icicles features. (Even then, users will not be affected +;; unless they turn on Icicle mode.) +;; +;; +;; For more (and there is a lot more), read on... + +;;(@* "Inserting Text Found Near the Cursor") +;; +;; Inserting Text Found Near the Cursor +;; ------------------------------------ +;; +;; Most of Icicles is about completing text that you type in the +;; minibuffer against some set of possible completion candidates. +;; This feature is not. It is related only in the sense that it is +;; also about inputting text that is already available elsewhere. +;; +;; Some Emacs commands provide, as the default value for minibuffer +;; input, a word or other text at the cursor position (aka "point"). +;; You can insert this default value in the minibuffer with `M-n'. +;; Icicles option `icicle-default-value' can be used to automatically +;; insert the default value into the minibuffer as an initial value, +;; if you prefer that optional behavior (I do; many people do not). +;; +;; Sometimes you would like to use the text at the cursor, but the +;; command asking for input does not let you retrieve that text as +;; the default value. For example, if the text at point is a file +;; name, you might like to use it with `C-x C-f' to open that file. +;; Or, if the text is a URL, you might want to visit it using a Web +;; browser. +;; +;; Some Emacs-Lisp libraries, such as `ffap.el', have as their +;; specific purpose to help you do this. "Ffap" stands for +;; `find-file-at-point', the main command in that library. It tries +;; to interpret the text at point and "do the right thing" with it: +;; visit a file, open a URL in a Web browser, and so on. +;; +;; If you like, you can use library `ffap.el' with Icicles. All +;; Icicles features are then available during file-name and URL +;; completion. And if you like `ffap.el', you might also like to try +;; my extension library `ffap-.el'. However, if you use ffap with +;; Icicles, you might not want to use the ffap key bindings, +;; preferring the Icicles bindings or the standard Emacs bindings for +;; keys such as `C-x C-f'. (In that case, do not call function +;; `ffap-bindings'.) +;; +;; Icicles provides a couple of simple ways to take advantage of +;; `ffap-guesser', which is the ffap function that guesses which +;; string at the cursor position you want to grab, without +;; sacrificing any key bindings to ffap. One way is to use `M-.' +;; (command `icicle-insert-string-at-point') at any time in the +;; minibuffer. It grabs text at or near the cursor and yanks it into +;; the minibuffer. By default, the text it grabs is whatever +;; `ffap-guesser' guesses. +;; +;; Another way is to use one of the proxy completion candidates +;; `*point file name*' or `*mouse-2 file name*' whenever Emacs asks +;; you to input a file name (provided option +;; `icicle-add-proxy-candidates-flag' is non-nil - toggle with +;; `C-M-_'). The former picks up the file name at point, just like +;; `M-.'. The latter lets you click a file name anywhere with +;; `mouse-2' to pick up the name. +;; +;; Using `M-.' or a proxy candidate on demand, instead of binding +;; keys to ffap commands, lets you control which buffer text you use +;; as minibuffer input and how that text should be interpreted (file +;; name, URL, and so on). By default, `M-.' uses `ffap-guesser', but +;; you can change this by customizing user option +;; `icicle-thing-at-point-functions'. +;; +;; Actually, `M-.' acts differently if you use it successively. +;; Successive uses of `M-.' grab and insert either 1) alternative +;; bits of text (different text "things") or 2) successive bits of +;; text. The default behavior is #1, but you can change this choice +;; by customizing option `icicle-default-thing-insertion' (setting it +;; to `more-of-the-same', instead of `alternatives'). +;; +;; As an example of grabbing successive bits of text (#2), suppose +;; that the cursor is at the beginning of the word "use" in the +;; previous paragraph. Then, during minibuffer input, suppose that +;; you use `M-. M-. M-.'. Each time you hit `M-.', another word is +;; inserted in the minibuffer: +;; +;; use +;; use it +;; use it successively +;; ... +;; +;; The rest of this section is a bit technical, so you might want to +;; skip it if you are reading the Icicles doc for the first time. It +;; details the behavior and definitions of options +;; `icicle-default-thing-insertion' and +;; `icicle-thing-at-point-functions', and how to temporarily override +;; those settings interactively. +;; +;; Option `icicle-thing-at-point-functions' controls which text at or +;; near the cursor `M-.' inserts into the minibuffer. It is a cons +;; cell, that is, an ordered pair: +;; +;; * The car (first part) is a list of functions that grab different +;; kinds of strings at or near point (#1, above). Any number of +;; functions can be used. They are used in sequence by `M-.'. By +;; default, there are four functions, which alternately grab: +;; +;; 1) whatever `ffap-guesser' returns (e.g. file name at point) +;; 2) the symbol or file name at point +;; 3) the word at point +;; 4) the URL at point +;; +;; * The cdr (second part) is a function that advances point one text +;; thing (#2, above). Each time command `M-.' is used +;; successively, this is called to grab more things of text (of the +;; same kind). The default function grabs successive words. +;; +;; If either the car or cdr is empty, then the other alone determines +;; the behavior of `M-.'. Otherwise, option +;; `icicle-default-thing-insertion' determines whether the car or the +;; cdr is used by `M-.'. +;; +;; For example, if the value of `icicle-default-thing-insertion' is +;; `alternatives' (the default value), then repeated use of `M-.' +;; inserts a different kind of thing at point: ffap guess, file name, +;; word, or URL. If you set `icicle-default-thing-insertion' to +;; `more-of-the-same', then repeated use of `M-.' inserts successive +;; words into the minibuffer, as shown in the example above. +;; +;; You need not make a final choice once and for all between +;; `alternatives' and `more-of-the-same'. You can also make an +;; interactive choice by using a prefix argument (`C-u') at any time +;; to override the value of `icicle-default-thing-insertion'. If you +;; use plain `C-u', then `M-.' inserts alternative strings. If you +;; use a numeric prefix argument N (not just plain `C-u'), then it is +;; the same as using `M-.' N times with `more-of-the-same' as the +;; value of `icicle-default-thing-insertion'. +;; +;; And, if the numeric argument is negative, then text is grabbed to +;; the left of the cursor, instead of to the right. In the example +;; above, if you used `M-- M-. M-. M-.', then the successive +;; insertions would be as follows: +;; +;; differently +;; differently if +;; differently if you +;; ... +;; +;; If you used `M--3 M-.', then you would immediately insert +;; `differently if you'. +;; +;; In the case of `alternatives', there are four possibilities, by +;; default. The first function in the list is `ffap-guesser'. The +;; second function grabs text that has the syntax of an Emacs-Lisp +;; symbol name, which in practice can also be a file name or a URL - +;; it can include characters such as -, /, +, ., :, @, and _. The +;; third function grabs a word, which includes letters, ' and -. The +;; fourth function grabs a URL, adding prefix "http://" if needed. +;; These are the functions used by default, but you can add to them +;; or replace them. +;; +;; If you use my library `thingatpt+.el', then the cursor need not be +;; exactly on the text for the second and third alternatives - the +;; symbol or word *nearest* the cursor is grabbed. +;; +;; See Also: +;; +;; * (@> "Inserting a Regexp from a Variable or Register") for +;; information on inserting text saved in a variable or register. +;; +;; * (@> "Moving Between the Minibuffer and Other Buffers") for +;; another way to insert buffer text in the minibuffer. + +;;(@* "Background on Vanilla Emacs Input Completion") +;; +;; Background on Vanilla Emacs Input Completion +;; -------------------------------------------- +;; +;; This section reviews standard Emacs behavior regarding input +;; completion. It does not describe any Icicles completion features. +;; +;; When you are prompted in the minibuffer to enter something, you +;; are sometimes presented with a default value. This might be +;; automatically inserted after the prompt, initially. If not, you +;; can retrieve the default value yourself, using `M-n' (Emacs 21 or +;; later). +;; +;; Often, there is more than one reasonable default value that might +;; make sense. Depending on what you're being asked to enter, these +;; "candidate default values" might be command names, buffer names, +;; existing file names, variable names, and so on. +;; +;; For most Emacs functions that prompt you for input, the person who +;; wrote the function decided on the reasonable set of default +;; values, and passed these to an "input-completing function" such as +;; `completing-read' or `read-file-name', which prompts you and reads +;; your input. The programmer also decided whether you will be +;; *required* to pick one of the default values or you will be free +;; to enter something else. The programmer might also have told the +;; input-completing function to require that your input pass some +;; special test (predicate). +;; +;; Be aware that standard Emacs terminology does not refer to such a +;; set of default values as "default values"; they are called +;; "completions". By "default value", standard Emacs terminology +;; means only the values that you can access via `M-n'. Icicles +;; refers to all such potential inputs indifferently as "default +;; values", "completions", "completion candidates", and "candidates". +;; Whenever completion is not requiring you to pick one of the +;; available candidates, they are effectively only default choices. +;; +;; So, how do you get access to the default values that the +;; programmer has made available to you, in order to choose one? You +;; hit certain keys to complete the current contents of the +;; minibuffer (excluding the prompt). This current, partial input is +;; considered as a prefix of one of the default values, and it is +;; completed in the minibuffer to the entire default value +;; (completion). +;; +;; Keys `TAB', `RET' (Return), and `SPC' (Space) perform different +;; degrees of this "prefix completion" in standard Emacs. If you +;; type a prefix of one of the available default values, you can +;; complete the value this way in the minibuffer, and then enter +;; (commit) it, using `RET'. +;; +;; But if your partial input matches the prefix of more than one +;; default value, then completion pops up the list of all matching +;; completions for you to choose from (in buffer `*Completions*'). +;; You choose a candidate by clicking it with `mouse-2' or placing +;; the cursor on it and hitting `RET'. +;; +;; Because this is the way you access the default values supplied to +;; an input-completing function, I call those values +;; "prefix-completion candidates". If there is no partial input yet +;; (empty minibuffer), then the entire list of default values +;; supplied to the input-completing function appears in the pop-up +;; `*Completions*' buffer. See the Emacs manual (`C-h i') for more +;; on this general mechanism of prefix completion (called simply +;; "completion" there). +;; +;; Calls to `completing-read' and `read-file-name' are not the only +;; places where input completion is used. When you use `M-x' +;; (command `execute-extended-command'), completion is also +;; available. + +;;(@* "Cycling Completions") +;; +;; Cycling Completions +;; ------------------- +;; +;; Icicles lets you use the `up' and `down' arrow keys to cycle +;; through the list of candidate prefix completions that match +;; whatever input is present in the minibuffer (or all candidate +;; completions, if there is no input in the minibuffer). In the +;; minibuffer, each candidate replaces your partial input, in turn, +;; when you cycle. The prefix (root) that was completed is +;; underlined in the minibuffer completion candidate. +;; +;; As an alternative to using `down' to cycle forward, you can hit +;; `TAB' repeatedly. +;; See (@> "Prefix Completion and Apropos Completion"). +;; +;; Suppose you use `C-x b' (command `switch-to-buffer'). You can +;; then use `down' until the right buffer name appears in the +;; minibuffer, then hit `RET'. Or you can type some text that begins +;; one or more of the buffer names, and then use `down' to cycle +;; among those names that match that prefix. If there are many +;; candidates, typing part of the name to narrow the field can save +;; time. +;; +;; Another example: Suppose you use `C-h v' (`describe-variable') and +;; type `cal'. Use `down' to cycle among all variables that start +;; with `cal', until you find the one you want (then hit `RET'). +;; +;; In other words, the current partial input in the minibuffer +;; determines a matching set of default values, and those are the +;; values that you can cycle through. You can at any time erase or +;; change the partial input - the list of matching candidates +;; automatically reflects the change. +;; +;; This also means that it's good to have a quick way to clear the +;; minibuffer of any input, so Icicles also provides minibuffer key +;; binding `M-k' to do that. +;; +;; A visible and audible signal lets you know when you have reached +;; one end of the list of completion candidates, but you can of +;; course continue to cycle, wrapping around. +;; +;; If the completion candidates are already displayed in buffer +;; `*Completions*' when you try to cycle among them (because you hit +;; `TAB'), then the current candidate is highlighted in +;; `*Completions*' as you access it in the minibuffer with the `up' +;; and `down' arrow keys. If you change the minibuffer input, then +;; the `*Completions*' list is updated accordingly, to reflect the +;; new set of matching candidates. The root that was completed (the +;; minibuffer input) is highlighted in each candidate of the +;; `*Completions*' display. The `*Completions*' window is +;; automatically scrolled as needed, to show the current candidate. +;; +;; Don't become a cycling drone! Input some text to narrow the set +;; of candidates, before cycling among them to choose one. This is a +;; good habit to adopt, generally, in Icicles. Most of the power of +;; Icicles comes in your ability to filter a set of candidates. This +;; is especially true when it comes to regexp filtering (see +;; (@> "Apropos Completions")). +;; +;; Cycling and filtering work hand in hand. If the set of candidates +;; is small to begin with, then just cycling might be quick enough - +;; that is the case if you move among a small set of buffers, for +;; instance. But with Icicles you can profitably use cycling on even +;; a very large set of candidates - by filtering the set first. The +;; reason this is not very practical with vanilla Emacs is that +;; filtering by a prefix only is not very potent. +;; +;; Tip: Whenever you type or delete text in the minibuffer, your +;; partial input is remembered. When you cycle completion +;; candidates, your input is replaced by each candidate, but you can +;; at any time refresh the minibuffer to retrieve what you last +;; typed. You do this with `C-l', which is bound in the minibuffer +;; to command `icicle-retrieve-previous-input'. Editing a completion +;; candidate that you have cycled into the minibuffer counts as +;; input. Editing tells Icicles to remember what is in the +;; minibuffer as your last real input. If you want to replace the +;; candidate and go back to editing the input you had already typed +;; before cycling, then use `C-l' - don't just delete characters from +;; the candidate. See (@> "History Enhancements"). +;; +;; You can change the keys that are bound to completion-candidate +;; cycling. And if you prefer to use the same key for cycling both +;; apropos matches and prefix matches, then you can customize option +;; `icicle-cycling-respects-completion-mode'. +;; See (@file :file-name "icicles-doc2.el" :to "Customizing Key Bindings"). +;; +;; If you are an Emacs-Lisp programmer, then you can use +;; `completing-read' and `read-file-name' to define your own +;; commands, enabling them to take advantage of Icicles completion +;; and cycling. The definition of command `icicle-recent-file' is a +;; good model to follow. Emacs has a `recentf-mode' that lets you +;; open recently accessed files. But this mode makes you open a file +;; using a menu interface. Command `icicle-recent-file' lets you use +;; the usual `find-file' minibuffer interface, with completion and +;; cycling among your recent files. See sections +;; (@> "Defining Icicles Commands") and +;; (@file :file-name "icicles-doc2.el" :to "Note to Programmers") +;; for more on defining your own commands with `completing-read' and +;; `read-file-name'. + +;;(@* "Traversing Minibuffer Histories") +;; +;; Traversing Minibuffer Histories +;; ------------------------------- +;; +;; Perhaps you are already used to accessing past inputs using the +;; `up' and `down' arrow keys (or `M-n', `M-p', and `next'). If not, +;; try it. You can go backward and forward in the minibuffer +;; histories (there are different history lists for different kinds +;; of input). You can't really cycle them (with wraparound), but +;; when you get to one end you can reverse the direction. +;; +;; Anyway, the input-cycling behavior that Icicles offers is in +;; addition to this standard traversal of histories. Since there +;; are, by default, several extra pairs of keys used for history +;; traversal, rebinding some of them to use for Icicles completion is +;; no real loss. +;; +;; By default, Icicles rebinds the arrow keys `up' and `down' for +;; prefix-completion cycling. Icicles also rebinds `next' and +;; `prior' for apropos-completion cycling. You still have `M-n' and +;; `M-p' available to access past inputs (history). And the +;; rebindings are only for minibuffer input; global bindings are not +;; affected. +;; +;; You can at any time switch back and forth between input-history +;; traversal (`M-n', `M-p') and completion cycling (`down', `up', +;; `next', `prior'). +;; +;; See Also: +;; +;; * (@> "History Enhancements") for new ways to use Emacs history +;; lists with Icicles +;; +;; * (@file :file-name "icicles-doc2.el" :to "Customizing Key Bindings") +;; for how to change the default Icicles key bindings, including +;; the keys used for candidate cycling + +;;(@* "Apropos Completions") +;; +;; Apropos Completions +;; ------------------- +;; +;; Icicles offers a new way to complete your partial input in the +;; minibuffer. Instead of considering the string of input characters +;; to be the prefix of various complete names, you can look for names +;; that match that string anywhere. +;; +;; This is the single most important feature that Icicles offers. +;; +;; This is similar in effect to using command `apropos' to find +;; "apropos completions" of a string (except it works also for file +;; and buffer names), so that's the term I use for this: apropos +;; completion. The more correct characterization of this is that of +;; the previous paragraph, however: names that match the given +;; string. +;; +;; Just as with prefix completion, Icicles lets you cycle among the +;; apropos candidates. To do this, you use keys `next' and `prior'. +;; The root that was completed is underlined in the minibuffer +;; completion candidate. +;; +;; For example, suppose you use `M-x' to enter a command. You don't +;; remember the exact command name, but it has something to do with +;; lines, so you type `M-x line', then hit `next' repeatedly, until +;; you see the right "line" command - `transpose-lines', perhaps. +;; Prefix completion cannot find this command, because "line" is not +;; a prefix of "transpose-lines". +;; +;; Because `M-x' expects a command name, only command names are +;; inserted into the minibuffer as the apropos-completion candidates +;; for `M-x'. Likewise, in other contexts, where names of other +;; kinds of object are expected, apropos completion inserts only +;; names of objects of the appropriate type. Prefix completion works +;; the same way. +;; +;; For example, using `next' and `prior' with `C-x b at' lets you +;; cycle through all buffers (such as `*scratch*') that have "at" in +;; their name - only buffer names appear as candidates. +;; +;; As an alternative to using `next' to cycle forward, you can hit +;; `S-TAB' repeatedly. Similarly, for prefix completion you can +;; repeat `TAB' to cycle forward. See +;; (@> "Prefix Completion and Apropos Completion"). +;; +;; Apropos completion uses a regular expression (regexp) as its input +;; string. You can type `M-x \bes', for instance, to find commands +;; with "es" at the start of a word within the command name (`\b' +;; matches the start of a word). It will find `eshell-test' and +;; `color-theme-blue-eshell', but not `count-lines' - "es" does not +;; start a word in `count-lines'. Similarly, for file names, buffer +;; names, and so on. +;; +;; Prefix completion is actually a special case of apropos +;; completion, where the regexp starts with "^". (That is not how it +;; is implemented, however.) +;; +;; What if you want to see the list of all completion candidates that +;; match the minibuffer input? Instead of cycling candidates +;; blindly, just hit `S-TAB' (Shift TAB) at any time to display the +;; matching candidates in pop-up buffer `*Completions*'. This is +;; analogous to `TAB' for prefix completion. +;; +;; (The documentation always refers to the key that performs apropos +;; completion as `S-TAB'. Actually, it is `S-TAB' only by default. +;; You can customize it, using option +;; `icicle-apropos-complete-keys'.) +;; +;; Everything said in section (@> "Cycling Completions") about the +;; `*Completions*' buffer for prefix completion is also true for +;; apropos completion. It is updated to reflect the current set of +;; matching candidates, and the current completion is highlighted. +;; The root that was completed is highlighted within each candidate +;; (first occurrence only). Root highlighting is more important in +;; the case of apropos completion, because the match position is +;; different in different candidates. In the case of apropos +;; completion, the root is not the input string, taken literally, but +;; the part of a candidate that the input matches. See +;; (@> "*Completions* Display") for additional ways to use the +;; minibuffer with `*Completions*'. +;; +;; Regexp matching is perhaps the most powerful feature of Icicles. +;; Enjoy! Explore! You can at any time switch back and forth +;; between prefix completion (`down', `up'), apropos completion +;; (`next', `prior'), and input history traversal (`M-n', `M-p'). + +;;(@* "Expanded-Common-Match Completion") +;; +;; Expanded-Common-Match Completion +;; -------------------------------- +;; +;; Apropos (regexp) matching and prefix completion each match a +;; pattern against a completion candidate. This operation concerns +;; only a single candidate; it does not take into account the fact +;; that there are others. Since the matching operation is repeated +;; anyway for each candidate, however, we can also find an expanded +;; string that includes the same match (apropos or prefix) for all +;; candidates. +;; +;; For prefix completion, Emacs completes your input to the longest +;; common prefix match. Icicles uses a similar notion for apropos +;; completion. +;; +;; For example, if you enter `M-x minib' and hit `TAB', Emacs +;; completes your input to `minibuffer', which is the longest prefix +;; match for `minib' among all command names. The actual string that +;; matches prefix `minib' among all candidates is, itself, `minib'. +;; +;; If you hit `S-TAB', then each matching candidate contains a +;; substring that matches your regexp input `minib'. In this case, +;; that substring is `minib', just as in the prefix-matching case. +;; And, as in the prefix case, each matching candidate also includes +;; a longer substring, `minibuffer', which includes what your input +;; matches for each candidate. +;; +;; Icicles replaces your regexp input in the minibuffer by a common +;; substring. Icicles highlights this expanded common match in +;; buffer `*Completions*' using face +;; `icicle-common-match-highlight-Completions' (magenta foreground, +;; by default). What your input matches directly is highlighted in +;; `*Completions*' using face `icicle-match-highlight-Completions' +;; (red foreground, by default). +;; +;; It is of course possible that a given regexp match different +;; candidates differently, so that there is no common match. In that +;; case, only the individual matches are highlighted in +;; `*Completions*' - you will see only red, no magenta, highlighting. +;; For example, if your regexp input is `min.*buf' then various +;; different substrings (such as `minibuf' from `minibuffer-complete' +;; and `mint-truncate-buf' from `comint-truncate-buffer') are +;; highlighted in red, but these share no common substring. +;; +;; You will also see only red highlighting if what your input matches +;; directly is the same as the expanded common match. For example, +;; if a function `moccur-regexp-read-from-minibuf' is defined (it is +;; in library `color-moccur.el'), and your input to `C-h f' is +;; `min[^-]*buf', then only `minibuf' is highlighted in red. +;; +;; Expanded-common-match completion is convenient, but when +;; apropos-completing you often need to try variants of a regexp, +;; editing it and observing which candidates match in +;; `*Completions*', until you get the regexp right. +;; Longest-common-match completion has the disadvantage that you lose +;; your regexp as input, which makes it hard to edit it! +;; +;; To retrieve it, use `C-l' (`icicle-retrieve-previous-input') +;; during completion. You can repeat `C-l' to retrieve older +;; completion inputs, cycling among them, and you can use `C-S-l' +;; (that is, `C-L') to cycle previous inputs in the other direction - +;; see (@> "History Enhancements"). You can set option +;; `icicle-expand-input-to-common-match-flag' to nil to turn off +;; longest-common-match completion altogether, if you prefer. You +;; can also toggle it from the minibuffer at any time, using `C-;'. +;; +;; Just what is meant by the "expanded common match" that Icicles +;; finds? It is the longest match of your input pattern that is +;; common to all candidates and also contains the first input match +;; in the first or second candidate, whichever is longer. +;; +;; For apropos completion, this is not always the longest common +;; match of your input, but in most cases it is, and it is quicker to +;; compute. In general, the longest common match does not +;; necessarily contain the first match of your input with either the +;; first candidate or the second candidate. It might contain a +;; different input match from the first in both the first and second +;; candidates. +;; +;; For example, with input `a' and candidates `abacb', `abbac', and +;; `bacba' (in that order), `bac' is the longest common match. But +;; `a' is the longest common match that contains the first match in +;; the first candidate. It is the second match of `a' against +;; `abacb' that yields `bac'. Likewise for the second candidate: it +;; is the second match of `a' against `abbac' that yields `bac'. +;; +;; So in this case Icicles will use `a' as the expanded input and +;; miss the longest common match. If the candidate order is +;; different, so that `bacba' is either the first or the second +;; candidate, then Icicles finds the longest common match, because +;; the first match of `a' against `bacba' yields `bac'. +;; +;; The reason that Icicles common-match expansion typically finds the +;; longest common match is that your input typically matches the +;; first or the second candidate in only one place. And the longer +;; the input you type, the more likely this is. In practice, it is +;; only with very short input such as `a' that Icicles expansion +;; sometimes misses the longest common match. Icicles independently +;; tries two candidates (first and second) as its starting point, to +;; increase the probability of finding the longest common match. +;; +;; It is also technically incorrect to speak of "the" longest common +;; match: in general, there can be more than one. For example, if +;; the input is `a' and the candidates are `abab', `abba', and +;; `baba', then both `ab' and `ba' are longest common substrings. +;; Again, however, for typical input and typical candidates there is +;; a single longest common match, and Icicles finds it. +;; +;; Note that Icicles expanded common match is not just a common +;; substring among all of the candidates that are matched by your +;; input pattern. It is a substring common to all candidates matched +;; by your input, but a substring that also matches your input. For +;; example, with apropos completion input `a.z' and candidates `abz' +;; and `apz', there is no expanded common match. The substring `a' +;; is common to both candidates, but it is not matched by the +;; (complete) input pattern. +;; +;; Finally, note that in Emacs 20 no common match is found if your +;; input or any of the candidates contains binary data. This is +;; because function `string-match' cannot handle strings with binary +;; data in Emacs 20. + +;;(@* "Progressive Completion") +;; +;; Progressive Completion +;; ---------------------- +;; +;; Perhaps the best way to explain this feature is to use a familiar +;; analogy. Unix or GNU/Linux command `grep' takes a +;; regular-expression argument, and matches it against lines in +;; files. A common idiom that people use is to chain, or cascade, +;; multiple calls to `grep', using the output of one as the input to +;; the next. For example: +;; +;; grep plant *.txt | grep food | grep mineral +;; +;; The output of the search for "plant" is used as the input for the +;; search for "food", and the output of that search serves as the +;; input for the search for "mineral". The order of the three +;; component searches can make a difference in terms of performance, +;; but not in terms of the result, which is always the set of lines +;; in files *.txt that match "plant" AND "food" AND "mineral", in any +;; order. Each of the `grep' operations defines a set of matches, +;; and the chain of `grep' operations effects the intersection of +;; those sets. +;; +;; Of course, you could try to accomplish the same thing with a +;; single call to `grep' using a complex regexp. But why would you? +;; +;; Moreover, it is in fact impossible to express such an unordered +;; set intersection using a single regexp. On their own, regular +;; expressions cannot express set intersection (conjunction) or +;; complementing (negation). (However, most `grep' programs provide +;; a way to obtain the lines that do not match a regexp.) +;; +;; The same idea of combining multiple regexp matches is behind the +;; Icicles feature of progressive completion: instead of trying to +;; come up with a single complex regexp that does what you want, try +;; getting there a step at a time: +;; +;; 1. Match an input regexp against the set of all possible +;; completions. +;; +;; 2. Narrow the set of matched candidates by matching them against +;; another input regexp (or by filtering them with a predicate). +;; +;; 3. Narrow those results down by matching them against a third +;; input regexp (or by filtering them with another predicate). +;; +;; 4... And so on. +;; +;;(@* "`M-*': Matching Additional Regexps") +;; ** `M-*': Matching Additional Regexps ** +;; +;; During completion, `M-*' is bound in the minibuffer to command +;; `icicle-narrow-candidates', which prompts for a new regexp and +;; matches it against the current set of completion candidates. +;; +;; For example, suppose that you want to know about an Emacs function +;; that deletes the character to the left of point (that is, +;; backward). You don't recall if it's `delete-character-back', +;; `delete-backward-char', `character-delete-backward', or whatever. +;; You take a guess that the name contains `delete', `char', and +;; `back'. +;; +;; 1. `C-h f char S-TAB' displays function names that contain +;; `char'. +;; +;; 2. `M-* delete' narrows that set of function names to those that +;; also contain `delete'. +;; +;; 3. `M-* back' narrows the set of matching names further, to those +;; that also contain `back'. +;; +;; This displays a list of functions like this in `*Completions*' +;; (your list might be somewhat different): +;; +;; backward-delete-char backward-delete-char-untabify +;; delete-backward-char icicle-backward-delete-char-untabify +;; icicle-delete-backward-char +;; quail-conversion-backward-delete-char +;; +;; Then, of course, you can pick one (or you can use `C-M-next' +;; repeatedly to view the doc of each of these functions in turn - +;; see (@> "Get Help on Candidates")). +;; +;; You get the idea. This feature is both very simple to use and +;; very useful. It's easy to appreciate using multiple simple +;; matching steps (regexp or not) instead of a single regexp. Try it +;; once, and you'll be hooked. +;; +;;(@* "Successive Approximation...") +;; ** Successive Approximation... ** +;; +;; You can use as many invocations of `M-*' (and of `M-&', described +;; in the next section) as you like, in any order. It works with +;; both prefix completion and apropos completion. You can, for +;; instance, first use `TAB' to require the target to start with some +;; string, and then use `M-*' to specify other patterns that parts of +;; it must also match. However, it of course makes no sense to use +;; `TAB' instead of `S-TAB' after you use `M-*': once you've said +;; that the target must start with "fo" there is no sense saying that +;; it also starts with "ti"! +;; +;; As a shortcut, instead of using `S-TAB' followed by `M-*', you can +;; use `S-SPC' (command `icicle-apropos-complete-and-narrow') to do +;; the same thing. You can thus use only `S-SPC', any number of +;; times, to choose a candidate by narrowing down the matches. +;; +;; I call this process of completion by successive approximation, or +;; progressively narrowing the candidate set, "progressive +;; completion". If the name "incremental completion" (= icompletion) +;; were not already taken to mean incremental completion *help* +;; (which performs no completion), then that might be a good name for +;; this. This might also be called "stepped", "cascaded", or +;; "piecewise" completion. +;; +;; Another possible name for it would be "multiple completion", but I +;; use that to stand for simultaneous (parallel) completion of +;; multiple parts of a compound target, which is something different +;; (see (@file :file-name "icicles-doc2.el" :to "Multi-Completions")). +;; Progressive completion is a set of mini-completions that are wired +;; in series, not in parallel. +;; +;; Note that when you use `M-*' (or `S-SPC') in the minibuffer, it +;; calls `completing-read' or `read-file-name', which creates a +;; recursive minibuffer. That is, the minibuffer depth is increased. +;; (This is not the case for `M-&', however.) In vanilla Emacs, +;; there is no indicator of the current minibuffer depth, and this +;; can sometimes be disorienting. Each time you use `M-*' you push +;; down one level of minibuffer recursion (that is, minibuffer depth +;; is incremented). Each time you use, say, `C-g', you pop up one +;; level of minibuffer recursion (that is, minibuffer depth is +;; decremented). +;; +;; If you use library `mb-depth.el', which is included with Emacs 23 +;; and which also works with Emacs 22, Icicle mode takes advantage of +;; this library by indicating the current depth in the minibuffer. I +;; recommend you also use my library `mb-depth+.el', which lets you +;; customize the form and face of the depth indicator. +;; +;; If you use my library `oneonone.el', then you get visual feedback +;; on the current minibuffer depth. One-On-One Emacs gives you a +;; standalone minibuffer frame, and it changes the background hue +;; (color) of that frame slightly with each change in minibuffer +;; depth. This is especially helpful with Icicles, where use of +;; `M-*' (or `S-SPC') is common. +;; +;; There is a slight difference in behavior between Icicles commands +;; and some other Emacs commands when you accept input after `M-*'. +;; When possible, Icicles accepts your input and passes it +;; immediately to the top level, bypassing any intermediate recursive +;; minibuffer levels that are waiting for input. However, Emacs +;; commands that are defined with literal-string `interactive' specs, +;; such as (interactive "fFile: "), do not use `completing-read' or +;; `read-file-name', so there is no way for Icicles to take this +;; shortcut with them. In that case, you will simply need to hit +;; `RET' again to accept your input at each recursive minibuffer +;; level, until you get back to the top level. Sorry for this +;; inconvenience! If you are an Emacs-Lisp programmer, note that +;; this is one reason to use `completing-read' and `read-file-name' +;; when you write commands that use completion. +;; +;; Note: If you use progressive completion with file names in Emacs +;; 20 or 21, `M-*' calls `completing-read', not `read-file-name'. +;; This is because `read-file-name' does not accept a PREDICATE +;; argument before Emacs 22. The effect is that instead of there +;; being a default directory for completion, the current directory at +;; the time you hit `M-*' is tacked onto each file name, to become +;; part of the completion candidates themselves. Yes, this is a +;; hack. It works, but be aware of the behavior. +;; +;; Progressive completion lets you match multiple regexps, some of +;; which could of course be literal substrings, with their regexp +;; special characters, if any, escaped. If you need to match such +;; substrings at particular locations in the target completion +;; candidate, then progressive completion won't do the job - it +;; matches its component regexps independently. You can regexp-quote +;; (escape) parts or all of your input using `C-M-;' +;; (`icicle-regexp-quote-input'). +;; See (@> "Quoting (Escaping) Special Characters") +;; +;;(@* "`M-&': Satisfying Additional Predicates") +;; ** `M-&': Satisfying Additional Predicates ** +;; +;; If you use Icicles, then you will use `M-*' very often. This +;; section describes a seldom-used feature that can be useful in +;; certain contexts. If you are new to Icicles or you are unfamiliar +;; with Emacs Lisp, then you might want to just skim this section or +;; skip it and come back to it later. +;; +;; Just as you can use `M-*' to narrow the set of candidates by +;; matching an additional regexp, so you can use `M-&' (bound to +;; `icicle-narrow-candidates-with-predicate') to narrow by satisfying +;; an additional predicate. The idea is the same; the only +;; difference is that, instead of typing a regexp to match, you type +;; a predicate to satisfy. +;; +;; The predicate is a Boolean function of a single completion +;; candidate. At the prompt, you enter its name or its +;; lambda-expression definition (anonymous function). The predicate +;; is used the same way as the PREDICATE argument to +;; `completing-read' and `read-file-name'. This means that the +;; candidate argument to the predicate is whatever is used in the +;; original call to `completing-read' or `read-file-name'; it is not +;; just a string such as you see in buffer `*Completions*'. To +;; provide an appropriate predicate, you must be familiar with the +;; kind of candidate expected by the command you invoked before just +;; before `M-&'. +;; +;; For example: +;; +;; * Command `describe-function' (`C-h f') uses candidates that are +;; symbols. An appropriate predicate would accept a symbol as +;; argument. +;; +;; * Command `icicle-search' (`C-c `') uses candidates that have this +;; form: (CONTEXT . MARKER), where CONTEXT is a string, the search +;; hit (search context), and MARKER is a buffer marker that locates +;; the CONTEXT. An appropriate predicate would accept such a +;; candidate as argument. +;; +;; Although entering a lambda expression at a prompt might not seem +;; too convenient, you can at least retrieve previously entered +;; predicates (using `M-p' and so on). +;; +;; You can also use `C-M-&' (bound to +;; `icicle-save-predicate-to-variable') at any time during completion +;; to save the current predicate as a string-valued variable. By +;; default, the variable is `icicle-input-string'. You can then +;; retrieve the saved string later, using `C-=' at the prompt for +;; `M-&'. The current predicate is what is saved. You can build up +;; a complex predicate, and then save it for later use. +;; +;; The inconvenience of typing an Emacs-Lisp sexp must be balanced +;; against the power of applying predicates on the fly. Whereas +;; regexp matching is purely syntactic, with a predicate you can +;; perform semantic tests. During search, for instance, you can look +;; not only for a syntax match; you can look for matching search +;; candidates that also belong to a particular class of objects +;; (e.g. function, variable, type) or that satisfy some other +;; semantic property. +;; See also (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview"). +;; +;; See Also: +;; +;; * (@> "Sets of Completion Candidates") for another way to perform +;; a set intersection on sets of candidate completions. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; for a way to search using two regexps - command `icicle-search' +;; uses the same idea as that behind progressive completion. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Compile/Grep Search") +;; for a way to grep files using multiple levels of regexps, and +;; performing selected replacements. + +;;(@* "Regressive Completion") +;; +;; Regressive Completion +;; --------------------- +;; +;; Though generally less useful than progressive completion, you can +;; also widen, instead of narrow, the current set of completion +;; candidates, by providing an alternative pattern (regexp) to match. +;; By analogy, I call this "regressive completion". +;; +;; The analogy is not exact. By definition, your current input is +;; always matched against all candidates in the domain of discourse. +;; With progressive completion, a recursive minibuffer is entered for +;; each new pattern to match. The candidates that matched the +;; previous input of the progression become the new domain of +;; discourse for the current act (recursive level) of completion. +;; +;; That same technique is not applicable for widening. Instead, you +;; enter, using `RET', a new pattern to match as an alternative, and +;; Icicles changes the current input to a regexp that matches either +;; what the previous input matched or the alternative pattern. In +;; other words, it is just a short cut for typing a regexp that +;; matches a choice: \(...\|...\). The domain of discourse remains +;; the same - in particular, there is no way to widen the domain of +;; discourse like narrowing narrows it. +;; +;; You use `M-+' (`icicle-widen-candidates') for regressive +;; completion - think of the `+' as set union (OR), just as you think +;; of the `*' in `M-*' as set intersection (AND). And, just as for +;; progressive completion, there is a shortcut, `S-backspace', for +;; `S-TAB' followed by `M-+'. +;; +;; For example, if you want to see all of the candidates that contain +;; either `for' or `back', you could type `\(for\|back\)' in the +;; minibuffer, or you could just type `for', then `S-backspace' (or +;; `S-TAB' followed by `M-+'), then `back'. Icicles replaces your +;; input by `\(for\|back\)'. You can continue with additional +;; alternative match patterns. And you can combine narrowing with +;; widening, that is, progressive with regressive completion. +;; +;; You can of course cycle among all matching candidates, regardless +;; of which alternative they match. One use of regressive completion +;; is with Icicles search - it corresponds to the OR searching of +;; common search engines. + +;;(@* "Completion On Demand") +;; +;; Completion On Demand +;; -------------------- +;; +;; When the minibuffer is active for your input, completion is not +;; always available. Functions such as `completing-read' and +;; `read-file-name' provide completion, but other functions that read +;; input in the minibuffer, such as `read-from-minibuffer' and +;; `read-string', do not provide completion. +;; (See (@> "Completion Status Indicators"), for how to tell when +;; completion is available in Icicles.) +;; +;; But in Icicles you can always invoke (lax) completion to insert +;; some completed text in the minibuffer - this is completion on +;; demand. +;; +;; On-demand completion is always available to insert a file name. +;; You invoke this using `C-M-F', that is, `C-M-S-f' +;; (`icicle-read+insert-file-name'). A recursive minibuffer is used +;; to perform the completion. The result of completing is inserted +;; at point in the parent minibuffer, without replacing any other +;; text that might already be there. +;; +;; You can use this feature to add multiple file or directory names +;; to the same minibuffer input. In this way, for instance, you can +;; use it to add particular file or directory names as arguments to a +;; shell command that you input in the minibuffer. By default, a +;; relative name is inserted, but if you use a prefix argument then +;; the directory component is included. +;; +;; Similarly, you can use `C-M-C', that is, `C-M-S-c' +;; (`icicle-completing-read+insert'), to invoke non file-name +;; completion. This, however, is available only if the command +;; reading from the minibuffer allows it, by defining a set of +;; possible completions. +;; +;; The actual keys used for on-demand completion are customizable, +;; using options `icicle-read+insert-file-name-keys' and +;; `icicle-completing-read+insert-keys'. The default values are +;; `C-M-S-f' and `C-M-S-c'. +;; +;; Another kind of on-demand completion is provided by `M-o' +;; (`icicle-insert-history-element'). Again, this is always +;; available in the minibuffer, regardless of whether input is being +;; read with completion. This invokes completion against the entries +;; in the current minibuffer history. +;; See (@> "History Enhancements"). + +;;(@* "Moving Between the Minibuffer and Other Buffers") +;; +;; Moving Between the Minibuffer and Other Buffers +;; ----------------------------------------------- +;; +;; Sometimes, when the minibuffer is active, you might want to move +;; the cursor and focus from the minibuffer back to the original +;; buffer from which you activated the minibuffer. When you are in +;; Icicle mode, the `pause' key is bound (by default) to command +;; `icicle-switch-to/from-minibuffer', which does that. This lets +;; you start minibuffer input (with or without completion), and then +;; interrupt it to search, edit, and so on, in the original buffer. +;; This same command (bound to `pause') then lets you switch back to +;; the minibuffer - it acts as a toggle for the input focus; go back +;; and forth as much as you like. +;; +;; This can be especially useful when you use multi-commands (see +;; (@> "Multi-Commands")). In that case, you often keep the +;; minibuffer active for completion while performing multiple +;; completion actions. It can be handy to interrupt this to perform +;; some normal editing or search, and then resume multi-command +;; actions. +;; +;; Another use for this feature is to select text in the original +;; buffer and then insert it in the minibuffer. See also +;; (@> "Inserting Text Found Near the Cursor") for another way to do +;; that. +;; +;; A somewhat related toggle is available using `C-insert'. This +;; lets you switch the focus between the minibuffer and buffer +;; `*Completions*'. See (@> "*Completions* Display") for more +;; information. + +;;(@* "Inserting a Regexp from a Variable or Register") +;; +;; Inserting a Regexp from a Variable or Register +;; ---------------------------------------------- +;; +;; Regexps are powerful, but they can sometimes be complex to compose +;; and hard to remember once composed. A shortcut is to compose a +;; regexp that you want to use and assign it to an Emacs variable or +;; register. +;; +;; If you assign it to a register (using `C-x r s'), then you can use +;; `C-x r i' (`insert-register') in the minibuffer to insert it. If +;; you assign it to a string, then you can use `C-=' +;; (`icicle-insert-string-from-variable') to insert it. +;; +;; If you use `C-u C-=' (provide a prefix argument) then you are +;; prompted for the variable to use. You can use any variable. +;; Without `C-u', the default variable is used (no prompting), +;; `icicle-input-string'. So, for example, if `icicle-input-string' +;; had value "[a-zA-Z]+" then it would match any completion candidate +;; composed only of letters. You can customize +;; `icicle-input-string'. +;; +;; For convenience, instead of using Lisp evaluation of a sexp such +;; as (setq icicle-input-string "[a-zA-Z]+") or (setq my-var ".*"), +;; you can use Icicles command `icicle-save-string-to-variable' to +;; save a regexp to a variable. You are prompted for the regexp to +;; save. Just as for `icicle-insert-string-from-variable', with a +;; prefix argument you are prompted for the variable to use; with no +;; prefix argument the regexp is saved to variable +;; `icicle-input-string'. +;; +;; Another way of inserting a string into the minibuffer is to use a +;; negative prefix arg with `M-:' (e.g. `M-- M-:') during minibuffer +;; input. With this method, you can type not only a string-valued +;; variable name but any Emacs-Lisp expression. The expression need +;; not evaluate to a string - whatever the result of evaluation is, +;; it is pretty-printed in the minibuffer, to be used as part of your +;; input text. +;; +;; These shortcut features are especially convenient for use with +;; command `icicle-search' - you can use it to search text for +;; sentences, paragraphs, file names, URLs, dates, times, function +;; definitions, and any other text entities that you can specify by +;; regexp. Create a library of regexp-valued variables that are +;; useful to you, and use `C-=' to quickly access them in +;; `icicle-search'. See +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; for more information. +;; +;; See Also: (@> "Inserting Text Found Near the Cursor"). + +;;(@* "Special Characters in Input Patterns") +;; +;; Special Characters in Input Patterns +;; ------------------------------------ +;; +;; Regular-expression syntax treats some characters specially, but +;; some of these special characters have another special meaning in +;; Emacs when used with file-name inputs. What about the conflict +;; between interpreting characters such as `$', `\', `.', `?', and +;; `*' as 1) regexp special characters and 2) special characters for +;; file-name input? For example, when inputting a file name, should +;; `*' be treated as a regexp multiple-occurrences operator or as a +;; file-name wildcard? +;; +;; In Emacs file-name input: +;; +;; - `$' can be used to prefix environment variables. +;; +;; - `*' and `?' can be used as wildcards, effectively inputting +;; multiple file names at once. +;; +;; - `.' and `..' can be used to navigate a directory hierarchy. +;; +;; - `\' is a directory separator, like `/', on MS Windows, at least. +;; +;; Icicles handles the conflict by interpreting such characters as +;; regexp special characters only during input completion and cycling +;; - and then only if you do not escape them (with `\'). If present +;; in the input when you finally accept it (using `RET'), they take +;; on their normal Emacs meanings for file-name input: +;; environment-variable prefix, wildcard, directory abbreviation, or +;; directory separator. +;; +;; That is, whenever there is a potential conflict of interpretation, +;; the regexp meaning is used for completion and cycling, and the +;; standard interpretation for file-name input is used for accepting +;; the input. So, for example, to get the wildcard interpretation of +;; `*', just forego regexp completion and cycling. And vice versa: +;; forego the wildcard interpretation to use regexp completion and +;; cycling. +;; +;; This is in any case the behavior of vanilla Emacs as well. If, in +;; vanilla Emacs, you use `ici*' or `ici*.el' as input to `find-file' +;; and hit `TAB', there is no completion available. File-name +;; globbing and completion are independent. +;; +;; Note: Because `?' is useful in regexp syntax, the standard Emacs +;; minibuffer binding of `?', which just displays the +;; completion-candidates list, is not used in Icicles. In +;; Icicles, `?' self-inserts in the minibuffer, like any other +;; printable character. (Use `TAB' or `S-TAB' to display the +;; list.) In standard Emacs, you must quote `?' or +;; copy-and-paste it, to insert it in the minibuffer for use as +;; a file-name wildcard. +;; +;; The interpretation conflict for `\' (on MS Windows) is not really +;; a problem, anyway. Although you cannot use a backslash (`\') as a +;; directory separator during apropos completion and cycling, you can +;; always use a slash (`/') instead - even on MS Windows. The best +;; practice is to just break with MS-Windows syntax, and get in the +;; habit of always using `/' as the directory-separator character. +;; +;; But what if you copy an absolute filename from some MS Windows +;; application, so it has backslashes, and you want to use it in +;; Emacs? You can go ahead and paste it in the minibuffer for +;; filename completion, as long as you are not doing regexp +;; completion. You can (a) use prefix completion with it, (b) use +;; `C-`' to turn on regexp quoting for apropos completion (so you can +;; complete a substring), or (c) change the backslashes to slashes. +;; +;; Even if you always use only slash, not backslash, as a directory +;; separator when inputting, however, it is possible that you could +;; run into some trouble on MS Windows. You might (knowingly or not) +;; use `\' as a directory separator in the values of environment +;; variables that you use as part of file-name input. If you are +;; regexp completing, then those backslashes will be treated as +;; regexp escapes. So you should use only non-regexp completion with +;; input that includes environment variables whose expansions might +;; include backslashes. +;; +;; The interpretation conflict for `$' is also not a real problem. +;; You can get the effect of both interpretations of `$' at the same +;; time, because Icicles recognizes that `$' at the end of input +;; cannot be an environment-variable prefix. This means, for +;; example, that you can use a pattern such as `$HOME.*t$' to match +;; the files in your home directory whose names end in `t'. +;; +;; The first `$' here is not treated specially during regexp matching +;; and cycling; the environment variable `$HOME' is expanded by the +;; shell to a directory name. The second `$' is treated as the +;; regexp special character that matches at the end of a line. When +;; using environment variables, you can also enclose them in braces: +;; `${HOME}', for example. +;; +;; Note: Starting with Emacs 23, if option +;; `icicle-TAB-completion-methods' includes `vanilla', and you choose +;; `vanilla' completion for `TAB' (by cycling using `C-(' or by +;; customizing `icicle-TAB-completion-methods' to use `vanilla' as +;; the default), then Icicles `TAB' completion will complete an +;; environment variable during file-name completion. This is in +;; addition to the traditional shell expansion of a variable when you +;; hit `RET'. +;; +;; Tip: Because slash (`/') is about the only non-word syntax +;; character that is likely to appear in file-name completions, +;; you can usually use `\W$' to match only directories (by +;; matching the `/' at the end of their names). `\W' is the +;; regexp pattern that matches any character that does not +;; appear in words. For example, you can use `${HOME}\W$' to +;; match all direct subdirectories in your home directory. +;; +;;(@* "Quoting (Escaping) Special Characters") +;; ** Quoting (Escaping) Special Characters ** +;; +;; You can toggle interpretation vs escaping of regexp special +;; characters at any time, using `C-`' in the minibuffer (command +;; `icicle-toggle-regexp-quote'). Escaping special characters this +;; way means they are no longer special; they simply match +;; themselves. This has the effect of reducing apropos completion to +;; simple substring completion. If you never want to use regexp +;; matching (*not* recommended!), you can customize user option +;; `icicle-regexp-quote-flag', setting it to non-nil. +;; +;; Apropos (regexp) completion contains literal substring completion +;; as a (common) special case. Sometimes you want to use regexp +;; completion, but you also want to match a literal substring that +;; contains special characters. You can of course quote (escape) +;; each of these characters by hand. Alternatively, you can use +;; `C-M-;' (`icicle-regexp-quote-input') to quote the text that you +;; want to match literally. If the region is active, then it is +;; quoted; otherwise, your entire minibuffer input is quoted. +;; +;; Note that if a substring that you want to match literally can +;; occur anywhere in the target completion candidate, then it is +;; simpler to just use progressive completion. Quoting a literal +;; substring is useful when the overall regexp requires it to be at a +;; certain location in the target. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Dired Enhancements") +;; for how to use Icicles regexp-matching to open Dired on sets of +;; files that you might not be able to specify using file-name +;; wildcards. +;; +;; * (@> "Multi-Commands") for a way to open multiple files whose +;; names match a regular expression. +;; +;; * (@file :file-name "icicles-doc2.el" :to "File-Name and Directory-Name Completion Tips") +;; for: +;; - Information about abbreviating your home directory as `~' or +;; expanding it. +;; - A way to locate and open files by regexp anywhere in your file +;; system - that is, match against directory-name as well as +;; file-name components. +;; +;; * (@> "Progressive Completion") + +;;(@* "Exiting the Minibuffer Without Confirmation") +;; +;; Exiting the Minibuffer Without Confirmation +;; ------------------------------------------- +;; +;; Normally, if you exit the minibuffer with input that only +;; partially matches a completion candidate, the value you input is +;; exactly what you typed. That is, exiting does not automatically +;; complete your input - what you type is what you get. This is +;; "lax" (or "permissive") completion, and it is desirable most of +;; the time, because it lets you input a value that does not +;; correspond to any of the completion candidates. This is how, for +;; instance, you can use `C-x C-f' to open a new file or `C-x b' to +;; create a new buffer. +;; +;; However, some people prefer "strict" completion: limiting input to +;; the available completion candidates. This can be handy in the +;; case of switching to a buffer, for instance. If you have a buffer +;; named `new-ideas.txt', you might like to be able to type only +;; `new' followed by `RET', and not have to first complete the input +;; text. This is the behavior of libraries `ido.el' and +;; `iswitchb.el'. +;; +;; It is the command you use that decides whether `RET' first +;; completes your input before exiting the minibuffer (strict +;; completion) or not (lax completion). This is done in the command +;; definition by providing a non-nil or nil REQUIRE-MATCH argument to +;; function `completing-read', which prompts you and reads your +;; input, possibly completing it. +;; +;; If you use standard Emacs command `switch-to-buffer' then +;; completion is lax: `RET' does not complete your input `new' to +;; `new-ideas.txt'; it simply accepts your input as is, and creates a +;; new buffer with that name, `new'. +;; +;;(@* "Using `S-RET' to Accept a Partial Match") +;; ** Using `S-RET' to Accept a Partial Match ** +;; +;; By default, Icicles command `icicle-buffer', not vanilla command +;; `switch-to-buffer', is bound to `C-x b' in Icicle mode. The +;; default behavior of `icicle-buffer' is the same as the behavior of +;; `switch-to-buffer' with respect to `RET'. However, you can obtain +;; the complete-and-exit `RET' behavior with `icicle-buffer' by +;; setting option `icicle-buffer-require-match-flag' to +;; `partial-match-ok'. This value overrides the REQUIRE-MATCH +;; argument to `completing-read', in effect forcing it to `t'. +;; +;; Whenever completion is strict, requiring a match against one of +;; the completion candidates (typically, an existing file or buffer +;; name), you can complete and exit the minibuffer all at once, with +;; only partial input in the minibuffer, by using `RET'. But what +;; about apropos completion? Simply use `S-RET' +;; (`icicle-apropos-complete-and-exit') instead of `RET': `RET' is +;; standard in Emacs and uses prefix completion; `S-RET' is specific +;; to Icicles and uses apropos completion. For example, you can type +;; `idea' followed by `S-RET' to switch to buffer `new-ideas.txt'. +;; +;; Note: You can customize `icicle-top-level-key-bindings' to prevent +;; the rebinding of `C-x b' in Icicle mode. +;; +;;(@* "Accepting Partial Matches by Default") +;; ** Accepting Partial Matches by Default ** +;; +;; For those people who prefer that a partial match always be +;; accepted immediately, regardless of the context (whether a match +;; is required or not) and without having to use `RET' or `S-RET', +;; there is Icicles user option +;; `icicle-top-level-when-sole-completion-flag'. If you set this to +;; non-nil, then, whenever your input matches only one candidate +;; completion, that candidate is used immediately. I don't recommend +;; this practice generally, but some people might prefer it. +;; +;; Option `icicle-top-level-when-sole-completion-delay' is the number +;; of seconds Icicles waits, before returning to top level with the +;; sole completion. It has no effect if +;; `icicle-top-level-when-sole-completion-flag' is nil. The delay +;; gives you a chance to forestall acceptance of the sole completion: +;; editing the completion (typing or deleting a character) before the +;; delay expires prevents its automatic acceptance. +;; +;; See Also: (@* "Ido and IswitchB") + +;;(@* "Ido and IswitchB") +;; +;; Ido and IswitchB +;; ---------------- +;; +;; Libraries Ido and IswitchB are alternatives to Icicles that also +;; enhance minibuffer completion in various ways. Their UIs are +;; similar to each other - Ido essentially extends IswitchB's +;; buffer-name completion to file names as well. Neither completes +;; other kinds of candidates. They work only for buffer names or +;; file names, but you can advise the standard completion functions +;; to get them to use Ido completion more generally. +;; +;; The behavior of Ido and IswitchB is different from the default +;; Icicles behavior. If you prefer their behavior for buffers then +;; you can just use IswitchB and Icicles together. You cannot use +;; Icicles and Ido together, however - they use the minibuffer in +;; incompatible ways. +;; +;; The default behavior of Icicles is different, but you can make +;; Icicles behave more like Ido if you like. It would be a mistake +;; to look for a complete reproduction of the Ido behavior in +;; Icicles, however. If you want exactly the same behavior as Ido, +;; then use Ido. ;-) +;; +;; The Icicles UI is different by design. Some of this difference in +;; approach has to do with the fact that Ido is specialized to +;; buffer- and file-name completion. The generality of Icicles makes +;; a different approach appropriate. Icicles has many additional +;; features that are not available in other libraries, but its main +;; advantage is its generality: you use the same user interface for +;; input of any kind. As you learn more about Icicles you may begin +;; to appreciate its approach, even if you are a diehard Ido addict. +;; +;; This section summarizes some differences between Icicles and Ido +;; and tells you how you can get more Ido-like behavior in Icicles if +;; that's what you prefer. It does not cover Icicles features that +;; have no counterpart in Ido or features that they have in common +;; (except to emphasize some differences). +;; +;; If you have the Ido habit but want to give Icicles a try, then +;; this section is for you. I recommend, however, that you give the +;; default Icicles behavior a good try before convincing yourself +;; that you still prefer a more Ido-like approach. +;; +;; See also the references at the section end for other sections that +;; go into more detail about some of the things mentioned here. +;; +;; 1. Incremental completion. By default, Icicles does not turn on +;; incremental completion until you have hit `TAB' or `S-TAB' to +;; display the matching candidates. Ido turns it on immediately. +;; You can get that behavior by setting option +;; `icicle-show-Completions-initially-flag' to t. +;; +;; You can get an intermediate behavior in this regard by instead +;; setting option `icicle-incremental-completion-flag' to a value +;; other than nil and t. That makes Icicles show the matching +;; candidates as soon as you start typing input. See also option +;; `icicle-incremental-completion-delay'. +;; +;; 2. Matching. By default, Ido uses substring matching for +;; completion. You can hit a key to switch to prefix matching, +;; "flex" matching, or regexp matching. Icicles gives you these +;; same matching possibilities, and more. (What Ido calls "flex" +;; matching Icicles calls "scatter" matching.) The main +;; difference here is that Icicles regexp support is general and +;; complete. Regexp-matching in Ido does not work with Ido-style +;; completion. +;; +;; 3. Current candidate, cycling, sorting. Both Ido and Icicles have +;; a notion of "current candidate". In Ido, completion candidates +;; are presented in a predefined sort order, most recently used +;; first. The current candidate is the first one. You cycle +;; candidates by moving the first to last or the last to first. +;; +;; In Icicles, you can switch among any number of sort orders at +;; any time by hitting a key. (And you can easily define your own +;; sort orders.) When you cycle candidates, the candidates stay +;; in order. If the candidates are displayed in `*Completions*' +;; then the current one is highlighted there, in place. The +;; highlight moves, not the candidate. +;; +;; 4. Input editing. In Ido, cycling does not replace your input by +;; the current candidate. To edit the current candidate you hit a +;; key to enter an edit mode (recursive minibuffer). In Icicles, +;; cycling replaces your input in the minibuffer by the current +;; candidate, so you can just edit it there normally. You can use +;; `C-l' to retrieve your original input. +;; +;; 5. Completions shown. In Ido, a limited number of matching +;; completion candidates are shown in the minibuffer. You can hit +;; a key to see all matches in a separate buffer. +;; +;; In Icicles, completion candidates are always shown in buffer +;; `*Completions*', not in the minibuffer. You can limit the +;; number of matches shown by customizing option +;; `icicle-max-candidates'. Only the first +;; `icicle-max-candidates' (in the current sort order) are shown. +;; +;; You can also increment and decrement this truncation value on +;; the fly during completion, by hitting `C-x #' and then using +;; the vertical arrow keys or the mouse wheel. (For that feature +;; you also need library `doremi.el'.) +;; +;; 6. Auto-choice of sole candidate. In Ido, if there is only one +;; match for your input then `TAB', which normally completes, also +;; chooses that candidate - you do not need to hit `RET'. By +;; default, Icicles always requires you to explicitly choose with +;; `RET' (or `C-RET'). If you set option +;; `icicle-top-level-when-sole-completion-flag' to non-nil, then +;; Icicles provides similar behavior to Ido. See also option +;; `icicle-top-level-when-sole-completion-delay'. +;; +;;(@* "Ido-Like Behavior Everywhere: `icicle-ido-like-mode'") +;; ** Ido-Like Behavior Everywhere: `icicle-ido-like-mode' ** +;; +;; If you want Icicles to be Ido-like in general, then turn on global +;; minor mode `icicle-ido-like-mode' (not available in Emacs 20). +;; Doing that sets options `icicle-show-Completions-initially-flag' +;; and `icicle-top-level-when-sole-completion-flag' to t. Turning +;; the mode off sets them to nil. +;; +;; You can simultaneously set option `icicle-max-candidates' when you +;; turn on `icicle-ido-like-mode', by using a positive prefix +;; argument. If you want the option to keep that value when you turn +;; the mode off, then use a zero or negative prefix argument. +;; Otherwise, it is reset to nil (no limit on the number of +;; candidates displayed). +;; +;; When you use this mode, you might also want to use nil or t as the +;; value of option `icicle-default-value', in order to not insert the +;; default value in the minibuffer. If you want to change that +;; option dynamically for the mode, use `icicle-ido-like-mode-hook'. +;; E.g.: +;; +;; (add-hook 'icicle-ido-like-mode-hook +;; (lambda () (setq icicle-default-value +;; (if icicle-ido-like-mode t 'insert-end)))) +;; +;;(@* "Ido-Like Behavior for Buffers and Files") +;; ** Ido-Like Behavior for Buffers and Files ** +;; +;; If you want Ido-like behavior in Icicles for buffers or files, but +;; not in general, then customize either or both options +;; `icicle-buffers-ido-like-flag' and `icicle-files-ido-like-flag' to +;; non-nil. +;; +;; See Also: +;; +;; * (@> "Exiting the Minibuffer Without Confirmation") +;; * (@file :file-name "icicles-doc2.el" :to "Customization and General Tips"): +;; `icicle-buffer-require-match-flag', +;; `icicle-deletion-action-flag', +;; `icicle-file-require-match-flag', +;; `icicle-show-Completions-initially-flag', +;; `icicle-incremental-completion-flag', +;; `icicle-incremental-completion-delay', +;; `icicle-max-candidates', +;; `icicle-regexp-quote-flag', +;; `icicle-top-level-when-sole-completion-flag', +;; `icicle-top-level-when-sole-completion-delay', +;; * (@file :file-name "icicles-doc2.el" :to "Fuzzy Completion") +;; * (@> "Special Characters in Input Patterns") +;; * (@> "Prefix Completion and Apropos Completion") +;; * http://www.emacswiki.org/emacs/IciclesDiscussion#IdoAndIcicles +;; (out-of-date discussion, but it might be helpful) + +;;(@* "*Completions* Display") +;; +;; *Completions* Display +;; --------------------- +;; +;; Icicles enhances the `*Completions*' display in several ways. The +;; following features are available whenever buffer `*Completions*' +;; is displayed. +;; +;; * In buffer `*Completions*', you can use the arrow keys (`up', +;; `down', `left', `right') to navigate among the candidate +;; completions. The current candidate (under the cursor) is +;; highlighted. +;; +;; * When you cycle completions in the minibuffer: +;; +;; - The current candidate is highlighted in `*Completions*'. +;; +;; - Help on the current candidate (typically, the first line of a +;; doc string) is displayed in the mode line, provided user +;; option `icicle-help-in-mode-line-flag' is non-nil. +;; +;; * The total number of completion candidates is displayed in the +;; mode-line of buffer `*Completions*' - e.g. `567 candidates'. +;; If the number of candidates is currently truncated (because of +;; option `icicle-max-candidates' - see +;; (@file :file-name "icicles-doc2.el" :to "Customization and General Tips"), +;; then the total number of candidates before truncation is also +;; shown - e.g. `149 shown / 567'. +;; +;; * You can use `C-insert' to move back and forth between the +;; minibuffer and `*Completions*'. In each direction, the current +;; candidate is tracked in the destination buffer. For example, if +;; the candidate in the minibuffer is `foobar', after you hit +;; `C-insert' the cursor is on `foobar' in `*Completions*'. In the +;; other direction, if the cursor is on `foobar' in +;; `*Completions*', after you hit `C-insert' the current input in +;; the minibuffer is `foobar'. +;; +;; * `*Completions*' can also serve as a new kind of icompletion help +;; - see (@> "Icompletion"). +;; +;; * You can choose multiple candidates during completion, by +;; clicking them with `mouse-2' while holding the Control key +;; pressed. See (@> "Multi-Commands"). You can choose a set of +;; candidates in additional ways, and then act on all of them - see +;; (@> "Sets of Completion Candidates"). +;; +;; * Icicles dynamically resizes the `*Completions*' window +;; vertically, to fit the current set of completion candidates. +;; The window is not resized, however, if buffer `*Completions*' +;; appears in its own frame. (It is also not resized in Emacs +;; releases prior to 21.) +;; +;; You can control this automatic resizing generally or on a +;; per-command basis: +;; +;; * User option `icicle-Completions-window-max-height' is the +;; maximum number of lines to show in the `*Completions*' +;; window. +;; +;; * You can override the behavior of option +;; `icicle-Completions-window-max-height' for any given command, +;; by setting property `icicle-Completions-window-max-height' on +;; the command symbol to a different maximum window height +;; value. This property value is predefined for commands, such +;; as `icicle-buffer' and `icicle-file', that do not involve the +;; content of the current buffer during completion. A large +;; value is used for these commands, so that nearly all of the +;; frame real estate is given to the `*Completions*' window. +;; +;; For example, you can use the following code to set the maximum +;; `*Completions*' height for command `foo' to 100 and turn off +;; per-command control of the height for command `bar'. If you use +;; such code, evaluate it after you load Icicles. +;; +;; (put 'foo 'icicle-Completions-window-max-height 100) +;; (put 'bar 'icicle-Completions-window-max-height nil) +;; +;; * Starting with Emacs 23, if you also use Do Re Mi library +;; `doremi-frm.el', then you can use `C-x -' in the minibuffer to +;; zoom the `*Completions*' buffer text, shrinking or enlarging it +;; incrementally using `-' or `=', respectively (`=' is typically +;; on the same keyboard key as `+', but it needs no Shift). +;; +;; Also starting with Emacs 23 (whether or not you use +;; `doremi-frm.el'), you can specify an initial text-scale amount +;; for the `*Completions*' text, by customizing option +;; `icicle-Completions-text-scale-decrease'. This controls the +;; default appearance. +;; +;; You typically use these features to make the `*Completions*' +;; text a bit smaller and thus save screen real estate - show more +;; candidates in less space. However, Emacs 23 text-scaling does +;; not by itself let you recuperate the saved window space - it +;; shrinks the text, but it does not shrink the window accordingly. +;; For that, you also need library `face-remap+.el' and its option +;; `text-scale-resize-window', which lets you resize the window or +;; not, horizontally, vertically, or in both directions. +;; +;; (For example, you might set `split-width-threshold' to a small +;; number, so `*Completions*' appears on the side rather than above +;; or below other windows, and in that case you might want to +;; resize it only horizontally.) +;; +;; If you use library `oneonone.el' with a standalone +;; `*Completions*' frame, then see option +;; `1on1-completions-frame-zoom-font-difference'. +;; +;; * Icicles varies the number of columns used to display completion +;; candidates, for a better fit. You can tweak this with options +;; `icicle-candidate-width-factor' and +;; `icicle-inter-candidates-min-spaces'. +;; +;; If you use Do Re Mi (library `doremi.el'), then you can modify +;; these options incrementally during completion, seeing the effect +;; as they change. Use `C-x w' or `C-x |' from the minibuffer, +;; then use the arrow keys or the mouse wheel to increment and +;; decrement the current value. WYSIWYG. +;; +;; Why is this important enough to merit changing it dynamically, +;; instead of just customizing the options once and for all? +;; Because different sets of candidates have different candidate +;; lengths and distributions of those lengths. Play with it a bit +;; and you will see. One size does not fit all in an ideal way. +;; +;; * You can use `C-x .' (`icicle-toggle-hiding-common-match') in the +;; minibuffer at any time during completion to toggle hiding of the +;; matched portions of the candidates in *Completions*. This +;; portion is replaced by ellipsis, `...'. (In Emacs 20, it is +;; replaced by nothing.) +;; +;; This can be useful when you don't care about the text that +;; matches or when that text is particularly long. For example, if +;; you use `icicle-find-file-absolute' (`C-u C-x C-f') and the +;; completion candidates are absolute file names that share a +;; common directory, it can be convenient to hide the directory +;; portion that is common to all candidates. +;; +;; * You can scroll `*Completions*' down using `C-v', and up using +;; `M-v'. You can use `C-u' at any time to reverse the scroll +;; directions. In Emacs 22 or later, you can also use the mouse +;; wheel to scroll `*Completions*'. +;; +;; * You can lay completion candidates out vertically, if you like, +;; instead of horizontally (the default). To do that, customize +;; option `icicle-completions-format' to have the value `vertical'. +;; +;; Starting with Emacs 23.2, this is also possible in vanilla +;; Emacs, and the vanilla option for this is `completions-format'. +;; The default value of `icicle-completions-format' is the value of +;; `completions-format', so if you prefer you can simply use the +;; vanilla Emacs option. Vertical layout works in Icicles for all +;; Emacs versions, starting with Emacs 20. +;; +;; Unlike the case for vanilla Emacs, in Icicles the arrow keys in +;; buffer `*Completions*' correctly reflect the candidate order +;; (e.g. as currently sorted). This also means that candidate +;; cycling acts properly for a vertical layout. +;; +;; Note: For visual clarity, a `vertical' value is overridden +;; (ignored) when multi-line multi-completions are used - the +;; layout is horizontal. See (@* "Customization and General Tips") +;; for more information. +;; +;; * In some cases, Icicles adds one or more additional, proxy +;; completion candidates. These are placeholders for real +;; candidates. If you choose a proxy candidate, then the real +;; candidate that is referred to is used. Typical proxy candidates +;; include a reference to a name under the cursor, a reference to +;; whatever you then click `mouse-2' on, and a reference to a name +;; that is the value of a variable. +;; +;; The inclusion of proxy candidates is controlled by user option +;; `icicle-add-proxy-candidates-flag'. You can toggle this +;; inclusion at any time during completion, using `C-M-_'. For +;; performance reasons, you must re-invoke some commands after +;; toggling the flag on, to make the proxy candidates available. +;; +;; Examples: +;; +;; . When you read a file name with completion, the proxy +;; candidates include the following (reading a face name is +;; similar): +;; +;; - `*mouse-2 file name*' - proxy for a file name that you +;; click with `mouse-2'. +;; +;; - `*point file name*' - proxy for the file name at point (if +;; available). +;; +;; - Single-quoted names of file-name variables - proxy for the +;; variable value. +;; +;; . When a command reads input using `icicle-read-number' or +;; `icicle-read-string-completing', the proxy candidates are all +;; variables whose values are numbers or strings, respectively. +;; You can choose such a proxy candidate to use its value. (All +;; candidates are proxy candidates for these functions.) +;; +;; . When you use command `icicle-read-color', the proxy +;; candidates include the following: +;; +;; - `*point foreground*' - proxy for the foreground color at +;; the cursor position (point). +;; +;; - `*mouse-2 foreground*' - proxy for the foreground color +;; where you then click `mouse-2'. +;; +;; - `*copied foreground*' - proxy for a previously copied +;; foreground color, the value of variable +;; `eyedrop-picked-foreground'. +;; +;; - Background versions of the first three: `*copied +;; background*' etc. +;; +;; - Single-quoted names of color-valued variables - proxy for +;; the variable value. +;; +;; See Also: +;; (@> "Different Places for Saving and Retrieving Candidates") for +;; information about using `C-M-{' in the minibuffer to retrieve the +;; value of any variable as minibuffer input. +;; +;; There are lots of Icicles features that enhance the display and +;; behavior of `*Completions*' in some way. Read on... +;; +;; See Also: +;; +;; * (@> "Moving Between the Minibuffer and Other Buffers"), for +;; information on the `pause' key, which is somewhat related to +;; using `C-insert'. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Candidates with Text Properties") +;; and (@file :file-name "icicles-doc2.el" :to "Programming Multi-Completions") +;; for information about using text properties in `*Completions*'. +;; These sections are for Emacs-Lisp programmers. + +;;(@* "Icompletion") +;; +;; Icompletion +;; ----------- +;; +;; Emacs incremental completion, or icompletion, provided by standard +;; library `icomplete.el', displays matching prefix completions in +;; the minibuffer. This display is updated incrementally as you type +;; characters. In spite of the name, icompletion does not, in fact, +;; provide any completion; it provides completion help, letting you +;; know which (prefix) completions are available. +;; +;; Icicles enhances Emacs icompletion in three ways: +;; +;; 1. It works with my library `icomplete+.el' to provide minibuffer +;; feedback on the number of completion candidates. +;; +;; 2. It highlights the part of your input that does not match any +;; completion candidate. +;; +;; 3. It provides a new kind of icompletion, using buffer +;; `*Completions*'. +;; +;;(@* "icomplete+.el Displays the Number of Other Prefix Candidates") +;; ** icomplete+.el Displays the Number of Other Prefix Candidates ** +;; +;; Library `icomplete+.el' enhances `icomplete.el' in various ways. +;; One of these ways is to complement Icicles by displaying the +;; number of other prefix-completion candidates when cycling. This +;; number is displayed whenever you change direction when cycling. +;; For example: +;; +;; M-x forward-line [Matched] (13 more) +;; +;; Like `icomplete.el', `icomplete+.el' provides help for only prefix +;; completions, not apropos completions. (Reminder: There is no +;; icompletion for file-name completion - see standard library +;; `icomplete.el'.) +;; +;;(@* "Icompletion in *Completions*: Apropos and Prefix Completion") +;; ** Icompletion in *Completions*: Apropos and Prefix Completion ** +;; +;; Buffer `*Completions*' shows you the current set of candidates for +;; either prefix or apropos completion. Together, user options +;; `icicle-incremental-completion-flag', +;; `icicle-incremental-completion-delay', and +;; `icicle-incremental-completion-threshold' control incremental +;; updating of `*Completions*'. +;; +;; If `icicle-incremental-completion-flag' is non-nil, then +;; `*Completions*' is automatically updated when you change your +;; input in the minibuffer - that is, with each character that you +;; type or delete. This is another form of icompletion, unique to +;; Icicles. It uses buffer `*Completions*', instead of the +;; minibuffer, to show the completion help. +;; +;; The particular non-nil value of +;; `icicle-incremental-completion-flag' determines when +;; `*Completions*' is displayed and updated. The default value, t, +;; means that `*Completions*' is updated only if it is already +;; displayed. Use t if you don't want `*Completions*' to be too +;; intrusive but you want it to provide the most help when you ask +;; for help (via `TAB' or `S-TAB'). +;; +;; Any other non-nil value displays and updates `*Completions*' +;; whenever there is more than one completion candidate. That can be +;; more helpful, but it can also be more distracting. A value of nil +;; turns off automatic updating altogether - `*Completions*' is then +;; displayed only upon demand. I find that t represents a good +;; compromise, providing help when I ask for it, and then continuing +;; to help until I've finished choosing a candidate. +;; +;; Option `icicle-incremental-completion-delay' is the number of +;; seconds to wait before updating `*Completions*' incrementally. It +;; has an effect only when the number of completion candidates is +;; greater than `icicle-incremental-completion-threshold'. This +;; delay can improve performance when there are many candidates. It +;; lets you type ahead before any redisplay occurs; otherwise, +;; redisplay occurs for each character you type or delete. +;; +;; You can toggle incremental completion at any time (changing +;; `icicle-incremental-completion-flag' between nil and t) using +;; command `icicle-toggle-incremental-completion', which is bound to +;; `C-#' in the minibuffer. If the number of completion candidates +;; is very large, then use `C-#' to toggle incremental completion off +;; - that will save time by not updating `*Completions*'. See also +;; (@> "Dealing With Large Candidate Sets") for other ways to deal +;; with a large number of candidates. +;; +;; Note: Incremental completion is effectively turned off when a +;; remote file name is read, that is, whenever your file-name input +;; matches a remote-file syntax. +;; +;; There are several advantages of using `*Completions*' for +;; icompletion, as opposed to the minibuffer: +;; +;; 1. Many more candidates can be displayed in `*Completions*' than +;; can be displayed by standard icompletion, which uses the +;; minibuffer for feedback. +;; +;; 2. Standard (minibuffer) icompletion provides feedback only on +;; matches for prefix completion. If you use both standard +;; icompletion and Icicles icompletion, you can have incremental +;; help for both prefix completion and apropos completion at the +;; same time, one in the minibuffer and the other in +;; `*Completions*'. +;; +;; 3. The other Icicles `*Completions*' features are available for +;; the current set of matching candidates: cycling, highlighting +;; of match root, highlighting of previously used candidates, and +;; so on. See (@> "*Completions* Display"). +;; +;;(@* "Icicles Highlights the Input that Won't Complete") +;; ** Icicles Highlights the Input that Won't Complete ** +;; +;; When you are typing or correcting your input during completion, +;; Icicles highlights the part of your minibuffer input that prevents +;; it from matching any completion candidates, by default. This +;; works for both prefix completion and apropos completion. For +;; both, it highlights your input from the leftmost mismatch through +;; the input end. +;; +;; You can use `C-M-l' to move the cursor to the start of the +;; highlighted, mismatched part of your input. Repeat `C-M-l' to +;; kill the highlighted portion. (Because it is killed, `C-y' yanks +;; it back.) +;; +;; User options `icicle-incremental-completion-flag', +;; `icicle-test-for-remote-files-flag', +;; `icicle-highlight-input-completion-failure', +;; `icicle-highlight-input-completion-failure-delay', and +;; `icicle-highlight-input-completion-failure-threshold' control this +;; highlighting, which is done using face +;; `icicle-input-completion-fail' (for strict completion) or +;; `icicle-input-completion-fail-lax' (for lax completion). +;; +;; If either `icicle-incremental-completion-flag' or +;; `icicle-highlight-input-completion-failure' is nil, then no such +;; highlighting is done. Remember that you can toggle incremental +;; completion using `C-#' in the minibuffer. +;; +;; Because this highlighting can have a negative impact on +;; performance, you can fine-tune when you want it to occur. The +;; value of `icicle-highlight-input-completion-failure' determines +;; when this highlighting can take place. +;; +;; In particular, highlighting the non-matching part of remote file +;; names can be slow. Two values of the option allow remote file +;; name highlighting: `always' and `explicit-remote'. The other +;; values do not highlight remote file names. You probably do not +;; want to use a value of `always'. +;; +;; If the value is nil, then highlighting never occurs. If the value +;; is `explicit-strict', `explicit', or `explicit-remote', then +;; highlighting occurs only upon demand: when you hit `TAB' or +;; `S-TAB' to request completion. If the value is `implicit-strict', +;; `implicit', or `always', then highlighting occurs also when you +;; update input during incremental completion (if incremental +;; completion is turned on). +;; +;; I use a value of `implicit' myself, but the default value is +;; `implicit-strict' because, depending on your setup and use cases, +;; `implicit' can impact performance for file-name completion (which +;; is lax, not strict). I suggest you try `implicit' to see - this +;; feature is especially useful for file names. +;; +;; Summary of `icicle-highlight-input-completion-failure' choices: +;; +;; nil Never +;; `explicit-strict' Only on demand and only during strict completion +;; `explicit' Only on demand (lax and strict completion) +;; `explicit-remote' Only on demand, even for remote file names +;; `implicit-strict' Incremental or explicit completion - strict only +;; `implicit' Incremental/explicit, lax/strict completion +;; `always' Always (including for remote file names) +;; +;; These values are listed here in terms of increasing +;; permissiveness, which also can mean increasing performance impact. +;; That is, a value of `implicit' is more likely to affect +;; performance than a value of `explicit'. The greatest performance +;; hit comes from file-name matching, in particular if remote files +;; are involved. +;; +;; If you know that you will not be using remote file names for a +;; while, you can let Icicles and Tramp know this by using the toggle +;; `C-^' in the minibuffer to turn off option +;; `icicle-test-for-remote-files-flag'. When this is off, you cannot +;; use remote files. +;; +;; Turning off `icicle-test-for-remote-files-flag' using `C-^' turns +;; off Tramp's remote file-name completion and remote file handling. +;; If you turn off the option using `C-^', then turn it back on using +;; `C-^' also (instead of just setting the option to non-nil), in +;; order to re-enable Tramp's file-name handling and completion. +;; +;; Turning off `icicle-test-for-remote-files-flag' can slightly speed +;; up file-name completion for local files, by avoiding any check for +;; remote file names. If you seldom use remote files, then you might +;; want to customize `icicle-test-for-remote-files-flag' to nil and +;; use `C-^' to toggle it back on whenever you do use remote files. +;; +;; A nil value of `icicle-test-for-remote-files-flag' also overrides +;; the `icicle-highlight-input-completion-failure' values +;; `implicit-strict', and `explicit-strict' for file-name completion, +;; treating them the same as `implicit'. It is assumed that you use +;; those values only to avoid the cost of remote file-name matching. + +;;(@* "Sorting Candidates and Removing Duplicates") +;; +;; Sorting Candidates and Removing Duplicates +;; ------------------------------------------ +;; +;; By default, completion candidates are usually presented in buffer +;; `*Completions*' in alphabetic order. But some commands use +;; different sort orders by default. Whatever sort order is used for +;; `*Completions*' is also the order of cycling among candidates. +;; +;; Also, duplicate candidates are typically removed as completion +;; choices, by default. But for some commands duplicates are +;; appropriate, so they are not removed. For example, command +;; `icicle-search' (`C-c `') uses completion to navigate among search +;; hits. Duplicate search hits are retained. Although some +;; search-hit candidates might have the same text, they are located +;; at different buffer positions. +;; +;; You can interactively control the order of candidates and whether +;; duplicates are removed. Use `C-,' during completion to choose a +;; different sort order or to turn off sorting altogether (one of the +;; available sort orders is in fact called "turned OFF"). Use `C-$' +;; to toggle the removal of duplicate candidates. A few commands, +;; for which sorting is inappropriate, prevent you from sorting. +;; +;;(@* "Changing the Sort Order") +;; ** Changing the Sort Order ** +;; +;; There are a couple of ways to use `C-,' (bound to command +;; `icicle-change-sort-order'). Its behavior depends on the value of +;; user option `icicle-change-sort-order-completion-flag', which is +;; nil by default. This value means to simply cycle to the next sort +;; order each time you hit `C-,'. A non-nil value means to use +;; completion to choose another sort order. If you have many +;; available sort orders, then you might prefer a non-nil value. In +;; any case, you can also change this behavior on the fly: using +;; plain `C-u' (no number) with `C-,' reverses the meaning of +;; `icicle-change-sort-order-completion-flag' for `C-,'. +;; +;; However, a numeric prefix argument, such as `C-9', means to simply +;; reverse the direction of the current sort order; it invokes +;; command `icicle-reverse-sort-order'. For example, if candidates +;; are sorted alphabetically from A to Z, then `C-9 C-,' flips the +;; sort order, so that from then on sorting is from Z to A. If +;; buffer names are sorted from small to large buffer size, then `C-9 +;; C-,' sorts large buffers first. This works for all sort orders. +;; The new sort order is echoed, so you can use this twice to just +;; remind yourself of the current sort order. +;; +;; In addition to the current sort order, which is defined by the +;; value of user option `icicle-sort-comparer', an alternative sort +;; order is available at all times. It is the value of option +;; `icicle-alternative-sort-comparer'. By default, this sorts +;; candidates into two alphabetical groups: those previously used as +;; accepted input, followed by those not yet used. +;; +;; Just as you can choose a different current sort order using `C-,', +;; so you can choose a different alternative sort order using `M-,'. +;; +;; How do you actually use the alternative sort order? Use `C-M-,' +;; (command `icicle-toggle-alternative-sorting') to swap the +;; alternative sort for the current sort. This is the quickest way +;; to flip between two sort orders. If, for example, you set your +;; alternative sort order to "turned OFF", then this is a quick way +;; to toggle sorting on and off. +;; +;; Commands that read buffer names with completion can use another +;; sort-function user option, `icicle-buffer-sort'. It has the same +;; meaning as `icicle-sort-comparer', but it applies only to those +;; commands. It is provided so that you can customize it separately. +;; You can also define buffer configurations that are used for +;; completion: named sets of buffers, sort functions, and other +;; parameters that control completion of buffer names. +;; +;;(@* "Defining New Sort Orders") +;; ** Defining New Sort Orders ** +;; +;; When you use `C-,' or `M-,', the sort orders that you can choose +;; from are those in user option `icicle-sort-orders-alist'. You can +;; customize this option to add or remove available sort orders. A +;; better way to define a new sort order is to use macro +;; `icicle-define-sort-command' in your Emacs init file (~/.emacs). +;; This defines a new Icicles command, named `icicle-sort-ORDER', +;; where `ORDER' is the name of the new sort order. The definition +;; of the "alphabetical" sort order provides an example: +;; +;; (icicle-define-sort-command "alphabetical" +;; icicle-case-string-less-p +;; "Sort completion candidates alphabetically.") +;; +;; The first argument, "alphabetical", is a string naming the new +;; sort order. When you change to this sort order, a message says +;; "Sorting is now alphabetical". Whatever sort-order name you +;; provide is used in the message. +;; +;; The second argument is the actual function used for sorting. It +;; can be any function, including a lambda expression. The function +;; takes two string arguments and returns non-nil if and only if the +;; first string sorts before (is "less than") the second. In this +;; case, function `icicle-case-string-less-p' is used, which compares +;; its two arguments alphabetically (lexicographically). The third +;; argument is the doc string for the new sorting command. +;; +;; The result of this definition is: +;; +;; 1. The creation of command `icicle-sort-alphabetical'. +;; 2. The addition of an entry for the new sort order in option +;; `icicle-sort-orders-alist'. The entry associates sort order +;; "alphabetical" with comparison function +;; `icicle-case-string-less-p'. +;; +;; You can invoke the new sorting command any time using `M-x', but +;; you can also change to the new sort order using `C-,' (or `M-,') +;; during minibuffer completion. +;; +;;(@* "Different Sorts for Different Sorts of Uses") +;; ** Different Sorts for Different Sorts of Uses ** +;; +;; There are many different uses of completion in Emacs, and this +;; means that sorting candidates needs to be flexible - there cannot +;; be a single sort order, or even a single set of sort orders, that +;; is useful for all purposes. Completion, and therefore also +;; sorting of completion candidates, needs to deal with different +;; types of candidates and different numbers of them, in different +;; contexts. +;; +;; Icicles predefines many sort functions, and you can easily define +;; more of your own. You can choose a different sort at any time, as +;; mentioned above. A good sort order can be a big help, depending +;; on the context. However, sorting isn't free, and it's helpful to +;; think for a moment about some of the consequences of sorting, in +;; terms of performance. +;; +;; What does a sort function do? It determines which of two strings +;; should come first, that is, which is "less than" the other. +;; During sorting, pairs of candidates are compared using the sort +;; function. And each time you change your input by typing or +;; deleting a character, the new set of matching candidates is sorted +;; (if `icicle-incremental-completion-flag' is non-nil). +;; +;; The number of candidates to be sorted depends on the kind of +;; completion and how you use Icicles. Some Icicles users like to +;; use cycling more and completion less, which means sorting more +;; candidates. Other users favor using completion to narrow down the +;; number of matches (which I recommend). Some commands typically +;; have few possible completion candidates; others have many. +;; Buffer-name completion, for example, typically involves relatively +;; few candidates, whereas file-name completion typically involves +;; many. +;; +;; If there are many candidates matching your input, then many +;; comparisons will be made each time the candidate set is sorted. +;; This means that if your sort function is complex, response can be +;; slow. A complex sort function might be OK for sorting a small or +;; medium set of candidates, but it might not be appropriate for +;; sorting a very large set. +;; +;; Only you, as a user, can control which sort makes the best sense +;; for you in any given situation. If you are likely to have +;; zillions of candidates in some context, then you probably will +;; want to change to a sort that computes quickly. You can, of +;; course, even choose not to sort at all, but simple sort +;; comparisons don't noticeably impact performance, even for a very +;; large number of candidates. +;; +;; Icicles could offer a threshold option similar to +;; `icicle-incremental-completion-threshold' (or it could reuse that +;; option), and not bother to sort if the number of candidates passed +;; the threshold, but there can be many sort orders of differing +;; complexity, so a set of thresholds would really be needed, perhaps +;; one per sort order. +;; +;; Rather than having you try to manage such complexity ahead of time +;; using options, it's better to just let you manage it at completion +;; time: Choose the sort order with knowledge of the possible +;; candidate set. For example, if the set of candidates to sort will +;; include every file on your file system, then you probably will +;; want to use a simple sort. On the other hand, there are +;; situations where you might nevertheless prefer to wait a few +;; seconds, in order to perform a complex sort that is of particular +;; use. +;; +;; In sum, Icicles keeps it simple, and leaves it up to you to choose +;; the appropriate sort order for any given context. This design +;; choice is one reason why Icicles makes it easy to choose a sort +;; even while you are completing input - each act of completion is +;; different. +;; +;; It can help you choose, however, to know which of the predefined +;; Icicles sort orders are more complex, and therefore tend to be +;; slower. Here they are: +;; +;; Sort Order Sort Function Used +;; ---------- ------------------ +;; by previous use alphabetically `icicle-historical-alphabetic-p' +;; by last use `icicle-most-recent-first-p' +;; +;; The reason these sorts are slower is that they check the current +;; minibuffer history, to see whether, and where, each candidate is +;; located in the history list. If you, like I, have very long +;; history lists, then this can take a while. I use histories of +;; virtually unlimited length - I let library `savehist-20+.el' save +;; all of my histories from one Emacs session to the next. +;; +;; Here are some of the Icicles sort orders that exist by default: +;; +;; - alphabetical - see +;; (@> "Putting Previous Candidates First: `C-M-,'") +;; - case-insensitive - (@> "Completion Status Indicators") +;; - by last use as input +;; - by previous use alphabetically - see +;; (@> "Putting Previous Candidates First: `C-M-,'") +;; by color name (colors) - see +;; (@file :file-name "icicles-doc2.el" :to "Candidates with Text Properties") +;; by hue (colors) +;; by purity/saturation (colors) +;; by brightness/value/luminance (colors) +;; by amount of red (colors) +;; by amount of green (colors) +;; by amount of blue (colors) +;; by RGB values (colors) +;; 22 by key name, prefix keys first (keys)- see (@> "Completing Prefix Keys") +;; 22 by key name, local bindings first (keys)- see +;; (@> "Local Bindings Are Highlighted") +;; 22 by command name (commands) +;; - by abbrev frequency (commands) - see +;; (@> "Multi `M-x' Turns Every Command into a Multi-Command") +;; by buffer size (buffer names) +;; *...* buffers last (buffer names) +;; by major mode name (buffer names) +;; 22 by mode-line mode name (buffer names) +;; by file/process name (buffer names) +;; - by last file modification time (file names) - see +;; (@> "Icicles Commands that Read File Names") +;; - by directories first or last (file names) +;; - in book order (Info) - see +;; (@file :file-name "icicles-doc2.el" :to "Icicles Completion for Info") +;; - special candidates first - see +;; (@> "Local Bindings Are Highlighted"), +;; (@file :file-name "icicles-doc2.el" :to "Candidates with Text Properties"), +;; (@file :file-name "icicles-doc2.el" :to "Icicles OO: Object-Action Interaction") +;; - proxy candidates first - see (> "*Completions* Display") +;; - extra candidates first - see +;; (@file :file-name "icicles-doc2.el" :to "Global Filters") +;; - by second multi-completion part (multi-completions) - see +;; (@file :file-name "icicles-doc2.el" :to "Sorting Candidates by Their Second Part") +;; - turned OFF (does not sort at all) +;; +;; As you can see, some are appropriate for color-name completion, +;; some for buffer-name completion, and some for file-name +;; completion. Some are general, appropriate for most kinds of +;; completion. +;; +;; Those marked above with the label `22' can be used only with Emacs +;; 22 or later. Those marked with a hyphen (-) are defined using +;; `icicle-define-sort-command', so they correspond to explicit +;; commands whose doc you can examine. The command names in this +;; case are `icicle-sort-' followed by the sort-order names (with +;; hyphens substituted for spaces) - for example, +;; `icicle-sort-by-directories-last' and `icicle-sort-turned-OFF'. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc2.el" :to "Customization and General Tips") +;; for more about `icicle-buffer-sort' and other buffer-name +;; completion parameters. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Global Filters") for a +;; way to filter and sort the domain of discourse, that is, all +;; possible candidates, prior to any use of completion. + +;;(@* "Get Help on Candidates") +;; +;; Get Help on Candidates +;; ---------------------- +;; +;; General Icicles help is available at any time during minibuffer +;; input, by hitting `C-?' (`icicle-minibuffer-help'). This section +;; is about specific help on individual completion candidates +;; instead. +;; +;; When you cycle among candidates for input, help on the current +;; candidate is shown in the mode-line, provided user option +;; `icicle-help-in-mode-line-flag' is non-nil. This makes it easy to +;; see what each candidate means or does. Similarly, this help is +;; shown whenever your input is completed entirely to one of the +;; candidates. If you use library `lacarte.el', then mode-line +;; candidate help is even available for menu-item candidates. +;; +;; Typically, this candidate mode-line help is the first line of the +;; candidate's doc string, but alternative help sources can be used +;; (and a doc string is not available for some kinds of candidates). +;; +;; To see more help than what is shown in the mode-line, for each +;; candidate or any given candidate as you cycle, press and hold the +;; Control and Meta keys while using the vertical arrow keys, for +;; prefix completion, or the `prior' and `next' keys (often labeled +;; Page Up and Page Down), for apropos completion. To show help on +;; any individual candidate, navigate to it (by cycling or using +;; completion), and hit `C-M-RET' - or press Control and Meta and +;; click it with `mouse-2' (`C-M-mouse-2') in buffer `*Completions*'. +;; +;; For example, if you use standard command `switch-to-buffer' and +;; you cycle among candidate buffers with `C-M-down' (prefix +;; completion), then the major and minor modes of each candidate +;; buffer are described in buffer *Help* as the buffer name appears +;; in the minibuffer. +;; +;; By default, you need not use the Meta key for candidate help; the +;; same bindings work with just the Control key. So, for example, +;; you can click `C-mouse-2' to get help on a candidate or use +;; `C-next' to cycle candidate help information. However, Icicles +;; multi-commands often have a different use for these bindings that +;; do not include Meta. It is only by default, when a multi-command +;; has not bound a more specific action to the plain Control +;; bindings, that you can use the sans-Meta bindings for help on +;; candidates. +;; +;; For example, Icicles binds `M-x', `C-x b', and `C-x C-f' to +;; multi-commands that execute a command, switch to a buffer, and +;; open a file, respectively. If you use only the Control key, +;; without the Meta key, when choosing candidates for these commands, +;; you will not get help on the candidates; instead, you will execute +;; a candidate command, switch to a candidate buffer, and open a +;; candidate file, respectively. For more information, see +;; (@> "Multi-Commands"). +;; +;;(@* "Use Candidate Help Like You Use Emacs Command `apropos'") +;; ** Use Candidate Help Like You Use Emacs Command `apropos' ** +;; +;; You can use this candidate-help functionality as a kind of +;; expanded `apropos' functionality. As an example, type `C-h v +;; out', then type `S-TAB' to display all variables that match "out" +;; (in buffer `*Completions*'). Then use `C-M-next' repeatedly to +;; cycle among those variables, displaying their documentation in the +;; *Help* buffer as they appear one by one in the minibuffer. Or +;; click individual variable names with `C-M-mouse-2', to display +;; their documentation. +;; +;; The standard `apropos' commands show only the first doc-string +;; line. Icicles shows that automatically in the mode-line, and it +;; shows the complete doc string on demand when you use `C-M-'. This +;; can be handy, for instance, when you are unsure which of several +;; similarly named candidates to choose. Seeing a candidate's +;; documentation along with its name can help you decide. +;; +;; You can click links in buffer *Help* to look up more info, and +;; then resume `C-M-next' where you left off, all without leaving +;; completion. +;; +;; This also works with menu items, if you load library `lacarte.el' +;; as well as Icicles. As you cycle among matching menu items, the +;; corresponding command documentation is displayed in *Help*. +;; +;; If you also use library `help-fns+.el' (Emacs 22 or later) or +;; library `help+.el' (or `help+20.el' for Emacs 20), then you can +;; use these Icicles features with additional help commands such as +;; `describe-keymap' (`C-h M-k'), `describe-command' (`C-h C-c'), +;; `describe-option' (`C-h o'), and `describe-option-of-type'. +;; +;; `C-h C-o', which is bound by those libraries to command +;; `describe-option-of-type', is bound in Icicle mode to +;; `icicle-describe-option-of-type' instead, which uses +;; multi-completion and is therefore more powerful. +;; See (@file :file-name "icicles-doc2.el" :to "Multi-Completions"). +;; `C-h C-o' describes a user option that is of a particular custom +;; type: you match the type and the option name at the same time. +;; +;; As an example, try `C-h C-o ici C-M-j string S-TAB' (`C-M-j' just +;; separates the option name and type parts). In buffer +;; *Completions*, you see all options whose name contains `ici' and +;; whose type (or an inherited type) definition contains `string'. +;; That means not only options that are strings, but options that are +;; lists that contain string elements, options that can be a string +;; or something else, and so on. +;; +;; Browse the doc for these options, one after the other, using +;; `C-M-next'. This is a way to see, at the same time, the +;; documentation for individual options (in buffer *Help*) and the +;; types their values must satisfy (in *Completions*). +;; +;; And remember that you can leave the option-name part or the type +;; part empty, to see all options of a certain type or options of all +;; types with a certain name pattern. For example, `C-h C-o .* C-M-j +;; string S-TAB' or `C-h C-o ici S-TAB'. +;; +;; And you can of course use progressive completion as well, to +;; match, say, a type that has a `string' component and an `integer' +;; component - or whatever. The type part of a completion candidate +;; is an entire `defcustom' type, so its `:tag' values are also +;; included. This means that you can also match against the +;; descriptive text (tag) that appears next to a value component in +;; Customize. +;; +;; `C-h C-o' is a powerful way to browse options and their +;; documentation. See the doc string of +;; `icicle-describe-option-of-type' for more possibilities. +;; +;; Candidate help (prefix `C-M-') is available for these types of +;; completion candidates, by default: +;; +;; * menu items +;; * commands and other functions +;; * keymap variables (if `describe-keymap' is defined - see +;; library `help-fns+.el') +;; * user options and other variables +;; * faces +;; * fonts (mode-line help only) +;; * command abbreviations (using `apropos-command' for matches) +;; * property lists +;; * buffers +;; * files +;; +;; If the same candidate names a function, a variable, and a face, or +;; any two of these, then all such documentation is shown (Emacs 22 +;; and later). +;; +;; In addition to the candidate types listed above, any command that +;; uses completion can define its own candidate help action function +;; and bind it to `icicle-candidate-help-fn'. +;; +;; A command can also provide its own mode-line and tooltip help for +;; any individual candidate. See +;; (@file :file-name "icicles-doc2.el" :to "Applying Text Properties to a Candidate String"). +;; +;; For more information about the types of candidates and their +;; associated documentation, see the documentation for command +;; `icicle-help-on-candidate'. This command is bound to `C-M-RET', +;; `C-M-mouse-2', `C-help', `C-M-help', `C-f1', and `C-M-f1'. When +;; no specific action is defined for candidates, it is also bound to +;; `C-RET' and `C-mouse-2'. You can use this to get help on any +;; completion candidate during completion. See also the related +;; help-cycling commands, `icicle-help-on-next-apropos-candidate' and +;; so on, bound to `C-M-next', `C-M-prior', `C-M-down', and `C-M-up'. +;; +;; If you use one-buffer-per-frame (`pop-up-frames' non-nil), then +;; displaying *Help* in one frame might interfere with viewing +;; `*Completions*' in another. For that reason, the `*Completions*' +;; frame is raised to the front. Also, if user option +;; `icicle-Completions-frame-at-right-flag' is non-nil (default +;; value: `t'), then the `*Completions*' frame is moved to the right, +;; out of the way, whenever you access help on a candidate. +;; +;;(@* "Other Icicles Apropos Commands") +;; ** Other Icicles Apropos Commands ** +;; +;; There are also Icicles replacements for the standard Emacs +;; `apropos' commands. They act similarly, but they also let you see +;; the list of regexp matches incrementally (as with all Icicles +;; commands), using `S-TAB'. If you also use my library +;; `apropos-fn+var.el', then these Icicles commands take advantage of +;; the apropos enhancements in that library. +;; +;; The Icicles apropos commands are: `icicle-apropos', +;; `icicle-apropos-command', `icicle-apropos-function', +;; `icicle-apropos-option', `icicle-apropos-variable', and +;; `icicle-apropos-zippy'. +;; +;; Another feature of these Icicles commands is that when more than +;; one type of object can be a candidate, candidates of a certain +;; type are shown in buffer `*Completions*' using face +;; `icicle-special-candidate'. For example, command `icicle-apropos' +;; shows function names as special candidates, to help you +;; distinguish them from variable names. +;; +;; In addition, Icicles commands `icicle-doc', `icicle-fundoc', and +;; `icicle-vardoc' provide the functionality of standard Emacs +;; command `apropos-documentation', but with additional features - +;; see (@file :file-name "icicles-doc2.el" :to "Multi-Completions"). +;; In addition, you can use command `icicle-plist' to find symbols +;; with certain property-list keys and values, and you can use +;; command `icicle-describe-option-of-type' (bound to `C-h C-o') to +;; find user options of a certain type. +;; +;; Command `icicle-customize-apropos-options-of-type' is similar to +;; `icicle-describe-option-of-type', in that it lets you specify the +;; type of matching options. But instead of describing an option, it +;; opens Customize for all options of the specified type that match +;; your input regexp. (Unlike `icicle-describe-option-of-type', +;; however, it is not a multi-completion command: you first specify +;; the type, then the regexp to match.) +;; +;; One difference between Icicles apropos commands and the standard +;; commands, besides the Icicles enhancements already described, is +;; that (starting with Emacs 22) the standard commands let you input +;; a set of keywords, as an alternative to inputting a regexp. +;; Icicles apropos commands do not allow for keyword input, as such. +;; However, Icicles progressive completion provides a more powerful +;; way to search with multiple keywords (in fact, multiple regexps) - +;; you can of course use it with the Icicles apropos commands. Also, +;; there are several problems with the standard Emacs apropos +;; commands, with respect to interpreting your input as either a set +;; of keywords or a regexp. Because they allow two very different +;; syntaxes as input, the standard apropos commands are forced to +;; make some limiting compromises for keyword searching. +;; +;; See Also: (@> "Progressive Completion"). + +;;(@* "Multi-Commands") +;; +;; Multi-Commands +;; -------------- +;; +;;(@* "What Is a Multi-Command?") +;; ** What Is a Multi-Command? ** +;; +;; A multi-command is a command that lets you make multiple input +;; choices in a single command execution: a multiple-choice command. +;; You can choose multiple items from a set of choices, using buffer +;; `*Completions*' as a multiple-choice "menu". (It's not necessary +;; to display `*Completions*', however.) Instead of asking you +;; "Which file do you want to delete?", a multi-command asks you, in +;; effect, "Which file(S) do you want to delete?". +;; +;; Nothing especially new here. Any Emacs command could be defined +;; to use an input loop, asking for file names until you do something +;; to signal that you're done inputting. It could provide for +;; file-name completion by calling `read-file-name' to read your +;; input. +;; +;; * But what if you could also filter the domain of discourse on the +;; fly, so that the candidate files were only those matching a +;; regular expression (regexp) that you typed? Then, the command +;; definition would need to provide for that behavior too. +;; +;; * And what if you could then take the complement of that set of +;; candidate file names, with respect to the complete set of files +;; in the directory? Or subtract (exclude) some set of file names +;; from the set of matching names, to get the set of possible +;; choices? +;; +;; * And what if the set of potential candidates at each step (regexp +;; match, complement, set difference) could also be displayed in a +;; multiple-choice menu? +;; +;; For such multi-command functionality you need Icicles. +;; +;; You can tell whether a command is a multi-command when you execute +;; it: if it is a multi-command, then the prompt is prefixed by `+'. +;; For example, multi-command `icicle-file' uses this prompt: +;; +;; + File or directory: +;; +;; Normal, non multi-command `find-file' uses this prompt, which has +;; no `+': +;; +;; Find file: +;; +;; Just remember that `+' means that you can choose any number of +;; inputs. For a list of predefined Icicles multi-commands, use +;; `C-?' (`icicle-minibuffer-help') in the minibuffer - search for +;; `+' at the beginning of a line. +;; +;;(@* "How Does a Multi-Command Work?") +;; ** How Does a Multi-Command Work? ** +;; +;; When an Icicles multi-command prompts you for input, you can make +;; a single choice and press `RET' to confirm it, as usual, or you +;; can choose any number of completion candidates, using `C-RET' (or +;; `C-mouse-2') for each. You can thus act on multiple candidates, +;; or even multiple times on the same candidate, during the same +;; execution of the command. +;; +;; But you don't have to - you can use any multi-command just as if +;; it were a normal, single-choice command. +;; +;; For example, command `icicle-delete-file' lets you delete a single +;; file or a set of files that match your minibuffer input - all in +;; the same command execution. If you type no input, then all files +;; in the current directory match, and you can delete any number of +;; them individually. If you type `~$' and hit `S-TAB' +;; (`icicle-apropos-complete'), then all files that end in `~' match, +;; and you can delete any number of them. Similarly, command +;; `icicle-buffer-other-window' lets you display any number of +;; buffers, and so on. +;; +;; You make multiple choices this way by cycling through the +;; candidate completions, as usual, and hitting `C-RET' whenever you +;; want to choose (act on) the current cycle candidate. Or just +;; press and hold Control while clicking each chosen candidate with +;; `mouse-2'. +;; +;; Similarly, you can use `C-next', `C-prior', `C-down', and `C-up' +;; to act on successive candidates, forward or backward. You can +;; thus just hold down the Control key while cycling, to act on each +;; candidate in turn, if you want. +;; +;; Instead of, or in addition to, cycling, you can use completion to +;; get to a particular candidate you want. No matter how a candidate +;; is made current, you can choose the current candidate (perform the +;; action on it) using `C-RET' or `C-mouse-2'. +;; +;; For lax (permissive) completion, you can act on any input text +;; with `C-RET' (but not with the other multi-command keys) - you +;; need not choose one of the available candidates. This means, for +;; example, that you can create any number of new file buffers with a +;; single `C-x C-f' invocation, as well as open any number of +;; existing files. +;; +;; As always, hitting `RET' (or `S-RET') ends the command. For most +;; multi-commands, hitting `RET' performs the same action as `C-RET', +;; but it is possible to have a command that acts differently for +;; `RET' and `C-RET'. That is the case, for instance, when help is +;; displayed via `C-RET'. +;; +;; You can use `C-RET' or `C-mouse-2' repeatedly to act multiple +;; times on the same candidate. A shortcut is to use `C-u' with +;; `C-RET' or `C-mouse-2'. That will work if the candidate action +;; function is designed to be `C-u' sensitive. This is the case for +;; the Icicles multi-commands that read the name of a command or +;; keyboard macro and execute the command or macro: +;; `icicle-execute-extended-command' (`M-x'), `icicle-kmacro' +;; (`S-f4'), and `icicle-execute-named-keyboard-macro' (`C-x M-e'). +;; +;; So, for example, if you use `C-u 10 C-RET' on command +;; `forward-char' during `M-x' command completion, the cursor +;; advances 10 characters. Another example: `C-x M-e C-u 200 C-RET' +;; on a keyboard-macro candidate `foo' executes `foo' 200 times. You +;; can use all of the numeric prefix argument shortcuts, such as +;; `M--', `M-7', and `C-6', with the exception of `C--', which has a +;; different meaning (`icicle-candidate-set-difference') in the +;; Icicles minibuffer. +;; +;; Note that you can supply a prefix argument for both the +;; multi-command and any of its individual actions. The command is +;; free to interpret these differently. For example, a prefix arg +;; for `icicle-kmacro' provides a default repeat factor, which can +;; then be overridden for any individual action by providing a +;; different prefix arg. As another example, a prefix arg used with +;; any file-name candidate for command `icicle-find-file' visits the +;; file in read-only mode. But a prefix arg for the command itself +;; reverses this effect: read-only becomes the default so that a +;; prefix arg for a candidate means visit not read-only. +;; +;; If user option `icicle-use-candidates-only-once-flag' is non-nil, +;; then, when you act on a candidate, it is removed from the list of +;; available candidates, for clarity. Commands where this behavior +;; is appropriate bind this option to a non-nil value. This is a +;; user option, but you normally will not customize it. +;; +;; You can use `C-g' to exit a multi-command at any time, without +;; making a final choice using `RET'. If the actions performed by a +;; multi-command are easily reversible, `C-g' will often restore +;; things to the way they were before performing the actions. +;; +;; Does this `C-RET' stuff sound familiar? Using a multi-command is +;; similar to accessing help on a candidate +;; (see (@> "Get Help on Candidates")). A multi-command is any +;; command that has a special action defined for use with `C-RET' +;; (command `icicle-candidate-action') on the current cycle +;; candidate. If no such special action is defined, then help on the +;; candidate is displayed - displaying help is just the default +;; action for `C-RET', used when no other action is defined. You can +;; always access candidate help using the `C-M-' prefix: `C-M-help', +;; `C-M-f1', `C-M-RET', `C-M-mouse-2', `C-M-next', `C-M-prior', +;; `C-M-down', and `C-M-up'. +;; +;; You can also cycle among elements of a set, performing actions, if +;; you use my libraries `doremi.el', `doremi-cmd.el', and +;; `doremi-frm.el'. Like Icicles, DoReMi lets you see the effect of +;; a choice immediately, whenever you make changes. Each library has +;; its own advantages and special uses. Advantages of Icicles +;; include: +;; +;; - completion to candidate values +;; - restoration after making changes, letting you preview changes +;; without actually applying them +;; +;; See Also: +;; +;; * (@> "More about Multi-Commands") for more about using +;; multi-commands. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Defining Icicles Commands (Including Multi-Commands)") +;; for how to define your own multi-commands. +;; +;; * (@> "Moving Between the Minibuffer and Other Buffers"). + +;;(@* "More about Multi-Commands") +;; +;; More about Multi-Commands +;; ------------------------- +;; +;; A multi-command is any command that uses input completion and lets +;; you perform actions on any number of individual completion +;; candidates without exiting completion. +;; +;; The default action is invoked on the current candidate by `C-RET' +;; (`icicle-candidate-action'). There are three other kinds of +;; actions on individual candidates: +;; +;; * alternative actions, invoked by `C-S-RET' +;; * deletion actions, invoked by `S-delete' +;; * help actions, invoked by `C-M-RET' +;; +;; A given command can define any combination of these four kinds of +;; actions: none of them, any one of them, any two of them, any three +;; of them, or all four kinds. +;; +;; This section provides information about alternative actions and +;; deletion actions. +;; +;; See Also: +;; +;; * (@> "Get Help on Candidates") for information about using +;; candidate help. +;; * (@file :file-name "icicles-doc2.el" :to "Defining Multi-Commands the Hard Way") +;; for information about defining a custom candidate-help action +;; for a command. +;; +;;(@* "Alternative Actions") +;; ** Alternative Actions ** +;; +;; Just as you can use `C-RET', `C-mouse-2', `C-next', and so on to +;; invoke a command's default action on multiple completion +;; candidates individually, so you can use `C-S-RET' +;; (`icicle-candidate-alt-action'), `C-S-mouse-2', `C-S-next', and so +;; on to invoke an alternative action that is associated with the +;; command. If the main action of a command `my-find-file' is to +;; visit a file, and the alternative action is to print a file, then +;; you can use `C-S-RET' to print one or more files on the fly, even +;; as you are completing the name of a file to be visited. +;; +;; Keys `C-|' and `M-|' apply the alternative action defined for a +;; given multi-command to *all* matching candidates at once, in the +;; same way that `C-!' and `M-!' apply the main action defined for it +;; to all candidates. For example, in Icicles search (e.g. `C-c `'), +;; the alternative action (e.g. `C-S-RET') replaces all or part of +;; the current search hit, and `M-|' does the same for all search +;; hits. +;; +;; It is the particular command that defines its alternative action. +;; Some commands define no such action. Some commands, as their +;; alternative action, prompt you to choose (using completion) a +;; function to be applied to the current completion candidate. In +;; this case, a single alternative action effectively provides a set +;; of possible actions. +;; +;; To achieve this, such commands use the value of user option +;; `icicle-type-actions-alist', which associates lists of possible +;; functions with specific candidate types. For example, for +;; file-name candidates, you can choose among functions that act on +;; file names. +;; +;; Choosing such a function to apply is itself a multi-command +;; operation. You can thus apply any number of functions to any +;; number of candidates. +;; +;; For example, while you are using `C-x C-f', you can, say, print +;; one or more candidate files on the fly, or invoke a shell command +;; on selected files, or byte-compile them... This is a particularly +;; handy feature, especially if you customize +;; `icicle-type-actions-alist' for your own particular use. +;; +;; Some such functions you can choose produce no side effect; they +;; simply return a value. But if you use `C-u' before `C-S-RET', +;; then the result of applying the function is pretty-printed (in the +;; echo area or buffer `*Pp Eval Output*'). For example, if you use +;; `C-x C-f', you hit `C-u C-S-RET' on the candidate file name +;; `icicles-doc1.el', and you choose the function candidate +;; `file-attributes' at the completion prompt `How (action): ', then +;; the properties of the candidate file (`icicles-doc1.el') are +;; displayed. With just `C-S-RET' (no prefix arg), the list of +;; properties is computed, but not displayed. +;; +;; Be aware of this gotcha: The alternative action for commands that +;; use `icicle-type-actions-alist' prompts for a function. If you +;; want to apply that function to all current completion candidates, +;; then you must use `M-|', not `C-|', because `C-|' prompts you for +;; each candidate. `M-|' is designed to do the right thing here: it +;; prompts you once for the function to apply, and then applies it to +;; each of the current candidates. Andyou can filter the set of +;; current candidates (progressive completion and so on), or retrieve +;; a saved set of candidates to operate on. +;; +;; Note that completion while you choose a function to apply is lax. +;; This means that you can really enter any function, including a +;; lambda expression that you invent on the fly. Of course, the +;; function must accept an object of the appropriate type, (but it +;; need not actually use that argument). +;; +;; Using a lambda expression here is a good way to curry a function +;; that requires multiple arguments, so that it adapts to expect just +;; a single argument of the appropriate object type. For example, +;; (lambda (sym-name) (get (intern (sym-name)) 'invisible)) +;; transforms function `get', which takes a symbol and a property as +;; arguments, to a function that takes a symbol name and looks up the +;; `invisible' property of the symbol. +;; +;; Option `icicle-type-actions-alist' is predefined with a number of +;; candidate types (buffer, color, command, face, file, frame, +;; function, option, process, variable, and window) and their +;; associated action functions, but you can add new types or modify +;; their associated function lists. Any Emacs-Lisp functions can be +;; used, including lambda expressions. But each function must accept +;; a value of the appropriate type as its sole required argument +;; (additional, optional arguments are OK). +;; +;; Sometimes, you might want to define your own alternative action +;; function for some command. Do this if you always want the same +;; alternative action, and it is not the predefined one. To do this, +;; just customize option `icicle-alternative-actions-alist'. The +;; associations defined by this option always override any predefined +;; alternative actions for the corresponding commands. +;; +;; An alternative to using option `icicle-alternative-actions-alist' +;; is to define a new command, wrapping an existing command with a +;; `let' binding that defines the action you want. I recommend using +;; the option instead, but you might sometimes prefer this approach. +;; For example: +;; +;; (defun my-icicle-find-file (f) +;; "`icicle-find-file', but with `w32-browser' as the alt action." +;; (interactive +;; (let ((icicle-candidate-alt-action-fn 'w32-browser)) +;; (list (read-file-name "File: ")))) +;; (icicle-find-file f)) +;; +;; If you are familiar with Icicles object-action commands (see +;; (@file :file-name "icicles-doc2.el" :to "Icicles OO: Object-Action Interaction")), +;; then this idea of choosing an object (completion candidate) and +;; then choosing a function to act on it will ring a bell. And just +;; as for the object-action commands, here too Icicles exploits any +;; object-action associations ("sources" and "types") defined by +;; library Anything (`anything.el'), if you happen to use that, in +;; addition to the associations defined by +;; `icicle-type-actions-alist'. And when you do use the Icicles +;; object-action commands, the same behavior is available as for +;; alternative actions. +;; +;; You might have noticed, above, that a type/actions association is +;; predefined for type `function'. Since the actions you can choose +;; are themselves functions, you can even use `C-S-RET' on one of +;; them, to apply a function-for-functions (e.g. `find-function' or +;; `symbol-function') to it. This is a curiosity, but it can +;; sometimes be useful. +;; +;; Finally, note that the completion candidate to which you apply an +;; alternative action is in most cases a string. In some cases, the +;; alternative action functions expect a non-string object, and they +;; will raise an error if applied to a string. +;; +;; Icicles takes care of this in the case of buffer-name candidates. +;; It assumes that you really want to operate on a buffer, not its +;; name (a string), so it automatically calls `get-buffer' before +;; applying the alternative action function. +;; +;; See Also: +;; +;; * (@* "Perform Alternative Operations on the Fly") +;; * (@file :file-name "icicles-doc2.el" :to "Icicles OO: Object-Action Interaction") +;; * (@file :file-name "icicles-doc2.el" :to "Search and Replace") +;; * (@* "Choose All Completion Candidates") +;; +;;(@* "Deleting Objects") +;; ** Deleting Objects ** +;; +;; When it is defined for a particular command, minibuffer command +;; `icicle-delete-candidate-object', bound to `S-delete' (that's the +;; `delete' key, Shifted), deletes the object or objects named by the +;; completion candidate on which it operates. (At least that is the +;; default behavior - if you customize `icicle-deletion-action-flag' +;; to nil, then `S-delete' has no effect.) +;; +;; Which objects are thus targeted by a given candidate (name) is +;; something that must be defined by the particular command. The doc +;; string of a command should always indicate the effect of using +;; `S-delete', if a deletion action is defined. +;; +;; As an example of a deletion action, Icicles command +;; `icicle-buffer-other-window', bound to `C-x 4 b', opens buffers +;; named by the individual candidates you act on, using `C-RET'. But +;; it also kills any buffer that you act on, using `S-delete'. This +;; is not the alternative action for the command (which is bound to +;; `C-S-RET'); it is the deletion action. Similarly, command +;; `icicle-bookmark' jumps to a bookmark, but you can also use +;; `S-delete' with it to delete individual bookmarks. +;; +;; When you use `S-delete' with a command that allows duplicate +;; candidate names that represent different candidate objects, it +;; deletes only the object associated with the current candidate +;; (name). +;; +;; Some multi-commands define a deletion action, so that `S-delete' +;; works; some do not. Consult the doc for any given command to see +;; if it does. Whenever it is defined, the meaning of "delete" +;; depends on the particular command you use. +;; +;; `S-delete' deletes only the objects named by the current +;; completion candidate. However, with a prefix argument, it deletes +;; *ALL* objects named by the current set of completion candidates, +;; after you confirm that this is really what you want to do. This +;; is a quick way to delete things whenever `S-delete' is available: +;; Use input patterns, with progressive completion, chipping away, +;; and so on, to define the candidates to delete, then use `C-u +;; S-delete' and confirm their deletion. Bye-bye. +;; +;; Do not confuse the unshifted `delete' key with `S-delete'. +;; `delete' does not delete any objects; it just removes a completion +;; candidate so that you can't complete to it. `S-delete' deletes an +;; object and removes its name as a completion candidate. +;; +;; If you are an Emacs-Lisp programmer, then you can define your own +;; multi-commands that provide a deletion action via `S-delete'. +;; There are two ways to do this. Both involve binding +;; `icicle-delete-candidate-object': +;; +;; * Bind it to a deletion function. The function must accept a +;; completion candidate string and perform the deletion. +;; +;; * Bind it to a symbol (variable) whose value is a list of +;; completion-candidate objects. The entries in the list must be +;; completion candidates for the current call to `completing-read', +;; but the list itself need not be the COLLECTION argument to +;; `completing-read'. The list can be an alist, a list of strings, +;; or a list of symbols. The object that corresponds to the +;; current candidate when `S-delete' is invoked is deleted from the +;; list. If, in addition, the list variable is a user option, then +;; the updated list value is saved in the user's custom file. +;; +;; For more information about using this feature in Emacs-Lisp code, +;; see the doc of function `icicle-delete-current-candidate-object' +;; (`S-delete') and variable `icicle-delete-candidate-object'. +;; +;;(@* "Option `icicle-use-C-for-actions-flag'") +;; ** Option `icicle-use-C-for-actions-flag' ** +;; +;; In some contexts, you end up using `C-next' more than `next', and +;; likewise for the other keys that combine candidate action and +;; cycling. This is especially true for Icicles multi-commands that +;; act like a browser, such as `icicle-search', `icicle-imenu', +;; `icicle-find-tag', `icicle-Info-goto-node', and +;; `icicle-compilation-search'. In these cases, you use the action +;; keys to navigate among the locations indicated by the completion +;; candidates. +;; +;; If you set user option `icicle-use-C-for-actions-flag' to nil, +;; then the keys that cycle are swapped with the keys that both cycle +;; and act on a candidate. You can then use `down', `up', `next', +;; and `prior' to both cycle and act (e.g. navigate), and `C-down', +;; `C-up', `C-next', and `C-prior' to merely cycle, without acting. +;; The option has no effect on other keys. +;; +;; You can toggle `icicle-use-C-for-actions-flag' at any time using +;; `M-g' (`icicle-toggle-C-for-actions') in the minibuffer. +;; +;;(@* "Accessing Saved Locations (Bookmarks) on the Fly") +;; ** Accessing Saved Locations (Bookmarks) on the Fly ** +;; +;; When you complete the names of some kinds of objects, you can use +;; `C-x m' to follow bookmarks to objects of that type. This is +;; available only if you use library `bookmark+.el'. +;; +;; For example, when you invoke a command that completes file names, +;; you can use `C-x m' to interrupt that operation and complete +;; against the names of file bookmarks. This is a multi-command, so +;; you can actually visit any number of file bookmarks. When +;; finished, you can continue with non-bookmark file-name completion. +;; +;; The same thing holds for Info bookmarks when you use +;; `icicle-Info-goto-node' (`g' in Info mode); for buffer (non-file) +;; bookmarks when you use `icicle-buffer' (`C-x b'); and for Dired +;; bookmarks when you use `icicle-dired' (`C-x d'). +;; +;; See Also: +;; (@file :file-name "icicles-doc2.el" :to "Icicles Bookmark Enhancements") + +;;(@* "Icicles Tripping") +;; +;; Tripping with Icicles +;; --------------------- +;; +;; Among the more useful multi-commands are those whose actions take +;; you to some location indicated by the completion candidate. This +;; is the way commands such as `icicle-bookmark', `icicle-find-tag', +;; `icicle-Info-goto-node', and `icicle-occur' work - you can use +;; `next' and so on to move among candidates to choose them to act +;; on, but when you do act on them, Icicles takes you to the places +;; they name. +;; +;; So just holding down both the Control key and `next' takes you +;; from one place to the next. And `C-mouse-2' takes you directly to +;; the location you click. Typically, `C-g' aborts the trip and puts +;; you back at your starting point, and `RET' ends the trip at the +;; chosen destination. +;; +;; There are many such Icicles tripping (or navigation or browsing) +;; commands, and they all work similarly. They give you the normal +;; cycling behavior provided by vanilla Emacs commands such as +;; `find-tag' (via `M-.', `C-u M-.', `M-*' etc.) or +;; `set-mark-command' (via `C-u C-SPC'). But unlike the vanilla +;; Emacs commands, the keys for this cycling are always the same. +;; +;; More importantly, you need not cycle through all possibilities. +;; You can go directly to particular locations with `C-RET', +;; `C-mouse-2' or using completion. And your input filters the +;; available candidates, as always. And you can, as always, use +;; progressive completion, chipping away, and so on to define your +;; `C-next' trip itinerary using a process of refinement. +;; +;; Whereas vanilla Emacs gives you some commands that let you use +;; completion to enter a destination and go there, and it gives you +;; other commands that let you cycle among locations, Icicles rolls +;; all of that into one. And you use the same keys, always, to +;; navigate. +;; +;; Here are some of the Icicles tripping commands: +;; +;; * `icicle-bookmark-other-window' - (`C-- C-x r m') +;; Trip among bookmarks of all types. (Also bound to `C-x 4 j j' +;; if library `bookmark+.el' is used.) +;; * Type-specific bookmark trips (requires library `bookmark+.el'). +;; (Use prefix key `C-x 4 j' for other-window commands.) +;; `icicle-bookmark-non-file' (`C-x j b') +;; `icicle-bookmark-bookmark-list' (`C-x j B') +;; `icicle-bookmark-dired' (`C-x j d') +;; `icicle-bookmark-file' (`C-x j f') +;; `icicle-bookmark-gnus' (`C-x j g') +;; `icicle-bookmark-info' (`C-x j i') +;; `icicle-bookmark-desktop' (`C-x j K') +;; `icicle-bookmark-local-file' (`C-x j l') +;; `icicle-bookmark-man' (`C-x j m') +;; `icicle-bookmark-region' (`C-x j r', `C-u C-x C-x') +;; `icicle-bookmark-remote-file' (`C-x j n') +;; `icicle-bookmark-all-tags' (`C-x j t *') +;; `icicle-bookmark-some-tags' (`C-x j t +') +;; `icicle-bookmark-all-tags-regexp' (`C-x j t % *') +;; `icicle-bookmark-some-tags-regexp' (`C-x j t % +') +;; `icicle-bookmark-url' (`C-x j u') +;; `icicle-bookmark-w3m' (`C-x j w') +;; `icicle-bookmark-this-buffer' (`C-x j .') +;; `icicle-bookmark-specific-buffers' (`C-x j = b') +;; `icicle-bookmark-specific-files' (`C-x j = f') +;; * `icicle-buffer' (`C-x b') - Trip among buffers +;; * `icicle-compilation-search' (`C-c `') - Trip among `grep' hits +;; * `icicle-dired' - Trip among directories +;; * `icicle-find-file' (`C-x C-f') - Trip among files +;; * `icicle-find-file-absolute' (`C-u C-x C-f') - Trip among files +;; * `icicle-find-file-in-tags-table' - Trip among files listed in +;; current tags table (project) +;; * `icicle-find-file-read-only' (`C-x C-r') - Visit read-only +;; * `icicle-find-first-tag' (`C-x 4 .') - Trip among tag hits +;; * `icicle-find-tag' (`M-.') - Trip among tag hits +;; * `icicle-goto-global-marker' (`C-- C-x C-SPC') - Trip among +;; global markers +;; * `icicle-goto-marker' (`C-- C-SPC') - Trip among local markers +;; * `icicle-imenu' (`C-c ='), `icicle-imenu-command', +;; `icicle-imenu-non-interactive-function' - Trip among definitions +;; * `icicle-Info-goto-node' (`g' in Info)- Trip among Info nodes +;; * `icicle-Info-index' (`i' in Info) - Trip among Info nodes +;; * `icicle-Info-menu' (`m' in Info) - Trip among Info nodes +;; * `icicle-locate-file' - Trip among files +;; * `icicle-occur' (`C-c '') - Trip among `occur' hits +;; (`icicle-search' among +;; single-line hits) +;; * `icicle-recent-file' - Trip among recent files +;; * `icicle-search' (`C-c `') - Trip among regexp search hits +;; * `icicle-search-bookmarks-together' (`C-u C-c `'), +;; `icicle-search-bookmark', - Search multiple bookmarks +;; * Type-specific bookmark searches +;; `icicle-search-bookmark-list-bookmark' - Search bookmark lists +;; `icicle-search-dired-bookmark' - Search Dired bookmarks +;; `icicle-search-file-bookmark' - Search file bookmarks +;; `icicle-search-gnus-bookmark' - Search Gnus bookmarks +;; `icicle-search-info-bookmark' - Search Info bookmarks +;; `icicle-search-local-file-bookmark'- Search local-file bookmarks +;; `icicle-search-man-bookmark' - Search `man'-page bookmarks +;; `icicle-search-non-file-bookmark' - Search non-file bookmarks +;; `icicle-search-region-bookmark' - Search bookmarked regions +;; `icicle-search-remote-file-bookmark' - Search remote bookmarks +;; `icicle-search-url-bookmark' - Search URL bookmarks +;; * `icicle-search-char-property' - Trip among buffer strings with +;; with a text/overlay property +;; * `icicle-search-dired-marked' - Search marked files in Dired +;; * `icicle-search-file' - Search multiple files +;; * `icicle-search-ibuffer-marked' - Search marked bufs in Ibuffer +;; * `icicle-search-keywords' (`C-c ^') - Trip among keyword search +;; hits. +;; * `icicle-search-overlay-property' - Trip among buffer strings +;; with some overlay property. +;; * `icicle-search-pages' - Search Emacs pages +;; * `icicle-search-paragraphs' - Search Emacs paragraphs +;; * `icicle-search-sentences' - Search sentences as contexts +;; * `icicle-search-text-property' (`C-c "') - Trip among buffer +;; strings with a text property +;; * `icicle-search-word' (`C-c $') - Trip among word-search hits +;; * `icicle-select-frame' (`C-x 5 o') - Trip among frames, by name +;; * `icicle-select-window' (`C-0 C-x o') - Trip among windows, by +;; buffer name +;; +;;(@* "Highlighting the Destination") +;; ** Highlighting the Destination ** +;; +;; `icicle-bookmark-region-other-window' activates the bookmarked +;; region (highlighting it) when you visit it, if you use Transient +;; Mark mode (or, e.g., Delete Selection mode). +;; +;; Starting with Emacs 22, most Icicles commands that have single +;; positions as their trip visits (e.g. `icicle-bookmark', +;; `icicle-Info-goto-node', `icicle-goto-marker', `icicle-find-tag') +;; highlight those positions temporarily as they are visited. Except +;; for the Icicles search commands, this highlighting is provided by +;; library `crosshairs.el'. If `crosshairs.el' and the libraries it +;; requires are not in your `load-path', then no such highlighting +;; occurs. +;; +;; See Also: +;; +;; * (@* "Icicles Commands that Read File Names") for information +;; about `icicle-find-file', `icicle-find-file-absolute', +;; `icicle-find-file-in-tags-table', `icicle-locate-file', and +;; `icicle-recent-file'. +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Tags Enhancements") +;; for information about `icicle-find-first-tag' and +;; `icicle-find-tag'. +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Bookmark Enhancements") +;; for information about the bookmark browsing commands. +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Info Enhancements") +;; for information about `icicle-Info-goto-node', +;; `icicle-Info-index', and `icicle-Info-menu'. +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; for information about `icicle-occur' and `icicle-search'. +;; * (@file :file-name "icicles-doc2.el" :to "Other Icicles Search Commands") +;; for information about `icicle-compilation-search', +;; `icicle-imenu', `icicle-imenu-command', +;; `icicle-imenu-non-interactive-function', +;; `icicle-search-char-property', `icicle-search-keywords', +;; `icicle-search-overlay-property', and +;; `icicle-search-text-property'. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Defining Icicles Tripping Commands") +;; for information about defining your own tripping commands. + +;;(@* "Key Completion") +;; +;; Key Completion +;; -------------- +;; +;; Here's another weird Icicles feature: completing key sequences, +;; instead of commands. (This feature works only for Emacs 22 and +;; later.) +;; +;; What on earth for? Ever want to use one of those myriad `C-x' key +;; sequences, but forget just what it was? The standard solution to +;; that is to use `C-x C-h', to display all of the `C-x' bindings +;; together with their commands. +;; +;; OK, but then you have to scroll down the list of bindings, +;; searching for the command you want, and then use its key binding. +;; You can use `C-M-s' to search for a substring of the command name, +;; in case you don't recall the exact name, but why not use Icicles +;; completion for this? Why not match against possible key sequences +;; and commands? +;; +;;(@* "Completing Keys") +;; ** Completing Keys ** +;; +;; To complete keys in Icicles, start the key sequence as usual, and +;; then hit `S-TAB' (command `icicle-complete-keys'). For example, +;; use `C-x' or `C-x 4', and then hit `S-TAB' to complete the prefix +;; `C-x' or `C-x 4' (or whatever). You're then completing against +;; candidates that are composed of two parts, separated by " = ": +;; +;; * a key binding that completes what you've typed so far - +;; e.g. `C-j' (that is, `C-x C-j') +;; +;; * the command it is bound to - e.g. `dired-jump-other-window' +;; +;; So, for example, this is a single completion candidate: +;; +;; C-j = dired-jump-other-window +;; +;; You can match your minibuffer input against the key name, the +;; command name, or both. +;; +;; Suppose, for instance, that you want to use a version-control +;; command, and you remember that all such commands are bound to key +;; sequences that begin with `C-x v'. You enter as much of the key +;; sequence as you remember (`C-x v'), and then you hit `S-TAB'. You +;; can then use completion (either apropos or prefix) against the +;; matching key sequences and command names to invoke the right +;; command. And, as a bonus, you are reminded of its key sequence. +;; You can thus use Icicles key completion to execute a command and, +;; at the same time, learn its key binding. +;; +;; (The documentation always refers to the key that performs key +;; completion as `S-TAB'. Actually, it is `S-TAB' only by default. +;; You can customize it, using option `icicle-key-complete-keys'.) +;; +;;(@* "`S-TAB' Is Everywhere - Start With It") +;; ** `S-TAB' Is Everywhere - Start With It ** +;; +;; In Icicle mode, whenever you are not in the minibuffer or buffer +;; `*Completions*', key `S-TAB' initiates key completion. That is, +;; you don't need to first type part of a key sequence to use it - +;; you can start with it. Hit `S-TAB' at any time, and you're +;; completing a key sequence, even if you haven't yet hit any keys. +;; This lets you see all key sequences that are available in a given +;; context. For example, in Dired, keys special to that mode are +;; included (and are highlighted as local bindings - +;; see (@> "Local Bindings Are Highlighted")). +;; +;; When completing a key sequence, you can type part of a command +;; name, then hit `S-TAB' to apropos-complete against the command +;; name. In this respect, `S-TAB' acts like `M-x', but the key +;; binding is also part of the completion candidate, so you can also +;; match key names. +;; +;;(@* "Completing Keys By Name") +;; ** Completing Keys By Name ** +;; +;; So, just how do you complete input against a set of +;; binding-plus-command completion candidates? You can always cycle +;; among the candidates, of course, and then choose one. But what +;; about completion? Just type text to match candidates, then use +;; `S-TAB' or `TAB' as usual to complete the text. Text? Yes. +;; Completion candidates are always, ultimately, strings. +;; +;; Suppose that you type `C-x S-TAB' to show all key sequences that +;; begin with `C-x'. You might see a candidate that looks like this: +;; +;; C-q = toggle-read-only +;; +;; You can then type "C-q" or "d-onl" or any other substring, and +;; then use `S-TAB' to complete the candidate. (This second use of +;; `S-TAB' invokes the command `icicle-apropos-complete', which has +;; nothing to do with `icicle-complete-keys', which was invoked by +;; the first `S-TAB'. The first was invoked outside the minibuffer; +;; the second was invoked from the minibuffer, during completion.) +;; +;;(@* "Completing Prefix Keys") +;; ** Completing Prefix Keys ** +;; +;; What happens if the completion candidate is itself a prefix key? +;; For example, `C-x S-TAB' shows some candidates whose commands are +;; shown as "...", like this: +;; +;; 4 = ... 5 = ... +;; 6 = ... C-k = ... +;; ESC = ... RET = ... +;; +;; These represent prefix keys (`C-x 4', `C-x C-k', and so on). If +;; you choose such a candidate, then you just continue completing - +;; buffer `*Completions*' is updated to show the completions of the +;; compound prefix: `C-x 4', `C-x RET', or whichever you choose. The +;; minibuffer prompt shows the completion so far; if you choose +;; `RET', for instance, then it shows `C-x RET' while prompting you +;; for the rest of the key sequence. +;; +;; By default, completion candidates are sorted in buffer +;; `*Completions*' with local bindings listed first. You can use +;; `C-M-,' at any time during key completion to toggle between this +;; order and sorting with the prefix-key candidates shown first. You +;; can use `C-,' at any time to change the sort order among these two +;; orders and sorting by command name. +;; +;; Gotcha: Commands that are remapped do not show up with the +;; bindings you think they have. For example, `C-x C-f' is bound to +;; `icicle-file' in Icicle mode, by default, but `C-x S-TAB' does not +;; include the completion candidate `C-f = icicle-file'. Instead, +;; `S-TAB' at the top level (without first doing `C-x') shows a +;; (pseudo) prefix key `remap = ..', and if you follow that then +;; you'll see the candidate `find-file = icicle-file'. The binding +;; of `C-x C-f' does not appear as such, because `find-file' is +;; remapped to command `icicle-file': whatever `find-file' was bound +;; to is indirectly bound to `icicle-file'. This indirection shows up +;; in Icicles key completion as (pseudo) prefix key `remap = ..'. +;; +;;(@* "Meta Key Bindings") +;; ** Meta Key Bindings ** +;; +;; If you use `S-TAB' at the top level, and you look for the key +;; sequence `M-x' or `M-d', you won't find it. Meta key bindings are +;; there, but many of them are disguised as keys in the `ESC' prefix +;; keymap - e.g. `ESC x' for `M-x'. That is, you must first choose +;; the `ESC` prefix key: `ESC = ...', and then choose the `x' key +;; or whatever. That's just the way Emacs works. So, yes, you can +;; use Icicles key completion to execute any Emacs command, even one +;; that is not bound to a key sequence, and you can use it to +;; evaluate any EmacsLisp expression. See (@> "Three-Key Emacs"). +;; +;;(@* "Navigate the Key-Binding Hierarchy") +;; ** Navigate the Key-Binding Hierarchy ** +;; +;; Choosing a completion candidate such as `C-x = ...' effectively +;; navigates down the key-binding hierachy (prefix-key hierarchy), to +;; complete against all keys with prefix `C-x'. Choosing `5 = ...' +;; to complete the prefix `C-x' then navigates down another level, to +;; complete keys that have prefix `C-x 5'. +;; +;; What about navigating back up the hierarchy, say from the `C-x 5' +;; keys to the `C-x' keys, or from the `C-x' keys to the keys with no +;; prefix? The special completion candidate `..' does that. By +;; default, it is always the first candidate in the `*Completions*' +;; list. It is of course not available unless you are completing a +;; prefix; that is, it is not available at the top level. +;; +;; This feature means that you can navigate the key-binding hierachy +;; just as you would navigate the file-system hierarchy (using, say, +;; `C-x C-f') or the menu-bar hierarchy (using library `lacarte.el'). +;; (In fact, since menu-bar bindings are also key bindings, you can +;; also use key completion to navigate the menu-bar hierarchy - just +;; complete the prefix key `menu-bar'! Start with `S-TAB', choose +;; `menu-bar = ...', then choose a menu, and so on.) +;; +;; Icicles key completion thus provides a general browser for key +;; bindings, which you can also use to learn about keys and their +;; associated comands, without necessarily executing them - see +;; (@> "Key and Command Help"). +;; +;; Gotcha: `S-TAB' uses apropos completion, by default, so remember +;; that typing `.' matches any character (except a newline). To +;; match only the literal string `..' (to go up a level), do one of +;; the following: +;; +;; * Turn on escaping of regexp special characters - use `C-`' in the +;; minibuffer to toggle this. +;; +;; * Use prefix completion (`TAB'). +;; +;; * Escape the regexp special character explicitly: `\.\.' (or use +;; `^\.'). +;; +;; * Cycle to candidate `..'. +;; +;;(@* "Local Bindings Are Highlighted") +;; ** Local Bindings Are Highlighted ** +;; +;; Sometimes it helps to know which key sequences are local bindings, +;; that is, bindings that are specific to the current mode. For +;; example, Dired mode defines keys specific to Dired buffer, such as +;; `* %', `% g', and `!'. To help you distinguish local key bindings +;; from others (global and minor-mode bindings), local bindings are +;; highlighted in buffer `*Completions*' using face +;; `icicle-special-candidate'. +;; +;;(@* "Completing Keys By Just Hitting Them") +;; ** Completing Keys By Just Hitting Them ** +;; +;; It may seem odd that you must complete a key sequence by entering +;; the names of keys, rather than just hitting the keys themselves: +;; e.g. typing "C-f" rather than hitting `C-f'. However, if keys +;; themselves were used for completing, then they could not be used +;; normally during key-sequence completion. You could not move the +;; cursor around the minibuffer using `C-f' or `right' (right arrow), +;; because those keys would be treated as input for completion. You +;; could not use `up' or `down' to cycle among completion candidates +;; for the same reason. Likewise, you could not use printing +;; (self-inserting) keys, such as `a' and `$', to match command +;; names. Having to use key names, instead of keys, for completion +;; is a small price to pay for being able to complete key sequences. +;; +;; Nevertheless, Icicles also provides a way for you to type key +;; sequences directly, even if it is something of a workaround: +;; precede each key with `M-q' (`icicle-insert-key-description', +;; during key completion) - think of `q' for "quote". This inserts +;; the key description of whatever key you hit next. This key +;; description (name) can be used to match key-completion candidates. +;; So, for example, instead of typing "C-f", you can hit `M-q' and +;; then hit `C-f'. The key description "C-f" is inserted in the +;; minibuffer. If you use `M-q C-M-right', then "C-M-right" is +;; inserted. Try it: `S-TAB M-q C-M-right' -> "C-M-right". Then hit +;; `TAB' or `S-TAB' to complete the candidate all the way to this: +;; +;; C-M-right = enlarge-frame-horizontally +;; +;; Note: Whether or not angle brackets are used is governed by user +;; option `icicle-key-descriptions-use-<>-flag'. By default, this is +;; nil, so angle brackets are not used, which I think improves +;; readability. If you set this to non-nil, then you will see +;; "" instead of "C-M-right", both as a completion +;; candidate and as what is inserted when you use `M-q'. You can +;; also provide a prefix argument to `M-q' to flip the behavior of +;; `icicle-key-descriptions-use-<>-flag' for that occurrence only. +;; +;;(@* "Key and Command Help") +;; ** Key and Command Help ** +;; +;; That points out another use of key completion, opposite to +;; learning the bindings of commands: learning the commands bound to +;; given keys. In other words, `S-TAB M-q' does both what `C-h w' +;; (`where-is') does and what `C-h c' (`describe-key-briefly') does. +;; It also does what `C-h b' (`describe-bindings') does. +;; +;; The point here is not that `S-TAB M-q' is quicker than `C-h w' or +;; `C-h c' or `C-h b' - it's not. The point is that key completion +;; can be handy in several ways, and it can teach you various things +;; about keys and commands as you use it. +;; +;; In addition to this key-completion help about bindings, you can +;; display help on the commands that are the right sides of the +;; `S-TAB' completion-candidate equations, by using the multi-command +;; help keys (see (@> "Help on Completion Candidates")). That is, +;; while completing, you can use `C-M-mouse-2', `C-M-RET', +;; `C-M-next', and so on to describe the command named in the current +;; completion candidate. +;; +;;(@* "`S-TAB' Is a Multi-Command") +;; ** `S-TAB' Is a Multi-Command ** +;; +;; Yes, `S-TAB' as `icicle-complete-keys' is a multi-command - see +;; (@> "Multi-Commands")). This means that you can, within the same +;; execution of `S-TAB', invoke any number of keys by clicking +;; (`C-mouse-2') their names in buffer `*Completions*' or choosing +;; them any other way (`C-RET', `C-next', and so on). +;; +;; Since you can navigate up and down the key-binding hierarchy, you +;; could even stay within a single `S-TAB' invocation to do nearly +;; everything you want in Emacs (see (@> "Three-Key Emacs"))! +;; +;;(@* "Possible Source of Confusion") +;; ** Possible Source of Confusion ** +;; +;; Keep in mind that `S-TAB' has two different uses in Icicles when +;; you are providing input in the minibuffer: +;; +;; * If input completion is available, then `S-TAB' performs apropos +;; completion (it is, in effect, bound to +;; `icicle-apropos-complete'). +;; +;; * If input completion is not available, then `S-TAB' performs key +;; completion (it is, in effect, bound to `icicle-complete-keys'). +;; +;; In addition, in buffer *Completions* `S-TAB' moves backward among +;; the candidate completions. +;; +;; This is by design; it takes advantage of the fact that these +;; contexts are mutually exclusive. However, this economy comes at a +;; risk of potential confusion. It's important that you know whether +;; or not completion is available when you are inputting text. If +;; input completion is not available, but you think it is, then +;; hitting `S-TAB' might give you a surprise by key completing. That +;; behavior is normal - you can use key-completion to input special +;; characters, for instance. But if you think that you are instead +;; completing the original input requested, then you can become +;; confused. +;; +;; Icicles provides completion status indicators so that you can +;; easily tell when completion is available for minibuffer input. +;; There are two indicators: (1) at the beginning of the minibuffer +;; prompt and (2) in the `Icy' minor-mode lighter in the mode line. +;; See (@> "Completion Status Indicators"). If completion is not +;; indicated when you are prompted for input, it means that `S-TAB' +;; is available, not for input completion, but for key completion. +;; Another clue can be found in the prompt text. For key completion, +;; it says "Complete keys: ". +;; +;; If you nevertheless find the overloaded use of `S-TAB' confusing, +;; you can change the bindings of the key `S-TAB' in these different +;; contexts. To do that, you can customize options +;; `icicle-apropos-complete-keys', `icicle-key-complete-keys', and +;; `icicle-previous-candidate-keys'. +;; +;;(@* "Three-Key Emacs") +;; ** Three-Key Emacs ** +;; +;; Icicles key completion piles a lot of stuff into `S-TAB'. Just as +;; `M-x' lets you execute any Emacs command, so does `S-TAB'. But +;; `S-TAB' also lets you insert characters. With the exception of +;; inserting multi-byte characters, you might say that it gives you +;; all of Emacs in one key binding. +;; +;; Of course, you need a couple other keys, as well. How many? +;; Suppose you had limited accessibility in terms of input devices. +;; Maybe you use Emacs on a cell phone, without voice recognition - +;; or whatever. How many keys, buttons, or whatnot do you need to +;; use Emacs? +;; +;; 1. You need one for `C-g', to interrupt commands. +;; 2. You need one to start telling Emacs what to do. +;; 3. You might need one to choose from a set of possible things to +;; do. +;; 4. You need one to tell Emacs that you're done telling it what to +;; do. +;; +;; (#2 and #3 might be combined somehow.) +;; +;; What does vanilla Emacs offer out of the box in this regard? +;; +;; * You can get by with just `mouse-1' and the menu-bar menus, but +;; they don't cover all of Emacs. You can't use them to enter +;; text, for instance. Of course, you could add more menus, to be +;; able to do more. +;; +;; * You can use `M-x' plus `RET' to execute any command. But how +;; would you insert text? +;; +;; * Similarly, for `M-:', which lets you evaluate any EmacsLisp +;; sexp. You still need a way to type characters. +;; +;; Icicles key completion lets you do almost anything in Emacs with +;; three or four keys, buttons, or whatever: +;; +;; * `S-TAB' - Offers every key sequence as a possible choice to +;; execute. +;; * `next' - Cycles among candidates, for choosing. +;; * `RET' - Chooses the current candidate. +;; * And of course `C-g', to cancel the current operation. +;; +;; `S-TAB' includes key `M-x (represented as prefix key `ESC' +;; followed by `x'), which offers all commands (even those not bound) +;; as possible choices. It also includes key `M-:' (`ESC' followed +;; by `:'), which lets you execute any Emacs-Lisp expression. That's +;; almost all of Emacs! +;; +;; You could even perhaps get away with only three mouse buttons, and +;; no keyboard: +;; +;; * `mouse-1' - Choose candidates, scroll, and so on (direct access, +;; no cycling). +;; +;; * `mouse-2' - Do what `S-TAB' does (bind it to +;; `icicle-complete-keys' and `icicle-apropos-complete'). +;; +;; * `mouse-3' - Do what `C-g' does (bind it to `keyboard-quit' and +;; `icicle-abort-recursive-edit'). +;; +;; Here, `mouse-2' and `mouse-3' aren't even used as mouse (pointer) +;; functions; any keys or buttons would do. You could use just +;; `mouse-1' plus a Shift key and a Control key. +;; +;; Would you want to use Emacs only this way? Of course not, if you +;; had a choice. Typing the character `a' by cycling through every +;; possible key binding/command combination and hitting `RET' when +;; you get to `a = self-insert-command' would be the epitome of +;; tedium. Likewise, doing everything with a single pointer-device +;; button. Using only three or four keys or buttons is definitely +;; not the ideal way to take advantage of Emacs. +;; +;; But you are probably not limited to just 3 or 4 keys or buttons. +;; The real point here is that Icicles `S-TAB' opens the door to +;; almost everything in Emacs. And if you do have a normal keyboard, +;; then you can type letters and such to match command names and key +;; sequences. Key `next' matches substrings (regexps, actually), +;; which makes choice even quicker. +;; +;; Why only "almost" everything in Emacs? Because you cannot use +;; Icicles `S-TAB' to input multi-byte characters (e.g. Chinese, +;; Japanese, Unicode). Such characters are grouped in Emacs into +;; character groups called "generic characters", and it is the +;; generic characters, not the individual multi-byte characters that +;; are bound to `self-insert-command'. Icicles excludes these +;; special key bindings, because you cannot simply execute +;; `self-insert-command' to insert these characters. (It is possible +;; to implement a completion extension to input such characters, but +;; that feature has not yet been implemented in Icicles.) +;; +;; Enjoy! +;; +;;(@* "Entering Special and Foreign Characters") +;; ** Entering Special and Foreign Characters ** +;; +;; Command `self-insert-command' is bound to each key that is +;; associated with a character that can be inserted in text. It is +;; the binding of the key `a' and the key `$'. It is also the +;; binding of keys that your keyboard might not even have - keys that +;; correspond to special or odd characters and characters in other +;; languages. +;; +;; To Icicles key completion, these keys are like any other keys, and +;; `self-insert-command' is like any other command. However, because +;; there are many, many keys bound to it, it can be distracting to +;; allow such keys as completion candidates. If option +;; `icicle-complete-keys-self-insert-flag' is nil (the default +;; value), then such keys are excluded as candidates. +;; +;; If it is non-nil, then you can use key completion to insert +;; characters that your keyboard has no keys for. This provides a +;; sort of universal input-method feature that works, in principle, +;; for all characters (but see below, for exceptions). +;; +;; To use this feature, just choose a character description (name) +;; with the mouse or by cycling, if you cannot type its description +;; (name) with your keyboard. You can even insert characters this +;; way that your system has no font for - they will be displayed as +;; empty boxes, but they will be correctly inserted. +;; +;; There is an exception, however. You cannot insert some characters +;; this way, because they don't have a one-to-one relation with keys +;; that are bound to `self-insert-command'. In such cases, "keys" +;; are bound to `self-insert-command' that represent not single +;; characters but groups of characters. Icicles filters out these +;; keys, so they are not available as completion candidates. The +;; problematic keys are in Korean, Chinese, Japanese, Ethiopic, +;; Indian, Tibetan, and some Unicode character sets. +;; +;; Because insertion of special characters is useful, but is a +;; special case of key completion, there is a separate Icicles +;; command that you can use just for that: `icicle-insert-char'. It +;; is a specialized version of `icicle-complete-keys' that uses +;; `self-insert-command' as the only possible command for completion. +;; +;;(@* "Handling Keymaps That Are Inaccessible From the Global Map") +;; ** Handling Keymaps That Are Inaccessible From the Global Map ** +;; +;; Actually, `S-TAB' is not bound to `icicle-complete-keys' in every +;; keymap. That would be inconvenient, in general. By default, it +;; is so bound in each keymap that is accessible from the global +;; keymap, as determined by function `accessible-keymaps'. +;; +;; You've seen, above, how you can navigate through prefix keys, +;; starting with the global map. In Dired, for instance, you can use +;; `S-TAB' at the top level, then choose the prefix key `*' in +;; `*Completions*', then choose a key, such as `/' (to mark +;; directories), in the `*' keymap. +;; +;; However, the act of binding of `S-TAB' in keymaps that are +;; accessible from the global map does not bind it in the `*' prefix +;; keymap itself. To handle this case, Icicles explicitly does for +;; `dired-mode-map' what it does for the global map: it binds `S-TAB' +;; in each keymap that is accessible from `dired-mode-map'. Because +;; of this, you can use `* S-TAB' to show all key completions of `*'. +;; +;; This treatment of `dired-mode-map' is done by default. Similarly +;; for a few other keymaps. But you might have other keymaps that +;; you would like to treat similarly - keymaps that Icicles might be +;; unaware of. You do this by including them in the list value of +;; user option `icicle-keymaps-for-key-completion', along with +;; `dired-mode-map' and the others provided in the default value. +;; The list entries are Emacs-Lisp symbols that are bound to keymaps, +;; each of which should define at least one prefix key. If you add a +;; keymap variable to this list, then `S-TAB' will be bound so that +;; you can use it to complete the prefix keys defined by that map. +;; +;; Notice that there is no keymap variable that corresponds to prefix +;; key `*' in Dired mode. You need only provide a keymap (variable +;; `dired-mode-map') from which the prefix key is accessible; it is +;; not necessary to also provide a variable that corresponds to the +;; prefix keymap itself. +;; +;; If a keymap listed in `icicle-keymaps-for-key-completion' is not +;; defined when Icicle mode is entered, then it is ignored. If you +;; later define that keymap, then just exit and reenter Icicle mode +;; for the `S-TAB' binding to take effect. For example, use `M-x +;; icy-mode' twice after entering Calendar mode, to be able to +;; complete `calendar-mode' prefix keys such as `t' - `t S-TAB'. + +;;(@* "Icicles Multi `M-x'") +;; +;; Icicles Multi `M-x' +;; ------------------- +;; +;; How about a multi-command replacement for `M-x'? Instead of +;; executing a single command, it would execute any number of +;; commands. This section describes two such multi-commands, +;; `icicle-execute-extended-command' and `icicle-command-abbrev', +;; which by default are bound in Icicle mode to `M-x' and `C-x SPC', +;; respectively. See Also: +;; (@file :file-name "icicles-doc2.el" :to "Defining Icicles Multi `M-x'"). +;; +;;(@* "Multi `M-x': `icicle-execute-extended-command'") +;; ** Multi `M-x': `icicle-execute-extended-command' ** +;; +;; When you use `M-x' in vanilla Emacs, you are actually executing +;; the standard Emacs command `execute-extended-command'. That +;; command prompts you for the name of another command, which you +;; input. It uses `completing-read' to do this, which is why you can +;; take advantage of Icicles features when you use `M-x'. Nothing +;; new here. +;; +;; Command `icicle-execute-extended-command' is simply a +;; multi-command version of `execute-extended-command'. It does the +;; same thing, except that it also lets you execute multiple +;; commands, one by one, using `C-RET' (or `C-next' and so on), +;; without ever exiting the minibuffer. +;; +;; With the default value of option `icicle-top-level-key-bindings', +;; `M-x' is bound to `icicle-execute-extended-command' whenever you +;; are in Icicle mode. If you never use it as a multi-command, you +;; won't notice any difference from `execute-extended-command'. +;; +;;(@* "Examples of Using Multi `M-x'") +;; *** Examples of Using Multi `M-x' *** +;; +;; Example: Repeat a command multiple times. Yes, `C-x z' does this +;; already (and better) - this is just an illustration. `M-x +;; forward-ch TAB' completes to `forward-char'. Then, use `C-RET' to +;; execute that command. Repeat as many times as you want. Use a +;; prefix arg if you like. +;; +;; To switch to another command in the same `M-x' invocation: Erase +;; the minibuffer (`M-k'), complete the second command, then use +;; `C-RET'. As long as you haven't yet used `RET', `S-RET', `C-g' +;; (or, say, `C-]'), you remain within the same invocation of `M-x'. +;; +;; What about executing a command that, itself, reads an input +;; argument? That's OK. And if that command reads its input with +;; completion, then you can use `C-RET' on the completion candidates +;; for that input. +;; +;; Example: `M-x describe-fa TAB C-RET' gives you the prompt for +;; command `describe-face'. +;; +;; 1. Type `ici S-TAB' to see the available Icicles faces. +;; +;; 2. Hit `next' until face `icicle-complete-input' is highlighted. +;; +;; 3. Hit `C-RET' to display its documentation. +;; +;; 4. Type `C-next' a few times to see the doc of other Icicles +;; faces. +;; +;; 5. Use `M-k' to erase the minibuffer, then type `search S-TAB' to +;; see faces about searching. +;; +;; 6. Cycle through them with `next', then use `C-RET' on +;; `icicle-search-main-regexp-current' to show its documentation. +;; +;; 7. Use `C-next' to do the same for face +;; `icicle-search-main-regexp-others'. +;; +;; 8. Use `RET' to finish with command `describe-face' - but you're +;; still in the same invocation of `M-x'. +;; +;; 9. Change the input to `describe-coding-system' and play again, +;; this time with coding-system names... +;; +;; Remember, if you get confused or lost: `C-]' +;; (`abort-recursive-edit') or `M-x top-level' should always +;; straighten you out. +;; +;;(@* "What about describe-variable and describe-function?") +;; *** What about describe-variable and describe-function? *** +;; +;; Sadly, if you try the last example with `describe-variable' or +;; `describe-function', you might be in for a surprise. In Emacs 20, +;; they both work fine. In later Emacs versions, `describe-variable' +;; gives you the message "You did not specify a variable", and +;; `describe-function' displays a *Help* buffer that says that each +;; function you choose is really a keyboard macro! +;; +;; Why? It's a bit complex, but worth hearing about if you want to +;; understand multi M-x better. +;; +;; When you choose a command that reads an argument in the minibuffer +;; and you then hit a multi-command key such as `C-RET' to choose an +;; argument, Icicles tries to apply the command you chose to the +;; argument you chose. However, completion candidates are always +;; strings, and the command you chose might expect something other +;; than a string. That is the case for `describe-variable', for +;; instance. The case of describe-function' is special: it +;; interprets a string argument blindly as a keyboard macro sequence. +;; +;; Icicles is smart enough to pick up a `wrong-type-argument' error, +;; if the command you choose barfs on a string argument. In that +;; case, Icicles converts the string to a symbol (or a number) and +;; tries again, using the symbol (or the number). +;; +;; And that's why `describe-variable' works in Emacs 20 but not in +;; later versions: In Emacs 20, `describe-variable' (sanely) raises a +;; type error if you pass it a string, and Icicles is able to save +;; the day by then passing it the corresponding symbol. In later +;; versions of Emacs, however, instead of raising an error with the +;; message "You did not specify a variable", `describe-variable' just +;; displays the message - no error, so there is no way for Icicles to +;; recuperate. +;; +;; I've reported this design misfeature to the Emacs developers, and +;; I hope it will be fixed in a future Emacs version. Until then, at +;; least you know... The more general lesson is this: Icicles can +;; turn every command into a multi-command, but multi-command actions +;; won't work for every command. +;; +;;(@* "Multi `M-x' Turns Every Command into a Multi-Command") +;; *** Multi `M-x' Turns Every Command into a Multi-Command *** +;; +;; Most of the time, of course, you do not execute commands +;; successively by name; instead, you use key bindings. The point +;; here is that even if you have a binding for a command, Icicles +;; `M-x' lets you use any command as a multi-command, which can +;; sometimes be advantageous. +;; +;; For example, Icicles defines and binds a real multi-command to +;; `C-x 0' in Icicle mode, which lets you delete any number of +;; windows. But, even without such a multi-command, you can get a +;; similar effect by using `M-x delete-windows-on'. In this way, you +;; can turn ordinary Emacs commands that use completion into +;; multi-commands. +;; +;; The other point is that you can move from one command to another +;; within the same execution of `M-x'. This is a different feature +;; from being able to use any command that uses completion as a +;; multi-command. Both features have their uses. +;; +;;(@* "Multi `M-x' with Abbreviations: `icicle-command-abbrev'") +;; ** Multi `M-x' with Abbreviations: `icicle-command-abbrev' ** +;; +;; The second multi-command that you can use in place of +;; `execute-extended-command' is `icicle-command-abbrev', bound in +;; Icicle mode to `C-x SPC'. It is similar to `M-x' +;; (`icicle-execute-extended-command'), with the added twist that it +;; lets you input command abbreviations, as well as commands. +;; +;; Emacs partial completion and some other libraries provide ways for +;; you to enter command abbreviations instead of command names at the +;; command prompt (`M-x'). Library `exec-abbrev-cmd.el' by Tassilo +;; Horn is an example. +;; +;; So just what is a command abbreviation? Hyphens (`-') in command +;; names divide them into parts. For example, `find-file' has two +;; parts: `find' and `file'. Each character of a command +;; abbreviation corresponds to one part of each of the commands that +;; match the abbreviation. For example, abbreviation `ff' matches +;; commands `find-file' and `focus-frame', and abbreviation `fg' +;; matches `find-grep'. +;; +;; If user option `icicle-command-abbrev-match-all-parts-flag' is +;; nil, then an abbreviation need not match all parts of a command +;; name; it need match only a prefix. For example, nil means that +;; abbreviation `ff' also matches `find-file-other-window' and `fg' +;; also matches `find-grep-dired'. +;; +;; In Icicles, you can input both abbreviations and commands at the +;; same prompt, and you can take advantage of the multi-command +;; feature to execute multiple commands. You can thus treat command +;; abbreviations just like commands. If an abbreviation matches a +;; single command name, then that command is invoked immediately. If +;; it matches more than one, then you can use completion to choose +;; one. +;; +;; One or more, that is - multi-command completion is available for +;; both abbreviations and commands. That is, you can invoke any +;; number of them within the same use of `C-x SPC'. +;; +;; What happens if your input matches a command name but it is also +;; an abbreviation for other command names? By default, command +;; names take precedence: if your input matches a command name then +;; that command is invoked. So, for example, by default the command +;; `cd' takes precedence over `cd' as an abbreviation for commands +;; such as `compile-defun' and `cancel-debug-on-entry'. If you +;; instead want abbreviations to take precedence over command names, +;; then set option `icicle-command-abbrev-priority-flag' to t. +;; +;; Abbreviations are completed against the (persistent) list of +;; abbreviations you have used in the past. That list is also +;; directly customizable as option `icicle-command-abbrev-alist'. +;; +;; Besides completing against past abbreviations, you can enter new +;; abbreviations (the completion is thus lax). When you exit Emacs, +;; your abbreviations list is updated and saved, along with the +;; number of times you've used each abbreviation. The latter +;; information is used to sort your abbreviations for completion, so +;; that those used most frequently are available first. + +;;(@* "Choose All Completion Candidates") +;; +;; Choose All Completion Candidates +;; -------------------------------- +;; +;; The previous section describes how you can use `C-RET' +;; (`icicle-candidate-action') to choose (act on) multiple completion +;; candidates, individually. If you hold down the Control key while +;; you cycle through the candidates, you can run through each of +;; them, one by one. +;; +;; Command `icicle-all-candidates-action', which is bound to `C-!' in +;; the minibuffer, is a shorthand way of doing that: act on all +;; candidates that match the current input. In many contexts, `C-!' +;; reports on any objects that were not acted upon successfully (in +;; buffer *Help*). +;; +;; All multi-commands let you use `C-!' in this way. Whenever a +;; command defines a special action for `C-RET' to perform on the +;; current completion candidate, you can use `C-!' to perform it on +;; all candidates at once. +;; +;; Perhaps you already use `% m' (command `dired-mark-files-regexp') +;; in Dired to mark all files that match a given regular expression, +;; and then operate on all of the marked files in some way (search +;; with `A', query-replace with `Q', open with `F', delete with `D', +;; and so on). When you execute a multi-command, `C-!' lets you do +;; something similar. +;; +;; How does it work? It applies `icicle-candidate-action-fn' to each +;; completion candidate that (apropos- or prefix-) matches the +;; current input in the minibuffer. +;; +;; Most top-level Icicles commands are multi-commands. Command +;; `icicle-delete-file' is an example. Instead of entering a file +;; name at the prompt (e.g. using completion or cycling), you can +;; type a regular expression, use `S-TAB' to see all matching files, +;; and then use `C-!' to delete all of them at once. +;; +;; You get the idea: Use the minibuffer to determine a set of objects +;; by pattern matching, and then act on all elements of the set. +;; +;; In addition to `C-!', keys `M-!', `C-|', and `M-|' act similarly: +;; +;; * `M-!' is like `C-!', but it acts on the list of matching +;; candidates as a whole, rather than acting individually on each +;; candidate. For example, with command `icicle-customize-face', +;; `M-!' opens a single Customize buffer for all of the matching +;; faces, while `C-!' opens a separate Customize buffer for each +;; face. +;; +;; * `C-|' and `M-|' are like `C-!' and `M-!', respectively, but they +;; apply an alternative action, not the main action, whenever one +;; is available. +;; +;; In the definition of a given multi-command, the appropriate action +;; functions are bound to variables: +;; +;; * `icicle-candidate-action-fn' (`C-!') - normal single-candidate +;; action +;; +;; * `icicle-candidate-alt-action-fn' (`C-|') - alternative +;; single-candidate action +;; +;; * `icicle-all-candidates-list-action-fn' (`M-!') - normal +;; list-of-candidates action +;; +;; * `icicle-all-candidates-list-alt-action-fn' (`M-|') - alternative +;; list-of-candidates action +;; +;; For most multi-commands, however, only the normal single-candidate +;; action is defined. In this case, `M-!' duplicates what `C-!' +;; does. If the corresponding function is not available, each of the +;; list-action keys (`M-!', `M-|') behaves the same as the +;; corresponding single-candidate key (`C-!', `C-|), and vice versa. +;; So for instance, if `icicle-all-candidates-list-action-fn' is nil +;; when reading some input, then `M-!' acts the same as `C-!'. +;; +;; As a shortcut, if you have saved completion candidates and they +;; all belong to the current set of completion candidates, then `C-!' +;; acts on the saved candidates instead of the complete set of +;; candidates. This means that you need not first do `C-M-<' to +;; retrieve the saved candidates; you can do `C-!' directly to act on +;; them. `C-|', `M-!', and `M-|' work the same way. +;; +;; All of the all-candidates actions inhibit candidate help display +;; in the mode line and minibuffer messages that the individual +;; actions might effect. This is to avoid unnecessary delays. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Dired Enhancements") +;; for an Icicles alternative to both `A' and `Q' (search and +;; replace) in Dired. + +;;(@* "Sets of Completion Candidates") +;; +;; Sets of Completion Candidates +;; ----------------------------- +;; +;; Whereas `C-RET' acts on individual objects, `C-!' acts on an +;; entire set of objects at once, via their names: the set of all +;; current completion candidates. There are additional Icicles +;; commands that also act, not on individual completion candidates, +;; but on one or more sets of completion candidates. +;; +;; One of these is `M-*', which effectively narrows the set of +;; completion candidates by taking the intersection of the candidate +;; sets defined by various input regexps. +;; +;; This section presents some more Icicles commands that act on sets +;; of completion candidates. The basic idea is that you can perform +;; set operations using the current set of completion candidates, +;; changing it into a different set. You can, then, for example, use +;; `C-!' to act on everything in a custom-defined set. Or you can +;; define a custom set that you want to use often (for example, a +;; list of project files), save it persistently, and then retrieve it +;; later to use for completion. +;; +;;(@* "Saving and Retrieving Completion Candidates") +;; ** Saving and Retrieving Completion Candidates ** +;; +;; Set operations such as union and difference act on two sets. The +;; current set of completion candidates is always one of these sets. +;; If an operation, such as set complement, acts on a single set, +;; then it acts on the current set. +;; +;; When two sets are involved, the other set is called the "saved +;; set". This just means that at some previous time in your sesssion +;; you saved some completion candidates as the value of variable +;; `icicle-saved-completion-candidates'. +;; +;; In buffer `*Completions*', candidates that have been saved are +;; highlighted using face `icicle-saved-candidate'. +;; +;; By default, the saved set is not persistent; it is saved only +;; until the next save in the same Emacs session overwrites it or +;; adds to it. See (@> "Persistent Sets of Completion Candidates") +;; for ways to save candidates persistently. +;; +;; One way you can save candidates is to use +;; `icicle-candidate-set-save', bound to `C-M->'. This saves all of +;; the current candidates. +;; +;; Gotcha: If you use progressive completion and you have not yet +;; typed anything after `M-*' or `S-SPC', then there is not +;; yet a set of candidates to save. If you use `C-M->' at +;; that point, you will reset the saved candidates to none. +;; To define the current candidates, either type something or +;; use `S-TAB'. +;; +;; Another way to save candidates, besides `C-M->', is to select +;; candidates in buffer `*Completions*' using the (active) region, +;; and then use `icicle-candidate-set-save-selected', bound to +;; `C-M-)'. This saves any candidates that are at least partially in +;; the region. +;; +;; You can also use `C-M-)' to UNsave all candidates: just select no +;; candidates before you hit `C-M-)', to reset the set of saved +;; completions to none. Think of this as replacing the saved set +;; with the empty set (no candidates). And you need not use `TAB' or +;; `S-TAB' first to use this, since the current set of candidates is +;; not used in any way when you reset the saved set. +;; +;; Command `icicle-mouse-candidate-set-save', bound to `M-S-mouse-3' +;; in `*Completions*' combines these two: if the region is active, +;; then the selected candidates become the saved set; otherwise, all +;; candidates are saved. This binding makes it easy to save +;; candidates using the mouse: select them (e.g. drag or double-click +;; `mouse-1', or click `mouse-1' then `mouse-3'), then use +;; `M-S-mouse-3' to save. +;; +;; You can process the list of saved candidates in any way you like +;; using Emacs Lisp. For example, you can save a list of file names +;; that match a regexp, then print the list or process the individual +;; files in some way. Here, for instance, is how to save the set of +;; file names that contain either `dir' or `ici': +;; +;; `C-x C-f \(dir\|ici\) S-TAB C-M-> C-g' +;; +;; You can retrieve a set of saved candidates with command +;; `icicle-candidate-set-retrieve', bound to `C-M-<'. This replaces +;; the current set of candidates with those retrieved. It also acts +;; like `M-*' by entering a recursive minibuffer, which removes any +;; saved-candidates highlighting. Using `TAB' or `S-TAB' restores +;; the highlighting. +;; +;; You can use `C-<' to retrieve a set of saved candidates and add +;; them to the current candidates, instead of replacing those +;; candidates. This way, you can build up the current set of +;; candidates by retrieving (combining) several saved sets. +;; +;; In the other direction, you can save additional candidates, adding +;; them to a set of candidates already saved, in these ways: +;; +;; * `C->' (`icicle-candidate-set-save-more') adds all of the current +;; candidates. +;; +;; * `C-)' (`icicle-candidate-set-save-more-selected') adds any +;; candidates that you have selected using the region in +;; `*Completions*'. +;; +;; * `M-mouse-3' (`icicle-mouse-candidate-set-save-more') acts the +;; same as `C-)' or `C->', depending on whether or not the region +;; is active in `*Completions*': it adds selected or all +;; candidates. +;; +;; * Extending the region with `mouse-3', and then clicking `mouse-3' +;; again in the same place, acts the same as `C-)'. That is, click +;; `mouse-1', then click `mouse-3' twice in another location, to +;; save all candidates between the `mouse-1' and `mouse-3' +;; positions. +;; +;; * The `insert' key (`icicle-save/unsave-candidate') adds just the +;; current completion candidate (e.g. during cycling). Clicking a +;; candidate in `*Completions*' with `M-S-mouse-2' +;; (`icicle-mouse-save/unsave-candidate') does the same thing. If +;; you do this to a candidate that has already been saved, then it +;; is UNsaved (no longer saved). +;; +;; Note that the `insert' key and `M-S-mouse-2' are toggles for a +;; given candidate, saving or unsaving it. In this sense each is its +;; own opposite. In another sense, the opposite operation of saving +;; is simply removing a candidate from the current set of candidates. +;; You do that using the `delete' key or `S-mouse-2'. +;; +;; Matching, saving, and retrieving candidates is a powerful way to +;; interact with completion. One important use is to prepare a list +;; of candidates on which to act, and then act on them all at once +;; using `C-!'. This is a good way to proceed when you want to +;; double-check what to act on, before you actually act. This is the +;; same idea behind marking files in Dired and then operating on the +;; marked files, using `x'. It corresponds to what is represented in +;; some user interfaces by filling out a checklist followed by +;; clicking `OK'. +;; +;;(@* "Different Places for Saving and Retrieving Candidates") +;; ** Different Places for Saving and Retrieving Candidates ** +;; +;; You can save completion candidates to a different variable from +;; `icicle-saved-completion-candidates' by using a numeric prefix +;; argument to command `icicle-candidate-set-save'; that is, use `C-u +;; N C-M->'. Alternatively, use `C-M-}', which is bound to command +;; `icicle-candidate-set-save-to-variable'. You are prompted for the +;; name of the variable, and you can use completion when inputting +;; it. During this completion, the only available candidates are +;; variables that you have used for saved candidates (but completion +;; is lax, so you can type a new variable name). The same behavior +;; works also for `C->', `C-M-)', and `C-)'. +;; +;; To retrieve completion candidates that were previously saved to a +;; variable other than `icicle-saved-completion-candidates', so that +;; they become the current set of candidates, use `C-u N C-M-<', +;; where N is an integer, or `C-M-{' (`icicle-candidate-set-retrieve' +;; or `icicle-candidate-set-retrieve-from-variable'). +;; +;; Using a plain prefix argument (`C-u' without a number) with +;; `C-M->' and `C-M-<' saves or retrieves a candidate set using a +;; cache file, not a variable. Alternatively, as a shortcut you can +;; use `C-}' and `C-{' for this. +;; See (@> "Persistent Sets of Completion Candidates") and +;; (@file :file-name "icicles-doc2.el" :to "Support for Projects"). +;; +;; When you save candidates to a different variable from +;; `icicle-saved-completion-candidates', they are not shown in buffer +;; `*Completions*' using face `icicle-saved-candidate'. When you +;; save candidates to a cache file, they are also saved to +;; `icicle-saved-completion-candidates', so they are shown in +;; `*Completions*' using face `icicle-saved-candidate'. +;; +;; `C->' and `C-<' accept the same prefix arguments as `C-M->' and +;; `C-M-<' , letting you specify the source or destination (variable, +;; cache file) when you save or retrieve additional candidates. +;; +;;(@* "Set Operations") +;; ** Set Operations ** +;; +;; The other available set-operation commands for use with completion +;; candidates, besides saving and retrieving, are these: +;; +;; * `icicle-candidate-set-swap', bound to `C-%'. Swap the saved and +;; current sets of completion candidates. +;; +;; * `icicle-candidate-set-define', bound to `C-:'. Define the +;; current set of completion candidates by evaluating an input +;; sexp. The sexp must evaluate to a list of strings, such as is +;; returned by `all-completions'. You can use this to substitute +;; any list of strings, and then operate on them as completions, +;; using any Icicles functionalities. Keep in mind, however, that +;; the completions must be of the proper type for the context in +;; which they are used. For example, if you are executing a +;; command, they must be command names. +;; +;; * `icicle-candidate-set-complement', bound to `C-~'. Complement +;; the current set of candidates: replace the current candidate set +;; with its set complement. This means all possible completions of +;; the appropriate type that do *not* match the current input. You +;; can combine this with progressive completion (`M-*') to +;; progressively eliminate candidates that match different inputs. +;; This process-of-elimination matching is a common Icicles usage +;; idiom. +;; +;; * `icicle-candidate-set-union', bound to `C-+'. Replace the +;; current candidate set by its union with the saved set of +;; candidates. +;; +;; * `icicle-candidate-set-difference', bound to `C--'. Replace the +;; current candidate set by its set difference with the saved set +;; of candidates. That is, the saved candidates are subtracted +;; from the current candidates, and the result becomes the current +;; candidate set. To obtain the opposite set difference, +;; subtracting the current candidates from the saved candidates, +;; just use `icicle-candidate-set-swap' followed by +;; `icicle-candidate-set-difference'. +;; +;; * `icicle-candidate-set-intersection', bound to `C-*'. Replace +;; the current candidate set by its intersection with the saved set +;; of candidates. Unlike the set intersection provided by `M-*', +;; `C-*' is, in itself, a one-time operation. `M-*' can be +;; repeated, using the previous intersection as one of the sets to +;; be intersected in a new operation. Both `C-*' and `M-*' use the +;; current set of matching candidates as one of the sets being +;; intersected. But `M-*' reads another input regexp to define the +;; other set to be intersected, whereas `C-*' uses the saved +;; candidates set as the other set. `M-*' is useful for chaining, +;; to achieve progressive approximation. `C-*' is useful to +;; perform an intersection on a set from a previous input reading. +;; +;; * `icicle-candidate-set-truncate', bound to `M-$'. Truncate the +;; set of completion candidates, so that it includes only the first +;; N candidates (as displayed in `*Completions*'). You are +;; prompted for N. You can use this when the order of candidates +;; represents priority in some way, so that you are interested only +;; in the topmost candidates. +;; +;; You can operate on or choose from all input values in the set that +;; results from any of these set operations. For example, you can +;; use `C-~' to see the list of objects that do not match the current +;; input, to cycle among those objects, or to operate on any or all +;; of them. Use `C-~' at any time to switch to the complement of the +;; current set of candidates. +;; +;; Example: To cycle through all files whose names do not end in +;; `el', you can do the following: +;; +;; 1. Use `C-f' to read a file name. +;; 2. Type `el$' to match all file names that end in `el'. +;; 3. Use `S-TAB' to show the matching files. +;; 4. Use `C-~' to flip to the complement: files not ending in `el'. +;; 5. Use `next' or `prior' to cycle among the new set of candidates. +;; +;; A minibuffer message briefly confirms each of the set operations. +;; +;; When buffer `*Completions*' is displayed, the union, difference, +;; and intersection commands scroll the buffer when repeated. +;; Repeating `icicle-candidate-set-complement' complements the +;; complement, of course, giving the original set. +;; +;; Once you have established a set of completion candidates using any +;; of the candidate-set commands, you can cycle among the candidates +;; of that set using either prefix or apropos cycling (that is, +;; `next'/`prior' or `down'/`up'). However, switching from prefix to +;; apropos cycling (or completion), or vice versa, establishes a new +;; completion set of the appropriate type, as usual. Switching +;; completion type signifies that you are finished with the specially +;; defined completion set, and you want to redefine it using apropos +;; or prefix cycling or completion. +;; +;; Note: Prefix icompletion (`icomplete.el' or `icomplete+.el' - see +;; (@> "Icompletion")) does not take into account the candidate +;; set resulting from a set operation: it always displays the +;; normal set of prefix completions in the minibuffer. +;; +;; Note: You might have noticed that, as a mnemonic device, the keys +;; bound to the various set operations use the corresponding +;; binary arithmetic or Boolean operators: `~' (unary negation) +;; for complement (not); `*' (multiplication) for intersection +;; (and); `+' (addition) for union (or); and `-' (subtraction) +;; for difference. Note too that the `C--' and `C-+' bindings +;; mean that you cannot use these key sequences for prefix +;; arguments - you must use `C-u N', or `M-N' instead, where N +;; is a possibly signed integer. +;; +;; See Also: +;; +;; * (@> "Multi-Commands") for information about `C-RET'. +;; +;; * (@> "Choose All Completion Candidates") for information about +;; `C-!'. +;; +;; * (@> "Progressive Completion") for information about `M-*'. +;; +;; * (@> "File-Name Input and Locating Files Anywhere") and +;; (@> "Persistent Sets of Completion Candidates"), for information +;; about saving completion candidates persistently and retrieving +;; them later. +;; +;; * (@> "History Enhancements"), (@> "Google Matching"), and +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview") +;; for examples of other set operations on input candidates. +;; +;; * (@file :file-name "icicles-doc2.el" :to "Icicles Dired Enhancements") +;; for information about saving and reusing sets of file-name +;; candidates with Dired. + +;;(@* "Google Matching") +;; +;; Google Matching +;; --------------- +;; +;; This section presents nothing new - but you might not want to skip +;; it. It points out something that you might not have picked up +;; yet. You've learned about Icicles regexp matching and candidate +;; set operations, but it can be worthwhile to compare how Icicles +;; matches inputs against completion candidates with how Google +;; matches search strings against Web pages. Summary: You can do +;; pretty much the same things, but the way you accomplish them is +;; different. +;; +;;(@* "Domain of Discourse") +;; ** Domain of Discourse ** +;; +;; In Google, the domain of discourse, that is, the possible set of +;; search hits, is the set of Web pages. There are also search +;; fields that limit the domain of discourse by file type, page +;; number, update date, page position, freedom of use, and even +;; morality ("Safe Search"). +;; +;; In Icicles (Emacs), the domain of discourse changes automatically, +;; depending on the current context. For command-name input, it is +;; the set of all named commands; for variable-name input, it is the +;; set of variable names; and so on. +;; +;;(@* "Global Filtering") +;; ** Global Filtering ** +;; +;; In Google, you can limit searching to specific Web sites, or +;; exclude certain Web sites from searching. +;; +;; In Icicles, you can add extra completion candidates, using +;; variable `icicle-extra-candidates', and you can filter out (other) +;; candidates globally, using filter variables +;; `icicle-must-match-regexp', `icicle-must-not-match-regexp', and +;; `icicle-must-pass-predicate'. These are internal Icicles +;; variables. Normally, you do not change them directly; instead, a +;; command can use them to limit or extend the effective domain of +;; discourse. +;; See (@file :file-name "icicles-doc2.el" :to "Global Filters"). +;; +;; Variable `icicle-must-pass-predicate' applies to the textual +;; candidates that are displayed in buffer `*Completions*'. You can +;; also apply a predicate to the full alist-entry candidates that are +;; supplied to `completing-read' or `read-file-name'. As a +;; programmer, you can of course do that when your code calls these +;; functions. As an Icicles user, you can use `M-&' to define and +;; apply predicates to such alist-entry candidates on the fly, while +;; completing. See +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview"). +;; +;;(@* "Word Matching and String Matching") +;; ** Word Matching and String Matching ** +;; +;; Google matches words, by default, but you can specify an "exact +;; phrase" to get literal string matching. +;; +;; By default, Icicles (apropos-)matches regexps, but you can use +;; `\b' in a regexp to perform word matching, and you can use `C-`' +;; (`icicle-toggle-regexp-quote') to perform exact (literal) +;; matching. See (@> "What About Special-Character Conflicts?"). +;; +;;(@* "AND Matching and OR Matching") +;; ** AND Matching and OR Matching ** +;; +;; Google has search fields for AND matching ("with all of the +;; words") and OR matching ("with at least one of the words"). +;; +;; In Icicles, you can use progressive completion to perform AND +;; matching: use `M-*' to introduce each term to match. +;; Alternatively, you can use `C-*' +;; (`icicle-candidate-set-intersection'). You can use `C-+' +;; (`icicle-candidate-set-union') to perform OR matching. Note that, +;; by definition, unordered AND matching is not possible using a +;; single regexp. See (@> "Progressive Completion") and +;; (@> "Sets of Completion Candidates"). +;; +;;(@* "NOT Matching") +;; ** NOT Matching ** +;; +;; Google has a search field for terms that must not occur in search +;; hits: "without the words". +;; +;; In Icicles, you can use `C-~' (`icicle-candidate-set-complement') +;; to exclude matching completion candidates. You can combine this +;; with progressive completion, to exclude any number of terms: `toto +;; C-~ M-* titi C-~ M-* foobar' excludes all candidates matching +;; toto, titi, or foobar. Use this process-of-eliminiation technique +;; to progressively pare down the set of possible candidates. Note +;; that such generalized complementing (as opposed to complementing a +;; character set) is not possible using a single regexp - you cannot +;; use a regular expression to say "Show me everything that does +;; *not* match this". See (@> "Sets of Completion Candidates") and +;; (@> "Progressive Completion"). + +;;(@* "File-Name Input and Locating Files Anywhere") +;; +;; File-Name Input and Locating Files Anywhere +;; ------------------------------------------- +;; +;; Emacs offers two main functions for reading minibuffer input with +;; completion: `completing-read' and `read-file-name'. Icicles uses +;; both of these, and it enhances each of them in various ways for +;; use in your own Emacs-Lisp code. These two functions can each be +;; used to read file-name input, but they do so in very different +;; ways. +;; +;; In addition to the usual Icicles key bindings, during file-name +;; completion you can use the following keys: +;; +;; * `C-backspace' (`icicle-up-directory') to navigate up the +;; directory hierarchy. It removes the last directory component +;; (and any partial file name) from your minibuffer input. +;; +;; (For Emacs versions before Emacs 22, this feature is available +;; only for completion of absolute file names.) +;; +;; * `C-c +' (`icicle-make-directory') to create a directory on the +;; fly. +;; +;; * `C-x m' (`icicle-bookmark-file-other-window') to visit a +;; bookmarked file or directory. This is available only if you use +;; library `bookmark+.el'. It is a multi-command, so you can +;; actually visit any number of file bookmarks. When finished, you +;; can continue with non-bookmark file-name completion. +;; +;; * `S-delete' to delete the file named by the current completion +;; candidate. +;; +;; * `M-|' (`icicle-all-candidates-list-alt-action') to open Dired on +;; the currently matching file names. That is, it opens a special +;; Dired buffer that contains only the matching files. You are +;; prompted for the Dired buffer name. See (@> "Alternative +;; Actions"). +;; +;; Note: Whether a command supports file-name globbing wildcards such +;; as `*' is independent of whether it uses `read-file-name' or +;; `completing-read'. It is the command itself that offers such +;; support or not. Globbing takes place only after the file name +;; (with wildcards) is read. All Icicles commands that visit files +;; (all of the commands mentioned in this section) let you use +;; globbing wildcards. Remember also that file-name globbing, with +;; its special wildcards, has nothing to do with regexp completion +;; matching. See (@> "What About Special-Character Conflicts?") for +;; more information about file-name globbing. +;; +;;(@* "Function `read-file-name'") +;; ** Function `read-file-name' ** +;; +;; Function `read-file-name' is specialized for file-name input with +;; completion. It knows about files and file names for your current +;; platform. It knows about Emacs remote file name syntax (Tramp, +;; Ange FTP). And starting with Emacs 23, `TAB' also completes +;; environment variables during `read-file-name' completion. +;; +;; Using `read-file-name' is the most flexible way to read a file +;; name in Emacs, and it is the traditional way. Unless stated +;; otherwise, "file-name completion", even in the Icicles doc, refers +;; to `read-file-name' completion. +;; +;; When `read-file-name' reads input, only the file name itself, not +;; the directory portion, is used for matching. The directory is +;; understood to be the value of variable `default-directory' (which +;; you can change using command `cd', for instance). The behavior is +;; thus the same whether or not the directory name is present in the +;; minibuffer. If you prefer, you can delete the directory name +;; first, using `M-k'. +;; +;; With `read-file-name', you can thus use apropos completion to +;; match a file-name substring, without needing to prefix the +;; substring with `.*' in the minibuffer. For example, to match the +;; file named `favorite-foo-file.bar' in directory +;; `/some/path/to/my/', you need not use `/some/path/to/my/.*foo'; it +;; is sufficient to use either `foo' or `/some/path/to/my/foo'. +;; +;; An additional feature of `read-file-name' in Icicle mode is that +;; candidates that are directory names are highlighted in buffer +;; `*Completions*' using face `icicle-special-candidate'. +;; +;;(@* "Function `completing-read'") +;; ** Function `completing-read' ** +;; +;; Function `completing-read' is a general function for reading input +;; with completion. It is not specially designed for reading file +;; names. It knows nothing about files and file names. It knows +;; nothing about remote file-name syntax. When `completing-read' +;; reads input, it makes no use of `default-directory'. The +;; completion candidates are treated as simple strings; they are not +;; really treated as file names. +;; +;; Icicles commands that use `completing-read' to read a file name +;; typically read an absolute name, that is, a name that includes the +;; directory portion. This means that you can match against any part +;; of the full name, including any directory components. The +;; directory portions of the candidate file names need not be the +;; same - you can thus complete against a set of files in multiple +;; directories. +;; +;;(@* "Icicles Commands that Read File Names") +;; ** Icicles Commands that Read File Names ** +;; +;; Icicles commands that use `read-file-name' include all +;; multi-commands, such as `icicle-find-file', that are defined using +;; `icicle-define-file-command'. Vanilla Emacs command `find-file' +;; is another example of a command that uses `read-file-name'. +;; +;; Icicles commands that use `completing-read' to read file names +;; include the multi-commands `icicle-find-file-absolute', +;; `icicle-find-file-in-tags-table', `icicle-recent-file', +;; `icicle-locate-file', and `icicle-locate-file-no-symlinks'. These +;; are defined using `icicle-define-command', not +;; `icicle-define-file-command'. +;; +;; There are also `-other-window' versions of all of the Icicles +;; commands that read file names. +;; +;; The Icicles commands that use `completing-read' to read file names +;; have an additional feature: you can use a prefix argument to tell +;; them to combine the last modification date with the file name, as +;; a multi-completion - see +;; (@file :file-name "icicles-doc2.el" :to "Multi-Completions"). +;; This means that you can easily look up files whose modification +;; time or date matches some (regexp) criterion, such as being +;; sometime in July 2008. +;; +;; When using a command that reads an absolute file name, remember +;; that, to save space, you can use `C-x .' to toggle hiding of the +;; common match portions of the candidates in `*Completions*'. This +;; portion is often a long directory substring. +;; +;; Command `icicle-file' is bound, by default, to `C-x C-f' in Icicle +;; mode, thus taking the place of `find-file'. It combines +;; `icicle-find-file' and `icicle-find-file-absolute'. With no +;; prefix argument, it matches relative file names; with a prefix +;; argument, it matches absolute names (as ordinary strings). With a +;; negative prefix argument, you can match also the modification +;; date. +;; +;; An additional feature of `icicle-find-file-absolute' and +;; `icicle-find-file-absolute-other-window' is that candidates that +;; are directory names are highlighted in buffer `*Completions*' +;; using face `icicle-special-candidate'. +;; +;; Commands `icicle-find-file-in-tags-table' and +;; `icicle-find-file-in-tags-table-other-window' let you visit files +;; that are listed in the current tags table. You can think of these +;; potential completion candidates as all of the files in a project +;; defined by the tags table. +;; +;; You can use `icicle-recent-file' to open any file that you have +;; visited recently, perhaps in a previous Emacs session. +;; +;; You can use `icicle-locate-file' to find a file when you do not +;; know what directory it is in. It looks throughout a given +;; directory, including throughout all of its subdirectories. +;; Command `icicle-locate-file-no-symlinks' is the same, except that +;; it does not follow symbolic links. Both of these locate commands +;; respect option `icicle-ignored-directories', which is a list of +;; directories to ignore - by default, version-control directories. +;; +;; By default, the target directory for `icicle-locate-file' is the +;; current directory, but if you supply a non-negative numeric prefix +;; argument (non-positive means include the date), then you are +;; prompted for the directory to search. If you use the root of your +;; file system as the search directory, then the locate-file commands +;; will match completion candidates anywhere in your file system. +;; +;; This can be quite useful. It gives you much of the power of the +;; Unix `find' command just for completing input! And with +;; incremental completion (see (@> "Icompletion")), you can see what +;; matches your input as you type. +;; +;; Obviously, if you use your entire file system as the set of +;; completion candidates, then gathering and matching such a large +;; set of file names can take some time. On my hard drive, for +;; instance, there are 36 GB full of files, and it takes about 40 +;; seconds to gather all of the file names. In spite of this +;; inconvenience, this functionality can be useful. And of course +;; searching a shallower directory tree presents less of a +;; performance penalty - you pay for what you get. +;; +;; There is a way, however, of having your cake and eating it too. +;; You can gather all of the file names in your file system once, and +;; save that list of completion candidates to a cache file on disk, +;; as a snapshot. +;; See (@> "Persistent Sets of Completion Candidates"), for how to do +;; this. +;; +;;(@* "Absolute File Names and Different Directories") +;; ** Absolute File Names and Different Directories ** +;; +;; Since `completing-read' has no understanding of file-name syntax, +;; including remote file-name syntax, `icicle-find-file-absolute' +;; (`C-u C-x C-f') and similar commands are similarly ignorant. (You +;; can nevertheless use `C-.' with these Icicles commands, to toggle +;; respect of `completion-ignored-extensions'.) In particular, these +;; commands will not let you complete to a remote file name if the +;; current directory is local. They also will not let you complete +;; to a file name in a different local directory. +;; +;; Because all Icicles commands that read file names use lax +;; completion, you can nevertheless visit a file in a different +;; directory (remote or local) from the current one, even though you +;; cannot complete your input to such a name. That is, you can +;; always use `RET' with any file name as minibuffer input. +;; +;; So how can you complete your input to an absolute file-name in a +;; different directory? By retrieving a saved candidate set that has +;; such absolute names and then completing against that set. For +;; example, you can retrieve a set that represents files on a remote +;; machine and complete to their names even from a local directory. +;; All that counts for `completing-read' is that your input can match +;; candidates, where that matching is ordinary (apropos or prefix) +;; string matching. +;; +;; To create such a saved set of names, you can visit the directory +;; (perhaps remote) that contains the files and then use `C-u C-x +;; C-f' and `C-}' to save the candidates. You can later retrieve +;; this saved set for completion, no matter what the current +;; directory is. As another example, you can use +;; `icicle-locate-file' in a remote directory to create a saved set +;; that includes remote files that are all somewhere under that +;; remote directory. +;; +;; In addition, you can add more file names to an existing saved set +;; using `C->', `C-)', `M-mouse-3', `insert', or `M-S-mouse-2' - see +;; (@> "Sets of Completion Candidates"). The added names can come +;; from a different directory than files already in the saved set. In +;; this way, you can build up a saved set that includes files from +;; any directories, some of which can be local and some remote, some +;; remote from one host, some remote from another, and so on. You can +;; create a saved set with any mix of absolute file names from any +;; locations. +;; +;; Remember this: +;; +;; * To create and add to a saved set of absolute file names, use a +;; command that expects absolute file names, and do this from the +;; directory that contains the files you want to add. +;; +;; * When you retrieve a saved set of file-name candidates for +;; completion, use a command that expects the same kind of file +;; names, relative or absolute, as the saved names. For example, +;; if you save a set of project files that are spread over +;; different directories (and hence are absolute), then retrieve +;; that candidate set using, say, `C-u C-x C-f' (absolute), not +;; `C-x C-f' (relative). +;; +;; Finally, although the commands that read absolute file names are +;; essentially ignorant of directory hierarchies and of file names as +;; such, so that they treat their candidates only as simple strings, +;; a few of these commands nevertheless define their domain of +;; possible file-name candidates relative to some starting directory. +;; +;; This is the case for `icicle-find-file-absolute' and +;; `icicle-locate-file' (and their variants). For these commands, +;; you can use `C-c C-d' (think UNIX command `cd') during completion +;; to change the current working directory (`default-directory') on +;; the fly. You are prompted for the directory. The domain of +;; possible candidates is recomputed relative to the new +;; `default-directory'. +;; +;; Use `C-c C-d' this way as many times as you like. You can use +;; this feature to add file names from different directories to a +;; saved set of candidates. When the command is finished, the +;; original `default-directory' is restored. +;; +;; See Also: +;; +;; * (@> "Persistent Sets of Completion Candidates") for information +;; about saving a set of file names persistently +;; * (@> "Sets of Completion Candidates") for information about +;; creating, saving, and retrieving sets of file names +;; * (@> "Dealing With Large Candidate Sets") for ways to deal with a +;; large number of candidates +;; * (@file :file-name "icicles-doc2.el" :to "Multi-Completions") +;; * (@file :file-name "icicles-doc2.el" :to "Support for Projects") +;; for more about `icicle-find-file-in-tags-table' + +;;(@* "Persistent Sets of Completion Candidates") +;; +;; Persistent Sets of Completion Candidates +;; ---------------------------------------- +;; +;; Section (@> "Sets of Completion Candidates") describes how you can +;; save the current set of completion candidates and reuse it later. +;; This is not a persistent save, however; the candidates are simply +;; saved in variable `icicle-saved-completion-candidates' for the +;; duration of your Emacs session (or until you save candidates +;; again). +;; +;; You can save the current set of completions (whatever it is) +;; persistently by supplying a plain prefix argument (`C-u') when you +;; use `C-M->' (`icicle-candidate-set-save') during completion. +;; Alternatively, you can use `C-}', bound to +;; `icicle-candidate-set-save-persistently', which does the same +;; thing. To retrieve completion candidates that were previously +;; saved to a cache file, so that they become the current set of +;; candidates, use either `C-u C-M-<' or `C-{' +;; (`icicle-candidate-set-retrieve' or +;; `icicle-candidate-set-retrieve-persistent'). +;; +;; Tip: Suppose you have already saved a set of candidates, but not +;; persistently, and you now want to write this saved set to a +;; cache file. Use `C-M-<' followed by `TAB' or `S-TAB', +;; followed by `C-}'. That is, retrieve the saved candidates +;; and then save the retrieved candidates persistently. (You +;; use `TAB' or `S-TAB' because retrieval opens a recursive +;; minibuffer.) +;; +;; Note that using a numeric prefix argument (`C-u' with a number) +;; with `C-M->' and `C-M-<' saves or retrieves a +;; completion-candidates set using a variable that you name, not a +;; cache file. See (@> "Sets of Completion Candidates"). +;; +;;(@* "Saving Candidates in Cache Files") +;; ** Saving Candidates in Cache Files ** +;; +;; If you have used the Emacs file-name cache (see the Emacs manual, +;; node "File Name Cache"), then you have already used a cache file +;; of (file-name) completion candidates. In vanilla Emacs, you use +;; `C-TAB' during file-name input to complete to a cached file name. +;; In Icicles, you use `C-{'. +;; +;; In Icicles, the cached candidates are not limited to file names, +;; and you can have any number of cache files, to save different sets +;; of completion candidates. Each cache file saves the set of +;; candidates that was current when you created (saved) the set. +;; +;; The fact that a cache file can contain just those candidates that +;; were current when you saved it is a considerable advantage, when +;; combined with Icicles features for sculpting the current set of +;; matching candidates. As far as I know, Icicles is the only +;; package to offer this feature. You spend a few moments to +;; fine-tune a set of candidates, using, for example, `M-*', `C-~', +;; and `delete', and then save it for later use. From then on, you +;; can match against exactly those candidates anytime you want. +;; +;; For example, you might have a software project that involves only +;; certain directories and perhaps only certain kinds of files in +;; those directories are of interest as completion candidates. Those +;; directories and files can even be in disparate locations. +;; +;; Start with command `icicle-locate-file' (or +;; `icicle-locate-file-no-symlinks'). Then use progressive +;; completion to match the directories and files you want and chip +;; away at those you don't want. Once you get just the set you need +;; for your project, save that set using `C-}'. You can have any +;; number of saved sets, for different projects or different purposes +;; in the same project. +;; +;; You name the sets of saved candidates, and these names are +;; associated with the cache files in user option +;; `icicle-saved-completion-sets'. This is an alist of entries, each +;; of which is of the form (SET-NAME . CACHE-FILE-NAME). You can +;; customize this option, or set it in your init file (~/.emacs). +;; +;; You can use command `icicle-add/update-saved-completion-set' to +;; add a new set to `icicle-saved-completion-sets' or update +;; (replace) an existing such set. You can use command +;; `icicle-remove-saved-completion-set' to remove a saved set. +;; +;; As an alternative to customizing `icicle-saved-completion-sets' or +;; using command `icicle-add/update-saved-completion-set', you can +;; simply try to save a set of completion candidates persistently, +;; using `C-u C-M->' or `C-}'. You are then prompted for the names +;; of the candidate set and cache file to use, and the names you +;; enter are automatically entered in option +;; `icicle-saved-completion-sets'. That option is automatically +;; saved to your custom file, so the next time you use Emacs you can +;; retrieve any saved set of candidates that you like. +;; +;; When you try to retrieve a persistent set of completion +;; candidates, you are similarly prompted for the candidate-set name +;; and the cache-file name. +;; +;; In addition to saving the current set of completion candidates to +;; a cache file, you can add individual strings as future completion +;; candidates to any cache file, and you can remove candidates from a +;; cache file individually. You do this using commands +;; `icicle-add-entry-to-saved-completion-set' and +;; `icicle-remove-entry-from-saved-completion-set'. +;; +;; Adding an individual candidate is similar to using the Emacs +;; file-name cache commands that add file names to the cache, but it +;; adds only a single candidate. For file names, adding a directory +;; name effectively provides completion for all of its files as well, +;; so there is no need to add each file name as well as the directory +;; name. Alternatively, you can always use `C-}' to add all file +;; names that match your current input. +;; +;;(@* "Filesets and Icicles Saved Completion Sets") +;; ** Filesets and Icicles Saved Completion Sets ** +;; +;; Starting with release 22, GNU Emacs includes a filesets feature +;; that lets you create named sets of file names, called "filesets". +;; It is a powerful feature, letting you define such sets by +;; intension, using regexp patterns, as well as by extension, listing +;; file names explicitly. You can easily use a fileset to define a +;; project of files. +;; +;; Icicles lets you use an Emacs fileset any time you can use an +;; Icicles saved completion set, provided that option +;; `icicle-filesets-as-saved-completion-sets-flag' is non-nil. +;; +;; That is, you can retrieve fileset file names as the current set of +;; completion candidates or save the current completion candidates to +;; a fileset. Provided +;; `icicle-filesets-as-saved-completion-sets-flag' is non-nil, you +;; can always choose a fileset as the set to retrieve. To save to a +;; fileset, use a prefix arg with `C-}' or a zero prefix arg with +;; `C-M->'. Saving candidates to a fileset gives you an alternative +;; to customizing option `filesets-data'. +;; +;; Being able to use an Emacs fileset in place of an Icicles saved +;; set lets you use filesets in additional ways. For example, it +;; lets you open Dired on only the files in a fileset, for easy +;; manipulation of the member files. Conversely, you can save all of +;; the marked files in a Dired buffer as a fileset. See +;; (@file :file-name "icicles-doc2.el" :to "Icicles Dired Enhancements"). +;; +;; Beyond letting you use a fileset in place of a persistent Icicles +;; saved completion set, you can include filesets in such saved +;; Icicles sets. That is, you can save one or more filesets of any +;; kind (`:files', `:tree', etc.) in an Icicles persistent saved set +;; (cache file). When you then retrieve such a saved set, all of the +;; file names specified by all of the included filesets become +;; completion candidates. +;; +;; For example, this could be a saved Icicles set that combines a +;; `:tree' fileset with an explicit `:files' fileset and with two +;; additional files: +;; +;; ((:fileset "set1" (:tree "~/my/dir" "^ici.+\\.el$")) +;; (:fileset "set2" (:files "dired+.el" "c:/my/dir/buff-menu+.el")) +;; "c:/some/other/dir/foobar.el" +;; "c:/somewhere/else/toto.el") +;; +;; This is a great way to put together a project of files from +;; different directory trees. And even aside from the use of such a +;; saved set for completion, this combining of filesets is something +;; that you cannot do with Emacs filesets alone, as far as I know - +;; you cannot combine different filesets into super filesets, and a +;; given fileset can specify files in only one way (`:files', +;; `:tree', etc.). Icicles gives you a way to associate related +;; filesets and use them together as a single set. +;; +;; You can use commands +;; `icicle-remove-entry-from-saved-completion-set' and +;; `icicle-add-entry-to-saved-completion-set' to remove a fileset +;; from an Icicles saved set or add a fileset to a saved set. To +;; add, use a prefix arg to tell +;; `icicle-add-entry-to-saved-completion-set' that you are adding a +;; fileset and not a single completion candidate. To add a single +;; file (default: the current buffer's file) to a fileset, use +;; command `icicle-add-file-to-fileset'. +;; +;; Note: Use the right type of saved candidates (persistent or not) +;; for a given command. It is the particular command that determines +;; whether or not a given type of saved candidate is appropriate. +;; For example, you can save search hits when you use +;; `icicle-search-file' (same as `icicle-search' with a negative +;; prefix arg), and those saved search-hit candidates effectively +;; reference files and positions in those files. And you can later +;; retrieve and reuse such saved candidates to visit the search +;; positions. But those candidates are not merely file names, so +;; they cannot be used with a command such as `find-file' or +;; `icicle-file' that expects a file name. Conversely, you cannot +;; use a saved set of file names with a command such as +;; `icicle-search-file' that expects `icicle-search' candidates. +;; +;;(@* "Improving Performance with Persistent Sets") +;; ** Improving Performance with Persistent Sets ** +;; +;; There are two independent reasons that using a persistent set of +;; file names can improve performance: +;; +;; * Avoiding remote file-name completion. You can complete your +;; input against remote file names without using Tramp and thus +;; without accessing the remote file system. (Once you have chosen +;; the file you want, visiting it of course makes a remote access.) +;; +;; * Avoiding generation of a large completion set. Retrieving a +;; list of file names is much, much faster than generating such a +;; list. So generate once and retrieve often, from a cache. +;; +;; These are covered in the next two sections. +;; +;;(@* "Avoid Remote File-Name Completion") +;; *** Avoid Remote File-Name Completion *** +;; +;; When you complete the name of a remote file, Tramp accesses the +;; remote file system to see which matching files exist. This takes +;; time. The completion itself is complicated - it involves parsing +;; the remote file name and calling upon various file handlers. But +;; the greatest time spent is in accessing the remote machine. +;; +;; When you retrieve a (persistently) saved set of file names during +;; completion, you are telling Emacs that these are the candidates +;; you want to complete against. You are not asking Emacs (Tramp) to +;; tell you what the possible candidates are; you are telling it. +;; (Obviously you will want to save the completions in a file on the +;; local machine, so retrieval itself takes no time.) +;; +;; After retrieving the saved candidates as the only possible ones, +;; you might type some input and complete it (`TAB' or `S-TAB') to +;; narrow your choices. Or you might not bother with completion but +;; instead pick one of the candidates using `mouse-2' or by cycling +;; to it and using `RET'. +;; +;; You can use either relative or absolute file-name completion with +;; remote file names. Relative name completion as provided by +;; `read-file-name' (via `C-x C-f', for example) always involves +;; Tramp (or ange-ftp, prior to Emacs 22). When using relative name +;; completion, you can save time in these ways: +;; +;; * Turn off incremental completion (using `C-#'), so that Tramp is +;; used only when you hit `TAB' or `S-TAB', not with each character +;; you type or delete! +;; +;; * Use `mouse-2', or cycle and use `RET', so that you avoid +;; completion altogether. Tramp is then used only to access the +;; chosen file. +;; +;; If you use absolute file-name completion as provided by +;; `completing-read' (via `C-u C-x C-f', for example), then you need +;; not worry about turning off incremental completion or avoiding +;; completion by cycling or using `mouse-2'. This is because +;; completion is entirely local - `completing-read' has no notion of +;; files, let alone remote files. +;; +;; In addition, if you use absolute file-name completion then you +;; need not bother to type the (long) remote file-name prefix to get +;; into the right directory for completion. Again, `completing-read' +;; has no notion of files or directories - it just completes an input +;; pattern against string candidates. Just type a substring or other +;; regexp and then hit `S-TAB'. +;; +;; In general, using absolute file names (`C-u C-x C-f') is the way +;; to go when dealing with remote files. There is no need to forego +;; the advantages of Icicles completion. On the other hand, if you +;; are going to work in a directory on a remote machine for some time +;; using files other than those in some saved completion set, then +;; you might want to use relative file names (`C-x C-f'). +;; +;;(@* "Avoid Generating A Large Completion Set") +;; *** Avoid Generating A Large Completion Set *** +;; +;; Section (@> "File-Name Input and Locating Files Anywhere") tells +;; you how you can locate any file in your file system. If you save +;; the set of all file names persistently, you will increase the +;; performance of using it - it is much faster to retrieve the list +;; of all file names than it is to generate it. +;; +;; With 36 GB of files in my file system, my all-file-system cache +;; file is 20 MB, and retrieving the file-name completions from it +;; takes only a few seconds. With this feature, Icicles essentially +;; gives you the functionality of the Unix `locate' command, but with +;; the addition of real-time regexp matching. Here is all you do: +;; +;; M-x icicle-locate-file RET +;; C-# ; Once or twice: turn off incremental completion. +;; C-{ ; Retrieve all file names from your cache file. +;; ; You are prompted for the set name and file name. +;; foo.*bar ; Regexp to match names with `foo' followed by `bar'. +;; S-TAB ; Update `*Completions*' display (because of `C-#'). +;; +;; Of course, once you have retrieved a set of candidates from your +;; cache file, you can access them again without re-reading the file. +;; When they are retrieved from your cache they are saved in variable +;; `icicle-saved-completion-candidates', so the next time you want to +;; use them, just retrieve them from this variable with `C-M-<'. +;; +;; See Also: +;; +;; * (@> "File-Name Input and Locating Files Anywhere") for +;; information about relative vs absolute file names and about +;; finding files located anywhere in your file system +;; +;; * (@> "Icompletion") for information about `C-#' (toggle +;; incremental completion) +;; +;; * (@> "Sets of Completion Candidates") for information about +;; `C-M->' (save current candidates) +;; +;; * (@> "Dealing With Large Candidate Sets") + +;;(@* "Dealing With Large Candidate Sets") +;; +;; Dealing With Large Candidate Sets +;; --------------------------------- +;; +;; One of the advantages Icicles provides is the ability to deal with +;; large sets of completion candidates with ease. There are other +;; libraries that also let you cycle among various choices of +;; different kinds (buffers, files, and so on), but cycling quickly +;; loses its effectiveness as the number of candidates increases. +;; +;; Icicles apropos matching lets you work with a large initial set of +;; candidates by filtering them, quickly reducing the number +;; candidates to cycle through. Filtering by a prefix only (vanilla +;; Emacs) is not very potent. Until you get used to Icicles, you +;; will be surprised at your ability to manipulate even humongous +;; sets of choices. +;; +;; Nevertheless, there can be times when a candidate set is so large +;; that you need to use a few tricks to deal with it efficiently. +;; There are two main things that take time when dealing with a large +;; set: computing the set and displaying it (with highlighting) in +;; buffer `*Completions*'. In particular, incremental completion +;; display is costly because it does both of these, recompute the set +;; and redisplay it, each time you type or delete a character in the +;; minibuffer. +;; +;; Here are some tips to improve performance with a large set of +;; candidates: +;; +;; * Turn off incremental completion display in buffer +;; `*Completions*'. You can do this on the fly at any time by +;; using `C-#' in the minibuffer - use `C-#' again to turn it back +;; on. See (@> "Icompletion"). +;; +;; * Compute a large candidate set only once, cache the result, and +;; reuse it later by reading the cache instead of recomputing. +;; This is useful, for instance, for the candidate set of all files +;; on your file system. You can cache a set of candidates in +;; either a variable (quickest, but not persistent) or a disk file +;; (slower, persistent). +;; See (@> "Persistent Sets of Completion Candidates"). +;; +;; * Compute a large candidate set (and perhaps cache it or filter +;; it) without displaying it in `*Completions*', by using `C-M-TAB' +;; or `C-M-S-TAB' instead of `TAB' or `S-TAB', respectively. These +;; are bound to commands `icicle-prefix-complete-no-display' and +;; `icicle-apropos-complete-no-display'. For example, when +;; initially computing the set of all files on your file system for +;; `C-u M-x icicle-locate-file', use `C-M-S-TAB' to compute the +;; set, then use `C-}' to save it to a cache file - you need never +;; display it. +;; +;; (The documentation refers to the keys that do this as +;; `C-M-S-TAB' and `C-M-TAB'. Actually, this is only by default. +;; You can customize this, using options +;; `icicle-apropos-complete-no-display-keys' and +;; `icicle-prefix-complete-no-display-keys'.) + +;;(@* "History Enhancements") +;; +;; History Enhancements +;; -------------------- +;; +;; This section is about accessing and reusing previous input that +;; you have typed in the minibuffer. +;; +;;(@* "What Input, What History?") +;; ** What Input, What History? ** +;; +;; First, what is meant by "input" and "input history"? In vanilla +;; Emacs and in this doc, "minibuffer history" and "input history" +;; generally refer to input that you have typed (or cycled or +;; completed) in the minibuffer and then entered using `RET' (or +;; `S-RET'). Emacs provides different history lists for this, +;; depending on the kind of input. The most general such list is the +;; value of variable `minibuffer-history'. +;; +;; But what about input that you type in the minibuffer (e.g. during +;; completion) but that you do not enter with `RET'? That is not +;; recorded in any standard history list, so you cannot recall it +;; using `M-p' and `M-n'. +;; +;; The Icicles doc speaks ambiguously of "minibuffer input". This +;; always refers to something that you type in the minibuffer, but +;; sometimes it means input that you enter with `RET' and sometimes +;; it does not. The context and the use of phrases such as "entered" +;; and "entered with `RET'" should make clear what is meant. Input +;; that you type during completion but that you do not necessarily +;; enter is sometimes referred to in the Icicles doc as "completion +;; input". +;; +;; Because completion is so important to Icicles, because cycling +;; replaces the input you type in the minibuffer, and because you +;; sometimes need to retrieve such typed input that was never +;; entered, Icicles also records this input. You can retrieve it +;; during completion using `C-l' (`icicle-retrieve-previous-input') +;; and `C-S-l', that is, `C-L', (`icicle-retrieve-next-input'). Use +;; these commands to cycle among your past completion inputs +;; (backward and forward, respectively). +;; +;; User option `icicle-completion-history-max-length' limits the +;; number of completion inputs to save. +;; +;; If you customize user option `icicle-C-l-uses-completion-flag' to +;; non-nil, then, instead of cycling, `C-l' lets you use Icicles +;; completion to retrieve a past completion input (`C-L' does the +;; same thing). Using completion to retrieve a past input does not +;; also choose that input as the candidate for the main completion; +;; it just replaces your current minibuffer input with it. Because +;; `C-l' completion uses a recursive minibuffer, you can also use +;; `C-g' to cancel this completion and return to the main completion. +;; +;; You can temporarily reverse the effect of +;; `icicle-C-l-uses-completion-flag' by using a prefix argument +;; (`C-u') with `C-l'. Thus, `C-u C-l' uses completion if +;; `icicle-C-l-uses-completion-flag' is nil and cycles if it is +;; non-nil. +;; +;; The other sections here describe Icicles enhancements for +;; minibuffer histories. They are thus concerned only with inputs +;; that you enter, not with completion inputs that are not entered. +;; +;;(@* "Overview of Minibuffer History Enhancements") +;; ** Overview of Minibuffer History Enhancements ** +;; +;; Icicles enhances the minibuffer history in these independent ways: +;; +;; 1. Commands invoked using a menu-bar menu are included in the +;; command history for `M-x'. This helps you quickly find again +;; and reuse a (possibly deep) menu item. It lets you use +;; completion to access such commands. And it helps you learn the +;; commands that correspond to menu items that you use, thus +;; providing a missing bridge between menu use and minibuffer use. +;; +;; If you do not want to include menu-item commands in the command +;; history, then set option `icicle-menu-items-to-history-flag' to +;; nil. +;; +;; Note: Non-nil `icicle-menu-items-to-history-flag' simply makes +;; Emacs handle menu items that you choose the same way that it +;; handles commands that you enter using `RET'. It does not add +;; such menu items to your completion history, which you access +;; using `C-l' (see (@> "What Input, What History?"), above). +;; +;; 2. Command `icicle-insert-history-element' (bound to `M-o' in the +;; minibuffer) lets you use (lax) completion to insert a history +;; element in the minibuffer. +;; +;; 3. Candidates displayed in `*Completions*' are highlighted using +;; face `icicle-historical-candidate' (blue foreground, by +;; default), when they have been used previously, so you can more +;; easily recognize them. This highlighting is controlled by +;; option `icicle-highlight-historical-candidates-flag'. You can +;; toggle this from the minibuffer at any time using `C-pause'. +;; +;; 4. Command `icicle-toggle-alternative-sorting', (`C-M-,' in the +;; minibuffer) re-sorts completion candidates, placing previously +;; used candidates first. This is a toggle: repeat it to return +;; to the original order. +;; +;; 5. Command `icicle-keep-only-past-inputs' (`M-pause' in the +;; minibuffer) restricts the current set of completion candidates +;; to those that you have used previously. In other words, it +;; keeps only those candidates that are highlighted in blue. To +;; use `M-pause', you must first have used `TAB' or `S-TAB' to +;; establish an explicit candidate set. If you use `C-u M-pause', +;; then the previously used candidates are ordered +;; chronologically, most recent first. Without `C-u', the normal +;; sort order is used (`icicle-sort-comparer'). +;; +;; 6. Command `icicle-history' (`M-h' in the minibuffer) matches the +;; current input against the minibuffer history directly. It can +;; be used during completion. +;; +;; 7. Command `icicle-other-history' (`C-M-pause' in the minibuffer) +;; lets you use a different history for the current completion. +;; You can choose the history using completion. +;; +;; 8. Commands `icicle-clear-history' and +;; `icicle-clear-current-history' (`M-i' in the minibuffer) +;; provide a general way to clean up histories. +;; +;; 9. When you cycle among previously entered inputs using `M-p' and +;; `M-n', you can use `M-k' (command +;; `icicle-erase-minibuffer-or-history-element') to delete the +;; current occurrence from the history list. This is a quick and +;; handy way to clean up list entries that you are no longer +;; interested in. Only the occurrence that you have cycled to is +;; deleted; if there are identical entries elsewhere in the +;; history, they remain. +;; +;; Some of these enhancements are described below in more detail. +;; Each of 1-7 lets you see the complete list of previous inputs that +;; match your current input. In vanilla Emacs, the history lists are +;; never shown as such; you can access previous inputs only one at a +;; time, in order (with `M-p'). In vanilla Emacs, you can use a +;; regexp to search the history list (via `M-r'), but the regexp +;; matching is not dynamic, and the first match found is the (only) +;; one you get. +;; +;; Displaying previous inputs that match the current input sounds +;; like a minor advantage, but it is actually quite helpful in +;; practice. Among other things, it means that you can work with +;; long history lists in a practical way. +;; +;;(@* "Using Completion to Insert Previous Inputs: `M-o'") +;; ** Using Completion to Insert Previous Inputs: `M-o' ** +;; +;; Unlike the other minibuffer history enhancements, described below, +;; which are available only during minibuffer completion, you can use +;; `M-o' (`icicle-insert-history-element') anytime you are asked for +;; minibuffer input. It provides a recursive minibuffer in which you +;; can match a previous input using completion. After you hit `RET' +;; to accept your choice, it is inserted in the minibuffer just as if +;; you had typed it. This is a form of on-demand completion +;; (see (@> "Completion On Demand"), and as such is always available. +;; +;; This has the advantage over cycling with `M-n' or `M-p' and +;; searching with `M-s' or `M-r', that you can use Icicles completion +;; and cycling to quickly access a previous input, no matter how long +;; ago you entered it. +;; +;; When completion is available for reading input, if you use `M-o' +;; to choose a previously entered input, this just inserts that input +;; in the minibuffer. What is in the minibuffer after you use `M-o' +;; is not automatically chosen for the main completion - you can edit +;; the minibuffer contents before entering it with `RET'. You can +;; also use `C-g' during the `M-o' completion to cancel it and return +;; to the main completion. +;; +;;(@* "Putting Previous Candidates First: `C-M-,'") +;; ** Putting Previous Candidates First: `C-M-,' ** +;; +;; At any time, two of the Icicles sort orders are immediately +;; available. These are the values of user options +;; `icicle-sort-comparer' and `icicle-alternative-sort-comparer'. By +;; default, the former usually sorts alphabetically, and the latter +;; puts all previously used inputs first, before the candidates you +;; have not yet used. Each of these groups, used and unused +;; candidates, is then sorted alphabetically, separately. So, with +;; the default alternative sort, you can see all matching candidates +;; (used and unused), but you privilege those used previously - they +;; are the first listed in `*Completions*' and the first available +;; for cycling. +;; +;; If you prefer, by customizing these user options, you can use +;; `icicle-historical-alphabetic-p' as the main sort function (option +;; `icicle-sort-comparer') and some other sort function +;; (e.g. `icicle-case-string-less-p') as the alternative sort +;; function. +;; +;; You can toggle at any time between normal sorting and alternative +;; sorting, using command `icicle-toggle-alternative-sorting'. +;; During completion, this is bound to `C-M-,'. Together with +;; toggling between normal sorting and not sorting at all, which is a +;; sort-order choice available through `C-,', this gives you quite a +;; lot of flexibility. +;; +;;(@* "Matching Only Historical Candidates: `M-h' and `M-pause'") +;; ** Matching Only Historical Candidates: `M-h' and `M-pause' ** +;; +;; Both `M-h' and `M-pause' can be used toward the same end. They +;; both work for all input types. They both use the appropriate +;; history list for the current command. They both provide apropos +;; completion and cycling for the minibuffer history (as well as +;; prefix completion, of course). Use them as another way to search +;; through a history list or complete to one of its elements. +;; +;; For example, If you use `C-x C-f' to find a file, and then use +;; `M-h' or `M-pause', the completion candidates will be the names of +;; files that you have previously accessed (file names you have input +;; in the minibuffer), and which match the current minibuffer input. +;; +;; `M-h' lets you complete your input against the minibuffer input +;; history. `M-pause' lets you restrict the current explicit set of +;; completion candidates to those that are also in the minibuffer +;; history. +;; +;; They provide similar functionality in different ways. The +;; difference is that `M-pause' takes the current set of matching +;; candidates into account. It is a completion-candidates set +;; operation, similar to those described in section +;; (@> "Sets of Completion Candidates"). +;; +;; This means, in particular, that with `M-pause' you can first +;; perform set operations on the set of candidates, and then use that +;; result to restrict the history search. For example, you can first +;; complement the candidate set using `C-~', then use `M-pause' to +;; restrict those candidates to matches in the history list. In this +;; way, you avoid including matches from the original match set when +;; searching the history. +;; +;; Example: You are in a directory with lots of files that have the +;; prefix `foo' and lots of C-language source files. You happen to +;; be interested in another file, however. One way to get to that +;; file is to use Dired's ability to mark files by matching a regexp +;; and then use Dired's ability to omit the marked files from view. +;; You can scan through those that remain, and pick the one you want. +;; However, it turns out that even then there are many files to scan. +;; You accessed the one you want now just the other day, but the file +;; date is unfortunately not significant. +;; +;; In Icicles, you use regexp matching and take the set complement of +;; the hits, just like in Dired: `C-x C-f foo.*\.c$' defines the +;; candidate set as all files whose names start with `foo' and have +;; extension `c'. `C-~' then defines the candidate set as all files +;; whose names are not like that. Finally, you use `M-pause' to +;; restrict the file-name candidates to names that you have used +;; before. You've accessed many, many files recently, so just +;; cycling through the history with `M-p' would be tedious. You +;; could match a regexp against the file history, but how can you +;; come up with a regexp that finds anti-matches? +;; +;; A consequence of this difference between `M-h' and `M-pause' is +;; that using `TAB' or `S-TAB' after `M-pause' abandons use of the +;; minibuffer history and starts a new set of completion candidates. +;; It simply completes the current input in the context of the +;; current command; `TAB' and `S-TAB' have nothing to do with the +;; minibuffer history in this case. Using `TAB' or `S-TAB' after +;; `M-h', however, re-completes your input against the current +;; history list. +;; +;; Another consequence is that you can use `down' or `C-down' on the +;; candidates displayed by `M-h', but not on those displayed by +;; `M-pause'. For example, to cycle through the doc for each +;; variable that starts with `icicle-' which you have previously +;; input, you can use `C-h v icicle- M-h', then repeatedly use +;; `C-down'. +;; +;; Also, file-name and directory-name completion works differently in +;; these two commands. By default, the current directory is (as +;; always) inserted into the minibuffer by commands such as +;; `find-file', so either `M-h' or `M-pause' after `C-x C-f' will +;; match previously input file names from the current directory. +;; +;; However, in the case of `M-h', the entire minibuffer input is +;; matched against the history list, which is a list of absolute file +;; names. `M-pause' works only with the current candidate set, +;; which, if you have already used `TAB' or `S-TAB' in the current +;; directory, is a set of relative file names in that directory. +;; +;; This difference has a consequence for apropos (regexp) completion +;; with `M-h'. It means that to match a file name using a substring +;; you must, in the minibuffer, either not specify a directory (erase +;; it) or explicitly use `.*' before the file-name substring. +;; +;; For example, with `M-h', `/foo/bar/lph' will not apropos-match the +;; previously input file name `/foo/bar/alphabet-soup.el'; you should +;; use either `/foo/bar/.*lph' or `lph' (no directory). +;; +;; In the case of `M-pause', however, the input is matched against +;; the history list as restricted by the existing completion list. +;; And, since apropos file-name completion uses only the relative +;; file name, without the directory name, as a regexp, the candidate +;; list that is restricted has already matched the input regexp. The +;; action of `M-pause' is simply to filter the list of candidates, +;; keeping those that are in the history list. This means that, with +;; `M-pause', the input `/foo/bar/lph' will match against the +;; previously input file name `/foo/bar/alphabet-soup.el'. +;; +;; If this all sounds confusing, just give it a try; it is much +;; harder to describe than it is to experience. +;; +;;(@* "Using Other Histories; Commands Any Which Way") +;; ** Using Other Histories; Commands Any Which Way ** +;; +;; This section describes how to complete your input against a +;; history other than the default history provided for the current +;; command. A special case of this, starting with Emacs 23, is +;; completing a command, abbrev, or keyboard macro name against all +;; such that were previously executed in any interactive way. This +;; includes commands invoked using a menu. +;; +;;(@* "Completing Against All Interactive Commands") +;; *** Completing Against All Interactive Commands *** +;; +;; When you execute a command using `M-x', it is added to the history +;; `extended-command-history'. Likewise, when you execute a command +;; or abbrev using `icicle-command-abbrev-command'. And when you +;; execute a keyboard macro using `C-x M-e' +;; (`icicle-execute-named-keyboard-macro'), it is added to history +;; `icicle-kmacro-history'. +;; +;; However, when you execute a command, abbrev, or keyboard macro in +;; other ways than these, it is not added to such a history. For +;; example, if you choose a menu item, the associated command is not +;; added to any of these histories. Thus, although `M-o' lets you +;; complete against previously used commands, this does not include +;; commands that were called via a menu item. +;; +;; To remedy this, starting with Emacs 23 Icicles can optionally add +;; all commands that are called using `call-interactively' to the +;; larger command history `icicle-interactive-history'. This +;; includes commands on menus. To enable this feature, you must +;; customize option `icicle-populate-interactive-history-flag', to +;; make it non-nil. Thereafter, when you enter Icicle mode, all +;; interactive use of commands records them on this special history. +;; +;; During completion, you can then use `C-M-pause' +;; (`icicle-other-history') to complete against this extended set of +;; previously used commands. For example, if you use menu item `Open +;; File', then the corresponding command, `menu-find-file-existing', +;; becomes available as a completion candidate. (Recall too that the +;; command associated with a given menu item is shown in the +;; `*Completions*' mode line whenever you cycle to it.) +;; +;; Be aware that use of this feature can slow Emacs down, and the +;; history list can become quite large. +;; +;;(@* "Using an Alternative History") +;; *** Using an Alternative History *** +;; +;; When you are completing something other than a command, abbrev, or +;; keyboard macro (or even when you complete one of those, if you use +;; a prefix argument), `C-M-pause' prompts you for an alternative +;; history to use - any history you like. You can choose the history +;; using completion. This does not automatically complete your +;; current input against the history you choose; it simply changes +;; the current history for the duration of the current minibuffer +;; completion. (You can use `M-h', as usual, if you want to complete +;; against the chosen history.) +;; +;;(@* "Cleaning Up History Lists") +;; ** Cleaning Up History Lists ** +;; +;; Besides the use of `M-k' during history cycling (`M-p', `M-n') to +;; remove individual input occurrences from the current history list, +;; you can use commands `icicle-clear-history' and +;; `icicle-clear-current-history' to clean minibuffer histories +;; entirely of selected entries. Command +;; `icicle-clear-current-history' is bound to `M-i' in the +;; minibuffer. It is `icicle-clear-history' specialized to work on +;; just the current history list. +;; +;; These commands prompt you for a history entry to delete from a +;; history list. These are multi-commands, so you can delete +;; multiple entries. For each entry you choose, all of its +;; occurrences are deleted from the history. +;; +;; Command `icicle-clear-history' first prompts you for a history +;; list to act on. This too is multi-command input, so you can use +;; `icicle-clear-history' to remove entries from multiple histories. +;; +;; If you use a prefix argument with these commands, then the +;; histories are emptied entirely (upon confirmation). Thus, for +;; instance, you can use `C-u M-i' at any time during minibuffer +;; input to completely empty the current history list. +;; +;; See Also: (@> "More about Multi-Commands") for information about +;; using `S-delete' to delete objects associated with completion +;; candidates. + +;;(@* "Isearch Enhancements") +;; +;; Isearch Enhancements +;; -------------------- +;; +;; Icicles provides two different enhancements for searching: +;; +;; - Icicles search: Top-level Icicles commands that provide an +;; entirely new and different way for you to search. +;; This is described in section +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview"). +;; +;; - Extensions to standard Emacs incremental search, Isearch. +;; These are described in this section. +;; +;; * Search string completion against previous search strings. +;; * Occur mode interface for Isearch hits. +;; * Icicles search (`icicle-search') interface, reusing the +;; Isearch search string (by default). +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc2.el" :to "Support for Projects") +;; for information about using `grep' to search all of the files in +;; a project. +;; +;;(@* "Isearch Completion Against the Search History") +;; ** Isearch Completion Against the Search History ** +;; +;; When you search incrementally (`C-s'), Emacs lets you use `M-TAB' +;; (aka `C-M-i', aka `ESC-TAB') to complete your input to a string +;; that you have sought previously, that is, a string in the current +;; search history (`search-ring' or `regexp-search-ring'). In Icicle +;; mode, this feature is enhanced so that you can use all of the +;; completion enhancements provided by Icicles: `M-TAB' is bound to +;; `icicle-isearch-complete' during Isearch. +;; +;; Some operating systems grab `M-TAB' for their own use, making it +;; unavailable for Emacs. They normally do not grab `ESC TAB', which +;; in Emacs is typically the same ase `M-TAB'. For this reason, +;; Icicles also binds `icicle-isearch-complete' to both `ESC TAB' and +;; `C-M-TAB'. (Note: For MS Windows, you can use +;; (w32-register-hot-key [M-tab]) to allow Emacs to use `M-TAB'.) +;; +;; Icicles users are in the habit of using `M-o' to complete the +;; current minibuffer input against previously entered inputs. +;; Because of the similarity, you can likewise use `M-o' during +;; Isearch to complete the current search string: `M-o' is equivalent +;; to `M-TAB'. +;; +;; The keys bound by default to `icicle-isearch-complete' in +;; `isearch-mode-map' are thus `M-TAB', `ESC TAB', `C-M-TAB', and +;; `M-o'. But you can change the keys to use for this by customizing +;; option `icicle-isearch-complete-keys'. +;; +;; When you use `M-o' (or `M-TAB') while searching, Isearch exits +;; momentarily, giving way to Icicles completion in the minibuffer +;; (Isearch actually uses the echo area, not the minibuffer). You +;; can then use either `S-TAB' or `TAB' to complete your search +;; string. After you finish completing (e.g. by hitting `RET'), +;; Isearch resumes with the new, completed search string. It's +;; pretty seamless, and easier to try than to describe. +;; +;; Reminder: Using `S-TAB' vs `TAB' for regexp vs non-regexp +;; completion against previous search strings has nothing to do with +;; regexp vs non-regexp searching. You can of course use either kind +;; of searching before or after having used either kind of +;; completion. Isearch uses different search rings for regexp and +;; non-regexp searching. The kind of search in progress (regexp or +;; not) at the moment you ask Isearch for completion determines which +;; search ring provides the candidates for completion. +;; +;;(@* "Launch Occur using the Isearch Search String") +;; ** Launch Occur using the Isearch Search String ** +;; +;; If you use library `color-moccur.el' or library +;; `occur-schroeder.el', then `C-o' is bound during Isearch to +;; `isearch-moccur', which provides an Occur buffer interface for +;; search hits. This has nothing per se to do with Icicles, but you +;; might find it useful. (Library `color-moccur.el' itself binds +;; `M-o' for this, but `M-o' is used in Icicles for search-string +;; completion.) +;; +;;(@* "Launch Icicles Search using the Isearch Search String") +;; ** Launch Icicles Search using the Isearch Search String ** +;; +;; Icicles search is described in section +;; (@file :file-name "icicles-doc2.el" :to "Icicles Search Commands, Overview"). +;; +;; You can start Icicles search from Isearch: Hit `S-TAB' to choose +;; the Icicles search initial regexp - the default value is the +;; current Isearch search string, but you can edit that. Completion +;; is available for your input - completion against your previous +;; Isearch regexp search strings. +;; +;; For example, use `C-s C-w C-w S-TAB' to pick up the next two words +;; at the cursor, then type `.*' before and after them and hit `RET'. +;; That puts you in Icicles search with the completion candidates +;; being all of the lines in the buffer that contain that two-word +;; phrase. Type some more text to narrow the candidate lines to +;; those that match what you type. Then use `C-next' to visit search +;; hits. +;; +;; The key to initiate Icicles search from Isearch is `S-TAB' only by +;; default. You can change this key by customizing option +;; `icicle-search-from-isearch-keys'. + +;; The Icicles doc is continued in file `icicles-doc2.el'. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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: + +;; You need not load this file. It contains only documentation. + +(provide 'icicles-doc1) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-doc1.el ends here diff --git a/.emacs.d/icicles/icicles-doc2.el b/.emacs.d/icicles/icicles-doc2.el new file mode 100644 index 0000000..8629446 --- /dev/null +++ b/.emacs.d/icicles/icicles-doc2.el @@ -0,0 +1,8539 @@ +;;; icicles-doc2.el --- Minibuffer input completion and cycling. +;; +;; Filename: icicles-doc2.el +;; Description: Minibuffer completion and cycling. +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Tue Aug 1 14:21:16 1995 +;; Version: 22.0 +;; Last-Updated: Tue Jul 20 14:02:24 2010 (-0700) +;; By: dradams +;; Update #: 27055 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-doc2.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: +;; +;; None +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; Icicles documentation, part 2. +;; +;; Files `icicles-doc1.el' and `icicles-doc2.el' contain the doc for +;; Icicles, including how to install and use Icicles. You can also +;; read the Icicles doc, in formatted form, on the Emacs-Wiki Web +;; site: http://www.emacswiki.org/cgi-bin/wiki/Icicles. Emacs Wiki +;; also has a few addtional pages about Icicles. In particular, if +;; you are new to Emacs, as well as Icicles, see this page: +;; http://www.emacswiki.org/cgi-bin/wiki/EmacsNewbieWithIcicles. +;; +;; This file continues the Icicles documentation, which starts in +;; file `icicles-doc1.el'. + +;;(@* "Index") +;; +;; 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 and render it more readable. Likewise, for +;; the cross-references and section headings throughout this file. +;; You can get `linkd.el' here: +;; http://www.emacswiki.org/cgi-bin/wiki/linkd.el. +;; +;; (@file :file-name "icicles-doc1.el" :to "Documentation in File `icicles-doc1.el'") +;; ----------------------------------------------------------- +;; +;; (@file :file-name "icicles-doc1.el" :to "Nutshell View of Icicles") +;; (@file :file-name "icicles-doc1.el" :to "README for Non-Readers") +;; (@file :file-name "icicles-doc1.el" :to "Toggle Options on the Fly") +;; (@file :file-name "icicles-doc1.el" :to "Cycle Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Display Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Prefix Completion and Apropos Completion") +;; (@file :file-name "icicles-doc1.el" :to "Chains of Simple Match Patterns - Progressive Completion") +;; (@file :file-name "icicles-doc1.el" :to "Chip Away the Non-Elephant") +;; (@file :file-name "icicles-doc1.el" :to "Choose Before You Act") +;; (@file :file-name "icicles-doc1.el" :to "Help on Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Perform Multiple Operations in One Command") +;; (@file :file-name "icicles-doc1.el" :to "Perform Alternative Operations on the Fly") +;; (@file :file-name "icicles-doc1.el" :to "Completion Status Indicators") +;; (@file :file-name "icicles-doc1.el" :to "Icicles Search") +;; (@file :file-name "icicles-doc1.el" :to "Complete Key Sequences Too") +;; (@file :file-name "icicles-doc1.el" :to "Available for Almost Any Input") +;; (@file :file-name "icicles-doc1.el" :to "Component Icicles Libraries") +;; (@file :file-name "icicles-doc1.el" :to "If You Are an Emacs-Lisp Programmer") +;; +;; (@file :file-name "icicles-doc1.el" :to "Inserting Text Found Near the Cursor") +;; (@file :file-name "icicles-doc1.el" :to "Background on Vanilla Emacs Input Completion") +;; (@file :file-name "icicles-doc1.el" :to "Cycling Completions") +;; (@file :file-name "icicles-doc1.el" :to "Traversing Minibuffer Histories") +;; (@file :file-name "icicles-doc1.el" :to "Apropos Completions") +;; (@file :file-name "icicles-doc1.el" :to "Expanded-Common-Match Completion") +;; (@file :file-name "icicles-doc1.el" :to "Progressive Completion") +;; (@file :file-name "icicles-doc1.el" :to "`M-*': Matching Additional Regexps") +;; (@file :file-name "icicles-doc1.el" :to "Successive Approximation...") +;; (@file :file-name "icicles-doc1.el" :to "`M-&': Satisfying Additional Predicates") +;; +;; (@file :file-name "icicles-doc1.el" :to "Regressive Completion") +;; (@file :file-name "icicles-doc1.el" :to "Completion On Demand") +;; (@file :file-name "icicles-doc1.el" :to "Moving Between the Minibuffer and Other Buffers") +;; (@file :file-name "icicles-doc1.el" :to "Inserting a Regexp from a Variable or Register") +;; (@file :file-name "icicles-doc1.el" :to "Special Characters in Input Patterns") +;; (@file :file-name "icicles-doc1.el" :to "Alternative Libraries: Other Methods of Choosing Default Values") +;; (@file :file-name "icicles-doc1.el" :to "Exiting the Minibuffer Without Confirmation") +;; (@file :file-name "icicles-doc1.el" :to "*Completions* Display") +;; (@file :file-name "icicles-doc1.el" :to "Icompletion") +;; (@file :file-name "icicles-doc1.el" :to "icomplete+.el Displays the Number of Other Prefix Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Icicles Highlights the Input that Won't Complete") +;; (@file :file-name "icicles-doc1.el" :to "Icompletion in *Completions*: Apropos and Prefix Completion") +;; +;; (@file :file-name "icicles-doc1.el" :to "Sorting Candidates and Removing Duplicates") +;; (@file :file-name "icicles-doc1.el" :to "Changing the Sort Order") +;; (@file :file-name "icicles-doc1.el" :to "Defining New Sort Orders") +;; (@file :file-name "icicles-doc1.el" :to "Different Sorts for Different Sorts of Uses") +;; +;; (@file :file-name "icicles-doc1.el" :to "Get Help on Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Use Candidate Help Like You Use Emacs Command `apropos'") +;; (@file :file-name "icicles-doc1.el" :to "Other Icicles Apropos Commands") +;; +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands") +;; (@file :file-name "icicles-doc1.el" :to "What Is a Multi-Command?") +;; (@file :file-name "icicles-doc1.el" :to "How Does a Multi-Command Work?") +;; +;; (@file :file-name "icicles-doc1.el" :to "More about Multi-Commands") +;; (@file :file-name "icicles-doc1.el" :to "Alternative Actions") +;; (@file :file-name "icicles-doc1.el" :to "Deleting Objects") +;; (@file :file-name "icicles-doc1.el" :to "Option `icicle-use-C-for-actions-flag'") +;; (@file :file-name "icicles-doc1.el" :to "Accessing Saved Locations (Bookmarks) on the Fly") +;; +;; (@file :file-name "icicles-doc1.el" :to "Icicles Tripping") +;; (@file :file-name "icicles-doc1.el" :to "Highlighting the Destination") +;; +;; (@file :file-name "icicles-doc1.el" :to "Key Completion") +;; (@file :file-name "icicles-doc1.el" :to "Completing Keys") +;; (@file :file-name "icicles-doc1.el" :to "`S-TAB' Is Everywhere - Start With It") +;; (@file :file-name "icicles-doc1.el" :to "Completing Keys By Name") +;; (@file :file-name "icicles-doc1.el" :to "Completing Prefix Keys") +;; (@file :file-name "icicles-doc1.el" :to "Meta Key Bindings") +;; (@file :file-name "icicles-doc1.el" :to "Navigate the Key-Binding Hierarchy") +;; (@file :file-name "icicles-doc1.el" :to "Local Bindings Are Highlighted") +;; (@file :file-name "icicles-doc1.el" :to "Completing Keys By Just Hitting Them") +;; (@file :file-name "icicles-doc1.el" :to "Key and Command Help") +;; (@file :file-name "icicles-doc1.el" :to "`S-TAB' Is a Multi-Command") +;; (@file :file-name "icicles-doc1.el" :to "Possible Source of Confusion") +;; (@file :file-name "icicles-doc1.el" :to "Three-Key Emacs") +;; (@file :file-name "icicles-doc1.el" :to "Entering Special and Foreign Characters") +;; (@file :file-name "icicles-doc1.el" :to "Handling Keymaps That Are Inaccessible From the Global Map") +;; +;; (@file :file-name "icicles-doc1.el" :to "Icicles Multi `M-x'") +;; (@file :file-name "icicles-doc1.el" :to "Examples of Using Multi `M-x'") +;; (@file :file-name "icicles-doc1.el" :to "What about describe-variable and describe-function?") +;; +;; (@file :file-name "icicles-doc1.el" :to "Multi `M-x' Turns Every Command into a Multi-Command") +;; +;; (@file :file-name "icicles-doc1.el" :to "Choose All Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Saving and Retrieving Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Different Places for Saving and Retrieving Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Set Operations") +;; +;; (@file :file-name "icicles-doc1.el" :to "Google Matching") +;; (@file :file-name "icicles-doc1.el" :to "Domain of Discourse") +;; (@file :file-name "icicles-doc1.el" :to "Global Filtering") +;; (@file :file-name "icicles-doc1.el" :to "Word Matching and String Matching") +;; (@file :file-name "icicles-doc1.el" :to "AND Matching and OR Matching") +;; (@file :file-name "icicles-doc1.el" :to "NOT Matching") +;; +;; (@file :file-name "icicles-doc1.el" :to "File-Name Input and Locating Files Anywhere") +;; (@file :file-name "icicles-doc1.el" :to "Function `read-file-name'") +;; (@file :file-name "icicles-doc1.el" :to "Function `completing-read'") +;; (@file :file-name "icicles-doc1.el" :to "Icicles Commands that Read File Names") +;; (@file :file-name "icicles-doc1.el" :to "Absolute File Names and Different Directories") +;; +;; (@file :file-name "icicles-doc1.el" :to "Persistent Sets of Completion Candidates") +;; (@file :file-name "icicles-doc1.el" :to "Saving Candidates in Cache Files") +;; (@file :file-name "icicles-doc1.el" :to "Filesets and Icicles Saved Completion Sets") +;; (@file :file-name "icicles-doc1.el" :to "Improving Performance with Persistent Sets") +;; (@file :file-name "icicles-doc1.el" :to "Avoid Remote File-Name Completion") +;; (@file :file-name "icicles-doc1.el" :to "Avoid Generating A Large Completion Set") +;; +;; (@file :file-name "icicles-doc1.el" :to "Dealing With Large Candidate Sets") +;; (@file :file-name "icicles-doc1.el" :to "History Enhancements") +;; (@file :file-name "icicles-doc1.el" :to "What Input, What History?") +;; (@file :file-name "icicles-doc1.el" :to "Overview of Minibuffer History Enhancements") +;; (@file :file-name "icicles-doc1.el" :to "Using Completion to Insert Previous Inputs: `M-o'") +;; (@file :file-name "icicles-doc1.el" :to "Putting Previous Candidates First: `C-M-,'") +;; (@file :file-name "icicles-doc1.el" :to "Matching Only Historical Candidates: `M-h' and `M-pause'") +;; (@file :file-name "icicles-doc1.el" :to "Using Other Histories; Commands Any Which Way") +;; (@file :file-name "icicles-doc1.el" :to "Completing Against All Interactive Commands") +;; (@file :file-name "icicles-doc1.el" :to "Using an Alternative History") +;; (@file :file-name "icicles-doc1.el" :to "Cleaning Up History Lists") +;; +;; (@file :file-name "icicles-doc1.el" :to "Isearch Enhancements") +;; (@file :file-name "icicles-doc1.el" :to "Launch Occur using the Isearch Search String") +;; (@file :file-name "icicles-doc1.el" :to "Launch Icicles Search using the Isearch Search String") +;; +;; (@* "Documentation in File `icicles-doc2.el'") +;; ---------------------------------------------- +;; +;; (@> "Icicles Search Commands, Overview") +;; (@> "Introduction: On Beyond Occur...") +;; (@> "How Icicles Search Works") +;; (@> "Why Use 2 Search Patterns?") +;; (@> "Search Multiple Buffers, Files, and Bookmarks") +;; (@> "User Options for Icicles Searching") +;; (@> "Using Regexps with Icicles Search") +;; +;; (@> "Search and Replace") +;; (@> "Other Icicles Search Commands") +;; (@> "Icicles Imenu") +;; (@> "`icicle-imenu' Combines Benefits of Imenu and Emacs Tags") +;; +;; (@> "Compile/Grep Search") +;; (@> "Input Reuse in Interactive Interpreter Modes") +;; (@> "Define Your Own Icicles Search Commands") +;; +;; (@> "Icicles Bookmark Enhancements") +;; (@> "Saving Regions and Selecting Them") +;; (@> "Setting a Bookmark and Jumping to a Bookmark") +;; (@> "Jumping to a Bookmark") +;; (@> "Searching Bookmarked Objects") +;; +;; (@> "Icicles Tags Enhancements") +;; (@> "`icicle-find-tag': Find Tags in All Tags Tables") +;; (@> "`icicle-find-first-tag': Find First Tag in Current Table") +;; (@> "`icicle-tags-search': Search and Replace Using Tags") +;; +;; (@> "Icicles Shell-Command Enhancements") +;; (@> "Icicles Dired Enhancements") +;; (@> "Shell Commands on Marked Files") +;; (@> "Search-and-Replace Marked Files") +;; (@> "Save Marked Files as Completion Candidates") +;; (@> "Open Dired for a Set of File Names") +;; (@> "Marked Files as a Project") +;; +;; (@> "Icicles Info Enhancements") +;; (@> "Icicles Completion for Info") +;; (@> "Virtual Info Books") +;; +;; (@> "Using Icicle-Search With Info") +;; +;; (@> "Support for Projects") +;; (@> "Bookmarks for Project Access and Organization") +;; (@> "A Tags File Can Define a Project") +;; (@> "Navigating Among Code Definitions") +;; (@> "Searching Project Files") +;; (@> "Defining and Saving Sets of Files or Buffers") +;; (@> "Retrieving and Reusing a Saved Project") +;; (@> "Semantics? Roll Your Own?") +;; +;; (@> "Using Complex Completion Candidates") +;; (@> "Icicles OO: Object-Action Interaction") +;; (@> "Apropos Completion as OO") +;; (@> "M-RET") +;; (@> "`icicle-object-action' and `icicle-anything'") +;; (@> "Icicles with Anything") +;; +;; (@> "Multi-Completions") +;; (@> "Icicles Multi-Completion Commands") +;; (@> "How Multi-Completions Work") +;; (@> "Multi-Completions vs `completing-read-multiple'") +;; +;; (@> "Dot, Dot, Dot") +;; (@> "Fuzzy Completion") +;; (@> "Partial Completion") +;; (@> "Scatter-Match Completion") +;; (@> "Swank (Fuzzy Symbol) Completion") +;; (@> "Fuzzy-Match Completion") +;; +;; (@> "Completion in Other Buffers") +;; (@> "Dynamic Abbreviation") +;; (@> "BBDB Completion") +;; (@> "Thesaurus Completion") +;; (@> "Completion in Comint Modes") +;; +;; (@> "Customization and General Tips") +;; (@> "Using Icicles with Delete Selection Mode") +;; (@> "Icicles User Options and Faces") +;; +;; (@> "File-Name and Directory-Name Completion Tips") +;; (@> "Key Bindings") +;; (@> "Global Bindings") +;; (@> "Icicles-Mode Bindings") +;; (@> "Minibuffer Bindings") +;; +;; (@> "Customizing Key Bindings") +;; (@> "Customizing Global Bindings") +;; (@> "Customizing Icicle Mode Bindings") +;; (@> "Customizing Minibuffer Bindings") +;; +;; (@> "Icicles Redefines Some Standard Commands") +;; (@> "Programming with Fancy Candidates") +;; (@> "Programming Multi-Completions") +;; (@> "Variable icicle-list-use-nth-parts") +;; (@> "Variable icicle-candidate-properties-alist") +;; (@> "What You See Is Not What You Get") +;; +;; (@> "Candidates with Text Properties") +;; (@> "Using Property icicle-special-candidate") +;; (@> "Applying Text Properties to a Candidate String") +;; +;; (@> "Defining Icicles Commands (Including Multi-Commands)") +;; (@> "Nothing To It!") +;; (@> "Multi-Commands Are Easy To Define Too") +;; (@> "Are Users Dependent on Icicles To Use Multi-Commands?") +;; +;; (@> "Defining Icicles Tripping Commands") +;; (@> "Defining Multiple-Choice Menus") +;; (@> "Defining Icicles Multi `M-x'") +;; (@> "How Multi `M-x' is Defined") +;; +;; (@> "Defining Multi-Commands the Hard Way") +;; (@> "Global Filters") +;; (@> "Specifying Match Functions for Commands") +;; (@> "Defining Buffer-Text Completion for Comint Modes") +;; (@> "Note to Programmers") +;; (@> "La Petite Histoire") +;; (@> "Note on Non-nil `pop-up-frames' on MS Windows") + +;;(@* "Icicles Search Commands, Overview") +;; +;; Icicles Search Commands, Overview +;; --------------------------------- +;; +;; This section provides an overview of Icicles search. +;; +;; See Also: +;; +;; * The doc string (`C-h f') of command `icicle-search'; it provides +;; a boatload of general information about Icicles search. +;; +;; * (@> "Other Icicles Search Commands") for specialized Icicles +;; search commands, including search in particular buffers. +;; +;; * (@> "Icicles Info Enhancements") for information about using +;; Icicles to search in Info mode. +;; +;; * (@> "Icicles Bookmark Enhancements") for information about +;; searching bookmarks. +;; +;; * (@> "Support for Projects") for information about using `grep' +;; to search all of the files in a project. +;; +;;(@* "Introduction: On Beyond Occur...") +;; ** Introduction: On Beyond Occur... ** +;; +;; You've no doubt used standard Emacs command `occur'. It finds all +;; lines in a buffer that match a regexp that you enter. It displays +;; the matching lines as links in buffer *Occur* - you can click a +;; link to navigate to the corresponding line in the original buffer. +;; Using buffer *Occur* is similar to using the output of the Emacs +;; `grep' command. +;; +;; Command `icicle-occur' is similar to `occur', but instead of +;; entering a regexp (with `RET') you type a regexp and then use +;; `S-TAB' to show the matching lines in buffer `*Completions*'. As +;; usual in Icicles, you can complete to a single candidate, or cycle +;; among candidates to choose one. To navigate to a match in the +;; original buffer, use `C-RET', `C-mouse-2', `C-next', or `C-prior'. +;; One advantage of `icicle-occur' over `occur' is that you can +;; change the regexp on the fly to match different sets of lines. +;; +;; Another, major advantage is that you can use progressive +;; completion to find lines that match multiple regexps. A similar, +;; but less interactive, effect can be had using chained `grep' +;; commands, but it is otherwise not possible with other search +;; methods such as regexp Isearch. A regexp simply cannot express +;; intersection ("and") except in the limited form of "followed by". +;; +;; Command `icicle-search' is a generalization of `icicle-occur'. +;; You enter an initial, search-context regexp (using `RET'), which +;; defines a set of completion candidates: all of the matching +;; strings in the current buffer (by default). These candidates are +;; called "search contexts". +;; +;; Command `icicle-occur' is really `icicle-search' with an implicit +;; initial regexp of `.*' (which you do not enter, however). That +;; is, the initial completion candidates for `icicle-occur' are all +;; of the lines of the buffer (`.' matches any character except a +;; newline). +;; +;; With `icicle-search', the candidates need not be single, complete +;; lines; they can be any strings in the buffer, including multi-line +;; strings. Your initial regexp is used over and over to find the +;; set of matching strings in the region or buffer that you search. +;; These strings then serve as the completion candidates. +;; +;; For example, you might use a search-context regexp of +;; "[A-Z][^.?!]+[.?!]" to search sentences, "\\(.+\n\\)+" to search +;; paragraphs, or "\\([^\f]*[\f]\\|[^\f]+$\\)" to search pages. +;; (That's in fact how convenience commands +;; `icicles-search-sentences', `icicles-search-paragraphs', and +;; `icicles-search-pages' are defined.) +;; +;; `\f' is the form-feed, or page-separator, character. You input +;; `\f', `\t', and `\n' using `C-q l', `C-q TAB', and `C-j', +;; respectively. See (@> "Dots, Dots, Dots") for information about +;; multi-line dot (`.'), which matches also newline. +;; +;; Again, you can use progressive completion (`M-*' or `S-SPC') to +;; match several different regexps within the same page or the same +;; sentence. For example, you could find all sentences that contain +;; `character', `delete', and `backward', in any order, as follows: +;; +;; C-c ` [A-Z][^.?!]+[.?!] RET +;; character M-* delete M-* backward +;; +;; When you visit a search context, both `icicle-occur' and +;; `icicle-search' highlight that hit. For `icicle-occur', the +;; search context is the current line. For `icicle-search', it is +;; whatever your search-context regexp matches. +;; +;;(@* "How Icicles Search Works") +;; ** How Icicles Search Works ** +;; +;; There are several Icicles search commands, some of which are bound +;; to keys in Icicle mode: +;; +;; `C-c '', `icicle-occur' - An `occur' with icompletion. +;; `C-c `' `icicle-search' - Seach buffer areas that match regexp. +;; `icicle-search-buffer' (`C-1')- Search selected buffers. +;; `icicle-search-file' (`C--') - Search selected files. +;; `icicle-search-bookmarks-together' (`C-u'), +;; `icicle-search-bookmark' - Search bookmarks. +;; `C-c $' `icicle-search-word' - Search for a whole word. +;; `C-c ^' `icicle-search-keywords' - Search with regexp keywords. +;; `C-c `' `icicle-compilation-search' - Search compilation hits +;; (e.g `grep' hits). +;; `C-c "' ["] `icicle-search-text-property' - +;; Search for a given text property value. +;; `C-c =' `icicle-imenu' - Navigate among Imenu entries. +;; `icicle-imenu-command' - +;; Navigate among Emacs command definitions. +;; `icicle-imenu-non-interactive-function' - +;; Navigate among Emacs non-interactive function +;; definitions. +;; `C-c TAB' `icicle-comint-command' - Retrieve a past shell command. +;; +;; All operate in the same general way: +;; +;; 1. Unlike standard incremental search, Icicles search commands +;; search the entire buffer, not just the part that follows the +;; cursor. If the region is active, however, then the search is +;; confined to the region. Some Icicles search commands let you +;; search across multiple buffers, multiple files, or multiple +;; bookmarks, including region bookmarks. Searching within one or +;; more such regions of text is a first way to limit the context +;; of a search. +;; +;; 2. You limit the search context in a second way, by providing some +;; information, such as a regexp or a character property (text or +;; overlay property), that defines zones of text that you want to +;; search. You can use (lax) completion against previous input to +;; enter the regexp or the character property. In some cases, the +;; information (e.g. regexp) to define the search context is +;; provided automatically by the search command; for example, +;; `icicle-occur' assumes that you want to search lines. +;; +;; 3. If you use a regexp to define the search context, and if that +;; regexp has subgroups, that is, subexpressions of the form +;; `\(...\)', then you are prompted for the subgroup to use to +;; define the search context. 0 means the entire regexp match is +;; used as a context. 1 means that whatever the first subgroup +;; matches is used as a context, and so on. +;; +;; Using a subgroup thus limits the search context in a third way. +;; It lets you find a search match within a larger search-match +;; context. For example, you might choose a Lisp argument list as +;; the search context, specifying that it must follow `(defun ': +;; `(defun [^(]*\(([^(]*)\)'. Subgroup 1 is the argument list. +;; Specifying a subgroup search context helps you become more +;; familiar with regexps. Icicles search highlighting (see below) +;; shows you the subgroup matches instantly. +;; +;; 4. You can limit the set of search contexts in a fourth way, by +;; using `M-&' to provide predicates that search-context +;; candidates must satisfy. Command `icicle-search' and its +;; derivative functions use candidates of the form (CONTEXT +;; . MARKER), where CONTEXT is a string, the search hit (search +;; context), and MARKER is a buffer marker that locates the +;; CONTEXT. Predicates you supply to the `M-&' prompt must expect +;; such candidates. Only contexts that satisfy the predicate are +;; found. For example, if the predicate is (lambda (x) (commandp +;; (intern-soft (car x)))), then only contexts that name Emacs +;; commands are found. Or, if you have a predicate `verbp' that +;; tests whether a word is an English verb form, then you can use +;; that to limit word matches to verbs. In this way, you can +;; combine purely syntactic searching (regexp or text-property +;; match) with more semantic search criteria. After building up a +;; complex predicate by using `M-&', you can save it to a variable +;; with `C-M-&' and then reuse it later with `C-='. In addition +;; to, or instead of, using `M-&', you can set user option +;; `icicle-search-context-match-predicate' to a predicate that +;; takes a CONTEXT as argument (the match string only, no MARKER). +;; See also (@file :file-name "icicles-doc1.el" :to "Progressive Completion"). +;; +;; 5. Icicles finds all of the qualified search contexts, and +;; presents them to you as completion candidates. As always for +;; Icicles completion, the number of search hits (matching +;; candidates), is displayed in the mode-line of buffer +;; `*Completions*' - e.g., `72 candidates'. +;; +;; 6. You can navigate among the source-buffer search contexts, using +;; the multi-command action keys (`C-next', `C-prior', `C-RET', +;; `C-mouse-2'). The contexts are highlighted in the source +;; buffer(s). +;; +;; 7. As always in Icicles, your current minibuffer input filters the +;; set of current candidates - the search contexts, so that only +;; those that contain matches to your input remain as candidates. +;; This is a second level of matching: looking for a refinement +;; pattern within the search contexts. And this constitutes a +;; fifth way you can limit the set of search contexts. +;; +;; 8. As always in Icicles, this input can be a regexp. This is +;; ordinary apropos completion, applied to searching. You don't +;; type `RET' to enter this regexp, and you can change it on the +;; fly to change the set of search hits. Icicles searching is +;; thus incremental, in the sense that changing your input +;; dynamically changes the set of matching search hits. Icicles +;; searching is not incremental with respect to the initial, +;; context matching, however. +;; +;; 9. As always in Icicles, you can type some input and then hit +;; `C-~' to remove all candidates that match that input. Then +;; type some other input and hit `C-~' again to remove those +;; matches. Or you can use `M-&' to define a predicate, and then +;; hit `C-~' to remove all candidates that satisfy that predicate. +;; And so on. And you can use `S-mouse-2' or the `delete' key to +;; remove individual search hits. These techniques let you chip +;; away at the search set, removing hits that are uninteresting. +;; This is a very powerful technique for both searching and +;; search-and-replace (see next), and it constitutes a sixth way +;; to limit the set of search contexts. See also +;; (@file :file-name "icicles-doc1.el" :to "Chip Away the Non-Elephant"). +;; +;; 10. You can sort the search hits in various ways. This can +;; facilitate navigation and comparison of hits, as well as +;; search-and-replace (see #11). And you can define your own +;; Icicles search commands that provide custom search orders for +;; particular kinds of search. It is likely that you have never +;; considered being able to sort search hits, but if you think +;; about it you will see that this can be handy. If you are +;; searching across multiple buffers, files, or bookmarks, sorting +;; helps you compare, visit, and replace related hits from the +;; different sources, instead of having to handle all of the hits +;; from each source in turn. +;; +;; 11. You can replace text while you search, forward, backward, or +;; randomly. You can replace entire search contexts or just the +;; parts that match your current input. You can use any +;; replacement string that is allowed by `query-replace-regexp'. +;; In Emacs 22 or later, this includes `\,', to substitute the +;; result of a Lisp evaluation. Use the alternative-action keys +;; for replacement: `C-S-RET', `C-S-mouse-2', `C-S-next', +;; `C-S-prior', `C-S-down', and `C-S-up'. At the first use, you +;; are prompted for the replacement string; it is used thereafter. +;; You can use `M-|' (`icicle-all-candidates-list-alt-action') to +;; replace all matches. See (@> "Search and Replace"). +;; +;; 12. When you visit a search context (using `C-mouse-2' or +;; `C-next', for example), the part of the candidate that matches +;; your input is highlighted. An entire search context is +;; highlighted in face `icicle-search-main-regexp-current', and +;; the part that matches your input is highlighted in face +;; `icicle-search-current-input'. All other search contexts are +;; also highlighted (in face `icicle-search-main-regexp-others'). +;; +;; 13. User option `icicle-search-highlight-all-current-flag' +;; controls whether the input matches are highlighted within each +;; search context or only within the current context. It, +;; together with `icicle-expand-input-to-common-match-flag', +;; controls whether the input-match highlighting covers an +;; expanded common match among all matches or just the exact input +;; match. +;; +;; 14. If you do not use a subgroup to define the search context (as +;; in #3, above), that is, if the search context corresponds to +;; the entire search regexp, then up to eight context levels +;; (subgroups) are each highlighted differently, using faces +;; `icicle-search-context-level-1' through +;; `icicle-search-context-level-8'. This context-level +;; highlighting is not done if user option +;; `icicle-search-highlight-context-levels-flag' is nil. +;; +;; You might have noticed that out of these 14 search features, 6 +;; constitute independent ways in which you can narrow or limit the +;; set of search hits among which you can navigate. And another one +;; (sorting) further facilitates your observation and selection of +;; search hits. Restricting the search space and making search-hit +;; patterns more evident are in fact what search is all about, and +;; Icicles offers you some unique tools to do this. +;; +;; For several Icicles search commands, including `icicle-search' +;; (`C-c `'), you provide an initial regexp to define the search +;; contexts (step 1, above). Why use two regexps to search (steps 1 +;; and 4, above)? To make things simpler. Regular expressions are +;; powerful for searching, but they can also be cumbersome sometimes. +;; Why not use one simple regexp to set up a set of candidates and +;; then, optionally, use a second simple regexp to filter those +;; candidates? +;; +;; This is the same idea as that behind progressive completion. And +;; speaking of which, how would you find a line that contains a given +;; set of words (each of them), but in an arbitrary (unknown) order? +;; Progressive completion. Which lines in this doc section contain +;; the words `which', `you', and `how', in any order? If you are +;; reading this doc in file `icicles-doc2.el', then just use +;; `icicle-occur' with progressive completion: +;; +;; C-c ' which M-SPC you M-SPC how +;; +;; That narrows things down to four lines that you can then navigate +;; among. Progressive completion gives Icicles search a power boost. +;; +;; Like `icicle-occur', commands `icicle-search-word' (`C-c $') and +;; `icicle-search-keywords' (`C-c ^') are variants of `icicle-search' +;; that differ only in the regexp used. Each accepts your input and +;; converts it to a regexp that does the right thing. +;; `icicle-search-word' just adds `\b' before and after the word you +;; type, so that it matches at word boundaries. +;; +;; `icicle-search-keywords' wraps the keywords you provide as input +;; with regexp grouping (`\(...\)') and alternative (`\|') syntax, so +;; that search looks for any of the keywords. +;; +;; "Keywords" here is an understatement. Each keyword is actually a +;; regexp and is treated as such, unless you use `C-`' to turn on +;; escaping of regexp special characters. In that case, each keyword +;; is matched as a substring. At the `C-c $' prompt, you can use +;; completion to choose keywords that you have already entered, or +;; you can use `C-RET' to enter new keywords. +;; +;; As a shortcut, you can use the search string during incremental +;; search (Isearch) as the initial regexp for `icicle-search'. You +;; do this by hitting `S-TAB' during Isearch. This ends Isearch and +;; passes its search string to `icicle-search'. This can be a handy +;; way to start `icicle-search', picking up its search pattern by +;; using, say, `C-s C-w C-w...'. +;; +;; +;;(@* "Search Multiple Buffers, Files, and Bookmarks") +;; ** Search Multiple Buffers, Files, and Bookmarks ** +;; +;; If you provide a prefix argument to most Icicles search functions, +;; then you can search multiple buffers, files, or bookmarks. +;; +;; * Plain prefix argument (`C-u') - Search multiple bookmarks of +;; various kinds. To use this feature, you must also use library +;; `bookmark+.el'. See (@> "Icicles Bookmark Enhancements"). +;; +;; * Non-negative numeric prefix argument (e.g. `C-9') - Search +;; multiple buffers - you are prompted for the buffers to search. +;; If the prefix argument is 99, then only buffers that are +;; visiting files are candidates. You can use `C-RET' and so on to +;; choose individual buffers with completion. You can use `C-!' to +;; choose all buffers or all buffers that match a regexp. +;; (See (@file :file-name "icicles-doc1.el" :to "Multi-Commands").) +;; +;; Note: You can use `M-s i' in Ibuffer or Buffer Menu to search +;; all marked buffers using Icicles search. In Ibuffer, menu item +;; `Icicles Search (and Replace)...' does the same thing as `M-s +;; i'. +;; +;; * Negative numeric prefix argument (e.g. `C--') - Search multiple +;; files in the current directory - you are prompted for the files +;; to search. As for multiple-buffer searching, you can use +;; `C-RET' and so on. +;; +;; Note: You can use `M-s i' in Dired to search all marked files +;; using Icicles search. Menu item `Search (and Replace)...' is +;; added to the Icicles submenu of menu `Multiple' (or `Operate'), +;; and it does the same thing as `M-s i'. +;; +;; As a convenience, some specialized Icicles commands are defined +;; that correspond to `icicle-search' with the various +;; prefix-argument cases: `icicle-search-bookmarks-together', +;; `icicle-search-buffer', and `icicle-search-file'. If you often +;; use `C-c `' with one of the prefix argument options, then you +;; might want to bind one or more of these commands. These commands +;; are also available in the Icicles menu-bar menu (or the Search +;; menu, if it exists). +;; +;;(@* "User Options for Icicles Searching") +;; ** User Options for Icicles Searching ** +;; +;; You can customize the following user options, to control search +;; and replacement behavior. +;; +;; * If `icicle-show-multi-completion-flag' is non-nil (the default +;; value), then, whenever you use a prefix argument, Icicles search +;; functions annotate each candidate with the name of the buffer +;; where the search hit occurs, highlighted, to help orient you. +;; The buffer name is actually part of the (multi-completion) +;; candidate, so you can match against it. +;; +;; Note that even when the value of this option is nil, if option +;; `icicle-help-in-mode-line-flag' is non-nil then you can see the +;; buffer name in the mode-line (as well as the position and length +;; of the search context in the buffer). +;; +;; * Icicles search functions that use an initial regexp highlight +;; the first `icicle-search-highlight-threshold' matches for that +;; regexp at once (using face `icicle-search-main-regexp-others'). +;; The effect is similar to the Emacs 22+ lazy search highlighting +;; of Isearch (except that the highlighting is not in fact lazy). +;; +;; * If `icicle-search-highlight-all-current-flag' is non-nil, then +;; Icicles search functions highlight your current input match +;; within *all* search contexts at once. If it is non-nil and +;; `icicle-expand-input-to-common-match-flag' is also non-nil, then +;; what is highlighted for each input match is the expanded common +;; match among all input matches throughout the search area. If +;; either is nil, then only the exact input match is highlighted. +;; +;; For example +;; (see (@file :file-name "icicles-doc1.el" :to "Nutshell View of Icicles")), +;; if the initial regexp defining the search context is +;; `.*recursive.*', and your input is `edit', then searching file +;; `icicles-doc1.el' highlights not `edit' but +;; ``abort-recursive-edit'', which is the longest common match +;; among all input matches. +;; +;; Gotcha: Remember that the expanded common match pertains to the +;; entire completion candidate. In the context of Icicles +;; search, if you are interested in multiple matches of +;; your input within the same search context, and you want +;; to be sure to catch each match, then turn off +;; common-match expansion. +;; +;; Why? The search context as a whole is compared with the +;; other search contexts when looking for the expanded +;; common match. Your input is matched against the entire +;; context (search hit), and the expanded common match is +;; (typically) the longest match that is common to the +;; other search contexts. Do not expect the longest common +;; match of your input against all occurrences in the +;; search contexts. What counts is the longest single +;; match for a given context. +;; +;; For example, if your input is `then' and two of the +;; search hits are `But then X and then Y' and `W and then +;; Z', the expanded common match will be `and then', not +;; `then'. The matches highlighted for your input thus do +;; not include each occurrence of `then' in the search +;; hits, but rather each occurrence of `and then'. +;; +;; If `icicle-expand-input-to-common-match-flag', +;; `icicle-search-highlight-all-current-flag', and +;; `icicle-search-replace-common-match-flag' are all non-nil, then +;; a search replacement replaces the expanded common match; +;; otherwise, it replaces only the exact match. +;; +;; The default value of `icicle-search-highlight-all-current-flag' +;; is nil, because non-nil can impact performance negatively if +;; there are many search contexts - the highlighting is updated +;; with each input change. You can toggle the value at any time +;; using command `icicle-toggle-highlight-all-current', bound to +;; `C-^' in the minibuffer during Icicles search. +;; +;; * If `icicle-search-cleanup-flag' is non-nil (the default value) +;; then search highlighting is removed after the search. If you +;; set this to nil then you can remove search highlighting manually +;; later using command `icicle-search-highlight-cleanup'. You can +;; toggle this search highlight removal at any time using command +;; `icicle-toggle-search-cleanup', bound to `C-.' in the minibuffer +;; (except during file-name completion). +;; +;; One use of nil `icicle-search-cleanup-flag' is to highlight +;; regexp matches throughout a region or buffer (or multiple files +;; or...). In that capacity, Icicles search functions act like +;; some of the highlighting commands in my library `highlight.el'. +;; Note that when `icicle-search-cleanup-flag' is nil, *all* +;; Icicles search highlighting remains: last-visited search +;; context, other context matches, current-input matches, and even +;; regexp subgroups. The faces for these are, respectively: +;; +;; - `icicle-search-main-regexp-current' +;; - `icicle-search-main-regexp-others' +;; - `icicle-search-highlight-input-matches-here' (everywhere, if +;; `icicle-search-highlight-all-current-flag' is non-nil) +;; - `icicle-search-context-level-1' through +;; `icicle-search-context-level-8' +;; +;; * If `icicle-search-replace-whole-candidate-flag' is nil, then +;; whatever matches your current input is replaced, within the +;; current search context, when you perform replacement +;; (e.g. `C-S-RET'). If the value is non-nil (the default value), +;; then the entire search context is replaced, instead. You can +;; use `C-,' at any time during searching and replacing, to toggle +;; the value. +;; +;; * Command `icicle-search-word' (bound to `C-c $') always searches +;; for a whole word: your initial search string is matched only +;; against whole words. Non-nil `icicle-search-whole-word-flag' +;; makes other Icicles search commands also perform whole-word +;; searching. The search string you type is matched literally, but +;; matches must start and end at word boundaries. Because it is +;; matched literally, all regexp special characters in the search +;; string are escaped. This means, for instance, that you can +;; match `foo-bar' as a word, even in contexts (such as Emacs Lisp) +;; where `-' is not a word-constituent character. Similarly, you +;; can match the literal four-character "word" `f.*g'. You can use +;; `M-q' while searching to toggle this option; the new value takes +;; effect for the next complete search. +;; +;; * You can toggle `icicle-use-C-for-actions-flag' at any time using +;; `M-g' in the minibuffer. This is handy for multi-commands that +;; browse, such as Icicles search. It means that you can use +;; `next' and so on instead of `C-next' and so on to navigate among +;; search hits. See +;; (@file :file-name "icicles-doc1.el" :to "Option `icicle-use-C-for-actions-flag'"). +;; +;; * `icicle-search-hook': Functions run after searching and moving +;; to a match, whether by `RET' or `C-RET' (or `C-next' or +;; `C-prior'). +;; +;; It can sometimes be useful to highlight all regexp matches using a +;; large value of `icicle-search-highlight-threshold' and a nil value +;; of `icicle-search-cleanup-flag', and then set +;; `icicle-search-highlight-threshold' to zero and use an Icicles +;; search function again with a different regexp to search through +;; the same region or buffer. This lets you see the relation between +;; the two sets of regexp matches. +;; +;;(@* "Using Regexps with Icicles Search") +;; ** Using Regexps with Icicles Search ** +;; +;; You can use Icicles search to find text entities of a certain kind +;; - sentences, paragraphs, file names, URLs, and so on. A +;; convenient way to do this is to use `C-=' +;; (`icicle-insert-string-from-variable') or `C-x r i' +;; (`insert-register') in the minibuffer to insert a predefined +;; regexp that matches a particular kind of text entity. Which of +;; these you use depends on whether the regexp string is saved in a +;; variable (`C-=') or a register (`C-x r i'). +;; +;; For example, suppose you are in a mail client and you want to move +;; between mail headers. If you use a regexp that matches the header +;; field you want (e.g. the sent date or sender) then Icicles search +;; highlights all such occurrences and lets you navigate among them - +;; instant mail browser! Or, suppose you are in a C++ or Perl file +;; and you want to navigate among function definitions or other +;; definitions. If you have a canned regexp that matches the start +;; of a definition, then you can use `C-=' to quickly turn +;; `icicle-search' into a code browser. In a log file, navigate +;; among date or time entries or IP addresses... Of course, most +;; programming modes and mail clients already provide other ways to +;; navigate, but you get the idea - Icicles search provides a general +;; way to navigate among things, as long as you can match them with +;; regexps, and `C-=' lets you quickly access a library of predefined +;; regexps. +;; +;; You can find useful regexps to store in variables in the standard +;; Emacs Lisp libraries. Grep for `font-lock-keywords' or `regexp' +;; in the Emacs `lisp' directory and its subdirectories. +;; +;; See `align.el' for regexps for programming languages. +;; See `url-dav.el' for regexps matching ISO 8601 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 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_\\)+\\)" +;; +;; You certainly do not want to type a regexp like that into the +;; minibuffer (and the function-definition regexp is twice as +;; complex)! Put it into a variable or register once and use `C-=' +;; or `C-x r i' from then on to retrieve it - simple. +;; +;; If it's so simple, then why not let a command do it? This is +;; exactly what command `icicle-imenu' (bound to `C-c =') does. You +;; don't need to bother looking up Imenu regexps and assigning them +;; to variables for use with `C-=' and `icicle-search'- +;; `icicle-imenu' does that for you automatically. +;; See (@> "Other Icicles Search Commands"). +;; +;; In sum: For complete interactivity, type a regexp dynamically as +;; input to `icicle-search'. For isolated special regexps that you +;; use, save them in variables and use `C-=' with `icicle-search'. +;; For well-defined sets of regexps, especially if used frequently, +;; define a command that uses `icicle-search'. There is a spectrum +;; of use cases for `icicle-search'. +;; +;; Command `icicle-search' is very general and very powerful. It +;; might never replace incremental search - either regexp or literal +;; string search, but in some cases it can be quite handy. Think of +;; it as another tool to add to your search-tool belt. Admittedly, +;; it does take a little getting used to. Remember, in particular, +;; that the initial, context regexp you enter (with `RET') cannot be +;; changed without re-executing `icicle-search'. +;; +;; And remember too that `C-l' (`icicle-retrieve-previous-input') is +;; your friend - it clears the minibuffer during cycling, retrieving +;; your last real input. Use it to modify your second and subsequent +;; regexps on the fly - those that filter the initial candidate list +;; further. You can repeat `C-l' to retrieve older completion +;; inputs, and you can use `C-S-l' (that is, `C-L') to cycle previous +;; inputs in the other direction. See +;; (@file :file-name "icicles-doc1.el" :to "History Enhancements"). +;; +;; Oh - And don't forget that you can do things like take the +;; complement of your fine-tuning regexp matches, within the context +;; of your coarse-tuning matches. See +;; (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates"). +;; +;; For example, use `^.*defun.*$' as the main regexp, to find all +;; lines containing `defun'. Then type `icicle' to match only the +;; lines with `defun' that also contain `icicle'. Then complement +;; (`C-~') that set, to see the lines that contain `defun' but not +;; `icicle'. +;; +;; And you can then save that set of matches, and then subtract it +;; from another set of matches in a different search... You get the +;; idea. When performing set operations combined with +;; `icicle-search', keep in mind that the saved set does not include +;; any position information - it is only a set of matching strings. +;; So, in particular, a set-union operation (`C-+') is not useful +;; with `icicle-search' (adding a saved set of strings without +;; positions is useless). Still, you can do things like match lines +;; that contain `defun' followed somewhere by `()', and then subtract +;; the (saved) set of lines in the same region that contain `icicle'. +;; Try it in an Icicles library, using regexps `.*icicle.*$' and +;; `^*.defun.*().*$'. +;; +;; One more reminder: When you save a set of completion candidates +;; (`C-M->'), make sure that you actually have a set of candidates to +;; save! It is not enough to just enter a regexp at the +;; `icicle-search' prompt. You must also use some Icicles command, +;; such as `TAB', `S-TAB', `next', or `down' to tell Icicles how to +;; create the candidate set - how to match the regexp. +;; +;; See Also: +;; +;; * The doc string (`C-h f') of command `icicle-search'; it provides +;; general information about Icicles search. +;; +;; * (@> "Other Icicles Search Commands") for specialized Icicles +;; search commands `icicle-comint-search', +;; `icicle-compilation-search', `icicle-imenu', +;; `icicle-imenu-command', `icicle-imenu-non-interactive-function', +;; `icicle-search-char-property', `icicle-search-keywords', +;; `icicle-search-overlay-property', and +;; `icicle-search-text-property'. +;; +;; * (@> "Search and Replace") for information about replacing search +;; hits or parts of search hits. +;; +;; * (@> "Customization and General Tips") for information about the +;; `icicle-search-*' faces, which control Icicles search. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Progressive Completion") +;; for information about `M-*' and `M-&'. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Multi-Commands") for +;; information about `C-RET', `C-mouse-2', `C-next', and `C-prior'. +;; +;; * (@> "Icicles Bookmark Enhancements") for information about +;; searching bookmarks. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Inserting a Regexp from a Variable or Register") +;; for more about inserting a saved string. +;; +;; * (@> "Icicles Info Enhancements") for information about using +;; Icicles to search in Info mode. + +;;(@* "Search and Replace") +;; +;; Search and Replace +;; ------------------ +;; +;; Replacement during Icicles search is something quite different +;; from anything you are used to. There are several different ways +;; to replace search-hit text during Icicles search, and it can be a +;; bit of a challenge to understand all the possibilities. So my +;; advice is to experiment, as well as to read the descriptions here. +;; +;; You can replace the current search match by using any of the +;; alternative action keys: `C-S-RET', `C-S-mouse-2' (in +;; `*Completions*'), `C-S-next', `C-S-prior', `C-S-down', and +;; `C-S-up'. You can use `M-|' +;; (`icicle-all-candidates-list-alt-action') to replace all matches +;; of your current input at once, throughout the search space. +;; +;; At the first use of any of these, you are prompted for the +;; replacement pattern; it is used thereafter, or until you use `M-,' +;; (`icicle-search-define-replacement'). You can use `M-,' at any +;; time during searching to change the pattern for subsequent +;; replacements. The replacement pattern can be anything that is +;; allowed as a replacement by `query-replace-regexp'. In Emacs 22 +;; or later, this includes Lisp sexp evaluation via `\,'. +;; +;; Unlike `query-replace', you need not visit each search match - you +;; can visit and replace selected matches in any order. Some other +;; differences from standard `query-replace' and +;; `query-replace-regexp': +;; +;; * Replacing matches of your current input provides a contextual +;; replacement feature: replace `foo' by `fu', but only in zones +;; that match `toto.*titi'. +;; +;; * Icicles search navigation (`C-next', etc.) lets you replace +;; individual search hits without navigating through each search +;; context in turn: direct access. +;; +;; * In Icicles search, replace-all (`M-|') means replace all +;; matches of your current input, throughout the search space, not +;; just all matches that follow the cursor. And remember that you +;; can (a) activate the region to limit the search-and-replace +;; space and (b) use progressive completion etc. to narrow the set +;; of hits. +;; +;; * You can act across multiple buffers, files, or bookmarks - +;; see information about the `icicle-search' prefix arg. +;; +;; * You can also replace matches within character-property search +;; contexts - just use `icicle-search-char-property' (`C-c "') ["] +;; as the search command. +;; +;; Search matches are replaced - but just what is meant by a "search +;; match"? It can be either an entire search context or each match +;; of your current minibuffer input within a search context. +;; +;; Anytime during search and replace: +;; +;; * `M-,' redefines the replacement string. +;; +;; * `C-`' toggles `icicle-toggle-regexp-quote' (as always). This +;; escapes regexp special characters, so that search is literal. +;; +;; * `M-q' toggles `icicle-search-whole-word-flag'. By default, +;; this is nil, meaning that searching is not for whole words +;; (except for `icicle-search-word', bound to `C-c $'). +;; +;; * `C-M-`' toggles `icicle-search-replace-literally-flag'. By +;; default, this is nil, which means that `\' character sequences +;; in replacement text are intrepreted as for +;; `query-replace-regexp'. +;; +;; * `C-,' toggles `icicle-search-replace-whole-candidate-flag'. By +;; default, this is non-nil, which means that the entire current +;; search context is replaced, that is, whatever matches the +;; context regexp that you entered initially using `RET'. +;; However, you can use `C-,' anytime during searching to toggle +;; between this default behavior and replacement of whatever your +;; current minibuffer input matches. +;; +;; * `M-;' toggles `icicle-search-replace-common-match-flag'. +;; Together with other options, it controls whether to replace the +;; expanded common match or just the exact match. See below. +;; +;; REMEMBER THIS: +;; +;; - If `icicle-search-replace-whole-candidate-flag' is true +;; (non-nil), then the granularity of replacement is a complete +;; search context. In this case, replacement behaves similarly to +;; `query-replace-regexp' (except that special replacement +;; constructs, such as `\#', are not treated as such). You can +;; still use minibuffer input to filter the set of search contexts, +;; but replacement is on a whole-context basis. +;; +;; - If `icicle-search-replace-whole-candidate-flag' is false (nil), +;; then you can replace multiple input matches separately within a +;; search context (using `C-S-RET'). This behavior is unique to +;; Icicles. You cannot, however skip over one input match and +;; replace the next one in the same context - `C-S-RET' always +;; replaces the first available match in the context (repeated use +;; changes which is first). When +;; `icicle-search-replace-whole-candidate-flag' is nil, you can +;; also use special replacement constructs, such as `\#'. +;; +;; If `icicle-search-replace-whole-candidate-flag' is true, then you +;; can use the navigational alternative action keys, `C-S-next', +;; `C-S-prior', `C-S-down', and `C-S-up', repeatedly to replace +;; successive search contexts. At the buffer limits, these commands +;; wrap around to the other buffer limit (last search context to +;; first, and vice versa). +;; +;; Search traversal using these go-to-next-context-and-replace keys +;; is always by search context, not by individual input match. This +;; means that you cannot use these keys to replace input matches +;; within a search context. +;; +;; If `icicle-search-replace-whole-candidate-flag' is false, then you +;; can use these keys to replace the first input match. More +;; importantly, you can use `C-S-RET' to replace that first match, +;; without moving on to the next context. Because `C-S-RET' always +;; acts on the current search hit (context), using it again, after +;; you have used it to replace the first such match, replaces the +;; next one. And so on. +;; +;; Thus, if your input matches multiple parts of a search context and +;; you want to replace these matches, use `C-S-RET' repeatedly. +;; After all of the matches in the current context have been +;; replaced, `C-S-RET' replaces the first match in the next context. +;; (There is a gotcha, however, if the replacement text matches your +;; input - see below.) +;; +;; You can thus traverse all matches of your input, in the current +;; sort order (by default, the order they appear in the source being +;; searched), by just repeating `C-S-RET'. At the buffer limits, +;; repeating `C-S-RET' wraps around. +;; +;; `C-S-RET' always replaces the first input match in the +;; current search context or, if there are no matches, then the first +;; input match in the next context. This behavior has these +;; important consequences: +;; +;; * If you repeat `C-S-RET' and the previous replacement no longer +;; matches your input, then `C-S-RET' moves on to the next input +;; match (which is now the first one) and replaces that. This is +;; why you can usually just repeat `C-S-RET' to successively +;; replaces matches of your input, including from one context to +;; the next. +;; +;; * If, on the other hand, after replacement the text still matches +;; your input, then repeating `C-S-RET' will just replace that +;; match. For example, if you replace the input match `ab' by +;; `abcd', then repeating `C-S-RET' produces `abcd', then `abcdcd', +;; then `abcdcdcd',... +;; +;; * You cannot replace an input match, skip the next match, and then +;; replace the following one, all in the same context. You can, +;; however, replace some matches and then skip (e.g. `C-next') to +;; the next context. +;; +;; What your input matches, hence what gets replaced if +;; `icicle-search-replace-whole-candidate-flag' is nil, depends on a +;; few Icicles options: +;; +;; - `icicle-regexp-quote-flag' determines whether to use regexp +;; matching or literal matching. +;; +;; - `icicle-search-highlight-all-current-flag', +;; `icicle-expand-input-to-common-match-flag' and +;; `icicle-search-replace-common-match-flag' together determine +;; whether to replace exactly what your input matches in the +;; current search hit or the expanded common match (ECM) of your +;; input among all search hits. If any of these options is nil, +;; then your exact input match is replaced; otherwise, the ECM is +;; replaced. +;; +;; The replacement string can be nearly anything that is allowed as a +;; replacement by `query-replace-regexp'. In Emacs 22 or later, this +;; includes Emacs-Lisp sexp evaluation via `\,' and constructs such +;; as `\#' and `\N' (back references). You can also use `\?', but it +;; is not very useful - you might as well use `M-,' instead, to +;; change the replacement text. +;; +;; Finally, let me repeat what I said at the beginning of this page: +;; Icicles search-and-replace is different from what you are used to, +;; and there are several different ways to use it. Experiment to get +;; to know how it works, and reread the description here. +;; +;; It is important to understand the various user options (with their +;; toggle commands) and their effects. They can radically change the +;; behavior of replacement. +;; +;; In particular, to put Icicles search-and-replace to best advantage +;; you need to know what gets replaced, depending on those user +;; options: the whole search hit vs only input matches, an exact +;; input match vs the expanded common match. Experiment with the +;; toggles `M-_', `C-^', `C-;', and `M-;'. And you need to know how +;; repeated `C-S-RET' works vs repeated `C-S-next'. +;; +;; I know it's tricky to learn. Experimenting helps. If something +;; happens that you didn't expect, reread this section and try to +;; understand. Have fun. +;; +;; See Also: +;; +;; * (@> "Icicles Search Commands, Overview") and the doc string of +;; `icicle-search' for more information about search-and-replace. +;; +;; * (@> "Compile/Grep Search") for information about using +;; search-and-replace with `grep' buffers and compilation buffers. +;; +;; * (@* "Icicles Dired Enhancements") for information about using +;; search-and-replace on marked files in Dired. + +;;(@* "Other Icicles Search Commands") +;; +;; Other Icicles Search Commands +;; ----------------------------- +;; +;; Function `icicle-search' is very general. As is explained in +;; (@> "Icicles Search Commands, Overview"), command `icicle-occur' +;; is defined trivially using `icicle-search' - it is basically +;; `icicle-search' with a regexp of `.*', to match lines. Similarly, +;; `icicle-search-word' (`C-c $') uses a regexp of `\bWORD\b', where +;; `WORD' is the word to look for, and `icicle-search-keywords' +;; (`C-c ^') uses a regexp of `\(KW1\|KW2\|KW2...\|KWn\)', where the +;; `KWm' are the keywords (regexps) to look for. +;; +;; Still other Icicles commands are available that make use of +;; `icicle-search'. And you can define your own, specialized search +;; commands along the same lines. To do that, it is instructive to +;; look at the source code of the commands described in this section; +;; they can serve as a model for defining your own search commands. +;; +;; Two of the commands described here, `icicle-compilation-search' +;; and `icicle-comint-search', are specialized versions of +;; `icicle-search' that work only in particular buffers where there +;; is little need for `icicle-search' itself. For this reason, these +;; commands reuse the key sequence, `C-c `' (backquote), that is +;; normally bound to `icicle-search'. This shadow binding occurs if +;; the current major mode is a compilation mode (for +;; `icicle-compilation-search') or an interactive interpreter mode +;; such as `shell-mode' or Lisp interactive mode (for +;; `icicle-comint-search'). +;; +;; [Programmer Note: Actually, the way this works is that `C-c `' is +;; bound to the value of internal variable `icicle-search-generic'. +;; You can use this mechanism to provide custom Icicles search +;; commands for particular buffers.] +;; +;; Besides the commands described in this section, there are Icicles +;; search commands for navigating tags-file definitions and searching +;; their associated source files. These are described in section +;; (@> "Icicles Tags Enhancements"). +;; +;; If you use `M-g' in the minibuffer to toggle option +;; `icicle-use-C-for-actions-flag', then you can use just `next' +;; instead of `C-next' to navigate when using any Icicles search +;; command. See +;; (@file :file-name "icicles-doc1.el" :to "Option `icicle-use-C-for-actions-flag'"). +;; +;;(@* "Searching Text with Properties") +;; ** Searching Text with Properties ** +;; +;; Instead of providing a context regexp, for commands +;; `icicle-search-char-property' (`C-c "') ["], +;; `icicle-search-overlay-property', and +;; `icicle-search-text-property' you provide a character property +;; (e.g. `face') and its value (e.g. `font-lock-function-name-face'). +;; All zones of text that have that property with that value become +;; the completion candidates (search hits). As always, you can +;; filter this set of candidates by typing input in the minibuffer. +;; +;; By a "character property" is meant either a text property or an +;; overlay property. `C-c "' ["] searches both kinds of character +;; property; `icicle-search-overlay-property' searches only overlay +;; properties; and `icicle-search-text-property' searches only text +;; properties. For example, if you use `C-c "' ["] with a `face' +;; property value `highlight', then the text searched includes text +;; with that overlay value and text with that text-property value. +;; With a `face' property value of `font-lock-string-face', you can +;; browse or search doc strings, and so on. +;; +;; If the property chosen is `face', then you can in fact choose +;; multiple faces, in multi-command fashion (e.g. `C-mouse-2'), and +;; the text that is searched has at least one of the faces you +;; choose. If you choose no face value (empty input), then the +;; target is text that has any face at all. The search hits are +;; zones of text that are distinguished by their `face' values. +;; +;; As with other Icicles search commands, a prefix argument controls +;; whether these character-property commands search the current +;; buffer, selected bookmarks, selected files, or selected buffers. +;; However, keep in mind that, since in this case you are searching +;; character properties, you will find search hits only for buffers +;; that already have such properties, for example, buffers that have +;; been fontified. +;; +;;(@* "Icicles Imenu") +;; ** Icicles Imenu ** +;; +;; Command `icicle-imenu', which is bound to `C-c =', is an Imenu +;; browser. It lets you use Icicles completion to navigate among +;; definitions of functions, variables, types, keys, and so on in a +;; programming language (in fact, any language that Imenu handles). +;; As always in Icicles, your current input (e.g. a regexp) filters +;; the set of available candidates. That is, you can match against +;; parts of an Imenu entry - any parts. That's particularly useful +;; if there are many entries in the Imenu menu; you don't need to +;; read/scan the whole list. +;; +;; If you look at the definition of `icicle-imenu' you'll see that it +;; simply lets you choose an Imenu submenu (Functions, User Options, +;; and so on) that is appropriate for the current buffer type, and +;; then it calls `icicle-search', passing it the appropriate Imenu +;; regexp. You can similarly define your own specialized search +;; commands using `icicle-search' to browse regexp matches. You get +;; all of the features of `icicle-search' when you do that. For +;; example, `icicle-imenu' gives you these advantages over a standard +;; Imenu menu: +;; +;; * You can restrict navigation (search) to a region. +;; +;; * You can navigate (browse) among multiple entries, instead of +;; choosing them one by one from a menu. +;; +;; * You can restrict the entries to browse using (regexp) pattern +;; matching. +;; +;; * As for `icicle-search', you can search multiple bookmarks, +;; multiple buffers, or multiple files. +;; +;; In addition, for Emacs-Lisp function definitions, Icicles provides +;; two specializations of `icicle-imenu', to find only Emacs command +;; definitions and only non-interactive function (that is, +;; non-command) definitions: `icicle-imenu-command' and +;; `icicle-imenu-non-interactive-function'. The definitions of these +;; two search commands provide examples of using `icicle-search' with +;; a predicate argument. +;; +;;(@* "`icicle-imenu' Combines Benefits of Imenu and Emacs Tags") +;; *** `icicle-imenu' Combines Benefits of Imenu and Emacs Tags *** +;; +;; * Imenu lets you navigate among definitions in a single buffer. +;; +;; * Emacs tags let you navigate among definitions in multiple files, +;; but you must build and update the tags file that identifies the +;; definitions. +;; +;; Like Emacs tags, `icicle-imenu' lets you navigate among +;; definitions in multiple files - and also multiple bookmarks and +;; multiple non-file buffers. Like Imenu, you need not build a tags +;; file. Unlike Imenu, Icicles provides regexp completion that lets +;; you filter Imenu hits that you want to visit. +;; +;; Another difference from Emacs tags, besides the need for a tags +;; file, is that, since Icicles locates definitions using Imenu +;; regexps, you can only navigate among definitions in buffers that +;; you are visiting. This is both an advantage and a disadvantage: +;; you can narrow the search to certain files, but you must know +;; which files to search. And if you want to search all files, then +;; you must open them all (e.g. by matching a project regexp), +;; +;; The differences mean that `icicle-imenu' does not provide a +;; substitute for Emacs tags; it provides some similar +;; functionality. It is another tool in your belt, handier in some +;; situations than using tags, and less useful in some other +;; situations. +;; +;; See Also: (@> "Icicles Tags Enhancements") +;; +;;(@* "Compile/Grep Search") +;; ** Compile/Grep Search ** +;; +;; In a compilation-results buffer, such as `*Compilation* or +;; `*grep*', you can use command `icicle-compilation-search', bound +;; to `C-c `', to search among the result set (search hits). This is +;; similar to `icicle-search', but when you use `C-RET', `C-mouse-2', +;; `C-prior', `C-next', `C-up', or `C-down', it visits the source +;; code that corresponds to the current line in the compilation +;; buffer. Just as for `icicle-search', you can narrow the set of +;; search contexts by typing a regexp. +;; +;; Using `icicle-compilation-search' with `grep' gives you two levels +;; of regexp searching: 1) the `grep' regexp and 2) your current +;; input regexp. And you can of course use progressive completion +;; (`M-*') to add any number of additional levels. (And, starting +;; with Emacs 22, you can pipe to other `grep' commands in the same +;; `M-x grep'.) +;; +;; In Emacs 22 and later, you can also replace search-hit text. You +;; can replace the entire grep regexp match or just the part of it +;; that matches your current input, depending on the value of option +;; `icicle-search-replace-whole-candidate-flag' (which you can toggle +;; with `C-,'). Replacement acts here just as it does for +;; `icicle-search'. +;; +;; You can also use a non-`grep' compilation buffer to perform search +;; and replace. Use it, for example, to correct errors in source +;; files. +;; +;; Icicles thus gives you several ways to perform search-and-replace +;; throughout multiple files: `grep'/compilation, `icicle-occur', and +;; `icicle-search'. The latter is of course not limited to +;; line-by-line search. +;; +;; See Also: (@> "Search and Replace"). +;; +;;(@* "Input Reuse in Interactive Interpreter Modes") +;; ** Input Reuse in Interactive Interpreter Modes ** +;; +;; In an interactive interpreter mode such as `shell-mode' or +;; interactive Lisp mode, you can search for and reuse a previous +;; input, possibly editing it first. Command `icicle-comint-search', +;; bound to `C-c `', lets you use Icicles completion and cycling to +;; access your previous (shell or Lisp) inputs; it uses +;; `icicle-search', so it highlights your regexp input matches, and +;; so on. You can use `C-$' at any time to toggle removal of +;; duplicate past inputs as completion candidates; by default, +;; duplicates are removed. +;; +;; Being a search command, however, `icicle-comint-search' has access +;; only to the commands that are visible in the buffer. It does not +;; use the `comint-input-ring', so it cannot, for instance, give you +;; access to commands used in a previous session, which might have +;; been recorded in a history file. +;; +;; Another Icicles command, `icicle-comint-command', which is not a +;; search command, does use `comint-input-ring' and does give you +;; completion and cycling against previous inputs that might not have +;; come from the current session. It is bound to `C-c TAB' in +;; `comint-mode' and derived modes. +;; +;;(@* "Define Your Own Icicles Search Commands") +;; ** Define Your Own Icicles Search Commands ** +;; +;; Function `icicle-search' is not only a useful user command; it is +;; also a framework for you to define your own Icicles search +;; commands. Consult the source code for the commands presented +;; above for models. And consult the doc string of `icicle-search' +;; for more information about calling it non-interactively. In +;; particular, note that: +;; +;; * You can pass a functional argument instead of a regexp to +;; `icicle-search', and it will use that function to define the +;; search contexts. The function is passed, as arguments, the +;; buffer to search, the beginning and end of the search region in +;; that buffer, and any additional arguments that you pass to +;; `icicle-search'. +;; +;; * You can pass a predicate argument to `icicle-search', in +;; addition to passing a regexp, and the search contexts will be +;; only those regexp matches that also satisfy the predicate. The +;; predicate takes two arguments, the search-context string and a +;; marker at the end of the search context. For information about +;; this, consult the doc string for function +;; `icicle-search-regexp-scan'. For a model of using this feature, +;; see the code that defines command `icicle-imenu'. +;; +;; By using your own function to define the search contexts, either +;; from scratch or by limiting regexp matches using a predicate, you +;; can perform semantic-based searching. That is, your search +;; command can use information besides syntax to define search hits. +;; For instance, commands `icicle-imenu-command' and +;; `icicle-imenu-non-interactive-function' use the semantic predicate +;; `commandp' to distinguish Emacs-Lisp commands from non-interactive +;; functions. +;; +;; See Also: +;; +;; * (@> "Icicles Search Commands, Overview") for general information +;; about Icicles search and the commands `icicle-search' and +;; `icicle-occur'. +;; +;; * (@> "Search and Replace") for information about replacing search +;; hits or parts of search hits. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Multi-Commands") for +;; information about using `C-RET', `C-mouse-2', `C-prior', +;; `C-next', `C-up', and `C-down'. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Progressive Completion") +;; for information about using any number of search regexps with +;; `M-*' and any number of search predicates with `M-&'. +;; +;; * (@> "Icicles Info Enhancements") for information about using +;; Icicles with Info mode. + +;;(@* "Icicles Bookmark Enhancements") +;; +;; Icicles Bookmark Enhancements +;; ----------------------------- +;; +;; Many of the enhancements described in this section are available +;; only if you also use library `bookmark+.el' (which I recommend). +;; Bookmark+ is compatible with vanilla Emacs bookmarks across +;; multiple Emacs versions. It enhances the use of bookmarks in many +;; ways. The explanation here does not attempt to describe the +;; Bookmark+ enhancements; it describes only the Icicles features +;; that make use of them. +;; +;; One of the main Bookmark+ enhancements is support for new bookmark +;; types. Icicles provides type-specific bookmark commands and +;; bookmark-candidate filtering. +;; +;; Regardless of the bookmark type, another Bookmark+ feature that +;; Icicles takes advantage of is the fact that a bookmark (any +;; bookmark) can save not only a single position but a region, that +;; is, two positions. You can think of this as bookmarking, or +;; saving, regions. When you jump to a region bookmark, the region +;; is activated (if option `bmkp-use-region' is non-nil). +;; +;; These are the main Icicles bookmarking features: +;; +;; * Bookmarking the region and selecting a bookmarked region +;; * Setting a bookmark and jumping to a bookmark +;; * Searching the text of a bookmark's buffer or region +;; +;; Each is described in more detail below. +;; +;; In addition, when you complete the names of some kinds of objects, +;; you can use `C-x m' to choose objects of that type. For example, +;; when you use `icicle-dired' (`C-x d') to complete a directory +;; name, you can use `C-x m' to choose among your Dired bookmarks. +;; See (@file :file-name "icicles-doc1.el" :to "Accessing Saved Locations (Bookmarks) on the Fly"). +;; +;;(@* "Saving Regions and Selecting Them") +;; ** Saving Regions and Selecting Them ** +;; +;; Saving the region just means bookmarking it. As for any bookmark, +;; it must have a name. When you later jump to a region bookmark, +;; the region is activated (provided option `bmkp-use-region' is +;; non-nil). +;; +;; Icicles gives you quick ways to save a region and select +;; (activate) a saved region. You can do both using `C-x C-x'. +;; +;; * With no prefix arg, `C-x C-x' exchanges point and mark +;; (activating the region), as usual. +;; +;; * With a plain prefix arg (`C-u'), `C-x C-x' jumps to a region +;; bookmark that you choose using completion, and activates it. +;; +;; * With a numeric prefix arg, `C-x C-x' saves the region. If the +;; prefix arg is negative, then you are prompted for the name to +;; use. Otherwise, the bookmark is named automatically using the +;; buffer name plus ": " plus the first +;; `icicle-bookmark-name-length-max' characters of the region text. +;; (Newline characters are changed to spaces for the name.) +;; +;; So if (a) you are visiting buffer `foo', (b) the region text +;; starts with "Arise, you wretched of the earth! For justice +;; thunders condemnation: A better world's in birth!", and (c) the +;; value of option `icicle-bookmark-name-length-max' is 15, then +;; `C-9 C-x C-x' sets the region bookmark named `foo: Arise, you'. +;; +;;(@* "Setting a Bookmark and Jumping to a Bookmark") +;; ** Setting a Bookmark and Jumping to a Bookmark ** +;; +;; Just as `C-x C-x' lets you either set or jump to a region +;; bookmark, so `C-x r m' lets you either set or jump to any +;; bookmark. `C-x r m' is the vanilla Emacs key for setting a +;; bookmark. In Icicle mode it is bound by default to command +;; `icicle-bookmark-cmd'. (By default, whatever keys are normally +;; bound to `bookmark-set' are remapped in Icicle mode to +;; `icicle-bookmark-cmd'.) +;; +;; * With no prefix arg or a plain prefix arg (`C-u'), `C-x r m' acts +;; like `icicle-bookmark-set'. This is similar to `bookmark-set', +;; but if you use Bookmark+ then you can use (lax) completion, +;; choosing from existing bookmarks for the same buffer. This +;; makes it easy to update a nearby bookmark. +;; +;; The same completion enhancements are available as for bookmark +;; jumping - see (@> "Jumping to a Bookmark"), below. +;; +;; * With a negative prefix arg, `C-x r m' jumps to a bookmark (with +;; completion). See (@> "Jumping to a Bookmark"), below. +;; +;; * With a non-negative prefix arg, `C-x r m' sets a bookmark, +;; automatically naming it. This is like the automatic naming for +;; a region bookmark, except that instead of including a prefix of +;; the region text, the name includes text from the current line +;; that starts at point. +;; +;; So if the cursor in buffer `foo' is on the `y' in a line with +;; the text "Arise, you wretched of the earth!", then the bookmark +;; will automatically be named `foo: you wretch'. +;; +;; If the prefix argument is 0, then the new bookmark does not +;; overwrite any existing bookmark with the same name. +;; +;;(@* "Jumping to a Bookmark") +;; ** Jumping to a Bookmark ** +;; +;; Icicles commands that jump to a bookmark are multi-commands: you +;; can use them to jump to any number of bookmarks in a single +;; invocation. Each jump command acts as a bookmark browser. +;; +;; As with most Icicles tripping commands, after you jump to a +;; (non-region) bookmark, the cursor position is highlighted using +;; cross hairs, if you also use library `crosshairs.el'. +;; +;; Bookmark names are highlighted in buffer `*Completions*' to +;; indicate the bookmark type. The faces used are those defined by +;; Bookmark+. +;; +;; If option `icicle-show-multi-completion-flag' is non-nil, then +;; each completion candidate is a multi-completion, with up to three +;; parts: the bookmark name, the bookmark file or buffer name, and +;; any (del.icio.us-style) tags the bookmark has. You can toggle +;; option `icicle-show-multi-completion-flag' (for the next command) +;; using `M-m' during completion. +;; +;; When using multi-completion candidates, you can match any of the +;; multi-completion parts. For example, you can match all bookmarks +;; that have any tags by typing this when choosing a bookmark: +;; +;; C-M-j . * C-M-j S-TAB +;; +;; Or match all bookmarks whose names match `P42' and whose tags +;; match `blue': +;; +;; P 4 2 . * C-M-j . * C-M-j . * b l u e S-TAB +;; +;; (Each `C-M-j' inserts `^G\n', which is `icicle-list-join-string'.) +;; +;; `C-M-RET' shows detailed info about the current bookmark +;; completion candidate. `C-u C-M-RET' shows the complete, internal +;; info for the bookmark. Likewise, for the other candidate help +;; keys: `C-M-down' etc. And the mode line always shows summary +;; info about the current bookmark. +;; +;; During bookmark completion you can sort the candidates in various +;; bookmark-specific ways: +;; +;; * By the current (latest) `*Bookmark List*' order +;; * By bookmark name +;; * By last access as a bookmark (date + time) +;; * By bookmark visit frequency (number of times visited) +;; * By last buffer or file access (date + time) +;; * With marked bookmarks before unmarked (in `*Bookmark List*') +;; * By file name +;; * By (local) file type +;; * By (local) file size +;; * By last (local) file access (date + time) +;; * By last (local) file update (date + time) +;; * By Info location (manual and node) +;; * By Gnus thread +;; * By URL +;; * By bookmark type +;; +;; The most general Icicles jump commands are `icicle-bookmark' and +;; `icicle-bookmark-other-window'. In Icicle mode these are bound to +;; whatever `bookmark-jump' and `bookmark-jump-other-window' are +;; normally bound to. If you use Bookmark+, the default bindings are +;; `C-x j j' and `C-x 4 j j', respectively. +;; +;; When you use these commands, you can narrow the completion +;; candidates to bookmarks of a specific type using these keys: +;; +;; `C-M-b' - non-file (buffer) bookmarks +;; `C-M-B' - bookmark-list bookmarks +;; `C-M-d' - Dired bookmarks +;; `C-M-f' - file bookmarks +;; `C-M-F' - local-file bookmarks +;; `C-M-g' - Gnus bookmarks +;; `C-M-i' - Info bookmarks +;; `C-M-K' - desktop bookmarks +;; `C-M-m' - `man' pages +;; `C-M-r' - bookmarks with regions +;; `C-M-u' - URL bookmarks +;; `C-M-w' - W3M (URL) bookmarks +;; `C-M-@' - remote-file bookmarks +;; +;; In addition, there are individual jump commands for bookmarks of +;; each of each type, and these commands are bound by default to keys +;; with the prefix `C-x 4 j' that use the same mnemonic characters as +;; for narrowing. For example, `icicle-bookmark-info-other-window' +;; is bound to `C-x 4 j i'. +;; +;; Commands `icicle-bookmark' and `icicle-bookmark-other-window' can +;; use a cache for the set of available bookmarks. This improves +;; performance, especially if you have a lot of bookmarks. The +;; downside is that the list of completion candidates is not +;; automatically updated when you add new bookmarks. +;; +;; By default, this caching is off, so the set of possible bookmark +;; candidates is always up-to-date. You can turn on this caching by +;; setting option `icicle-bookmark-refresh-cache-flag' to nil. +;; +;; Alternatively, you can use a prefix argument to reverse the effect +;; of this option. If you have a lot of bookmarks then I recommend +;; that you customize the option to nil and just update it +;; occasionally by using `C-u' for bookmark completion. That will +;; temporarily turn off caching so that the current jump command +;; refreshes (updates) the cache. The default value of the option is +;; t only to avoid confusion for new users. +;; +;; The bookmarks cache is also used for searching bookmarks (see +;; next). The type-specific bookmark jump commands +;; (e.g. `icicle-bookmark-info-other-window') do not use the cache, +;; since they typically use a smaller number of candidates. And the +;; cache is automatically updated whenever you use `S-delete' to +;; delete a candidate bookmark. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Icicles Tripping") +;; +;;(@* "Searching Bookmarked Objects") +;; ** Searching Bookmarked Objects ** +;; +;; Icicles search (and replace) lets you search across multiple +;; buffers, files, or bookmarks. This is true for nearly all Icicles +;; search commands. You use a plain prefix argument to specify +;; bookmark searching. For command `icicle-search' itself (`C-u C-c +;; `'), you can alternatively use the specific command +;; `icicle-search-bookmarks-together'. +;; +;; When you do this you first choose the bookmarks to search, using +;; completion. Use `C-RET' and similar multi-command actions to +;; choose (use `RET' for the final choice). Once you have chosen the +;; bookmarks, you type a search pattern to narrow the set of +;; candidates. +;; +;; (Multi-command `icicle-bookmark-list' similarly lets you choose +;; bookmark names. It returns them as a Lisp list of strings.) +;; +;; When you search the text of a region bookmark, the search is +;; limited to the region. +;; +;; In addition to using `C-u' with the general Icicles search +;; commands, you can use the following Icicles search commands that +;; are specific to bookmarks: +;; +;; * icicle-search-bookmark +;; * icicle-search-bookmark-list-bookmark +;; * icicle-search-dired-bookmark +;; * icicle-search-file-bookmark +;; * icicle-search-gnus-bookmark +;; * icicle-search-info-bookmark +;; * icicle-search-local-file-bookmark +;; * icicle-search-man-bookmark +;; * icicle-search-non-file-bookmark +;; * icicle-search-region-bookmark +;; * icicle-search-remote-file-bookmark +;; * icicle-search-url-bookmark +;; +;; All of these except `icicle-search-bookmark' act only on bookmarks +;; of a specific type. But all of them act the same way. They are +;; multi-commands, so you can use them to search multiple bookmarks. +;; But unlike `icicle-search-bookmarks-together' (`C-u C-c `'), you +;; do not first choose all of the bookmarks and then search them +;; together. Instead, you search them one at a time. +;; +;; See Also: +;; +;; * (@> "Icicles Search Commands, Overview") for information about +;; command `icicle-search'. +;; * (@> "Jumping to a Bookmark") for information about bookmark +;; caching. Caching is also used for bookmark searching. +;; * (@> "Support for Projects") + +;;(@* "Icicles Tags Enhancements") +;; +;; Icicles Tags Enhancements +;; ------------------------- +;; +;; In Emacs and Icicles, the word "tag" is used in multiple ways. +;; This section is about tags as identifiers of source-code +;; definitions. Emacs uses tags files, typically named `TAGS', to +;; index these definition locations. +;; +;; What constitutes a "definition" is determined by the content of +;; the tags file. Typically, definition recognition is available for +;; programming languages, but in fact a tags table can record any +;; text at all as a definition. That is, if you create your own tags +;; table, you can use the Emacs tags feature to navigate among any +;; "definitions" of your own choosing. +;; +;; If you use `M-g' in the minibuffer to toggle option +;; `icicle-use-C-for-actions-flag', then you can use just `next' +;; instead of `C-next' to navigate when using any of the Icicles tags +;; browsing commands described here. See +;; (@file :file-name "icicles-doc1.el" :to "Option `icicle-use-C-for-actions-flag'"). +;; +;; See Also: +;; +;; * (@> "Support for Projects") +;; * (@file :file-name "icicles-doc1.el" :to "File-Name Input and Locating Files Anywhere") +;; +;;(@* "`icicle-find-tag': Find Tags in All Tags Tables") +;; ** `icicle-find-tag': Find Tags in All Tags Tables ** +;; +;; In vanilla Emacs, you use commands such as `find-tag' (`M-.') to +;; find a tag, `tags-loop-continue' (`M-,') to find another matching +;; tag, `tags-apropos' to list all tags that match a regexp, and +;; `list-tags' to show all tags (definitions) in a given source file. +;; +;; In Icicles, you can use multi-command `icicle-find-tag', bound to +;; `M-.' in Icicle mode, to do all of this. It is similar to the +;; Icicles search commands. It is a general tags browser, just as +;; `icicle-imenu' is an Imenu browser. Being a multicommand, you can +;; visit any number of tags, in any order, in a single `M-.' +;; invocation. +;; +;; With `icicle-find-tag', you enter (using `RET') a regexp to match +;; the tags you want to visit. By default, all tags in all tags +;; files are searched, and the matches become completion candidates +;; (which you can of course match further by typing another pattern). +;; As always, you can use progressive completion, chip away the +;; non-elephant, and so on. Just as with Icicles search commands, +;; you use `C-RET', `C-mouse-2', `C-next', and so on, to visit the +;; search hits. You can use `M-*' (`icicle-pop-mark') to return to +;; the place you invoked `M-.'. +;; +;; By default, the completion candidates are multi-completions: the +;; source file name is included. This is an important aid, because +;; there can be similar, or even identical, tags in different source +;; files. Your current input can of course filter the source-file +;; name also, excluding certain files from the search. +;; +;; A prefix argument changes the default behavior, as follows: +;; +;; * If non-negative (>= 0), then only the current tag table is used, +;; instead of all tag tables. +;; +;; * If non-positive (<= 0), then the source file name is not part of +;; the completion candidate; only the tag itself is used. +;; +;; See Also: +;; +;; * (@> "Icicles Search Commands, Overview") for general information +;; about Icicles search commmands. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Nutshell View of Icicles") +;; for information about progressive completion and chipping away +;; the non-elephant. +;; +;;(@* "`icicle-find-first-tag': Find First Tag in Current Table") +;; ** `icicle-find-first-tag': Find First Tag in Current Table ** +;; +;; Sometimes you don't need the full power and flexibility of +;; `icicle-find-tag'. If you just want to find the first tag among +;; several duplicates that match your input, and you just want to use +;; the current tags table, then you can use `icicle-find-first-tag' +;; or `icicle-find-first-tag-other-window'. These commands are like +;; vanilla `find-tag', but they are multi-commands, so you can visit +;; any number of tags in one invocation. Unlike `find-tag', however, +;; you cannot follow up to find another tag that matches using `M-,'. +;; +;;(@* "`icicle-tags-search': Search and Replace Using Tags") +;; ** `icicle-tags-search': Search and Replace Using Tags ** +;; +;; In vanilla Emacs, you use commands `tags-search', +;; `tags-query-replace', and `tags-loop-continue' (`M-,') to search +;; and replace text in source files whose definitions are indexed in +;; a tags file. +;; +;; In Icicles, you can use multi-command `icicle-tags-search' to +;; search and replace. It is in fact just command `icicle-search' +;; applied to the relevant source files. +;; +;; See Also (@> "Icicles Search Commands, Overview") for information +;; about `icicle-search. + +;;(@* "Icicles Shell-Command Enhancements") +;; +;; Icicles Shell-Command Enhancements +;; ---------------------------------- +;; +;; Icicles provides completion support for shell commands in these +;; ways: +;; +;; * In Shell mode and related modes, it enhances completion of +;; commands, previous inputs (commands plus their switches and +;; arguments), file names, and environment variables. +;; See (@> "Completion in Comint Modes"). +;; +;; * In any buffer, it provides Icicles completion for `M-!' and +;; `M-|'. +;; +;; * In Dired mode, it provides Icicles completion for `!', and `&'. +;; See (@> "Shell Commands on Marked Files"). +;; +;; This section describes the completion available for `M-!' and +;; `M-|'. It applies also to completion for `!', and `&' in Dired +;; (but those have additional enhancements). +;; +;; In vanilla Emacs, when you enter a shell command at the prompt for +;; `M-!' or `M-|', no completion is available for Emacs prior to +;; Emacs 23. In Emacs 23, no completion is available for empty +;; input, and non-empty input is completed only to a shell command in +;; your search path. +;; +;; In Icicle mode, `M-!' and `M-|' can, like in vanilla Emacs 23, +;; complete using commands on your search path. This depends on the +;; the value of option `icicle-guess-commands-in-path' (see below). +;; +;; The most significant thing about Icicles completion for reading a +;; shell command is that it is enhanced *file-name* completion. This +;; means that you can easily invoke a program no matter where it +;; resides, whether or not its directory is in your search path. You +;; can use completion to navigate to the command's location. +;; +;; Icicles shell-command completion is lax, so you can enter any +;; command you want, not just a completion candidate, and you can +;; edit completed input, to add switches (options) and arguments. +;; +;; Though file-name completion is used for reading shell commands, +;; extra, known commands are also made available as completion +;; candidates if option `icicle-guess-commands-in-path' is non-nil +;; (it is nil by default). These extra candidates are the names of +;; all executable files (or of all files, if +;; `shell-completion-execonly' is nil) in your search path. +;; +;; The fact that these are Icicles *extra* candidates means that they +;; are available regardless of the current default-directory - they +;; are not in fact treated as file-name candidates, even though they +;; are available during file-name completion. You can easily +;; recognize Icicles extra candidates in buffer `*Completions*': they +;; have face `icicle-extra-candidates'. See (@> "Global Filters"). +;; +;; If `icicle-guess-commands-in-path' is non-nil, the list of +;; search-path candidate commands is computed once and cached as the +;; value of option `icicle-shell-command-candidates-cache'. The +;; particular non-nil value of `icicle-guess-commands-in-path' +;; determines when the cache is filled. +;; +;; If the value of `icicle-guess-commands-in-path' is `first-use', +;; the cache is filled the first time you use it, and each time you +;; turn on Icicle mode it is updated. If the value of +;; `icicle-guess-commands-in-path' is `load', then the cache is +;; instead filled each time you load Icicles. +;; +;; Regardless of the non-nil value of +;; `icicle-guess-commands-in-path', if you save +;; `icicle-shell-command-candidates-cache', then that value is used +;; in future sessions (no delay for searching your path). +;; +;; If your environment changes, you can use command +;; `icicle-recompute-shell-command-candidates' to update the cached +;; list at any time. With a prefix argument, the updated value is +;; saved persistently. +;; +;; In addition to the extra candidates computed by searching your +;; search path, in contexts such as Dired where target (e.g. marked) +;; files for the shell command are known, the extra candidates +;; include additional commands (possibly including switches) that +;; Icicles can guess might be appropriate for the target files. +;; See (@> "Shell Commands on Marked Files"). +;; +;; During shell-command completion, help is available for individual +;; candidates, using `C-M-RET', `C-M-mouse-2', and so on. For an +;; extra candidate, help is provided for the command by the `apropos' +;; shell command (if available). For a file-name candidate, help +;; shows the file's properties. See +;; (@file :file-name "icicles-doc1.el" :to "Get Help on Candidates"). +;; +;; Remember also: +;; +;; * After you have typed or completed the shell command per se +;; (e.g. a file name or search-path command), you can use `C-M-S-f' +;; (file-name completion on demand) to complete (relative) file +;; names to insert as shell-command arguments as part of the +;; command line to submit to the shell. See +;; (@file :file-name "icicles-doc2.el" :to "Completion On Demand"). +;; +;; * You can use `M-o' anytime in the minibuffer to complete against +;; a previous input. This means that if you have previously +;; entered some complex shell command (e.g. with various switches +;; or arguments), then you can use `M-o' to retrieve it for reuse +;; (possibly editing it). See +;; (@file :file-name "icicles-doc2.el" :to "Using Completion to Insert Previous Inputs: `M-o'") +;; +;; * If for some reason you do not want to use the enhancements +;; described here, just customize option +;; `icicle-redefine-standard-commands-flag' to nil. If you do +;; that, then Icicle mode will not substitute any Icicles commands +;; for standard commands. + +;;(@* "Icicles Dired Enhancements") +;; +;; Icicles Dired Enhancements +;; -------------------------- +;; +;; Icicles can help with Dired in these ways: +;; +;; * You can use completion when you use `!' or `&' to execute a +;; shell command. +;; +;; * You can use Icicles search-and-replace on the marked files. +;; +;; * You can save marked file names as completion candidates for +;; reuse later. +;; +;; * You can open Dired on saved file names, that is, names that you +;; previously saved as a completion candidates set or as an Emacs +;; fileset. It does not matter how the file names were saved or +;; which directories the files are in. +;; +;;(@* "Shell Commands on Marked Files") +;; ** Shell Commands on Marked Files ** +;; +;; In Icicle mode, `!' and `&' in Dired let you complete a shell +;; command. All Icicles completion features are available. This is +;; the same program-file completion that is available anywhere when a +;; shell command is read (see +;; (@> "Icicles Shell-Command Enhancements")), but in Dired the extra +;; candidates include commands that Icicles thinks might be +;; particularly appropriate for the marked files. +;; +;; These extra candidates are not necessarily only command names. +;; They can include switches (options) that specialize a command. +;; For example, if a PDF file (*.pdf) is marked in Dired, the +;; completion candidates might include `gv -safer', `pdftotext ? -', +;; and `xpdf'. The first two of these are not just command names +;; (`-safer' is a command switch). +;; +;; Starting with Emacs 23, Icicles uses both of the following methods +;; to guess extra candidates that are file type-specific: +;; +;; * MIME-type associations +;; +;; * The rules defined by user option `dired-guess-shell-alist-user' +;; and variable `dired-guess-shell-alist-default' (provided you use +;; Dired X, that is, standard library `dired-x.el') +;; +;; Prior to Emacs 23, MIME types are not used. In the example of a +;; PDF file, candidates `gv -safer' and `pdftotext ? -' are provided +;; by MIME-type associations, and candidate `xpdf' is provided by the +;; Dired X rules. Note that you can customize the rules. +;; +;; Any candidates that are specific to the marked files are Icicles +;; *extra* candidates -- see (@> "Global Filters"). These are +;; available regardless of the current default-directory. They are +;; not treated as file-name candidates, even though they are +;; available during file-name completion. Icicles extra candidates +;; have face `icicle-extra-candidates' in buffer `*Completions*'. +;; +;; Again, everything that is true for shell-command completion +;; elsewhere is also true for shell-command completion in Dired. See +;; (@> "Icicles Shell-Command Enhancements"). This includes adding +;; all commands from your search path as extra candidates if option +;; `icicle-guess-commands-in-path' is non-nil, and providing help on +;; individual candidates (shell commands or files) during completion. +;; +;;(@* "Search-and-Replace Marked Files") +;; ** Search-and-Replace Marked Files ** +;; +;; In Dired, `A' searches the marked files using a regexp, and `Q' +;; launches `query-replace-regexp' on them. But suppose that you +;; want to change only a few occurrences in each file, perhaps among +;; the first occurrences. Using `Q', you are forced to review each +;; search hit in turn - all of them; you cannot simply skip the rest +;; in one file and continue with the next file. +;; +;; [I suggested that this feature be added to Emacs, and it has been +;; added in Emacs 23: you can now skip to the next file.] +;; +;; One workaround is to use `M->' to go to the end of a file, and +;; then `M-,' to resume query-replace. Or you can quit the command +;; altogether, unmark the file you're finished searching, and then +;; hit `Q' again, but that's not very convenient. A similar problem +;; applies to searching using `A'. +;; +;; In Dired with Icicles, you can use `M-s i' +;; (`icicle-search-dired-marked') to search the files and possibly +;; replace search hits. This runs `icicle-search', so you have +;; available all of its features, including accessing search hits +;; directly, in any order. To skip a whole file, just match its name +;; with your minibuffer input and then use `C-~' to remove all of its +;; occurrences from the set of hits. +;; +;; Note: You can similarly use `M-s i' in Ibuffer or Buffer Menu to +;; search all marked buffers using Icicles search. +;; +;;(@* "Save Marked Files as Completion Candidates") +;; ** Save Marked Files as Completion Candidates ** +;; +;; In Dired with Icicles, you can use `C-M->' +;; (`icicle-dired-save-marked') to save the marked file names as a +;; set of completion candidates, for reuse later. You can use `C->' +;; to add the marked files to an existing saved set of candidates. +;; These bindings act similarly to `C-M->' and `C->' in the +;; minibuffer: a prefix argument controls whether you save candidates +;; to a variable or a cache file. +;; +;; You can use such a saved set of file names as candidates during +;; file-name completion. They are saved as absolute names, +;; which means you can use them with, say, `C-u C-x C-f'. See +;; (@file :file-name "icicles-doc1.el" :to "Absolute File Names and Different Directories"). +;; +;;(@* "Open Dired for a Set of File Names") +;; ** Open Dired for a Set of File Names ** +;; +;; In Dired with Icicles you can use `C-M-<' +;; (`icicle-dired-chosen-files-other-window') to open Dired for a set +;; of file or directory names that you choose interactively or that +;; you have previously saved (persistently or not) as completion +;; candidates or as an Emacs fileset. The Dired buffer that is +;; created is named `Icy File Set' (suffixed with <1>, <2>, etc. as +;; needed), and it contains only the chosen file names. +;; +;; The file names are checked to be sure they reference existing +;; files. If any of the names are relative names, those files are +;; checked for existence in the Dired directory. If you use a prefix +;; argument, then you are prompted for the directory to use. +;; +;;(@* "Marked Files as a Project") +;; ** Marked Files as a Project ** +;; +;; Just as `C-}' in the minibuffer is a shortcut for `C-u C-M->', +;; which saves the current set of completion candidates persistently, +;; so `C-}' in Dired saves the marked file names in a cache file or, +;; with a prefix arg, an Emacs fileset. Similarly, just as `C-{' in +;; the minibuffer is a shortcut for `C-u C-M-<', which retrieves +;; candidates from a persistent set, so `C-{' in Dired retrieves a +;; persistent set of file names and opens them in a separate Dired +;; buffer. +;; +;; You can think of such persistent file-name sets as projects. +;; `C-}' is bound to command `icicle-dired-save-marked-as-project' +;; (aka `icicle-dired-save-marked-persistently'). `C-{' is bound to +;; command `icicle-dired-project-other-window'. +;; +;; Again, you can use such a project as a candidate set for file-name +;; completion at any time. In addition, `C-}' and `C-{' can be handy +;; in Dired for working with projects even without using completion. +;; The files in a project can be distributed among any directories +;; anywhere. This gives you an easy way to open Dired on just the +;; files you want and operate on them there. +;; +;; And while in a project in Dired you can use `C-M-<' to mark a +;; project subset to work on, and then use `C-M->' to operate on that +;; subset using Icicles completion. And you can have any number of +;; projects - you access each by its name (with completion) and need +;; not remember its cache file name. +;; +;; +;; See Also: +;; +;; * (@> "Icicles Shell-Command Enhancements") for more information +;; about shell-command completion +;; +;; * (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates") +;; for information about saved completion candidates +;; +;; * (@file :file-name "icicles-doc1.el" :to "Chip Away the Non-Elephant") +;; for the use of `C-~' to remove matching candidates +;; +;; * (@> "Icicles Search Commands, Overview") for information about +;; `icicle-search' +;; +;; * (@> "Search and Replace") for how to replace selected search hits +;; +;; * (@file :file-name "icicles-doc1.el" :to "Persistent Sets of Completion Candidates") +;; for more information about using persistent sets +;; +;; * (@> "Support for Projects") for more information about working +;; with projects +;; +;; * Library `dired+.el', which has related features such as `C-M-*' +;; to open Dired on just the marked files and `M-g' to `grep' just +;; the marked files. + +;;(@* "Icicles Info Enhancements") +;; +;; Icicles Info Enhancements +;; ------------------------- +;; +;; Icicles can help with Info in these ways: +;; +;; * Icicles completion is available for any input. +;; +;; * You can use `icicle-search' on part or all of a manual, if you +;; flatten it first with `Info-merge-subnodes' . +;; +;;(@* "Icicles Completion for Info") +;; ** Icicles Completion for Info ** +;; +;; Whenever completion is available for Info commands, such as `g' +;; (`Info-goto-node'), `i' (`Info-index'), and `m' (`Info-menu'), you +;; can take advantage of Icicles completion. For instance, if you +;; type `g yan', you can use `S-TAB' for apropos completion and +;; choose node `Isearch Yank', whose name contains `yan' but does not +;; start with it. This is an obvious and standard Icicles feature. +;; +;; Although vanilla Emacs also accepts a substring as input for `i', +;; it does not provide substring or regexp completion, and it won't +;; accept a regexp as final input. +;; +;; Icicles binds `g', `i', and `m' to multi-commands +;; `icicle-Info-goto-node', `icicle-Info-index', and +;; `icicle-Info-menu', which means that you can also use `g', `i', +;; and `m' with `C-next', `C-RET', `C-mouse-2', and so on, to browse +;; among matching Info nodes. Unlike browsing with repeated use of +;; `,' after `i' in vanilla Emacs, you can continue to see all of the +;; matching candidates, in buffer `*Completions*', and you need not +;; visit the index hits in sequential order. +;; +;; If you use `M-g' in the minibuffer to toggle +;; `icicle-use-C-for-actions-flag', then you can use just `next' +;; instead of `C-next' to navigate. See +;; (@file :file-name "icicles-doc1.el" :to "Option `icicle-use-C-for-actions-flag'"). +;; +;; As usual in Icicles, you can sort completion candidates in various +;; ways, using `C-,' (`icicle-change-sort-order'). For `g', in +;; particular, although the default order is alphabetical, you can +;; choose `in book order', which shows the node candidates in the +;; same order as in the book. In that case, using `g' and then +;; navigating among candidates sequentially using `C-up', `C-down', +;; `C-next', or `C-prior' visits the nodes in their natural order. +;; +;; As a special case of this, if you use a negative prefix argument +;; (that is, `M-- g'), then not only are the candidate nodes +;; presented `in book order', they are also limited to the nodes that +;; follow your current location in the book - that is, to the +;; remainder of the book. (A non-negative numeric prefix argument +;; has the same meaning as for `Info-goto-node'.) +;; +;; In addition, except when you are at the `Top' node, a pseudo-node +;; `..' is added to the set of completion candidates. Choosing this +;; takes you up to the parent of the current node. You can thus use +;; `g' in Info not only to explore nodes by name, but also as another +;; means to traverse the Info menu hierarchy. +;; +;;(@* "Virtual Info Books") +;; *** Virtual Info Books *** +;; +;; You can take advantage of Icicles completion-candidate set +;; operations to create your own virtual Info books. That is, you +;; can define and save sets of Info nodes or Info index entries, and +;; then reuse them later. +;; +;; Both `m' and `g' in Info use nodes as candidates, so you can use +;; `m' or `g' or a combination of `m' and `g' to define a node set, +;; and you can use either `m' or `g' to reuse a node set. A set of +;; index entries is different: You must use `i' to create and reuse +;; such a set. +;; +;; Remember that you can define a candidate set incrementally, adding +;; more elements using `C->', `C-)', `insert', `M-S-mouse-2', +;; `M-mouse-3', or `mouse-1 mouse-3 mouse-3'. And you can save a +;; candidate set persistently. +;; +;; You can even create a virtual book that includes Info nodes from +;; different manuals. For example, you might want to collect +;; together specific nodes that deal with some particular topic, such +;; as faces, from both the Emacs manual and the Elisp manual. +;; +;; You do this using `C-u g' (a plain prefix argument). This +;; prepends the Info file name (book identifier) to each node-name +;; completion candidate. For example, when you are in the Emacs +;; manual, each node candidate is prefixed by `(emacs)', and in the +;; Elisp manual each candidate is prefixed by `(elisp)'. You define +;; a set of candidates in the usual Icicles ways, changing manuals as +;; needed to add additional nodes to the set you save. +;; +;; A node name prefixed by its file name is analogous to an absolute +;; file name, that is, a relative file name prefixed by its +;; directory. Because such a saved candidate has a book prefix, +;; e.g. `(emacs)', it is absolute and unambiguous. You can use it +;; wherever you happen to be in Info, to go directly to that node. +;; This is a feature of `g' even in vanilla Emacs: you can go to a +;; node in a different manual from the one you are currently +;; visiting. +;; +;; When you want to reuse a virtual book, hit `g' again, retrieve the +;; saved set of node candidates that defines the book, and navigate +;; among the saved nodes. +;; +;; If you use library `info+.el', you can also take advantage of its +;; definition of virtual books and saved Info nodes. That library +;; defines command `Info-virtual-book', which opens Info on a Table +;; of Contents of a virtual book of nodes that you have saved either +;; using command `Info-save-current-node' or by customizing user +;; option `Info-saved-nodes'. +;; +;; Icicles command `icicle-Info-virtual-book' extends +;; `Info-virtual-book' by letting you define the virtual book nodes +;; using completion. That is, you can use `g' to save a set of +;; node-name completion candidates (as the value of variable +;; `icicle-saved-completion-candidates'), and then use command +;; `icicle-Info-virtual-book' to open an Info buffer with those nodes +;; as a menu. +;; +;; If you have not saved any node-name candidates, then +;; `icicle-Info-virtual-book' acts the same as `Info-virtual-book': +;; it opens the virtual book that is defined by `Info-saved-nodes'. +;; With `info+.el', the key `.' adds the current node to +;; `Info-saved-nodes', which gives you a convenient way to build up a +;; virtual book as you read. This is like Emacs bookmarking, but it +;; keeps your saved Info nodes separate from your other bookmarks. +;; +;; With a prefix argument, `icicle-Info-virtual-book' lets you choose +;; a persistently saved completion set to use instead of +;; `icicle-saved-completion-candidates' or `Info-saved-nodes'. This +;; means that you can have any number of such saved node sets as +;; virtual books, to use at any time. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates") +;; for information about defining, saving, and reusing sets of +;; completion candidates. +;; +;; * (@> "Icicles Bookmark Enhancements") for information about using Info bookmarks. +;; +;;(@* "Using Icicle-Search With Info") +;; ** Using Icicle-Search With Info ** +;; +;; Icicles searching (`icicle-search') is not Isearch. It searches +;; for all matches in the portion of text you tell it to search. +;; This means that you cannot use it to search an entire manual in +;; one operation, unless you have the entire manual available in a +;; single buffer to be searched. +;; +;; So, when you use `icicle-search' (`C-c `') to search with Info, +;; you are limited to a few options: +;; +;; * You can use it normally, to search within a single Info node. +;; +;; * You can widen the visible portion of the Info buffer +;; (`C-x n w'), to use it on an entire Info file. However: +;; +;; 1. It is not obvious how a given Info manual is divided into +;; files. That is, you need to be aware of the point at which +;; the manual moves from one file to the next. +;; +;; 2. Only the nodes in the same file that you have already visited +;; are highlighted, and lots of ugly Info "plumbing" becomes +;; visible in the other nodes. +;; +;; 3. You lose all Info features, such as navigation using links. +;; +;; * There is another way to search across nodes, which addresses #1 +;; and #2, but still does not give you navigable links and such. +;; Think of it as a hack that can sometimes be handy. That is what +;; is described below. +;; +;; The idea is to flatten a subtree of Info nodes - possibly an +;; entire manual, but more typically a node and its children - and +;; then use `icicle-search' (`C-c `') over that flattened document. +;; What is needed is a command that flattens Info subtrees. Library +;; `info+.el' provides such a command, `Info-merge-subnodes', and +;; binds it to `+' in Info. +;; +;; You can control how you want the flattening to occur, by using +;; different values of prefix argument. For searching, you probably +;; want complete flattening of the chosen subtree, in a single +;; buffer, so you use a prefix arg of zero: `C-u 0 +'. +;; +;; This does not replace the *Info* buffer that you started with; it +;; creates a new buffer, named after the root node of the subtree you +;; flattened. A principle use of `Info-merge-subnodes' is to print +;; out a manual or a portion of it. Also, I wrote a library +;; (`mkhtml.el', outdated now) that lets you convert the result to +;; HTML. +;; +;; In sum, you can use Icicles search in Info: `C-u 0 +', then +;; `C-c `'. +;; +;; One caveat, however: You will generally want to limit your search +;; to a reasonably small subtree of a manual, instead of flattening +;; and then searching the entire manual. Flattening a large manual +;; can take a while: it took me 10 minutes to flatten the Emacs +;; Manual. Of course, you could flatten a large manual once, and +;; save the result in a file for later searches. +;; +;; Obviously, flattening in order to search is less convenient than +;; using manual-wide incremental search (`C-s') with Info (starting +;; with Emacs 22), and it is often less convenient than using +;; `Info-search' (bound to `s' in Info). Icicles searching is +;; different from both, and it has its advantages and disadvantages. +;; When you want the advantages of Icicles searching in Info, the +;; flattening hack can be useful. When you don't need those +;; advantages, other search methods can sometimes be more +;; appropriate. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Multi-Commands") for +;; information on using multi-commands. +;; +;; * (@> "Icicles Search Commands, Overview") for information about +;; command `icicle-search'. +;; +;; * Library `info+.el' for information about `Info-merge-subnodes'. + +;;(@* "Support for Projects") +;; +;; Icicles Support for Projects +;; ---------------------------- +;; +;; This section mainly provides pointers to other sections of the +;; Icicles doc that describe features that can help you work with a +;; project that involves multiple files, buffers, or bookmarks. +;; +;; +;;(@* "Bookmarks for Project Access and Organization") +;; ** Bookmarks for Project Access and Organization ** +;; +;; If you use Bookmark+ (library `bookmark+.el'), then you can use +;; bookmarks of various types, including the following, to help +;; manage software projects: +;; +;; * Dired buffers, with specific sets of files and subdirectories +;; that are marked or omitted, and using specific listing switches. +;; +;; * `*Bookmark List*' buffers, with specific sets of bookmarks that +;; are marked or hidden. +;; +;; * Multiple alternative bookmark files. For example, use a +;; different one for each project. Or use different ones for +;; subprojects and use them together for a full project. +;; +;; * Desktops, which include sets of variables and visited buffers +;; and files. +;; +;; * Composite, or sequence, bookmarks, which combine other +;; bookmarks. +;; +;; You can also associate tags, in the del.icio.us sense, with most +;; types of bookmarks. (Such tags are unrelated to the Emacs +;; source-code tags that use tags files.) A bookmark can have any +;; number of tags, and multiple bookmarks can have the same tag, +;; which means you can use them to organize their target objects. +;; And tags can be more than just names: they can be user-defined +;; attributes, with Emacs-Lisp objects as their values. +;; +;; These and other Bookmark+ features give you different ways to +;; save, restore, filter, access, and otherwise organize projects, as +;; collections of information about source-code components and +;; related software. +;; +;; Icicles enhances access to such features. +;; See (@> "Icicles Bookmark Enhancements"). +;; +;;(@* "A Tags File Can Define a Project") +;; ** A Tags File Can Define a Project ** +;; +;; One simple kind of a project includes the files that are in or +;; under a single directory. Such a project is limited, but it can +;; often be useful, and it has the advantage of being supported by +;; several existing Emacs features. +;; +;; Another simple kind of project includes the files that are listed +;; in a given Emacs tags file. This is obviously more complex and +;; flexible than a directory listing. +;; +;; Icicles provides multi-commands for visiting one or more files +;; that are listed in the current tags table: +;; `icicle-find-file-in-tags-table' and +;; `icicle-find-file-in-tags-table-other-window'. See also +;; (@file :file-name "icicles-doc1.el" :to "Icicles Commands that Read File Names"). +;; +;;(@* "Navigating Among Code Definitions") +;; ** Navigating Among Code Definitions ** +;; +;; For software projects, you need to be able to navigate among code +;; definitions. Imenu and Emacs tags features are useful for this, +;; as are `grep' and compilation buffers. Icicles improves all of +;; these. (A tags file is just a saved index for project files.) +;; +;; See Also: +;; +;; * (@> "Icicles Imenu") +;; * (@> "Icicles Tags Enhancements") +;; * (@> "Compile/Grep Search") +;; +;;(@* "Searching Project Files") +;; ** Searching Project Files ** +;; +;; Searching within your project is another area where Icicles can +;; help. Icicles search is both search and navigation. Navigating +;; among tags definitions that match a regexp is also really +;; searching, and the same is true for Imenu and grep navigation. +;; +;; See also (@> "Icicles Search Commands, Overview") and its +;; subsections for information about the many ways that you can use +;; Icicles search to access parts of your projects. +;; +;; See also (@> "Icicles Dired Enhancements") for an easy way to +;; search marked files in Dired with Icicles search. +;; +;; See also (@> "Searching Bookmarked Objects") for ways to search +;; bookmarked objects, including the files that have a given set of +;; del.icio.us-style tags and the bookmarks that are marked in a +;; given bookmark-list state. +;; +;; And don't forget that all uses of Icicles search also let you do +;; search-and-replace on the fly. This applies to `grep' results, +;; searching marked files in Dired, tags navigation, and Imenu +;; navigation. You can at any time replace the current search hit +;; or just the part of it that matches your current input. +;; +;;(@* "Defining and Saving Sets of Files or Buffers") +;; ** Defining and Saving Sets of Files or Buffers ** +;; +;; Let's assume that you have one or more sets of files or buffers +;; that you use frequently. For each such set of objects, you create +;; an Emacs option whose value is a list of the file or buffer names +;; (strings). +;; +;; Later, you use the option value to refer to those objects by name. +;; This brings you back to the context of working with just those +;; particular files or buffers that belong to your project. You can +;; search such sets or navigate among their objects. Icicles has a +;; number of features that can help with these tasks. +;; +;; Note: Bookmarks are also persistent references to files and +;; buffers, and you can use sets of bookmarks similarly. Bookmarking +;; is a vanilla Emacs feature. Being able to manipulate explicit +;; sets of bookmarks is a Bookmark+ feature (library `bookmark+.el'). +;; Bookmarking features are described elsewhere, but they work in +;; concert with Icicles to offer very good project support. +;; See (@> "Icicles Bookmark Enhancements"). +;; +;; Before you can name and save a set of file or buffer names, you +;; must define its members: pick the file and buffer names that you +;; want to belong to a given project. Icicles can help with this. +;; +;; For buffers, use commands `icicle-add-buffer-config' and +;; `icicle-remove-buffer-config' to define one or more buffer +;; configurations. These are named sets of buffers, sort functions, +;; and other parameters that control completion of buffer names. +;; Thereafter, you can use command `icicle-buffer-config' to choose a +;; configuration to be current. +;; +;; To define a set of files, you use Icicles completion against file +;; names. You can use progressive completion, chip away the +;; non-elephant, and so on, to get just the file names you want. +;; +;; For this completion, you can use a command that calls +;; `read-file-name', and so matches relative file names using the +;; current `default-directory'. Or you can use a command that calls +;; `completing-read', and so matches file names only as ordinary +;; strings, that is, with no notion that they are file names. In the +;; latter case, the file names are often absolute, which means that +;; you can match not only file names but also directory components. +;; +;; Examples of the former type are `icicle-find-file' and +;; `icicle-find-file-read-only' (`C-x C-r' by default). Examples of +;; the latter type are `icicle-find-file-absolute', +;; `icicle-find-file-in-tags-table', `icicle-recent-file', and +;; `icicle-locate-file'. Command `icicle-file' (bound to `C-x C-f' +;; by default) lets you do both, depending on the prefix argument. +;; +;; You save a set of file names the same way you save any set of +;; completion candidates. You can save all of the names that match +;; your current input. You can add a set of names or individual +;; names to a set of names that you have already saved. +;; +;; In addition, you can save the marked files in Dired as a set of +;; project files. +;; +;; Your project is not only files that are all in the same directory, +;; of course. You can save file names from multiple directories in +;; the same set. And you can include directory names as well, for +;; use later with commands that operate on directories. Finally, you +;; can also save file names as Emacs filesets and use those the same +;; way. An Icicles set of saved file names can include Emacs +;; filesets - see +;; (@file :file-name "icicles-doc1.el" :to "Filesets and Icicles Saved Completion Sets"). +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates") +;; * (@file :file-name "icicles-doc1.el" :to "Persistent Sets of Completion Candidates") +;; * (@> "Icicles Bookmark Enhancements") +;; * (@file :file-name "icicles-doc1.el" :to "Progressive Completion") +;; * (@file :file-name "icicles-doc1.el" :to "Chip Away the Non-Elephant") +;; * (@file :file-name "icicles-doc1.el" :to "File-Name Input and Locating Files Anywhere") +;; * (@> "Save Marked Files as Completion Candidates") (Dired) +;; +;;(@* "Retrieving and Reusing a Saved Project") +;; ** Retrieving and Reusing a Saved Project ** +;; +;; This section could also be called "Using Retrieved Saved Sets". +;; +;; You retrieve a set of saved file names (a project) the same way +;; you retrieve any saved set of completion candidates. That is, you +;; access the files defined for your project by retrieving their +;; names during completion, to serve as the current set of completion +;; candidates. This odd feature is unique to Icicles. +;; +;; There's nothing much more to say about this, except that you +;; should be taking advantage of it now. Define and save a set of +;; project files (or buffers), and later use just those files, +;; staying within the bounds of your project for your navigation, +;; search, compilation, etc. needs. Even if the files you use in a +;; given project are scattered all over your file system, Icicles +;; lets you access them together as a named unit. For more +;; information, see +;; (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates"). +;; +;; If you use library `bookmark+.el' then you can open a project that +;; is defined by a set of bookmarks, by doing one of the following: +;; +;; * Using a project-specific bookmark file. +;; +;; * Using a bookmark-list bookmark (it records a `*Bookmark List*' +;; buffer state, including which bookmarks are marked or omitted). +;; +;; You can also open Dired for a project or for a list of file names +;; saved non-persistently as completion candidates - only those files +;; are listed in the Dired buffer. +;; See (@> "Icicles Dired Enhancements"). +;; +;; You can also run `grep' on a saved list of file names using +;; command `icicle-grep-saved-file-candidates'. If you use library +;; `dired+.el', then you can also `grep' the files in a project or +;; saved list of file names by opening it in Dired and then using +;; `M-g' (`diredp-do-grep'). +;; +;; Finally, note that among the sets of completion candidates that +;; you can save are Icicles search hits. That's right. Icicles +;; search lets you search multiple buffers, files, or bookmarks, and +;; you can save selected search hits or all matching hits for later +;; use. When you save search hits, Icicles records the buffer or +;; file names and the hit locations within those buffers or files. +;; When you retrieve such a saved set to access its hits, Icicles +;; automatically takes you to the proper files. +;; +;; A related feature is being able to filter tags definitions and +;; then save the filtered hit list. This works the same way, and it +;; gives you the equivalent of per-project tags files: A saved hit +;; list acts just like a custom tags file when you reuse it. And +;; unlike some of your project files, a tags file doesn't change +;; often, so saved hit sets stay accurate longer. +;; +;;(@* "Semantics? Roll Your Own?") +;; ** Semantics? Roll Your Own? ** +;; +;; I no longer develop software. I just putz around with Emacs Lisp +;; for my own enjoyment, entertainment, and enlightenment. So I +;; don't use things like ECB (Emacs Code Browser) or Semantic +;; (Bovinator). I don't use any IDE that has knowledge of a +;; particular programming language. The Icicles commands I've +;; written therefore use little or no semantic or language +;; information; they rely upon syntax for the most part, and they are +;; essentially language-agnostic (i.e. ignorant). +;; +;; But you are a different story. If you use, say, Semantic, you +;; could write a little Emacs-Lisp code to take advantage of Icicles +;; in combination with Semantic's parser information. With complete +;; ignorance of Semantic, I dare say it wouldn't be hard. If you can +;; get an alist of completion candidates for something from Semantic +;; in some context, then you can exploit all of the Icicles features: +;; apropos completion, progressive completion, multi-commands, +;; Icicles search, and so on. Likewise for any other IDE that plays +;; well with Emacs and for any other programming language support. +;; Think about it. Others would appreciate your contribution. +;; +;; Icicles provides lots of features for Emacs-Lisp programmers. The +;; end-user commands I've written using some of those features are +;; really just a demonstration of what you can do. Try rolling your +;; own Icicles commands. See Also: (@> "Note to Programmers"). + +;;(@* "Using Complex Completion Candidates") +;; +;; Using Complex Completion Candidates +;; ----------------------------------- +;; +;; This section could also be called "Applying a Function +;; Interactively" or "Mapping over Sets". It is about applying a +;; function to members of a set of completion candidates that you +;; select interactively. The candidates can represent arbitrarily +;; complex data, and the function is applied to the associated data +;; as well, not just to the displayed (string) candidate that names +;; the data. +;; +;; You already know that you can manipulate sets of candidates - see +;; (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates"). +;; The elements of those sets are strings; you choose +;; candidate names. Sometimes, however, you need to choose among +;; named items that are themselves complex, containing more +;; information than just the name. That is the idea behind +;; multi-command `icicle-apply', which this section introduces. +;; +;; You (or a command that you use) can obtain the information +;; associated with a name after you choose the name. This is what +;; happens, for instance, when you use `find-file'; the command looks +;; up the file associated with the file name you choose. Icicles +;; multi-commands such as `icicle-file' perform this lookup both when +;; you act on a candidate during completion (e.g. `C-RET') and when +;; you make a final candidate selection (`RET') - see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands"). +;; +;; Names and their associated information can be available in Emacs +;; Lisp in the form of an association list (alist), that is, a list +;; whose items are conses (cons cells). An alist is often used to +;; represent a function that maps one set of things to another. The +;; conses in the alist represent the tuples (typically pairs) of +;; related items. The car of each cons is called its "key"; the cdr +;; is called its "value". Different alists have different kinds of +;; keys and values. Typical key types include symbols and strings; +;; typical value types include symbols, strings, numbers, and lists. +;; There are quite a few standard Emacs-Lisp variables whose value is +;; an alist. Most are internal variables, but some are user options. +;; See the Emacs-Lisp manual for more about alists. +;; +;; The completion mechanism of Emacs function `completing-read' can +;; take an alist as input: the keys are the completion-candidate +;; strings that you choose from. For Emacs completion, however, the +;; value (cdr) of each alist key/value entry is completely ignored. +;; Icicles uses `completing-read', and it works the same way. If a +;; command needs to access the value associated with a key +;; (candidate), then it must somehow do so independently of +;; completion. +;; +;; Command `icicle-search' offers an example of this. The completion +;; alist contains key/value pairs whose car (key) is a search-hit +;; string that matches your search string and whose cdr (value) is +;; the buffer position for the hit. When you use completion with +;; this command, you work only with the keys, but `icicle-search' +;; also keeps track of the corresponding buffer positions for you. +;; The logic for doing this is coded into the definition of +;; `icicle-search'. +;; +;; It is common to want to do something interesting interactively +;; with the values also, not just the keys, of a completion alist. +;; Why lose the important value information when you choose a key? +;; And instead of requiring the logic of each command to deal with +;; this need individually, why not provide a general mechanism for +;; accessing this information - both by program and interactively? +;; This is what command `icicle-apply' is for. +;; +;; To make use of completion alist values, you need to access the cdr +;; of a key/value cons (pair). Different alists are structured +;; differently: the cdr can itself be complex (structured - a cons). +;; In general, you want to access not just the cdr (value) but the +;; key as well, the key/value pair as a whole, to do what you want +;; with it - that is, to apply some function to it. +;; +;; Emacs-Lisp programmers sometimes map functions over lists to +;; obtain a different list. For example, mapping the function `1+' +;; over the list (3 1 4 1 5 9) gives the list (4 2 5 2 6 10). Or if +;; interested only in the side effects, they apply a function +;; iteratively over a list without bothering to accumulate the +;; results as a new list. The command `icicle-apply' is inspired by +;; these common practices of mapping and iterating over a list, but +;; it applies only to alists. And it lets you choose interactively +;; which alist elements to act on, instead of always acting on all +;; elements. +;; +;; `icicle-apply' lets you apply a function of your choice to any +;; number of key/value entries in an alist. As user of the command, +;; you choose the entries to act on. The alist is used for +;; completion; you choose among the keys. The function is applied to +;; the corresponding key/value pairs, however, not to the keys alone. +;; +;; For example, given the alist `auto-mode-alist' and the function +;; `cdr', you can choose to apply `cdr' to selected alist entries. +;; This acts as a simple lookup function, because `cdr' just returns +;; the value associated with a chosen key. If you choose, for +;; example, the candidate (key) "\.el\'", then the (value) result is +;; the symbol `emacs-lisp-mode'. In this case, the chosen key/value +;; pair is ("\\.el\\'" . emacs-lisp-mode). (A literal backslash must +;; be doubled in an Emacs-Lisp string.) +;; +;; Function `cdr' returns the value, which is `emacs-lisp-mode' here. +;; If instead of `cdr' you use the function (lambda (x) +;; (describe-function (cdr x))), then the result of choosing +;; candidate "\.el\'" is to display the help for function +;; `emacs-lisp-mode'. This function first uses `cdr' to obtain the +;; value (the mode) and then applies `describe-function' to that +;; value. +;; +;; A typical use of `icicle-apply' is to define your own +;; multi-command that you or someone else can use to act on objects +;; selected by name. The definition of command `icicle-goto-marker' +;; provides an example. It uses an alist whose elements are pairs +;; composed of a text line (the key) and the marker (the value) in +;; that line. It applies a function that moves to the marker. +;; +;; If called interactively (as opposed to being used to define +;; another command), `icicle-apply' lets you use completion to choose +;; not only the objects to act on but also the function to apply to +;; them and the alist to choose them from. See the doc string of +;; `icicle-apply' for more information. +;; +;; Note that you can type in a lambda expression when prompted for +;; the function. You can use any function, provided it targets a +;; key/value pair (a cons). This is why you could not simply use +;; `describe-function' itself as the function to apply in the example +;; above: `describe-function' expects a symbol argument, not a cons. +;; +;; So what is `icicle-apply' really for? Anything you want. You can +;; use it to simply browse an alist or to perform actions on complex +;; things. The idea is to let you take advantage of Icicles features +;; to interactively filter and manipulate a set of completion keys, +;; and then apply any function you like to them - not just to the +;; keys, but to the keys or their values, or both. +;; +;; You can use apropos (regexp) matching or prefix matching to filter +;; the alist, as always, during completion. You can use `C-RET' and +;; so on to act on (that is, apply the function to) selected +;; key/value pairs that match your current input. +;; +;; You can also act on *all* such pairs, by using `C-!' or `M-!'. +;; `C-!' corresponds to iterating over the items in a list, applying +;; a function to each. `M-!' applies a function not to each chosen +;; pair, but to the *list* of all chosen pairs. By default, the +;; completion candidates are not sorted, but you can of course sort +;; them in various ways, either interactively or by program. +;; +;; As an Emacs-Lisp programmer, you can use function `icicle-apply' +;; programmatically to let users look things up in alists that you +;; construct or to act on selected alist entries in complex ways. +;; Icicles just provides the interactive completion features. +;; +;; The real value of `icicle-apply' comes from what you do with it. +;; Use it with a database of geographical coordinates to look up +;; location names provided by users and draw corresponding vicinity +;; maps. Use it with a list of hardware configurations to let users +;; perform diagnostic or maintenance operations on selected +;; equipment. You get the idea - use your imagination. +;; +;; Note: Although completion alists normally require string-valued +;; keys, `icicle-apply' is designed to work with any alist. + +;;(@* "Icicles OO: Object-Action Interaction") +;; +;; Icicles OO: Object-Action Interaction +;; -------------------------------------- +;; +;; Here's another crazy Icicles feature: Instead of choosing a +;; function (e.g. command) and then the object to apply it to, choose +;; the object first and then the function. +;; +;; The first thing to say about this feature is that Emacs is not +;; really designed for this, so it's not feasible to do this in a +;; entirely satisfactory way. In particular, there is no practical +;; way, given an object, to find all of the functions that apply to +;; it, in order to allow all of those functions, and only those +;; functions, as completion candidates. +;; +;; The second thing to say is that there are several ways that +;; Icicles helps you operate on an object that you have already +;; chosen: +;; +;; * apropos completion - (1) choose an object type by name, (2) +;; choose a function, (3) choose the target object +;; +;; * alternative action by type, during completion - (1) choose a +;; target object, (2) choose a function appropriate for the +;; object's type. +;; +;; * `M-RET' during completion - (1) choose a target object, (2) +;; choose any function +;; +;; * `icicle-object-action' and `icicle-anything' - (1) choose an +;; object type by name, (2) choose the target object, (3) choose a +;; function +;; +;; As a special case, if you use library Anything (`anything.el'), +;; then `icicle-object-action' lets you apply one or more Anything +;; actions defined for the object. See (@> "Icicles with Anything") +;; for more information. +;; +;;(@* "Apropos Completion as OO") +;; ** Apropos Completion as OO ** +;; +;; You can use apropos completion with `M-x' to narrow the set of +;; possible commands to those that have a given object type in their +;; name. You choose the command before the individual object, but +;; you at least choose the object type first (which narrows the set +;; of possible objects). +;; +;; If you use Icicles, you already use apropos completion this way, +;; but you might not have thought about it in these terms. If you +;; want to invoke some command on a buffer, you might start by typing +;; `M-x buffer S-TAB' or `M-x buff S-TAB'. This is simple, but it +;; really does get you most of the way toward object-action +;; interaction. And you can of course then use progressive +;; completion (`M-*') to filter the matching commands for additional +;; object-type names; for example `M-* window' keeps only those +;; commands whose names contain both `buffer' and `window'. +;; +;; Of course, this approach requires the command name to actually +;; advertise truthfully the object types that it operates on. There +;; are false positives and true negatives, but Emacs is generally +;; quite helpful in this respect. +;; +;;(@* "Alternative Action as OO") +;; ** Alternative Action as OO ** +;; +;; As explained in +;; (@file :file-name "icicles-doc1.el" :to "Alternative Actions"), +;; many Icicles commands, as their alternative action +;; (e.g. `C-S-RET'), prompt you to choose an action to be applied to +;; the current completion candidate. The actions you can choose are +;; all appropriate functions for the current type of object +;; (candidate). If you use library Anything (see below), then any +;; actions defined for the current type by Anything are included. +;; +;; See Also: +;; (@file :file-name "icicles-doc1.el" :to "Alternative Actions"). +;; +;;(@* "M-RET") +;; ** M-RET ** +;; +;; `M-RET' (`icicle-candidate-read-fn-invoke') during completion +;; provides a typeless object-action interaction, which is always +;; available. (You can also use `ESC RET' or `ESC C-m'.) +;; +;; This is similar to the action choice provided for some +;; commands by `C-S-RET', except that there is no notion of the +;; current object type - you can choose from among all Emacs-Lisp +;; functions. +;; +;; Whenever you cycle through completion candidates, `M-RET' enters a +;; recursive edit that prompts you for a function to apply to the +;; current candidate. `M-mouse-2' does the same thing. For example, +;; if the current candidate is a buffer named `foo.el', then `M-RET' +;; prompts you for a function to apply to it. (Actually, the +;; function is applied to the candidate, which is the buffer name in +;; this case, but many functions accept an object name in place of +;; the object.) +;; +;; The function you enter can be anything, including a lambda +;; expression that accepts an argument of the appropriate type. The +;; function is read with (lax) completion. It is up to you to choose +;; a function that is appropriate for the current object type. +;; +;; If you use a prefix argument (`C-u M-RET' or `C-u M-mouse-2'), +;; then the result of the function application is pretty-printed. +;; Otherwise, the function is called for effect only. +;; +;;(@* "`icicle-object-action' and `icicle-anything'") +;; ** `icicle-object-action' and `icicle-anything' ** +;; +;; Another way that Icicles helps with object-action interaction is +;; provided by command `icicle-object-action'. This reads an +;; object-type name ("what"), with completion; then it reads an +;; object of that type ("which"), with completion; then it reads a +;; function (name or lambda expression) to apply to the object +;; ("how"), with (lax) completion. Again, use a prefix argument if +;; you want to pretty-print the result. +;; +;; `what-which-how' is an alias for command `icicle-object-action'. +;; It is easy to remember, taking its name from the successive input +;; prompts: "What?" - a file. "Which?" - icicles.el. "How?" open. +;; Another alias for the same command is `a', because it acts on a +;; file, a buffer, a symbol, a process, and so on. The first thing +;; it does is prompt you for the type of object, so you do `M-x a RET +;; buffer', `M-x a RET symbol', and so on. +;; +;; The aliases `what-which-how' and `a' are just convenience +;; commands. They are defined only if user option +;; `icicle-define-alias-commands-flag' is non-nil. Two related +;; commands are also defined only if this option is non-nil: +;; +;; * `file' - same as `a RET file' +;; * `buffer' - same as `a RET buffer' +;; +;; For example: `M-x file RET'. You are prompted for a file to act +;; on, and then for the action to use. +;; +;; Note: If you use AUCTeX, then be aware of an AUCTeX bug that +;; causes problems if `icicle-define-alias-commands-flag' is non-nil. +;; Here is the bug description, filed 2007/10/05 by Bjorn Haagensen: +;; http://lists.gnu.org/archive/html/bug-auctex/2007-10/msg00006.html. +;; The problem is that AUCTeX mistakenly invokes the Icicles `file' +;; command, in an inappropriate context. AUCTeX does not define any +;; function `file' when it is loaded, but it invokes one, if defined. +;; This appears to be a name-capture problem. Since there is no +;; `file' function defined when Icicles is loaded, Icicles defines +;; its command. AUCTeX developers will no doubt fix this bug. Until +;; then, AUCTeX users can avoid the bug by setting +;; `icicle-define-alias-commands-flag' to nil. +;; +;; The "type" of an object is one of these: +;; +;; a. A type defining an entry in user option +;; `icicle-predicate-types-alist'. These are type predicates, +;; such as `bufferp', `keywordp', or `atom'. +;; +;; b. The `type' of an Anything source, or its `name' if it has no +;; `type'. This is available only if you use library +;; `anything.el'. +;; +;; c. A type defining an entry in user option +;; `icicle-type-actions-alist'. +;; +;; Icicles completion is available for each prompt: the type, the +;; object, and the action to apply to the object. Types defined by +;; Anything are highlighted in buffer `*Completions*' using face +;; `icicle-special-candidate'. In the case of an Anything type, you +;; can use multi-command features to act on multiple objects in +;; multiple ways, all within a single `a' invocation. See +;; (@> "Icicles with Anything") for more information about using +;; Anything types. +;; +;; The objects of types (b) and (c) are easily named, and their names +;; serve as the completion candidates when you choose them. So, for +;; instance, if you choose type `buffer', then you can act on a +;; buffer by choosing its name. +;; +;; The objects of predicate type (type a, above) are not necessarily +;; named. The completion candidates for these objects are symbols +;; whose values are the objects that are acted upon. The object-type +;; names used for these candidates are really Emacs-Lisp type +;; predicate names, which all end in `p', except for `atom'. +;; +;; So, for instance, if you choose type `bufferp', then you can +;; choose a symbol whose value is a buffer, in order to act on that +;; buffer. A buffer is of course always named, but an object of type +;; `stringp' is not. The value of `emacs-version' is one such string +;; that you can act on. +;; +;; Be aware that the action function you choose must accommodate the +;; object you choose as its only argument. Also, completion of the +;; function candidate itself is lax, so you can enter a lambda +;; expression as the action. +;; +;; Objects that are naturally associated with names are treated +;; differently, depending on the type. Besides Anything types, the +;; following object types are used for named objects: `buffer', +;; `command', `face', `frame', `function', `option', `process', +;; `symbol', `variable', `window'. For all of these except `window', +;; the name of the object is used. For `window', the candidate +;; objects are the names of the buffers that are currently shown in a +;; window (on any frame). +;; +;; You'll note that some types are treated both ways, 1) using named +;; objects and 2) using symbols whose values are objects. An example +;; is `frame' and `framep': the completion candidates (objects) for +;; type `frame' are frame names; the candidates for type `framep' are +;; symbols whose values are frames. +;; +;; See Also: +;; +;; * (@> "Icicles with Anything") +;; * (@file :file-name "icicles-doc1.el" :to "Apropos Completions"). +;; * (@file :file-name "icicles-doc1.el" :to "Progressive Completion"). + +;;(@* "Icicles with Anything") +;; +;; Icicles with Anything +;; --------------------- +;; +;; Library Anything (`anything.el') lets you define object types and +;; associate actions with them. It provides command `anything', +;; which you can use to apply an action to an object, choosing the +;; object first by name. All objects (of all types) that have a name +;; that matches your input are candidates. You can use command +;; `anything' while in Icicle mode; it has the same behavior with +;; Icicles as without it. +;; +;; Icicles also integrates some Anything features within its own +;; completion environment, so that you can use Icicles features such +;; as progressive completion at the same time. In particular, you +;; can act on multiple Anything objects in the same command +;; invocation, and you can act on them using multiple Anything +;; actions. +;; +;; Command `icicle-anything' (alias `any') is just command +;; `icicle-object-action' (alias `a') restricted to Anything types - +;; see (@> "Icicles OO: Object-Action Interaction"). It is more +;; convenient than `a' if you know that you want to use an Anything +;; type, because the set of type candidates to choose from is more +;; limited. +;; +;; When you act on an object of an Anything type, you are not +;; prompted for the action ("how"). The default Anything action is +;; applied, or you can choose a different Anything action. +;; +;; Command `any' (or command `a' when applied to an Anything type) is +;; a multi-command (see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands")): +;; +;; * `C-RET', `C-mouse-2', and so on perform the default Anything +;; action on each chosen object. +;; +;; * `C-S-RET', `C-S-mouse-2', and so on, prompt you, for each chosen +;; object, to choose one or more Anything actions (with +;; completion). +;; +;; You can thus act on any number of Anything objects in any number +;; of Anything ways, all in the same `any' command invocation. And +;; you can of course use Icicles completion and cycling to choose. +;; User option `icicle-anything-transform-candidates-flag' determines +;; whether Anything function `anything-transform-candidates' is +;; applied to displayed Anything candidates in Icicles. +;; +;; Here's an example of using command `any'. Let's assume that you +;; have an `action' entry such as this in `anything-type-attributes' +;; for the Anything type `command': +;; +;; (action ("Call interactively" +;; . (lambda (command-name) +;; (call-interactively (intern command-name)))) +;; ("Describe command" +;; . (lambda (command-name) +;; (describe-function (intern command-name)))) +;; ("Add command to kill ring" . kill-new) +;; ("Go to command's definition" +;; . (lambda (command-name) +;; (find-function (intern command-name))))) +;; +;; This defines four actions for objects of type `command', the +;; default action being the first listed ("Call interactively"). +;; +;; You enter command `any', choose the Anything type `command', and +;; then choose the command `icicle-face-list' to act on: +;; +;; M-x any RET +;; What (type): command RET +;; Which (command): icicle-face-list RET +;; +;; This invokes command `icicle-face-list', because the default +;; Anything action for an object of type `command' is to call it. +;; +;; If you use `C-RET' instead of `RET' when choosing command +;; `icicle-face-list', then you remain within the `any' invocation, +;; and you can do something with another command after +;; `icicle-face-list'. If you use `C-S-RET' when choosing a command, +;; then you are prompted for the action to invoke for that command: +;; +;; Which (command): icicle-face-list C-S-RET +;; How (action): Go to command's definition RET +;; +;; If you choose the Anything action "Go to command's definition", +;; then, well, that's what happens: here, you go to the definition of +;; `icicle-face-list'. Again, you could use `C-RET' instead of +;; `RET', to perform this action on the command and then choose and +;; apply (via `RET' or `C-RET') another action to the same command. +;; +;; After you've stopped (via `RET' or `C-g') acting on command +;; `icicle-face-list', you can clear the minibuffer (using `M-k') and +;; type another command to act on, and so on. Or, you can stop (via +;; `RET' or `C-g') and end the invocation of command `any'. +;; +;; At each prompt, you can use (apropos or prefix) completion or +;; cycling to pick a candidate. So, for instance, using completion, +;; you could simply do this to choose `command', `icicle-face-list', +;; and "Go to command definition": +;; +;; M-x any RET c RET face-l S-TAB C-S-RET g TAB RET +;; +;; Icicles enhances Anything by providing multi-command features, as +;; well as by providing all of the other standard Icicles features: +;; apropos and prefix completion, cycling, progressive completion, +;; help on individual candidates, and so on. On the other hand, +;; Anything by itself provides some features that Icicles does not +;; exploit. The aim of command `any' is to give you the basic +;; Anything features in an Icicles completion context. +;; +;; A significant behavior difference between Anything (that is, +;; command `anything') and Icicles command `any' is that with +;; `anything' only the object name is used for filtering, whereas +;; with Icicles command `any' you first narrow down the potential +;; candidates by type, before the object name is matched (against +;; objects of only that type). +;; +;; That is, with Anything, your input pattern is matched against +;; every possible object of every possible type. You then choose +;; among the matches. If you want, after that wide-net matching you +;; can cycle among only the matches of a given type (e.g. file), but +;; matching against all other types has already taken place. +;; +;; This behavior of starting with typeless matching can be convenient +;; sometimes (you need not specify the object type), but it can also +;; be inconvenient (and unnecessarily slow) to match objects of types +;; totally unrelated to what you're after. In such cases, it can +;; require either a long input pattern or cycling among more +;; candidates, to disambiguate among the hits. +;; +;; With Icicles command `any', you have the inconvenience of needing +;; to specify first the type of object you want, but this has the +;; advantage of eliminating searching among irrelevant types. +;; Finally, remember that you can use both `anything' and `any' - +;; choose whichever is most convenient for the current task. + +;;(@* "Multi-Completions") +;; +;; Multi-Completions +;; ----------------- +;; +;; This section is about using completion candidates that are +;; composed of more than one part: strings that you can complete +;; against separately and simultaneously. +;; +;;(@* "Icicles Multi-Completion Commands") +;; ** Icicles Multi-Completion Commands ** +;; +;; Have you ever used standard Emacs command `apropos-documentation'? +;; It searches the doc strings of all Emacs-Lisp symbols for matches +;; to an input regexp, and displays the hits. It can be useful when +;; you don't remember the name of a function or variable but you can +;; guess at terms that might occur in its doc string. Typically, +;; people resort to it only after first trying apropos commands that +;; match against the function or variable name. +;; +;; The idea behind `apropos-documentation' also motivates Icicles +;; command `icicle-doc'. This is a multi-command (see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands")), +;; so you can use `C-RET' and `C-next' to browse the regexp matches, +;; displaying the documentation of each match in turn, and you can +;; change the regexp to get different matches during the same command +;; invocation. +;; +;; Like `apropos-documentation', `icicle-doc' lets you match a regexp +;; against the doc strings of symbols such as functions, variables, +;; and faces. You can of course use progressive completion to match +;; multiple regexps. Here, for example, is a query that shows all doc +;; strings (functions, variables, faces - a lot! of doc strings) +;; that match both `mail' and `mode line', in either order, +;; as completion candidates: +;; +;; M-x icicle-doc RET mail S-SPC mode line +;; +;; You cannot do that with vanilla Emacs `apropos-documentation' or +;; with any other vanilla Emacs `apropos*' command. +;; +;; Commands `icicle-vardoc', `icicle-fundoc', and `icicle-plist' are +;; similar to `icicle-doc' in the kind of functionality they provide. +;; +;; Each of these commands gathers a tremendous amount of information +;; to construct an initial set of completion candidates based on all +;; existing Emacs symbols (in the standard `obarray'). This is +;; time-consuming. Since the set of symbols that have property lists +;; or that name functions, variables, or faces changes little, you +;; can optionally bypass this gathering and reuse the last initial +;; set of candidates for that command. You do this by invoking the +;; command using a prefix argument (non-negative prefix arg, for +;; `icicle-vardoc' and `icicle-plist'). +;; +;; Each of these particular commands also uses Icicles +;; multi-completion. A "multi-completion" is a completion candidate +;; that has multiple parts. A multi-completion command lets your +;; input match any or all parts individually, at the same time. +;; +;; * Commands `icicle-vardoc' and `icicle-fundoc' let you match both +;; the function or variable name and the doc string. +;; +;; * Command `icicle-doc' lets you match any combination of the +;; following: +;; +;; - the function, variable, or face name +;; - the type: FUNCTION, VARIABLE, or FACE (uppercase) +;; - the doc string +;; +;; * Command `icicle-plist' lets you match both a symbol name and its +;; property list. You can use it to find symbols with certain +;; property-list keys or values. By default (for Emacs 22 or +;; later), plists are pretty-printed (in `*Help*' and +;; `*Completions*'), but if you use a negative prefix argument then +;; pretty-printing is skipped, gaining a little time. +;; +;; * Command `icicle-describe-option-of-type' (bound to `C-h C-o' in +;; Icicle mode) lets you match both an option name and the option's +;; `defcustom' type definition. There are several ways to match +;; type definitions, controlled by the prefix argument - see the +;; command's doc string. You can match a type directly or taking +;; type inheritance into account. You can match a type as a sexp +;; or using a regexp. You can match a type expression or match the +;; option's current value against a type. +;; +;; Other Icicles commands that use multi-completion include +;; `icicle-locate-file', `icicle-locate-file-other-window', +;; `icicle-recent-file', and `icicle-recent-file-other-window'. +;; These commands let you match against two-part multi-completion +;; candidates that are composed of an absolute file name and the +;; file's last modification date. This means that you can easily +;; find those notes you took sometime last week... +;; +;; The way multi-completion commands work is a bit inelegant perhaps, +;; and it can take a little getting used to, but it is quite powerful +;; and lets you do things with completion that are otherwise +;; impossible. +;; +;; In the case of commands that use two-part multi-completions, you +;; provide two regexps as input, one to match the name of a symbol +;; (e.g. a function or variable) and one to match some associated +;; information (doc string, property list, or type definition). +;; +;; However, since completion candidates are not actually multipart, +;; you in fact type a single regexp that is the concatenation of the +;; two. You join these two regexps using `icicle-list-join-string' +;; (a user option), which, by default, is `^G^J', that is, a +;; control-G character followed by a control-J (newline) character. +;; As always, you can input control characters using `C-q', so to +;; input `^G^J' you can use `C-q C-g C-q C-j'. +;; +;; However, in Icicles, `C-j' (newline) is self-inserting during +;; completion, so you don't need to quote it with `C-q' - you can use +;; just `C-q C-g C-j'. Better yet, you can use `C-M-j' +;; (`icicle-insert-list-join-string') to insert `^G^J'. +;; +;; This has the added benefit (in Emacs 22 or later) of hiding the +;; `^G' - it's there, but you don't see it. This hiding is only +;; cosmetic; you still match the characters `^G' and `^J'. In the +;; same way, Icicles hides the `^G' part of `^G^J' in *Completions*, +;; so the join string appears as a newline character. +;; +;; This hiding of `^G' happens only when option +;; `icicle-list-join-string' has its (ugly but useful) default value. +;; If not seeing the join string confuses you and you would prefer to +;; distinguish multi-completion part separators from ordinary newline +;; characters, then customize `icicle-list-join-string' - just remove +;; the following from the Lisp sexp that defines the default value: +;; +;; (set-text-properties 0 1 '(display "") strg) +;; +;; As an example of using a multi-completion command, you can use the +;; following to match a function name that contains `dired' and its +;; doc string that contains `file': +;; +;; M-x icicle-fundoc dired^G^Jfile S-TAB +;; +;; That is, you type this: +;; +;; M-x icicle-fundoc dired C-q C-g C-j file S-TAB +;; +;; or this: +;; +;; M-x icicle-fundoc dired C-M-j file S-TAB +;; +;; Well, almost. The way it actually works is that the completion +;; candidates are themselves formed by concatenating symbol names +;; with their doc strings, using `icicle-list-join-string'. Your +;; input regexp is matched against those candidates. This means that +;; the input regexp `dired^G^Jfile' would actually match only +;; function names that *end* with `dired' and doc strings that +;; *begin* with `file'. +;; +;; To match `file' against any part of the doc string, you must +;; explicitly link the two component regexps with a regexp that +;; matches anything. If you want to search only the first lines of +;; doc strings, you can use `.*' to do that: `dired.*^G^J.*file' will +;; match all functions whose names contain `dired' and whose doc +;; strings' first lines contain `file'. +;; +;; Why only the first lines? Because `.' matches any character +;; except a newline - it doesn't look past the first line. If you +;; want to search the entire doc strings (or property lists, for +;; `icicle-plist'), then you need to use a connecting regexp that +;; matches any character, including a newline. That means a regexp +;; such as `\(.\|\n\)'. Or you can just use the Icicles multi-line +;; dot feature - see (@> "Dot, Dot, Dot"). +;; +;; Without a multi-line dot, you would use something like this to +;; search whole, multi-line doc strings for `file': +;; +;; M-x icicle-fundoc dired.*^G^J\(.\|\n\)*file S-TAB +;; +;; That is, you would type (without the spaces): +;; +;; M-x icicle-fundoc dired.* C-M-j \ ( . \ | C-j \ ) * file S-TAB +;; +;; With a multi-line dot, you would type just this: +;; +;; M-x icicle-fundoc dired.* C-M-j . * file S-TAB +;; +;; What if you want to match, say, `file' in either the function name +;; or the doc string, not necessarily both? Remember that a +;; multi-completion is in fact a single string, with a separator such +;; as `^G^J' in the middle somewhere. Because it is a single string, +;; the simple minibuffer input `file' matches the substring `file' +;; anywhere in the multi-completion. So the answer is just this: +;; +;; M-x icicle-fundoc file S-TAB +;; +;; Even this simple command expression combines the effect of Emacs +;; commands `apropos-function' with that of `apropos-documentation'. +;; +;;(@* "How Multi-Completions Work") +;; ** How Multi-Completions Work ** +;; +;; These commands that accept a multipart regexp are examples of +;; Icicles multi-completion. Icicles extends standard function +;; `completing-read' so that it will accept, as the set of completion +;; candidates, an alist argument whose candidates are not only +;; individual strings but can also be lists of strings. Each string +;; in the list is one part of a multipart completion candidate, that +;; is, a multi-completion. The strings are joined together pairwise +;; using `icicle-list-join-string' by `completing-read'. Commands +;; `icicle-fundoc' and`icicle-vardoc' each use lists of two strings +;; (name and doc), but a multi-completion can have any number of +;; strings. +;; +;; Why is the default value of `icicle-list-join-string' so odd: +;; `^G^J'? You can use any string you like, but here is the +;; rationale behind the default choice: +;; +;; - ^G does not normally occur in simple strings such as doc strings +;; - a newline (^J) visually separates the multiple component strings +;; - ^G^J is not too difficult to enter: `C-M-j' or `C-q C-g C-j' +;; +;; It is important that the value of `icicle-list-join-string' not be +;; something that is, itself, likely to match any of the candidates. +;; Otherwise, it would not serve its role as separator. +;; +;; I find that it helps a bit (in Emacs 22 or later) to customize +;; face `escape-glyph', which is used for control characters such as +;; `^G', in such a way that it stands out a bit, especially because +;; control characters can be used in regexps that also use `^' as a +;; special character. I use an orange background with a blue +;; foreground for this face. +;; +;; Because multi-completions often extend over multiple lines, and +;; candidates in buffer *Completion* appear one right after the +;; other, it's helpful to add additional separation between +;; multi-completion candidates. That is the purpose of user option +;; `icicle-list-end-string', whose default value is "^J^J" (two +;; newline characters). It is automatically appended to each +;; candidate, for purposes of both display and matching. Remember +;; that it is part of each multi-completion candidate, especially if +;; you use a regexp that ends in `$', matching the end of the +;; candidate. +;; +;;(@* "Multi-Completions Let You Match Multiple Things in Parallel") +;; ** Multi-Completions Let You Match Multiple Things in Parallel ** +;; +;; Consider the command `describe-option-of-type', defined in my +;; library `help-fns+.el' (or `help+.el', for Emacs 20). This lets +;; you first pick a `defcustom' type using completion and then pick +;; an option of that type to describe. There are two separate, +;; sequential acts of completion. For each completion act, your +;; current input defines a set of matches. You can see all option +;; types that match, say, the regexp `.*string', which means all +;; types that contain `string'. After you choose one of those types, +;; you can see all options of that type whose names start with +;; `icicle' and then pick one. +;; +;; You can thus tweak the type regexp to filter types, and you can +;; tweak the name regexp to filter option names. And you can of +;; course use progressive completion to whittle down either set of +;; matches, piecemeal. +;; +;; What you cannot do, however, using `describe-option-of-type' is +;; filter both sets at the same time: narrow down the set of type +;; matches and name matches simultaneously. For that, you need +;; Icicles multi-completion. Without it, you must commit 100% to a +;; type before you can choose among the options of that type. With +;; it, you can change the type (or the name) part of your input +;; regexp on the fly, and see immediately the set of matching names +;; (or types) as well. +;; +;;(@* "Multi-Completions vs `completing-read-multiple'") +;; ** Multi-Completions vs `completing-read-multiple' ** +;; +;; Note that there is (only) a superficial similarity between Icicles +;; multi-completion and the functionality provided by function +;; `completing-read-multiple' of standard Emacs library `crm.el'. +;; The latter lets you complete multiple strings in the minibuffer, +;; one at a time. It involves ordinary Emacs prefix completion, and +;; it uses the same set of completion candidates for each of the +;; strings in the input. +;; +;; By contrast, Icicles multi-completion completes each part of your +;; input against a different set of completion candidates. For +;; example, when you use `icicle-vardoc', it completes the +;; variable-name part of your input against the names of defined +;; variables, and the variable-description part against the doc +;; strings of defined variables. Standard Emacs command +;; `completing-read-multiple' lets you complete several different +;; variable names at the same minibuffer prompt, but they each +;; complete against the same set of variable names. +;; +;; Multi-completion matches a list of regexps in parallel. See also +;; the description of `M-*', which matches a list of regexps in +;; series: (@file :file-name "icicles-doc1.el" :to "Progressive Completion"). +;; You can combine these features, of course. +;; +;;(@* "Sorting Candidates by Their Second Part") +;; ** Sorting Candidates by Their Second Part ** +;; +;; Most multi-completions have two parts. Typically, the first part +;; is the main part, that is, the part that you will most frequently +;; complete against. Many candidate sort orders involve some flavor +;; of alphabetic order, and this means alphabetizing first with +;; respect to the first multi-completion part. +;; +;; However, it can sometimes be convenient to sort instead by the +;; second part first. That is what the Icicles sort order "by 2nd +;; parts alphabetically" is for. You can use it, for example, with +;; command `icicle-locate-file' to sort file-name candidates first by +;; date, and then by file-name for the same date. This gives you an +;; easy way to look up files that you modified during a given time +;; period. For example, your input regexp can limit candidates to +;; those files last modified sometime in July, 2008, and you can then +;; access these chronologically (by cycling or in buffer +;; *Completions*). And don't forget that you can always reverse the +;; current sort order, using `C-N C-,' where N is an integer. +;; +;; See Also: +;; +;; * (@> "Programming Multi-Completions") for information about +;; changing the appearance and behavior of Icicles +;; multi-completions using Emacs-Lisp code. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Sorting Candidates and Removing Duplicates") +;; +;; * (@file :file-name "icicles-doc1.el" :to "Progressive Completion") + +;;(@* "Dot, Dot, Dot") +;; +;; Dot, Dot, Dot +;; ------------- +;; +;; This section is about dot, that is, `.', and its role as a regexp +;; special character in apropos completion. +;; +;; Since the inception of regular-expression matching, `.' has +;; matched any character *except* a newline character (aka `^J', aka +;; `C-j'). Recent languages typically have an additional mode in +;; which `.' can match any character, including a newline. See, for +;; example, http://www.regular-expressions.info/dot.html and this +;; language comparison for regexp features: +;; http://www.regular-expressions.info/refflavors.html. +;; +;; It is not unusual to manipulate multi-line completion candidates +;; in Icicles, in which case it can be handy to let `.' match any +;; character, including a newline. For this and more general +;; reasons, I long ago requested such a mode for Emacs, but there was +;; little interest in implementing it. In Emacs, dot never matches a +;; newline. Too bad. +;; +;; The regexp `\(.\|[\n]\)' is good enough, of course: it matches any +;; character: any character any except newline, plus newline. But it +;; is a bit unwieldly, especially when used within a larger regexp, +;; and especially if used more than once in the same regexp. +;; Interactively, you input the `\n' using `C-j', and it appears in +;; the minibuffer as a newline character; that is, it creates another +;; line of input. +;; +;; For convenience in multi-line matching, I added a *multi-line +;; dot*, or dot-matches-newline-too, hack to Icicles. This feature +;; is turned off, by default. You can toggle it on/off, using +;; command `icicle-toggle-dot', which is bound to `C-M-.' in the +;; minibuffer during completion. +;; +;; When it is turned on, `.' is highlighted in the minibuffer (using +;; face `highlight'), and it matches newlines also. In fact, +;; although it appears as just a highlighted dot, the ugly regexp +;; `\(.\|[\n]\)' is really used, under the covers. Icicles takes +;; care of things so that you can edit normally (delete and transpose +;; characters, etc.): A multi-line `.' acts just like a normal, +;; single character, even though it is really a string of ten +;; characters. +;; +;; If you prefer to see the full regexp, `\(.\|[\n]\)', but +;; highlighted, then set option `icicle-dot-show-regexp-flag' to +;; non-nil. (In Emacs 20, the newline-matching dot is always shown +;; as that full regexp.) If you prefer to turn on newline matching +;; by default, then just customize option `icicle-dot-string'. +;; +;; This match-anything dot is handy, but sometimes you might want to +;; match anything except a newline, perhaps in the same input pattern +;; where you also want to match any character (possibly a newline) at +;; other positions. How can you get the plain dot behavior, when +;; multi-line dot is turned on? +;; +;; One way is just to use a regexp that matches anything except +;; newline: `[^\n]' (which you input using `[ ^ C-j ]'). Another way +;; is to use a plain prefix argument: `C-u .'. (A numeric prefix +;; argument N inserts N multi-line dots, each of which matches any +;; single character.) +;; +;; `C-u' flips the behavior of `.' when you hit it: If by default `.' +;; enters a multi-line dot, then `C-u .' enters a plain dot. If by +;; default `.' enters a plain dot, then `C-u .' enters a multi-line +;; dot. So `C-u' also gives you a way to enter a one-off multi-line +;; dot, if you prefer to generally have `.' not match a newline. +;; Either way, what you see in the minibuffer is the single character +;; `.', highlighted if it is a multi-line dot, unhighlighted if it is +;; a plain dot. +;; +;; Multi-line dots are converted to plain dots automatically when you +;; use prefix completion. And if you then move back to apropos +;; completion during the same completion operation, you get back any +;; multi-line dots you had before, and any plain dots that you +;; entered before remain plain. +;; +;; So when is a multi-line dot useful? Whenever you want to match +;; against multi-line candidates. Typical use cases include +;; `icicle-search' and the Icicles doc commands, `icicle-vardoc', +;; `icicle-fundoc', and `icicle-doc'. + +;;(@* "Fuzzy Completion") +;; +;; Fuzzy Completion +;; ---------------- +;; +;; There are a few different kinds of what might be called "fuzzy" +;; matching used in Icicles completion, in addition to apropos +;; (regexp) matching and prefix matching. +;; +;; * Fuzzy - This method uses a fairly sophisticated matching +;; algorithm that seems to account for various typing mistakes. +;; This algorithm is provided by library `fuzzy-match.el', so I +;; call its use in Icicles `fuzzy' completion. You must have +;; library `fuzzy-match.el' to use this. +;; +;; * Swank - Symbols are completed using the algorithm of +;; `el-swank-fuzzy.el' - see that library for details. +;; +;; * Scatter - This is a simple, poor man's fuzzy matching method +;; that I call `scatter' matching. Ido calls it `flex' matching. +;; The TextMate editor has the same thing for file-name matching +;; (only), without naming it. +;; +;; * Levenshtein - This method checks whether two strings differ by +;; at most a given number of character operations, the so-called +;; "Levenshtein distance". +;; +;; You can use fuzzy or swank completion in place of prefix +;; completion (`TAB'). You can use the scatter or Levenshtein +;; completion in place of apropos completion (`S-TAB'). You can +;; change completion methods easily at any time, by hitting a key in +;; the minibuffer: +;; +;; * `C-(' (command `icicle-next-TAB-completion-method') to cycle +;; among `TAB' completion methods: `basic', `vanilla', `fuzzy', and +;; `swank' (`vanilla' only for Emacs 23 and later; `fuzzy' only if +;; you have library `fuzzy-match.el'; `swank' only if you have +;; library `el-swank-fuzzy.el'). +;; +;; * `M-(' (command `icicle-next-S-TAB-completion-method') to cycle +;; `S-TAB' completion methods: `apropos', `scatter', `Levenshtein' +;; and `Levenshtein strict'. +;; +;; Repeating `C-(' and `TAB' or `M-(' and `S-TAB' on the fly for the +;; same input can be a good way to learn the differences between the +;; various completion methods. +;; +;; My opinion about the relative usefulness of the various methods: +;; Basic (prefix) completion and apropos completion are by far the +;; most useful. They are followed, in order of decreasing +;; usefulness, by scatter, fuzzy, Levenshtein, vanilla, and swank +;; completion. YMMV. +;; +;; Besides these methods, remember that you can get ordinary +;; substring matching with `S-TAB' by using `C-`' to turn off +;; (toggle) escaping of regexp special characters. With special +;; characters escaped, `S-TAB' does literal substring completion. +;; +;; The type of completion matching that is used when you hit `S-TAB' +;; and `TAB' is controlled by user options +;; `icicle-S-TAB-completion-methods-alist' and +;; `icicle-TAB-completion-methods', respectively. By default, the +;; first method in each list is used for matching. +;; +;;(@* "Partial Completion") +;; ** Partial Completion ** +;; +;; This section pertains to Emacs releases starting with Emacs 23. +;; +;; If option `icicle-TAB-completion-methods' includes `vanilla' +;; (which it does, by default), and you choose `vanilla' completion +;; for `TAB' (by cycling using `C-(' or by customizing +;; `icicle-TAB-completion-methods' to use `vanilla' as the default), +;; then Icicles `TAB' completion respects the standard Emacs option +;; `completion-styles', so the behavior of `TAB' is similar to what +;; it is in vanilla Emacs. +;; +;; Emacs includes `partial-completion' in the default value of +;; `completion-styles'. This means that Icicles too will make use of +;; partial completion when you use `TAB' (with `vanilla'). Icicles +;; makes no use of `completion-styles' when you use `S-TAB'. +;; +;; Partial completion is not really a kind of fuzzy completion, but +;; its effect can sometimes be similar. In some ways, it is similar +;; to scatter-match completion (see next), but it requires you to +;; explicitly mark where to skip ahead (using `*', ` ' (space), or +;; `-'). +;; +;; Icicles does not support using the mode `partial-completion-mode', +;; and Emacs itself is in the process of deprecating it, now that the +;; partial-completion style is active by default. +;; +;; I do not necessarily recommend using `vanilla' for `TAB' +;; completion, or, if you do, including `partial-completion' as an +;; entry in `completion-styles', because its effect is often +;; counter-intuitive or confusing. But it is included by default in +;; Emacs, and Icicles supports it. You might find it useful in +;; file-name completion, to be able to complete directory components, +;; for instance. +;; +;;(@* "Scatter-Match Completion") +;; ** Scatter-Match Completion ** +;; +;; The idea behind scatter-match completion is very simple: input +;; characters are matched in order against completion candidates, but +;; possibly with intervening characters. That is, your input +;; scatter-matches a completion candidate if each character is also +;; in the candidate, and the character order is respected. +;; +;; What this really amounts to is matching input `abc' as if it were +;; the regexp `a.*b.*c'. That's all. +;; +;; You can use Icicles scatter matching at any time in place of +;; apropos (regexp) matching. Unlike the cases of swank and fuzzy +;; completion (see below), you can use it to complete file names +;; also. +;; +;;(@* "Swank (Fuzzy Symbol) Completion") +;; ** Swank (Fuzzy Symbol) Completion ** +;; +;; If you choose `swank' completion, what you get in Icicles is fuzzy +;; completion (see next), except regarding symbols. That is, swank +;; completion per se applies only to symbols. Symbols are completed +;; using the algorithm of `el-swank-fuzzy.el' - see that library for +;; details. +;; +;; Icicles options `icicle-swank-timeout' and +;; `icicle-swank-prefix-length' give you some control over the +;; behavior. When the `TAB' completion method is `swank', you can +;; use `C-x 1' (`icicle-doremi-increment-swank-timeout+') and `C-x 2' +;; (`icicle-doremi-increment-swank-prefix-length+') in the minibuffer +;; to increment these options on the fly using the arrow keys `up' +;; and `down'. +;; +;; Swank symbol completion uses heuristics that relate to supposedly +;; typical patterns found in symbol names. It also uses a timeout +;; that can limit the number of matches. It is generally quite a bit +;; slower than fuzzy completion, and it sometimes does not provide +;; all candidates that you might think should match, even when all of +;; your input is a prefix (or even when it is already complete!). +;; +;; If swank completion produces no match when you think it should, +;; remember that you can use `C-(' on the fly to change the +;; completion method. +;; +;; I do not necessarily recommend swank symbol completion, but it is +;; available for those who appreciate it. +;; +;; Like fuzzy completion (see next), swank completion always sorts +;; candidate symbols according to its own scoring, putting what it +;; thinks are the best matches first. This means that using `C-,' in +;; the minibuffer to sort candidates differently has no effect. +;; +;;(@* "Fuzzy-Match Completion") +;; ** Fuzzy-Match Completion ** +;; +;; Fuzzy completion takes more explaining. It is described in detail +;; in the commentary of library `fuzzy-match.el'; please refer to +;; that documentation. Here are some things to keep in mind when you +;; use Icicles fuzzy completion: +;; +;; * File-name completion is never fuzzy. Basic prefix completion is +;; used for file names. +;; * Fuzzy completion is always case-sensitive. This means that +;; `C-A' in the minibuffer has no effect on fuzzy completion. +;; * Fuzzy completion always takes a space prefix in your input into +;; account. This means that `M-_' in the minibuffer has no effect +;; on fuzzy completion. +;; * Fuzzy completion candidates are always sorted by decreasing +;; match strength. This means that using `C-,' in the minibuffer +;; to sort candidates differently has no effect. +;; +;; Fuzzy completion is a form of prefix completion in which some +;; input characters might not be present in a matched candidate. +;; Matching finds the candidates that have the most characters in +;; common with your input, in the same order and with a minimum of +;; non-matching characters. It can skip over non-matching +;; characters, as long as the number of characters skipped in the +;; candidate is less that those following them that match. After the +;; matching candidates are found, they are sorted by skip length and +;; then candidate length. +;; +;; Here are some examples: +;; +;; Input Completion Domain Matches (Candidates) +;; ----- ----------------- -------------------- +;; +;; abc {xxabcxx, xabcxxx, +;; xabx} {xabcxxx, xxabcxx} +;; +;; point-mx Emacs variables {point-max, point-max-marker} +;; +;; begining-of-l Emacs commands {beginning-of-line, +;; beginning-of-line-text, +;; move-beginning-of-line, +;; widget-beginning-of-line} +;; +;; The last example shows that although fuzzy matching is a kind of +;; prefix matching, your input is not necessarily a prefix of each +;; matching candidate. It is prefix matching because it tries to +;; match your input starting at its beginning. This input prefix is +;; matched against candidate substrings, not necessarily candidate +;; prefixes, but the non-matching part (if any) preceding the matched +;; substring must not be longer than the matching part. That is, +;; non-matching substrings can be skipped over, but they must be no +;; longer than the matching substrings that follow them. If an input +;; prefix does not match under these conditions, it is skipped over. +;; +;; After matching an input prefix this way, the same process is +;; repeated, recursively, for input text following that prefix and +;; for match positions following the matches found. That is, after +;; each such prefix match, the process starts again where it left off +;; in both the input and the candidates. The resulting matches +;; contain one or more substrings of your input that are each at +;; least as long as the non-matching parts that immediately precede +;; them. Only matches with the highest number of matching characters +;; are retained. They are sorted by two criteria: (1) nearness of +;; matches to the start of the candidate and (2) candidate length. +;; +;; The fuzzy-match algorithm is detailed in library `fuzzy-match.el'. +;; However, it is easier to get a feel for what it does by trying it +;; than by reading any description. Just give it a try. Do not +;; expect it to rival apropos completion in power or expressivity, +;; however. Instead, think of it as prefix completion for lazy or +;; inaccurate typists! If that sounds like you, then you might find +;; it useful. +;; +;; As an example, here are some command-name candidates for the input +;; `fo' (there are lots more): +;; +;; fortune forms-mode focus-frame +;; follow-mode forward-sexp forward-list +;; forward-word forward-line forward-page +;; ... +;; ifconfig info Info-up +;; Info-edit Info-next Info-help +;; ... +;; Info-mouse-follow-nearest-node Info-goto-emacs-key-command-node +;; +;; And here are all the command-name candidates for the input `fol': +;; +;; follow-mode follow-delete-other-windows-and-split +;; Info-last info-lookup-file info-lookup-reset +;; Info-last-preorder info-lookup-symbol Info-last-menu-item +;; nnfolder-generate-active-file mh-folder-mode +;; +;; The first thing to notice is the distribution of candidates for +;; input `fo'. Candidates are in decreasing order of match fit: +;; +;; * The nearer the match to the start of the candidate, the better +;; the fit. +;; +;; * The greater the ratio of matched text to unmatched text, the +;; better the fit. +;; +;; Note too the candidate `ifconfig'. First, note that it has no +;; strict match for substring `fo'. Its match is in fact in two +;; parts: `f', then `o'. Second, note that it is considered a better +;; fuzzy match than the candidate `info'. This is because its match +;; (`f') is nearer to the start of the candidate (second character, +;; versus third). +;; +;; The second thing to notice is that when you type the third input +;; character, `l', the candidates are not a subset of the original +;; set that matches `fo'. The candidates in the second screenshot +;; all match `fol' in a fuzzy way, even though one of them, +;; `mh-folder-mode', does not match `fo' sufficiently well to be +;; included as a candidate. Why? Because in the `fo' case, the +;; match is only two characters long and it starts after three +;; non-matching characters. +;; +;; For both inputs: If all input prefixes are fair game for matching, +;; why doesn't `*Completions*' also include other command names that +;; match only the prefix `f' and nothing else? Because there is at +;; least one match that matches more than that - only the best +;; matches are retained. In this case, the best matches for input +;; `fo' match both the `f' and the `o', and the best matches for +;; input `fol' match all three of those characters. +;; +;; Refer to `fuzzy-match.el' for a precise description of fuzzy +;; matching. It refers to "matchiness" for how many characters match +;; and "closeness" for the ratio of number of characters matched to +;; candidate length. +;; +;; Note: It is not practical to try to highlight the exact candidate +;; portions that match different parts of your input. Because +;; fuzzy-match input does not function as a literal string for +;; matching purposes, it is more akin to substring matching than to +;; plain prefix matching. For this reason, regexp-match highlighting +;; is used for fuzzy matching. That is why you see the input `fo' +;; highlighted in `*Completions*' candidates in other than just the +;; prefix position. It is also why the matching `f' and `o' in +;; candidate `ifconfig' are not highlighted: for highlighting +;; purposes, your input is treated as a regexp. +;; +;; One takeaway here is that fuzzy completion is complicated. Rather +;; than try to understand how it works and think ahead in those +;; terms, you just need to get a feel for it - learn by doing. Have +;; fun! +;; +;;(@* "Levenshtein-Match Completion") +;; ** Levenshtein-Match Completion ** +;; +;; The "Levenshtein distance" is the maximum number of character +;; insertions, deletions, or replacements that are needed to +;; transform one string to another. The more similar two strings +;; are, the smaller their Levenshtein distance. +;; +;; When this kind of completion is used, Icicles considers your input +;; to match a completion candidate if their Levenshtein distance is +;; no greater than the value of option `icicle-levenshtein-distance'. +;; The default value of the option is 1, meaning that the difference +;; is at most one character operation. +;; +;; Using a strict definition of the distance, this also requires the +;; length of your input to be within the Levenshtein distance of the +;; length of a completion candidate, for it to match. That is quite +;; restrictive. +;; +;; It is more flexible to consider your input to match a candidate if +;; it is within `icicle-levenshtein-distance' of some *substring* of +;; the candidate. Because candidate substrings are tested, the +;; length of your input need not be nearly the same as the candidate +;; length. +;; +;; When you cycle among `S-TAB' completion methods using `M-(', there +;; are thus two choices for Levenshtein completion: `Levenshtein' and +;; `Levenshtein strict'. The former is generally more useful. +;; +;; The larger the value of `icicle-levenshtein-distance', the slower +;; Levenshtein completion becomes, since it must test more +;; possibilities. Also, when the value is 1 (except for `Levenshtein +;; strict'), Icicles uses a fast, special-case algorithm, and it +;; highlights the matching parts of candidates in buffer +;; `*Completions*'. 1 is the most useful value. +;; +;; If the value is other than 1 (or if it is 1 with `Levenshtein +;; strict'), then you must also use library `levenshtein.el', and +;; Levenshtein completion can be quite slow. In that case, you will +;; no doubt want to turn off incremental completion (`C-#'). +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Icicles Multi `M-x'") +;; for completion of command abbreviations +;; +;; * (@file :file-name "icicles-doc1.el" :to "Apropos Completions") +;; for completion with regexp matching + +;;(@* "Completion in Other Buffers") +;; +;; Completion in Other Buffers +;; --------------------------- +;; +;; In addition to input completion, you can use Icicles to complete +;; words and symbols in other buffers, besides the minibuffer. +;; Icicles enhances this completion in these ways: +;; +;; 1. Lisp symbol completion via `M-TAB' (`lisp-complete-symbol'). +;; (This is also `ESC-TAB' and `C-M-i'.) +;; +;; 2. Word completion using the dynamic abbreviation of standard +;; Emacs library `dabbrev.el', via `C-M-/'. +;; +;; 3. Mailing information completion for BBDB (Insidious Big Brother +;; Database). +;; +;; 4. Word completion using the words and phrases in a thesaurus, via +;; `C-c /' (requires library `synonyms.el'). +;; +;; 5. `TAB' completion of the following in Shell mode and ESS modes +;; (and other, similar interpreters): +;; +;; * Commands +;; * Previous inputs - commands plus their arguments +;; * File names +;; * Environment variables +;; +;; Whenever multiple completion candidates are available, you can use +;; Icicles completion, with all of its features: cycling of +;; candidates (`TAB', `down', or `next'), apropos (regexp) completion +;; (`S-TAB'), progressive completion (`M-SPC'), help on individual +;; candidates (`C-M-RET'), and so on. +;; +;;(@* "Dynamic Abbreviation") +;; ** Dynamic Abbreviation ** +;; +;; Library `dabbrev.el' lets you type a few characters in a buffer +;; and then prefix-complete them (in the same buffer) to a full word +;; or symbol name. The completion candidates come from words or +;; symbol names in buffers that you are editing. This functionality +;; is called "dynamic abbreviation", though that is not a very good +;; term for it (words are completed, not abbreviated, dynamically). +;; +;; In Emacs, there are two ways to "dynamically abbreviate" text: +;; +;; a. `M-/' (command `dabbrev-expand') completes to a candidate word. +;; Repeating it replaces the completion with a different one - +;; that is, it cycles candidates in the text buffer (not in the +;; minibuffer). +;; +;; b. `C-M-/' (command `dabbrev-completion') completes to the common +;; prefix of all matching completion candidates. Repeating it +;; displays buffer `*Completions*' for you to choose a candidate. +;; However, in this case, there is no way to cycle among the +;; candidates. +;; +;; If there are many candidate completions, then cycling among them +;; with `M-/' can be tedious. You can use `C-M-/' to complete to a +;; common prefix, thus narrowing the set of candidates, but then you +;; lose the ability to cycle among them. +;; +;; If user option `icicle-redefine-standard-commands-flag' is non-nil +;; (which is the case by default), then Icicles redefines command +;; `dabbrev-completion' (it does not change `dabbrev-expand') so that +;; it uses Icicles completion when there are multiple completions. +;; You can use any Icicles features, such as apropos completion and +;; candidate cycling. In addition, you can even complete an empty +;; prefix, starting from scratch with apropos completion. +;; +;;(@* "BBDB Completion") +;; ** BBDB Completion ** +;; +;; Library `bbdb.el', available at http://bbdb.sourceforge.net/, is a +;; rolodex-like database program for GNU Emacs. +;; +;; If user option `icicle-redefine-standard-commands-flag' is non-nil +;; (which is the case by default), then Icicles redefines command +;; `bbdb-complete-name' so that it uses Icicles completion when there +;; are multiple completions. You can use any Icicles features, such +;; as apropos completion and candidate cycling. For this feature to +;; take effect, you must load BBDB before you load Icicles. +;; +;;(@* "Thesaurus Completion") +;; ** Thesaurus Completion ** +;; +;; Library `synonyms.el' provides various features for defining a +;; thesaurus and looking up words and phrases in it. Command +;; `icicle-complete-thesaurus-entry' takes advantage of these +;; features. You can use it to complete a word in a text buffer to +;; any word or phrase in the thesaurus. With the default value of +;; option `icicle-top-level-key-bindings', this is bound to `C-c /' +;; in Icicle mode. +;; +;; Tip: You can use `icicle-complete-thesaurus-entry' to quickly +;; check the spelling of a word. If it is correctly spelled, then it +;; appears as a complete completion (is highlighted as such in the +;; minibuffer). +;; +;; Another Icicles command that uses the thesaurus is +;; `icicle-insert-thesaurus-entry'. It lets you use Icicles +;; completion, cycling, and so on to insert thesaurus words and +;; phrases in any buffer. It does not complete the word at point. +;; It is a multi-command (see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands")), so you +;; can, within a single call to it, insert any number of thesaurus +;; entries, in succession. If you wanted to, you could write an +;; entire book using a single call to +;; `icicle-insert-thesaurus-entry'! +;; +;; Both commands, `icicle-complete-thesaurus-entry' and +;; `icicle-insert-thesaurus-entry', require that you first load +;; library `synonyms.el'. See library `synonyms.el' for more +;; information. +;; +;;(@* "Completion in Comint Modes") +;; ** Completion in Comint Modes ** +;; +;; `TAB' in a shell or similar buffer provides Icicles completion for +;; command names, file names, and environment variables that are +;; known to the shell (or other interpreter). +;; +;; You can also complete input using your previous inputs as the set +;; of candidates. Just type something at the prompt, hit `C-c `', +;; and pick one or more previous inputs to execute again (this uses +;; `icicle-search', so it is a multi-command). You need not +;; re-execute the exact same shell command; you can edit your +;; previous input before hitting `RET' to enter the command. +;; +;; These features are available for Comint mode and several modes +;; that inherit from it, including Shell mode, Shell Script (SH) +;; mode, various ESS modes (Emacs Speaks Statistics), Inferior +;; Emacs-Lisp mode (IELM), Grand Unified Debugger (GUD) mode, Tcl +;; mode, Rlogin mode, and NS Lookup mode. +;; +;; See Also: +;; +;; * (@> "Icicles Shell-Command Enhancements") for more information +;; about Icicles enhancements for Comint mode and related modes +;; +;; * (@> "Other Icicles Search Commands") for information about other +;; Icicles search enhancements for Comint mode and related modes +;; +;; * (@> "Defining Buffer-Text Completion for Comint Modes") for +;; information about how you can add Icicles completion to other +;; modes that inherit from Comint mode + +;;(@* "Customization and General Tips") +;; +;; Customization and General Tips +;; ------------------------------ +;; +;; This section contains some tips on using Icicles and descriptions +;; of Icicles user options. +;; +;; See Also: +;; +;; * (@> "File-Name and Directory-Name Completion Tips") for tips on +;; using Icicles to complete file names. User options related to +;; file-name and directory-name completion are presented there, not +;; here. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Dealing With Large Candidate Sets") +;; for tips on improving performance when dealing with a large +;; number of completion candidates. +;; +;; * (@> "Customizing Key Bindings") for information on customizing +;; Icicles key bindings. +;; +;;(@* "Using Icicles with Delete Selection Mode") +;; ** Using Icicles with Delete Selection Mode ** +;; +;; Icicles works especially well with Delete Selection mode, which I +;; use and recommend. (Likewise, for PC selection mode, which uses +;; Delete Selection mode.) In Delete Selection mode, whenever the +;; region (selection) is active (highlighted), you can simply type to +;; replace text in the region, or hit `DEL' (Backspace) or `C-d' +;; (Delete) to delete the region. +;; +;; However, library `delsel.el', which provides Delete Selection +;; mode, binds keys in minibuffer maps that are also bound by +;; Icicles. For this reason, if you use both Icicles and Delete +;; Selection mode, you must turn on Icicle mode after you turn on +;; Delete Selection mode. If you forget to do this, you will notice +;; that `C-g' does not abort minibuffer input. The remedy is simply +;; to turn Icicle mode off, then on again. +;; +;;(@* "Icicles User Options and Faces") +;; ** Icicles User Options and Faces ** +;; +;; There are several user options (user variables) and faces that +;; Icicles defines, and you can also use various standard user +;; options, including Icomplete options, that control various aspects +;; of completion. +;; +;; * User option `icicle-mode-hook' is a normal hook containing +;; functions that are run after entering and exiting Icicle mode. +;; This is nil, by default. +;; +;; * User option `icicle-minibuffer-setup-hook' is a list of +;; functions to be run at the end of minibuffer setup for Icicle +;; mode. This is nil, by default. +;; +;; * User option `icicle-update-input-hook' is a list of functions to +;; be run when minibuffer input is updated (typing or deleting). +;; This is nil, by default. +;; +;; * User option `icicle-no-match-hook' is a list of functions to be +;; run during completion (`TAB' or `S-TAB') when there are no +;; completion candidates that match the current input. This is +;; nil, by default. +;; +;; * Case sensitivity: The following standard user options control +;; whether completion distinguishes between uppercase and lowercase +;; letters: +;; +;; * `completion-ignore-case' +;; * `read-file-name-completion-ignore-case' (Emacs 22 and later) +;; * `read-buffer-completion-ignore-case' (Emacs 23 and later) +;; +;; In addition, you can toggle case-sensitivity at any time using +;; `C-A' (that is, `C-S-a') in the minibuffer. This toggles +;; `case-fold-search' and `completion-ignore-case'. With a prefix +;; argument, it also toggles +;; `read-file-name-completion-ignore-case' and +;; `read-buffer-completion-ignore-case'. +;; +;; More precisely, it toggles the default value of +;; `case-fold-search', and then it sets the other variables to the +;; value of `case-fold-search'. Because the default value of +;; `case-fold-search' is changed, all buffers are affected. Note +;; that because some Icicles commands bind one or more of these +;; variables, toggling case-sensitivity during command execution +;; will not necessarily toggle their global values. +;; +;; You can tell whether completion is currently case-sensitive by +;; looking at the Icicle minor-mode lighter in the mode line, if +;; `icicle-highlight-lighter-flag' is non-nil. If case-sensitive, +;; then the lighter text (with or without multi-command symbol `+') +;; is `Icy'; if not, it is `ICY'. +;; +;; * User options `icicle-region-background', +;; `icicle-point-position-in-candidate', +;; `icicle-mark-position-in-candidate', and +;; `icicle-change-region-background-flag' are all used to define +;; the region (the selected text) when cycling completion +;; candidates. They are described below individually. The region +;; is active when cycling, so you can easily delete it or replace +;; it. +;; +;; * User option `icicle-point-position-in-candidate' defines the +;; minibuffer cursor position (point) while cycling candidate +;; completions. By default, the cursor is placed at the end of the +;; root being completed. You can instead place it at the root +;; beginning or at the beginning or end of the complete minibuffer +;; input. For file-name input, the beginning of minibuffer input +;; starts after the directory name (which is inserted +;; automatically). +;; +;; * Similarly, user option `icicle-mark-position-in-candidate' +;; defines the position of the mark; by default, it is at the end +;; of the input. Together, these two options control the size and +;; placement of the region in a flexible way. You can make the +;; region include all of the input, only the root, from beginning +;; to root, or from root to end. You can put the cursor at either +;; end of the region. You can get rid of the region altogether, by +;; making point and mark coincide (at any of the possible +;; positions). +;; +;; * Because the region background color is often quite different +;; from the frame background color (in order to have it stand out), +;; it can be a bit hard to read the completion candidates when the +;; region is highlighted during input cycling. If user option +;; `icicle-change-region-background-flag' is non-nil, however, then +;; the region background is changed to a color that differs only +;; slightly from the frame background, making it easier to read the +;; completion candidates. The actual background color used is the +;; value of `icicle-region-background', which you can customize. +;; If you make this color the same as the frame background, then +;; the region background is, in effect, invisible. +;; +;; * The default value of `icicle-change-region-background-flag' is +;; determined by the current value of `delete-selection-mode', that +;; is, whether or not Delete Selection mode is enabled, when +;; Icicles is loaded. For this reason, if you use Delete Selection +;; mode and you want the region background to change in the +;; minibuffer, you should either turn on Delete Selection mode +;; before loading `icicles.el' or explicitly customize +;; `icicle-change-region-background-flag' to non-nil. +;; +;; * User option `icicle-default-value' controls the treatment of a +;; default value for minibuffer input. This includes not only +;; functions that read input with completion (`completing-read', +;; `read-file-name'), but also other input-reading functions: +;; `read-from-minibuffer' and `read-string'. The default value of +;; t gives the vanilla Emacs behavior: `completing-read' adds the +;; default input value to the prompt as a hint (but +;; `read-file-name' does not). Non-nil and non-t means to +;; automatically insert the default input value into the minibuffer +;; as the initial value. I prefer to have it inserted, as I often +;; use the default value (perhaps editing it). A value of nil +;; neither inserts the default value nor adds it to the prompt. If +;; the value is t or nil, remember that you can always insert the +;; default value manually with `M-n'. If the value is neither t +;; nor nil, you can always use `M-p' to remove the default value +;; from the minibuffer. +;; +;; A non-nil, non-t value of `icicle-default-value' controls also +;; whether or not the initial value is preselected, and where to +;; leave the cursor: at the beginning or end of the value. +;; Preselecting the value can be useful in Delete Selection mode or +;; PC Selection mode, because it makes it easy to replace that +;; value by typing characters, or delete it by hitting `DEL' +;; (Backspace) or `C-d' (Delete). However, all of the initial +;; input is lost if you type or hit `C-d' or `DEL', which is +;; inconvenient if you want to edit it only slightly. +;; +;; * User options `icicle-thing-at-point-functions' and +;; `icicle-default-thing-insertion' control the behavior of `M-.' +;; in the minibuffer, which grabs text from the current buffer and +;; yanks it into the minibuffer. +;; See (@file :file-name "icicles-doc1.el" :to "Inserting Text Found Near the Cursor") +;; and the doc string (`C-h v') of +;; `icicle-thing-at-point-functions' for more information. +;; +;; * User option `icicle-comint-dynamic-complete-replacements' +;; specifies a list of function replacements for +;; `icicle-comint-dynamic-complete' to replace the functions in +;; `comint-dynamic-complete-functions'. You can use this to +;; provide Icicles completion for various modes that inherit from +;; Comint mode. By default, it treats Comint mode and Shell mode. +;; +;; * User option `icicle-input-string' is a regexp string that is +;; inserted in the minibuffer when you use `C-='. See +;; (@file :file-name "icicles-doc1.el" :to "Inserting a Regexp from a Variable or Register"). +;; +;; * In buffer `*Completions*', face `icicle-saved-candidate' +;; highlights candidates that have been saved, face +;; `icicle-current-candidate-highlight' highlights the current +;; completion candidate, and, provided user option +;; `icicle-expand-input-to-common-match-flag' is non-nil, face +;; `icicle-common-match-highlight-Completions' highlights the +;; expanded common match among all completions. Faces +;; `icicle-match-highlight-Completions' and +;; `icicle-match-highlight-minibuffer' highlight whatever your +;; input matches, in buffer `*Completions*' and in the minibuffer, +;; respectively. In the minibuffer, face `icicle-complete-input' +;; highlights your input when it is complete. +;; +;; * Non-nil user option `icicle-touche-pas-aux-menus-flag' means +;; that Icicles will not add menu items to menu-bar menus, except +;; for the Icicles and Minibuf menus. Default value nil means that +;; whenever an appropriate menu-bar menu exists, Icicles items are +;; added to it (when in Icicle mode). For example, if nil, then +;; Delete File is added to the File menu; otherwise it is added to +;; the Icicles menu. The value of this option is used only when +;; Icicle mode is initially established, so changing it has no +;; effect after Icicles has been loaded. However, you can change +;; it and save the new value, so it will be used next time. +;; +;; * User option `icicle-redefine-standard-commands-flag' controls +;; whether Icicles redefines some standard commands, enhancing them +;; to use Icicles completion. A non-nil value causes redefinition. +;; +;; * Option `icicle-inhibit-advice-functions' is a list of functions +;; that Icicles redefines, and for which Icicle mode deactivates +;; the advice. The advice for each is reactivated when you leave +;; Icicle mode. Generally, it is a bad idea to use advice with +;; functions that Icicles redefines, in particular minibuffer +;; functions. If you want to allow some such advice or prohibit +;; advice for additional functions, then customize this list. +;; +;; Note: If you or a library you load advises one of these +;; functions while you are in Icicle mode, then toggle Icicle mode +;; twice, so that this option can have the proper effect. +;; +;; * The following user options specify the keys to use for +;; completion-candidate cycling: +;; +;; `icicle-apropos-cycle-previous-keys' (cycle) +;; `icicle-apropos-cycle-next-keys' (cycle) +;; `icicle-prefix-cycle-previous-keys' (cycle) +;; `icicle-prefix-cycle-next-keys' (cycle) +;; `icicle-apropos-cycle-previous-action-keys' (cycle, act) +;; `icicle-apropos-cycle-next-action-keys' (cycle, act) +;; `icicle-prefix-cycle-previous-action-keys' (cycle, act) +;; `icicle-prefix-cycle-next-action-keys' (cycle, act) +;; `icicle-apropos-cycle-previous-alt-action-keys' (cycle, alt act) +;; `icicle-apropos-cycle-next-alt-action-keys' (cycle, alt act) +;; `icicle-prefix-cycle-previous-alt-action-keys' (cycle, alt act) +;; `icicle-prefix-cycle-next-alt-action-keys' (cycle, alt act) +;; `icicle-apropos-cycle-previous-help-keys' (cycle, help) +;; `icicle-apropos-cycle-next-help-keys' (cycle, help) +;; `icicle-prefix-cycle-previous-help-keys' (cycle, help) +;; `icicle-prefix-cycle-next-help-keys' (cycle, help) +;; +;; By default, these keys are, respectively, `prior', `next', `up', +;; `down', `C-prior', `C-next', `C-up', `C-down', `C-S-prior', +;; `C-S-next', `C-S-up', `C-S-down', `C-M-prior', `C-M-next', +;; `C-M-up', and `C-M-down'. +;; +;; The keys defined by options `icicle-prefix-cycle-previous-keys' +;; and `icicle-prefix-cycle-next-keys' are used also to move up or +;; down a line in buffer `*Completions*'. +;; +;; * Non-nil option `icicle-cycling-respects-completion-mode' causes +;; the modal cycling keys to act differently during completion. +;; Those keys are `up', `down', `C-up', and `C-down' by default, +;; but they are configurable by user options +;; `icicle-modal-cycle-up-action-keys', +;; `icicle-modal-cycle-up-alt-action-keys', +;; `icicle-modal-cycle-up-help-keys', `icicle-modal-cycle-up-keys', +;; `icicle-modal-cycle-down-action-keys', +;; `icicle-modal-cycle-down-alt-action-keys', +;; `icicle-modal-cycle-down-help-keys', and +;; `icicle-modal-cycle-down-keys'. +;; +;; The completion mode, and hence the behavior of these keys, is +;; changed whenever you hit `TAB' or `S-TAB' during completion: the +;; mode is prefix completion after `TAB' and apropos completion +;; after `S-TAB'. +;; +;; Before you hit `TAB' or `S-TAB', the cycling behavior depends on +;; the particular non-nil value of the option: +;; +;; - `prefix' means cycle prefix completions +;; - `apropos' means cycle apropos completions +;; - Other non-nil value means cycle inputs from the input history +;; +;; For example, if the value is `apropos' then you can immediately +;; cycle apropos completions without first hitting `S-TAB'. +;; +;; Once you have used `TAB' or `S-TAB', the only way to traverse +;; the input history is to use `M-p' and `M-n' (`up' and `down' +;; will cycle completions). +;; +;; If the option is non-nil you can still use `M-p' and `M-n' to +;; traverse the input history, and `prior' and `next' to cycle +;; apropos completions (assuming that those default keys have not +;; been changed). And if you customize either the modal cycling +;; keys or the prefix cycling keys so that they are different +;; (e.g. one of those sets is no longer `up'/`down'), then you can +;; also still use the latter. In this case, you need not use `TAB' +;; and `S-TAB' to switch between the two completion types, even +;; when this option is non-nil - you can use the separate apropos +;; and prefix cycling keys. +;; +;; * The values of user options `icicle-modal-cycle-up-action-keys', +;; `icicle-modal-cycle-up-alt-action-keys', +;; `icicle-modal-cycle-up-help-keys', `icicle-modal-cycle-up-keys', +;; `icicle-modal-cycle-down-action-keys', +;; `icicle-modal-cycle-down-alt-action-keys', +;; `icicle-modal-cycle-down-help-keys', and +;; `icicle-modal-cycle-down-keys', are the keys used for modal +;; cycling. By default, these keys are `C-up', `C-S-up', `C-M-up', +;; `up', `C-down', `C-S-down', `C-M-down', and `down'. These +;; options have an effect only if option +;; `icicle-cycling-respects-completion-mode' is non-nil. +;; +;; * User option `icicle-word-completion-keys' is a list of keys to +;; use for word completion. By default, the only such key is +;; `M-SPC'. +;; +;; * User option `icicle-apropos-complete-no-display-keys' is a list +;; of keys to bind to `icicle-apropos-complete-no-display'. By +;; default, these keys are `C-M-S-tab' and `C-M-S-iso-lefttab', +;; which together implement `C-M-S-TAB'. Similarly, +;; `icicle-prefix-complete-no-display-keys' is the list of keys for +;; `icicle-prefix-complete-no-display'. By default, the only such +;; key is `C-M-tab'. +;; +;; * Option `icicle-prefix-complete-keys' is the list of keys for +;; `icicle-prefix-complete'. By default, these keys are `tab' and +;; `C-i', which together implement `TAB'. +;; +;; * Option `icicle-apropos-complete-keys' is the list of keys to +;; bind to `icicle-apropos-complete'. By default, these keys are +;; `S-tab' and `S-iso-lefttab', which together implement `S-TAB'. +;; (In Emacs 22 and later, `backtab' is the canonical key that +;; represents both `S-tab' and `S-iso-lefttab', so that is used in +;; the default value.) +;; +;; * Option `icicle-key-complete-keys' is the list of keys to bind to +;; `icicle-complete-keys'. By default, these keys are `S-tab' and +;; `S-iso-lefttab', which together implement `S-TAB'. (In Emacs 22 +;; and later, `backtab' is the canonical key that represents both +;; `S-tab' and `S-iso-lefttab', so that is used in the default +;; value.) +;; +;; * Option `icicle-previous-candidate-keys' is the list of keys to +;; bind to `icicle-move-to-previous-completion', for moving among +;; candidates in buffer `*Completions*'. By default, these keys +;; are `S-tab' and `S-iso-lefttab', which together implement +;; `S-TAB'. (In Emacs 22 and later, `backtab' is the canonical key +;; that represents both `S-tab' and `S-iso-lefttab', so that is +;; used in the default value.) +;; +;; * Option `icicle-isearch-complete-keys' is the list of keys for +;; `icicle-isearch-complete'. By default, these keys are `M-TAB', +;; `ESC TAB', `C-M-TAB', and `M-o'. +;; +;; * Option `icicle-read+insert-file-name-keys' is the list of keys +;; for invoking file-name completion on demand. By default, +;; `C-M-S-f' is the only such key. Option +;; `icicle-completing-read+insert-keys' is the list of keys for +;; invoking non file-name completion on demand. By default, +;; `C-M-S-c' is the only such key. See (@> "Completion On Demand"). +;; +;; * User option `icicle-act-before-cycle-flag' nil means that keys +;; such as `C-next', which combine candidate action and cycling, +;; cycle to the next (or previous) candidate and act on it. +;; Non-nil means they act on the current candidate and then cycle +;; to the next (or previous) candidate. When the value is nil, you +;; can think of `C-next' as an operation on the next candidate. +;; When the value is non-nil, you can think of `C-next' as an +;; operation on the current candidate, which ends by making the +;; next candidate current. Similarly for the other cycling keys +;; that act, alternative-act, or show help on a candidate. The +;; default value is nil. See also option +;; `icicle-use-C-for-actions-flag', which changes the keys affected +;; by `icicle-act-before-cycle-flag'. +;; +;; * If option `icicle-use-C-for-actions-flag' is nil, then the keys +;; that cycle candidates are swapped with the keys that both cycle +;; and act on a candidate. You can then use `C-down', `C-up', +;; `C-next', and `C-prior' to both cycle and act, and `down', `up', +;; `next', and `prior' to merely cycle, without acting +;; (e.g. navigating). The option has no effect on other keys. You +;; can toggle this option at any time using `M-g' +;; (`icicle-toggle-C-for-actions') in the minibuffer. +;; +;; (The keys mentioned here are the default bindings. The actual +;; keys swapped are those defined by these user options: +;; `icicle-prefix-cycle-next-action-keys', +;; `icicle-prefix-cycle-previous-action-keys', +;; `icicle-apropos-cycle-next-action-keys', +;; `icicle-apropos-cycle-previous-action-keys', +;; `icicle-modal-cycle-down-action-keys', +;; `icicle-modal-cycle-up-action-keys', +;; `icicle-prefix-cycle-next-keys', +;; `icicle-prefix-cycle-previous-keys', +;; `icicle-apropos-cycle-next-keys', +;; `icicle-apropos-cycle-previous-keys', +;; `icicle-modal-cycle-down-keys', `icicle-modal-cycle-up-keys'.) +;; +;; * Non-nil user option `icicle-top-level-when-sole-completion-flag' +;; means that whenever there is only one completion candidate that +;; matches your input, that candidate is used immediately, without +;; requiring you to hit `RET' or `S-RET'. +;; +;; * When `icicle-top-level-when-sole-completion-flag' is nil, option +;; `icicle-top-level-when-sole-completion-delay' is the number of +;; seconds Icicles waits, before returning to top level with the +;; sole completion. (It has no effect if the flag is nil.) The +;; delay gives you a chance to forestall acceptance of the sole +;; completion: editing the completion (typing or deleting a +;; character) before the delay expires prevents its automatic +;; acceptance. The default value is 0 seconds (no delay). +;; +;; * Non-nil user option `icicle-TAB-shows-candidates-flag' means +;; that hitting `TAB' for prefix completion immediately shows the +;; completion candidates in buffer `*Completions*'. If nil, then +;; candidates are shown only after `TAB' is hit a second time, +;; which is the standard Emacs behavior. The default value is t. +;; (Actually, the concerned keys are those defined by option +;; `icicle-prefix-complete-keys', not necessarily `TAB'.) +;; +;; * Non-nil option `icicle-max-candidates' means truncate the list +;; of completion candidates to at most this many. If you use +;; library `doremi.el' then you can use `C-x #' during completion +;; to increment or decrement the option value using the vertical +;; arrow keys or the mouse wheel. A numeric prefix argument for +;; `C-x #' sets the increment size. A plain prefix argument +;; (`C-u') resets `icicle-max-candidates' to nil, meaning no +;; truncation. +;; +;; * Non-nil user option `icicle-expand-input-to-common-match-flag' +;; means that completion commands `TAB' and `S-TAB' expand your +;; minibuffer input to (typically) the longest substring common to +;; all completion candidates and that matches your (complete) input +;; pattern. This replaces the input you typed. If you want to +;; edit your original, raw input, use `C-l'. If your input has +;; been expanded, then hit `C-l' twice: once to replace a +;; completion candidate (from, say, `next') with the common match +;; string, and a second time to replace the common match string +;; with your original input. The main reason you might want to set +;; this to nil is for apropos completion, if you want to always +;; work with a regexp in the minibuffer. You can toggle this +;; option at any time using `C-;' in the minibuffer. +;; See (@file :file-name "icicles-doc1.el" :to "Expanded-Common-Match Completion"). +;; +;; * Non-nil user option +;; `icicle-hide-common-match-in-Completions-flag' hides the common +;; match for your current input from each candidate in +;; *Completions*. You can toggle this at any time during +;; completion using `C-x .' (`icicle-toggle-hiding-common-match'). +;; +;; * User option `icicle-show-Completions-initially-flag' controls +;; whether or not buffer `*Completions*' is shown initially, +;; without your needing to hit `TAB' or `S-TAB' to show it. +;; However, if you type something before +;; `icicle-incremental-completion-delay', then display is +;; inhibited. The default value is nil, meaning that +;; `*Completions*' is not shown until you hit `TAB' or `S-TAB'. +;; More typical than setting this option to non-nil globally is to +;; bind it to non-nil in Emacs-Lisp code, to display +;; `*Completions*' as a menu. For example, pass a non-nil binding +;; to `icicle-define-command' to create a command that displays a +;; multiple-choice menu. +;; +;; For an alternative but similar behavior to using non-nil for +;; `icicle-show-Completions-initially-flag', you can set option +;; `icicle-incremental-completion-flag' to a value that is neither +;; nil nor t. That displays `*Completions*' as soon as you type or +;; delete input, but not initially. +;; +;; * User option `icicle-incremental-completion-flag' controls +;; whether or not `*Completions*' is updated incrementally +;; (icompletion) as you type. You can toggle incremental +;; completion at any time using `C-#'. For more information, see +;; (@file :file-name "icicles-doc1.el" :to "Icompletion"). +;; +;; * User options `icicle-incremental-completion-delay' and +;; `icicle-incremental-completion-threshold' together cause a delay +;; before incremental completion takes effect. +;; See (@file :file-name "icicles-doc1.el" :to "Icompletion"). +;; +;; * User option `icicle-Completions-display-min-input-chars' is the +;; minimum number of input characters that allow buffer +;; `*Completions*' to remain displayed. By default, this is zero +;; (0), meaning that any number of input characters, even none, +;; allows `*Completions*' to remain displayed. If you use +;; incremental completion (see `icicle-incremental-completion-*'), +;; and you are bothered by `*Completions*' being automatically +;; updated when, for instance, you empty the minibuffer, then you +;; might want to set this option to, say, 1 or 2. With a value of +;; 2, for instance, whenever the minibuffer input has less than 2 +;; characters, incremental completion will remove the +;; `*Completions*' window. You can also remove the `*Completions*' +;; window at any time using `C-x 0' in the minibuffer. +;; +;; * Non-nil option `icicle-show-Completions-help-flag' means display +;; help (instructions) at the top of the `*Completions*' window. +;; These instructions are shown in faces +;; `icicle-Completions-instruction-1' and +;; `icicle-Completions-instruction-2'. +;; +;; * Non-nil option `icicle-help-in-mode-line-flag' means display +;; help on individual completion candidates in the mode-line as you +;; cycle or your input is completed. The mode-line used is that of +;; buffer `*Completions*', if it is displayed, or the current +;; buffer, otherwise. Typically, this mode-line candidate help is +;; the first line of a doc string, but alternative help is +;; available. +;; +;; * Face `icicle-mode-line-help' is used to highlight Icicles help +;; shown in the mode-line. This includes that controlled by option +;; `icicle-help-in-mode-line-flag' and the indication in +;; `*Completions*' of the total number of matching candidates. +;; +;; * User option `icicle-Completions-frame-at-right-flag' controls +;; whether `icicle-candidate-action' moves the frame showing buffer +;; `*Completions*' to the right, out of the way of other frames. +;; This can be useful if you use one-buffer-per-frame (non-nil +;; `pop-up-frames'). In that case, I recommend that you also try +;; my library `oneonone.el'. +;; See (@> "Note on Non-nil `pop-up-frames' on MS Windows") for +;; more advice about non-nil `pop-up-frames'. +;; +;; * User option `icicle-Completions-window-max-height' is the +;; maximum height of the `*Completions*' window, in lines. The +;; window is fit to the buffer size, with this as maximum height. +;; This is not used if `*Completions*' is a special display buffer +;; with its own frame, and it is not used in Emacs releases prior +;; to 21. +;; +;; * Starting with Emacs 23, you can use option +;; `icicle-Completions-text-scale-decrease' to change the size of +;; the text used in buffer `*Completions*'. +;; +;; * User option `icicle-candidate-width-factor' controls how many +;; columns of completion candidates are displayed in +;; `*Completions*'. The widest current candidate is scaled by this +;; percentage, and the window width is divided by that figure. +;; Other things are taken into account also, but this gives you a +;; way to tweak the number of columns: the larger this number, the +;; fewer the columns. +;; +;; If you use Do Re Mi (library `doremi.el'), then you can modify +;; `icicle-candidate-width-factor' incrementally during completion, +;; seeing the effect as it changes. Use `C-x w' from the +;; minibuffer, then use the `right' and `left' arrow keys or the +;; mouse wheel to increment and decrement the value. You can at +;; the same time use the `up' and `down' keys to adjust the value +;; of `icicle-inter-candidates-min-spaces'. WYSIWYG. +;; +;; * User option `icicle-inter-candidates-min-spaces' is the minimum +;; number of spaces between candidates displayed in +;; `*Completions*'. The default value is one space. +;; +;; If you use Do Re Mi (library `doremi.el'), then you can modify +;; `icicle-inter-candidates-min-spaces' incrementally during +;; completion, seeing the effect as it changes. Use `C-x |' from +;; the minibuffer, then use the `up' and `down' arrow keys or the +;; mouse wheel to increment and decrement the value. You can at +;; the same time use the `left' and `right' keys to adjust the +;; value of `icicle-candidate-width-factor'. WYSIWYG. +;; +;; * Option `icicle-completions-format' controls whether candidates +;; displayed in `*Completions*' are laid out horizontally (the +;; default) or vertically. Set the value to `vertical' for the +;; latter. Starting with Emacs 23.2, you can just use the vanilla +;; option `completions-format' for this, if you want the same type +;; of layout with Icicle mode turned on or off. +;; +;; Multi-completions often involve complex, multi-line text for +;; which a vertical `*Completions*' layout is not appropriate. For +;; this reason, when multi-line multi-completions are used the +;; layout is horizontal, temporarily overriding any `vertical' +;; value for `icicle-completions-format' or `completions-format'. +;; +;; If you need to override this override behavior for some command, +;; use `icicle-minibuffer-setup-hook' and `minibuffer-exit-hook' to +;; temporarily set and reset the internal variable +;; `icicle-completions-format-internal'. +;; +;; * Face `icicle-historical-candidate' is used to highlight +;; completion candidates that you have used (entered with `RET') +;; previously. This highlighting is controlled by user option +;; `icicle-highlight-historical-candidates-flag'. You can toggle +;; this option from the minibuffer at any time using `C-pause'. +;; See (@file :file-name "icicles-doc1.el" :to "History Enhancements"). +;; +;; * If option `icicle-menu-items-to-history-flag' is non-nil (the +;; default), then commands that you invoke using the menu-bar menu +;; are included in the command history for `M-x'. +;; +;; * Non-nil option `icicle-populate-interactive-history-flag' means +;; that any interactive use of a command causes it to be added to +;; the history `icicle-interactive-history'. You can access this +;; history by using `C-M-pause' during completion. Be aware that +;; addition of all interactive invocations to this history can slow +;; Emacs down. (This option is only available starting with Emacs +;; 23.) +;; +;; * User option `icicle-sort-comparer' controls the order of +;; completion candidates during cycling and in buffer +;; `*Completions*'. If nil, then no sorting is done. If non-nil, +;; then the value must be a string-comparison function - the +;; function is passed to the standard function `sort' to do the +;; sorting. The default value for `icicle-sort-comparer' is +;; `icicle-case-string-less-p', which sorts alphabetically, +;; possibly ignoring letter case. During completion, you can +;; toggle sorting using `C-,'. If you are an Emacs-Lisp programmer +;; and you write new commands using Icicles functionalities, you +;; can bind `icicle-sort-comparer' temporarily to any sort function +;; you need. +;; +;; * User option `icicle-alternative-sort-comparer' is an alternative +;; to `icicle-sort-comparer, providing a different sort order. By +;; default, it is `icicle-historical-alphabetic-p', a function that +;; sorts previously used completion candidates before candidates +;; that have not yet been used, and sorts alphabetically within +;; each of these groups of candidates. In other words, it places +;; inputs that you have used previously at the top of buffer +;; `*Completions*' and makes them available for completion first. +;; During completion, you can toggle normal and alternative sorting +;; using `C-M-,'. See (@> "Sorting Candidates") and +;; (@file :file-name "icicles-doc1.el" :to "History Enhancements"). +;; +;; * User option `icicle-change-sort-order-completion-flag' specifies +;; whether `C-,' cycles among available sort orders or lets you +;; choose a sort order using Icicles completion. Non-nil means to +;; use completion; nil (the default value) means to cycle. You can +;; override the current setting at any time by using `C-u C-,'. +;; See (@> "Sorting Candidates"). +;; +;; * User option `icicle-sort-orders-alist' is an alist of possible +;; sort orders for user to choose from using `C-,' or `M-,'. +;; See (@> "Sorting Candidates"). +;; +;; * The value of user option `icicle-transform-function' is a +;; function that is applied to the list of completion candidates, +;; to transform them before they are presented to the user. If +;; nil, then no transformation is done. The default transformation +;; is to remove duplicate candidates, when transformation is +;; active, but the default value of this option is nil. You can +;; toggle transformation at any time using command +;; `icicle-toggle-transforming', bound to `C-$' in the minibuffer. +;; Although this is a user option, you probably do *NOT* want to +;; change its value by customizing it. Icicles commands already +;; "do the right thing" when it comes to candidate transformation. +;; +;; The value of this option can be changed by program locally, for +;; use in particular contexts. For example, when you use +;; `icicle-search-generic' (`C-c `') in a *shell* buffer, Icicles +;; uses this variable with a value of `icicle-remove-duplicates', +;; to remove duplicate shell commands from your input history list. +;; Lisp programmers can use this variable to transform the list of +;; candidates in any way they like. A typical use is to remove +;; duplicates, by binding it to `icicle-remove-duplicates' or +;; `icicle-remove-dups-if-extras'. +;; +;; * User options `icicle-require-match-flag', +;; `icicle-buffer-require-match-flag', and +;; `icicle-file-require-match-flag' let you override the value of +;; the REQUIRE-MATCH argument provided to `completing-read' or +;; `read-file-name'. They are provided mainly for use (binding) in +;; `icicle-define-command' and `icicle-define-file-command', but +;; you may also use them globally, if you wish. See +;; (@file :file-name "icicles-doc1.el" :to "Exiting the Minibuffer Without Confirmation"). +;; +;; A typical use is made in the definition of command +;; `icicle-buffer': `icicle-buffer-require-match-flag' is used to +;; bind `icicle-require-match-flag', so that you can, for example, +;; match only existing buffers and be able to match on partial +;; input without explicitly completing (hitting `TAB' or `S-TAB'). +;; Simply set the option to `partial-match-ok' to get this +;; behavior. To apropos-complete and exit the minibuffer, use +;; `S-RET' instead of `RET'. See +;; (@file :file-name "icicles-doc1.el" :to "Exiting the Minibuffer Without Confirmation"), +;; for more information. +;; +;; * Non-nil user option `icicle-ignore-space-prefix-flag' means to +;; ignore completion candidates that start with a space. However, +;; such candidates are not ignored for prefix completion if the +;; input also starts with a space. Naturally, apropos completion +;; is not affected by whether or not the input starts with a space. +;; +;; Option `icicle-buffer-ignore-space-prefix-flag' lets you +;; override the value of `icicle-ignore-space-prefix-flag' for use +;; with buffer-name completion (the names of internal buffers start +;; with a space). It is provided mainly for binding when using +;; `icicle-define-command' (`icicle-buffer' does this). +;; +;; You can toggle `icicle-ignore-space-prefix-flag' at any time +;; using `M-_' in the minibuffer. If the current command binds +;; this option locally, then it is the local, not the global, value +;; that is changed. For example, if +;; `icicle-buffer-ignore-space-prefix-flag' is non-nil, then `M-_' +;; toggles `icicle-ignore-space-prefix-flag' to nil only for the +;; duration of the buffer command (e.g. `icicle-buffer'). +;; +;; * Non-nil user option `icicle-test-for-remote-files-flag' means +;; that Icicles tests for remote file names; nil means that it does +;; not. You can toggle this using `C-^' in the minibuffer (except +;; during Icicles search). Turning off remote file-name testing +;; means that you cannot use remote files with Tramp; it disables +;; Tramp's remote file-name handling and completion. This can, for +;; local files, slightly speed up incremental completion and the +;; highlighting of the part of your current input that does not +;; complete (see `icicle-highlight-input-completion-failure'). +;; +;; * Non-nil user option `icicle-regexp-quote-flag' reduces apropos +;; completion to simple substring completion and Icicles regexp +;; search to literal search. Regexp special characters are no +;; longer recognized as special; they simply match themselves. You +;; probably do not want to customize this option. Instead, you can +;; toggle it at any time using `C-`' in the minibuffer. +;; +;; * User options `icicle-command-abbrev-match-all-parts-flag', +;; `icicle-command-abbrev-priority-flag', and +;; `icicle-command-abbrev-alist' control the behavior of +;; multi-command `icicle-command-abbrev' (`C-x SPC'). The first +;; determines whether an abbreviation must match all parts of a +;; command name. The second controls whether command names or +;; abbreviations take precedence in case of conflict. The third is +;; the persistent list of your command abbreviations. +;; +;; * User options `icicle-S-TAB-completion-methods-alist' and +;; `icicle-TAB-completion-methods' control which completion method +;; is used by `S-TAB' and `TAB', respectively, to complete your +;; input. By default, the first method in each list is used for +;; matching. You can use `M-(' and `C-(' (commands +;; `icicle-next-S-TAB-completion-method' and +;; `icicle-next-TAB-completion-method') in the minibuffer to cycle +;; among the `S-TAB' and `TAB' methods. +;; +;; For fuzzy completion (choice `fuzzy' when cycling with `C-('), +;; `TAB' completes non-filename input using fuzzy prefix matching +;; as defined in library `fuzzy-match.el'. See the Commentary in +;; `fuzzy-match.el' for details about fuzzy matching. +;; +;; Fuzzy completion is not available for file-name completion; it +;; is always case-sensitive; leading spaces are taken into account; +;; and completion candidates are always sorted by decreasing fuzzy +;; match strength. In other words, fuzzy completion is not +;; affected by `C-A', `M-_', or `C-,'. +;; +;; * User option `icicle-levenshtein-distance' is the Levenshtein +;; distance allowed for strings to be considered as matching during +;; N-off completion. This means that two strings match if they +;; differ by at most this many character operations (insertion, +;; deletion, replacement). This option is used only if you have +;; library `levenshtein.el'. See (@> "Fuzzy Completion"). +;; +;; * Top-level command `icicle-search' uses several faces to +;; highlight found text that matches your input. Faces +;; `icicle-search-main-regexp-current' and +;; `icicle-search-main-regexp-others' highlight what your +;; search-context regexp (entered with `RET') matches. The former +;; highlights the current search context; the latter highlights all +;; other search contexts. +;; +;; Face `icicle-search-current-input' highlights what your current +;; input (typically another regexp) matches; that is, it highlights +;; a match within a search context. Faces +;; `icicle-search-context-level-1' through +;; `icicle-search-context-level-8' highlight the first eight regexp +;; subgroup matches, within a search context. This highlighting is +;; done whenever `icicle-search-highlight-context-levels-flag' is +;; non-nil and the search context corresponds to the entire regexp. +;; +;; * User option `icicle-search-highlight-context-levels-flag' +;; controls highlighting of regexp subgroup matches within the +;; search context. Non-nil (the default value) means highlight +;; them. +;; +;; * User option `icicle-search-highlight-threshold' controls +;; highlighting with face `icicle-search-main-regexp-others': this +;; many matches, maximum, are highlighted. If zero, then only the +;; current match is highlighted. The effect is similar to the +;; Emacs 22+ lazy search highlighting of Isearch (except that the +;; highlighting is not in fact lazy). +;; +;; * Non-nil user option `icicle-search-highlight-all-current-flag' +;; means highlight the current input match in all main search hits +;; at the same time. If `icicle-expand-input-to-common-match-flag' +;; is also non-nil, then what is highlighted for each input match +;; is the expanded common match among all input matches throughout +;; the search area. If either is nil, then only the exact input +;; match is highlighted. +;; +;; The default value of `icicle-search-highlight-all-current-flag' +;; is nil, because non-nil can impact performance negatively if +;; there are many search contexts - the highlighting is updated +;; with each input change. You can toggle the value at any time +;; using command `icicle-toggle-highlight-all-current', bound to +;; `C-^' in the minibuffer (except during file-name completion). +;; +;; * If, in addition to `icicle-search-highlight-all-current-flag' +;; and `icicle-expand-input-to-common-match-flag', option +;; `icicle-search-replace-common-match-flag' is also non-nil, then +;; a search replacement replaces the expanded common match; +;; otherwise, it replaces only the exact match. You can toggle the +;; value at any time using `M-;' in the minibuffer. +;; +;; * Non-nil user option `icicle-search-cleanup-flag' means that +;; `icicle-search' highlighting is removed after the search. This +;; is the default behavior. If you set this to nil then you can +;; remove search highlighting manually later using command +;; `icicle-search-highlight-cleanup'. You can toggle this search +;; highlight removal at any time using command +;; `icicle-toggle-search-cleanup', bound to `C-.' in the minibuffer +;; (except during file-name completion). +;; +;; One use of nil `icicle-search-cleanup-flag' is to highlight +;; regexp matches throughout a region or buffer (or multiple files +;; or...). In that capacity, Icicles search functions act like +;; some of the highlighting commands in my library `highlight.el'. +;; Note that when `icicle-search-cleanup-flag' is nil, *all* +;; Icicles search highlighting remains: last-visited search +;; context, other context matches, current-input matches, and even +;; regexp subgroups. The faces for these are, respectively: +;; +;; - `icicle-search-main-regexp-current' +;; - `icicle-search-main-regexp-others' +;; - `icicle-search-highlight-input-matches-here' (everywhere, if +;; `icicle-search-highlight-all-current-flag' is non-nil) +;; - `icicle-search-context-level-1' through +;; `icicle-search-context-level-8' +;; +;; * Non-nil user option `icicle-search-whole-word-flag' means that +;; whole-word search is done. All characters in your search string +;; are searched for literally, and matches for the string must +;; begin and end on a word boundary. +;; +;; * User option `icicle-search-context-match-predicate', if non-nil, +;; is a predicate that takes a search-context (string) argument. +;; Only contexts that satisfy the predicate are used. For example, +;; if the predicate is (lambda (x) (commandp (intern-soft x))), +;; then only contexts that name commands are kept. +;; +;; * If user option `icicle-search-replace-whole-candidate-flag' is +;; nil, then whatever matches your current input is replaced, +;; within the current search context, when you perform replacement +;; during Icicles searching (e.g. `C-S-RET'). If the value is +;; non-nil (the default value), then the entire search context is +;; replaced, instead. You can use `C-,' at any time during +;; searching and replacing, to toggle the value. +;; +;; * User option `icicle-search-replace-literally-flag' determines +;; whether Icicles search-and-replace replaces text literally or +;; interprets `\' specially in the replacement text, as in +;; `query-replace-regexp'. Non-nil means to treat replacement text +;; literally. The default value is nil. You can use `C-M-`' to +;; toggle this at any time during Icicles search. +;; +;; * User option `icicle-search-hook' is a list of functions to be +;; run after searching and moving to an `icicle-search' match, +;; whether you move there by `RET', `C-RET', `C-next', or +;; `C-prior'. +;; +;; * User option `icicle-bookmark-name-length-max' is the maximum +;; number of characters to use when `icicle-bookmark-cmd' (`C-x r +;; m') with a non-negative numeric prefix argument automatically +;; names a bookmark. +;; +;; * User option `icicle-bookmark-refresh-cache-flag' determines +;; whether commands such as `icicle-bookmark' and +;; `icicle-search-bookmark' refresh the bookmark-list cache. The +;; default value of t, meaning refresh, ensures that the set of +;; bookmark candidates is always up-to-date, but you can improve +;; performance for a large bookmark list if you customize it to +;; nil. +;; +;; In any case, a plain prefix argument (`C-u') for these commands +;; overrides the default setting of the option for the duration of +;; the command. Thus if the customized value is nil, you can use +;; `C-u' occasionally to refresh the list on demand. In addition, +;; the cache is refreshed whenever you use `S-delete' to delete a +;; candidate bookmark. +;; +;; * Non-nil user option `icicle-show-multi-completion-flag' means +;; that for some commands additional information is shown along +;; with each completion candidate. That is, a multi-completion is +;; used. You can match against any parts of the multi-completion. +;; The default value is t. +;; +;; For example, for command `icicle-search', the name of the buffer +;; associated with each completion candidate is added to the +;; candidate and highlighted. You can match against the buffer +;; name, as well as the search hit within the buffer. +;; +;; Note that even when the value of this option is nil, you can +;; often see the multi-completion information in the mode-line when +;; you cycle candidates, and you can typically see it in the help +;; that is displayed by `C-M-mouse-2' and so on. +;; +;; * User options `icicle-buffer-match-regexp', +;; `icicle-buffer-no-match-regexp', `icicle-buffer-predicate', and +;; `icicle-buffer-extras' determine the behavior of Icicles buffer +;; commands, such as `icicle-buffer' and `insert-buffer'. They +;; determine the set of buffer-name candidates initially available +;; for completion. +;; +;; The first three restrict this set to names that satisfy the +;; properties they specify. Option `icicle-buffer-extras' lets you +;; add additional buffer names to the set of candidates, after +;; restriction by the other options. Extra buffer-name candidates +;; are displayed in buffer `*Completions*' using face +;; `icicle-extra-candidate'. +;; +;; Note that if an extra candidate is already a candidate anyway +;; then it will be present twice in the list of all candidates +;; (that is, unless `icicle-transform-function' removes duplicate +;; candidates). +;; +;; Since these are user options, they provide an additional, more +;; static way to filter the set of candidates. Typing input +;; (e.g. a regexp) then dynamically filters the result of applying +;; the filter options. +;; +;; Options `icicle-file-match-regexp', +;; `icicle-file-no-match-regexp', `icicle-file-predicate', and +;; `icicle-file-extras' act similarly for file-name completion. +;; You could use `icicle-file-no-match-regexp' or +;; `icicle-file-predicate', for instance, to exclude files that are +;; in or under the directories in `vc-directory-exclusion-list': +;; +;; (defun my-locate-non-vc-file () +;; "`icicle-locate-file', but excluding stuff in VC directories." +;; (interactive) +;; (let ((icicle-file-predicate 'not-excluded-vc-file-p)) +;; (icicle-locate-file))) +;; +;; (defun not-excluded-vc-file-p (file) +;; "nil if FILE is in a `vc-directory-exclusion-list' directory." +;; (or (not (boundp 'vc-directory-exclusion-list)) +;; (not (consp vc-directory-exclusion-list)) +;; (not (let ((case-fold-search completion-ignore-case)) +;; (catch 'nevfp +;; (dolist (dir vc-directory-exclusion-list) +;; (when (string-match +;; (concat ".*" dir "\\(/.*\\)?") +;; file) +;; (throw 'nevfp t))) +;; nil))))) +;; +;; * Option `icicle-ignored-directories' is a list of directories +;; that are ignored by commands `icicle-locate-file' and +;; `icicle-locate-file-no-symlinks'. By default, this is the value +;; of `vc-directory-exclusion-list'. +;; +;; * User option `icicle-buffer-sort' is a predicate used to sort +;; buffer-name candidates in Icicles buffer commands, such as +;; `icicle-buffer' and `icicle-insert-buffer'. One possible value +;; is `icicle-buffer-sort-*...*-last', which sorts names of +;; internal buffers, which begin with `*', after other buffer +;; names. Option `icicle-file-sort' acts similarly for file-name +;; completion. +;; +;; * User option `icicle-buffer-configs' is a list of named +;; configurations of options `icicle-buffer-match-regexp', +;; `icicle-buffer-no-match-regexp', `icicle-buffer-predicate', +;; `icicle-buffer-extras', and `icicle-buffer-sort'. You use +;; command `icicle-buffer-config' to choose one of the +;; configurations to be current. You can use commands +;; `icicle-add-buffer-config' and `icicle-remove-buffer-config' to +;; add and remove configurations from the list. +;; +;; Example: A configuration such as the following, named "Files and +;; Scratch", defines `icicle-buffer-predicate' to display only file +;; buffers, and it defines `icicle-buffer-extras' to include the +;; extra buffer `*scratch*': +;; +;; ("Files and Scratch" nil nil +;; (lambda (bufname) (buffer-file-name (get-buffer bufname))) +;; ("*scratch*") icicle-sort-comparer) +;; +;; The idea of buffer-option configurations was borrowed from +;; library `bs.el', by Olaf Sylvester . +;; +;; * User option `icicle-dot-string' is the regexp string inserted by +;; `icicle-insert-dot-command' (bound to `.' in the minibuffer +;; during completion). You can set it to a regexp that matches any +;; character, including newline. The default value instead matches +;; any character except newline. You can toggle between these two +;; behaviors using command `icicle-toggle-dot', bound to `C-M-.' +;; during completion. +;; +;; * Non-nil option `icicle-dot-show-regexp-flag' means show the +;; underlying regexp (value of constant `icicle-anychar-regexp') +;; explicitly for a multi-line dot (`.'). A nil value works only +;; for Emacs versions 21 and later. +;; +;; * User options `icicle-list-join-string', +;; `icicle-list-end-string', and +;; `icicle-list-nth-parts-join-string' are described in sections +;; (@> "Multi-Completions") and +;; (@> "Programming Multi-Completions"). Option +;; `icicle-list-join-string' is the separator string that joins +;; together the parts of a multi-completion. The end string is +;; appended to each multi-completion candidate. Option +;; `icicle-list-nth-parts-join-string' specifies how the +;; multi-completion extracted parts are joined back together when a +;; user chooses a multi-completion. +;; +;; The default value of `icicle-list-join-string' is `^G^J'. With +;; Emacs 22 and later, the `^G' part is hidden when it appears in +;; *Completions*, and you can hide it in the minibuffer also by +;; using `C-M-j' instead of typing `C-q C-g C-j'. See the doc +;; string for more information. +;; +;; * Face `icicle-candidate-part' highlights one or more parts of a +;; candidate, in buffer `*Completions*'. The candidate is +;; typically a multi-completion. +;; +;; * Face `icicle-special-candidate' highlights candidates, in +;; `*Completions*', that are considered "special". Generally, +;; these are candidates that match user option +;; `icicle-special-candidate-regexp'. +;; +;; * Similarly, face `icicle-proxy-candidate' highlights proxy +;; candidates. These are placeholders for real candidates. +;; Non-nil user option `icicle-add-proxy-candidates-flag' means +;; include proxy candidates whenever there are any. You can toggle +;; this option during completion using command +;; `icicle-toggle-proxy-candidates', which is bound to `C-M-_' in +;; the minibuffer. For performance reasons, you will in some cases +;; need to re-invoke the command to make the proxy candidates +;; available. +;; +;; * Face `icicle-extra-candidate' highlights extra candidates, that +;; is, members of `icicle-extra-candidates', `icicle-buffer-extras', +;; or `icicle-file-extras'. +;; +;; * User option `icicle-kmacro-ring-max' acts as `kmacro-ring-max' +;; when you are in Icicle mode. (When you exit Icicle mode, +;; `kmacro-ring-max' is restored.) In Icicles, you will typically +;; want to use a much larger number than the default value in +;; vanilla Emacs. +;; +;; * User options `icicle-regexp-search-ring-max' and +;; `icicle-search-ring-max' act as `regexp-search-ring-max' and +;; `search-ring-max', respectively, when you are in Icicle mode. +;; (When you exit Icicle mode, `regexp-search-ring-max' and +;; `search-ring-max' are restored.) The reason for having these +;; options is that with Icicles you will likely want to use a much +;; longer search history. By default, these are as large as +;; possible (virtually unlimited). +;; +;; Suggestion: If you use library `savehist.el' (recommended), +;; customize `savehist-additional-variables' to include variables +;; `search-ring' and `regexp-search-ring', so that your search +;; histories will be saved between Emacs sessions. +;; +;; Note: You can clear (empty) a given search history with command +;; `clear-option' (aka `icicle-reset-option-to-nil'). For example, +;; to clear the regular-expression search history, do this: +;; +;; `C-u M-x clear-option RET regexp-search-ring RET' +;; +;; (The `C-u' is needed because this variable is not a user +;; option.) If you use my library `misc-cmds.el', you can clear +;; search histories easier, using commands `clear-search-history', +;; `clear-regexp-search-history', and `clear-search-histories'. +;; See (@file :file-name "icicles-doc1.el" :to "Isearch Completion"). +;; +;; * User option `icicle-completion-history-max-length' limits the +;; number of completion inputs to save. If you customize user +;; option `icicle-C-l-uses-completion-flag' to non-nil, then, +;; instead of cycling, `C-l' lets you use Icicles completion to +;; retrieve a past completion input. (`C-L' does the same thing.) +;; If you use library `savehist.el', then you can save the history +;; of completion inputs persistently by customizing user option +;; `savehist-additional-variables' to include the Icicles internal +;; variables `icicle-previous-raw-file-name-inputs' and +;; `icicle-previous-raw-non-file-name-inputs'. +;; +;; * Faces `icicle-completion', `icicle-multi-command-completion', +;; and `icicle-mustmatch-completion' indicate the status of +;; minibuffer completion. During completion, Icicles uses them for +;; a minibuffer indicator and, if user option +;; `icicle-highlight-lighter-flag' is non-nil, for the `Icy' +;; mode-line lighter as well. +;; +;; * Non-nil option `icicle-highlight-input-initial-whitespace-flag' +;; uses face `icicle-whitespace-highlight' to highlight any +;; whitespace that starts your minibuffer input. This is done to +;; help you recognize accidentally typing such whitespace. +;; Otherwise, you might not understand the set of matching +;; completion candidates (or lack thereof). There is not +;; necessarily anything wrong with input that starts with +;; whitespace - it might be what you want, but without this +;; highlighting it is easy to not notice the whitespace. +;; +;; * The part of your current input that does not complete can be +;; highlighted automatically, and you can then remove that part +;; using `C-M-l'. This highlighting is controlled by options +;; `icicle-incremental-completion-flag', +;; `icicle-test-for-remote-files-flag', +;; `icicle-highlight-input-completion-failure', +;; `icicle-highlight-input-completion-failure-delay', and +;; `icicle-highlight-input-completion-failure-threshold'. The +;; highlighting uses face `icicle-input-completion-fail' (for +;; strict completion) or `icicle-input-completion-fail-lax' (for +;; lax completion). For details, see the option doc strings and +;; (@file :file-name "icicles-doc1.el" :to "Icicles Highlights the Input that Won't Complete"). +;; +;; * User option `icicle-top-level-key-bindings' specifies top-level +;; commands and their bindings for Icicle mode. By default, this +;; rebinds several standard Emacs keys (in Icicle mode only). For +;; example, it substitutes `icicle-kill-buffer' for `kill-buffer' +;; (binding it to whatever `kill-buffer' is bound to globally). +;; Top-level commands are commands that are not used only in the +;; minibuffer. To change these bindings, customize +;; `icicle-top-level-key-bindings'. If you do that, then you must +;; exit and re-enter Icicle mode to ensure that the change takes +;; effect. This is really necessary only if your changes would +;; undefine a key. +;; +;; * Non-nil option `icicle-define-alias-commands-flag' defines a few +;; top-level Icicles commands whose names do not begin with +;; `icicle-', for convenience when using `M-x'. For example, +;; command `toggle' is defined as an alias for command +;; `icicle-toggle-option'. In any case, no such command is ever +;; defined by Icicles if a function with the same name is already +;; defined. +;; +;; * User option `icicle-color-themes' is a list of color themes to +;; cycle through when you use command `icicle-color-theme'. +;; +;; * User option `icicle-saved-completion-sets' is a persistent list +;; of named sets of completion candidates. You can switch among +;; such sets at any time. See +;; (@file :file-name "icicles-doc1.el" :to "Persistent Sets of Completion Candidates"). +;; +;; * User option `icicle-filesets-as-saved-completion-sets-flag' +;; non-nil means you can use Emacs filesets to save completion +;; candidates persistently. This means that you can save file-name +;; candidates in a persistent Icicles saved completion set (cache +;; file) or in in an Emacs fileset. It also means that an Icicles +;; persistent completion set can contain filesets, in addition to +;; file names: any number of filesets, and filesets of different +;; type. Available only for Emacs 22 and later, and you must load +;; library `filesets.el' (and enable filesets using +;; `(filesets-init)'). +;; +;; * User option `icicle-key-descriptions-use-<>-flag' determines +;; whether angle brackets (`<', `>') are used by Icicles for named +;; keys, such as function keys (`' vs `f9') and pseudo keys +;; (`' vs `mode-line'). Non-nil means to use angle +;; brackets. This option does not affect Emacs key descriptions +;; outside of Icicles (e.g. `C-h k' or `C-h w'), and it has no +;; effect for versions of Emacs prior to 21, because they never use +;; angle brackets. The default value is nil, because I think angle +;; brackets reduce readability. +;; +;; * User option `icicle-keymaps-for-key-completion' is a list of +;; variables that are bound to keymaps in which you want to bind +;; `S-TAB' (actually, each of the keys in the value of option +;; `icicle-key-complete-keys') to `icicle-complete-keys'. Each +;; such keymap should have at least one prefix key. `S-TAB' is +;; bound in each keymap, so that you can use it to complete the +;; prefix keys. See also `icicle-complete-key-anyway-flag'. +;; +;; * Non-nil option `icicle-complete-key-anyway-flag' means bind +;; `S-TAB' (actually, each of the keys in the value of option +;; `icicle-key-complete-keys') to `icicle-complete-keys' in each +;; keymap of option `icicle-keymaps-for-key-completion', regardless +;; of whether `S-TAB' already has a binding in that keymap. A +;; value of nil means bind `S-TAB' only if there is not already a +;; binding. +;; +;; * Non-nil option `icicle-complete-keys-self-insert-flag' means +;; that `icicle-complete-keys' includes self-inserting keys as +;; completion candidates. You will probably want to leave this nil +;; and use command `icicle-insert-char', not +;; `icicle-complete-keys', to insert special characters. +;; +;; * User option `icicle-yank-function' is a function to use to yank +;; text. By default, it is `yank'. Command +;; `icicle-yank-maybe-completing' calls this function, except when +;; it is called from the minibuffer or called with a negative +;; prefix argument. +;; +;; * Non-nil user option `icicle-use-candidates-only-once-flag' means +;; that acting on a candidate removes it from the set of available +;; candidates, so that you don't see that it can be used again. +;; (`TAB' or `S-TAB' makes it available again.) The default value +;; is nil, and you probably do not want to customize this. +;; However, if you write Emacs-Lisp code that uses completion, then +;; you can bind this to non-nil in contexts where that makes sense. +;; +;; * Non-nil user option `icicle-deletion-action-flag' means +;; `S-delete' during completion deletes the current object. More +;; precisely, it deletes the object named by the current completion +;; candidate, if a deletion action is defined for the current +;; command. If no deletion action is defined, then the value of +;; this option has no effect for that command. +;; +;; * User option `icicle-alternative-actions-alist' is an alist that +;; associates Emacs commands and alternative action functions. It +;; overrides any alternative actions defined otherwise for the +;; commands. +;; +;; * User option `icicle-type-actions-alist' is an alist that +;; associates Emacs object types, such as buffer, file, and +;; process, with functions that accept an object of the given type +;; as their only required object. This is used by some Emacs +;; commands during completion to prompt for a function to apply to +;; the current completion candidate. Each function can be a symbol +;; or a lambda expression. At runtime, symbols that are not +;; functions (`functionp') are ignored. +;; +;; * User option `icicle-type-actions-alist' is an alist of Emacs +;; object types and associated actions (functions). Each function +;; must accept an object of the specified type as its only required +;; argument. A function here can be a symbol or a lambda +;; expression. Any symbols that do not have function definitions +;; when this option is used are filtered out (not used). +;; +;; * Non-nil user option `icicle-use-anything-candidates-flag' means +;; Anything actions are used for candidate alternate actions in +;; some Icicles commands, and Anything types and actions are used +;; by command `icicle-object-action' (aka `what-which-how' and +;; `a'). The default value is t. This option has no effect if +;; library `anything.el' cannot be loaded. +;; +;; * Non-nil user option `icicle-anything-transform-candidates-flag' +;; means that Anything function `anything-transform-candidates' is +;; applied to displayed Anything candidates in Icicles. +;; +;; The advantage of a nil value is that command `icicle-anything' +;; then acts as a multi-command: you can act on multiple +;; candidates, or apply multiple actions for the same candidate, +;; within a single invocation of `icicle-anything' (or related +;; commands). The advantage of a non-nil value is that some of the +;; displayed Anything candidates might be more readable. The +;; default value is nil. This option has no effect if library +;; `anything.el' cannot be loaded. +;; +;; * User option `icicle-WYSIWYG-Completions-flag' controls how face +;; and color names are displayed as candidates in `*Completions*'. +;; If value is non-nil, then a WYSIWYG (what you see is what you +;; get) sample of the face or color is shown. If the value is a +;; string, then a face name is accompanied by a separate face +;; swatch with that string text. If the value is t, then the face +;; name itself is shown using the face it names. You can use +;; command `icicle-toggle-WYSIWYG-Completions' to toggle this +;; option. +;; +;; * Non-nil user option `icicle-unpropertize-completion-result-flag' +;; means that `completing-read' and (starting with Emacs 23) +;; `read-file-name' will strip all text properties from the result +;; they return. Regardless of the option value, Icicles strips +;; text properties that it adds for its internal use. See the doc +;; string of function `icicle-unpropertize' for more information +;; about this. +;; +;; The default value of the option is nil. It is not likely that +;; you will need to change this, but you might if you use some +;; other library that cannot accept a propertized string as the +;; result of completion. +;; +;; Note: This is the case if you use GNUS - it has a known bug in +;; this regard (reported 2008-06-21). It blindly prints the +;; Emacs-Lisp string that is the result of completion into an MML +;; attribute value: filename=#("~/.gnus/attach.el" 0 25 (face +;; nil)). GNUS should ensure that whatever it uses for an +;; attribute value is valid for MML (has normal "..." string +;; syntax, with acceptable characters). But it simply calls a Lisp +;; print function, which prints #("..."). +;; +;; * User options `icicle-pp-eval-expression-print-length' and +;; `icicle-pp-eval-expression-print-level' control the Lisp sexp +;; print length and print level, respectively, for values printed +;; by `M-:' (`icicle-pp-eval-expression'). +;; +;; * Non-nil option `icicle-guess-commands-in-path' means that all +;; executable files (or all files, if option +;; `shell-completion-execonly' is nil) in your search path are +;; included among the completion candidates whenever a +;; shell command is read. The particular non-nil value determines +;; when this list of commands is updated from your current search +;; path. The default value is nil. +;; See (@> "Icicles Shell-Command Enhancements"). +;; +;; * Non-nil option `icicle-quote-shell-file-name-flag' means that +;; `icicle-read-shell-command-completing' double-quotes the file +;; name at the beginning of the shell command it reads. This +;; affects several Emacs commands, such as `M-!' that read a shell +;; command and its arguments. +;; +;; If this is nil, then such commands will not quote a +;; shell-command file name such as +;; `c:/Program Files/My Dir/mycmd.exe'. In that case, a shell such +;; as `bash' fails for a shell command such as +;; `c:/Program Files/My Dir/mycmd.exe arg1 arg2 &', because it +;; interprets only `c:/Program' as the shell command. That is, it +;; interprets the space (`SPC') characters in the file name as +;; separators. +;; +;; If this is non-nil (the default value), then input such as +;; `c:/Program Files/My Dir/mycmd.exe arg1 arg2 &' is passed to the +;; shell as `"c:/Program Files/My Dir/mycmd.exe" arg1 arg2 &' +;; (notice the double-quotes). +;; +;; See the doc string of `icicle-quote-file-name-part-of-cmd' for +;; information about the characters that, like `SPC', lead to +;; file-name quoting. +;; +;; * Non-nil user option `icicle-inhibit-ding-flag' means Icicles +;; never uses an audible bell (ding). +;; +;; * Option `icicle-option-type-prefix-arg-list' is a list of symbols +;; that control prefix arguments for command +;; `icicle-describe-option-of-type (bound to `C-h C-o' by +;; default). A list of six symbols taken from this list: +;; +;; `direct' `inherit' `inherit-or-value' +;; `direct-or-value' `inherit-or-regexp' `direct-or-regexp' +;; +;; Choose the order you like. The list members map, in order from +;; left to right, to these prefix argument keys: +;; +;; 1. `C-u C-u' +;; 2. `C-0' +;; 3. `C-u' +;; 4. `C-9' (positive) +;; 5. no prefix arg +;; 6. `C--' (negative) +;; +;; For the meanings of the symbols, see the doc string of +;; `icicle-describe-option-of-type', which describes the default +;; prefix-argument bindings for the command. +;; +;; * Non-nil user option `icicle-customize-save-flag' means that +;; Icicles will save the updated value of option +;; `icicle-command-abbrev-alist' when you quit Emacs. This is the +;; normal behavior. If you for some reason do not want your +;; `custom-file' or init file updated in this way, then customize +;; `icicle-customize-save-flag' to nil. +;; +;; * If `icicle-buffers-ido-like-flag' is t then `icicle-buffer' and +;; similar commands act more Ido-like. Specifically, those +;; commands then bind these options to t: +;; `icicle-show-Completions-initially-flag', +;; `icicle-top-level-when-sole-completion-flag', and +;; `icicle-default-value'. +;; +;; * If `icicle-files-ido-like-flag' is t then `icicle-file' and +;; similar commands act more Ido-like. Specifically, those +;; commands then bind these options to t: +;; `icicle-show-Completions-initially-flag', +;; `icicle-top-level-when-sole-completion-flag', and +;; `icicle-default-value'. +;; +;; * The value of option `icicle-customize-save-variable-function' is +;; the function Icicles uses to automatically save user option +;; changes made by some commands. I recommend that you do *NOT* +;; change this option value. This is provided only for users who +;; might want to disable such automatic saving of option changes, +;; by setting this to `ignore', or users who might want to manage +;; such option saving using their own function instead of the +;; default value, `customize-save-variable'. + +;;(@* "File-Name and Directory-Name Completion Tips") +;; +;; File-Name and Directory-Name Completion Tips +;; -------------------------------------------- +;; +;; This section contains some tips about completing file and +;; directory names. +;; +;; * Functions `icicle-dirs-first-p' and `icicle-dirs-last-p' are +;; provided as possible values for user option +;; `icicle-sort-comparer'. They treat file and directory names +;; specially, sorting directory names before or after file names; +;; otherwise, they are the same as `icicle-case-string-less-p'. +;; +;; * User option `icicle-cycle-into-subdirs-flag' controls whether or +;; not minibuffer-input cycling explores subdirectories. By +;; default, it is nil, meaning that cycling does not descend into +;; subdirectories. +;; +;; non-nil - When this option is non-nil, you might want to use a +;; function such as `icicle-dirs-last-p' for option +;; `icicle-sort-comparer', to prevent cycling depth-first +;; into the subdirectories. +;; +;; nil - When this option is nil, you can still choose to cycle +;; into a given directory (which is why nil is the default +;; value). When cycling reaches a candidate directory that +;; you want to cycle through, just: 1) move the cursor +;; (e.g. `C-e'), 2) hit `TAB' or `S-TAB' to "complete" the +;; candidate, and then 3) use any of the cycle keys, such as +;; `up', to cycle within the candidate directory. +;; +;; Although the candidate directory was already completed by +;; cycling, moving the cursor and explicitly "completing" it +;; tells Icicles that you want to treat the candidate in the +;; minibuffer as real input, just as if you had typed it, not +;; merely as a cycling candidate. +;; +;; * You can use `..' during completion to access a parent directory, +;; and you can use `/' and `~/' to shadow input to the left. There +;; is currently no special treatment of MS Windows drive letters +;; (e.g. `C:') - I use Cygwin on Windows. +;; +;; * Non-nil user option +;; `icicle-hide-common-match-in-Completions-flag' hides the common +;; match for your current input from each candidate in +;; *Completions*. You can toggle this at any time during +;; completion using `C-x .' (`icicle-toggle-hiding-common-match'). +;; This can be especially useful when reading an absolute file name +;; (e.g. `C-u C-x C-f'), by removing any common directory +;; component. +;; +;; * Standard Emacs user option `completion-ignored-extensions' is a +;; list of file-name extensions. File names that match any of +;; these extensions are generally ignored for completion (but see +;; the doc string for particulars). In Icicles, however, the +;; behavior is slightly different: +;; +;; - In vanilla Emacs the option is itself ignored for display in +;; buffer `*Completions*'. That is, even file names that are +;; ignored for completion are shown in `*Completions*' as +;; available completion candidates. +;; +;; - In Icicles this is not the case. When a file name is ignored +;; it is ignored completely; it is not shown in `*Completions*'. +;; But in Icicles you can toggle this ignoring off or on at any +;; time during completion, using `C-.' in the minibuffer. +;; +;; In addition, if you load library `completion-ignored-build.el', +;; by Kevin Ryde, then Icicles automatically takes advantage of +;; that library's dynamic adjustment of ignored extensions. (Just +;; load the library - do not enable its minor mode or advice.) +;; +;; * User option `icicle-use-~-for-home-dir-flag' controls whether +;; your home directory is written in the minibuffer using `~' or in +;; expanded form, during completion. The default value is `t', +;; which means to use `~', saving minibuffer space. You can toggle +;; this option at any time using command +;; `icicle-toggle-~-for-home-dir', bound to `M-~'. +;; +;; * Remember that you can use a regular expression to +;; apropos-complete file names. This is a powerful feature. Do +;; not confuse its use with the ability to use shell wildcards +;; (globbing) to access multiple files at once. For example, if +;; you use `C-x 4 f *.el RET', then all files with suffix `el' will +;; be opened. Regexp matching is used only for apropos (not +;; prefix) completion and cycling. See +;; (@file :file-name "icicles-doc1.el" :to "What About Special-Character Conflicts?"). +;; +;; * You can use `$' for both environment variables and as a regexp +;; special character. For example, you can use a pattern such as +;; `$HOME.*t$' to match the files in your home directory (`$HOME') +;; whose names end in `t'. See +;; (@file :file-name "icicles-doc1.el" :to "What About Special-Character Conflicts?"). +;; +;; * Starting with Emacs 23, and if the current `TAB' completion +;; method is `vanilla' (see (@* "Fuzzy Completion")), you can +;; complete environment variables during file-name completion, +;; using `TAB'. So you can, for example, complete `$HO' to any of +;; the candidates `HOME', `HOMEDRIVE', `HOMEPATH'. This is in +;; addition to the expansion of complete environment variables +;; (e.g. `$HOME' to `/my/home/dir/') when you use `S-TAB' or `RET'. +;; +;; * You can use the idiom `\W$' as input to match only directories, +;; when a command asks for a file or directory name. The `\W' says +;; to match any non word-syntax character. The `$' says to match +;; this at the end of the name. This works because directory names +;; appear as completion candidates with a trailing slash (`/'), and +;; slash (`/') is about the only non word-syntax character that is +;; likely to appear in file-name completions. See +;; (@file :file-name "icicles-doc1.el" :to "What About Special-Character Conflicts?"). +;; +;; * You can use library `ffap.el', if you like, with Icicles, to +;; pick up the file, directory, or URL name under the cursor. All +;; Icicles features are available during file-name and URL +;; completion. If you like `ffap.el', you might also like to try +;; my extension library `ffap-.el'. See also +;; (@file :file-name "icicles-doc1.el" :to "Inserting Text Found Near the Cursor"). +;; +;; * Many Icicles commands that target file or directory names look +;; only in the current directory (`default-directory'). This means +;; that the directory part of the name is ignored for matching +;; purposes. You can thus use apropos completion to match a +;; substring, without needing to prefix the substring with `.*'. +;; For example, to match file `favorite-foo-file.bar' in directory +;; `/some/path/to/my/', it is sufficient to use either `foo' or +;; `/some/path/to/my/foo'. +;; +;; * Some Icicles commands that target file names match your input +;; against file names as ordinary strings, that is, with no notion +;; that they are actually file names. This is the case for +;; `icicle-locate-file', `icicle-recent-file', +;; `icicle-find-file-in-tags-table', and +;; `icicle-find-file-absolute', as well as `icicle-file' with a +;; prefix argument. Such candidates are often absolute file names. +;; In that case, you can regexp-match against any part of the +;; absolute file name, including directory components. See +;; (@file :file-name "icicles-doc1.el" :to "File-Name Input and Locating Files Anywhere"). +;; +;; * If you have symbolic links that might get in the way of +;; exploring directories while locating files, you can use command +;; `icicle-locate-file-no-symlinks' instead of +;; icicle-ignored-directories' - it will not follow symbolic links. +;; +;; This also gives you a way to temporarily avoid descending into a +;; subdirectory you are not interested in: put a symbolic link in +;; its place temporarily. +;; +;; Another, cleaner way to skip certain directories is to customize +;; or `let'-bind option `icicle-ignored-directories'. By default +;; this is the value of `vc-directory-exclusion-list', which means +;; that it ignores version-control directories. +;; +;; See Also: +;; +;; * (@> "Customization and General Tips") for general tips about +;; using Icicles. Many of those tips apply also to file-name and +;; directory-name completion. +;; * (@file :file-name "icicles-doc1.el" :to "File-Name Input and Locating Files Anywhere"). + +;;(@* "Key Bindings") +;; +;; Key Bindings +;; ------------ +;; +;; You can customize any of the key bindings that Icicles uses - see +;; (@> "Customizing Key Bindings"). I recommend that you first try +;; using the default bindings, however. There are many Icicles key +;; bindings (in particular in the minibuffer), but they are grouped +;; into a few natural sets, to help you remember them. +;; +;;(@* "Global Bindings") +;; ** Global Bindings ** +;; +;; Icicles does not change your global key bindings. It changes some +;; minibuffer bindings, and it adds some bindings for Icicle mode, +;; but it does not change your global bindings. +;; +;; There are two exceptions: +;; +;; 1. In Icicle mode, various Icicles commands are added to menu-bar +;; menus. File commands are added to the File menu, and so on, under +;; an Icicles submenu. Those items that do not belong naturally to +;; any existing menu-bar menu are added to a new top-level Icicles +;; menu and to the existing Minibuf menu. Whatever the menu they +;; appear in, however, Icicles menu items are visible only when +;; Icicle mode is active. +;; +;; If you do not want Icicles to add items to menus besides Minibuf +;; and Icicles, then set option `icicle-touche-pas-aux-menus' to +;; non-nil. See (@> "Customizing Key Bindings"). +;; +;; 2. Icicles adds the key `S-TAB' (bound to `icicle-complete-keys') +;; to each existing keymap. This allows you to complete keys in any +;; keymap. For technical reasons, these bindings are not part of +;; `icicle-mode-map'; other keymaps are enhanced to include this +;; binding. However, this Icicles binding of `S-TAB' never replaces +;; any existing binding of `S-TAB'. See +;; (@file :file-name "icicles-doc1.el" :to "Key Completion") for more +;; information about this use of `S-TAB'. +;; +;; (The documentation always refers to the key that performs key +;; completion as `S-TAB'. Actually, it is `S-TAB' only by default. +;; You can customize it, using option `icicle-key-complete-keys'.) +;; +;;(@* "Icicle-Mode Bindings") +;; ** Icicle-Mode Bindings ** +;; +;; Most Icicle-mode bindings are in the Icicles menu-bar menu. In +;; addition, option `icicle-top-level-key-bindings' causes Icicles to +;; bind some keyboard keys to some top-level Icicles commands. Some +;; of these take the place of similar, global bindings whenever you +;; are in Icicle mode. Typically, these top-level commands are +;; Icicles multi-command versions of the vanilla Emacs commands. +;; See (@file :file-name "icicles-doc1.el" :to "Multi-Commands"). +;; +;; You can customize option `icicle-top-level-key-bindings' to +;; specify the top-level commands that you want to bind in Icicle +;; mode, and the keys you want to bind them to. With the default +;; value of `icicle-top-level-key-bindings', Icicles makes the +;; following Icicle-mode bindings: +;; +;; * `C-c '' - `icicle-occur' +;; * `C-c =' - `icicle-imenu' +;; * `C-c `' - `icicle-search' +;; * `C-c `' - `icicle-compilation-search' (in *grep* etc.) +;; * `C-c `' - `icicle-comint-search' (in *shell* etc.) +;; * `C-c TAB' - `icicle-comint-command' (in *shell* etc.) +;; * `C-c /' - `icicle-complete-thesaurus-entry' +;; * `C-h C-o' - `icicle-describe-option-of-type' +;; * `ESC M-x' - `lacarte-execute-command' +;; * `M-`', `f10' - `lacarte-execute-menu-command' +;; * `M-x' - `icicle-execute-extended-command' +;; * `C-x SPC' - `icicle-command-abbrev' +;; * `C-x M-e' - `icicle-execute-named-keyboard-macro' +;; * `S-f4' - `icicle-kmacro' +;; * `pause' - `icicle-switch-to/from-minibuffer' +;; +;; `S-TAB' is bound, in effect, to `icicle-complete-keys', which +;; completes a key sequence. Prefix keys followed by `S-TAB' are +;; also bound to `icicle-complete-keys'. (`S-TAB' is effectively +;; bound to other commands in buffer `*Completions*' and in the +;; minibuffer.) +;; +;; (The documentation always refers to the key that performs key +;; completion as `S-TAB'. Actually, it is `S-TAB' only by default. +;; You can customize it, using option `icicle-key-complete-keys'.) +;; +;; When `icicle-top-level-key-bindings' has its default value, +;; Icicles also substitutes all of the key bindings for some standard +;; Emacs commands. For example, Icicles binds `icicle-buffer' to all +;; keys that are globally bound outside Icicle mode to standard +;; command `switch-to-buffer'. By default, the following standard +;; commands have their bindings co-opted this way by Icicles +;; commands: +;; +;; Standard Command Icicles Command +;; +;; `abort-recursive-edit'.............`icicle-abort-recursive-edit' +;; `bookmark-jump'....................`icicle-bookmark' +;; `bookmark-jump-other-window'.......`icicle-bookmark-other-window' +;; `bookmark-set'.....................`icicle-bookmark-cmd' +;; `dabbrev-completion'...............`icicle-dabbrev-completion' +;; `delete-window'....................`icicle-delete-window' +;; `dired'............................`icicle-dired' +;; `dired-other-window'...............`icicle-dired-other-window' +;; `eval-expression'..................`icicle-pp-eval-expression' +;; `exchange-point-and-mark'.........`icicle-exchange-point-and-mark' +;; `execute-extended-command'.......`icicle-execute-extended-command' +;; `find-file'........................`icicle-file' +;; `find-file-other-window'...........`icicle-file-other-window' +;; `find-file-read-only'..............`icicle-find-file-read-only' +;; `find-file-read-only-other-window'.`...read-only-other-window' +;; `find-tag'.........................`icicle-find-tag' +;; `find-tag-other-window'.......`icicle-find-first-tag-other-window' +;; `Info-goto-node'...................`icicle-Info-goto-node' +;; `Info-index'.......................`icicle-Info-index' +;; `Info-menu'........................`icicle-Info-menu' +;; `insert-buffer'....................`icicle-insert-buffer' +;; `kill-buffer'......................`icicle-kill-buffer' +;; `lisp-complete-symbol'.............`icicle-lisp-complete-symbol' +;; `other-window'.....................`icicle-other-window-or-frame' +;; `other-frame'......................`icicle-select-frame' +;; `pop-global-mark'...`icicle-goto-global-marker-or-pop-global-mark' +;; `pop-tag-mark'.....................`icicle-pop-tag-mark' +;; `pp-eval-expression'...............`icicle-pp-eval-expression' +;; `set-mark-command'........`icicle-goto-marker-or-set-mark-command' +;; `switch-to-buffer'.................`icicle-buffer' +;; `switch-to-buffer-other-window'....`icicle-buffer-other-window' +;; `where-is'.........................`icicle-where-is' +;; `yank'.............................`icicle-yank-maybe-completing' +;; +;; Actually, by default, Icicles binds `icicle-yank-maybe-completing' +;; to whatever the value of option `icicle-yank-function' is. By +;; default, this value is `yank'. +;; +;; Option `icicle-top-level-key-bindings' remaps not only these +;; standard Emacs commands but also some commands provided by other +;; libraries. For example, if you use package Bookmark+, then +;; type-specific bookmark jump commands such as +;; `bmkp-dired-jump-other-window' are remapped to Icicles +;; multi-command versions. +;; +;; Here are some other Icicles commands that you might want to bind +;; to keys in Icicle mode - they are not bound by Icicles (except to +;; menu items): +;; +;; `clear-option' (alias) - Set value of binary option to nil +;; `icicle-add-buffer-candidate' - +;; Add buffer to those always shown +;; `icicle-add-buffer-config' - Add to `icicle-buffer-configs' +;; `icicle-add-entry-to-saved-completion-set' - +;; Add a completion candidate to a saved set +;; `icicle-add/update-saved-completion-set' - Add a set to +;; `icicle-saved-completion-sets' +;; `icicle-apply' - Selectively apply function to alist items +;; `icicle-apropos' - `apropos', but shows matches +;; `icicle-apropos-command' - Enhanced `apropos-command' +;; `icicle-apropos-variable' - Enhanced `apropos-variable' +;; `icicle-apropos-zippy' - Show matching Zippy quotes +;; `icicle-buffer-config' - Pick options for Icicles buffer commands +;; `icicle-buffer-list' - Choose a list of buffer names +;; `icicle-clear-history' - Clear minibuffer histories +;; `icicle-color-theme' - Change color theme +;; `icicle-completing-yank' - Yank text using completion +;; `icicle-customize-face' - Multi-command `customize-face' +;; `icicle-customize-icicles-group' - +;; Customize Icicles options and faces +;; `icicle-delete-file' - Delete a file or directory +;; `icicle-delete-windows' - Delete all windows for a buffer +;; `icicle-doc' - Display doc of function, variable, or face +;; `icicle-doremi-increment-variable+' - +;; Increment a variable using Do Re Mi +;; `icicle-face-list' - Choose a list of face names +;; `icicle-file-list' - Choose a list of file names +;; `icicle-font' - Change the frame font +;; `icicle-frame-bg' - Change the frame background color +;; `icicle-frame-fg' - Change the frame foreground color +;; `icicle-fundoc' - Display the doc of a function +;; `icicle-increment-option' - Increment numeric options (Do Re Mi) +;; `icicle-increment-variable' - Increment variables (Do Re Mi) +;; `icicle-Info-virtual-book' - Open Info on a virtual book +;; `icicle-insert-thesaurus-entry' - +;; Insert a thesaurus entry +;; `icicle-keyword-list' - Choose a list of keywords (regexps) +;; `icicle-locate-file' - Open a file located anywhere +;; `icicle-minibuffer-help' - Show Icicles minibuffer help +;; `icicle-plist' - Show symbols, property lists +;; `icicle-recent-file' - Open a recently used file +;; `icicle-recompute-shell-command-candidates' - Update from PATH +;; `icicle-remove-buffer-candidate' - +;; Remove buffer from those always shown +;; `icicle-remove-buffer-config'- Remove from `icicle-buffer-configs' +;; `icicle-remove-entry-from-saved-completion-set' - +;; Remove a candidate from a saved set +;; `icicle-remove-file-from-recentf-list' - Remove from recent files +;; `icicle-remove-saved-completion-set' - Remove a set from +;; `icicle-saved-completion-sets' +;; `icicle-reset-option-to-nil' - +;; Set value of binary option to nil +;; `icicle-save-string-to-variable' - +;; Save text for use with `C-=' +;; `icicle-search-bookmark' - Search bookmarks +;; `icicle-search-bookmark-list-bookmark' - bookmark-list bookmarks +;; `icicle-search-buff-menu-marked' - Search marked buffers, in order +;; `icicle-search-buffer' - Search multiple buffers +;; `icicle-search-char-property' - Search for character properties +;; `icicle-search-dired-bookmark' - Search Dired bookmarks +;; `icicle-search-dired-marked' - Search the marked files in Dired +;; `icicle-search-file' - Search multiple files +;; `icicle-search-file-bookmark' - Search file bookmarks +;; `icicle-search-gnus-bookmark' - Search Gnus bookmarks +;; `icicle-search-ibuffer-marked' - Search marked buffers in Ibuffer +;; `icicle-search-info-bookmark' - Search Info bookmarks +;; `icicle-search-local-file-bookmark' - Search local file bookmarks +;; `icicle-search-man-bookmark' - Search `man'-page bookmarks +;; `icicle-search-non-file-bookmark' - Search non-file bookmarks +;; `icicle-search-overlay-property' - Search for overlay properties +;; `icicle-search-pages' - Search Emacs pages (delimited by ^L chars) +;; `icicle-search-paragraphs' - Search Emacs paragraphs +;; `icicle-search-region-bookmark' - Search bookmarked regions +;; `icicle-search-remote-file-bookmark' - Search remote files +;; `icicle-search-sentences' - Search using sentences as contexts +;; `icicle-search-url-bookmark' - Search URL bookmarks +;; `icicle-select-window' - Select a window by its buffer name +;; `icicle-set-option-to-t' - Set value of binary option to t +;; `icicle-toggle-option' - Toggle the value of a binary option +;; `icicle-vardoc' - Display the doc of a variable +;; `toggle' (alias) - Toggle the value of a binary option +;; +;;(@* "Minibuffer Bindings") +;; ** Minibuffer Bindings ** +;; +;; There are many key bindings available during completion. Most of +;; these key sequences are bound in the minibuffer completion +;; keymaps, but some are bound in the `*Completions*' buffer keymap. +;; In addition, clicking `C-mouse-3' on a completion candidate in +;; buffer `*Completions*' pops up a menu of available commands. +;; +;; Some of these menu commands are applicable to the completion you +;; click; others apply to the current state of completion or to the +;; complete set of completion candidates. The associated key +;; bindings are indicated in the menu items, so this can be a good +;; way to learn minibuffer and `*Completions*' bindings. +;; +;; The following key bindings are made for the minibuffer completion +;; keymaps. They are in effect whenever you are using the minibuffer +;; for input with completion (e.g. `completing-read', +;; `read-file-name', `M-x'). +;; +;; `C-?' - `icicle-minibuffer-help': Pop up a *Help* buffer with +;; information on using the minibuffer in Icicle mode. +;; During completion, this includes information similar to +;; what you are reading now. It also includes toggle +;; commands and the current toggle values. +;; +;; `down', `up' - `icicle-next-prefix-candidate', +;; `icicle-next-candidate-per-mode' (modal), +;; `icicle-previous-prefix-candidate', +;; `icicle-previous-candidate-per-mode' (modal), +;; which cycle candidate prefix completions. +;; +;; `next', `prior' - `icicle-next-apropos-candidate', +;; `icicle-previous-apropos-candidate', which +;; cycle candidate apropos completions. +;; +;; (The documentation always refers to the keys +;; that cycle completion candidates as `down', +;; `up', `next', and `prior'. Actually, these +;; are the cycling keys only by default. You can +;; customize the cycling keys, using options +;; `icicle-prefix-cycle-next-keys', +;; `icicle-modal-cycle-down-keys' (modal), +;; `icicle-prefix-cycle-previous-keys', +;; `icicle-modal-cycle-up-keys' (modal), +;; `icicle-apropos-cycle-next-keys', and +;; `icicle-apropos-cycle-previous-keys'.) +;; +;; Keys bound globally to commands that perform simple text +;; insertion, deletion, and transposition operations - commands +;; such as `self-insert-command' - are bound to Icicles versions of +;; those commands that do the same thing but also provide apropos +;; icompletion. This includes keys such as `C-d', `C-k', and `C-w' +;; (and lots more). See (@file :file-name "icicles-doc1.el" :to "Icompletion"). +;; +;; `pause' - `icicle-switch-to/from-minibuffer': Move cursor to +;; the buffer from which the minibuffer was activated. +;; +;; `C-insert' - `icicle-switch-to-Completions-buf': Move cursor to +;; the current candidate in buffer `*Completions*'. +;; +;; `M-*' - `icicle-narrow-candidates': Narrow the set of +;; completion candidates using another input regexp. +;; +;; `M-SPC' - `icicle-prefix-word-complete': Complete current input +;; in minibuffer, as a prefix, a single word at a time. +;; This replaces `minibuffer-complete-word'. In fact, +;; it is the keys in `icicle-word-completion-keys' that +;; are bound to this command; `M-SPC' is by default. +;; +;; `S-SPC' - `icicle-apropos-complete-and-narrow': Same as +;; `S-TAB' followed by `M-*'. +;; +;; `TAB' - `icicle-prefix-complete': Complete current input in +;; minibuffer, as a prefix. If there is more than one +;; prefix-completion candidate, display them in buffer +;; `*Completions*', highlighting the common prefix. +;; This replaces `minibuffer-complete'. +;; +;; (The documentation always refers to the key that does +;; this as `TAB'. Actually, it is only `TAB' by +;; default. You can customize it, using option +;; `icicle-prefix-complete-keys'.) +;; +;; `S-TAB' - In the minibuffer: `icicle-apropos-complete' - like +;; `TAB', but use apropos completion. In buffer +;; `*Completions*': `icicle-move-to-previous-completion' +;; - move backwards among candidates. +;; +;; (The documentation always refers to the keys that do +;; these things as `S-TAB'. Actually, they are only +;; `S-TAB' by default. You can customize the keys, +;; using options `icicle-apropos-complete-keys' and +;; `icicle-previous-candidate-keys'.) +;; +;; `C-M-TAB' - `icicle-prefix-complete-no-display': Like `TAB', but +;; does not display candidates in `*Completions*'. +;; +;; (The documentation always refers to the key that does +;; this as `C-M-TAB'. Actually, it is only `C-M-TAB' by +;; default. You can customize it, using option +;; `icicle-prefix-complete-no-display-keys'.) +;; +;; `C-M-S-TAB' - `icicle-apropos-complete-no-display': Like +;; `S-TAB', but does not display candidates. +;; +;; (The documentation always refers to the key that does +;; this as `C-M-S-TAB'. Actually, it is only +;; `C-M-S-TAB' by default. You can customize it, using +;; option `icicle-apropos-complete-no-display-keys'.) +;; +;; `C-M-&' - `icicle-save-predicate-to-variable': Save the current +;; predicate used for completion to a variable. +;; +;; `delete' - `icicle-remove-candidate': Remove the current +;; candidate from consideration. +;; +;; `S-mouse-2' - `icicle-mouse-remove-candidate': Same as `delete'. +;; +;; `M-q' - `icicle-insert-key-description': Insert the textual +;; representation of a key sequence, during key +;; completion. +;; +;; `M-o' - `icicle-insert-history-element': Invoke completion to +;; insert a previously entered input in the minibuffer. +;; +;; `C-M-S-f' - `icicle-read+insert-file-name': Invoke completion to +;; insert a file name in the minibuffer. +;; +;; `C-M-S-c' - `icicle-completing-read+insert': Invoke completion +;; to insert something other than a file name (not +;; always available). +;; +;; (`C-M-S-f' and `C-M-S-c' are the default values for +;; the keys that invoke completion on demand. You can +;; customize the keys to use, using options +;; `icicle-read+insert-file-name-keys' and +;; `icicle-completing-read+insert-keys'.) +;; +;; In Icicles, multi-line completion candidates are not uncommon. +;; You can move up and down minibuffer lines with `C-p' and `C-n', +;; and you can use the following keys to move among line beginnings +;; and ends: +;; +;; `C-a', `C-e' - `icicle-beginning-of-line+', +;; `icicle-end-of-line+': Like normal `C-a', `C-e', but +;; repeating goes to the previous or next line. +;; +;; If you use libraries `fit-frame.el' and `oneonone.el' with a +;; standalone minibuffer frame (non-nil +;; `1on1-minibuffer-frame-flag'), and if option +;; `1on1-fit-minibuffer-frame-flag' is non-nil, then the minibuffer +;; frame is automatically resized to fit its content as you edit that +;; content. (Options `1on1-fit-minibuffer-frame-max-height' and +;; `1on1-fit-minibuffer-frame-max-height-percent' define the maximum +;; height for this.) +;; +;; If, in addition, you bind `1on1-fit-minibuffer-frame' to a key, +;; then you can use that key repeatedly to increase the height by one +;; line, even beyond the maximum. Library `setup-keys.el' binds this +;; to `C-o'. +;; +;; (If you do not use a separate minibuffer frame, then you will +;; likely want to set standard option `resize-mini-windows' to t, not +;; to `grow-only', at least while in Icicle mode.) +;; +;; `C-M-j' - `icicle-insert-list-join-string': Insert +;; `icicle-list-join-string'. See also +;; (@> "Multi-Completions"). +;; +;; You can insert a single Icicles multi-line dot using `C-u .', or +;; by turning on this dot magic generally, using `C-M-.': +;; +;; `.' - `icicle-insert-dot-command' +;; `C-M-.' - `icicle-toggle-dot' +;; +;; If option `icicle-cycling-respects-completion-mode' is non-nil, +;; then you can use the keys that are defined by the following +;; options for both prefix and apropos completion (as well as for +;; input-history traversal): +;; +;; * `icicle-modal-cycle-up-keys' +;; * `icicle-modal-cycle-down-keys' +;; * `icicle-modal-cycle-up-action-keys' +;; * `icicle-modal-cycle-down-action-keys' +;; * `icicle-modal-cycle-up-alt-action-keys' +;; * `icicle-modal-cycle-down-alt-action-keys' +;; * `icicle-modal-cycle-up-help-keys' +;; * `icicle-modal-cycle-down-help-keys' +;; +;; By default, the keys defined for these options are, respectively, +;; `up', `down', `C-up', `C-down', `C-S-up', `C-S-down', `C-M-up', +;; and `C-M-down'. Whether one of the keys is used for prefix or +;; apropos completion at a given time depends on the current +;; completion mode, which is determined by which of `TAB' and `S-TAB' +;; was used last. +;; +;; In vanilla Emacs, the following keys have a special purpose during +;; input completion, but in Icicles they simply insert the character +;; typed - they are self-inserting. This is because (1) there are +;; better ways to do what vanilla Emacs uses these keys for and (2) +;; it is useful to be able to insert these characters without first +;; typing `C-q' to quote them. +;; +;; `?' - see also +;; (@file :file-name "icicles-doc1.el" :to "What About Special-Character Conflicts?") +;; +;; `SPC' (space) +;; +;; `C-j' (newline) - see also `C-o', above, and +;; (@> "Multi-Completions") +;; +;; The following minibuffer bindings are made to clear minibuffer +;; input, making them handy for editing and removing completions +;; (e.g. default or initial values) in the minibuffer. +;; +;; `M-k' - `icicle-erase-minibuffer-or-history-element' +;; `M-S-backspace', `M-S-delete' - `icicle-erase-minibuffer' +;; +;; `M-k' has an alternative behavior when you are cycling minibuffer +;; history items: it deletes the current item from the history. +;; +;; During (absolute or relative) file-name completion, the following +;; minibuffer bindings are also in effect: +;; +;; `C-backspace' - `icicle-up-directory': +;; Navigate up the directory hierarchy. +;; `C-c +' - `icicle-make-directory': Create a directory. +;; `C-x m' - `icicle-bookmark-file-other-window': +;; Visit a file or directory (Dired) bookmark. +;; See also +;; (@file :file-name "icicles-doc1.el" :to "Accessing Saved Locations (Bookmarks) on the Fly"). +;; (Available only if you use `bookmark+.el'.) +;; +;; During absolute file-name completion, you can use `C-c C-d' to +;; change the current directory on the fly (think UNIX command `cd'). +;; See also +;; (@file :file-name "icicles-doc1.el" :to "Absolute File Names and Different Directories"). +;; +;; The following minibuffer binding moves the cursor to the start of +;; the part of your input, if any, that is highlighted because it +;; does not match any completion candidate (see option +;; `icicle-highlight-input-completion-failure'). Repeating this +;; command kills the rest of the line, removing the highlighted +;; mismatched input. +;; +;; `C-M-l' - `icicle-goto/kill-failed-input' +;; +;; The remaining input matches at least one candidate. +;; +;; The following minibuffer bindings can be used to get rid of a +;; completion inserted during cycling, and retrieve what you last +;; typed during completion or any previous completion inputs: +;; +;; `C-l' - `icicle-retrieve-previous-input' +;; `C-S-l' (`C-L') - `icicle-retrieve-next-input' +;; +;; You can use these to cycle among and reuse inputs that you typed +;; during completion but did not enter. This completion input is not +;; recorded in the standard input histories - they record only input +;; that you have entered with `RET'. +;; See (@file :file-name "icicles-doc1.el" :to "History Enhancements"). +;; +;; For example, suppose that you used `C-h v hook' to examine various +;; hook variables, and you did this using`C-next' to display their +;; documentation. If you finished the command by just typing `C-g', +;; then your input (`hook') was never really entered, so it is not +;; available via the minibuffer history (`M-p'). You can retrieve it +;; with `C-l', to use it again, in your next command. User option +;; `icicle-C-l-uses-completion-flag' controls the behavior of `C-l' +;; and `C-L'; if non-nil, then, instead of cycling inputs, these +;; commands let you access previous inputs using completion. +;; +;; You of course have the standard access to the minibuffer history, +;; via `M-p', `M-n', `M-r', and `M-s'. In addition to these, the +;; following minibuffer bindings let you use apropos completion on +;; the current minibuffer history list. For explanation, see +;; (@file :file-name "icicles-doc1.el" :to "History Enhancements"). +;; +;; `M-h' - `icicle-history' +;; `M-pause' - `icicle-keep-only-past-inputs' +;; +;; Minibuffer binding `C-M-pause' lets you use a different minibuffer +;; history during the current input reading with completion. +;; Normally, you are prompted for the history to use. Starting with +;; Emacs 23, if option `icicle-populate-interactive-history-flag' is +;; non-nil, then during command, abbrev, and keyboard-macro +;; completion, `C-M-pause' completes your input against the history +;; of all commands that were invoked interactively in any way, +;; `icicle-interactive-history'. +;; +;; The following minibuffer bindings let you act on candidate +;; completions. For explanation, see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands"), +;; (@file :file-name "icicles-doc1.el" :to "More about Multi-Commands"), +;; (@file :file-name "icicles-doc1.el" :to "Choose All Completion Candidates"), +;; and (@> "OO: Object-Action Interaction"). +;; +;; `C-RET' - `icicle-candidate-action': current candidate +;; `C-mouse-2' - `icicle-mouse-candidate-action': clicked candidate +;; `C-up' - `icicle-previous-prefix-candidate-action' +;; `C-up' - `icicle-previous-candidate-per-mode-action' +;; (modal) +;; `C-down' - `icicle-next-prefix-candidate-action' +;; `C-down' - `icicle-next-candidate-per-mode-action' (modal) +;; `C-prior' - `icicle-previous-apropos-candidate-action' +;; `C-next' - `icicle-next-apropos-candidate-action' +;; `C-!' - `icicle-all-candidates-action': each candidate +;; `M-!' - `icicle-all-candidates-list-action': all, as list +;; `M-RET' - `icicle-candidate-read-fn-invoke': apply function +;; `M-mouse-2' - `icicle-mouse-yank-secondary' (in minibuffer) +;; `M-mouse-2' - `icicle-mouse-candidate-read-fn-invoke': apply fn +;; `S-delete' - `icicle-delete-candidate-object': delete object +;; +;; (Actually, some of these are only default key +;; bindings. You can customize the keys to use for +;; `previous' and `next' actions.) +;; +;; Except as noted, the bindings for `icicle-mouse-*' are actually in +;; the `*Completions*' buffer. +;; +;; The following minibuffer bindings provide help on candidate +;; completions. For explanation, see +;; (@file :file-name "icicles-doc1.el" :to "Get Help on Candidates") +;; and (@file :file-name "icicles-doc1.el" :to "Multi-Commands"). +;; +;; `C-M-RET' - `icicle-help-on-candidate': current candidate +;; `C-M-mouse-2' - `icicle-mouse-help-on-candidate': clicked +;; `C-M-up' - `icicle-help-on-previous-prefix-candidate' +;; `C-M-down' - `icicle-help-on-next-prefix-candidate' +;; `C-M-prior' - `icicle-help-on-previous-apropos-candidate' +;; `C-M-next' - `icicle-help-on-next-apropos-candidate' +;; +;; (Actually, some of these are only the default key +;; bindings. You can customize the keys to use for +;; `previous' and `next' candidate help.) +;; +;; The following minibuffer bindings provide an alternative action +;; for individual candidates. The alternative action is specific to +;; the given command. Most commands define no alternative action. +;; +;; `C-S-RET' - `icicle-candidate-alt-action': current candidate +;; `C-S-mouse-2' - `icicle-mouse-candidate-alt-action': clicked +;; `C-S-up' - `icicle-previous-prefix-candidate-alt-action' +;; `C-S-up' - `icicle-previous-candidate-per-mode-alt-action' +;; (modal) +;; `C-S-down' - `icicle-next-prefix-candidate-alt-action' +;; `C-S-down' - `icicle-next-candidate-per-mode-alt-action' +;; (modal) +;; `C-S-prior' - `icicle-previous-apropos-candidate-alt-action' +;; `C-S-next' - `icicle-next-apropos-candidate-alt-action' +;; `C-|' - `icicle-all-candidates-alt-action': each +;; `M-|' - `icicle-all-candidates-list-alt-action': list +;; +;; The following minibuffer bindings let you perform set operations +;; on sets of completion candidates. For explanation, see +;; (@file :file-name "icicles-doc1.el" :to "Sets of Completion Candidates"). +;; +;; `C-~' - `icicle-candidate-set-complement' +;; `C--' - `icicle-candidate-set-difference' +;; `C-+' - `icicle-candidate-set-union' +;; `C-*' - `icicle-candidate-set-intersection' +;; `C-M-<' - `icicle-candidate-set-retrieve': retrieve saved set +;; `C-M->' - `icicle-candidate-set-save': save current set +;; `C-M-)' - `icicle-candidate-set-save-selected': save selected +;; `C-<' - `icicle-candidate-set-retrieve-more': add from saved +;; `C->' - `icicle-candidate-set-save-more': add to saved set +;; `C-)' - `icicle-candidate-set-save-more-selected': selected +;; `insert' - `icicle-save/unsave-candidate': save current cand +;; `C-%' - `icicle-candidate-set-swap': swap saved and current +;; `C-:' - `icicle-candidate-set-define': define current (Lisp) +;; `M-S-mouse-2' - `icicle-mouse-save/unsave-candidate': (un)save +;; `M-S-mouse-3' - `icicle-mouse-candidate-set-save': save selected +;; `M-mouse-3' - `icicle-mouse-candidate-set-save-more' +;; +;; The following minibuffer bindings insert text in the minibuffer. +;; +;; `M-.' - `icicle-insert-string-at-point' +;; `C-=' - `icicle-insert-string-from-variable' +;; `M-:' - `icicle-pp-eval-expression-in-minibuffer' +;; (with a prefix arg) +;; +;; The following minibuffer bindings let you toggle Icicles options +;; or cycle among alternative Icicles behaviors. +;; +;; `C-A' (that is, `C-S-a') - `icicle-toggle-case-sensitivity' +;; `C-.' - `icicle-toggle-ignored-extensions' (file completion) +;; `C-.' - `icicle-toggle-search-cleanup' (search) +;; `C-M-.' - `icicle-toggle-dot' +;; `C-x .' - `icicle-toggle-hiding-common-match' +;; `C-;' - `icicle-toggle-expand-to-common-match' +;; `C-,' - `icicle-change-sort-order' +;; `C-,' - `icicle-toggle-search-replace-whole' (search) +;; `M-,' - `icicle-change-alternative-sort-order' +;; `C-M-,' - `icicle-toggle-alternative-sorting' +;; `C-^' - `icicle-toggle-remote-file-testing' +;; `C-^' - `icicle-toggle-highlight-all-current' (search) +;; `C-#' - `icicle-toggle-incremental-completion' +;; `C-(' - `icicle-next-TAB-completion-method' +;; `C-`' - `icicle-toggle-regexp-quote' +;; `C-M-`' - `icicle-toggle-literal-replacement' (search) +;; `C-$' - `icicle-toggle-transforming' (removal of duplicates) +;; `C-pause' - `icicle-toggle-highlight-historical-candidates' +;; `M-g' - `icicle-toggle-C-for-actions' +;; `M-q' - `icicle-toggle-search-whole-word' (search) +;; `M-(' - `icicle-next-S-TAB-completion-method' +;; `M-~' - `icicle-toggle-~-for-home-dir' +;; `M-_' - `icicle-toggle-ignored-space-prefix' +;; `C-M-_' - `icicle-toggle-proxy-candidates' +;; +;; The following minibuffer bindings let you incrementally change +;; options that affect the `*Completions*' display columns and text +;; size. To take advantage of these, you must also use Do Re Mi +;; (libraries `doremi.el' and `doremi-frm.el'). `C-x -' requires +;; Emacs 23 or later. +;; +;; `C-x w' - `icicle-doremi-candidate-width-factor+' +;; `C-x |' - `icicle-doremi-inter-candidates-min-spaces+' +;; `C-x -' - `icicle-doremi-zoom-Completions+' +;; +;; When used in the minibuffer, the following Icicles global binding +;; lets you remove the `*Completions*' window. +;; +;; `C-x 0' - `icicle-delete-window' +;; +;; The following minibuffer bindings are in effect during Icicles +;; search: +;; +;; `C-.' - `icicle-toggle-search-cleanup' +;; `C-,' - `icicle-toggle-search-replace-whole' +;; `M-,' - `icicle-search-define-replacement' +;; `M-q' - `icicle-toggle-search-whole-word' +;; `C-^' - `icicle-toggle-highlight-all-current' +;; `C-M-`' - `icicle-toggle-literal-replacement' +;; +;; The following minibuffer binding lets you evaluate an Emacs-Lisp +;; sexp at any time, using a recursive minibuffer. It displays the +;; result of evaluation in the echo area or in a pop-up buffer, `*Pp +;; Eval Output*'. With a prefix arg (`C-u M-:'), it inserts the +;; result into the minibuffer at point. +;; +;; `M-:' - `icicle-pp-eval-expression-in-minibuffer' +;; +;; Some additional bindings are made available in the minibuffer for +;; the duration of specific commands: +;; +;; * During completion of names of some kinds of objects (files, +;; buffers, directories, Info nodes), `C-x m' lets you complete +;; against bookmarks that have the same type as those objects (file +;; bookmarks, buffer bookmarks, Dired bookmarks, Info bookmarks). +;; This feature requires use of package Bookmark+. +;; +;; * During completion of file names, `C-backspace' is bound to +;; `icicle-up-directory', which navigates to the parent directory +;; and completes there instead. +;; +;; * During completion of bookmark names, various keys with the +;; prefix `C-M-' are bound to commands that narrow the available +;; candidates to bookmarks of a specific type. For example, +;; `C-M-d' narrows the choices to Dired bookmarks. +;; +;; The following bindings are made for `completion-list-mode', that +;; is, for buffer `*Completions*', which shows the list of candidate +;; completions: +;; +;; `left', `right' (`TAB') +;; - `icicle-move-to-previous-completion', +;; `icicle-move-to-next-completion': Navigate +;; backward & forward among candidates +;; `up', `down' - `icicle-previous-line', `icicle-next-line': +;; Navigate up & down among candidates (The +;; documentation refers to these keys as `up' and +;; `down'. Actually, these are the keys only by +;; default. You can customize them using options +;; `icicle-prefix-cycle-next-keys' and +;; `icicle-prefix-cycle-previous-keys'.) +;; `C-insert' - `icicle-insert-completion': Move cursor to the +;; minibuffer, with the current `*Completions*' +;; candidate as input +;; `C-a', `C-e' - `icicle-beginning-of-line+', +;; `icicle-end-of-line+' (repeatable) +;; `C-g', `q' - `icicle-abort-recursive-edit' +;; `mouse-2' - `icicle-mouse-choose-completion' +;; `C-mouse-2' - `icicle-mouse-candidate-action' +;; `M-mouse-2' - `icicle-mouse-candidate-read-fn-invoke' +;; `C-M-mouse-2' - `icicle-mouse-help-on-candidate' +;; `M-S-mouse-2' - `icicle-mouse-save/unsave-candidate' +;; `C-mouse-3' - `icicle-Completions-mouse-3-menu' +;; `M-mouse-3' - `icicle-mouse-candidate-set-save-more' +;; `M-S-mouse-3' - `icicle-mouse-candidate-set-save' + +;;(@* "Customizing Key Bindings") +;; +;; Customizing Key Bindings +;; ------------------------ +;; +;; See (@> "Key Bindings") for a description of the key bindings +;; defined by Icicles. The options mentioned here are also presented +;; there, in context. You can customize all of the key-binding user +;; options with `M-x customize-group RET Icicles-Key-Bindings'. +;; +;; Key bindings are very personal choices, and reflect preferences +;; and habits, as well as keyboard and other configurations. You +;; might want to change some of the bindings that Icicles creates. +;; This section tells you how to do that. +;; +;; However, before doing so, unless the default bindings present a +;; hardware or OS configuration problem for you, please try using the +;; default bindings for a while, before deciding that you want to +;; change them. Habit is a powerful persuader, but its advice is not +;; always the best ;-). +;; +;; The main user option for customizing key bindings is +;; `icicle-top-level-key-bindings'. You use it to change or remove +;; any of the top-level bindings in Icicle mode. +;; +;; There are some other user options that make it easy to customize +;; some Icicles key bindings. Most of these are minibuffer key +;; bindings. +;; +;; * `icicle-apropos-cycle-previous-keys' (`prior') +;; Cycle to the previous apropos-completion candidate. +;; * `icicle-apropos-cycle-next-keys' (`next') +;; Cycle to the next apropos-completion candidate. +;; * `icicle-prefix-cycle-previous-keys' (`up') +;; Cycle to the previous prefix-completion candidate. +;; * `icicle-prefix-cycle-next-keys' (`down') +;; Cycle to the next prefix-completion candidate. +;; * `icicle-modal-cycle-up-keys' (`up') +;; Cycle to the previous candidate (modal). +;; * `icicle-modal-cycle-down-keys' (`down') +;; Cycle to the next candidate (modal). +;; * `icicle-apropos-cycle-previous-action-keys' (`C-prior') +;; Cycle to previous apropos-completion candidate and act on it. +;; * `icicle-apropos-cycle-next-action-keys' (`C-next') +;; Cycle to next apropos-completion candidate and act on it. +;; * `icicle-prefix-cycle-previous-action-keys' (`C-up') +;; Cycle to previous prefix-completion candidate and act on it. +;; * `icicle-prefix-cycle-next-action-keys' (`C-down') +;; Cycle to next prefix-completion candidate and act on it. +;; * `icicle-modal-cycle-up-action-keys' (`C-up') +;; Cycle to previous candidate and act on it (modal). +;; * `icicle-modal-cycle-down-action-keys' (`C-down') +;; Cycle to next candidate and act on it (modal). +;; * `icicle-apropos-cycle-previous-alt-action-keys' (`C-S-prior') +;; Cycle to previous apropos-completion candidate and +;; alternative-act on it. +;; * `icicle-apropos-cycle-next-alt-action-keys' (`C-S-next') +;; Cycle to next apropos-completion candidate and alternative-act +;; on it. +;; * `icicle-prefix-cycle-previous-alt-action-keys' (`C-S-up') +;; Cycle to previous prefix-completion candidate and +;; alternative-act on it. +;; * `icicle-prefix-cycle-next-alt-action-keys' (`C-S-down') +;; Cycle to next prefix-completion candidate and alternative-act +;; on it. +;; * `icicle-modal-cycle-up-alt-action-keys' (`C-S-up') +;; Cycle to previous candidate and alternative-act on it (modal). +;; * `icicle-modal-cycle-down-alt-action-keys' (`C-S-down') +;; Cycle to next candidate and alternative-act on it (modal). +;; * `icicle-prefix-complete-keys' (`TAB') +;; Prefix-complete your input. +;; * `icicle-apropos-complete-keys' (`S-TAB') +;; Apropos-complete your input. +;; * `icicle-prefix-complete-no-display-keys' (`C-M-TAB') +;; Prefix-complete without showing `*Completions*'. +;; * `icicle-apropos-complete-no-display-keys' (`C-M-S-TAB') +;; Apropos-complete without showing `*Completions*'. +;; * `icicle-word-completion-keys' (`M-SPC') +;; Prefix-complete your input a word at a time. +;; * `icicle-key-complete-keys' (`S-TAB') +;; Complete key sequences. +;; * `icicle-previous-candidate-keys' (`S-TAB') +;; Move to the previous candidate in `*Completions*'. +;; * `icicle-completing-read+insert-keys' (`C-M-S-c') +;; Completion on demand. +;; * `icicle-read+insert-file-name-keys' (`C-M-S-f') +;; Completion on demand for file names. +;; * `icicle-search-from-isearch-keys' (`S-TAB') +;; Start `icicle-search' from Isearch. +;; * `icicle-isearch-complete-keys' (`M-TAB', `C-M-TAB', `M-o') +;; Complete incremental search string using search ring. +;; +;; These are the main kinds of Icicles key bindings: +;; +;; * Global bindings +;; . Additions to menu-bar menus +;; . Key completion keys (`S-TAB' by default) +;; * Icicle mode bindings +;; * Minibuffer bindings +;; +;;(@* "Customizing Global Bindings") +;; ** Customizing Global Bindings ** +;; +;; Icicles normally adds items to appropriate existing menu-bar +;; menus, such as File and Options, as well as to menu-bar menus +;; Minibuf and Icicles. These items are placed in an Icicles submenu +;; (e.g. Files > Icicles). If you do not want to add an Icicles +;; submenu, then set option `icicle-touche-pas-aux-menus-flag' to +;; non-nil before loading Icicles. The menu items are then added to +;; the Icicles menu. +;; +;; Icicles binds key completion (`icicle-complete-keys') to the keys +;; defined in option `icicle-key-complete-keys'. See +;; (@> "Key Bindings") for more information about this. +;; +;;(@* "Customizing Icicle Mode Bindings") +;; ** Customizing Icicle Mode Bindings ** +;; +;; In the Icicle mode keymap, several top-level commands are bound by +;; default. You can use option `icicle-top-level-key-bindings' to +;; customize the keys that are used for these commands, or to remove +;; any such bindings. +;; +;;(@* "Customizing Minibuffer Bindings") +;; ** Customizing Minibuffer Bindings ** +;; +;; There are user options for most Icicles minibuffer bindings that +;; you might want to change - see above for the list. This section +;; tells you how to change additional bindings. +;; +;; To understand how you can modify Icicles minibuffer bindings, it +;; helps to know how Icicles creates the default bindings. For that, +;; the best advice is to consult the Emacs-Lisp code in library +;; `icicle-mode.el'. Even if you are not very familiar with +;; Emacs-Lisp, however, you should be able to do what you want by +;; adapting the example in this section. +;; +;; Suppose that you want to bind `f11' and `f12' to traverse the +;; input history up and down whenever you are in Icicle mode. There +;; are no user options for this, but you can do it by inserting this +;; code into your init file (~/.emacs), before the code that requires +;; (loads) library `icicles.el': +;; +;; (add-hook 'icicle-mode-hook 'bind-my-icicles-keys) +;; (defun bind-my-icicles-keys () +;; "Replace some default Icicles minibuffer bindings with others." +;; (dolist +;; (map +;; (append +;; (list minibuffer-local-completion-map +;; minibuffer-local-must-match-map) +;; (and (fboundp +;; 'minibuffer-local-filename-completion-map) +;; (list minibuffer-local-filename-completion-map)))) +;; (when icicle-mode +;; (define-key map [f11] 'previous-history-element) +;; (define-key map [f12] 'next-history-element)))) +;; +;; See Also: +;; +;; * (@> "Key Bindings") +;; * (@> "Customization and General Tips") for information +;; about other customizations, besides key bindings. + +;;(@* "Icicles Redefines Some Standard Commands") +;; +;; Icicles Redefines Some Standard Commands +;; ---------------------------------------- +;; +;; If user option `icicle-redefine-standard-commands-flag' is +;; non-nil, then Icicles automatically redefines a few standard Emacs +;; commands when you are in Icicle mode, enhancing them for Icicles +;; completion: +;; +;; `bbdb-complete-name' (from BBDB), `customize-apropos', +;; `customize-apropos-faces', `customize-apropos-groups', +;; `customize-apropos-options', `customize-face', +;; `customize-face-other-window', `dabbrev-completion', +;; `lisp-complete-symbol', `repeat-complex-command', +;; `switch-to-completions'. +;; +;; Icicles automatically redefines these standard Emacs commands for +;; use in the minibuffer or *Completions*: +;; +;; `choose-completion', `exit-minibuffer', +;; `minibuffer-complete-and-exit', `mouse-choose-completion', +;; `next-history-element'. +;; +;; When you exit Icicle mode, the standard definitions are restored. + +;;(@* "Programming with Fancy Candidates") +;; +;; Programming with Fancy Candidates +;; --------------------------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;; Icicles lets you program with several kinds of candidates that are +;; not supported by vanilla Emacs. For lack of a better word, I call +;; them all "fancy candidates". Multi-completions are fancy +;; candidates. So are ordinary string candidates that have text +;; properties such as `face'. And there are other kinds of fancy +;; candidates. +;; +;; Because they are not supported by vanilla Emacs, and because +;; Icicles uses Emacs functions such as `all-completions' to perform +;; the primitive completion operations, fancy candidates require some +;; extra processing. +;; +;; All fancy candidates must first be converted to a form that such +;; primitives can understand. During completion, fancy candidates +;; must sometimes be displayed specially, for example using +;; particular faces. And after completion, the completion result +;; must sometimes be converted back again to retrieve some or all of +;; the original candidate information. +;; +;; This conversion (encoding and decoding) can be costly, especially +;; when there are many candidates. For this reason, it is turned +;; off, by default, so it that doesn't represent overhead during +;; completion of non-fancy candidates. +;; +;; In order to use `completing-read' with fancy candidates, you must +;; do one of the following in your code: +;; +;; 1. Propertize at least the first character of the +;; `completing-read' PROMPT argument string with a non-nil text +;; property `icicle-fancy-candidates'. This turns on processing +;; of fancy candidates for the duration of the `completing-read' +;; call. +;; +;; 2. Bind variable `icicle-fancy-candidates-p' to non-nil. +;; +;; 3. Bind variable `icicle-whole-candidate-as-text-prop-p' to +;; non-nil. +;; +;; You use method 1 or 2 to handle multi-completion candidates or +;; candidates that have text properties or are otherwise to be +;; displayed specially. I recommend that you generally use text +;; property `icicle-fancy-candidates', not variable +;; `icicle-fancy-candidates-p'. The variable is provided so that you +;; can widen the scope of this feature beyond a given call to +;; `completing-read'. You will need to do that only rarely. +;; +;; A use case for variable `icicle-fancy-candidates-p' would be, for +;; instance, if your code calls other code that calls +;; `completing-read', so you have no direct access to the +;; `completing-read' PROMPT argument in order to propertize it. If +;; you nevertheless want to use some fancy candidates, then you can +;; bind `icicle-fancy-candidates-p' with the scope you want. +;; +;; You use method 3, `icicle-whole-candidate-as-text-prop-p', when +;; you need to save and later retrieve all of the information +;; contained in an alist COLLECTION entry. Completion returns only a +;; string. If the COLLECTION alist has only one entry with a given +;; string as its car, then you can simply use `assoc' to retrieve the +;; whole entry. +;; +;; But if you use an alist that allows entries with different cdrs +;; for the same car, then you need some way to encode an entire alist +;; entry in a display string. When you have this need, set variable +;; `icicle-candidates-alist' to the alist, and bind +;; `icicle-whole-candidate-as-text-prop-p' to non-nil. +;; +;; This has the effect of encoding, as a text property on the +;; candidate display string, the entire corresponding original alist +;; entry. You can then use `icicle-get-alist-candidate' to recover +;; that information. + +;;(@* "Programming Multi-Completions") +;; +;; Programming Multi-Completions +;; ----------------------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;; Multi-completions are completion candidates that are composed of +;; parts separated by `icicle-list-join-string' and terminated by +;; `icicle-list-end-string'. See (@> "Multi-Completions") for +;; information about how users interact with multi-completions. +;; +;; Multi-completions are examples of fancy candidates. +;; See (@> "Programming with Fancy Candidates"). +;; +;; You can define your own Icicles commands that use +;; multi-completions. You can bind `icicle-list-join-string' or +;; `icicle-list-end-string' to any strings you like, depending on +;; your needs. See +;; (@file :file-name "icicles-doc1.el" :to "Key Completion") for an +;; example where `icicle-list-join-string' is bound to " = " and +;; `icicle-list-end-string' is "". This section describes two +;; additional variables that you can bind to affect the appearance +;; and behavior of multi-completions. +;; +;;(@* "Variable icicle-list-use-nth-parts") +;; ** Variable icicle-list-use-nth-parts ** +;; +;; Variable `icicle-list-use-nth-parts' affects the minibuffer +;; behavior of multi-completions. If you bind this to a list of +;; whole numbers, then multi-completion candidates are transformed +;; using those numbers as indexes. During completion and cycling, +;; whenever a sole candidate matches the user input, if that +;; candidate is a multi-completion, then it is transformed by +;; extracting and possibly reordering its parts according to +;; `icicle-list-use-nth-parts'. +;; +;; The actual candidate to match is still the original candidate; the +;; transformation takes place after matching, for final insertion in +;; the minibuffer. This means that you must use this feature only +;; with lax (permissive) completion, since strict completion requires +;; an exact match against the original completion candidate, and the +;; transformed candidate will normally not match the original. +;; +;; Variable `icicle-list-use-nth-parts' works as follows. The +;; matching candidate is split at each `icicle-list-join-string' into +;; its component parts. The indexes in `icicle-list-use-nth-parts' +;; are then used to extract parts, in the same order as the indexes +;; appear. The extracted parts are joined back together in an order +;; that you specify, separated by the value of user option +;; `icicle-list-nth-parts-join-string'. An index greater than the +;; number of parts means to use the last part. +;; +;; For example: If the value of `icicle-list-use-nth-parts' is (1), +;; then only the first part of the multi-completion is used as the +;; completion candidate. If the value is (2 1), then the resulting +;; candidate is the second part followed by the first part, the two +;; parts being joined by `icicle-list-nth-parts-join-string'. If the +;; value is (1 99) and the multi-completion has fewer than 99 parts, +;; then the first and last parts are used. If the value is (2 1 2), +;; then the resulting candidate is composed of the second part +;; followed by the first part followed by the second part again. +;; +;; Thus, you can use a given part any number of times. You can also +;; mix multi-completions and single-string completions, and you can +;; mix multi-completions composed of different numbers of strings. +;; For example, a set of completions might be: +;; +;; ((("cmd1" "description of cmd1")) +;; (("cmd2" "description of cmd" "more")) +;; (("cmd3"))) +;; +;; If you use multi-completions with `icicle-list-use-nth-parts' in +;; your own commands, please make sure that their doc strings let +;; users know what to expect, and remind them of the behavior of +;; option `icicle-list-nth-parts-join-string'. Let them know, in +;; particular, that: +;; +;; * They can match any part of a candidate as it is displayed in +;; buffer `*Completions*'. +;; +;; * The candidate choice they make will in fact have the form that +;; you define in your command. +;; +;; * They can control how the parts are joined, using option +;; `icicle-list-nth-parts-join-string'. +;; +;;(@* "Variable icicle-candidate-properties-alist") +;; ** Variable icicle-candidate-properties-alist ** +;; +;; Whereas variable `icicle-list-nth-parts-join-string' affects the +;; appearance of multi-completions in the minibuffer, variable +;; `icicle-candidate-properties-alist' affects their appearance in +;; buffer `*Completions*'. You use it to apply text properties to +;; individual parts of a multi-completion, where the parts are +;; defined in the same way as for `icicle-list-use-nth-parts'. +;; +;; This feature affects all candidates the same way. See also +;; (@> "Candidates with Text Properties") for ways to apply text +;; properties to individual candidates (which need not be +;; multi-completions). +;; +;; The value of `icicle-candidate-properties-alist' is an alist whose +;; entries have either of these forms: +;; +;; (NTH PROPERTIES) or (NTH PROPERTIES JOIN-TOO) +;; +;; NTH is the number of the target multi-completion part. +;; +;; PROPERTIES is a list of text properties to apply to the NTH part. +;; +;; JOIN-TOO is optional. If it is present and non-nil, then the text +;; properties are also applied to the join string that follows the +;; target part. +;; +;; You can use any text properties, including `invisible', `keymap', +;; `display', and properties that you define yourself and that have +;; meaning to only your code. +;; +;; As an example of its use, commands `icicle-fundoc', +;; `icicle-vardoc', `icicle-doc', and `icicle-plist' bind +;; `icicle-candidate-properties-alist' to +;; ((1 (face 'icicle-candidate-part))), so that the first part of +;; each multi-completion candidate is highlighted using face +;; `icicle-candidate-part'. +;; +;; Here is another example value of +;; `icicle-candidate-properties-alist': +;; +;; ((3 (face 'underline)) +;; (2 (invisible t) t)) +;; +;; The first entry underlines the third multi-completion part. The +;; second entry makes both the second part and the join string that +;; follows it invisible. +;; +;; One use of making a completion part invisible is so that you can +;; sort candidates using it, and let users match input against it, +;; but not have it appear explicitly. +;; +;; Recall that `completing-read' displays only the car of each +;; element present in its COLLECTION (alist) argument. For example, +;; if you pass `completing-read' an alist such as (("foo" . 2) ("bar" +;; . 3)), then only `foo' and `bar' are displayed as candidates. +;; However, the PREDICATE argument to `completing-read' applies to +;; the entire alist element, and your command that calls +;; `completing-read' might well use the chosen candidate (e.g. `foo') +;; to look up the entire element (e.g. ("foo" . 2)) for further +;; processing. Several Icicles commands, including `icicle-search', +;; do that. +;; +;; However, sometimes you might want the user to be able to match +;; against the additional information (e.g. 2 and 3), and you might +;; want to use it to sort candidates. In that case, you can use the +;; alist (("foo 2") ("bar 3")). In cases where the additional +;; information can be distracting, you can use multi-completion with +;; `icicle-candidate-properties-alist' to hide it: Pass the alist +;; ((("foo "2")) (("bar" 3"))) and use ((2 (invisible t))) for +;; `icicle-candidate-properties-alist'. +;; +;; Keep in mind that hiding completion parts can be confusing to +;; users. Do so with care, and let your users know what to expect. +;; Inform them that there are invisible parts that are nevertheless +;; taken into account for input matching and candidate sorting. When +;; you hide parts, you will often want to omit them from the +;; minibuffer as well, using `icicle-list-use-nth-parts', to avoid +;; confusion. +;; +;; Consider also the position of a hidden part: In some cases you +;; might want to place it first among the multi-completion parts, but +;; in many cases you will want to place it last, to minimize +;; interference with prefix-completion matching. +;; +;; Similar considerations apply to other text properties, such as +;; `display' and `keymap', that change the appearance or behavior of +;; a completion candidate. +;; +;;(@* "What You See Is Not What You Get") +;; ** What You See Is Not What You Get ** +;; +;; While on the subject of confusing users, let me point out a +;; general drawback that is common to both +;; `icicle-list-use-nth-parts' and +;; `icicle-candidate-properties-alist': *not* WYSIWYG. Keep this in +;; mind if you decide to take advantage of these variables. Users +;; see one thing, choose it, and they get something different as a +;; result. That promotes confusion that you will need to weigh +;; against the possible benefits. +;; +;; Users are confused, because what they choose is not exactly what +;; they get. What's more, a user's completion choice is not +;; reflected in the input history, leading to further confusion. For +;; example, Icicles highlighting of previously used inputs in buffer +;; `*Completions*' does not apply to such a candidate, even though it +;; was previously entered using `RET'. It is the transformed +;; candidate that was entered, not the candidate as it was proposed +;; for choosing, so when that candidate is proposed again, it is not +;; recognized as having been previously chosen. +;; +;; The bottom line here is this: variables +;; `icicle-list-use-nth-parts' and +;; `icicle-candidate-properties-alist' are useful in certain +;; contexts, but be aware of the downside: confusing your users. +;; +;; See Also: +;; +;; * (@> "Multi-Completions") +;; * (@> "Programming with Fancy Candidates") +;; * (@> "Candidates with Text Properties") + +;;(@* "Candidates with Text Properties") +;; +;; Candidates with Text Properties +;; ------------------------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;; Section (@> "Programming Multi-Completions") explains how to apply +;; text properties to specific parts of all multi-completion +;; candidates in buffer `*Completions*' at the same time. This +;; section tells you how to apply text properties to specific +;; candidates in `*Completions*'. The candidates need not be +;; multi-completions, but in some cases they can be. +;; +;; When you use candidates with text properties such as `face' that +;; are visible, the display candidates in `*Completions*' show those +;; properties. In addition, the candidate string that the user +;; finally chooses can also be propertized. +;; +;; There are four different methods for providing candidates with +;; text properties, in addition to the way presented in section +;; (@> "Programming Multi-Completions"): +;; +;; 1. Apply face `icicle-special-candidate' to all candidates that +;; match a given regexp. +;; +;; 2. Use a set of text properties as the `icicle-special-candidate' +;; property of the symbol that represents the candidate. The text +;; properties are transferred to the string candidate that is +;; displayed (and returned). +;; +;; 3. Use a propertized string as the `icicle-display-string' +;; property of the symbol that represents the candidate. That +;; string replaces the candidate that would otherwise have been +;; displayed, completed against, and returned. +;; +;; 4. Start with a propertized string in the COLLECTION argument +;; that you pass to `completing-read'. +;; +;; All four methods use fancy candidates, in the sense that they go +;; beyond what vanilla Emacs offers. For methods 1-3, you must turn +;; on fancy-candidate handling. See +;; (@> "Programming with Fancy Candidates"). +;; +;; But method 4 does not require any costly fancy-candidate encoding +;; or decoding, because the Icicles implementation of +;; `completing-read' handles propertized string candidates, and they +;; are transparent to the Emacs primitive completion operations. +;; +;; The following sections explain methods 1-4 individually. +;; +;;(@* "Using Regexp `icicle-special-candidate-regexp'") +;; ** Using Regexp `icicle-special-candidate-regexp' ** +;; +;; If you just want several candidates to have face +;; `icicle-special-candidate' in `*Completions', you can simply +;; define (e.g. bind) option `icicle-special-candidate-regexp' to a +;; regexp that matches those candidates. The original candidates can +;; be strings or symbols. Unlike the other methods described here, +;; this one affects only the display in `*Completions'; the +;; completion return string does not have face +;; `icicle-special-candidate'. +;; +;; The highlighting applies only to the part of a candidate that +;; matches the regexp. This selectivity is particularly useful when +;; dealing with multi-completions. Function `icicle-read-file-name' +;; provides an example: file names that match ".+/$", that is, +;; directory names, are highlighted as special candidates. Function +;; `icicle-read-color' provides another example (using the similar, +;; but internal, variable `icicle-proxy-candidate-regexp'): proxy +;; color-name candidates such as `*point foreground*' and +;; `'icicle-region-background'' are highlighted, but not their color +;; swatches. +;; +;;(@* "Using Property icicle-special-candidate") +;; ** Using Property icicle-special-candidate ** +;; +;; In this approach, you use the desired list of text properties as +;; the value of property `icicle-special-candidate' for the symbol +;; that represents the candidate. This method affects the candidates +;; that are used during completion, as well as the completion return +;; value. +;; +;; If the candidate is a string, not a symbol, then `intern' it and +;; put the property on the resulting symbol. If you want the effect +;; to be temporary, then set property `icicle-special-candidate' for +;; the candidate to nil when completion is finished. +;; +;; As a shortcut, if you use the value t instead of a property list +;; for property `icicle-special-candidate', then face +;; `icicle-special-candidate' will be used as the `face' property of +;; the candidate. Using a value of t is thus equivalent to using a +;; value of (face icicle-special-candidate). This approach is used, +;; for instance, in the definition of command `icicle-complete-keys' +;; (`S-TAB'). +;; +;;(@* "Using Property `icicle-display-string'") +;; ** Using Property `icicle-display-string' ** +;; +;; This method is similar to that of using property +;; `icicle-special-candidate'. The use case for both is +;; propertizing, in a general way, candidates that are symbols. Both +;; can be useful when you have an obarray as the COLLECTION argument +;; for `completing-read'. +;; +;; In this method the symbol name is not used at all; the candidate +;; is entirely replaced by another string, which is typically +;; propertized. +;; +;; You use a propertized string as the value of property +;; `icicle-display-string' for the candidate symbol. The propertized +;; string is displayed in `*Completions*' and returned as the final +;; completion choice. +;; +;; Note that multi-completion is not available when you use an +;; obarray. Using property `icicle-special-candidate' or +;; `icicle-display-string' you can propertize candidates and parts of +;; candidates, but you cannot manipulate multi-completion parts and +;; there are no join or end strings. +;; +;;(@* "Applying Text Properties to a Candidate String") +;; ** Applying Text Properties to a Candidate String ** +;; +;; This is the most flexible approach, and it is explained in a bit +;; more detail. It can be used with multi-completions, and it +;; affects the `*Completions*' display and the completion return +;; value. However, it is limited to using an alist or list of +;; strings, not an obarray, as the COLLECTION argument to +;; `completing-read'. +;; +;; In this approach, you simply apply the text properties to the +;; string(s) that represent the candidate, which you then pass to +;; `completing-read' in its COLLECTION parameter. +;; +;; As with the other methods, you can use any text properties you +;; like, including these: +;; +;; * `face' - to make some completion candidates stand out in +;; particular ways +;; +;; * `icicle-mode-line-help' - candidate help shown in the mode-line +;; when the candidate is current, provided option +;; `icicle-help-in-mode-line-flag' is non-nil (only the first +;; character of a candidate string is tested for this property) +;; +;; * `help-echo' - candidate help shown in a mouseover tooltip, +;; provided `tooltip-mode' is on +;; +;; * `keymap' and `pointer' - for individualized mouse treatment of +;; candidates +;; +;; * `display' - to include images in candidates +;; +;; * `invisible' - to hide part or all of particular candidates +;; (which are nevertheless available for completion) +;; +;; As a convenience, you can use function +;; `icicle-candidate-short-help' to apply both +;; `icicle-mode-line-help' and `help-echo' text properties to a +;; candidate string. +;; +;; How does this work? Icicles redefines the standard Emacs function +;; `display-completion-list' so that it retains text properties. +;; Emacs should do the same, but it doesn't (yet). +;; +;; Icicles command `icicle-read-color' presents an illustration, +;; using the `face' property. (It also uses properties +;; `icicle-mode-line-help' and `help-echo', to provide RGB and HSV +;; information in the mode-line and via tooltip.) +;; +;; In `icicle-read-color', a multi-completion candidate is used, +;; composed of an unpropertized string that names a color and a +;; propertized string that names its RGB (red, green, blue) value. +;; The RGB string, by default, has a background of the same color - +;; each completion candidate is thus accompanied by its own color +;; swatch. +;; +;; The code that does this is function `icicle-make-color-candidate', +;; which is used by `icicle-read-color' and other Icicles commands +;; that read colors. Here is a simplified definition: +;; +;; (defun icicle-make-color-candidate (color-name) +;; "Return candidate of COLOR-NAME and its hex RGB string. +;; If `icicle-WYSIWYG-Completions-flag' is non-nil, then the hex RGB +;; string has the color as its background text property." +;; (let ((rgb-string (hexrgb-color-name-to-hex color-name))) +;; (when icicle-WYSIWYG-Completions-flag +;; (put-text-property +;; 0 (length rgb-string) 'face +;; (cons 'background-color rgb-string) rgb-string)) +;; (list (list color-name rgb-string)))) +;; +;; You'll notice that the face property is added only when option +;; `icicle-WYSIWYG-Completions-flag' is non-nil. You can toggle this +;; option at any time during completion to change the behavior. (The +;; new value takes effect for the next act of completion.) +;; +;; You can match any part of the multi-completion: color name or RGB +;; value. Command `icicle-read-color' defines a set of sort orders +;; that are pertinent to the color candidates. You can use `C-,' to +;; sort by color name, RGB value, hue, saturation, value, or amount +;; of red, blue, or green. +;; +;; If option `icicle-add-proxy-candidates-flag' is non-nil, then +;; command `icicle-read-color' includes proxy completion candidates +;; that are not color-name-and-RGB pairs. As always, you can toggle +;; the use of proxy candidates using `C-M-_' in the minibuffer. +;; +;; The proxy candidates for colors include the single-quoted names of +;; user options (variables) whose custom type is `color'. So, for +;; example, option `icicle-region-background' appears as proxy color +;; candidate `'icicle-region-background''. Color proxies also include +;; the following: +;; +;; * `*copied foreground*' - last copied foreground, if available +;; * `*copied background*' - last copied background, if available +;; * `*mouse-2 foreground*' - foreground where you click `mouse-2' +;; * `*mouse-2 background*' - background where you click `mouse-2' +;; * `*point foreground*' - foreground under the text cursor +;; * `*point background*' - background under the text cursor +;; +;; When you choose a proxy color candidates, the color referred to is +;; used. For example, `*point foreground*' means to use the +;; foreground color at the cursor position (point), whatever it might +;; be. Choosing a `mouse-2' candidate lets you then click `mouse-2' +;; to pick up a color somewhere. If you use library `palette.el' or +;; `eyedropper.el', and you have already copied a color, then you can +;; choose `*copied foreground*' (or background) to use that color. +;; +;; Icicles treats reading face names similarly to reading colors, by +;; redefining standard function `read-face-name' when you are in +;; Icicle mode. In this case, multi-completions are not used. The +;; pertinent function is `icicle-make-face-candidate', which provides +;; a WYSIWYG face sample whenever `icicle-WYSIWYG-Completions-flag' +;; is non-nil. +;; +;; A string value for `icicle-WYSIWYG-Completions-flag' presents the +;; face name accompanied by that string as a separate sample swatch. +;; A value of t presents the face name itself in the face it names. +;; +;; (defun icicle-make-face-candidate (face) +;; "Return a completion candidate for FACE. +;; The value of option `icicle-WYSIWYG-Completions-flag' determines +;; the kind of candidate to use. +;; If nil, then the face name is used (a string). +;; +;; If a string, then a multi-completion candidate is used, with the +;; face name followed by a sample swatch using FACE on the string's +;; text. +;; +;; If t, then the candidate is the face name itself, propertized +;; with FACE." +;; (if (stringp icicle-WYSIWYG-Completions-flag) +;; (let ((swatch (copy-sequence +;; icicle-WYSIWYG-Completions-flag))) +;; (put-text-property +;; 0 (length icicle-WYSIWYG-Completions-flag) +;; 'face face swatch) +;; (list (list (symbol-name face) swatch))) +;; (let ((face-name (copy-sequence (symbol-name face)))) +;; (when icicle-WYSIWYG-Completions-flag +;; (put-text-property 0 (length face-name) +;; 'face face face-name)) +;; (list face-name)))) +;; +;; See Also: +;; +;; * (@> "Programming with Fancy Candidates") +;; * (@> "Programming Multi-Completions") +;; * (@file :file-name "icicles-doc1.el" :to "Sorting Candidates and Removing Duplicates") +;; for information about changing sort orders. +;; +;; * (@file :file-name "icicles-doc1.el" :to "*Completions* Display") for +;; more about proxy candidates. + +;;(@* "Defining Icicles Commands (Including Multi-Commands)") +;; +;; Defining Icicles Commands (Including Multi-Commands) +;; ---------------------------------------------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;;(@* "Nothing To It!") +;; ** Nothing To It! ** +;; +;; Defining a command that uses Icicles completion and cycling is +;; simple: just call `completing-read' or `read-file-name' to read +;; input, then act on that input. +;; +;; Nothing could be simpler - just use `completing-read'or +;; `read-file-name'! Icicles does the rest. This is the most +;; important thing to learn about defining Icicles commands: you +;; don't need to do anything except call `completing-read' or +;; `read-file-name' as you would normally anyway. +;; +;; Or at least as I HOPE you would normally. I fear that many +;; Emacs-Lisp programmers don't take sufficient advantage of +;; `completing-read' when they could, using instead a function such +;; as (quel horreur !) `read-string' to read user input. +;; +;;(@* "Multi-Commands Are Easy To Define Too") +;; ** Multi-Commands Are Easy To Define Too ** +;; +;; If defining an Icicles command is trivial, so is defining an +;; Icicles multi-command. For the same effort it takes to define a +;; command that acts on a single input choice, you can have a command +;; that acts on any number of input choices. A multi-command takes +;; advantage of one or more action functions when cycling candidates, +;; as described in sections +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands"), +;; (@> "More about Multi-Commands"), and +;; (@file :file-name "icicles-doc1.el" :to "Choose All Completion Candidates"). +;; +;; In fact, there is no reason NOT to define your commands as +;; multi-commands - you lose nothing, and you gain a lot. Whenever +;; it is appropriate for a user to possibly want to act on multiple +;; objects, define a multi-command that does that. +;; +;; An anecdote, to make the point. An Icicles user sent me an email +;; saying how much he appreciated Icicles multi-commands, and asking +;; if I would add a multi-command version of `insert-buffer'. I did +;; so, but I replied to him that the definition is trivial: it is +;; identical to the definition of `icicle-buffer', except that the +;; action function is `insert-buffer' instead of `switch-to-buffer'. +;; +;; The point is to not be afraid of defining multi-commands yourself. +;; You don't really need to have me add a multi-command to Icicles in +;; most cases; you can easily define it yourself. Here is a simple +;; definition of `icicle-insert-buffer'. You will understand it in +;; detail after reading the next section. +;; +;; (icicle-define-command icicle-insert-buffer +;; "Multi-command version of `insert-buffer'." ; Doc string +;; insert-buffer ; Action function +;; "Buffer: " ; `completing-read' args +;; (mapcar #'(lambda (buf) (list (buffer-name buf))) (buffer-list)) +;; nil t nil 'buffer-name-history (icicle-default-buffer-names) nil) +;; +;; Macros `icicle-define-command' and `icicle-define-file-command' +;; make it easy to define a multi-command. Without them, it is +;; sometimes not so easy, depending on the complexity of your action +;; functions. See (@> "Defining Multi-Commands the Hard Way") for a +;; taste of what is involved. If you read that section first, make +;; sure you come back here to see how easy things can be. +;; +;; Here is how you might define a multi-command to delete one or more +;; files or directories: +;; +;; 1. Define the multi-command, `my-delete-file': +;; +;; (icicle-define-file-command +;; my-delete-file ; Command name +;; "Delete a file or directory." ; Doc string +;; my-delete-file-or-directory ; Function to perform the action +;; "Delete file or directory: " ; `read-file-name' arguments... +;; default-directory nil t) +;; +;; 2. Define the action function that deletes a single file: +;; +;; (defun my-delete-file-or-directory (file) +;; "Delete file (or directory) FILE." +;; (condition-case i-delete-file +;; (if (eq t (car (file-attributes file))) +;; (delete-directory file) +;; (delete-file file)) +;; (error (message (error-message-string i-delete-file)) +;; (error (error-message-string i-delete-file))))) +;; +;; There are two parts to the definition of `my-delete-file': +;; +;; 1. The definition of the command itself, using +;; `icicle-define-file-command'. +;; +;; 2. The definition of an action function, +;; `my-delete-file-or-directory', which deletes a single file (or +;; directory), given its name. +;; +;; It is #1 that is of interest here, because that is essentially +;; what you do to define any multi-command. +;; +;; The details of #2 are less interesting, even if more complex in +;; this case: `my-delete-file-or-directory' checks whether its +;; argument is a file or directory, and then tries to delete it. If +;; an error occurs, it prints the error message and then returns the +;; message, so that the calling command can report on all deletion +;; errors. +;; +;; In #1, the arguments to `icicle-define-file-command' are +;; straightforward: +;; +;; * The name of the command being defined `my-delete-file'. +;; +;; * Its doc string. +;; +;; * The function that actually performs the action on the input file +;; name - `my-delete-file-or-directory'. +;; +;; * The arguments that you would supply anyway to `read-file-name' +;; to read a single file name. +;; +;; These are the SAME things you would need if you were defining a +;; simple command to delete a SINGLE file or directory. The only +;; differences here are that you: +;; +;; * Use `icicle-define-file-command' instead of `defun' with an +;; `interactive' spec. +;; +;; * Separate the action code into a separate function (here, +;; `my-delete-file-or-directory') that acts on a single object +;; (here, a file). +;; +;; When you use `icicle-define-file-command', the action function is +;; called on the result of `read-file-name', and it is also bound to +;; `icicle-candidate-action-fn', so that it will be applied to the +;; current candidate via `C-RET' or `C-mouse-2'. +;; +;; Command `icicle-all-candidates-action' (`C-!' -- see +;; (@file :file-name "icicles-doc1.el" :to "Choose All Completion Candidates")) +;; can report in buffer *Help* on the objects that it did not act +;; upon successfully. For this reporting to work, the function bound +;; to `icicle-candidate-action-fn' +;; (e.g. `my-delete-file-or-directory', above) should return `nil' +;; for "success" and non-`nil' (for example, an error message) for +;; "failure", whatever "success" and "failure" might mean in the +;; particular context of use. This is not a requirement, except if +;; you want to take advantage of such reporting. For a command that +;; deletes files, it is important to let the user know which +;; deletions failed when s?he tries to delete all matching candidates +;; at once. +;; +;; If the command you want to define acts on objects other than +;; files, then use `icicle-define-command' instead of +;; `icicle-define-file-command' - the only difference is that you +;; then supply the arguments for `completing-read' instead of those +;; for `read-file-name'. +;; +;; To let users know that a command is a multi-command, and how to +;; use it as such, `icicle-define-command' and +;; `icicle-define-file-command' automatically add this explanation to +;; the doc string you provide for the multi-command: +;; +;; --- +;; Read input, then call `' to act on it. +;; +;; Input-candidate completion and cycling are available. While +;; cycling, these keys with prefix `C-' are active: +;; +;; `C-mouse-2', `C-RET' - Act on current completion candidate only +;; `C-down' - Move to next prefix-completion candidate and act +;; `C-up' - Move to previous prefix-completion candidate and act +;; `C-next' - Move to next apropos-completion candidate and act +;; `C-prior'- Move to previous apropos-completion candidate and act +;; `C-!' - Act on *all* candidates, successively (careful!) +;; +;; When candidate action and cycling are combined (e.g. `C-next'), user +;; option `icicle-act-before-cycle-flag' determines which occurs first. +;; +;; With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +;; `C-M-RET', `C-M-down', and so on) provide help about candidates. +;; +;; Use `mouse-2', `RET' or `S-RET' to finally choose a candidate, or +;; `C-g' to quit. +;; +;; This is an Icicles command - see `icicle-mode'. +;; --- +;; +;; Notice that the doc string of your new multi-command references +;; your action function (e.g. `my-delete-file-or-directory'). The +;; doc string you provide for the multi-command can thus be a little +;; more abstract, leaving any detailed explanation of the action to +;; the doc string of your action function. +;; +;; To provide more flexibility, `icicle-define-command' and +;; `icicle-define-file-command' provide some predefined key bindings +;; and allow for additional arguments. +;; +;; Here is a definition of a multi-command, `change-font', that reads +;; a font name and changes the selected frame to use that font. +;; +;; 1 (icicle-define-command +;; 2 change-font "Change font of current frame." +;; 3 (lambda (font) +;; 4 (modify-frame-parameters orig-frame +;; 5 (list (cons 'font font)))) +;; 6 "Font: " (mapcar #'list (x-list-fonts "*")) +;; 7 nil t nil nil nil nil +;; 8 ((orig-frame (selected-frame)) +;; 9 (orig-font (frame-parameter nil 'font))) +;; 10 nil +;; 11 (modify-frame-parameters orig-frame +;; 12 (list (cons 'font orig-font))) +;; 13 nil) +;; +;; The arguments to `icicle-define-command' here are as follows: +;; +;; Command name (line 2) +;; Doc string (line 2) +;; Action function (lines 3-5) +;; Args passed to `completing-read' (lines 6-7) +;; Additional bindings (lines 8-9) +;; Additional initialization code (line 10) +;; "Undo" code to run in case of error or user quit (lines 11-12) +;; Additional code to run at the end (line 13) +;; +;; The following bindings are predefined - you can refer to them in +;; the command body: +;; +;; `orig-buff' is bound to (current-buffer) +;; `orig-window' is bound to (selected-window) +;; +;; Before running any "undo" code that you supply, the original +;; buffer is restored, in case of error or user quit (`C-g'). +;; +;; Most of the arguments to `icicle-define-command' are optional. In +;; this case, optional arguments were provided to save (lines 8-9) +;; and then restore (lines 11-12) the original font and frame. +;; +;; Several top-level Icicles commands have been defined using +;; `icicle-define-command' and `icicle-define-file-command'. You can +;; use their definitions as models for your own multi-commands. +;; +;; `clear-option' (alias) - Set value of binary option to nil +;; `icicle-add-buffer-candidate' - Add buffer to those always shown +;; `icicle-add-buffer-config' - Add to `icicle-buffer-configs' +;; `icicle-bookmark' - Jump to a bookmark +;; `icicle-bookmark-bookmark-list-*' - Jump: bookmark-list bookmark +;; `icicle-bookmark-desktop-*' - Jump: bookmarked desktop +;; `icicle-bookmark-dired-*' - Jump: bookmarked Dired state +;; `icicle-bookmark-file-*' - Jump: bookmarked file +;; `icicle-bookmark-gnus-*' - Jump: bookmarked Gnus message +;; `icicle-bookmark-info-*' - Jump: bookmarked Info node +;; `icicle-bookmark-list' - Choose a list of bookmark names +;; `icicle-bookmark-local-file-*' - Jump: bookmarked local file +;; `icicle-bookmark-man-*' - Jump: bookmarked `man' page +;; `icicle-bookmark-non-file-*' - Jump: bookmarked buffer +;; `icicle-bookmark-region-*' - Jump: bookmarked region +;; `icicle-bookmark-remote-file-*' - Jump: bookmarked remote file +;; `icicle-bookmark-url-*' - Jump: bookmarked URL +;; `icicle-buffer' - Switch to another buffer +;; `icicle-buffer-config' - Choose a config for buffer commands +;; `icicle-buffer-list' - Choose a list of buffer names +;; `icicle-clear-history' - Clear entries from minibuffer histories +;; `icicle-clear-current-history' - Clear current history entries +;; `icicle-color-theme' - Change color theme +;; `icicle-comint-command' - Reuse a previous command in comint mode +;; `icicle-command-abbrev' - Execute command or command abbreviation +;; `icicle-command-abbrev-command' - Execute command from abbrev +;; `icicle-completing-yank' - Yank text using completion +;; `icicle-delete-file' - Delete a file or directory +;; `icicle-delete-windows' - Delete windows showing a buffer anywhere +;; `icicle-describe-option-of-type' - Describe option of a given type +;; `icicle-directory-list' - Choose a list of directory names +;; `icicle-dired' - Visit a directory in Dired mode +;; `icicle-doc' - Display doc of function, variable, or face +;; `icicle-execute-extended-command' - +;; A multi-command version of `M-x' +;; `icicle-execute-named-keyboard-macro' - Execute named kbd macro +;; `icicle-face-list' - Choose a list of face names +;; `icicle-file-list' - Choose a list of file names +;; `icicle-file' - Visit a file or directory +;; `icicle-find-file' - Visit a file or directory (relative) +;; `icicle-find-file-absolute' - Visit a file (absolute) +;; `icicle-find-file-in-tags-table' - Visit a file in a tags table +;; `icicle-find-file-read-only' - Visit a file in read-only mode +;; `icicle-find-first-tag' - Visit source-code definition with tag +;; `icicle-font' - Change the frame font +;; `icicle-frame-bg' - Change the frame background color +;; `icicle-frame-fg' - Change the frame foreground color +;; `icicle-fundoc' - Display the doc of a function +;; `icicle-Info-menu' - Go to an Info menu node +;; `icicle-increment-option' - Increment option value using arrows +;; `icicle-increment-variable' - Increment variable value +;; `icicle-insert-buffer'- Insert a buffer +;; `icicle-insert-thesaurus-entry' - Insert thesaurus entry +;; `icicle-keyword-list' - Choose a list of keywords (regexps) +;; `icicle-kill-buffer' - Kill a buffer +;; `icicle-kmacro' - Execute a keyboard macro (Emacs 22+) +;; `icicle-locate-file' - Open a file located anywhere +;; `icicle-plist' - Choose a symbol and its property list +;; `icicle-recent-file' - Open a recently used file +;; `icicle-remove-buffer-candidate' - +;; Remove buffer from those always shown +;; `icicle-remove-buffer-config' - +;; Remove from `icicle-buffer-configs' +;; `icicle-remove-file-from-recentf-list' - Remove from recent files +;; `icicle-remove-saved-completion-set' - Remove a set from +;; `icicle-saved-completion-sets' +;; `icicle-reset-option-to-nil' - +;; Set value of binary option to nil +;; `icicle-search-bookmark' - Search a bookmark +;; `icicle-search-bookmark-list-bookmark' - Bookmark-list bookmark +;; `icicle-search-dired-bookmark' - Search a Dired bookmark +;; `icicle-search-file-bookmark' - Search a bookmarked file +;; `icicle-search-gnus-bookmark' - Search a bookmarked Gnus message +;; `icicle-search-info-bookmark' - Search a bookmarked Info node +;; `icicle-search-local-file-bookmark' - Search a local-file bookmark +;; `icicle-search-man-bookmark' - Search a bookmarked `man' page +;; `icicle-search-non-file-bookmark' - Search a bookmarked buffer +;; `icicle-search-region-bookmark' - Search a bookmarked region +;; `icicle-search-remote-file-bookmark' - Search a remote bookmark +;; `icicle-search-url-bookmark' - Search a bookmarked URL +;; `icicle-select-frame' - Select frame by name and raise it +;; `icicle-select-window' - Select window by its buffer name +;; `icicle-set-option-to-t' - Set the value of a binary option to t +;; `icicle-toggle-option' - Toggle the value of a binary option +;; `icicle-vardoc' - Display the doc of a variable +;; `icicle-where-is' - Show key sequences that invoke a command +;; +;; For simplicity, the descriptions of these commands are singular +;; actions (e.g. "kill a buffer"), but each of them can be used to +;; act on any number of items any number of times (e.g. kill one or +;; more buffers). I recommend that you follow a similar naming +;; convention - remember that the doc string will let users know that +;; the command can be used on multiple objects. +;; +;; Macros `icicle-define-command' and `icicle-define-file-command' +;; define a multi-command in a simple way. Sometimes you will need a +;; little more flexibility. In that case, you can use higher-order +;; functions `icicle-explore' and `icicle-apply' to define a +;; multi-command. See (@> "Defining Icicles Tripping Commands"). +;; +;;(@* "Are Users Dependent on Icicles To Use Multi-Commands?") +;; ** Are Users Dependent on Icicles To Use Multi-Commands? ** +;; +;; For users to be able to take advantage of the Icicles features +;; that your multi-command provides, they must load Icicles. You can +;; do this for them, by adding (require 'icicles nil t) to your code. +;; The last two arguments mean that no error will be raised if for +;; some reason Icicles cannot be found or successfully loaded. +;; +;; But that brings up another question: What happens to your +;; multi-command if Icicles is not available for a user, or s?he +;; doesn't want to load it? No problem - your multi-command then +;; automatically turns into a normal, single-choice command - +;; graceful degradation. +;; +;; Similarly, users can always turn off `icicle-mode' at any time, to +;; return to the standard Emacs behavior. +;; +;; Users will, in any case, need to load Icicles at compile time, in +;; order to byte-compile your library that calls macro +;; `icicle-define-command' or `icicle-define-file-command' - either +;; that, or you can duplicate the definition of the macro in your +;; library. To let users load Icicles at (only) compile time, add +;; this to your library that defines multi-commands: +;; +;; (eval-when-compile '(require icicles)) +;; +;; See Also: +;; +;; * (@> "Defining Icicles Tripping Commands") for how to use +;; `icicle-apply' and `icicle-explore' to define browsing commands. +;; +;; * (@> "Defining Multiple-Choice Menus"). +;; +;; * (@> "Note to Programmers") for further programming guidelines. +;; +;; * Library `synonyms.el', which uses `icicle-define-command' to +;; define command `synonyms'. This command lets you use Icicles +;; completion on input regexps when you search a thesaurus. +;; +;; * Library `palette.el', which uses `icicle-define-command' to +;; define command `palette-pick-color-by-name-multi'. This command +;; lets you use Icicles completion on input regexps when you choose +;; a palette color by name. +;; +;; * Library `highlight.el', which uses `icicle-define-command' to +;; defined commands `hlt-choose-faces', `hlt-choose-visible-faces', +;; and `hlt-choose-invisible-faces'. These commands let you choose +;; a set of faces. + +;;(@* "Defining Icicles Tripping Commands") +;; +;; Defining Icicles Tripping Commands +;; ---------------------------------- +;; +;; Section (@file :file-name "icicles-doc1.el" :to "Icicles Tripping") +;; describes the use of Icicles tripping (aka navigation or browsing) +;; multi-commands. This section tells you how to define your own +;; such commands for custom trips - it is thus for Emacs-Lisp +;; programmers. +;; +;; The best way to learn how to do this is to look at how the +;; existing tripping commands are defined. Some of them use macro +;; `icicle-define-command'; others do not. Some use the +;; building-block functions `icicle-explore' or `icicle-apply'; +;; others do not. Several use `icicle-search' as a building block. +;; +;;(@* "Using `icicle-define-command'") +;; ** Using `icicle-define-command' ** +;; +;; Those that use `icicle-define-command' take advantage of some +;; extraneous way to obtain trip location information from a display +;; candidate, which is just a string. For example, `icicle-bookmark' +;; ultimately uses the display string to look up location information +;; in a bookmarks file. Those that use `icicle-explore' or +;; `icicle-apply' make use of location information stored in the +;; alist COLLECTION argument to `completing-read'. +;; +;; You can also use `icicle-define-command', `icicle-explore', and +;; `icicle-apply' to define multi-commands other than browsing +;; commands - the action function can do anything you like. +;; +;;(@* "Using `icicle-explore'") +;; ** Using `icicle-explore' ** +;; +;; `icicle-explore' is a higher-order function that takes as +;; arguments the following functions, in addition to accepting +;; the optional `completing-read' arguments. +;; +;; * A function to build a candidates alist (COLLECTION) for +;; completion. It fills `icicle-candidates-alist' with the +;; candidates, each of which is a cons with a display candidate +;; string as car and (typically) location information as cdr. For +;; example, `icicle-find-tag' uses the tag text as display +;; candidate and the standard tag-locating information as the cdr: +;; tag info, file path, and goto function. +;; +;; * A function that acts on the candidate finally chosen (`RET'), +;; when completion is finished. +;; +;; * A function to call if the user hits `C-g' during completion. +;; +;; * A function to call if an error is raised during completion. +;; +;; * A function to call after completion is finished, to clean things +;; up. +;; +;; If you also bind `icicle-candidate-action-fn' to a function that +;; takes a display candidate (string) as argument and navigates to +;; the corresponding location, then `icicle-explore' does everything +;; you need for an Icicles trip. You can use function +;; `icicle-get-alist-candidate' to get the location information for a +;; given display candidate. +;; +;;(@* "Using `icicle-apply'") +;; ** Using `icicle-apply' ** +;; +;; `icicle-apply' binds `icicle-candidate-action-fn' appropriately +;; and calls `icicle-explore'. It applies its function argument to +;; completion candidates the user acts on (using `C-RET' etc.). It +;; applies the function to the full alist entry, that is, the display +;; candidate car plus any additional information in the cdr. For a +;; tripping command, the additional information provides a location +;; and the function applied takes you there. +;; +;; This use of an alist that stores location information in the cdrs +;; is what makes `icicle-apply' and `icicle-explore' particularly +;; suitable for defining navigation multi-commands. The Icicles +;; macros `icicle-define-command' and `icicle-define-file-command' +;; make no such provision, but with suitable arguments you can use +;; them too to define tripping commands. +;; +;;(@* "Using `icicle-search'") +;; ** Using `icicle-search' ** +;; +;; `icicle-search' is another high-level function for defining +;; tripping commands. Like `icicle-apply', it calls +;; `icicle-explore', but it also provides features for searching +;; bookmarks, buffers, and files. It takes as arguments the search +;; limits (region), if any, and either a regexp or a function that +;; determines the unfiltered search hits. It does everything else +;; needed to define a trip command that uses search hits as +;; completion candidates. Several predefined Icicles tripping +;; commands were defined using `icicle-search'. +;; +;;(@* "Tripping on Foot") +;; ** Tripping on Foot ** +;; +;; You should be able to define any tripping commands you need using +;; `icicle-explore', `icicle-apply', or `icicle-search'. +;; +;; If, however, for some reason you decide to define one at a lower, +;; pedestrian level (that is, without using any of those building +;; blocks), then bind `icicle-whole-candidate-as-text-prop-p' to `t' +;; around the call to `completing-read'. You can then use +;; `icicle-get-alist-candidate' to retrieve the candidate cdr +;; (e.g. location) information from the completion result. +;; +;; However, if the action or alternate action function that you need +;; modifies the existing set of completion candidates on the fly, as +;; a side effect, then bind `icicle-whole-candidate-as-text-prop-p' +;; to `nil' in the action function. Then modify both +;; `minibuffer-completion-table' and `icicle-candidates-alist' as +;; needed to perform the side effect. +;; +;; Icicles search-and-replace provides an example of this. When you +;; replace text, the original domain of search-hit candidates (with +;; their associated location information) is altered, so that you can +;; continue replacing coherently. (See the code for +;; `icicle-search-action' and +;; `icicle-search-highlight-and-maybe-replace'.) +;; +;; Because such side effects can change the meaning of cycling state +;; information such as the current candidate number, Icicles does not +;; automatically save such state information before a candidate +;; action and then restore it afterward. +;; +;; For example, search-and-replace removes a search-hit candidate, as +;; a side effect, if the replacement text no longer matches your +;; input. In that case, a current candidate number recorded before +;; the action would no longer correspond to the same candidate. +;; +;; For this reason, if your action function does not perform any such +;; side effects on the candidates, and you want to restore the +;; cycling state as it was before a candidate action, then you might +;; want your action function to save and then restore the values of +;; Icicles variables such as `icicle-candidate-nb', +;; `icicle-last-completion-candidate', and +;; `icicle-completion-candidates'. +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Icicles Tripping") +;; for information about using Icicles Trip commands +;; +;; * (@> "Defining Icicles Commands (Including Multi-Commands)") +;; for general information about defining multi-commands +;; +;; * (@> "Programming with Fancy Candidates") for information about +;; `icicle-whole-candidate-as-text-prop-p' + +;;(@* "Defining Multiple-Choice Menus") +;; +;; Defining Multiple-Choice Menus +;; ------------------------------ +;; +;; Icicles multi-commands (see +;; (@file :file-name "icicles-doc1.el" :to "Multi-Commands")) can be +;; used provide users with multiple-choice menus. While the possible +;; choices can be accessed by minibuffer completion or cycling, a +;; user can also display them in buffer `*Completions*' using `TAB' +;; or `S-TAB', and click them there to choose them. +;; +;; That is, buffer `*Completions*' can act as a multiple-choice menu. +;; +;; Simple use case: Suppose that you use special characters (Greek +;; letters, math symbols, accented letters in another language...), +;; but only occasionally - you don't want to take the trouble to +;; learn a special input method for them or flip to a different soft +;; keyboard. One simple way to handle this is to create a menu of +;; such special characters - Greek letters, for instance. You only +;; need to create the menu once, providing the necessary completions +;; as, say, Unicode characters. When you need to input such a +;; character, just use your command that pops up buffer +;; `*Completions*' with the available special characters. Even if +;; you don't know how to type them on your keyboard, you can cycle +;; through them or use `mouse-2' to choose them. +;; +;; Here's a simple example of defining a command that uses a +;; multiple-choice menu. (Other examples given above, such as +;; `my-delete-file-or-directory' are also examples, but this one uses +;; menu items that look more like menu items.) +;; +;; (icicle-define-command my-menu-command +;; "Display menu and act on choice(s)." +;; my-menu-action +;; "`TAB' for menu. `C-mouse-2' to choose. " +;; my-menu-items nil t) +;; +;; (defvar my-menu-items +;; '(("Foobar" . foobar-fn) ("Toto" . toto-fn) ("Titi" . titi-fn)) +;; "Alist of menu items and their associated commands.") +;; +;; (defun my-menu-action (item) +;; "Call function associated with menu-item ITEM." +;; (funcall (cdr (assoc item my-menu-items)))) +;; +;; (defun foobar-fn () (message "Foobar chosen")) +;; (defun toto-fn () (message "Toto chosen")) +;; (defun titi-fn () (message "Titi chosen")) +;; +;; A user does `M-x my-menu-command' and hits `TAB' to display this +;; menu in the `*Completions*' buffer: +;; +;; Click mouse-2 on a completion to select it. (C-h: help) +;; +;; Possible completions are: +;; Foobar Titi +;; Toto +;; +;; The user presses and holds the Control key. S?he clicks `Foobar' +;; - message "Foobar chosen" appears. S?he clicks `Toto - message +;; "Toto chosen" appears. +;; +;; And so on - all while holding Control pressed. Any number of menu +;; items can be chosen, any number of times. The command is finally +;; exited with `RET' or `C-g'. +;; +;; The COLLECTION argument passed to `completing-read' here is +;; `my-menu-items', an alist of key-value pairs, where the key is a +;; menu-item name and the value is the function that implements the +;; menu item. For example, menu item `Foobar' is implemented by +;; function `foobar-fn', and the alist element is therefore ("Foobar" +;; . foobar-fn). +;; +;; Function `my-menu-action' is executed when a user clicks +;; `C-mouse-2' on a menu item. It just looks up the menu item's +;; function in alist `my-menu-items', and then calls that function. +;; +;; What? You think it's odd that the user must hit `TAB' to display +;; the menu? Then just use this code instead: +;; +;; (icicle-define-command +;; my-menu-command +;; "Display menu and act on choice(s)." +;; my-menu-action +;; "`C-mouse-2' or `C-RET' to choose menu items" +;; my-menu-items nil t nil nil nil nil +;; ((icicle-show-*Completions*-initially-flag t))) +;; +;; This just adds a binding for +;; `icicle-show-*Completions*-initially-flag', so that +;; `*Completions*' is displayed initially. +;; +;; Granted, the `*Completions*' display doesn't exactly look like +;; your average menu. And the header line doesn't mention the +;; multiple-choice possibility (holding Control while clicking). But +;; the header does say to use `C-h' for help, and that help does +;; mention `C-mouse-2' (as does the prompt). And the menu does act +;; like a menu. And the doc string of `my-menu-command' can provide +;; more help, as needed. +;; +;; There are also some freebie advantages of using such menus, +;; besides the feature of multiple-choice. These include choosing +;; menu items from the keyboard, with completion, and cycling among +;; menu items. The additional features are all explained when the +;; user hits `C-?'. +;; +;; One common use of a multiple-choice menu is letting the user +;; select a list of items from a larger list of candidates. The list +;; is returned, with the items in the order selected. Examples of +;; this include these multi-commands: +;; +;; * `icicle-bookmark-list' - bookmark names +;; +;; * `icicle-buffer-list' - buffer names, selected from `buffer-list' +;; (possibly after filtering) +;; +;; * `icicle-directory-list' - directory names, selected from +;; subdirectories in the current directory and any directories you +;; navigate to +;; +;; * `icicle-face-list' - face names, selected from `face-list' +;; +;; * `icicle-file-list' - file names, selected from files in the +;; current directory and any directories you navigate to +;; +;; * `icicle-keyword-list' - keywords (regexps), selected from those +;; you have previously entered +;; +;; * `hlt-choose-faces', `hlt-choose-visible-faces', +;; `hlt-choose-invisible-faces' - face names, selected from the +;; (visible/invisible) highlighting faces in the buffer +;; +;; Such commands can be used on their own, or they can be used in the +;; `interactive' specs of other commands that act on an entire list +;; of selected items. And don't forget that the set of "menu items" +;; (completion candidates) is susceptible to sorting in various ways, +;; as well as filtering in the usual ways: progressive completion, +;; chipping away the non-elephant, and so on. +;; +;; Here as an example definition is `icicle-file-list': +;; +;; (icicle-define-command icicle-file-list +;; "Choose a list of file names. +;; The list of names (strings) is returned." +;; (lambda (name) (push name file-names)) +;; "Choose file (`RET' when done): " +;; (mapcar #'list (directory-files default-directory nil +;; icicle-re-no-dot)) +;; nil nil nil 'file-name-history nil nil +;; ((file-names ())) ; Additional bindings +;; nil nil +;; (prog1 (setq file-names (delete "" file-names)) ; Return list +;; (when (interactive-p) (message "Files: %S" file-names)))) +;; +;; See (@file :file-name "icicles-doc1.el" :to "Nutshell View of Icicles") +;; for information about progressive completion and chipping away. + +;;(@* "Defining Icicles Multi `M-x'") +;; +;; Defining Icicles Multi `M-x' +;; ---------------------------- +;; +;; This section is for Emacs-Lisp programmers. It explains how the +;; Icicles Multi `M-x' feature is implemented, providing an advanced +;; illustration of using macro `icicle-define-command'. +;; +;;(@* "How Multi `M-x' is Defined") +;; ** How Multi `M-x' is Defined ** +;; +;; The definition of `icicle-execute-extended-command' provides an +;; interesting illustration of using `icicle-define-command'. The +;; candidate action function itself binds a candidate action +;; function, in case the candidate is a command that reads input with +;; completion. +;; +;; (icicle-define-command +;; icicle-execute-extended-command ; `M-x' in Icicle mode. +;; "Read command name, then read its arguments and call it." +;; icicle-execute-extended-command-1 ; Action function +;; (format "Execute command%s: " ; `completing-read' args +;; (if current-prefix-arg +;; (format " (prefix %d)" +;; (prefix-numeric-value current-prefix-arg)) +;; "")) +;; obarray 'commandp t nil 'extended-command-history nil nil +;; ((last-cmd last-command)) ; Save the last command. +;; nil (setq last-command last-cmd) ; Undo: restore last command. +;; (setq last-command last-cmd)) ; Last: restore last command. +;; +;; (defun icicle-execute-extended-command-1 (cmd-name) +;; "Action function for `icicle-execute-extended-command'." +;; (set-buffer orig-buff) ; bound by `icicle-define-command'. +;; (select-window orig-window) +;; (let ((icicle-candidate-action-fn +;; (lambda (x) (funcall (intern cmd-name) x)))) +;; (run-hooks 'post-command-hook) +;; (setq this-command cmd) +;; (run-hooks 'pre-command-hook) +;; (let ((enable-recursive-minibuffers t)) +;; (call-interactively (intern cmd-name) 'record-it)))) +;; +;; The last seven lines of this action function rebind +;; `icicle-candidate-action-fn' to a function that calls the +;; candidate `cmd-name' on a single argument that it reads. This is +;; useful if `cmd-name' is a command that, itself, reads an input +;; argument with completion. When that is the case, you can use +;; completion on that input, and if you do that, you can use `C-RET' +;; to use command `cmd-name' as a multi-command. In other words, +;; this binding allows for two levels of multi-commands. +;; +;; There are a few things wrong with this definition, however. In +;; the action function, the candidate command is applied to a +;; candidate that is a string. What if it is a command, such as +;; `describe-variable', that expects a symbol argument? Or a number +;; argument? There is no way to know what kind of command will be +;; used, and what kind of argument it will need. The solution is to +;; first try a string candidate argument, then convert the string to +;; a symbol or number. That is, bind this to +;; `icicle-candidate-action-fn': +;; +;; (lambda (x) +;; (condition-case nil +;; (funcall cmd x) ; Try to use a string candidate. If that +;; (wrong-type-argument ; didn't work, use a symbol or number. +;; (funcall cmd (car (read-from-string x)))))) +;; +;; A similar problem occurs if the action function called doesn't +;; accept a (single) argument. The best thing to do in this case is +;; punt - call `icicle-help-on-candidate' to display help on the +;; candidate. To the code above, we add another error handler: +;; +;; (wrong-number-of-arguments (funcall #'icicle-help-on-candidate)) +;; +;; And what if the command `cmd' does something that changes the +;; focus away from the minibuffer's frame? That's the case for +;; `describe-variable', for instance: it selects buffer `*Help*'. To +;; fix this potential problem, the action function needs to reset the +;; focus back to the minibuffer frame: +;; +;; (lambda (x) +;; (condition-case nil +;; (funcall cmd x) +;; (wrong-type-argument (funcall cmd (car (read-from-string x)))) +;; (wrong-number-of-arguments +;; (funcall #'icicle-help-on-candidate))) +;; (select-frame-set-input-focus +;; (window-frame (minibuffer-window)))) +;; +;; The actual definitions of the action function and the main command +;; are even more complex. They need to take into account various +;; subtleties, including those associated with recursive minibuffers +;; and multiple invocations of `completing-read'. Evaluate, for +;; example, (symbol-function 'icicle-execute-extended-command) to see +;; the real definition. +;; +;; See Also: +;; +;; (@file :file-name "icicles-doc1.el" :to "Icicles Multi `M-x'"). + +;;(@* "Defining Multi-Commands the Hard Way") +;; +;; Defining Multi-Commands the Hard Way +;; ------------------------------------ +;; +;; This section is for Emacs-Lisp programmers. It gives you a taste +;; of what is involved behind the scene when you effortlessly use +;; `icicle-define-command' or `icicle-define-file-command' to define +;; a multi-command. +;; See (@> "Defining Icicles Commands (Including Multi-Commands)"). +;; +;; It can be good to know this, if only for the case where you need +;; to define a multi-command that has special behavior not provided +;; by `icicle-define(-file)-command' out of the box. For example, if +;; you want the normal, single-choice `RET' behavior to be different +;; from the multiple-choice `C-RET' behavior, then you might want to +;; roll your own. Likewise, if you want to define your own help on +;; individual candidates, to be invoked when users use `C-M-RET' and +;; so on. +;; +;; To write your own multi-command, you must make the command do +;; this: +;; +;; 1. Call `completing-read' or `read-file-name', and perform some +;; action on the completed input. +;; +;; 2. Bind one or more of these variables to action functions, which +;; each take a completion candidate as argument: +;; +;; a. `icicle-candidate-action-fn' - a function that performs an +;; action on a completion candidate - often the same action as +;; #1. +;; +;; b. `icicle-candidates-list-action-fn' - a function that +;; performs an action on the list of all completion candidates. +;; +;; c. `icicle-candidate-alt-action-fn' - a function that performs +;; an alternative action on a completion candidate. +;; +;; d. `icicle-candidates-list-alt-action-fn' - a function that +;; performs an alternative action on the list of candidates. +;; +;; e. `icicle-candidate-help-fn' - a function that displays +;; specialized help for a completion candidate. +;; +;; (You can also provide mode-line help and tooltip help for +;; individual candidates. +;; See "Candidates with Text Properties".) +;; +;; f. `icicle-delete-candidate-object' - a function that deletes +;; an object associated with (e.g. named by) a completion +;; candidate. +;; +;; #1 just lets people use the command normally, to perform the #1 +;; action on a completion candidate entered with `RET'. Because of +;; #2, people can perform the #2 action(s) on any completion +;; candidates, while still continuing to cycle or complete +;; candidates. `icicle-candidate-action-fn' is often the same as the +;; action for #1, but nothing prevents you from using different +;; actions. +;; +;; When internal variable `icicle-candidate-action-fn' is not bound, +;; the default action is performed: display help on the current +;; completion candidate. When `icicle-candidate-help-fn' is not +;; bound, the default help display is used. +;; +;; Instead of binding `icicle-delete-candidate-object' to a deletion +;; action function, you can bind it to a symbol (variable) whose +;; value is a list of completion-candidate objects. +;; See (@> "More about Multi-Commands") for more information. +;; +;; Here is a definition of a simple (not multi-) command that reads a +;; font name and then changes the selected frame to use that font. +;; By virtue of calling `completing-read', Icicles completion and +;; cycling are available, using all available font names as the pool +;; of candidates. +;; +;; (defun change-font () +;; "Change font of selected frame." +;; (modify-frame-parameters +;; (selected-frame) +;; (list (cons 'font (completing-read +;; "Font: " (mapcar #'list (x-list-fonts "*")) +;; nil t))))) +;; +;; Here's a definition of a multi-command `change-font' that takes +;; advantage of an action function when cycling candidates: +;; +;; 1 (defun change-font () +;; 2 "Change font of current frame." +;; 3 (interactive) +;; 4 (let* ((orig-frame (selected-frame)) +;; 5 (orig-font (frame-parameter nil 'font)) +;; 6 (icicle-candidate-action-fn +;; 7 ;; Perform the action on a candidate, without leaving +;; 8 ;; `completing-read'. You can do this over and over. +;; 9 (lambda (font) +;; 10 (modify-frame-parameters orig-frame +;; 11 (list (cons 'font font)))))) +;; 12 (condition-case nil +;; 13 (modify-frame-parameters +;; 14 orig-frame +;; 15 (list +;; 16 (cons 'font +;; 17 ;; Perform the action on your final choice. +;; 18 (completing-read +;; 19 "Font: " +;; 20 (mapcar #'list (x-list-fonts "*")) nil t)))) +;; 21 ((quit error) +;; 22 (modify-frame-parameters +;; 23 orig-frame +;; 24 (list (cons 'font orig-font))))))) +;; +;; As you can see, there is a lot more going on here than in the +;; simple-command version. These are the points to keep in mind, +;; when defining a multi-command by hand: +;; +;; 1. Save anything you need to restore, so you can, in effect, undo +;; the action in case of `C-g' (lines 4-5). +;; +;; 2. Bind `icicle-candidate-action-fn' to the action to perform +;; (lines 6-11). +;; +;; 3. Perform the action, using `completing-read' to provide the +;; target candidate (lines 13-20). Do this in the body of a +;; `condition-case' (lines 12-24). +;; +;; 4. Restore the original context in the error-handling part of the +;; `condition-case' (lines 22-24). Include `quit' in the +;; error-type list. +;; +;; The above definition is not quite complete, in fact. To let +;; `icicle-all-candidates' be able to report on failures, the +;; `icicle-candidate-action-fn' code should also trap errors and +;; return nil as a success indicator. +;; +;; In fact, things can get even hairier (much hairier) still, if the +;; function at the core of your command does things like create a new +;; frame - especially on MS Windows, with its click-to-focus window +;; manager. The action of `change-font' doesn't do that, but if it +;; did, you would need to redirect the focus back to the minibuffer +;; frame, using `select-frame-set-input-focus'. As an illustration +;; of what's involved, here's a definition that would deal with such +;; problems. It also traps `icicle-candidate-action-fn' errors, +;; returning nil to report success and the error message to report +;; failure. +;; +;; (defun change-font () +;; "Change font of current frame." +;; (interactive) +;; (let* ((orig-buff (current-buffer)) +;; (orig-window (selected-window)) +;; (orig-frame (selected-frame)) +;; (orig-font (frame-parameter nil 'font)) +;; (icicle-candidate-action-fn +;; (lambda (candidate) +;; (condition-case action-fn-return +;; (progn +;; (modify-frame-parameters +;; orig-frame (list (cons 'font candidate))) +;; (select-frame-set-input-focus +;; (window-frame (minibuffer-window))) +;; nil) ; Return nil to report success. +;; ;; Return error message to report error. +;; (error (error-message-string action-fn-return)))))) +;; (condition-case act-on-choice +;; (modify-frame-parameters +;; orig-frame +;; (list (cons 'font +;; (completing-read +;; "Font: " (mapcar #'list (x-list-fonts "*")) +;; nil t nil nil nil nil)))) +;; (quit (switch-to-buffer orig-buff) +;; (modify-frame-parameters +;; orig-frame (list (cons 'font orig-font)))) +;; (error (switch-to-buffer orig-buff) +;; (modify-frame-parameters +;; orig-frame (list (cons 'font orig-font))) +;; (error (error-message-string act-on-choice)))))) +;; +;; That's a lot of (error-prone) work! You obviously don't want to +;; be doing that a lot. Whenever you can, you should use macro +;; `icicle-define-command' or `icicle-define-file-command' to define +;; your multi-commands. +;; +;; See Also: +;; +;; * (@> "Defining Icicles Commands (Including Multi-Commands)") for +;; the easy way to define `change-font'. +;; +;; * (@file :file-name "icicles-doc1.el" :to "Icicles Tripping") +;; for information about defining action functions that perform +;; side effects on candidates. + +;;(@* "Global Filters") +;; +;; Global Filters +;; -------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;; Which completion candidates get displayed? To review: +;; +;; 1. The domain of discourse, that is, all possible candidates, is +;; determined by the arguments to `completing-read', +;; `read-file-name', or `M-x'. +;; +;; 2. A user types something in the minibuffer. This narrows the +;; possible candidates to those that match the input. Matching +;; can be prefix-matching or apropos-matching. +;; +;; Wouldn't it sometimes be useful to filter #1 in a global way, +;; before filtering it with the user input (#2)? Functions +;; `completing-read' and `read-file-name' take a predicate argument, +;; so that can be used for global filtering. However, those +;; functions are usually called from some command, and it would also +;; be useful to give end users, not just programmers, some way to +;; globally filter candidates. +;; +;; For example, if you have a command, such as `icicle-buffer', that +;; reads a buffer name and displays the buffer, some users might +;; always be interested only in buffers that are associated with +;; files. They don't want to see possible candidates like +;; `*scratch*' and `*Messages*'. What they need is a way to apply a +;; global predicate that limits candidates to file-buffer names - but +;; they don't have access to the call to `completing-read' that is +;; inside the command definition. +;; +;; For this reason, some global filtering variables are provided by +;; Icicles: +;; +;; `icicle-must-match-regexp', `icicle-must-not-match-regexp', +;; `icicle-must-pass-predicate', `icicle-extra-candidates'. +;; +;; The first and second of these are regexps that candidates must +;; match and must not match, respectively, in order for them to be +;; displayed. The third is a predicate that candidates must satisfy. +;; The fourth is a list of extra candidates to display. Any of the +;; filters can be nil, in which case it has no effect. +;; +;; Each of these except `icicle-extra-candidates' filters not only +;; completion candidates but also the default values passed to +;; `completing-read' and `read-file-name'. +;; +;; Variable `icicle-must-match-regexp' is similar to the standard +;; variable `completion-regexp-list', except: +;; +;; * `completion-regexp-list' is a list of regexps, not just one. +;; * `icicle-must-match-regexp' is used after filtering using option +;; `icicle-transform-function'. +;; +;; Variable `icicle-extra-candidates' is not really a "filter". It +;; does not restrict the set of possible candidates - rather, it +;; extends that set. The other filters do not act on the candidates +;; in `icicle-extra-candidates' - they are always added. Extra +;; candidates are displayed in buffer `*Completions*' using face +;; `icicle-extra-candidate'. +;; +;; Note that an extra candidate need not have anything in common with +;; the normal (non-extra) candidates. In particular, because it is +;; provided explicitly, it does not follow the restrictions implied +;; by the current candidate-generation method. For example, when +;; option `icicle-guess-commands-in-path' is non-nil, the extra +;; shell-command candidates provided have no connection with the +;; file-name completion that is used to generate the other candidates +;; (see (@* "Icicles Shell-Command Enhancements")). +;; +;; Note too that if an extra candidate is already a candidate anyway +;; then it will be present twice in the list of all candidates (that +;; is, unless `icicle-transform-function' removes duplicate +;; candidates). +;; +;; These global variables are internal variables, even though they +;; are defined as user options - they are not really meant to be +;; customized. If you are not an Emacs-Lisp programmer, you will not +;; use these variables, but some commands that you use might provide +;; corresponding global-filter user options. Icicles provides +;; customizable user options for Icicles buffer commands, such as +;; `icicle-buffer'. For example: +;; +;; `icicle-buffer-match-regexp' - Regexp buffer names must match +;; `icicle-buffer-no-match-regexp' - Regexp buffers must not match +;; `icicle-buffer-predicate' - Predicate buffers must satisfy +;; `icicle-buffer-extras' - Extra buffer names to display +;; +;; You might, for instance, customize `icicle-buffer-no-match-regexp' +;; to not display file-buffers whose names end in `.elc', and +;; customize `icicle-buffer-predicate' to show only buffers that are +;; associated with files. The former would use a value of "\\.elc$", +;; and the latter would use a value such as this: +;; +;; (lambda (bufname) (buffer-file-name (get-buffer bufname))) +;; +;; Similarly, Icicles provides user options for filtering and sorting +;; file names during completion: +;; +;; `icicle-file-match-regexp' - Regexp file names must match +;; `icicle-file-no-match-regexp' - Regexp file names must not match +;; `icicle-file-predicate' - Predicate files must satisfy +;; `icicle-file-extras' - Extra file names to display +;; +;; If you, as a programmer, write a command, and you want to expose +;; global filters to users of the command, you should: +;; +;; 1. Create corresponding user options that can be customized. +;; 2. Bind the user options to the corresponding filtering variables. +;; +;; If you use `icicle-define-command' or `icicle-define-file-command' +;; to define a command (recommended), then you can simply pass the +;; filter-variable bindings as part of the BINDINGS argument. +;; +;; For example, here is the core definition of `icicle-buffer': +;; +;; (icicle-define-command +;; icicle-buffer ; Command name +;; "Switch to a different buffer." ; Doc string +;; switch-to-buffer ; Action function +;; "Switch to buffer: " ; completing-read args +;; (mapcar (lambda (buf) (list (buffer-name buf))) (buffer-list)) +;; nil nil nil 'buffer-name-history +;; (icicle-default-buffer-names) nil +;; ;; Filter bindings +;; ((icicle-must-match-regexp icicle-buffer-match-regexp) +;; (icicle-must-not-match-regexp icicle-buffer-no-match-regexp) +;; (icicle-must-pass-predicate icicle-buffer-predicate) +;; (icicle-extra-candidates icicle-buffer-extras) +;; (icicle-sort-comparer icicle-buffer-sort))) +;; +;; If you define a command that uses completion, but you don't use +;; `icicle-define-command' or `icicle-define-file-command', then you +;; can just bind such variables around a call to `completing-read' or +;; `read-file-name'. Command `icicle-complete-keys' presents an +;; example of this, binding `icicle-buffer-no-match-regexp'. +;; +;; Another way that users can apply predicates to completion +;; candidates is to use `M-&' while completing. These predicates +;; apply to the full alist-entry candidates that are supplied to +;; `completing-read' or `read-file-name', not just to the textual +;; candidates that are displayed in buffer `*Completions*'. +;; See (@file :file-name "icicles-doc1.el" :to "Progressive Completion"). + +;;(@* "Specifying Match Functions for Commands") +;; +;; Defining Commands that Use Specific Match Functions +;; --------------------------------------------------- +;; +;; This section is for Emacs-Lisp programmers. +;; +;; By default, Icicles lets users use basic prefix completion (with +;; `TAB') or apropos completion (with `S-TAB'). They can +;; alternatively use other completion methods with `TAB' and `S-TAB': +;; +;; * They can use `C-(' during completion to cycle among `TAB' +;; completion methods. +;; +;; * They can use `M-(' to cycle among `S-TAB' completion +;; methods. +;; +;; * They can customize options `icicle-TAB-completion-methods-alist' +;; and `icicle-S-TAB-completion-methods-alist', to define the +;; completion methods among which they can cycle. +;; +;; When you define an Icicles command, you can specify which +;; string-matching functions the command uses during completion: +;; +;; * If you want the command to use fuzzy completion for `TAB' by +;; default, then bind `icicle-fuzzy-completion-flag' to +;; non-`nil'. Users can still use `C-(' to toggle fuzzy completion +;; off. +;; +;; * If you want the command to use a particular string-matching +;; function for `S-TAB' completion by default, then bind variable +;; `icicle-apropos-complete-match-fn' to that function. Users can +;; still use `M-(' to cycle among the other matching functions for +;; `S-TAB'. +;; +;; You can bind `icicle-apropos-complete-match-fn' to any function +;; that matches strings. You will probably also want to ensure that +;; it is available for `M-(' cycling, by adding it to +;; `icicle-S-TAB-completion-methods-alist' in a `let' binding. For +;; example, to use matching function `my-match' in `my-cmd', you +;; might do this: +;; +;; (defun my-cmd () +;; "..." +;; (interactive) +;; (let ((icicle-apropos-complete-match-fn 'my-match) +;; (icicle-S-TAB-completion-methods-alist +;; (cons (cons "mine" 'my-match) +;; icicle-S-TAB-completion-methods-alist))) +;; (do-something (completing-read "Choose: " ...) ...))) + +;;(@* "Defining Buffer-Text Completion for Comint Modes") +;; +;; Defining Buffer-Text Completion for Comint Modes +;; ------------------------------------------------ +;; +;; This section is for Emacs-Lisp programmers. +;; +;; Out of the box, Icicles provides completion for buffer text in +;; some contexts. This includes Shell mode, for example. Whenever +;; there are two or more candidate completions, you can use Icicles +;; completion, with all of its features (cycling, progressive +;; completion, apropos completion, and so on). +;; See (@> "Completion in Comint Modes"). +;; +;; Shell mode is an example of a mode that inherits from Comint mode. +;; Other libraries sometimes define modes that also extend Comint +;; mode in different ways. Library ESS does so, for example. +;; +;; In such modes, the top-level completion command used is typically +;; `comint-dynamic-complete', and it is typically bound to `TAB'. In +;; Icicle mode, `TAB' in such a buffer is instead bound to the +;; Icicles version of this command, `icicle-comint-dynamic-complete'. +;; +;; Icicles provides the infrastructure for you to take advantage of +;; Icicles completion with your own modes that inherit from Comint +;; mode. For that, just do the following: +;; +;; 1. Define replacement functions for the functions that perform the +;; completion. The functions to be replaced themselves typically +;; call a Comint completion function, such as +;; `comint-dynamic-complete-filename'. You can typically use the +;; same definitions as the original functions, except replace the +;; call to a function that displays multiple matching candidates +;; by a call to a corresponding Icicles function that performs +;; completion. +;; +;; 2. Customize option `icicle-comint-dynamic-complete-replacements', +;; adding the mappings that specify which standard functions to +;; replace with your completion functions (from #1). Take a look +;; at the default value of this option to see what I mean. +;; +;; 3. Use `eval-after-load' to toggle Icicle mode when the vanilla +;; code for your mode is loaded, to ensure that the original +;; definitions are picked up. See the end of `icicles-mode.el' +;; for an example of this. +;; +;; If you are interested in trying this, take a look at the Icicles +;; code for, say, `icicle-shell-dynamic-complete-command', comparing +;; it with the original code for `shell-dynamic-complete-command'. +;; You will see that the only change is to substitute a call to +;; `icicle-shell-dynamic-complete-as-command' for a call to +;; `shell-dynamic-complete-as-command'. Likewise, +;; `icicle-shell-dynamic-complete-as-command' is a trivial alteration +;; of `shell-dynamic-complete-as-command'. +;; +;; The key is to ultimately call an Icicles completion command, such +;; as `icicle-comint-dynamic-simple-complete', whenever there are +;; multiple completion candidates. This has the effect of using +;; Icicles minibuffer completion instead of simply displaying the +;; alternatives in buffer `*Completions*'. +;; +;; Icicles uses this same technique, of substituting Icicles +;; completion for simple display of alternatives, for all buffer-text +;; completion that it supports out of the box, even when there is no +;; relation with Comint mode. + +;;(@* "Note to Programmers") +;; +;; Note to Programmers +;; ------------------- +;; +;; Here are some simple guidelines for using Icicles in Emacs-Lisp +;; programming: +;; +;; 1. *Use it*! Even if you don't do anything else, include this in +;; your library: +;; +;; (require 'icicles nil t) +;; +;; That has absolutely no consequences if Icicles is not present +;; in the user's `load-path' (there is no load error). If Icicles +;; is present, however, then users can take advantage of each use +;; you make of `completing-read' and `read-file-name' in your +;; code. +;; +;; 2. Use an input-completion read function, such as +;; `completing-read' or `read-file-name', when you read input! +;; There is almost never a reason not to use an input-completion +;; function when reading user input - especially considering that +;; you need not always provide a REQUIRE-MATCH argument. +;; +;; Try also to find an appropriate PREDICATE argument, and a good +;; set of default values to pass to `completing-read' as its +;; COLLECTION argument. Too often, I think, we use an overly +;; general COLLECTION argument, such as the `obarray', and we +;; don't provide a (good) PREDICATE. Using an input-completion +;; function with an appropriate candidate completion list and +;; predicate can help users considerably. +;; +;; If you want to also give users a way to customize a (different) +;; predicate that applies only to the textual candidates that are +;; displayed in buffer `*Completions*', as opposed to the full +;; alist-entry candidates that are supplied to `completing-read' +;; or `read-file-name', then you can define a new user option and +;; then bind internal variable `icicle-must-pass-predicate' to the +;; value of that option. See (@> "Global Filters"). +;; +;; 3. Avoid using a literal-string `interactive' spec (e.g. +;; (interactive "fFile: ")) that reads input with completion. +;; Instead, call `completing-read' or `read-file-name' within the +;; `interactive' spec. This saves Icicles users of progressive +;; completion the need to hit `RET' multiple times to pass their +;; input up through multiple levels of recursive minibuffers to +;; the top level. See +;; (@file :file-name "icicles-doc1.el" :to "Progressive Completion"). +;; +;; 4. In many cases, it makes sense to define a multi-command, rather +;; than a simple command. People can always use a multi-command +;; as a simple command, but not vice versa. +;; See (@file :file-name "icicles-doc1.el" :to "Multi-Commands"), +;; (@> "Defining Icicles Commands (Including Multi-Commands)"), +;; and (@> "Defining Multi-Commands the Hard Way"). +;; +;; 5. Consider using `icicle-completing-read-history' instead of +;; `read-from-minibuffer' or `read-string' for most purposes. +;; This lets users complete their input against previously entered +;; input. Completion is lax, so they can also enter new input. +;; +;; 6. You can bind `icicle-sort-comparer' temporarily to any sort +;; function you need. +;; +;; 7. Function `icicle-next-candidate' is a general framework for +;; letting users cycle completions of partial input strings. I +;; use it to define the cycling behavior for both prefix and +;; apropos completions. You can use it to easily define other, +;; application-specific input matching/completion/cycling +;; behavior. Just supply it with a function that takes the +;; current partial user input (a string) and returns a list of +;; candidate completions, however those might be defined. +;; +;; 8. If the potential number of completion candidates is enormous, +;; then icompletion display in `*Completions*' can be slow. In +;; that case, consider turning it off for the duration of the +;; command, by binding `icicle-incremental-completion-flag' to +;; nil. An alternative to turning it off is the approach taken in +;; Icicles (e.g. `icicle-vardoc' and +;; `icicle-insert-thesaurus-entry'): Just add a reminder to the +;; doc string to tell users that they can toggle +;; `icicle-incremental-completion-flag' with `C-#'. +;; +;; 9. Another of my libraries that can help programmers provide +;; default values is `thingatpt+.el'. It provides functions for +;; picking up symbols, sexps, numbers, words, and other sorts of +;; thing near the text cursor (`point'). +;; +;; See Also: +;; +;; * (@file :file-name "icicles-doc1.el" :to "Multi-Commands") +;; * (@> "Defining Icicles Commands (Including Multi-Commands)") +;; * (@> "Defining Multi-Commands the Hard Way") +;; * (@> "Defining Multiple-Choice Menus") +;; * (@> "Global Filters") +;; * (@> "Specifying Match Functions for Commands") +;; * (@> "Multi-Completions") + +;;(@* "La Petite Histoire") +;; +;; La Petite Histoire +;; ------------------ +;; +;; 1. This library started life as `elect-mbuf.el', by Hans Koomen. +;; +;; Original posting: +;; From koomen@cs.rochester.edu Mon Jun 19 19:27:58 1989 +;; To: info-gnu-emacs@prep.ai.mit.edu +;; Cc: Hans +;; Subject: elect-mbuf.el +;; Date: Tue, 13 Jun 89 15:17:07 -0400 +;; +;; 2. I hacked and enhanced the library in various relatively minor +;; ways over the years, maintaining it as `elect-mbuf.el' - see +;; details in file `icicles-chg.el'. +;; +;; I did not change the main functionality of the library during this +;; period: it always cycled the COMPLETE list of (prefix) completion +;; candidates passed to `completing-read'; it did not update the +;; candidate list based on the current minibuffer contents. +;; +;; So, for instance, if you had `M-x for' in the minibuffer, `down' +;; would cycle among ALL Emacs commands, not just those that start +;; with "for". I used the library this way for fifteen years without +;; thinking much about this behavior or the code behind it. +;; +;; 3. In July 2005, Lennart Borgman gave `elect-mbuf.el' a quick try, +;; and intuitively expected to see behavior along the lines that you +;; see now for Icicles prefix completion: +;; +;; a. `down' should cycle completions relative to the current input, +;; not all completions supplied to `completing-read'. +;; b. If buffer `*Completions*' is displayed, `down' should highlight +;; the current candidate there. +;; +;; Good idea Lennart (). So I +;; implemented that behavior, and renamed the library "Icicles" (for, +;; I suppose, "input cycles" or some such - or because it's "cool"). +;; +;; 4. The code changes I made to implement #3 (completion cycling +;; relative to current input) made me realize that other completion +;; matchings could be implemented in a similar way. Prefix +;; completion (the completion provided by Emacs) is handy, but it is +;; also sometimes a bit limited. The idea of apropos completion +;; occurred to me, and I implemented that as well. +;; +;; 5. I extended the library quite a bit more, in terms of +;; convenience (highlighting, treatment of buffer +;; `*Completions*',..., but also in terms of functionality. In +;; particular, it now treats file names too. And, because Emacs 21 +;; and later versions use `read-file-name' for `find-file' and so on, +;; Icicles now treats `read-file-name' the same as `completing-read'. +;; +;; 6. On another suggestion from LennartBorgman, I made Icicles take +;; advantage of Delete Selection mode. And I implemented it as a +;; minor mode. +;; +;; 7, 8, 9,... One thing has led to another, and I've just kept +;; adding features. Feature creep, I guess. But the more I play +;; with Icicles, the more I imagine new ways it might be made more +;; useful. + +;;(@* "Note on Non-nil `pop-up-frames' on MS Windows") +;; +;; Note on Non-nil `pop-up-frames' on MS Windows +;; --------------------------------------------- +;; +;; If you use `pop-up-frames' = t, like I do, you might have noticed +;; that Emacs completion does not play well with using separate +;; frames for each buffer. In particular, it does not play well with +;; having a separate frame for buffer `*Completions*'. When you try +;; to complete input using `TAB', a new frame is created for buffer +;; `*Completions*', and, at least on MS Windows, it is selected, +;; taking the input focus away from the original frame's minibuffer! +;; +;; This means that, once the `*Completions*' buffer has been +;; displayed in a separate frame, you cannot, for instance, cycle +;; completion candidates, without first reselecting the original +;; frame manually. You cannot even use normal completion - you +;; cannot add text in the minibuffer, or delete text there, because +;; the minibuffer in the original frame no longer has the input +;; focus. Bummer. +;; +;; In general, Emacs does not play too well with one-buffer-per-frame +;; (`pop-up-frames' = t), and this is a good example of that general +;; problem. +;; +;; I reported this Emacs bug. I've been hoping it will be corrected +;; since Emacs 21... +;; +;; I don't have this problem of loss of frame input focus in my own +;; setup, even though I use `pop-up-frames' = t, because I use my +;; library `oneonone.el'. (Try it!) If you need a solution while +;; waiting for the Emacs fix, you can try doing something similar to +;; what I do in `oneonone.el': +;; +;; 1. Use dedicated frames for both `*Completions*' and the +;; minibuffer. +;; +;; 2. Display buffer `*Completions*' using a special-display function +;; that explicitly redirects the input focus from the +;; `*Completions*' frame back to the minibuffer frame. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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: + +;; You need not load this file. It contains only documentation. + +(provide 'icicles-doc2) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-doc2.el ends here diff --git a/.emacs.d/icicles/icicles-face.el b/.emacs.d/icicles/icicles-face.el new file mode 100644 index 0000000..e79ad7d --- /dev/null +++ b/.emacs.d/icicles/icicles-face.el @@ -0,0 +1,681 @@ +;;; icicles-face.el --- Faces for Icicles +;; +;; Filename: icicles-face.el +;; Description: Faces for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:19:43 2006 +;; Version: 22.0 +;; Last-Updated: Wed May 5 10:53:48 2010 (-0700) +;; By: dradams +;; Update #: 518 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-face.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: +;; +;; None +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; customization groups and faces. For Icicles documentation, see +;; `icicles-doc1.el' and `icicles-doc2.el'. +;; +;; Groups defined here: +;; +;; `Icicles', `Icicles-Buffers', `Icicles-Completions-Display', +;; `Icicles-Files', `Icicles-Key-Bindings', +;; `Icicles-Key-Completion', `Icicles-Matching', +;; `Icicles-Minibuffer-Display', `Icicles-Miscellaneous', +;; `Icicles-Searching'. +;; +;; Faces defined here: +;; +;; `icicle-candidate-part', +;; `icicle-common-match-highlight-Completions', +;; `icicle-complete-input', `icicle-completion', +;; `icicle-Completions-instruction-1', +;; `icicle-Completions-instruction-2', +;; `icicle-current-candidate-highlight', `icicle-extra-candidate', +;; `icicle-historical-candidate', `icicle-input-completion-fail', +;; `icicle-input-completion-fail-lax', +;; `icicle-match-highlight-Completions', +;; `icicle-match-highlight-minibuffer', `icicle-mode-line-help', +;; `icicle-multi-command-completion', +;; `icicle-mustmatch-completion', `icicle-proxy-candidate', +;; `icicle-saved-candidate', `icicle-search-context-level-1', +;; `icicle-search-context-level-2', +;; `icicle-search-context-level-3', +;; `icicle-search-context-level-4', +;; `icicle-search-context-level-5', +;; `icicle-search-context-level-6', +;; `icicle-search-context-level-7', +;; `icicle-search-context-level-8', `icicle-search-current-input', +;; `icicle-search-main-regexp-current', +;; `icicle-search-main-regexp-others', `icicle-special-candidate', +;; `icicle-whitespace-highlight', `minibuffer-prompt'. +;; +;; Functions defined here: +;; +;; `icicle-increment-color-hue', +;; `icicle-increment-color-saturation'. +;; +;; 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. +;; +;; (@> "Groups, organized alphabetically") +;; (@> "Faces, organized alphabetically") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Groups, organized alphabetically") + +;;; Groups, organized alphabetically --------------------------------- + +;;;###autoload +(defgroup Icicles nil + "Minibuffer input completion and cycling of completion candidates." + :prefix "icicle-" + :group 'completion :group 'convenience :group 'help :group 'apropos + :group 'dabbrev :group 'matching :group 'minibuffer :group 'recentf + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Buffers nil + "Icicles preferences related to buffers." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Files nil + "Icicles preferences related to files." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Completions-Display nil + "Icicles preferences related to display of completion candidates." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Key-Bindings nil + "Icicles preferences related to key bindings." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Key-Completion nil + "Icicles preferences related to key completion (`icicle-complete-keys')." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Matching nil + "Icicles preferences related to matching input for completion." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Minibuffer-Display nil + "Icicles preferences related to minibuffer display during completion." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Miscellaneous nil + "Miscellaneous Icicles preferences." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;;###autoload +(defgroup Icicles-Searching nil + "Icicles preferences related to searching." + :prefix "icicle-" :group 'Icicles + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "drew.adams" "@" "oracle" + ".com?subject=icicles.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and Icicles library versions.")) + :link '(url-link :tag "Other Libraries by Drew" + "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries") + :link '(url-link :tag "Download" + "http://www.emacswiki.org/cgi-bin/wiki/icicles.el") + :link '(url-link :tag "Description" + "http://www.emacswiki.org/cgi-bin/wiki/Icicles") + :link '(emacs-commentary-link :tag "Doc-Part2" "icicles-doc2") + :link '(emacs-commentary-link :tag "Doc-Part1" "icicles-doc1") + ) + +;;(@* "Faces, organized alphabetically") + +;;; Faces, organized alphabetically ---------------------------------- + +;;;###autoload +(defface icicle-candidate-part + '((((background dark)) (:background "#451700143197")) ; a very dark magenta + (t (:background "#EF84FFEAF427"))) ; A light green. + "*Face used to highlight part(s) of a candidate in *Completions*." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-common-match-highlight-Completions + '((((background dark)) (:foreground "#2017A71F2017")) ; a dark green + (t (:foreground "magenta3"))) + "*Face used to highlight candidates common match, in *Completions*." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-complete-input + '((((background dark)) (:foreground "#B19E6A64B19E")) ; a dark magenta + (t (:foreground "DarkGreen"))) + "*Face used to highlight input when it is complete." + :group 'Icicles-Minibuffer-Display :group 'faces) + +;;;###autoload +(defface icicle-completion + '((((background dark)) (:foreground "#0000D53CD53C")) ; a dark cyan + (t (:foreground "Red"))) ; red + "*Face used to indicate minibuffer completion. +It highlights the minibuffer indicator and the `Icy' minor-mode +lighter during completion. +Not used for versions of Emacs before version 21." + :group 'Icicles-Minibuffer-Display :group 'Icicles-Miscellaneous :group 'faces) + +;;;###autoload +(defface icicle-Completions-instruction-1 + '((((background dark)) (:foreground "#AC4AAC4A0000")) ; a dark yellow + (t (:foreground "Blue"))) + "*Face used to highlight first line of *Completions* buffer." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-Completions-instruction-2 + '((((background dark)) (:foreground "#0000D53CD53C")) ; a dark cyan + (t (:foreground "Red"))) + "*Face used to highlight second line of *Completions* buffer." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-current-candidate-highlight + '((((background dark)) (:background "#69D40A460000")) ; a red brown + (t (:background "CadetBlue1"))) + "*Face used to highlight the current candidate, in *Completions*." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-extra-candidate + '((((background dark)) (:background "#4517305D0000")) ; a dark brown + (t (:background "#C847D8FEFFFF"))) ; a light blue + "*Face used to highlight *Completions* candidates that are extra. +This means that they belong to list `icicle-extra-candidates'." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-historical-candidate + '((((background dark)) (:foreground "#DBD599DF0000")) ; a dark orange + (t (:foreground "Blue"))) + "*Face used to highlight *Completions* candidates that have been used." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-input-completion-fail + '((((background dark)) (:background "#22225F5F2222")) ; a dark green + (t (:foreground "Black" :background "Plum"))) + "*Face for highlighting failed part of input during strict completion." + :group 'Icicles-Minibuffer-Display :group 'faces) + +;;;###autoload +(defface icicle-input-completion-fail-lax + '((((background dark)) (:background "#00005E3B5A8D")) ; a dark cyan + (t (:foreground "Black" :background "#FFFFB8C4BB87"))) + "*Face for highlighting failed part of input during lax completion." + :group 'Icicles-Minibuffer-Display :group 'faces) + +;;;###autoload +(defface icicle-match-highlight-Completions + '((((background dark)) (:foreground "#1F1FA21CA21C")) ; a very dark cyan + (t (:foreground "Red3"))) + "*Face used to highlight root that was completed, in *Completions*." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-match-highlight-minibuffer '((t (:underline t))) + "*Face used to highlight root that was completed, in minibuffer." + :group 'Icicles-Minibuffer-Display :group 'faces) + +;;;###autoload +(defface icicle-mode-line-help + '((((background dark)) (:foreground "#AC4AAC4A0000")) ; a dark yellow + (t (:foreground "Blue"))) + "*Face used to highlight help shown in the mode-line." + :group 'Icicles-Completions-Display :group 'Icicles-Miscellaneous :group 'faces) + +;;;###autoload +(defface icicle-multi-command-completion + '((((background dark)) ; a dark cyan on a dark magenta + (:foreground "#0000D53CD53C" :background "#8B3500007533")) + (t (:foreground "Red" :background "#78F6FFFF8E4F"))) ; red on a light green + "*Face used to indicate Icicles multi-command completion. +It highlights the minibuffer indicator and the `Icy+' minor-mode +lighter during multi-command completion. +Not used for versions of Emacs before version 21." + :group 'Icicles-Minibuffer-Display :group 'Icicles-Miscellaneous :group 'faces) + +;;;###autoload +(defface icicle-mustmatch-completion + '((((type x w32 mac graphic) (class color)) + (:box (:line-width -2 :color "Blue"))) ; blue box + (t (:inverse-video t))) + "*Face used to indicate strict minibuffer completion. +It highlights the minibuffer indicator and the `Icy' or `Icy+' +minor-mode lighter during strict completion. +Not used for versions of Emacs before version 21." + :group 'Icicles-Minibuffer-Display :group 'Icicles-Miscellaneous :group 'faces) + +;;;###autoload +(defface icicle-proxy-candidate + '((((background dark)) (:background "#316B22970000")) ; a very dark brown + (t (:background "#E1E1EAEAFFFF" ; A light blue. + :box (:line-width 2 :color "White" :style released-button)))) + "*Face used to highlight proxy candidates in `*Completions*'." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-saved-candidate + '((((background dark)) (:background "gray20")) ; a dark gray + (t (:background "gray80"))) ; a light gray + "*Face used to highlight *Completions* candidates that have been saved." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-search-main-regexp-current + '((((background dark)) (:background "#00004AA652F1")) ; a dark cyan + (t (:background "misty rose"))) + "*Face used to highlight current match of your search context regexp. +This highlighting is done during Icicles searching." + :group 'Icicles-Searching :group 'faces) + +;; This is essentially a version of `doremi-increment-color-component' for hue only. +;; Must be before `icicle-search-context-level-1'. +(defun icicle-increment-color-hue (color increment) + "Increase hue component of COLOR by INCREMENT." + (unless (featurep 'hexrgb) (error "`icicle-increment-color-hue' requires library `hexrgb.el'")) + (unless (string-match "#" color) ; Convert color name to #hhh... + (setq color (hexrgb-color-values-to-hex (x-color-values color)))) + ;; Convert RGB to HSV + (let* ((rgb (x-color-values color)) + (red (/ (float (nth 0 rgb)) 65535.0)) ; Convert from 0-65535 to 0.0-1.0 + (green (/ (float (nth 1 rgb)) 65535.0)) + (blue (/ (float (nth 2 rgb)) 65535.0)) + (hsv (hexrgb-rgb-to-hsv red green blue)) + (hue (nth 0 hsv)) + (saturation (nth 1 hsv)) + (value (nth 2 hsv))) + (setq hue (+ hue (/ increment 100.0))) + (when (> hue 1.0) (setq hue (1- hue))) + (hexrgb-color-values-to-hex (mapcar (lambda (x) (floor (* x 65535.0))) + (hexrgb-hsv-to-rgb hue saturation value))))) + +;; This is essentially a version of `doremi-increment-color-component' for saturation only. +;; Must be before `icicle-search-context-level-1'. +(defun icicle-increment-color-saturation (color increment) + "Increase saturation component of COLOR by INCREMENT." + (unless (featurep 'hexrgb) + (error "`icicle-increment-color-saturation' requires library `hexrgb.el'")) + (unless (string-match "#" color) ; Convert color name to #hhh... + (setq color (hexrgb-color-values-to-hex (x-color-values color)))) + ;; Convert RGB to HSV + (let* ((rgb (x-color-values color)) + (red (/ (float (nth 0 rgb)) 65535.0)) ; Convert from 0-65535 to 0.0-1.0 + (green (/ (float (nth 1 rgb)) 65535.0)) + (blue (/ (float (nth 2 rgb)) 65535.0)) + (hsv (hexrgb-rgb-to-hsv red green blue)) + (hue (nth 0 hsv)) + (saturation (nth 1 hsv)) + (value (nth 2 hsv))) + (setq saturation (+ saturation (/ increment 100.0))) + (when (> saturation 1.0) (setq saturation (1- saturation))) + (hexrgb-color-values-to-hex (mapcar (lambda (x) (floor (* x 65535.0))) + (hexrgb-hsv-to-rgb hue saturation value))))) + +;;;###autoload +(defface icicle-search-context-level-1 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 80) 10) + "#071F473A0000"))) ; a dark green + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 80) 10) + "#FA6CC847FFFF"))))) ; a light magenta + "*Face used to highlight level (subgroup match) 1 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-2 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 40) 10) + "#507400002839"))) ; a dark red + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 40) 10) + "#C847FFFFE423"))))) ; a light cyan + "*Face used to highlight level (subgroup match) 2 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-3 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 60) 10) + "#4517305D0000"))) ; a dark brown + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 60) 10) + "#C847D8FEFFFF"))))) ; a light blue + "*Face used to highlight level (subgroup match) 3 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-4 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 20) 10) + "#176900004E0A"))) ; a dark blue + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-saturation + (icicle-increment-color-hue context-bg 20) 10) + "#EF47FFFFC847"))))) ; a light yellow + "*Face used to highlight level (subgroup match) 4 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-5 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 80) + "#04602BC00000"))) ; a very dark green + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 80) + "#FCFCE1E1FFFF"))))) ; a light magenta + "*Face used to highlight level (subgroup match) 5 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-6 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 40) + "#32F200001979"))) ; a very dark red + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 40) + "#E1E1FFFFF0F0"))))) ; a light cyan + "*Face used to highlight level (subgroup match) 6 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-7 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 60) + "#316B22970000"))) ; a very dark brown + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 60) + "#E1E1EAEAFFFF"))))) ; a light blue + "*Face used to highlight level (subgroup match) 7 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-context-level-8 + (let ((context-bg (face-background 'icicle-search-main-regexp-current))) + `((((background dark)) + (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 20) + "#12EC00003F0E"))) ; a very dark blue + (t (:background ,(if (featurep 'hexrgb) + (icicle-increment-color-hue context-bg 20) + "#F6F5FFFFE1E1"))))) ; a light yellow + "*Face used to highlight level (subgroup match) 8 of your search context. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-current-input + '((((background dark)) + (:foreground "White" :background "#7F0D00007F0D")) ; a dark magenta + (t (:foreground "Black" :background "Green"))) + "*Face used to highlight what your current input matches. +This highlighting is done during Icicles searching whenever +`icicle-search-highlight-context-levels-flag' is non-nil and the +search context corresponds to the entire regexp." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-search-main-regexp-others + '((((background dark)) (:background "#348608690000")) ; a very dark brown + (t (:background "CadetBlue1"))) + "*Face used to highlight other matches of your search context regexp. +If user option `icicle-search-highlight-threshold' is less than one, +then this face is not used. +This highlighting is done during Icicles searching." + :group 'Icicles-Searching :group 'faces) + +;;;###autoload +(defface icicle-special-candidate + '((((background dark)) (:background "#176900004E0A")) ; a dark blue + (t (:background "#EF47FFFFC847"))) ; A light yellow. + "*Face used to highlight *Completions* candidates that are special. +The meaning of special is that their names match +`icicle-special-candidate-regexp'." + :group 'Icicles-Completions-Display :group 'faces) + +;;;###autoload +(defface icicle-whitespace-highlight + '((((background dark)) (:background "#000093F402A2")) ; a medium green + (t (:background "Magenta"))) + "*Face used to highlight initial whitespace in minibuffer input." + :group 'Icicles-Minibuffer-Display :group 'faces) + +;; This is defined in `faces.el', Emacs 22. This is for Emacs < 22. This is used +;; only for versions of Emacs that have `propertize' but don't have this face. +;;;###autoload +(unless (facep 'minibuffer-prompt) + (defface minibuffer-prompt '((((background dark)) (:foreground "cyan")) + (t (:foreground "dark blue"))) + "Face for minibuffer prompts." + :group 'basic-faces)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-face) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-face.el ends here diff --git a/.emacs.d/icicles/icicles-fn.el b/.emacs.d/icicles/icicles-fn.el new file mode 100644 index 0000000..85258e2 --- /dev/null +++ b/.emacs.d/icicles/icicles-fn.el @@ -0,0 +1,5972 @@ +;;; icicles-fn.el --- Non-interactive functions for Icicles +;; +;; Filename: icicles-fn.el +;; Description: Non-interactive functions for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:25:53 2006 +;; Version: 22.0 +;; Last-Updated: Fri Jun 18 13:12:20 2010 (-0700) +;; By: dradams +;; Update #: 11863 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-fn.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', `cl', `el-swank-fuzzy', `ffap', +;; `ffap-', `fuzzy-match', `hexrgb', `icicles-face', `icicles-opt', +;; `icicles-var', `kmacro', `levenshtein', `thingatpt', +;; `thingatpt+', `wid-edit', `wid-edit+', `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; non-interactive functions. For Icicles documentation, see +;; `icicles-doc1.el' and `icicles-doc2.el'. +;; +;; Non-interactive functions defined here: +;; +;; `assq-delete-all', `icicle-2nd-part-string-less-p', +;; `icicle-abbreviate-or-expand-file-name', `icicle-alpha-p', +;; `icicle-alt-act-fn-for-type', `icicle-any-candidates-p', +;; `icicle-apropos-any-candidates-p', +;; `icicle-apropos-any-file-name-candidates-p', +;; `icicle-apropos-candidates', `icicle-assoc-delete-all', +;; `icicle-barf-if-outside-Completions', +;; `icicle-barf-if-outside-Completions-and-minibuffer', +;; `icicle-barf-if-outside-minibuffer', +;; `icicle-buffer-file/process-name-less-p', +;; `icicle-buffer-smaller-p', +;; `icicle-call-then-update-Completions', `icicle-candidate-set-1', +;; `icicle-candidate-short-help', +;; `icicle-case-insensitive-string-less-p', +;; `icicle-case-string-less-p', `icicle-cdr-lessp', +;; `icicle-choose-completion-string', `icicle-clear-lighter', +;; `icicle-clear-minibuffer', `icicle-color-blue-lessp', +;; `icicle-color-completion-setup', `icicle-color-green-lessp', +;; `icicle-color-help', `icicle-color-hue-lessp', +;; `icicle-color-name-w-bg', `icicle-color-red-lessp', +;; `icicle-color-saturation-lessp', `icicle-color-value-lessp', +;; `icicle-command-abbrev-save', +;; `icicle-command-abbrev-used-more-p', +;; `icicle-command-names-alphabetic-p', +;; `icicle-complete-again-update', `icicle-completing-p', +;; `icicle-completing-read', `icicle-completing-read-multiple', +;; `icicle-completing-read-history', +;; `icicle-completion-all-completions', +;; `icicle-completion-setup-function', +;; `icicle-completion-try-completion', `icicle-custom-type', +;; `icicle-define-crm-completion-map', `icicle-delete-count', +;; `icicle-delete-whitespace-from-string', +;; `icicle-dired-read-shell-command', +;; `icicle-dired-smart-shell-command', +;; `icicle-dir-prefix-wo-wildcards', `icicle-dirs-first-p', +;; `icicle-dirs-last-p', `icicle-displayable-cand-from-saved-set', +;; `icicle-display-cand-from-full-cand', +;; `icicle-display-completion-list', `icicle-display-Completions', +;; `icicle-display-candidates-in-Completions', +;; `icicle-expanded-common-match', +;; `icicle-expanded-common-match-1', `icicle-expand-file-name', +;; `icicle-explicit-saved-completion-candidates', +;; `icicle-extra-candidates-first-p', +;; `icicle-face-valid-attribute-values', `icicle-file-directory-p', +;; `icicle-file-name-apropos-candidates', +;; `icicle-file-name-directory', +;; `icicle-file-name-directory-w-default', +;; `icicle-file-name-input-p', `icicle-file-name-nondirectory', +;; `icicle-file-name-prefix-candidates', `icicle-file-readable-p', +;; `icicle-file-remote-p', `icicle-file-writable-p', +;; `icicle-filesets-files-under', `icicle-files-within', +;; `icicle-files-within-1', `icicle-filter-alist', +;; `icicle-filter-wo-input', `icicle-first-matching-candidate', +;; `icicle-first-N', `icicle-fit-completions-window', +;; `icicle-fix-default-directory', `icicle-frames-on', +;; `icicle-fuzzy-candidates', `icicle-get-alist-candidate', +;; `icicle-get-candidates-from-saved-set', +;; `icicle-dired-guess-shell-command', `icicle-help-line-buffer', +;; `icicle-help-line-file', +;; `icicle-highlight-candidate-in-Completions', +;; `icicle-highlight-complete-input', +;; `icicle-highlight-initial-whitespace', +;; `icicle-highlight-input-noncompletion', +;; `icicle-highlight-input-noncompletion-rest', +;; `icicle-highlight-lighter', `icicle-historical-alphabetic-p', +;; `icicle-increment-cand-nb+signal-end', +;; `icicle-input-from-minibuffer', `icicle-insert-candidates', +;; `icicle-insert-cand-in-minibuffer', +;; `icicle-insert-Completions-help-string', +;; `icicle-isearch-complete-past-string', `icicle-join-nth-parts', +;; `icicle-key-description', `icicle-kill-a-buffer', +;; `icicle-last-modified-first-p', `icicle-levenshtein-match', +;; `icicle-levenshtein-one-match', `icicle-levenshtein-one-regexp', +;; `icicle-levenshtein-strict-match', +;; `icicle-lisp-vanilla-completing-read', +;; `icicle-local-keys-first-p', `icicle-make-color-candidate', +;; `icicle-make-plain-predicate', `icicle-major-mode-name-less-p', +;; `icicle-make-face-candidate', +;; `icicle-maybe-sort-and-strip-candidates', +;; `icicle-maybe-sort-maybe-truncate', `icicle-mctize-all', +;; `icicle-mctized-display-candidate', +;; `icicle-mctized-full-candidate', +;; `icicle-minibuffer-default-add-completions', +;; `icicle-minibuf-input', `icicle-minibuf-input-sans-dir', +;; `icicle-minibuffer-default-add-dired-shell-commands', +;; `icicle-minibuffer-prompt-end', `icicle-mode-line-name-less-p', +;; `icicle-most-recent-first-p', `icicle-msg-maybe-in-minibuffer', +;; `icicle-ms-windows-NET-USE', `icicle-multi-sort', +;; `icicle-next-candidate', `icicle-not-basic-prefix-completion-p', +;; `icicle-part-1-cdr-lessp', `icicle-part-1-lessp', +;; `icicle-part-2-lessp', `icicle-part-3-lessp', +;; `icicle-part-4-lessp', `icicle-part-N-lessp', +;; `icicle-place-cursor', `icicle-place-overlay', +;; `icicle-prefix-any-candidates-p', +;; `icicle-prefix-any-file-name-candidates-p', +;; `icicle-prefix-candidates', `icicle-prefix-keys-first-p', +;; `icicle-proxy-candidate-first-p', `icicle-put-at-head', +;; `icicle-put-whole-cand-prop', +;; `icicle-quote-file-name-part-of-cmd', +;; `icicle-readable-to-markers', `icicle-read-char-exclusive', +;; `icicle-read-face-name', `icicle-read-file-name', +;; `icicle-read-from-minibuffer', +;; `icicle-read-from-minibuf-nil-default', `icicle-read-number', +;; `icicle-read-shell-command', +;; `icicle-read-shell-command-completing', `icicle-read-string', +;; `icicle-read-string-completing', +;; `icicle-recentf-make-menu-items', `icicle-recompute-candidates', +;; `icicle-redefine-standard-options', +;; `icicle-redefine-std-completion-fns', +;; `icicle-remove-color-duplicates', `icicle-remove-dots', +;; `icicle-remove-duplicates', `icicle-remove-dups-if-extras', +;; `icicle-remove-if', `icicle-remove-if-not', +;; `icicle-remove-property', `icicle-require-match-p', +;; `icicle-restore-standard-commands', +;; `icicle-restore-standard-options', +;; `icicle-restore-std-completion-fns', `icicle-reversible-sort', +;; `icicle-saved-fileset-p', `icicle-save-or-restore-input', +;; `icicle-save-raw-input', `icicle-scatter', +;; `icicle-scatter-match', `icicle-scroll-or-update-Completions', +;; `icicle-set-difference', `icicle-set-intersection', +;; `icicle-set-union', `icicle-shell-command', +;; `icicle-shell-command-on-region', +;; `icicle-show-help-in-mode-line', `icicle-show-in-mode-line', +;; `icicle-special-candidates-first-p', +;; `icicle-start-of-candidates-in-Completions', +;; `icicle-strip-ignored-files-and-sort', +;; `icicle-subst-envvar-in-file-name', +;; `icicle-substring-no-properties', `icicle-substrings-of-length', +;; `icicle-take', `icicle-toggle-icicle-mode-twice', +;; `icicle-transform-candidates', +;; `icicle-transform-multi-completion', +;; `icicle-unhighlight-lighter', `icicle-unpropertize', +;; `icicle-unsorted-apropos-candidates', +;; `icicle-unsorted-file-name-apropos-candidates', +;; `icicle-unsorted-file-name-prefix-candidates', +;; `icicle-unsorted-prefix-candidates', `icicle-upcase', +;; `icicle-value-satisfies-type-p', `icicle-var-inherits-type-p', +;; `icicle-var-is-of-type-p', `icicle-var-matches-type-p', +;; `icicle-var-val-satisfies-type-p', +;; `old-choose-completion-string', `old-completing-read', +;; `old-completing-read-multiple', `old-completion-setup-function', +;; `old-dired-smart-shell-command', `old-display-completion-list', +;; `old-face-valid-attribute-values', +;; `old-minibuffer-default-add-completions', `old-read-face-name', +;; `old-read-file-name', `old-read-from-minibuffer', +;; `old-read-number', `old-read-string', `old-shell-command', +;; `old-shell-command-on-region'. +;; +;; Internal variables defined here: +;; +;; `icicle-crm-local-completion-map', +;; `icicle-crm-local-must-match-map', +;; `old-crm-local-completion-map', `old-crm-local-must-match-map'. +;; +;; +;; ***** NOTE: These EMACS PRIMITIVES have been REDEFINED HERE: +;; +;; `completing-read' - (See below and doc string.) +;; `display-completion-list' - (See below and doc string.) +;; `face-valid-attribute-values' - (See below and doc string.) +;; `read-file-name' Emacs 20, 21 only - (See below and doc string.) +;; `read-from-minibuffer' - (See below and doc string.) +;; `read-string' - (See below and doc string.) +;; +;; +;; ***** NOTE: The following functions defined in `simple.el' have +;; been REDEFINED HERE: +;; +;; `choose-completion-string' - +;; Don't exit minibuffer after `lisp-complete-symbol' completion. +;; `completion-setup-function' - 1. Put faces on inserted string(s). +;; 2. Help on help. +;; `repeat-complex-command' - Use `completing-read' to read command. +;; +;; +;; ***** NOTE: The following function defined in `filesets.el' has +;; been REDEFINED HERE: +;; +;; `filesets-get-filelist' - Fix. Bug #976 reported to Emacs devel. +;; +;; 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 functions") +;; (@> "Icicles functions - completion display (not cycling)") +;; (@> "Icicles functions - TAB completion cycling") +;; (@> "Icicles functions - S-TAB completion cycling") +;; (@> "Icicles functions - common helper functions") +;; (@> "Icicles functions - sort functions") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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, lexical-let + ;; plus, for Emacs < 21: dolist, push, pop + ;; plus, for Emacs < 20: when, unless + +(require 'hexrgb nil t) ;; (no error if not found): hexrgb-color-name-to-hex, hexrgb-defined-colors, + ;; hexrgb-hex-to-rgb, hexrgb-(red|green|blue|hue|saturation|value), + ;; hexrgb-rgb-to-hsv, hexrgb-value +(require 'wid-edit+ nil t) ;; (no error if not found): + ;; redefined color widget (for icicle-var-is-of-type-p) + +(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-with-selected-window +(require 'icicles-opt) + ;; icicle-Completions-display-min-input-chars, icicle-cycle-into-subdirs-flag, + ;; icicle-expand-input-to-common-match-flag, icicle-highlight-historical-candidates-flag, + ;; icicle-highlight-input-initial-whitespace-flag, icicle-ignore-space-prefix-flag, + ;; icicle-incremental-completion-delay, icicle-incremental-completion-flag, + ;; icicle-incremental-completion-threshold, icicle-default-value, icicle-list-end-string, + ;; icicle-list-join-string, icicle-mark-position-in-candidate, icicle-point-position-in-candidate, + ;; icicle-regexp-quote-flag, icicle-require-match-flag, + ;; icicle-show-Completions-help-flag, icicle-sort-comparer, icicle-special-candidate-regexp, + ;; icicle-transform-function, icicle-use-~-for-home-dir-flag +(require 'icicles-var) + ;; icicle-candidate-nb, icicle-candidate-action-fn, icicle-candidate-properties-alist, + ;; icicle-cmd-calling-for-completion, icicle-common-match-string, icicle-complete-input-overlay, + ;; icicle-completing-p, icicle-completion-candidates, icicle-current-completion-mode, + ;; icicle-current-input, icicle-current-raw-input, icicle-default-directory, icicle-edit-update-p, + ;; icicle-extra-candidates, icicle-ignored-extensions-regexp, icicle-incremental-completion-p, + ;; icicle-initial-value, icicle-last-completion-candidate, icicle-last-input, + ;; icicle-must-match-regexp, icicle-must-not-match-regexp, icicle-must-pass-predicate, + ;; icicle-nb-of-other-cycle-candidates, icicle-re-no-dot, icicle-reverse-sort-p, + ;; icicle-saved-completion-candidates + +;; This requirement is real, but leads to recursion. +;; You should, in any case, just load everything by loading `icicles.el'. +;; (require 'icicles-mode) ;; icicle-mode + + +;; Byte-compiling this file, you will likely get some error or warning +;; messages due to differences between different versions of Emacs. + + +;;; Defvars to quiet the byte-compiler: + +(when (< emacs-major-version 22) + (defvar completion-common-substring) + (defvar completion-root-regexp) + (defvar directory-sep-char) + (defvar minibuffer-completing-symbol) + (defvar minibuffer-prompt-properties) + (defvar partial-completion-mode) + (defvar read-file-name-completion-ignore-case) + (defvar minibuffer-local-filename-completion-map) + (defvar minibuffer-local-must-match-filename-map) + (defvar minibuffer-local-filename-must-match-map) + (defvar tooltip-mode)) + +(when (< emacs-major-version 23) + (defvar completion-styles) ; Defined in `minibuffer.el' + (defvar icicle-Completions-text-scale-decrease)) ; Defined in `icicles-opt.el' (for Emacs 23) + +(defvar filesets-data) ; Defined in `filesets.el' +(defvar shell-completion-execonly) ; Defined in `shell.el' +(defvar recentf-list) ; Defined in `recentf.el' +(defvar recentf-menu-filter-commands) +(defvar recentf-menu-filter) +(defvar recentf-max-menu-items) +(defvar recentf-menu-open-all-flag) +(defvar recentf-menu-filter-commands) +(defvar recentf-menu-items-for-commands) + +;; The name changed during development of Emacs 23. They aliased it for 23.1, but removed it for 23.2. +;; Use the new name and alias the old, but don't declare old obsolete (let Emacs 23 do that.) +(when (and (boundp 'minibuffer-local-must-match-filename-map) (fboundp 'defvaralias)) ; Emacs 22 + (defvar minibuffer-local-filename-must-match-map minibuffer-local-must-match-filename-map + "Local keymap for minibuffer input with completion for filenames with exact match.") + (defvaralias 'minibuffer-local-must-match-filename-map 'minibuffer-local-filename-must-match-map)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Redefined standard functions") + +;;; Redefined standard functions ------------------------------------- + + +;; REPLACE ORIGINAL `choose-completion-string' in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Don't exit minibuffer if this is just a `lisp-complete-symbol' completion. +;; Go to point-max before insert choice. Respect `icicle-dir-candidate-can-exit-p'. +;; +;; Free variable `completion-reference-buffer' is defined in `simple.el'. +;; +(unless (fboundp 'old-choose-completion-string) +(defalias 'old-choose-completion-string (symbol-function 'choose-completion-string))) + +;;;###autoload +(cond ((> emacs-major-version 21) ; Emacs 22+ + (defun icicle-choose-completion-string (choice &optional buffer base-size) + "Switch to BUFFER and insert the completion choice CHOICE. +BASE-SIZE, if non-nil, says how many characters of BUFFER's text +to keep. If it is nil, we call `choose-completion-delete-max-match' +to decide what to delete. +If BUFFER is the minibuffer, then exit the minibuffer, unless one of +the following is true: + - it is reading a file name, CHOICE is a directory, and + `icicle-dir-candidate-can-exit-p' is nil + - `completion-no-auto-exit' is non-nil + - this is just a `lisp-complete-symbol' completion." + (let* ((buffer (or buffer completion-reference-buffer)) + (mini-p (minibufferp buffer))) + ;; If BUFFER is a minibuffer, barf unless it's currently active. + (if (and mini-p (or (not (active-minibuffer-window)) + (not (equal buffer (window-buffer (active-minibuffer-window)))))) + (error "Minibuffer is not active for completion") + ;; Set buffer so buffer-local `choose-completion-string-functions' works. + (set-buffer buffer) + (unless (run-hook-with-args-until-success 'choose-completion-string-functions + choice buffer mini-p base-size) + ;; Insert the completion into the buffer where completion was requested. + (if base-size + (delete-region (+ base-size (if mini-p (minibuffer-prompt-end) (point-min))) + (if mini-p (point-max) (point))) + (choose-completion-delete-max-match choice)) + (when mini-p (goto-char (point-max))) ; $$$$$ (was unconditional) + (insert choice) + (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil)) + ;; Update point in the window that BUFFER is showing in. + (let ((window (get-buffer-window buffer 0))) (set-window-point window (point))) + ;; If completing for the minibuffer, exit it with this choice, + ;; unless this was a `lisp-complete-symbol' completion. + (and (not completion-no-auto-exit) + (equal buffer (window-buffer (minibuffer-window))) + (or minibuffer-completion-table + (and icicle-mode (or icicle-extra-candidates icicle-proxy-candidates))) + (not (eq 'lisp-complete-symbol icicle-cmd-calling-for-completion)) + ;; Exit the minibuffer if `icicle-dir-candidate-can-exit-p', + ;; or not reading a file name, or chosen file is not a directory. + (if (or icicle-dir-candidate-can-exit-p + (not (eq minibuffer-completion-table 'read-file-name-internal)) + (not (file-directory-p (field-string (point-max))))) + (exit-minibuffer) + (let ((mini (active-minibuffer-window))) + (select-window mini) + (when minibuffer-auto-raise (raise-frame (window-frame mini))))))))))) + + ((> emacs-major-version 20) ; Emacs 21 + (defun icicle-choose-completion-string (choice &optional buffer base-size) + "Switch to BUFFER and insert the completion choice CHOICE. +BASE-SIZE, if non-nil, says how many characters of BUFFER's text +to keep. If it is nil, we call `choose-completion-delete-max-match' +to decide what to delete. +If BUFFER is the minibuffer, then exit the minibuffer, unless one of +the following is true: + - it is reading a file name, CHOICE is a directory, and + `icicle-dir-candidate-can-exit-p' is nil + - `completion-no-auto-exit' is non-nil + - this is just a `lisp-complete-symbol' completion." + (let ((buffer (or buffer completion-reference-buffer)) + (mini-p (save-match-data (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" + (buffer-name buffer))))) + ;; If BUFFER is a minibuffer, barf unless it's currently active. + (if (and mini-p (or (not (active-minibuffer-window)) + (not (equal buffer (window-buffer (active-minibuffer-window)))))) + (error "Minibuffer is not active for completion") + ;; Insert the completion into the buffer where completion was requested. + (set-buffer buffer) + (if base-size + (delete-region (+ base-size (if mini-p (icicle-minibuffer-prompt-end) (point-min))) + (if mini-p (point-max) (point))) + (choose-completion-delete-max-match choice)) + (when mini-p (goto-char (point-max))) ; $$$$$ (was unconditional) + (insert choice) + (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil)) + ;; Update point in the window that BUFFER is showing in. + (let ((window (get-buffer-window buffer 0))) (set-window-point window (point))) + ;; If completing for the minibuffer, exit it with this choice, + ;; unless this was a `lisp-complete-symbol' completion. + (and (not completion-no-auto-exit) + (equal buffer (window-buffer (minibuffer-window))) + (or minibuffer-completion-table + (and icicle-mode (or icicle-extra-candidates icicle-proxy-candidates))) + (not (eq 'lisp-complete-symbol icicle-cmd-calling-for-completion)) + ;; Exit the minibuffer if `icicle-dir-candidate-can-exit-p', + ;; or not reading a file name, or chosen file is not a directory. + (if (or icicle-dir-candidate-can-exit-p + (not (eq minibuffer-completion-table 'read-file-name-internal)) + (not (file-directory-p (field-string (point-max))))) + (exit-minibuffer) + (let ((mini (active-minibuffer-window))) + (select-window mini) + (when minibuffer-auto-raise (raise-frame (window-frame mini)))))))))) + + (t ; Emacs 20 + (defun icicle-choose-completion-string (choice &optional buffer base-size) + "Switch to BUFFER and insert the completion choice CHOICE. + BASE-SIZE, if non-nil, says how many characters of BUFFER's text + to keep. If it is nil, we call `choose-completion-delete-max-match' + to decide what to delete. + If BUFFER is the minibuffer, then exit the minibuffer, unless one of + the following is true: + - it is reading a file name, CHOICE is a directory, and + `icicle-dir-candidate-can-exit-p' is nil + - `completion-no-auto-exit' is non-nil + - this is just a `lisp-complete-symbol' completion." + (let ((buffer (or buffer completion-reference-buffer)) + (mini-p (save-match-data (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" + (buffer-name buffer))))) + ;; If BUFFER is a minibuffer, barf unless it's currently active. + (when (and mini-p (or (not (active-minibuffer-window)) + (not (equal buffer (window-buffer (active-minibuffer-window)))))) + (error "Minibuffer is not active for completion")) + ;; Insert the completion into the buffer where completion was requested. + (set-buffer buffer) + (if base-size + (delete-region (+ base-size (point-min)) (if mini-p (point-max) (point))) + (choose-completion-delete-max-match choice)) + (when mini-p (goto-char (point-max))) ; $$$$$ (was unconditional) + (insert choice) + (remove-text-properties (- (point) (length choice)) (point) '(mouse-face nil)) + ;; Update point in the window that BUFFER is showing in. + (let ((window (get-buffer-window buffer 0))) (set-window-point window (point))) + ;; If completing for the minibuffer, exit it with this choice, + ;; unless this was a `lisp-complete-symbol' completion. + (and (not completion-no-auto-exit) + (equal buffer (window-buffer (minibuffer-window))) + (or minibuffer-completion-table + (and icicle-mode (or icicle-extra-candidates icicle-proxy-candidates))) + (not (eq 'lisp-complete-symbol icicle-cmd-calling-for-completion)) + ;; Exit the minibuffer if `icicle-dir-candidate-can-exit-p', + ;; or not reading a file name, or chosen file is not a directory. + (if (or icicle-dir-candidate-can-exit-p + (not (eq minibuffer-completion-table 'read-file-name-internal)) + (not (file-directory-p (buffer-string)))) + (exit-minibuffer) + (select-window (active-minibuffer-window)))))))) + + +;; REPLACE ORIGINAL `completion-setup-function' in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Don't print the help lines here. Do that in `icicle-display-completion-list' instead. +;; That's so we can fit the *Completions* window to the buffer, including the help lines. +;; +(unless (fboundp 'old-completion-setup-function) +(defalias 'old-completion-setup-function (symbol-function 'completion-setup-function))) + +;;;###autoload +(when (< emacs-major-version 22) + (defun icicle-completion-setup-function () + "Set up for completion. This goes in `completion-setup-hook' +so it is called after completion-list buffer text is written." + (save-excursion + (let* ((mainbuf (current-buffer)) + (mbuf-contents (icicle-input-from-minibuffer)) + ;; $$$$$ Should we `expand-file-name' mbuf-contents first? + (dir-of-input (and minibuffer-completing-file-name + (icicle-file-name-directory mbuf-contents)))) + ;; If reading file name and either `icicle-comp-base-is-default-dir-p' is nil or this is a + ;; completion command, then set `default-directory' so it will be copied into *Completions*. + (when (and dir-of-input + (or (and (symbolp last-command) (get this-command 'icicle-completing-command)) + (not icicle-comp-base-is-default-dir-p))) + (with-current-buffer mainbuf (setq default-directory dir-of-input))) + (with-current-buffer standard-output + (completion-list-mode) + (set (make-local-variable 'completion-reference-buffer) mainbuf) + (setq completion-base-size + (cond ((and (eq minibuffer-completion-table 'read-file-name-internal) + icicle-comp-base-is-default-dir-p + (length default-directory))) + ((eq minibuffer-completion-table 'read-file-name-internal) + ;; For file name completion, use the number of chars before + ;; the start of the file name component at point. + (with-current-buffer mainbuf + (save-excursion (skip-chars-backward (format "^%c" directory-sep-char)) + (- (point) (icicle-minibuffer-prompt-end))))) + ((save-match-data (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" + (buffer-name mainbuf))) + ;; Otherwise, in minibuffer, the whole input is being completed. + 0)))))))) + +;;;###autoload +(when (>= emacs-major-version 22) + (defun icicle-completion-setup-function () + "Set up for completion. This goes in `completion-setup-hook' +so it is called after completion-list buffer text is written." + (save-excursion + (let* ((mainbuf (current-buffer)) + (mbuf-contents (minibuffer-completion-contents)) ; Get contents only up to point. + ;; $$$$$ Should we `expand-file-name' mbuf-contents first? Vanilla Emacs does that. + (dir-of-input (and minibuffer-completing-file-name + (icicle-file-name-directory mbuf-contents))) + common-string-length) + ;; If reading file name and either `icicle-comp-base-is-default-dir-p' is nil or this is a + ;; completion command, then set `default-directory' so it will be copied into *Completions*. + (when (and dir-of-input + (or (and (symbolp this-command) (get this-command 'icicle-completing-command)) + (not icicle-comp-base-is-default-dir-p))) + (with-current-buffer mainbuf (setq default-directory dir-of-input))) + (with-current-buffer standard-output + (completion-list-mode) + (set (make-local-variable 'completion-reference-buffer) mainbuf) + (setq completion-base-size + (cond ((and minibuffer-completing-file-name icicle-comp-base-is-default-dir-p + (length default-directory))) + ((and (symbolp minibuffer-completion-table) + (get minibuffer-completion-table 'completion-base-size-function)) + ;; To compute base size, a function can use the global value of + ;; `completion-common-substring' or `minibuffer-completion-contents'. + (with-current-buffer mainbuf + (funcall (get minibuffer-completion-table 'completion-base-size-function)))) + (minibuffer-completing-file-name + ;; For file name completion, use the number of chars before + ;; the start of the file name component at point. + (with-current-buffer mainbuf + (save-excursion (skip-chars-backward completion-root-regexp) + (- (point) (minibuffer-prompt-end))))) + ((and (boundp 'minibuffer-completing-symbol) minibuffer-completing-symbol) nil) + ;; Otherwise, in minibuffer, the base size is 0. + ((minibufferp mainbuf) 0))) + (setq common-string-length + (cond (completion-common-substring (length completion-common-substring)) + (completion-base-size (- (length mbuf-contents) completion-base-size)))) + ;; Put faces on first uncommon characters and common parts. + (when (and (integerp common-string-length) (>= common-string-length 0)) + (let ((element-start (point-min)) + (maxp (point-max)) + element-common-end) + (while (and (setq element-start (next-single-property-change element-start 'mouse-face)) + (< (setq element-common-end (+ element-start common-string-length)) + maxp)) + (when (get-char-property element-start 'mouse-face) + (if (and (> common-string-length 0) + (get-char-property (1- element-common-end) 'mouse-face)) + (put-text-property element-start element-common-end + 'font-lock-face 'completions-common-part)) + (if (get-char-property element-common-end 'mouse-face) + (put-text-property element-common-end (1+ element-common-end) + 'font-lock-face 'completions-first-difference))))))))))) + +(defun icicle-insert-Completions-help-string () + "Add or remove help in *Completions*. +This is controlled by `icicle-show-Completions-help-flag'. If that +option is nil, remove help; else, add it." + (if icicle-show-Completions-help-flag + (let ((instruction2 (or (and icicle-mode (substitute-command-keys + (concat "(\\" + "\\[icicle-minibuffer-help]: help) "))) + "")) + instruction1) + (cond ((< emacs-major-version 22) + (setq instruction1 (if window-system ; We have a mouse. + (substitute-command-keys "Click \\\ +\\[mouse-choose-completion] on a completion to select it. ") + (substitute-command-keys ; No mouse. + "In this buffer, type \\\ +\\[choose-completion] to select the completion near point. ")))) + ((>= emacs-major-version 22) + (setq instruction1 (if (display-mouse-p) ; We have a mouse. + (substitute-command-keys + "Click \\\ +\\[mouse-choose-completion] or type \\[choose-completion] on a completion to select it. ") + (substitute-command-keys ; No mouse. + "In this buffer, type \\\ +\\[choose-completion] to select the completion near point. "))))) + (goto-char (point-min)) + (put-text-property 0 (length instruction1) 'face 'icicle-Completions-instruction-1 + instruction1) + (put-text-property 0 (length instruction2) 'face 'icicle-Completions-instruction-2 + instruction2) + (insert instruction1 instruction2 "\n")) + + ;; Not showing help. Remove standard Emacs help string. + (goto-char (point-min)) + (re-search-forward "Possible completions are:\n") + (delete-region (point-min) (point)))) + +(defun icicle-read-from-minibuf-nil-default (prompt &optional initial-contents keymap read hist + default-value inherit-input-method) + "Like `read-from-minibuffer', but return nil for empty input. +Args are as for `read-from-minibuffer'. +If nothing is input, then nil is returned." + (let ((input (read-from-minibuffer prompt initial-contents keymap nil hist default-value + inherit-input-method))) + (if (string= "" input) nil (if read (car (read-from-string input)) input)))) + +(defun icicle-completing-read-history (prompt &optional hist pred init-input def inherit-i-m) + "Lax `completing-read' against entries in history HIST. +Arguments are as for `completing-read'. HIST is a symbol that is a +history variable. It defaults to `minibuffer-history'. Completion is +lax: a match is not required." + (setq hist (or hist 'minibuffer-history)) + (let ((hist-val (icicle-remove-duplicates (symbol-value hist)))) + (when (and (consp hist-val) (not (stringp (car hist-val)))) ; Convert, e.g. `comand-history'. + (setq hist-val (mapcar (lambda (v) (format "%s" v)) hist-val))) + (completing-read prompt (mapcar #'list hist-val) pred nil init-input hist def inherit-i-m))) + +;; Based on the Emacs 22 C code that defined `completing-read'. +(defun icicle-lisp-vanilla-completing-read (prompt collection &optional predicate require-match + initial-input hist def inherit-input-method) + "Lisp version of vanilla Emacs `completing-read'." + (let ((pos 0) val histvar histpos position init) + (setq init initial-input + minibuffer-completion-table collection + minibuffer-completion-predicate predicate + minibuffer-completion-confirm (if (eq require-match t) nil require-match)) + (setq position nil) + (when init + (when (consp init) (setq position (cdr init) + init (car init))) + (unless (stringp init) + (error "icicle-lisp-vanilla-completing-read, INIT must be a string: %S" init)) + (if (not position) + (setq pos (1+ (length init))) ; Default is to put cursor at end of INITIAL-INPUT. + (unless (integerp position) + (error "icicle-lisp-vanilla-completing-read, POSITION must be an integer: %S" position)) + (setq pos (1+ position)))) ; Convert zero-based to one-based. + (if (symbolp hist) + (setq histvar hist + histpos nil) + (setq histvar (car-safe hist) + histpos (cdr-safe hist))) + (unless histvar (setq histvar 'minibuffer-history)) + (unless histpos (setq histpos 0)) + (setq val (read-from-minibuffer + prompt + (cons init pos) ; initial-contents + (if (not require-match) ; key map + (if (or (not minibuffer-completing-file-name) + (eq minibuffer-completing-file-name 'lambda) + (not (boundp 'minibuffer-local-filename-completion-map))) + minibuffer-local-completion-map + minibuffer-local-filename-completion-map) + (if (or (not minibuffer-completing-file-name) + (eq minibuffer-completing-file-name 'lambda) + (not (boundp 'minibuffer-local-filename-must-match-map))) + minibuffer-local-must-match-map + minibuffer-local-filename-must-match-map)) + nil histvar def inherit-input-method)) + ;; Use `icicle-filtered-default-value', not DEF, because `read-from-minibuffer' filters it. + (when (consp icicle-filtered-default-value) ; Emacs 23 lets DEF be a list of strings - use first. + (setq icicle-filtered-default-value (car icicle-filtered-default-value))) + (when (and (stringp val) (string= val "") icicle-filtered-default-value) + (setq val icicle-filtered-default-value)) + val)) + + +;; REPLACE ORIGINAL `completing-read' (built-in function), +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Allows for completion candidates that are lists of strings. +;; Allows for reading and returning completion candidates that are strings with properties. +;; Adds completion status indicator to minibuffer and mode-line lighter. +;; Removes *Completions* window. +;; +;; We use HIST-m@%=!$+&^*z instead of HIST, to avoid name capture by `minibuffer-history-variable's +;; value. If we didn't need to be Emacs 20-compatible, then we could employ +;; `#1=#:hist'...`#1#'...`#1' read syntax to use an uninterned symbol. +;; +(unless (fboundp 'old-completing-read) +(defalias 'old-completing-read (symbol-function 'completing-read))) + +;;;###autoload +(defun icicle-completing-read (prompt collection &optional predicate require-match + initial-input hist-m@%=!$+&^*z def inherit-input-method) + "Read string in minibuffer, with completion and cycling of completions. +Prefix completion via \\\ +`\\[icicle-prefix-word-complete]' (word) and `\\[icicle-prefix-complete]' (full). +Apropos (regexp) completion via `\\[icicle-apropos-complete]'. + +Prefix cycling of candidate completions via `\\[icicle-previous-prefix-candidate]' and \ +`\\[icicle-next-prefix-candidate]'. +Apropos cycling of candidate completions via `\\[icicle-previous-apropos-candidate]' and \ +`\\[icicle-next-apropos-candidate]'. + +Cycling of past minibuffer inputs via `\\[previous-history-element]' and \ +`\\[next-history-element]'. +Searching through input history via `\\[previous-matching-history-element]' \ +and `\\[next-matching-history-element]'. + +Case is ignored if `completion-ignore-case' is non-nil. +Position of the cursor (point) and the mark during completion cycling + is determined by `icicle-point-position-in-candidate' and + `icicle-mark-position-in-candidate', respectively. +Highlighting of the matched part of completion candidates during + cycling is determined by `icicle-match-highlight-minibuffer', + `icicle-match-highlight-Completions', and + `icicle-common-match-highlight-Completions'. + +Use `\\[icicle-minibuffer-help]' during completion for more information on completion and key +bindings in Icicle mode. + +PROMPT is a string to prompt with. It normally ends in a colon and a +space. If PROMPT has non-nil text property `icicle-fancy-candidates' +on its first character, then completion candidates can be fancy - they +can have properties. However, if all of the candidates would be +acceptable to vanilla Emacs, then PROMPT need not use property +`icicle-fancy-candidates', even for candidates that have text +properties. Property `icicle-fancy-candidates' is needed only for +candidates that require encoding and decoding to store and retrieve +properties. See the Icicles doc, section `Programming with Fancy +Candidates'. + +COLLECTION is an obarray or an alist whose elements' cars are strings. +It can also be a function that performs the completion itself. +In Emacs 22 or later, it can also be a hash table or list of strings. + +In Icicle mode, the car of an alist entry can also be a list of +strings. In this case, the completion candidate is a +multi-completion. The strings are joined pairwise with +`icicle-list-join-string' to form the completion candidate seen by the +user, which is terminated by `icicle-list-end-string'. You can use +variable `icicle-candidate-properties-alist' to control the appearance +of multi-completions in buffer *Completions*. You can use variables +`icicle-list-use-nth-parts' and `icicle-list-nth-parts-join-string' to +control the minibuffer behavior of multi-completions. See the Icicles +documentation for more information. + +PREDICATE limits completion to a subset of COLLECTION. + +See `try-completion' and `all-completions' for more details on +completion, COLLECTION, and PREDICATE. + +REQUIRE-MATCH can take any of these values: +* nil means the user can exit using any input. +* t means the user can exit only if the input is (or completes to) an + element of COLLECTION or is null. +* In Emacs 23 or later: + - `confirm' means the user can exit with any input, but if the input + is not an element of COLLECTION then confirmation is needed. + - `confirm-after-completion' is similar, except that with + non-matching input exit is allowed only just after completing. +* Anything else behaves like t, except that hitting `\\[exit-minibuffer]' does not + exit if it performs non-null completion. + +Regardless of the value of REQUIRE-MATCH, if the user input is empty, +then `completing-read' returns DEF or, if DEF is nil, an empty string. + +If option `icicle-require-match-flag' is non-nil, it overrides the +value of REQUIRE-MATCH. + +If INITIAL-INPUT is non-nil, insert it in the minibuffer initially, +with point positioned at the end. If it is (STRING . POSITION), the +initial input is STRING, but point is placed at zero-indexed position +POSITION in STRING. (This is different from `read-from-minibuffer' +and related functions, which use one-indexing for POSITION.) + +INITIAL-INPUT is considered deprecated by vanilla Emacs, but not by +Icicles. If INITIAL-INPUT is nil and DEF is non-nil, the user can use +`next-history-element' to yank DEF into the minibuffer. + +HIST, if non-nil, specifies a history list and optionally the initial +position in the list. It can be a symbol, which is the history list +variable to use, or it can be a cons cell (HISTVAR . HISTPOS). If a +cons cell, HISTVAR is the history list variable to use, and HISTPOS is +the initial position (the position in the list used by the minibuffer +history commands). For consistency, you should also specify that +element of the history as the value of INITIAL-INPUT. Positions are +counted starting from 1 at the beginning of the list. The variable +`history-length' controls the maximum length of a history list. + +DEF, if non-nil, is the default value or (Emacs 23+ only) the list of +default values. Option `icicle-default-value' controls the treatment +of the default value (or the first default value, if DEF is a list): +whether it is shown in the prompt, substituted for an empty +INITIAL-INPUT, and so on. + +If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits the +current input method and the setting of `enable-multibyte-characters'. + +Both completion candidates and DEF are filtered using these Icicles +variables: + `icicle-must-match-regexp' + `icicle-must-not-match-regexp' + `icicle-must-pass-predicate' + +Completion ignores case when `completion-ignore-case' is non-nil." + (unless (stringp icicle-initial-value) (setq icicle-initial-value "")) ; Convert nil to "". + (unless initial-input (setq initial-input icicle-initial-value)) + (if (consp initial-input) + (setq icicle-initial-value (car initial-input)) + (setq initial-input (format "%s" initial-input) ; Convert symbol to string + icicle-initial-value initial-input)) + (setq icicle-nb-of-other-cycle-candidates 0 + icicle-completions-format-internal icicle-completions-format) + + ;; Use DEF for INITIAL-INPUT also, if `icicle-default-value' says so. + (when (and def icicle-default-value (not (eq icicle-default-value t)) + (stringp initial-input) (string= "" initial-input)) + ;; Filter DEF using `icicle-filter-wo-input'. Done in `read-from-minibuffer' anyway, but we + ;; must also do it here, to reuse the correct default value for the init value. + (if (atom def) + (setq initial-input (or (icicle-filter-wo-input def) "")) ; Ensure that it is non-nil. + (let ((found nil) + (def1 def)) + (while (and (not found) def1) + (setq found (icicle-filter-wo-input (car def1)) + def1 (cdr def1))) + (setq initial-input (or found "")))) + (when (memq icicle-default-value '(insert-start preselect-start)) + (setq initial-input (cons initial-input 0)))) + + ;; Override REQUIRE-MATCH as needed. + (setq require-match (case icicle-require-match-flag + ((nil) require-match) + (no-match-required nil) + (partial-match-ok t) + (full-match-required 'full-match-required)) + icicle-require-match-p require-match) + (icicle-highlight-lighter) + (let* ((minibuffer-history-variable minibuffer-history-variable) + ;; $$$$$$$$$$ `minibuffer-completion-table' binding needed? `setq' in `*-lisp-vanilla-*'. + (minibuffer-allow-text-properties t) ; This is nil for completion in vanilla Emacs. + (minibuffer-completion-table collection) + (icicle-fancy-cands-internal-p (or icicle-whole-candidate-as-text-prop-p + icicle-fancy-candidates-p + (get-text-property + 0 'icicle-fancy-candidates prompt))) + result) + ;; Transform a cons collection to what is expected for `minibuffer-completion-table'. + (when icicle-fancy-cands-internal-p + (let ((c+p (icicle-mctize-all collection predicate))) + (setq collection (car c+p) ; After banalizing for vanilla Emacs. + predicate (cadr c+p)))) + ;; $$$$$$$$$$$$$ (setq minibuffer-completion-table collection) + (cond ((not icicle-mode) + (setq result (icicle-lisp-vanilla-completing-read + prompt collection predicate require-match initial-input + hist-m@%=!$+&^*z def inherit-input-method))) + (t + (let ((minibuffer-prompt-properties + (and (boundp 'minibuffer-prompt-properties) ; Emacs 21+ only + (icicle-remove-property 'face minibuffer-prompt-properties))) + (minibuffer-completing-file-name + ;; Can't be file-name completion unless it's a function. + (and (functionp collection) minibuffer-completing-file-name))) + (when (< emacs-major-version 21) + (setq prompt (concat (and icicle-candidate-action-fn "+ ") prompt))) + (setq result (catch 'icicle-read-top + (icicle-lisp-vanilla-completing-read + prompt collection predicate require-match initial-input + hist-m@%=!$+&^*z def inherit-input-method))) + (icicle-unpropertize result)))) + ;; HACK. Without this, when REQUIRE-MATCH is non-nil, *Completions* window + ;; does not disappear. + (when require-match (icicle-remove-Completions-window)) + result)) + +(defun icicle-mctize-all (coll pred) + "Transform collection COLL and predicate PRED for vanilla completion. +COLL is an Icicles collection argument acceptable to + `icicle-completing-read' but not necessarily to vanilla + `completing-read': COLL can contain multi-completions. +PRED is a predicate. + +Returns a new two-element list of the new collection and predicate: +\(MCT NEWPRED), where MCT is COLL transformed and NEWPRED is PRED +transformed. MCT is a collection suitable for vanilla +`completing-read'. + +COLL is transformed to MCT by applying `icicle-mctized-full-candidate' +to each of its elements. + +If PRED is non-nil, then NEWPRED is a predicate that applies PRED to +the cdr of an MCT entry. If PRED is nil, so is NEWPRED." + (when (consp coll) + ;; Copy alist collection COLL, so we don't change the original alist in any way. + ;; Change each entry in COLL using `icicle-mctized-full-candidate'. + (setq coll (mapcar #'icicle-mctized-full-candidate coll)) + ;; Convert non-nil PRED so that, for a cons entry with a string car, PRED uses the cdr + ;; (which is the original entry) instead. + (and pred (lexical-let ((new-pred pred)) + (setq pred (lambda (x) + (funcall new-pred (if (and (consp x) (stringp (car x))) (cdr x) x))))))) + (list coll pred)) + +(defun icicle-mctized-full-candidate (cand) + "Return MCT candidate that corresponds to full candidate CAND. +See the source code for details." + ;; If neither `icicle-fancy-cands-internal-p' nor `icicle-whole-candidate-as-text-prop-p' is + ;; non-nil, then just return CAND. + ;; Otherwise: + ;; If CAND is a string A, we change it to (A) and then treat that (as follows). + ;; If CAND is (A . B), where A is a string, then we change it to (S A . B), where S is a copy + ;; of A. This way, the cdr of each MCT candidate is the original alist candidate, (A . B). + ;; If CAND is (M . B), where M is a multi-completion (X Y Z...), then we change it to + ;; (M' A . B), where M' is the display string for the multi-completion M. + ;; Otherwise, we make no change to CAND. + ;; If `icicle-whole-candidate-as-text-prop-p' is non-nil and the MCT candidate is a cons (X A . B) + ;; with a string car X, then we put the cdr, (A . B), as a text property on the car X, so + ;; we can get back the original (A . B) from the car. + (if (not (or icicle-fancy-cands-internal-p icicle-whole-candidate-as-text-prop-p)) + cand + (let ((new-cand + (cond ((and (consp cand) ; Multi-completion: (("aa" "bb") . cc) -> + (consp (car cand)) ; ("aa^G\nbb\n\n" ("aa" "bb") . cc) + (stringp (caar cand))) + (when (string-match "\n" icicle-list-join-string) + (setq icicle-completions-format-internal 'horizontal)) ; Override + (cons (concat (mapconcat #'identity (car cand) icicle-list-join-string) + icicle-list-end-string) + cand)) + ((and (consp cand) (stringp (car cand))) ; ("aa" . cc) -> ("aa" "aa" . cc) + (cons (copy-sequence (car cand)) cand)) + ((stringp cand) ; "aa" -> ("aa" "aa") + (list (copy-sequence cand) cand)) + (t ; Anything else: (aa), aa -> no change + cand)))) + ;; Put original alist candidates on display candidates (strings), as a text property. + (when (and icicle-whole-candidate-as-text-prop-p (consp new-cand) (stringp (car new-cand))) + (icicle-put-whole-cand-prop new-cand)) + new-cand))) + +(defun icicle-put-whole-cand-prop (cand) + "Put cdr of CAND on its car, as text property `icicle-whole-candidate'. +This has no side effects. +Returns a new propertized string corresponding to (car CAND)." + (let ((text-cand (copy-sequence (car cand)))) + (put-text-property 0 (length text-cand) 'icicle-whole-candidate (cdr cand) text-cand) + (setcar cand text-cand) + text-cand)) + +(defun icicle-mctized-display-candidate (cand) + "Return MCT candidate that corresponds to display candidate CAND." + (let ((full-cand (or (funcall icicle-get-alist-candidate-function cand) (list cand)))) + (cons cand full-cand))) + +;;;###autoload +(defun icicle-read-file-name (prompt &optional dir default-filename + require-match initial-input predicate) + "Read file name, prompting with PROMPT and completing in directory DIR. +Value is not expanded---you must call `expand-file-name' yourself. +DIR should be an absolute directory name. It defaults to the value of + `default-directory'. +Default the name to DEFAULT-FILENAME if user exits the minibuffer with +the same non-empty string that was inserted by this function. + (If DEFAULT-FILENAME is omitted, the visited file name is used, + but if INITIAL-INPUT is specified, that combined with DIR is used.) +If the user exits with an empty minibuffer, this function returns +an empty string. (This can only happen if the user erased the +pre-inserted contents or if `insert-default-directory' is nil.) +Fourth arg REQUIRE-MATCH non-nil means require existing file's name. + Non-nil and non-t means also require confirmation after completion. +Fifth arg INITIAL-INPUT specifies text to start with. +If optional sixth arg PREDICATE is non-nil, possible completions and + the resulting file name must satisfy `(funcall predicate NAME)'. + This argument is only available starting with Emacs 22. + +Both completion candidates and DEFAULT-FILENAME are filtered using +these Icicles variables: + `icicle-must-match-regexp' + `icicle-must-not-match-regexp' + `icicle-must-pass-predicate' + +Directory names are highlighted in *Completions* using face +`icicle-special-candidate'. + +If option `icicle-require-match-flag' is non-nil, it overrides the +value of REQUIRE-MATCH. + +Cycling into subdirectories is determined by option +`icicle-cycle-into-subdirs-flag'. Case is ignored if +`read-file-name-completion-ignore-case' is non-nil. See also +`read-file-name-function'. + +If option `icicle-add-proxy-candidates-flag' is non-nil, then the +following proxy file-name candidates are included. (This inclusion +can be toggled at any time from the minibuffer, using `C-M-_'.) + +* `*mouse-2 file name*' - Click `mouse-2' on a file name to choose it. +* `*point file name*' - Use the file name at point (cursor). +* Single-quoted file-name variables - Use the variable's value. + +Candidates `*mouse-2 file name*' and `*point file name*' are available +only if library `ffap.el' can be loaded. A file-name variable has +custom type `file' or (file :must-match t). + +If this command was invoked with the mouse, use a file dialog box if +`use-dialog-box' is non-nil, and the window system or X toolkit in use +provides a file dialog box. + +See also `read-file-name-completion-ignore-case' (Emacs version > 21) +and `read-file-name-function'." + (unwind-protect + (let* ((ffap-available-p (or (require 'ffap- nil t) (require 'ffap nil t))) + ;; The next four prevent slowing down `ffap-guesser'. + (ffap-alist nil) (ffap-machine-p-known 'accept) + (ffap-url-regexp nil) (ffap-shell-prompt-regexp nil) + (fap + (if (and (eq major-mode 'dired-mode) (fboundp 'dired-get-file-for-visit)) + (condition-case nil + (abbreviate-file-name (dired-get-file-for-visit)) + (error nil)) + (and ffap-available-p (ffap-guesser)))) + (mouse-file "*mouse-2 file name*") + (icicle-special-candidate-regexp (or icicle-special-candidate-regexp ".+/$")) + (icicle-proxy-candidates + (append + (and icicle-add-proxy-candidates-flag + (append (and fap (list "*point file name*")) + (and ffap-available-p (list mouse-file)) + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) + (icicle-var-is-of-type-p + cand '(file (file :must-match t)))) + (push (concat "'" (symbol-name cand) "'") ipc)))) + ipc))) + icicle-proxy-candidates)) + (minibuffer-completing-file-name t) + result) + + ;; ;; $$$$$$ Does Emacs 23+ need explicit directory? If so, add these three lines + ;; (unless dir (setq dir default-directory)) + ;; (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) + ;; (setq dir (abbreviate-file-name dir)) ; Use `~' for home directory. + + (setq result (icicle-read-file-name-1 prompt dir default-filename + require-match initial-input predicate)) + (when ffap-available-p + (cond ((save-match-data (string-match "*point file name\\*$" result)) + (setq result fap)) + ((save-match-data (string-match "*mouse-2 file name\\*$" result)) + (setq result + (progn (let ((e (read-event "Click `mouse-2' on file name"))) + (read-event) ; Get rid of mouse up event. + (save-excursion + (mouse-set-point e) + (if (and (eq major-mode 'dired-mode) + (fboundp 'dired-get-file-for-visit)) ; In `dired+.el'. + (condition-case nil ; E.g. error: not on file line (ignore) + (abbreviate-file-name (dired-get-file-for-visit)) + (error "No such file")) + (or (ffap-guesser) (error "No such file")))))))))) + (icicle-unpropertize result) + (let* ((temp (member (file-name-nondirectory result) icicle-proxy-candidates)) + (symb (and temp (intern (substring (car temp) 1 (1- (length (car temp)))))))) + (when (and symb (boundp symb)) (setq result (symbol-value symb)))) + result) + (setq icicle-proxy-candidates ()))) + +;;;###autoload +(defun icicle-read-file-name-1 (prompt &optional dir default-filename + require-match initial-input predicate) + "Helper function for `icicle-read-file-name'." + (setq icicle-nb-of-other-cycle-candidates 0 + icicle-initial-value (or initial-input (if (stringp icicle-initial-value) + icicle-initial-value + ""))) + (icicle-fix-default-directory) ; Make sure there are no backslashes in it. + (unless (string= "" icicle-initial-value) (setq initial-input icicle-initial-value)) + + ;; Use DEFAULT-FILENAME for INITIAL-INPUT also, if `icicle-default-value' says so. + ;; But if so, remove the directory part first. + ;; Note that if DEFAULT-FILENAME is null, then we let INITIAL-INPUT remain null too. + (when (and default-filename icicle-default-value (not (eq icicle-default-value t)) + ;; We don't use the same test as for `completing-read': + ;; (stringp initial-input) (string= "" initial-input)) + (string= "" icicle-initial-value)) + ;; Filter DEFAULT-FILENAME using `icicle-filter-wo-input'. Done in `read-from-minibuffer' + ;; anyway, but we must also do it here, to reuse the correct default value for the init value. + (if (atom default-filename) + (setq initial-input (icicle-filter-wo-input (file-name-nondirectory default-filename))) + (let ((found nil) + (def1 default-filename)) + (while (and (not found) def1) + (setq found (icicle-filter-wo-input (file-name-nondirectory (car def1))) + def1 (cdr def1))) + (setq initial-input (or found ""))))) + + ;; Override REQUIRE-MATCH as needed. + (setq require-match (case icicle-require-match-flag + ((nil) require-match) + (no-match-required nil) + (partial-match-ok t) + (full-match-required 'full-match-required)) + icicle-require-match-p require-match) + (icicle-highlight-lighter) + (let ((read-file-name-function nil) + (minibuffer-history-variable minibuffer-history-variable) + result) + (let ((minibuffer-prompt-properties + (and (boundp 'minibuffer-prompt-properties) ; Emacs 21+ only + (icicle-remove-property 'face minibuffer-prompt-properties)))) + (when (< emacs-major-version 21) + (setq prompt (concat (and icicle-candidate-action-fn "+ ") prompt))) + (condition-case nil ; If Emacs 22+, use predicate arg. + (setq result + (catch 'icicle-read-top + (funcall (or icicle-old-read-file-name-fn 'read-file-name) prompt dir + default-filename require-match initial-input predicate))) + (wrong-number-of-arguments + (setq result (catch 'icicle-read-top + (funcall (or icicle-old-read-file-name-fn 'read-file-name) prompt dir + default-filename require-match initial-input)))))) + ;; HACK. Without this, when REQUIRE-MATCH is non-nil, *Completions* window + ;; does not disappear. + (when require-match (icicle-remove-Completions-window)) + result)) + +(defun icicle-fix-default-directory () + "Convert backslashes in `default-directory' to slashes." + ;; This is a hack. If you do `C-x 4 f' from a standalone minibuffer + ;; frame, `default-directory' on MS Windows has this form: + ;; `C:\some-dir/'. There is a backslash character in the string. This + ;; is not a problem for standard Emacs, but it is a problem for Icicles, + ;; because we interpret backslashes using regexp syntax - they are not + ;; file separators for Icicles. So, we call `substitute-in-file-name' to + ;; change all backslashes in `default-directory' to slashes. This + ;; shouldn't hurt, because `default-directory' is an absolute directory + ;; name - it doesn't contain environment variables. For example, we + ;; convert `C:\some-dir/' to `c:/some-directory/'." + (setq default-directory (icicle-abbreviate-or-expand-file-name + (substitute-in-file-name default-directory)))) + +(defun icicle-remove-property (prop plist) + "Remove property PROP from property-list PLIST, non-destructively. +Returns the modified copy of PLIST." + (let ((cpy plist) + (result ())) + (while cpy + (unless (eq prop (car cpy)) (setq result `(,(cadr cpy) ,(car cpy) ,@result))) + (setq cpy (cddr cpy))) + (nreverse result))) + + +;; REPLACE ORIGINAL `read-from-minibuffer' (built-in function), +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Respect `icicle-default-value'. +;; +;; We use HIST-m@%=!$+&^*z instead of HIST, to avoid name capture by `minibuffer-history-variable's +;; value. If we didn't need to be Emacs 20-compatible, then we could employ +;; `#1=#:hist'...`#1#'...`#1' read syntax to use an uninterned symbol. +;; +(unless (fboundp 'old-read-from-minibuffer) +(defalias 'old-read-from-minibuffer (symbol-function 'read-from-minibuffer))) + +;;;###autoload +(defun icicle-read-from-minibuffer (prompt &optional initial-contents keymap read + hist-m@%=!$+&^*z default-value inherit-input-method) + "Read a string from the minibuffer, prompting with string PROMPT. +The optional second arg INITIAL-CONTENTS is an alternative to + DEFAULT-VALUE. Vanilla Emacs considers it to be obsolete, but + Icicles does not. It is discussed in more detail below. +Third arg KEYMAP is a keymap to use while reading; + if omitted or nil, the default is `minibuffer-local-map'. +If fourth arg READ is non-nil, then interpret the result as a Lisp object + and return that object: + in other words, do `(car (read-from-string INPUT-STRING))' +Fifth arg HIST, if non-nil, specifies a history list and optionally + the initial position in the list. It can be a symbol, which is the + history list variable to use, or it can be a cons cell + (HISTVAR . HISTPOS). In that case, HISTVAR is the history list variable + to use, and HISTPOS is the initial position for use by the minibuffer + history commands. For consistency, you should also specify that + element of the history as the value of INITIAL-CONTENTS. Positions + are counted starting from 1 at the beginning of the list. +Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available + for history commands; but, unless READ is non-nil, `read-from-minibuffer' + does NOT return DEFAULT-VALUE if the user enters empty input! It returns + the empty string. DEFAULT-VALUE can be a string or a list of strings. + These become the minibuffer's future history, available using `M-n'. +Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits + the current input method and the setting of `enable-multibyte-characters'. +Eighth arg KEEP-ALL, if non-nil, says to put all inputs in the history list, + even empty or duplicate inputs. This is available starting with Emacs 22. +If the variable `minibuffer-allow-text-properties' is non-nil, + then the string which is returned includes whatever text properties + were present in the minibuffer. Otherwise the value has no text properties. + +Option `icicle-default-value' controls how the default value, +DEFAULT-VALUE, is treated. + +The remainder of this documentation string describes the +INITIAL-CONTENTS argument in more detail. If non-nil, +INITIAL-CONTENTS is a string to be inserted into the minibuffer before +reading input. Normally, point is put at the end of that string. +However, if INITIAL-CONTENTS is (STRING . POSITION), the initial input +is STRING, but point is placed at one-indexed position POSITION in the +minibuffer. Any integer value less than or equal to one puts point at +the beginning of the string. *Note* that this behavior differs from +the way such arguments are used in `completing-read' and some related +functions, which use zero-indexing for POSITION." + (unless initial-contents (setq initial-contents "")) + + ;; Filter DEFAULT-VALUE using `icicle-filter-wo-input'. + (when default-value + (setq default-value + (if (atom default-value) + (icicle-filter-wo-input default-value) + (delq nil (mapcar #'icicle-filter-wo-input default-value))))) ; Emacs 23 accepts a list. + ;; Save new default value for caller (e.g. `icicle-lisp-vanilla-completing-read'. + (setq icicle-filtered-default-value default-value) + + ;; If a list of strings, use the first one for prompt etc. + (let ((def-value (if (consp default-value) (car default-value) default-value))) + ;; Maybe use DEFAULT-VALUE for INITIAL-CONTENTS also. + (when (and icicle-default-value (not (eq icicle-default-value t)) + def-value (stringp initial-contents) (string= "" initial-contents)) + (setq initial-contents (if (integerp def-value) ; Character + (char-to-string def-value) + def-value))) + (when (and def-value (eq icicle-default-value t)) ; Add DEFAULT-VALUE to PROMPT. + (when (icicle-file-name-input-p) (setq def-value (file-name-nondirectory def-value))) + (setq prompt (if (string-match "\\(.*\\)\\(: *\\)$" prompt) + (concat (substring prompt (match-beginning 1) (match-end 1)) " (" def-value + ")" (substring prompt (match-beginning 2) (match-end 2))) + (concat prompt def-value))))) + (old-read-from-minibuffer + prompt initial-contents keymap read hist-m@%=!$+&^*z default-value inherit-input-method)) + + +;; REPLACE ORIGINAL `minibuffer-default-add-completions' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Respect Icicles global filters, so you don't see, as defaults, candidates that were filtered out. +;; +(when (fboundp 'minibuffer-default-add-completions) ; Emacs 23+. + (unless (fboundp 'old-minibuffer-default-add-completions) +(defalias 'old-minibuffer-default-add-completions + (symbol-function 'minibuffer-default-add-completions))) + + ;; Use this as `minibuffer-default-add-function'. + (defun icicle-minibuffer-default-add-completions () + "Like `old-minibuffer-default-add-completions', but respect global filters." + (let ((def minibuffer-default) + (all (all-completions "" minibuffer-completion-table minibuffer-completion-predicate t))) + (setq all (icicle-remove-if-not (lambda (cand) + (let ((case-fold-search completion-ignore-case)) + (icicle-filter-wo-input cand))) + all)) + (if (listp def) + (append def all) + (cons def (delete def all)))))) + + +;; REPLACE ORIGINAL `read-number' defined in `subr.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; 1. Let user enter a numeric variable name, for its value. Allow completion. +;; 2. Allow for error reading input. +;; 3. Call `ding' if not a number, and don't redisplay for `sit-for'. +;; +(when (fboundp 'read-number) ; Emacs 22+ + (unless (fboundp 'old-read-number) +(defalias 'old-read-number (symbol-function 'read-number))) + + (defun icicle-read-number (prompt &optional default) + "Read a number in the minibuffer, prompting with PROMPT (a string). +DEFAULT is returned if the user hits `RET' without typing anything. + +If option `icicle-add-proxy-candidates-flag' is non-nil, the user can +also enter the name of a numeric variable - its value is returned. +Completion is available for this. A numeric variable is a variable +whose value or whose custom type is compatible with type `integer', +`number', or `float'." + (unwind-protect + (let ((num nil) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) + (icicle-var-is-of-type-p cand (if (>= emacs-major-version 22) + '(number integer float) + '(number integer)))) + (push (symbol-name cand) ipc)))) + ipc))) + + ;; Emacs 23 allows DEFAULT to be a list of strings - use the first one for prompt etc. + (default1 (if (consp default) (car default) default))) + (when default + (save-match-data + (setq prompt (if (string-match "\\(\\):[ \t]*\\'" prompt) + (replace-match (format " (default %s)" default1) t t prompt 1) + (replace-regexp-in-string + "[ \t]*\\'" (format " (default %s) " default1) prompt t t))))) + (when icicle-proxy-candidates (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (while (progn + (let ((str (completing-read prompt nil nil nil nil nil + (if (consp default) + (mapcar #'number-to-string default) + (and default1 (number-to-string default1))))) + temp) + (setq num (cond ((zerop (length str)) default1) + ((setq temp (member str icicle-proxy-candidates)) + (symbol-value (intern (car temp)))) + ((stringp str) (condition-case nil (read str) (error nil)))))) + (unless (numberp num) + (icicle-ding) (message "Not a number. Try again.") (sit-for 0.5 nil t) + t))) + num) + (setq icicle-proxy-candidates ())))) + +;; Can't replace standard `read-char-exclusive' with this, because, starting with Emacs 22, it has +;; an optional SECONDS arg that cannot be simulated using `completing-read'. +(defun icicle-read-char-exclusive (prompt &optional inherit-input-method) + "Read a character in the minibuffer, prompting with PROMPT (a string). +It is returned as a number. +Optional arg INHERIT-INPUT-METHOD is as for `completing-read'. + +If option `icicle-add-proxy-candidates-flag' is non-nil, the user can +also enter the name of a character variable - its value is returned. +Completion is available for this. A character variable is a variable +whose value is compatible with type `character'." + (unwind-protect + (let* ((char nil) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (let ((ipc ())) + (mapatoms (lambda (cand) + (when (and (user-variable-p cand) + (icicle-var-is-of-type-p cand '(character))) + (push (symbol-name cand) ipc)))) + ipc))) + str temp) + (when icicle-proxy-candidates (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (setq str (completing-read prompt nil nil nil nil nil nil inherit-input-method) + char (cond ((zerop (length str)) (error "No character read")) + ((setq temp (member str icicle-proxy-candidates)) + (symbol-value (intern (car temp)))) + ((stringp str) (condition-case nil + (progn (when (> (length str) 1) + (message "First char is used: `%c'" + (elt str 0)) (sit-for 2)) + (elt str 0)) + (error nil))))) + char) + (setq icicle-proxy-candidates ()))) + +(defun icicle-read-string-completing (prompt &optional default pred hist) + "Read a string in the minibuffer, prompting with PROMPT (a string). +If the user hits `RET' without typing anything, return DEFAULT, or \"\" + if DEFAULT is nil. +PRED is a predicate that filters the variables available for completion. +HIST is the history list to use, as for `completing-read'. + +If option `icicle-add-proxy-candidates-flag' is non-nil, the user can +also enter the name of a string variable - its value is returned. +Completion is available for this. A string variable is a variable +whose value or whose custom type is compatible with type `string'." + (unwind-protect + (let ((strg nil) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (let ((ipc ())) + (mapatoms (lambda (cand) + (when (and (user-variable-p cand) + (icicle-var-is-of-type-p cand '(string color regexp))) + (push (symbol-name cand) ipc)))) + ipc))) + ;; Emacs 23 allows DEFAULT to be a list of strings - use the first one for prompt etc. + (default1 (if (consp default) (car default) default))) + (when default + (save-match-data + (setq prompt (if (string-match "\\(\\):[ \t]*\\'" prompt) + (replace-match (format " (default %s)" default1) t t prompt 1) + (replace-regexp-in-string + "[ \t]*\\'" (format " (default %s) " default1) prompt t t))))) + (when icicle-proxy-candidates (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (let ((strg-read (completing-read prompt nil pred nil + (and (consp hist) + (nth (cdr hist) (symbol-value (car hist)))) + hist default)) + temp) + (setq strg (cond ((zerop (length strg-read)) (or default1 "")) + ((setq temp (member strg-read icicle-proxy-candidates)) + (setq temp (symbol-value (intern (car temp)))) + (cond ((and (symbolp hist) (consp (symbol-value hist))) + (setcar (symbol-value hist) temp)) + ((and (consp hist) (symbolp (car hist)) + (consp (symbol-value (car hist)))) + (setcar (symbol-value (car hist)) temp))) + temp) + (t strg-read)))) + strg) + (setq icicle-proxy-candidates ()))) + +;; Same as `help-var-is-of-type-p'. +(defun icicle-var-is-of-type-p (variable types &optional mode) + "Return non-nil if VARIABLE satisfies one of the custom types in TYPES. +TYPES is a list of `defcustom' type sexps or a list of regexp strings. +TYPES are matched, in order, against VARIABLE's type definition or +VARIABLE's current value, until one is satisfied or all are tried. + +If TYPES is a list of regexps, then each is regexp-matched against +VARIABLE's custom type. + +Otherwise, TYPES is a list of type sexps, each of which is a +definition acceptable for `defcustom' :type or the first symbol of +such a definition (e.g. `choice'). In this case, two kinds of type +comparison are possible: + +1. VARIABLE's custom type, or its first symbol, is matched using + `equal' against each type in TYPES. + +2. VARIABLE's current value is checked against each type in TYPES to + see if it satisfies one of them. In this case, VARIABLE's own type + is not used; VARIABLE might not even be typed - it could be a + variable not defined using `defcustom'. + +For any of the comparisons against VARIABLE's type, either that type +can be checked directly or its supertypes (inherited types) can also +be checked. + +These different type-checking possibilities depend on the value of +argument MODE, as follows, and they determine the meaning of the +returned value: + +`direct': VARIABLE's type matches a member of list TYPES +`inherit': VARIABLE's type matches or is a subtype of a TYPES member +`value': VARIABLE is bound, and its value satisfies a type in TYPES +`inherit-or-value': `inherit' or `value', tested in that order +`direct-or-value': `direct' or `value', tested in that order +anything else (default): `inherit' + +VARIABLE's current value cannot satisfy a regexp type: it is +impossible to know which concrete types a value must match." + (case mode + ((nil inherit) (icicle-var-inherits-type-p variable types)) + (inherit-or-value (or (icicle-var-inherits-type-p variable types) + (icicle-var-val-satisfies-type-p variable types))) + (value (icicle-var-val-satisfies-type-p variable types)) + (direct (icicle-var-matches-type-p variable types)) + (direct-or-value (or (member (get variable 'custom-type) types) + (icicle-var-val-satisfies-type-p variable types))) + (otherwise (icicle-var-inherits-type-p variable types)))) + +(defun icicle-var-matches-type-p (variable types) + "VARIABLE's type matches a member of TYPES." + (catch 'icicle-type-matches + (let ((var-type (get variable 'custom-type))) + (dolist (type types) + (when (if (stringp type) + (save-match-data (string-match type (format "%s" (format "%S" var-type)))) + (equal var-type type)) + (throw 'icicle-type-matches t)))) + nil)) + +(defun icicle-var-inherits-type-p (variable types) + "VARIABLE's type matches or is a subtype of a member of list TYPES." + (catch 'icicle-type-inherits + (let ((var-type (get variable 'custom-type))) + (dolist (type types) + (while var-type + (when (or (and (stringp type) + (save-match-data (string-match type (format "%s" (format "%S" var-type))))) + (equal type var-type)) + (throw 'icicle-type-inherits t)) + (when (consp var-type) (setq var-type (car var-type))) + (when (or (and (stringp type) + (save-match-data (string-match type (format "%s" (format "%S" var-type))))) + (equal type var-type)) + (throw 'icicle-type-inherits t)) + (setq var-type (car (get var-type 'widget-type)))) + (setq var-type (get variable 'custom-type)))) + nil)) + +(defun icicle-var-val-satisfies-type-p (variable types) + "VARIABLE is bound, and its value satisfies a type in the list TYPES." + (and (boundp variable) + (let ((val (symbol-value variable))) + (and (widget-convert (get variable 'custom-type)) + (icicle-value-satisfies-type-p val types))))) + +(defun icicle-value-satisfies-type-p (value types) + "Return non-nil if VALUE satisfies a type in the list TYPES." + (catch 'icicle-type-value-satisfies + (dolist (type types) + (unless (stringp type) ; Skip, for regexp type. + (setq type (widget-convert type)) + ;; Satisfies if either :match or :validate. + (when (condition-case nil + (progn (when (and (widget-get type :match) (widget-apply type :match value)) + (throw 'icicle-type-value-satisfies t)) + (when (and (widget-get type :validate) + (progn (widget-put type :value value) + (not (widget-apply type :validate)))) + (throw 'icicle-type-value-satisfies t))) + (error nil)) + (throw 'icicle-type-value-satisfies t)))) + nil)) + +(defun icicle-custom-type (variable) + "Returns the `defcustom' type of VARIABLE. +Returns nil if VARIABLE is not a user option. + +Note: If the library that defines VARIABLE has not yet been loaded, +then `icicle-custom-type' loads it. Be sure you want to do that +before you call this function." + (and (custom-variable-p variable) + (or (get variable 'custom-type) + (progn (custom-load-symbol variable) (get variable 'custom-type))))) + + +;; REPLACE ORIGINAL `read-string' (built-in function), +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Respect `icicle-default-value' (via use of `read-from-minibuffer'). +;; +;; We use HIST-m@%=!$+&^*z instead of HISTORY, to avoid name capture by `minibuffer-history-variable's +;; value. If we didn't need to be Emacs 20-compatible, then we could employ +;; `#1=#:hist'...`#1#'...`#1' read syntax to use an uninterned symbol. +;; +(unless (fboundp 'old-read-string) +(defalias 'old-read-string (symbol-function 'read-string))) + +;;;###autoload +(defun icicle-read-string (prompt &optional initial-input hist-m@%=!$+&^*z + default-value inherit-input-method) + "Read a string from the minibuffer, prompting with string PROMPT. +If non-nil, second arg INITIAL-INPUT is a string to insert before reading. + Vanilla Emacs considers it to be obsolete, but Icicles does not. It + behaves like argument INITIAL-CONTENTS in `read-from-minibuffer'. + See the documentation string of `read-from-minibuffer' for details. +The third arg HISTORY, if non-nil, specifies a history list + and optionally the initial position in the list. + See `read-from-minibuffer' for details of HISTORY argument. +Fourth arg DEFAULT-VALUE is the default value. If non-nil, it is used + for history commands, and as the value to return if the user enters + the empty string. +Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits + the current input method and the setting of enable-multibyte-characters." + (let ((value (read-from-minibuffer prompt initial-input nil nil hist-m@%=!$+&^*z + default-value inherit-input-method))) + (when (and default-value (equal value "")) + (setq value (if (consp default-value) (car default-value) default-value))) + value)) + + +;; REPLACE ORIGINAL `read-face-name' in `faces.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Show face names in *Completions* with the faces they name. +;; +(unless (fboundp 'old-read-face-name) +(defalias 'old-read-face-name (symbol-function 'read-face-name))) + +;;;###autoload +(cond ((< emacs-major-version 21) + (defun icicle-read-face-name (prompt) ; Emacs 20 + "Read a face name with completion and return its face symbol. +PROMPT is the prompt. + +If option `icicle-add-proxy-candidates-flag' is non-nil, then you can +also enter the name of a face-name variable - its value is returned. +A face-name variable is a variable with custom-type `face'. + +If library `eyedropper.el' is used, then you can also choose proxy +candidate `*point face name*' to use the face at point." + (require 'eyedropper nil t) + (let ((icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1)) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (append (and (fboundp 'eyedrop-face-at-point) (list "*point face name*")) + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) (eq (get cand 'custom-type) 'face)) + (push `,(concat "'" (symbol-name cand) "'") ipc)))) + ipc)))) + face) + (setq prompt (copy-sequence prompt)) ; So we can modify it by adding property. + (put-text-property 0 1 'icicle-fancy-candidates t prompt) + (while (= (length face) 0) + (setq face (icicle-transform-multi-completion + (completing-read prompt (mapcar #'icicle-make-face-candidate (face-list)) + nil (not (stringp icicle-WYSIWYG-Completions-flag)) nil + (if (boundp 'face-name-history) + 'face-name-history + 'icicle-face-name-history))))) + (let ((proxy (car (member face icicle-proxy-candidates)))) + (cond ((save-match-data (string-match "*point face name\\*$" face)) + (eyedrop-face-at-point)) + (proxy (symbol-value (intern (substring proxy 1 (1- (length proxy)))))) + (t (intern face))))))) + ((= emacs-major-version 21) ; Emacs 21 + (defun icicle-read-face-name (prompt) + "Read a face name with completion and return its face symbol. +PROMPT is the prompt. + +If option `icicle-add-proxy-candidates-flag' is non-nil, then you can +also enter the name of a face-name variable - its value is returned. +A face-name variable is a variable with custom-type `face'. + +If library `eyedropper.el' is used, then you can also choose proxy +candidate `*point face name*' to use the face at point." + (require 'eyedropper nil t) + (let ((icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1)) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (append (and (fboundp 'eyedrop-face-at-point) (list "*point face name*")) + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) (eq (get cand 'custom-type) 'face)) + (push `,(concat "'" (symbol-name cand) "'") ipc)))) + ipc)))) + (face-list (face-list)) + (def (thing-at-point 'symbol)) + face) + (cond ((assoc def face-list) (setq prompt (concat prompt " (default " def "): "))) + (t (setq def nil + prompt (concat prompt ": ")))) + (put-text-property 0 1 'icicle-fancy-candidates t prompt) + (while (equal "" (setq face (icicle-transform-multi-completion + (completing-read + prompt (mapcar #'icicle-make-face-candidate face-list) nil + (not (stringp icicle-WYSIWYG-Completions-flag)) nil + (if (boundp 'face-name-history) + 'face-name-history + 'icicle-face-name-history) + def))))) + (let ((proxy (car (member face icicle-proxy-candidates)))) + (cond ((save-match-data (string-match "*point face name\\*$" face)) + (eyedrop-face-at-point)) + (proxy (symbol-value (intern (substring proxy 1 (1- (length proxy)))))) + (t (intern face))))))) + (t ; Emacs 22 + (defun icicle-read-face-name (prompt &optional string-describing-default multiple) + "Read a face name with completion and return its face symbol +By default, use the face(s) on the character after point. If that +character has the property `read-face-name', that overrides the `face' +property. + +PROMPT should be a string that describes what the caller will do with the face; + it should not end in a space. +STRING-DESCRIBING-DEFAULT should describe what default the caller will use if + the user just types RET; you can omit it. +If MULTIPLE is non-nil, return a list of faces (possibly only one). +Otherwise, return a single face. + +If option `icicle-add-proxy-candidates-flag' is non-nil, then you can +also enter the name of a face-name variable - its value is returned. +A face-name variable is a variable with custom-type `face'. + +If library `palette.el' or `eyedropper.el' is used, then you can also +choose proxy candidate `*point face name*' to use the face at point." + (or (require 'palette nil t) (require 'eyedropper nil t)) + (let ((faceprop (or (get-char-property (point) 'read-face-name) + (get-char-property (point) 'face))) + (aliasfaces ()) + (nonaliasfaces ()) + (icicle-proxy-candidates + (and icicle-add-proxy-candidates-flag + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) (eq (get cand 'custom-type) 'face)) + (push `,(concat "'" (symbol-name cand) "'") ipc)))) + ipc))) + faces) + ;; Undo Emacs 22 brain-dead treatment of PROMPT arg. + (when (save-match-data (string-match ": $" prompt)) + (setq prompt (substring prompt 0 -2))) + ;; Try to get a face name from the buffer. + (when (memq (intern-soft (thing-at-point 'symbol)) (face-list)) + (setq faces (list (intern-soft (thing-at-point 'symbol))))) + ;; Add the named faces that the `face' property uses. + (if (and (consp faceprop) + ;; Don't treat an attribute spec as a list of faces. + (not (keywordp (car faceprop))) + (not (memq (car faceprop) '(foreground-color background-color)))) + (dolist (f faceprop) (when (symbolp f) (push f faces))) + (when (and faceprop (symbolp faceprop)) (push faceprop faces))) + (delete-dups faces) + (cond (multiple + ;; We leave this branch as it is. Icicles does nothing special with + ;; `completing-read-multiple'. + (require 'crm) + (mapatoms (lambda (s) (when (custom-facep s) ; Build up the completion tables. + (if (get s 'face-alias) + (push (symbol-name s) aliasfaces) + (push (symbol-name s) nonaliasfaces))))) + (let* ((input (completing-read-multiple ; Read the input. + (if (or faces string-describing-default) + (format "%s (default %s): " + prompt (if faces + (mapconcat 'symbol-name faces ",") + string-describing-default)) + (format "%s: " prompt)) + ;; This lambda expression is the expansion of Emacs 22 macro + ;; (complete-in-turn nonaliasfaces aliasfaces). We expand it so + ;; this can be compiled also in Emacs < 22 to work for Emacs 22. + (lambda (string predicate mode) + (cond ((eq mode t) + (or (all-completions string nonaliasfaces predicate) + (all-completions string aliasfaces predicate))) + ((eq mode nil) + (or (try-completion string nonaliasfaces predicate) + (try-completion string aliasfaces predicate))) + (t + (or (test-completion string nonaliasfaces predicate) + (test-completion string aliasfaces predicate))))) + nil t nil (if (boundp 'face-name-history) + 'face-name-history + 'icicle-face-name-history) + (and faces (mapconcat 'symbol-name faces ",")))) + (output (cond ((or (equal input "") (equal input '(""))) ; Canonicalize. + faces) + ((stringp input) + (mapcar 'intern (split-string input ", *" t))) + ((listp input) + (mapcar 'intern input)) + (input)))) + output)) ; Return the list of faces + (t + (when (consp faces) (setq faces (list (car faces)))) + (let ((icicle-list-nth-parts-join-string ": ") + (icicle-list-join-string ": ") + (icicle-list-end-string "") + (icicle-list-use-nth-parts '(1)) + (face-list (face-list)) + (def (if faces + (mapconcat 'symbol-name faces ",") + string-describing-default)) + face) + (put-text-property 0 1 'icicle-fancy-candidates t prompt) + (while (equal "" (setq face (icicle-transform-multi-completion + (completing-read + (if def + (format "%s (default %s): " prompt def) + (format "%s: " prompt)) + (mapcar #'icicle-make-face-candidate face-list) + nil (not (stringp icicle-WYSIWYG-Completions-flag)) + nil (if (boundp 'face-name-history) + 'face-name-history + 'icicle-face-name-history) + def))))) + (let ((proxy (car (member face icicle-proxy-candidates)))) + (if proxy + (symbol-value (intern (substring proxy 1 (1- (length proxy))))) + (intern face)))))))))) + +(defun icicle-make-face-candidate (face) + "Return a completion candidate for FACE. +The value of option `icicle-WYSIWYG-Completions-flag' determines the +kind of candidate to use. + If nil, then the face name is used (a string). + + If a string, then a multi-completion candidate is used, with the face + name followed by a sample swatch using FACE on the string's text. + + If t, then the candidate is the face name itself, propertized with +FACE." + (if (stringp icicle-WYSIWYG-Completions-flag) + (let ((swatch (copy-sequence icicle-WYSIWYG-Completions-flag))) + (put-text-property 0 (length icicle-WYSIWYG-Completions-flag) 'face face swatch) + (list (list (symbol-name face) swatch))) + (let ((face-name (copy-sequence (symbol-name face)))) + (when icicle-WYSIWYG-Completions-flag + (put-text-property 0 (length face-name) 'face face face-name)) + (list face-name)))) + + +;; REPLACE ORIGINAL `face-valid-attribute-values' in `faces.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Show color names in *Completions* with the (background) colors they name. +;; This is really so that commands such as `modify-face' take advantage of colored candidates. +;; We don't bother to try the same thing for Emacs 20, but the fix (directly to `modify-face') is +;; similar and trivial. +;; +(when (fboundp 'face-valid-attribute-values) ; Emacs 21+. + (unless (fboundp 'old-face-valid-attribute-values) +(defalias 'old-face-valid-attribute-values (symbol-function 'face-valid-attribute-values))) + +;;;###autoload + (defun icicle-face-valid-attribute-values (attribute &optional frame) + "Return valid values for face attribute ATTRIBUTE. +The optional argument FRAME is used to determine available fonts +and colors. If it is nil or not specified, the selected frame is +used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value +out of a set of discrete values. Value is `integerp' if ATTRIBUTE expects +an integer value." + (let ((valid + (case attribute + (:family (if window-system + (mapcar #'(lambda (x) (cons (car x) (car x))) + (if (fboundp 'font-family-list) + (font-family-list) + (x-font-family-list))) + ;; Only one font on TTYs. + (list (cons "default" "default")))) + ((:width :weight :slant :inverse-video) + (mapcar #'(lambda (x) (cons (symbol-name x) x)) + (internal-lisp-face-attribute-values attribute))) + ((:underline :overline :strike-through :box) + (if window-system + (nconc (mapcar #'(lambda (x) (cons (symbol-name x) x)) + (internal-lisp-face-attribute-values attribute)) + (mapcar #'(lambda (c) (cons c c)) + (mapcar #'icicle-color-name-w-bg (x-defined-colors frame)))) + (mapcar #'(lambda (x) (cons (symbol-name x) x)) + (internal-lisp-face-attribute-values attribute)))) + ((:foreground :background) + (mapcar #'(lambda (c) (cons c c)) + (mapcar #'icicle-color-name-w-bg (x-defined-colors frame)))) + ((:height) 'integerp) + (:stipple (and (memq window-system '(x w32 mac)) + (mapcar #'list (apply #'nconc (mapcar (lambda (dir) + (and (file-readable-p dir) + (file-directory-p dir) + (directory-files dir))) + x-bitmap-file-path))))) + (:inherit (cons '("none" . nil) + (mapcar #'(lambda (c) (cons (symbol-name c) c)) (face-list)))) + (t + (error "Internal error"))))) + (if (and (listp valid) (not (memq attribute '(:inherit)))) + (nconc (list (cons "unspecified" 'unspecified)) valid) + valid))) + + (defun icicle-color-name-w-bg (color-name) + "Return copy of string COLOR-NAME with its background of that color. +If `hexrgb.el' is not loaded, then just return COLOR-NAME." + (if (featurep 'hexrgb) + (let ((propertized-name (copy-sequence color-name))) + (put-text-property 0 (length propertized-name) + 'face (cons 'background-color (hexrgb-color-name-to-hex color-name)) + propertized-name) + propertized-name) + color-name))) + + +;; REPLACE ORIGINAL `completing-read-multiple' stuff in `crm.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; Essentially, we just inhibit Icicles features for Icicle mode. +;; +(eval-after-load "crm" + '(progn + (when (fboundp 'crm-init-keymaps) (crm-init-keymaps)) ; Emacs 22, but not 23. + ;; Save vanilla CRM stuff as `old-' stuff. + (unless (fboundp 'old-completing-read-multiple) +(defalias 'old-completing-read-multiple (symbol-function 'completing-read-multiple))) + (defvar old-crm-local-completion-map crm-local-completion-map "Original CRM completion map.") + (defvar old-crm-local-must-match-map crm-local-must-match-map "Original CRM must-match map.") + + ;; Define CRM stuff to use in Icicle mode. Basically, just inhibit Icicles features. + (defun icicle-completing-read-multiple (prompt collection &optional predicate require-match + initial-input hist def inherit-input-method) + "Read multiple strings in the minibuffer, with completion. +By using this functionality, a user may specify multiple strings at a +single prompt, optionally using completion. + +Multiple strings are specified by separating each of the strings with +a prespecified separator character. For example, if the separator +character is a comma, the strings 'alice', 'bob', and 'eve' would be +specified as 'alice,bob,eve'. + +The default value for the separator character is the value of +`crm-default-separator' (comma). The separator character may be +changed by modifying the value of `crm-separator'. + +Contiguous strings of non-separator-characters are referred to as +'elements'. In the aforementioned example, the elements are: 'alice', +'bob', and 'eve'. + +Completion is available on a per-element basis. For example, if the +contents of the minibuffer are 'alice,bob,eve' and point is between +'l' and 'i', pressing TAB operates on the element 'alice'. + +The return value of this function is a list of the read strings. + +See the documentation for `completing-read' for details on the +arguments: PROMPT, COLLECTION, PREDICATE, REQUIRE-MATCH, +INITIAL-INPUT, HIST, DEF, and INHERIT-INPUT-METHOD." + (let ((icicle-highlight-input-completion-failure nil)) + (old-completing-read-multiple prompt collection predicate require-match + initial-input hist def inherit-input-method))) + + ;; Helper function - workaround because of a lack of multiple inheritance for keymaps. + (defun icicle-define-crm-completion-map (map) + "Make basic bindings for keymap MAP, a crm completion map." + (set-keymap-parent map minibuffer-local-completion-map) + (define-key map [remap minibuffer-complete] ; Emacs 22, 23. + (if (fboundp 'crm-complete) #'crm-complete #'crm-minibuffer-complete)) + (when (fboundp 'crm-complete-word) + (define-key map [remap minibuffer-complete-word] #'crm-complete-word)) + (when (and (boundp 'icicle-word-completion-keys) (fboundp 'crm-complete-word)) + (dolist (key icicle-word-completion-keys) (define-key map key #'crm-complete-word))) + (define-key map [remap minibuffer-completion-help] ; Emacs 22, 23. + (if (fboundp 'crm-completion-help) #'crm-completion-help #'crm-minibuffer-completion-help)) + (define-key map "?" #'crm-completion-help) ; Put back `?' as help (self-insert for Icicles). + (when (boundp 'icicle-prefix-complete-keys) ; Don't use Icicles completion. + (dolist (key icicle-prefix-complete-keys) + (define-key map key ; Emacs 22, 23. + (if (fboundp 'crm-complete) #'crm-complete #'crm-minibuffer-complete))))) + + (defvar icicle-crm-local-completion-map + (let ((map (make-sparse-keymap))) + (icicle-define-crm-completion-map map) + map) + "Local keymap for minibuffer multiple input with completion. +Analog of `minibuffer-local-completion-map'.") + + (defvar icicle-crm-local-must-match-map + (let ((map (make-sparse-keymap))) + (icicle-define-crm-completion-map map) + (define-key map [remap minibuffer-complete-and-exit] + (if (fboundp 'crm-complete-and-exit) + #'crm-complete-and-exit + #'crm-minibuffer-complete-and-exit)) + map) + "Local keymap for minibuffer multiple input with exact match completion. +Analog of `minibuffer-local-must-match-map' for crm.") + + ;; Now, toggle Icicle mode, to take into account loading `crm.el' and redefining its stuff. + (when (featurep 'icicles-mode) (icicle-toggle-icicle-mode-twice)))) + + +;; REPLACE ORIGINAL `read-shell-command' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Uses Icicles completion. +;; +(defun icicle-read-shell-command (prompt &optional initial-contents hist default-value + inherit-input-method) + "Read a shell command. +Use file-name completion, unless INITIAL-CONTENTS is non-nil. +For completion, pass args to `icicle-read-shell-command-completing'." + (if initial-contents + (if (fboundp 'old-read-shell-command) ; Emacs 23+. + (old-read-shell-command prompt initial-contents hist default-value inherit-input-method) + (error "icicle-read-shell-command: YOU SHOULD NOT SEE THIS; use`M-x icicle-send-bug-report'")) + (if (fboundp 'minibuffer-with-setup-hook) + (minibuffer-with-setup-hook + (lambda () + (set (make-local-variable 'minibuffer-default-add-function) + 'minibuffer-default-add-shell-commands)) + (icicle-read-shell-command-completing prompt initial-contents (or hist 'shell-command-history) + default-value inherit-input-method)) + (icicle-read-shell-command-completing prompt initial-contents (or hist 'shell-command-history) + default-value inherit-input-method)))) + + +;; REPLACE ORIGINAL `shell-command' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Uses Icicles completion. +;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'. +;; +(unless (fboundp 'read-shell-command) ; Emacs 23 + (defun icicle-dired-smart-shell-command (command &optional output-buffer error-buffer) + "Like `icicle-shell-command', but in the current Virtual Dired directory. +Uses Icicles completion - see `icicle-read-shell-command-completing'." + (interactive + (list (icicle-read-shell-command "Shell command: " nil nil + (cond (buffer-file-name (file-relative-name buffer-file-name)) + ((eq major-mode 'dired-mode) (dired-get-filename t t)))) + current-prefix-arg + shell-command-default-error-buffer)) + (let ((default-directory (if (fboundp 'dired-default-directory) ; Emacs 21+. + (dired-default-directory) + (default-directory)))) + (icicle-shell-command command output-buffer error-buffer)))) + + +;; REPLACE ORIGINAL `shell-command' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Uses Icicles completion. +;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'. +;; +(unless (fboundp 'read-shell-command) ; Emacs 23. + (unless (fboundp 'old-shell-command) +(defalias 'old-shell-command (symbol-function 'shell-command))) + + (defun icicle-shell-command (command &optional output-buffer error-buffer) + "Execute string COMMAND in inferior shell; display output, if any. +Uses Icicles completion - see `icicle-read-shell-command-completing'. + +With prefix argument, insert the COMMAND's output at point. + +If COMMAND ends in ampersand, execute it asynchronously. +The output appears in the buffer `*Async Shell Command*'. +That buffer is in shell mode. + +Otherwise, COMMAND is executed synchronously. The output appears in +the buffer `*Shell Command Output*'. If the output is short enough to +display in the echo area (which is determined by the variables +`resize-mini-windows' and `max-mini-window-height'), it is shown +there, but it is nonetheless available in buffer `*Shell Command +Output*' even though that buffer is not automatically displayed. + +To specify a coding system for converting non-ASCII characters +in the shell command output, use \\[universal-coding-system-argument] \ +before this command. + +Noninteractive callers can specify coding systems by binding +`coding-system-for-read' and `coding-system-for-write'. + +The optional second argument OUTPUT-BUFFER, if non-nil, +says to put the output in some other buffer. +If OUTPUT-BUFFER is a buffer or buffer name, put the output there. +If OUTPUT-BUFFER is not a buffer and not nil, +insert output in current buffer. (This cannot be done asynchronously.) +In either case, the output is inserted after point (leaving mark after it). + +If the command terminates without error, but generates output, +and you did not specify \"insert it in the current buffer\", +the output can be displayed in the echo area or in its buffer. +If the output is short enough to display in the echo area +\(determined by the variable `max-mini-window-height' if +`resize-mini-windows' is non-nil), it is shown there. +Otherwise,the buffer containing the output is displayed. + +If there is output and an error, and you did not specify \"insert it +in the current buffer\", a message about the error goes at the end +of the output. + +If there is no output, or if output is inserted in the current buffer, +then `*Shell Command Output*' is deleted. + +If the optional third argument ERROR-BUFFER is non-nil, it is a buffer +or buffer name to which to direct the command's standard error output. +If it is nil, error output is mingled with regular output. +In an interactive call, the variable `shell-command-default-error-buffer' +specifies the value of ERROR-BUFFER." + (interactive + (list (icicle-read-shell-command "Shell command: " nil nil + (and buffer-file-name (file-relative-name buffer-file-name))) + current-prefix-arg + shell-command-default-error-buffer)) + (old-shell-command command output-buffer error-buffer))) + + +;; REPLACE ORIGINAL `shell-command-on-region' defined in `simple.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Uses Icicles completion. +;; Not needed for Emacs 23+ - Icicles completion is automatic via `icicle-read-shell-command'. +;; +(unless (fboundp 'read-shell-command) ; Emacs 23. + (unless (fboundp 'old-shell-command-on-region) +(defalias 'old-shell-command-on-region (symbol-function 'shell-command-on-region))) + + (defun icicle-shell-command-on-region (start end command &optional output-buffer replace + error-buffer display-error-buffer) + "Execute string COMMAND in inferior shell with region as input. +Uses Icicles completion - see `icicle-read-shell-command-completing'. + +Normally, display any output in temp buffer `*Shell Command Output*'; +Prefix arg means replace the region with it. Return the exit code of +COMMAND. + +To specify a coding system for converting non-ASCII characters +in the input and output to the shell command, use \\[universal-coding-system-argument] +before this command. By default, the input (from the current buffer) +is encoded in the same coding system that will be used to save the file, +`buffer-file-coding-system'. If the output is going to replace the region, +then it is decoded from that same coding system. + +The noninteractive arguments are START, END, COMMAND, +OUTPUT-BUFFER, REPLACE, ERROR-BUFFER, and DISPLAY-ERROR-BUFFER. +Noninteractive callers can specify coding systems by binding +`coding-system-for-read' and `coding-system-for-write'. + +If the command generates output, the output may be displayed +in the echo area or in a buffer. +If the output is short enough to display in the echo area +\(determined by the variable `max-mini-window-height' if +`resize-mini-windows' is non-nil), it is shown there. Otherwise +it is displayed in the buffer `*Shell Command Output*'. The output +is available in that buffer in both cases. + +If there is output and an error, a message about the error +appears at the end of the output. + +If there is no output, or if output is inserted in the current buffer, +then `*Shell Command Output*' is deleted. + +If the optional fourth argument OUTPUT-BUFFER is non-nil, +that says to put the output in some other buffer. +If OUTPUT-BUFFER is a buffer or buffer name, put the output there. +If OUTPUT-BUFFER is not a buffer and not nil, +insert output in the current buffer. +In either case, the output is inserted after point (leaving mark after it). + +If REPLACE, the optional fifth argument, is non-nil, that means insert +the output in place of text from START to END, putting point and mark +around it. + +If optional sixth argument ERROR-BUFFER is non-nil, it is a buffer +or buffer name to which to direct the command's standard error output. +If it is nil, error output is mingled with regular output. +If DISPLAY-ERROR-BUFFER is non-nil, display the error buffer if there +were any errors. (This is always t, interactively.) This argument is +not available before Emacs 22. +In an interactive call, the variable `shell-command-default-error-buffer' +specifies the value of ERROR-BUFFER." + (interactive (let (string) + (unless (mark) (error "The mark is not set now, so there is no region")) + ;; Do this before calling region-beginning and region-end, in case subprocess + ;; output relocates them while we are in the minibuffer. + (setq string (icicle-read-shell-command "Shell command on region: ")) + ;; call-interactively recognizes region-beginning and region-end specially, + ;; leaving them in the history. + (list (region-beginning) (region-end) string current-prefix-arg current-prefix-arg + shell-command-default-error-buffer (= emacs-major-version 22)))) + (if (= emacs-major-version 22) ; `icicle-shell-command-on-region' not defined for Emacs 23+. + (old-shell-command-on-region start end command output-buffer replace error-buffer + display-error-buffer) + (old-shell-command-on-region start end command output-buffer replace error-buffer)))) + + +;; REPLACE ORIGINAL `dired-read-shell-command' defined in `dired-aux.el' +;; and redefined in `dired-x.el', saving it for restoration when you toggle `icicle-mode'. +;; Uses Icicles completion. +;; Uses `icicle-minibuffer-default-add-dired-shell-commands', not +;; `minibuffer-default-add-dired-shell-commands'. +;; +(defun icicle-dired-read-shell-command (prompt arg files) + "Read a shell command for FILES using file-name completion. +Uses Icicles completion - see `icicle-read-shell-command-completing'. +ARG is passed to `dired-mark-prompt' as its first arg, for the prompt. +FILES are the files for which the shell command should be appropriate." + (if (fboundp 'minibuffer-with-setup-hook) + (minibuffer-with-setup-hook + (lambda () + (set (make-local-variable 'minibuffer-default-add-function) + 'icicle-minibuffer-default-add-dired-shell-commands)) + (dired-mark-pop-up nil 'shell files 'icicle-dired-guess-shell-command + (format prompt (dired-mark-prompt arg files)) files)) + (dired-mark-pop-up nil 'shell files 'icicle-dired-guess-shell-command + (format prompt (dired-mark-prompt arg files)) files))) + +(defun icicle-dired-guess-shell-command (prompt files) + "Read a shell command for FILES using file-name completion. +Call `icicle-read-shell-command-completing', passing PROMPT and FILES." + (icicle-read-shell-command-completing prompt nil nil nil nil files)) + +;; Similar to `minibuffer-default-add-dired-shell-commands', but if Dired-X is available +;; we include also the commands from `dired-guess-default'. +;; +;; Free var here: `files' is bound in `icicle-dired-read-shell-command'. +(defun icicle-minibuffer-default-add-dired-shell-commands () + "Return a list of all commands associated with current dired files. +The commands are from `minibuffer-default-add-dired-shell-commands', +and if `dired-x.el' is used, `dired-guess-default'." + (interactive) + (let ((dired-guess-cmds (and (boundp 'files) (fboundp 'dired-guess-default) + (dired-guess-default files))) + (mailcap-cmds (and (boundp 'files) (require 'mailcap nil t) + (mailcap-file-default-commands files)))) + (when (stringp dired-guess-cmds) (setq dired-guess-cmds (list dired-guess-cmds))) + (if (listp minibuffer-default) + (append minibuffer-default dired-guess-cmds mailcap-cmds) + (cons minibuffer-default (append dired-guess-cmds mailcap-cmds))))) + +(defun icicle-read-shell-command-completing (prompt &optional initial-contents hist default-value + inherit-input-method files) + "Read a shell command using file-name completion. +FILES name some files for which the command might be appropriate. +The other arguments are the same as those for `read-from-minibuffer', +except that READ and KEYMAP are missing, and HIST defaults to +`shell-command-history'. + +Completion is lax, so you can use any shell command you want, not +just a completion candidate, and you can edit the completed input to +add options and arguments etc. + +In addition to file-name candidates, the following are combined to +produce extra completion candidates (which are indicated using face +`icicle-extra-candidates' in buffer *Completions*): + +* If you use Dired X, then the rules defined by user option + `dired-guess-shell-alist-user' and variable + `dired-guess-shell-alist-default' provide candidates appropriate for + the marked files in Dired. + +* Starting with Emacs 23, MIME-type associations provide candidates + appropriate for the marked files. + +* If option `icicle-guess-commands-in-path' is non-nil, then + executable files (or all files, if `shell-completion-execonly' is + nil) in your search path provide candidates. + +In addition, if `icicle-extra-candidates' is non-nil, its elements are +also included as extra candidates. + +Help is available for individual candidates, using `C-M-RET', +`C-M-mouse-2', and so on. For an extra candidate (that is, for a +shell command guessed to be appropriate), help is provided by the +`apropos' shell command (if available). For a file name, help shows +the file's properties." + (let* ((dired-guess-files (and files (fboundp 'dired-guess-default) + (dired-guess-default files))) + (icicle-sort-comparer 'icicle-extra-candidates-first-p) + (completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) + (insert-default-directory nil) + (icicle-extra-candidates-dir-insert-p nil) + (icicle-point-position-in-candidate 'input-end) + (icicle-candidate-help-fn (lambda (cand) + (if (member cand icicle-extra-candidates) + (shell-command + (concat "apropos " (shell-quote-argument + cand)) + "*Help*") + (icicle-describe-file cand)))) + (icicle-extra-candidates icicle-extra-candidates) + (icicle-must-match-regexp icicle-file-match-regexp) + (icicle-must-not-match-regexp icicle-file-no-match-regexp) + (icicle-must-pass-predicate icicle-file-predicate) + (icicle-transform-function 'icicle-remove-dups-if-extras) + ;; (icicle-sort-comparer (or icicle-file-sort icicle-sort-comparer)) + (icicle-require-match-flag icicle-file-require-match-flag) + (icicle-default-value ; Let user get default via `M-n', but don't insert it. + (and (memq icicle-default-value '(t nil)) icicle-default-value))) + (when (and dired-guess-files (atom dired-guess-files)) + (setq dired-guess-files (list dired-guess-files))) + ;; Add dired-guess guesses and mailcap guesses to `icicle-extra-candidates'. + (setq icicle-extra-candidates (append dired-guess-files + (and files (require 'mailcap nil t) ; Emacs 23. + (fboundp 'mailcap-file-default-commands) + (mailcap-file-default-commands files)) + icicle-extra-candidates)) + (when icicle-guess-commands-in-path ; Add commands available from user's search path. + (setq icicle-extra-candidates (append icicle-extra-candidates + (or icicle-shell-command-candidates-cache + (icicle-recompute-shell-command-candidates))))) + (when icicle-extra-candidates + (setq prompt (copy-sequence prompt)) ; So we can modify it by adding property. + (put-text-property 0 1 'icicle-fancy-candidates t prompt)) + (let ((cmd (icicle-read-file-name prompt nil default-value nil initial-contents))) + (when icicle-quote-shell-file-name-flag (setq cmd (icicle-quote-file-name-part-of-cmd cmd))) + cmd))) + +(defun icicle-quote-file-name-part-of-cmd (strg) + "Double-quote the file name that starts string STRG, for the shell. +This assumes a UNIX-style shell, for which the following characters +normally need to be escaped in file names: [ \t\n;<>&|()'\"#$]. +This is appropriate, for example, if you use Cygwin with MS Windows. + +STRG is assumed to be a shell command, possibly including arguments +and possibly ending with `&' to indicate asynchronous execution. + +The beginning of STRG is assumed to be a file name, possibly including +the characters [ \t\n;<>&|()'\"#$]. This function double-quotes the +file name only, not the rest of STRG. + +Example: If STRG is `c:/Program Files/My Dir/mycmd.exe arg1 arg2 &', +and file c:/Program Files/My Dir/mycmd.exe exists, then this returns +`\"c:/Program Files/My Dir/mycmd.exe\" arg1 arg2 &'." + (save-match-data + (if (not (string-match "[ \t\n;<>&|()'\"#$]" strg)) + strg + (let ((indx 0) + (compl "") + (filename "") + (quoted-strg strg) + prefix) + (while (and indx ; Find longest prefix that matches a file name. + (setq indx (1+ (length compl))) + (<= indx (length strg)) + (setq prefix (substring strg 0 indx)) + (setq compl (try-completion prefix 'read-file-name-internal + (if (> emacs-major-version 22) + minibuffer-completion-predicate + default-directory)))) + (when (and (<= (length compl) (length strg)) (string-match compl strg 0) + (file-exists-p compl)) + (setq filename compl))) + (if (or (string= "" filename) (not (file-exists-p filename))) + strg + (setq quoted-strg (concat "\"" filename "\"")) + (setq quoted-strg (concat quoted-strg (substring strg (length filename))))))))) + + +;; REPLACE ORIGINAL `recentf-make-menu-items' defined in `recentf.el', +;; saving it for restoration when you toggle `icicle-mode'. +;; Adds Icicles submenu to Open Recent menu. +;; +(defun icicle-recentf-make-menu-items (&optional menu) + "Make menu items from the recent list. +This is a menu filter function which ignores the MENU argument." + (setq recentf-menu-filter-commands nil) + (let* ((recentf-menu-shortcuts 0) + (file-items (condition-case err + (mapcar 'recentf-make-menu-item + (recentf-apply-menu-filter recentf-menu-filter + (recentf-menu-elements + recentf-max-menu-items))) + (error + (message "recentf update menu failed: %s" (error-message-string err)))))) + (append (or file-items '(["No files" t :help "No recent file to open" :active nil])) + (if recentf-menu-open-all-flag + '(["All..." recentf-open-files :help "Open recent files through a dialog" :active t]) + (and (< recentf-max-menu-items (length recentf-list)) ; `recentf-list' is free here. + '(["More..." recentf-open-more-files + :help "Open files not in the menu through a dialog" :active t]))) + (and recentf-menu-filter-commands '("---")) recentf-menu-filter-commands + (and recentf-menu-items-for-commands '("---")) recentf-menu-items-for-commands + (and icicle-mode + '(("Icicles" + ["+ Open Recent File..." icicle-recent-file] + ["+ Open Recent File (Other Window)..." icicle-recent-file-other-window] + ["+ Remove from Recent Files List..." icicle-remove-file-from-recentf-list])))))) + +;;(@* "Icicles functions - completion display (not cycling)") + +;;; Icicles functions - completion display (not cycling) ------------- + +(defun icicle-display-candidates-in-Completions (&optional reverse-p no-display-p) + "Refresh the current set of completion candidates in *Completions*. +REVERSE-P non-nil means display the candidates in reverse order. +NO-DISPLAY-P non-nil means do not display the candidates; just + recompute them. If the value is `no-msg', then do not show a + minibuffer message indicating that candidates were updated." + ;;$$ ;; Pred is special if `minibuffer-completion-table' is a function. + ;; (when (and (not (functionp minibuffer-completion-table)) + ;; (functionp minibuffer-completion-predicate)) + ;; (setq icicle-completion-candidates + ;; (icicle-remove-if-not + ;; (lambda (cand) + ;; (funcall minibuffer-completion-predicate + ;; (if (arrayp minibuffer-completion-table) (intern cand) (list cand)))) + ;; icicle-completion-candidates))) + + ;; $$$ (case icicle-incremental-completion-flag + ;; ((t always) (setq icicle-incremental-completion-p 'always)) + ;; ((nil) (setq icicle-incremental-completion-p nil))) + + ;; $$$$$ (unless (input-pending-p) ; Do nothing if user hit a key. + + ;; Upgrade `icicle-incremental-completion-p' if we are redisplaying, so that completions will + ;; be updated by `icicle-call-then-update-Completions' when you edit. + (setq icicle-incremental-completion-p icicle-incremental-completion-flag) + (when (and (eq t icicle-incremental-completion-p) (get-buffer-window "*Completions*" 0)) + (setq icicle-incremental-completion-p 'always)) + + (let ((nb-cands (length icicle-completion-candidates))) + (cond ((eq no-display-p 'no-msg)) ; No-op. + (no-display-p (icicle-msg-maybe-in-minibuffer + (format "Candidates updated (%s matching): %d" + icicle-current-completion-mode nb-cands))) + ((null icicle-completion-candidates) + (save-selected-window (icicle-remove-Completions-window)) + (icicle-msg-maybe-in-minibuffer + (if (eq 'apropos icicle-current-completion-mode) + (let ((typ (car (rassq icicle-apropos-complete-match-fn + icicle-S-TAB-completion-methods-alist)))) + (concat "No " typ (and typ " ") "completions")) + (case icicle-current-TAB-method + (fuzzy "No fuzzy completions") + (swank "No swank (fuzzy symbol) completions") + (vanilla "No vanilla completions") + (t "No prefix completions"))))) + (t + (when (> nb-cands icicle-incremental-completion-threshold) + (message "Displaying completion candidates...")) + ;; Display `*Completions*' now, so we can get its window's width. + ;; We don't wait for `with-output-to-temp-buffer' to display it, because displaying it + ;; might lead to splitting the display window, which would change its width. + ;; We need to know the width in order to calculate the proper candidate formatting. + (when (consp icicle-completion-candidates) + (let ((fit-frame-inhibit-fitting-flag t) + (comp-buf (get-buffer-create "*Completions*"))) + (unless (get-buffer-window comp-buf 'visible) + (save-selected-window (display-buffer comp-buf t 0) + (deactivate-mark))))) ; Remove any leftover mouse selection. + (with-output-to-temp-buffer "*Completions*" + + ;; Each candidate in `icicle-completion-candidates' is a string, regardless of the + ;; original type of candidate used (e.g. symbol, string, alist candidate,...). Here, + ;; provided `icicle-fancy-cands-internal-p' is non-nil, we transform these candidates, + ;; replacing each by a string that takes into account symbol properties + ;; `icicle-display-string' and `icicle-special-candidate'. + ;; + ;; Because `icicle-completion-candidates' is affected, changes to the candidate strings + ;; (e.g. propertizing) are also reflected in the completion return value chosen by the + ;; user. It is not only the display in `*Completions*' that is affected. + ;; + ;; The symbol whose properties are used is the one in the current obarray that is named + ;; by the string candidate to be transformed. If there is no such symbol, then no + ;; transformation occurs. Unless `minibuffer-completion-table' is an obarray, the + ;; global obarray is used to get the symbol. + ;; + ;; 1. If the symbol has an `icicle-display-string' property, then that property value + ;; must be a string (possibly propertized). We replace the candidate by that string. + ;; + ;; 2. If the symbol has an `icicle-special-candidate' property, then we transfer the + ;; property to the candidate string as a set of text properties. (If the value is + ;; not a plist, and `icicle-special-candidate-regexp' is nil, then just apply face + ;; `icicle-special-candidate'.) The effect is similar to using + ;; `icicle-special-candidate-regexp', but the completion return value is also + ;; affected. + (when icicle-fancy-cands-internal-p + (setq icicle-completion-candidates + (mapcar (lambda (cand) + (let* ((symb (intern-soft + cand (and (arrayp minibuffer-completion-table) + minibuffer-completion-table))) + (display-strg (and symb + (stringp (get symb 'icicle-display-string)) + (get symb 'icicle-display-string))) + (new-cand (or display-strg cand)) + (spec-prop (and symb (get symb 'icicle-special-candidate)))) + ;; Apply `icicle-special-candidate' property's value. + ;; If the value is a plist, then apply the properties as text props. + ;; Else (the value is t), apply face `icicle-special-candidate'. + (when spec-prop + (setq new-cand (copy-sequence new-cand)) + (if (consp spec-prop) + (add-text-properties 0 (length new-cand) spec-prop new-cand) + (unless icicle-special-candidate-regexp + (add-text-properties 0 (length new-cand) + '(face icicle-special-candidate) + new-cand)))) + new-cand)) + icicle-completion-candidates))) + ;; The `condition-case' shouldn't be needed, but it prevents an "End of buffer" + ;; message from `display-completion-list' on Emacs 22. + (condition-case nil + (display-completion-list + (if reverse-p (reverse icicle-completion-candidates) icicle-completion-candidates)) + (error nil))) + (save-excursion + (save-window-excursion + (with-current-buffer (get-buffer "*Completions*") + (let ((buffer-read-only nil) + (eob (point-max)) + (dir (and (icicle-file-name-input-p) icicle-last-input + (icicle-file-name-directory icicle-last-input))) + (hist (and (symbolp minibuffer-history-variable) + (boundp minibuffer-history-variable) + (symbol-value minibuffer-history-variable))) + (case-fold-search + ;; Don't bother with buffer completion, `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case))) + (goto-char (icicle-start-of-candidates-in-Completions)) + (while (not (eobp)) + (let* ((beg (point)) + (end (next-single-property-change beg 'mouse-face nil eob)) + (next (next-single-property-change end 'mouse-face nil eob)) + (faces ())) + + ;; Highlight candidate specially if it is a proxy candidate. + (let ((candidate (icicle-current-completion-in-Completions))) + ;;$$$ (when dir (setq candidate (expand-file-name candidate dir))) + (when (member candidate icicle-proxy-candidates) + (setq faces (cons 'icicle-proxy-candidate faces)) + (if (not icicle-proxy-candidate-regexp) + (add-text-properties beg end (cons 'face (list faces))) + (save-match-data + (when (string-match icicle-proxy-candidate-regexp candidate) + (add-text-properties (+ beg (match-beginning 0)) (+ beg (match-end 0)) + (cons 'face (list faces)))))))) + + ;; Highlight candidate specially if it is an extra candidate. + (let ((candidate (icicle-current-completion-in-Completions))) + ;;$$$ (when dir (setq candidate (expand-file-name candidate dir))) + (save-match-data + (when (member candidate icicle-extra-candidates) + (setq faces (cons 'icicle-extra-candidate faces)) + (add-text-properties beg end (cons 'face (list faces)))))) + + ;; Highlight candidate specially if it is a special candidate. + (let ((candidate (icicle-current-completion-in-Completions))) + ;;$$$ (when dir (setq candidate (expand-file-name candidate dir))) + (save-match-data + (when (and icicle-special-candidate-regexp + (string-match icicle-special-candidate-regexp candidate)) + (setq faces (cons 'icicle-special-candidate faces)) + (if (not icicle-special-candidate-regexp) + (add-text-properties beg end (cons 'face (list faces))) + (add-text-properties (+ beg (match-beginning 0)) (+ beg (match-end 0)) + (cons 'face (list faces))))))) + + ;; Highlight candidate (`*-historical-candidate') if it was used previously. + (when icicle-highlight-historical-candidates-flag + (let ((candidate (icicle-current-completion-in-Completions))) + (when dir (setq candidate (expand-file-name candidate dir))) + (when (and (consp hist) (member candidate hist) + (not (member candidate icicle-hist-cands-no-highlight))) + (add-text-properties + beg end + `(face ,(setq faces (cons 'icicle-historical-candidate faces))))))) + + ;; Highlight, inside the candidate, the expanded common match. + (when (and (or icicle-expand-input-to-common-match-flag + (eq icicle-current-completion-mode 'prefix)) + icicle-current-input (not (string= "" icicle-current-input))) + (save-excursion + (save-restriction + (narrow-to-region beg end) ; Restrict to the completion candidate. + (when (re-search-forward (regexp-quote (icicle-minibuf-input-sans-dir + icicle-current-input)) + nil t) + (setq faces (cons 'icicle-common-match-highlight-Completions faces)) + (put-text-property (match-beginning 0) (point) 'face faces))))) + + ;; Hide match for `icicle-current-input' (expanded common match, if available), + ;; if `icicle-hide-common-match-in-Completions-flag' is non-nil. + (save-excursion + (save-restriction + (narrow-to-region beg end) ; Restrict to the completion candidate. + (when (and icicle-hide-common-match-in-Completions-flag + icicle-common-match-string) + (when (re-search-forward (regexp-quote icicle-common-match-string) nil t) + (if (> emacs-major-version 20) + (put-text-property (match-beginning 0) (point) 'display "...") + (put-text-property (match-beginning 0) (point) 'invisible t)))))) + + ;; Highlight, inside the candidate, what the input expression matches. + (unless (and icicle-current-raw-input (string= "" icicle-current-raw-input) + icicle-apropos-complete-match-fn) ; Do nothing if no match fn. + (save-excursion + (save-restriction + (narrow-to-region beg end) ; Restrict to the completion candidate. + (let ((fn (if (and (eq 'prefix icicle-current-completion-mode) + (not (memq icicle-current-TAB-method '(fuzzy swank)))) + ;; $$$$$$ What is best for `vanilla' (Emacs 23) completion? + 'search-forward + (case icicle-apropos-complete-match-fn + (icicle-scatter-match + (lambda (input bound noerror) + (re-search-forward (icicle-scatter input) + bound noerror))) + (icicle-levenshtein-match + (if (= icicle-levenshtein-distance 1) + (lambda (input bound noerror) + (re-search-forward (icicle-levenshtein-one-regexp + input) + bound noerror)) + 're-search-forward)) + (otherwise 're-search-forward))))) + (when (funcall fn (icicle-minibuf-input-sans-dir + icicle-current-raw-input) + nil t) + (setq faces (cons 'icicle-match-highlight-Completions faces)) + (put-text-property (match-beginning 0) (point) 'face faces)))))) + + ;; Highlight candidate if it has been saved. + (when icicle-saved-completion-candidates + (let ((candidate (icicle-current-completion-in-Completions))) + (when (member candidate icicle-saved-completion-candidates) + (let ((ov (make-overlay beg end (current-buffer)))) + (push ov icicle-saved-candidate-overlays) + (overlay-put ov 'face 'icicle-saved-candidate) + (overlay-put ov 'priority '10))))) + + ;; Treat `icicle-candidate-properties-alist'. + ;; A `face' prop will unfortunately wipe out any `face' prop we just applied. + (when icicle-candidate-properties-alist + (save-excursion + (save-restriction + (narrow-to-region beg end) ; Restrict to the completion candidate. + (let* ((candidate (buffer-substring (point-min) (point-max))) + (orig-pt (point)) + (start 0) + (end 0) + (partnum 1) + (join (concat "\\(" icicle-list-join-string "\\|$\\)")) + (len-cand (length candidate)) + (len-join (length icicle-list-join-string)) + (first t)) + (save-match-data + (while (and (or first (not (= end (match-beginning 0))) + (< (+ end len-join) len-cand)) + (string-match join candidate + (if (and (not first) + (= end (match-beginning 0)) + (< end len-cand)) + (+ end len-join) + end)) + (< end len-cand)) + (setq first nil + end (or (match-beginning 0) len-cand)) + (let* ((entry + (assq partnum icicle-candidate-properties-alist)) + (properties (cadr entry)) + (propertize-join-string (car (cddr entry)))) + (when properties + (add-text-properties + (+ start orig-pt) (+ end orig-pt) properties)) + (when propertize-join-string + (add-text-properties + (+ end orig-pt) + (+ end orig-pt len-join) + properties))) + (setq partnum (1+ partnum) + start (match-end 0)))))))) + (goto-char next)))) + (set-buffer-modified-p nil) + (setq buffer-read-only t)))) + (with-current-buffer (get-buffer "*Completions*") + (set (make-local-variable 'mode-line-frame-identification) + (format " %d %s " + nb-cands + (if (and icicle-max-candidates + (< icicle-max-candidates icicle-nb-candidates-before-truncation)) + (format "shown / %d" icicle-nb-candidates-before-truncation) + "candidates"))) + (put-text-property 0 (length mode-line-frame-identification) + 'face 'icicle-mode-line-help + mode-line-frame-identification) + (goto-char (icicle-start-of-candidates-in-Completions)) + (set-window-point (get-buffer-window "*Completions*" 0) (point))) + (message nil))))) ; Clear out any "Looking for..." + + +;; REPLACE ORIGINAL `display-completion-list' (built-in function), +;; saving it for restoration when you toggle `icicle-mode'. +;; +;; 1. Does not remove text properties from candidates when it displays them in *Completions*. +;; 2. Adjusts number of columns and their widths to window size. +;; 3. The optional second arg is ignored. In vanilla Emacs < 23, this is a string +;; representing a common prefix, and faces `completions-first-difference' and +;; `completions-common-part' are used on candidates. +;; +(unless (fboundp 'old-display-completion-list) +(defalias 'old-display-completion-list (symbol-function 'display-completion-list))) + +;;;###autoload +(defun icicle-display-completion-list (completions &optional ignored) + "Display the list of completions, COMPLETIONS, using `standard-output'. +Each element may be just a symbol or string or may be a list of two +strings to be printed as if concatenated. +If it is a list of two strings, the first is the actual completion +alternative, the second serves as annotation. +`standard-output' must be a buffer. +The actual completion alternatives, as inserted, are given the +`mouse-face' property of `highlight'. +At the end, this runs the normal hook `completion-setup-hook'. +It can find the completion buffer in `standard-output'. +The optional second arg is ignored." + (if (not (bufferp standard-output)) + (let ((standard-output (current-buffer))) (icicle-display-completion-list completions)) + (let ((mainbuf (current-buffer))) ; $$$$$$$$$ For Emacs 23 crap that puts base-size in last cdr. + (with-current-buffer standard-output + (goto-char (point-max)) + (when icicle-show-Completions-help-flag (icicle-insert-Completions-help-string)) + (let ((cand-intro-string (if completions + "Possible completions are:\n" + "There are no possible completions of what you have typed."))) + (put-text-property 0 (length cand-intro-string) 'face 'icicle-Completions-instruction-1 + cand-intro-string) + (insert cand-intro-string)) + ;; $$$$$$$$ Emacs 23 nonsense. Revisit this when Stefan finally removes that crud. + ;; This is done in Emacs 23 `display-completion-list'. + (when (fboundp 'completion-all-sorted-completions) ; Emacs 23 + (let ((last (last completions))) + ;; Set base-size from the tail of the list. + (set (make-local-variable 'completion-base-size) + (or (cdr last) (and (minibufferp mainbuf) 0))) + (setcdr last nil))) ; Make completions a properly nil-terminated list. + (icicle-insert-candidates completions))) + ;; In vanilla Emacs < 23, the hook is run with `completion-common-substring' bound to + ;; what is here called IGNORED. + (run-hooks 'completion-setup-hook) + nil)) + +(defun icicle-insert-candidates (candidates) + "Insert completion candidates from list CANDIDATES into the current buffer." + (when (consp candidates) + (let* ((max-cand-len (apply #'max (mapcar (lambda (cand) + (if (consp cand) + (+ (length (car cand)) (length (cadr cand))) + (length cand))) + candidates))) + (comp-win (get-buffer-window (current-buffer) 0)) + (wwidth + (let ((spcl-frame-params (special-display-p (buffer-name)))) + (cond ((and spcl-frame-params ; Special-buffer. Use its default frame width. + (or (and (consp spcl-frame-params) + (cdr (assq 'width (cadr spcl-frame-params)))) + (cdr (assq 'width special-display-frame-alist)) + (cdr (assq 'width default-frame-alist))))) + (comp-win (1- (window-width comp-win))) ; Width picked by `display-buffer'. + (t 40)))) ; Failsafe. + (nb-cands (length candidates)) + (columns (max 1 (min (/ (* 100 wwidth) (* icicle-candidate-width-factor max-cand-len)) + nb-cands))) + (colwidth (/ wwidth columns)) + (column-nb 0) + (rows (/ nb-cands columns)) + (row 0) + startpos endpos string) + (unless (zerop (mod nb-cands rows)) (setq rows (1+ rows))) + (dolist (cand candidates) + (setq endpos (point)) + (cond ((eq icicle-completions-format-internal 'vertical) ; Vertical layout. + (when (>= row rows) + (forward-line (- rows)) + (setq column-nb (+ column-nb colwidth) + row 0)) + (when (> column-nb 0) + (end-of-line) + (let ((cand-end (point))) + (indent-to column-nb icicle-inter-candidates-min-spaces) + (put-text-property cand-end (point) 'mouse-face nil) ; Turn off `mouse-face', `face' + (put-text-property cand-end (point) 'face nil)))) + (t ; Horizontal layout. + (unless (bolp) + (put-text-property (point) (point) 'mouse-face nil) ; Turn off `mouse-face' + (indent-to (* (max 1 column-nb) colwidth) icicle-inter-candidates-min-spaces) + (when (< wwidth (+ (max colwidth (if (consp cand) + (+ (length (car cand)) (length (cadr cand))) + (length cand))) + (current-column))) + (save-excursion ; This is like `fixup-whitespace', but only forward. + (delete-region (point) (progn (skip-chars-forward " \t") (point))) + (unless (or (looking-at "^\\|\\s)") + (save-excursion (forward-char -1) (looking-at "$\\|\\s(\\|\\s'"))) + (insert ?\ ))) + (insert "\n") + (setq column-nb columns))) ; End of the row. Simulate being in farthest column. + (when (< endpos (point)) (set-text-properties endpos (point) nil)))) + ;; Convert candidate (but not annotation) to unibyte or to multibyte, if needed. + (setq string (if (consp cand) (car cand) cand)) + (cond ((and (null enable-multibyte-characters) (multibyte-string-p string)) + (setq string (string-make-unibyte string))) + ((and enable-multibyte-characters (not (multibyte-string-p string))) + (setq string (string-make-multibyte string)))) + ;; Insert candidate (and annotation). Mouse-face candidate, except for any newline as final + ;; char. This is so that candidates are visually separate in *Completions*. Instead, + ;; however, put property `icicle-keep-newline' on any final \n in the candidate, so + ;; `icicle-mouse-choose-completion' and `icicle-current-completion-in-Completions' can put + ;; the newline back as part of the candidate. + (cond ((atom cand) ; No annotation. + (put-text-property (point) (progn (insert string) + (if (eq ?\n (char-before (point))) + (1- (point)) + (point))) + 'mouse-face 'highlight) + (when (eq ?\n (char-before (point))) + (put-text-property (1- (point)) (point) 'icicle-keep-newline t))) + (t ; Candidate plus annotation. + (put-text-property (point) (progn (insert string) + (if (eq ?\n (char-before (point))) + (1- (point)) + (point))) + 'mouse-face 'highlight) + (when (eq ?\n (char-before (point))) + (put-text-property (1- (point)) (point) 'icicle-keep-newline t)) + (set-text-properties (point) (progn (insert (cadr cand)) (point)) nil))) + (if (not (eq icicle-completions-format-internal 'vertical)) + (setq column-nb (mod (1+ column-nb) columns)) + (if (> column-nb 0) (forward-line) (insert "\n")) ; Vertical layout. + (setq row (1+ row))))))) + +(defun icicle-fit-completions-window () + "Fit the window showing completions to its contents. +Scale text size initially, using +`icicle-Completions-text-scale-decrease' (Emacs 23+). +\(Do not scale if using `oneonone.el' with a `*Completions*' frame.) +Useful in `temp-buffer-show-hook'." + (let ((window-min-height 1)) ; Prevent deletion of other windows. + (when (and (eq major-mode 'completion-list-mode) (fboundp 'fit-window-to-buffer)) + (let ((win (selected-window))) + (unless (< (window-width win) (frame-width)) ; Don't shrink if split horizontally. + (fit-window-to-buffer + win + (or (and (symbolp icicle-last-top-level-command) + (get icicle-last-top-level-command 'icicle-Completions-window-max-height)) + icicle-Completions-window-max-height)))))) + (when (and (eq major-mode 'completion-list-mode) ; Emacs 23+ + (or (not (boundp '1on1-*Completions*-frame-flag)) (not 1on1-*Completions*-frame-flag)) + (boundp 'icicle-Completions-text-scale-decrease)) + (text-scale-decrease icicle-Completions-text-scale-decrease))) + +(defun icicle-highlight-initial-whitespace (input) + "Highlight any initial whitespace in your input. +Only if `icicle-highlight-input-initial-whitespace-flag' is non-nil. +INPUT is the current user input, that is, the completion root. +This must be called in the minibuffer." + (when (and icicle-highlight-input-initial-whitespace-flag (not (string= "" input))) + (let ((case-fold-search + ;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case))) + (save-excursion + (goto-char (icicle-minibuffer-prompt-end)) + (when (and (icicle-file-name-input-p) insert-default-directory) + (search-forward (icicle-file-name-directory-w-default input) nil t)) ; Skip directory. + (save-excursion + (save-restriction + (narrow-to-region (point) (point-max)) ; Search within completion candidate. + (while (and (not (eobp)) (looking-at "\\(\\s-\\|\n\\)+")) + (put-text-property (point) (1+ (point)) 'face 'icicle-whitespace-highlight) + (forward-char 1)) + ;; Remove any previous whitespace highlighting that is no longer part of prefix. + (while (not (eobp)) + (when (eq (get-text-property (point) 'face) 'icicle-whitespace-highlight) + (put-text-property (point) (1+ (point)) 'face nil)) + (forward-char 1)))))))) + +(defun icicle-minibuffer-prompt-end () + "Buffer position of end of minibuffer prompt, or `point-min'. +Version of `minibuffer-prompt-end' that works for Emacs 20 and later." + (if (fboundp 'minibuffer-prompt-end) (minibuffer-prompt-end) (point-min))) + +;;(@* "Icicles functions - TAB completion cycling") + +;;; Icicles functions - TAB completion cycling -------------------- + +(defun icicle-prefix-candidates (input) + "List of prefix or fuzzy completions for the current partial INPUT. +INPUT is a string. Each candidate is a string." + (setq icicle-candidate-nb nil) + (if (or (and (eq 'fuzzy icicle-current-TAB-method) (featurep 'fuzzy-match)) + (and (eq 'swank icicle-current-TAB-method) (featurep 'el-swank-fuzzy))) + (condition-case nil + (icicle-transform-candidates (append icicle-extra-candidates icicle-proxy-candidates + (icicle-fuzzy-candidates input))) + (quit (top-level))) ; Let `C-g' stop it. + (let ((cands (icicle-unsorted-prefix-candidates input))) + (cond (icicle-abs-file-candidates (icicle-strip-ignored-files-and-sort cands)) + (icicle-sort-comparer (icicle-maybe-sort-maybe-truncate cands)) + (t cands))))) + +(defun icicle-fuzzy-candidates (input) + "Return fuzzy matches for INPUT. Handles also swank fuzzy symbol match." + (let ((candidates ())) + ;; $$$$ Should treat other `minibuffer-completion-table' types also. + (cond ((and (vectorp minibuffer-completion-table) + (not (eq icicle-current-TAB-method 'swank))) + (mapatoms (lambda (symb) (when (or (null minibuffer-completion-predicate) + (funcall minibuffer-completion-predicate symb)) + (push (symbol-name symb) candidates))) + minibuffer-completion-table) + (setq candidates (FM-all-fuzzy-matches input candidates))) + ((vectorp minibuffer-completion-table) + (setq candidates (mapcar #'car + (car (el-swank-fuzzy-completions + input icicle-swank-timeout + (or minibuffer-completion-predicate 'fboundp) + icicle-swank-prefix-length))))) + ((and (consp minibuffer-completion-table) (consp (car minibuffer-completion-table))) + (dolist (cand minibuffer-completion-table) + (when (or (null minibuffer-completion-predicate) + (funcall minibuffer-completion-predicate cand)) + (push (car cand) candidates))) + (setq candidates (FM-all-fuzzy-matches input candidates)))) + (when (consp candidates) + (setq icicle-common-match-string (icicle-expanded-common-match input candidates))) + (unless candidates (setq icicle-common-match-string nil)) + candidates)) + +(defun icicle-unsorted-prefix-candidates (input) + "Unsorted list of prefix completions for the current partial INPUT. +this also sets `icicle-common-match-string' to the expanded common +prefix over all candidates." + (condition-case nil + (let* ((candidates + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-all-completions input minibuffer-completion-table + minibuffer-completion-predicate + ;; $$$$$$ (- (point) (field-beginning))) + (length input)) + (all-completions input minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag))) + (icicle-extra-candidates + (icicle-remove-if-not + (lambda (cand) + (save-match-data + (string-match (concat "^" (regexp-quote input)) cand))) icicle-extra-candidates)) + (icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) + (save-match-data + (string-match (concat "^" (regexp-quote input)) cand))) icicle-proxy-candidates)) + (filtered-candidates + (icicle-transform-candidates + (append icicle-extra-candidates icicle-proxy-candidates + (icicle-remove-if-not (lambda (cand) + (let ((case-fold-search completion-ignore-case)) + (icicle-filter-wo-input cand))) + candidates))))) + (when (consp filtered-candidates) + (let ((common-prefix + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-try-completion input minibuffer-completion-table + minibuffer-completion-predicate + ;; $$$$$$ (- (point) (field-beginning))) + (length input)) + (try-completion input minibuffer-completion-table + minibuffer-completion-predicate)))) + (setq icicle-common-match-string (if (eq t common-prefix) input common-prefix)))) + (unless filtered-candidates (setq icicle-common-match-string nil)) + filtered-candidates) + (quit (top-level)))) ; Let `C-g' stop it. + +(defun icicle-file-name-prefix-candidates (input) + "List of prefix completions for partial file name INPUT. +INPUT is a string. +Candidates can be directories. Each candidate is a string." + (setq icicle-candidate-nb nil) + ;; $$$$$$ (let ((default-directory (icicle-file-name-directory-w-default input))) + ;; $$$$$$ (icicle-unsorted-file-name-prefix-candidates + ;; $$$$$$ (or (icicle-file-name-nondirectory input) "")))) + (icicle-strip-ignored-files-and-sort (icicle-unsorted-file-name-prefix-candidates input))) + +(defun icicle-unsorted-file-name-prefix-candidates (input) + "Unsorted list of prefix completions for the current file-name INPUT. +This also sets `icicle-common-match-string' to the expanded common +prefix over all candidates." + (condition-case nil + (let* ((candidates + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-all-completions input minibuffer-completion-table + minibuffer-completion-predicate (length input)) + (all-completions input minibuffer-completion-table default-directory + icicle-ignore-space-prefix-flag))) + (icicle-extra-candidates + (icicle-remove-if-not + (lambda (cand) + (save-match-data + (string-match (concat "^" (regexp-quote input)) cand))) icicle-extra-candidates)) + (icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) + (save-match-data + (string-match (concat "^" (regexp-quote input)) cand))) icicle-proxy-candidates)) + (filtered-candidates + (icicle-transform-candidates + (append icicle-extra-candidates icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) + (let ((case-fold-search + (if (boundp 'read-file-name-completion-ignore-case) + read-file-name-completion-ignore-case + completion-ignore-case))) + (if (member cand '("../" "./")) + (member input '(".." ".")) ; Prevent "" from matching "../" + (and +;;; $$$$$$ REMOVED - This was no good for PCM - e.g. input `ic-o' and candidates `icicles-opt.el[c]'. +;;; We don't do it for non-file-name completion, anyway, and it doesn't seem needed. +;;; (save-match-data +;;; (string-match (concat "^" (regexp-quote input)) cand)) + (icicle-filter-wo-input cand))))) + candidates))))) + (when (consp filtered-candidates) + (let ((common-prefix + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-try-completion input minibuffer-completion-table + minibuffer-completion-predicate + (length input)) + (try-completion input minibuffer-completion-table default-directory)))) + ;; If common prefix matches an empty directory, use that dir as the sole completion. + (when (and (stringp common-prefix) + (save-match-data (string-match "/\\.$" common-prefix))) ; Matches /., /.. + (setq common-prefix (substring common-prefix 0 (- (length common-prefix) 2)))) + (setq icicle-common-match-string (if (eq t common-prefix) input common-prefix)))) + (unless filtered-candidates (setq icicle-common-match-string nil)) + filtered-candidates) + (quit (top-level)))) ; Let `C-g' stop it. + +;;(@* "Icicles functions - S-TAB completion cycling") + +;;; Icicles functions - S-TAB completion cycling ------------------- + +(defun icicle-apropos-candidates (input) + "List of candidate apropos completions for the current partial INPUT. +INPUT is a string. Each candidate is a string." + (setq icicle-candidate-nb nil) + (let ((cands (icicle-unsorted-apropos-candidates input))) + (cond (icicle-abs-file-candidates (icicle-strip-ignored-files-and-sort cands)) + (icicle-sort-comparer (icicle-maybe-sort-maybe-truncate cands)) + (t cands)))) + +(defun icicle-unsorted-apropos-candidates (input) + "Unsorted list of apropos completions for the current partial INPUT. +When `icicle-expand-input-to-common-match-flag' is non-nil, this also +sets `icicle-common-match-string' to the expanded common match of +input over all candidates." + (condition-case nil + (progn + (when icicle-regexp-quote-flag (setq input (regexp-quote input))) + (let* ((candidates + (if (and (functionp minibuffer-completion-table) + (not icicle-apropos-complete-match-fn)) + ;; Let the function do it all. + (all-completions input minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag) + (all-completions "" minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag))) + (icicle-extra-candidates + (icicle-remove-if-not + (lambda (cand) (save-match-data (string-match input cand))) icicle-extra-candidates)) + (icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) (save-match-data (string-match input cand))) icicle-proxy-candidates)) + (filtered-candidates + (icicle-transform-candidates + (append icicle-extra-candidates icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) + (let ((case-fold-search completion-ignore-case)) + (and (icicle-filter-wo-input cand) + (or (not icicle-apropos-complete-match-fn) + ;; Assume no match if error - e.g. due to `string-match' with + ;; binary data in Emacs 20. Do this everywhere we call + ;; `icicle-apropos-complete-match-fn'. + (condition-case nil + (funcall icicle-apropos-complete-match-fn input cand) + (error nil)))))) + candidates))))) + (when (and icicle-expand-input-to-common-match-flag (consp filtered-candidates)) + (setq icicle-common-match-string (icicle-expanded-common-match input + filtered-candidates))) + (unless filtered-candidates (setq icicle-common-match-string nil)) + filtered-candidates)) ; Return candidates. + (quit (top-level)))) ; Let `C-g' stop it. + +(defun icicle-file-name-apropos-candidates (input) + "List of apropos completions for partial file-name INPUT. +INPUT is a string. +Candidates can be directories. Each candidate is a string." + (setq icicle-candidate-nb nil) + (let ((default-directory (icicle-file-name-directory-w-default input))) + (icicle-strip-ignored-files-and-sort + (icicle-unsorted-file-name-apropos-candidates (or (icicle-file-name-nondirectory input) ""))))) + +(defun icicle-unsorted-file-name-apropos-candidates (input) + "Unsorted list of apropos completions for the partial file-name INPUT. +When `icicle-expand-input-to-common-match-flag' is non-nil, this also +sets `icicle-common-match-string' to the expanded common match of +input over all candidates." + (condition-case nil + (progn + (when icicle-regexp-quote-flag (setq input (regexp-quote input))) + (let* ((candidates + ;; $$$$$ Should we remove string test for Emacs 23? + (if (and (not (stringp minibuffer-completion-predicate)) + (not icicle-apropos-complete-match-fn) + (functionp minibuffer-completion-table)) + ;; Let the function do it all. + (all-completions input minibuffer-completion-table default-directory + icicle-ignore-space-prefix-flag) + (all-completions "" minibuffer-completion-table default-directory + icicle-ignore-space-prefix-flag))) + (icicle-extra-candidates + (icicle-remove-if-not + (lambda (cand) (save-match-data (string-match input cand))) + icicle-extra-candidates)) + (icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) (save-match-data (string-match input cand))) + icicle-proxy-candidates)) + (filtered-candidates + (icicle-transform-candidates + (append icicle-extra-candidates icicle-proxy-candidates + (icicle-remove-if-not + (lambda (cand) + (let ((case-fold-search + (if (boundp 'read-file-name-completion-ignore-case) + read-file-name-completion-ignore-case + completion-ignore-case))) + (if (member cand '("../" "./")) + (member input '(".." ".")) ; Prevent "" from matching "../" + (and (icicle-filter-wo-input cand) + (or (not icicle-apropos-complete-match-fn) + ;; Assume no match if error - e.g. due to `string-match' + ;; with binary data in Emacs 20. Do this everywhere we + ;; call `icicle-apropos-complete-match-fn'. + (condition-case nil + (funcall icicle-apropos-complete-match-fn input cand) + (error nil))))))) + candidates))))) + (when icicle-expand-input-to-common-match-flag + (setq icicle-common-match-string (if (consp filtered-candidates) + (icicle-expanded-common-match + input filtered-candidates) + nil))) + (unless filtered-candidates (setq icicle-common-match-string nil)) + filtered-candidates)) ; Return candidates. + (quit (top-level)))) ; Let `C-g' stop it. + +(defun icicle-expanded-common-match (input candidates) + "Return the expanded common match for INPUT among all CANDIDATES. +This assumes that INPUT matches each string in list CANDIDATES. +Return nil if there is no common match. This actually returns +`regexp-quote' applied to the expanded common match, so that special +characters in the match don't throw off regexp matching. + +The expanded common match is typically, but not always, the longest +common match. See the documentation, section `Expanded-Common-Match +Completion', for details." + ;; Since `icicle-expanded-common-match-1' checks only the first match for a single candidate, + ;; we call it twice, once using the first candidate and once using the second. + ;; Typically, one of these tries will give us the longest common match. + (catch 'ecm-error + (let ((first-try (icicle-expanded-common-match-1 input candidates)) + (second-try nil)) + (when (and first-try (cadr candidates)) + (setq second-try (icicle-expanded-common-match-1 + input (cons (cadr candidates) (cons (car candidates) (cddr candidates)))))) + (if (> (length second-try) (length first-try)) second-try first-try)))) + +(defun icicle-expanded-common-match-1 (input candidates) + "Helper function for `icicle-expanded-common-match." + ;; This does not always give a longest common match, because it looks only at the first match + ;; of INPUT with the first candidate. What it returns is the longest match that is common to + ;; all CANDIDATES and also contains the first match in the first candidate. + (let ((case-fold-search + ;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case)) + (first (car candidates))) + (and icicle-apropos-complete-match-fn ; Return nil if no match function. + (save-match-data + ;; Assume no common match in case of error - e.g. due to `string-match' with binary data + ;; in Emacs 20. Do this throughout, whenever we call `icicle-apropos-complete-match-fn'. + (unless (condition-case nil + (funcall icicle-apropos-complete-match-fn input first) + (error (throw 'ecm-error nil))) + (error (throw 'ecm-error nil))) ; If input doesn't match candidate, return nil. + (let* ((len-first (length first)) + (beg 0) + (end len-first) + (orig-match-beg (match-beginning 0)) + (orig-match-end (match-end 0)) + (ecm first) ; "ecm" for "expanded common match". + (rest (cdr candidates)) + beg-ecm beg-next) + (if (= orig-match-beg end) + (setq ecm "") ; INPUT was, for instance, "$" or "\\>$; return "". + ;; Compare with the rest of the candidates, reducing as needed. + (while (and rest ecm) + (condition-case nil + (funcall icicle-apropos-complete-match-fn input (car rest)) + (error (throw 'ecm-error nil))) ; If input doesn't match candidate, return nil. + (setq beg-next (match-beginning 0)) + ;; Remove any prefix that doesn't match some other candidate. + (while (and (< beg orig-match-beg) + (not (condition-case nil + (funcall icicle-apropos-complete-match-fn + (regexp-quote (substring ecm 0 (- orig-match-end beg))) + (car rest)) + (error (throw 'ecm-error nil)))) + (progn (setq beg-ecm (match-beginning 0)) (>= beg-ecm beg-next))) + ;; Take a character off of the left. + (setq ecm (substring ecm 1) + beg (1+ beg))) + ;; Remove any suffix that doesn't match some other candidate. + (while (and (> end 0) (not (condition-case nil + (funcall icicle-apropos-complete-match-fn + (regexp-quote ecm) (car rest)) + (error (throw 'ecm-error nil))))) + ;; Take a character off of the right. + (setq ecm (substring ecm 0 (1- (length ecm))) + end (1- end))) + (unless (and (condition-case nil + (funcall icicle-apropos-complete-match-fn + (regexp-quote ecm) (car rest)) + (error (throw 'ecm-error nil))) + (condition-case nil ; Input must match the substring that is common. + (funcall icicle-apropos-complete-match-fn input ecm) + (error (throw 'ecm-error nil)))) + (setq ecm nil)) ; No possible expansion + (pop rest)) + ecm)))))) + +(defun icicle-scatter-match (string completion) + "Returns non-nil if STRING scatter-matches COMPLETION. +This means that all of the characters in STRING are also in string +COMPLETION, in the same order, but perhaps scattered among other +characters. For example, STRING = \"ure\" matches COMPLETION +\"curried\"." + (string-match (icicle-scatter string) completion)) + +(defun icicle-scatter (string) + "Returns a regexp that matches a scattered version of STRING. +The regexp will match any string that contains the characters in +STRING, in the same order, but possibly with other characters as well. +Returns, for example, \"a.*b.*c.*d\" for input string \"abcd\"." + (if (> emacs-major-version 21) + (mapconcat #'regexp-quote (split-string string "" t) ".*") + (mapconcat #'regexp-quote (split-string string "") ".*"))) + +(defun icicle-levenshtein-strict-match (s1 s2) + "String S1 is within `icicle-levenshtein-distance' of string S2. +This means that S1 differs by at most `icicle-levenshtein-distance' +character deletions, insertions, or replacements from S2. The string +lengths too must differ by at most `icicle-levenshtein-distance'. +You probably want to turn off incremental completion (`C-#') if you +use this match method; it is quite slow. +To use this match method, you must also have library `levenshtein.el'." + (and (require 'levenshtein nil t) (<= (levenshtein-distance s1 s2) icicle-levenshtein-distance))) + +(defun icicle-levenshtein-match (s1 s2) + "String S1 is within `icicle-levenshtein-distance' of a substring of S2. +S1 and S2 are strings. This means that S1 and some substring of S2 +differ by at most `icicle-levenshtein-distance' character deletions, +insertions, or replacements. + +You will probably want to turn off incremental completion (`C-#') if +you use this match method; it can be quite slow, especially with a +large value of `icicle-levenshtein-distance'. To use this method with +a value other than 1, you must also have library `levenshtein.el'." + (if (= icicle-levenshtein-distance 1) + (icicle-levenshtein-one-match s1 s2) + (unless (require 'levenshtein nil t) (error "You need library `levenshtein.el' for this")) + (catch 'icicle-levenshtein-match + (dolist (sub (icicle-substrings-of-length s2 (length s1))) + (when (<= (levenshtein-distance s1 sub) icicle-levenshtein-distance) + (throw 'icicle-levenshtein-match t))) + nil))) + +;; This is much faster than testing with `levenshtein-distance' and a value of 1. +(defun icicle-levenshtein-one-match (s1 s2) + "S1 is within a Levenshtein distance of one of some substring of S2. +That is, S1 with 0 or 1 char inserted, deleted or replaced is a +substring of S2. S1 and S2 are strings. +You do not need library `levenshtein.el' to use this function." + (string-match (icicle-levenshtein-one-regexp s1) s2)) + +(defun icicle-levenshtein-one-regexp (string) + "Return a regexp for strings that are 1 Levenshtein unit from STRING." + (let ((indx 0) + (regexp "\\(")) + (dotimes (indx (length string)) + (setq regexp (concat regexp (substring string 0 indx) ".?" (substring string (1+ indx)) "\\|" + (substring string 0 indx) "." (substring string indx) "\\|"))) + (setq regexp (concat (substring regexp 0 -1) ")")))) + +(defun icicle-substrings-of-length (string &optional len) + "Return a list of substrings of STRING that have length LEN. +If LEN is nil, treat it as the length of STRING." + (unless len (setq len (length string))) + (if (zerop len) + (list "") + (let ((subs ())) + (dotimes (idx (- (length string) (1- len))) (push (substring string idx (+ idx len)) subs)) + (nreverse subs)))) + +;;(@* "Icicles functions - common helper functions") + +;;; Icicles functions - common helper functions ---------------------- + +;; Main cycling function - used by `icicle-next-prefix-candidate', `icicle-next-apropos-candidate'. +(defun icicle-next-candidate (nth candidates-fn &optional regexp-p) + "Replace input by NTH next or previous completion for an input. +Default value of NTH is 1, meaning use the next completion. +Negative NTH means use a previous, not subsequent, completion. + +CANDIDATES-FN is a function that returns the list of candidate +completions for its argument, the current partial input (a string). + +Optional arg REGEXP-P non-nil means that CANDIDATES-FN uses regexp +matching. This is used to highlight the appropriate matching root. + +If option `icicle-help-in-mode-line-flag' is non-nil, then help on the +current candidate is shown in the mode line." + (let ((saved-last-input icicle-last-input)) ; For call to `icicle-recompute-candidates'. + (unless (stringp icicle-last-completion-candidate) + (setq icicle-last-completion-candidate icicle-initial-value)) + (setq nth (or nth 1) + icicle-current-input (if (icicle-file-name-input-p) + (abbreviate-file-name (icicle-input-from-minibuffer 'leave-envar)) + (icicle-input-from-minibuffer)) + icicle-cycling-p t) + (unless (and (symbolp this-command) (get this-command 'icicle-apropos-cycling-command) + (or (and (symbolp last-command) (get last-command 'icicle-apropos-cycling-command)) + (memq last-command + '(icicle-candidate-action + icicle-remove-candidate icicle-mouse-remove-candidate + icicle-apropos-complete icicle-apropos-complete-no-display)))) + (setq icicle-common-match-string nil)) ; Don't use old one, in `icicle-save-or-restore-input'. + (icicle-save-or-restore-input) + (when (and (icicle-file-name-input-p) (icicle-file-directory-p icicle-current-input)) + (setq icicle-default-directory icicle-current-input)) + (unless (eq this-command last-command) + (icicle-recompute-candidates nth candidates-fn saved-last-input)) + (icicle-save-or-restore-input) ; Again, based on updated `icicle-common-match-string'. + (cond ((null icicle-completion-candidates) + (save-selected-window (icicle-remove-Completions-window)) + (minibuffer-message " [No completion]")) + (t + (icicle-clear-minibuffer) + (let ((nb-cands (length icicle-completion-candidates)) + (unit (if (wholenump nth) 1 -1)) + next) + ;; So `icomplete+' can append the number of other candidates to the minibuffer. + (setq icicle-nb-of-other-cycle-candidates (1- nb-cands)) + (icicle-increment-cand-nb+signal-end nth nb-cands) + (setq next (elt icicle-completion-candidates icicle-candidate-nb)) + (while (null next) ; Skip null candidates. + (icicle-increment-cand-nb+signal-end unit nb-cands) + (setq next (elt icicle-completion-candidates icicle-candidate-nb))) + + ;; Update last-candidate to NEXT. Need a copy, because we change its text properties. + (setq icicle-last-completion-candidate (copy-sequence next)) + + (icicle-insert-cand-in-minibuffer icicle-last-completion-candidate regexp-p) + + ;; Highlight current completion candidate, if *Completions* is displayed. + (when (get-buffer-window "*Completions*" 0) + + ;; Refresh *Completions*, updating it to reflect the current candidates. + (unless (or (and (symbolp this-command) + (get this-command 'icicle-apropos-cycling-command) + (or (and (symbolp last-command) + (get last-command 'icicle-apropos-cycling-command)) + (memq last-command '(icicle-candidate-action + icicle-remove-candidate + icicle-mouse-remove-candidate)))) + (and (symbolp this-command) + (get this-command 'icicle-prefix-cycling-command) + (or (and (symbolp last-command) + (get last-command 'icicle-prefix-cycling-command)) + (memq last-command '(icicle-candidate-action + icicle-remove-candidate + icicle-mouse-remove-candidate))))) + (icicle-display-candidates-in-Completions)) + (save-selected-window + (select-window (get-buffer-window "*Completions*" 'visible)) + (if (fboundp 'thumfr-only-raise-frame) (thumfr-only-raise-frame) (raise-frame))) + (icicle-highlight-candidate-in-Completions)) + (icicle-show-help-in-mode-line icicle-last-completion-candidate)))))) + +(defun icicle-insert-cand-in-minibuffer (candidate regexp-p) + "Insert CANDIDATE in minibuffer. Highlight root and initial whitespace. +REGEXP-P non-nil means use regexp matching to highlight root." + ;; Highlight any initial whitespace (probably a user typo). + (icicle-highlight-initial-whitespace (if regexp-p icicle-current-raw-input icicle-current-input)) + + ;; Underline the root that was completed, in the minibuffer. + (let ((inp (icicle-minibuf-input-sans-dir icicle-current-input)) + (case-fold-search + ;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case)) + indx) + (unless (and regexp-p (not icicle-regexp-quote-flag)) (setq inp (regexp-quote inp))) + (save-match-data + (setq indx (string-match inp icicle-last-completion-candidate)) + (when indx (put-text-property indx (match-end 0) 'face 'icicle-match-highlight-minibuffer + icicle-last-completion-candidate)))) + + ;; Insert candidate in minibuffer, and place cursor. + (insert (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-dir-prefix-wo-wildcards icicle-current-input) + "") + candidate) + (icicle-place-cursor icicle-current-input)) + +(defun icicle-dir-prefix-wo-wildcards (filename) + "Return the directory portion of FILENAME. +If using partial completion, this is the portion before the first +occurrence of `*'. Otherwise, this is just `file-name-directory'." + (if (and (icicle-not-basic-prefix-completion-p) (boundp 'completion-styles) + (member 'partial-completion completion-styles) + (string-match "/[^/]*\\*" filename)) + (substring filename 0 (1+ (match-beginning 0))) + (or (file-name-directory filename) ""))) ; Don't return nil, in any case. + + +(defun icicle-show-help-in-mode-line (candidate) + "If short help for CANDIDATE is available, show it in the mode-line. +Do this only if `icicle-help-in-mode-line-flag' is non-nil." + (when icicle-help-in-mode-line-flag + (let* ((cand (cond (;; Call to `lacarte-execute(-menu)-command' (in `lacarte.el'). + ;; Use command associated with menu item. + (consp lacarte-menu-items-alist) + (cdr (assoc candidate lacarte-menu-items-alist))) + (;; Key-completion candidate. Get command from candidate. + (and (boundp 'icicle-completing-keys-p) icicle-completing-keys-p) + (if (string= ".." candidate) + "GO UP" + (let ((cmd-name (save-match-data + (string-match "\\(.+\\) = \\(.+\\)" candidate) + (substring candidate (match-beginning 2) + (match-end 2))))) + (if (string= "..." cmd-name) "Prefix key" (intern-soft cmd-name))))) + (;; Buffer or file name. + (or (get-buffer candidate) (icicle-file-name-input-p) + icicle-abs-file-candidates) + (icicle-transform-multi-completion candidate)) + (t ; Convert to symbol or nil. + (intern-soft (icicle-transform-multi-completion candidate))))) + (doc (progn (when (stringp candidate) + (setq candidate (icicle-transform-multi-completion candidate))) + (cond ((and (stringp candidate) ; String with help as property. + (get-text-property 0 'icicle-mode-line-help candidate))) + ((and cand (symbolp cand) ; Symbol. + (cond ((get cand 'icicle-mode-line-help)) ; Help prop. + ((fboundp cand) ; Function. + (or (documentation cand t) ; Functon's doc string. + (if (string-match ; Easy-menu item. + "^menu-function-[0-9]+$" (symbol-name cand)) + (format "%s" (symbol-function cand)) + (format "Command `%s'" cand)))) + ((facep cand) (face-documentation cand)) ; Face. + (t (documentation-property ; Variable. + cand 'variable-documentation t))))) + ((and (consp cand) (eq (car cand) 'lambda)) ; Lambda form. + (format "%s" cand)) + ((and (stringp cand) ; Prefix key, `..'. + (member cand '("Prefix key" "GO UP"))) + cand) + ((stringp candidate) ; String without help property. + (cond ((and (or (icicle-file-name-input-p) ; File name. + icicle-abs-file-candidates) + (file-exists-p candidate)) + (if (get-file-buffer candidate) + (concat (icicle-help-line-buffer + (get-file-buffer candidate) 'no-bytes-p) " " + (icicle-help-line-file cand)) + (icicle-help-line-file candidate))) + ((get-buffer candidate) ; Non-file buffer. + (icicle-help-line-buffer candidate)) + (t nil)))))) ; Punt. + (doc-line1 (and (stringp doc) (string-match ".+$" doc) (match-string 0 doc)))) + (when doc-line1 + (put-text-property 0 (length doc-line1) 'face 'icicle-mode-line-help doc-line1) + (icicle-show-in-mode-line + doc-line1 + (cond ((get-buffer-window "*Completions*" 'visible) "*Completions*") + ((eq (current-buffer) (window-buffer (minibuffer-window))) (cadr (buffer-list))) + (t (current-buffer)))))))) + +(defun icicle-help-line-buffer (buffer &optional no-bytes-p) + "Simple help string for BUFFER." + (with-current-buffer buffer + (if no-bytes-p + (format "Mode: %s" mode-name) + (format "Bytes: %d, Mode: %s" (buffer-size) mode-name)))) + +(defun icicle-help-line-file (file) + "Simple help string for FILE." + (let ((attrs (file-attributes file))) + (and attrs (format "Bytes: %d, Saved: %s, Access: %s" (nth 7 attrs) + (format-time-string "%c" (nth 5 attrs)) (nth 8 attrs))))) ; "%Y-%m-%d %H" + +(defun icicle-show-in-mode-line (text &optional buffer) + "Display TEXT in BUFFER's mode line for 10 sec (or until user event). +Note: This sits for 10 sec or until a user event, so call this last in +a sequence of user-visible actions." + (message nil) ; Remove any msg, such as "Computing completion candidates...". + (with-current-buffer (or buffer (current-buffer)) + (make-local-variable 'mode-line-format) ; Needed for Emacs 21+. + (let ((mode-line-format text)) (force-mode-line-update) (sit-for 10)) + (force-mode-line-update))) + +(defun icicle-recompute-candidates (nth candidates-fn saved-last-input) + "Recompute `icicle-completion-candidates', if needed. +If buffer *Completions* is already displayed, it is updated. +This does nothing, unless the user changed the minibuffer input or the +completion type has changed (from apropos to prefix or vice versa). +NTH < 0 means candidate order is reversed in *Completions*. +Argument CANDIDATES-FN is a function that recomputes the candidates. +SAVED-LAST-INPUT is the last input, as in `icicle-last-input'." + (unless (and icicle-last-completion-command + (symbolp this-command) ; Need symbol for `get', below. + (string= icicle-current-input saved-last-input) ; No change in user input. + ;; No change in completion type: apropos vs prefix. + (or (and (or (get icicle-last-completion-command 'icicle-apropos-completing-command) + (memq icicle-last-completion-command + '(icicle-candidate-set-complement icicle-mouse-remove-candidate + icicle-keep-only-past-inputs))) + (or (get this-command 'icicle-apropos-completing-command) + (get this-command 'icicle-apropos-cycling-command))) + (and (or (get icicle-last-completion-command 'icicle-prefix-completing-command) + (memq icicle-last-completion-command + '(icicle-candidate-set-complement icicle-mouse-remove-candidate + icicle-keep-only-past-inputs))) + (or (get this-command 'icicle-prefix-completing-command) + (get this-command 'icicle-prefix-cycling-command))))) + (when (string= icicle-current-input saved-last-input) ; Changed completion type, not user input. + ;; Set `icicle-last-completion-command', to record new completion type. + (cond ((and (symbolp this-command) (get this-command 'icicle-prefix-cycling-command)) + (setq icicle-last-completion-command + (if (eq icicle-last-completion-command 'icicle-apropos-complete-no-display) + 'icicle-prefix-complete-no-display + 'icicle-prefix-complete))) + ((and (symbolp this-command) (get this-command 'icicle-apropos-cycling-command)) + (setq icicle-last-completion-command + (if (eq icicle-last-completion-command 'icicle-prefix-complete-no-display) + 'icicle-apropos-complete-no-display + 'icicle-apropos-complete))))) + + ;; Recompute and redisplay completion candidates. Reset candidate number. + (setq icicle-completion-candidates + (condition-case nil + (funcall candidates-fn icicle-current-input) + (error icicle-completion-candidates))) ; No change if completion error. + (when (get-buffer-window "*Completions*" 0) ; Update *Completions* display or remove it. + (if icicle-completion-candidates + (icicle-display-candidates-in-Completions (not (wholenump nth))) + (save-selected-window (icicle-remove-Completions-window)))))) + +(defun icicle-save-raw-input () + "Save `icicle-current-raw-input' as the latest previous input. +It is saved to `icicle-previous-raw-file-name-inputs', if completing a +file name, or `icicle-previous-raw-non-file-name-inputs', otherwise." + (let* ((prev-inputs-var (if (icicle-file-name-input-p) + 'icicle-previous-raw-file-name-inputs + 'icicle-previous-raw-non-file-name-inputs)) + (prev-inputs (symbol-value prev-inputs-var))) + (unless (string= "" icicle-current-raw-input) + (set prev-inputs-var (icicle-put-at-head prev-inputs-var icicle-current-raw-input))) + (when (> (length prev-inputs) icicle-completion-history-max-length) + (setcdr (nthcdr (1- icicle-completion-history-max-length) prev-inputs) ())))) + +(defun icicle-save-or-restore-input () + "Save the current minibuffer input, or restore the last input. +If there is a previous input and we are cycling, then restore the last + input. (Cycled completions don't count as input.) +Otherwise, save the current input for use by `C-l', and then compute + the expanded common match. + +There are several particular cases that modulate the behavior - see +the code." + (cond + ;; Restore last input, if there is some to restore and we are cycling. + ((and icicle-last-input icicle-cycling-p icicle-last-completion-candidate) + (setq icicle-current-input icicle-last-input)) ; Return `icicle-current-input'. + (t + (cond + ;; Save the current input for `C-l', then update it to the expanded common match. + ;; Do NOT do this if: + ;; the user doesn't want to use the expanded common match + ;; or there is no common match string + ;; or the last command was a cycling command + ;; or the input and the completion mode have not changed + ;; (so saved regexp will not be overwritten). + ((not (or (and (not icicle-expand-input-to-common-match-flag) + (eq icicle-current-completion-mode 'apropos)) + (not icicle-common-match-string) + (and (symbolp last-command) (get last-command 'icicle-cycling-command) + (not (get last-command 'icicle-completing-command))) ; Not `TAB' or `S-TAB'. + (and (equal icicle-last-input icicle-current-input) + (eq icicle-current-completion-mode + (if (get icicle-last-completion-command 'icicle-prefix-completing-command) + 'prefix + 'apropos))))) + + ;; Expand current input to expanded common match, after saving it for `C-l'. + (let ((common (if (and (icicle-file-name-input-p) insert-default-directory) + (if (string= "" icicle-common-match-string) + (or (icicle-file-name-directory icicle-current-input) "") + (directory-file-name (icicle-abbreviate-or-expand-file-name + icicle-common-match-string + (icicle-file-name-directory icicle-current-input)))) + icicle-common-match-string))) + + ;; Save current input for `C-l', then save common match as current input. + ;; Do NOT do anything if we're ignoring letter case and that is the only difference + ;; between the common match and the input (e.g. MS Windows file names). + (unless (and case-fold-search + (string= (icicle-upcase icicle-current-input) (icicle-upcase common)) + (not (string= icicle-current-input common))) + + ;; Save input for `C-l' if this is not `C-l' or `C-L'. + ;; Save it also if this is the first cycling command, or the first after completion. + (unless (or (memq this-command '(icicle-retrieve-previous-input + icicle-retrieve-next-input)) + (and icicle-cycling-p + (or icicle-candidate-nb ; Not the first cycling command. + (and (symbolp last-command) + (get last-command 'icicle-completing-command))))) + (setq icicle-current-raw-input icicle-current-input) + ;; Save it for `C-l', unless it is "". Drop old entries when too big. + (icicle-save-raw-input)) + + ;; Save expanded common match as current input, unless input is a directory. + ;; Use `icicle-file-directory-p'. + ;; `file-directory-p' fails to consider "~/foo//usr/" a directory. + ;; $$$$$$ We could use the `icicle-file-directory-p' code with `icicle-file-name-directory' + ;; instead of `icicle-file-name-directory-w-default', if that presents a problem. + (unless (and (icicle-file-name-input-p) (icicle-file-directory-p icicle-current-input)) + (setq icicle-current-input common))))) + + ;; Save input for `C-l'. + ;; Do NOT do this if: + ;; this command is `C-l' or `C-L' + ;; or we are cycling or the last command was a cycling command + ;; or this command is the same as last command. + ((not (or (memq this-command '(icicle-retrieve-previous-input icicle-retrieve-next-input)) + icicle-cycling-p + (and (symbolp last-command) (get last-command 'icicle-cycling-command) + (not (get this-command 'icicle-completing-command))) + ;;$$$ (and (symbolp last-command) (get last-command 'icicle-completing-command)) + (eq last-command this-command))) + (setq icicle-current-raw-input icicle-current-input) + ;; Save it for `C-l', unless it is "". Drop old entries when too big. + (icicle-save-raw-input)) + ;; Forget last raw input, so it is not highlighted in *Completions*. + ;; Do NOT do this if we are cycling. + ((not icicle-cycling-p) + (setq icicle-current-raw-input ""))))) + (setq icicle-last-input icicle-current-input)) ; Return `icicle-current-input'. + +(defun icicle-put-at-head (list-var element) + "Put ELEMENT at the front of the value of LIST-VAR. +If ELEMENT is already a member of the list, then it is moved to the +front. Otherwise, it is added to the front. Membership is tested +with `equal'. The return value is the new value of LIST-VAR. +This is a destructive operation: the list structure is changed." + (let* ((lis (symbol-value list-var)) + (tl (member element lis))) + (cond ((null lis) (set list-var (list element))) + ;;;((eq tl lis) (set list-var (cdr lis))) + ((not (eq tl lis)) + (when tl (setcdr (nthcdr (1- (- (length lis) (length tl))) lis) (cdr tl))) + (set list-var (cons element lis))))) + (symbol-value list-var)) + +(defun icicle-remove-dots (filename) + "Strip leading string through last ../ or ./ from FILENAME." + (let ((newname filename)) + (save-match-data + (while (or (string-match "\\.\\./" newname) + (string-match "\\./" newname) + ;; Emacs 21+ `file-relative-name' returns ".." and "." (no slash) for "" first arg + (string-match "^\\.\\.$" newname) + (string-match "^\\.$" newname)) + (setq newname (substring newname (match-end 0))))) + newname)) + +(defun icicle-increment-cand-nb+signal-end (incr max) + "Increment candidate number by INCR modulo MAX, and signal end of cycle." + (setq icicle-candidate-nb (if icicle-candidate-nb + (+ incr icicle-candidate-nb) + (if (natnump incr) 0 (1- max)))) + (let ((wrapped (mod icicle-candidate-nb max))) + (when (and (/= wrapped icicle-candidate-nb) (eq last-command this-command)) + (let ((visible-bell t)) (ding))) + (setq icicle-candidate-nb wrapped))) + +(defun icicle-place-cursor (input &optional dont-activate-p) + "Position point and mark with respect to the minibuffer candidate. +Positions are `icicle-point-position-in-candidate' and +`icicle-mark-position-in-candidate', respectively. +INPUT is the current user input, that is, the completion root. +Optional argument DONT-ACTIVATE-P means do not activate the mark." + (let ((case-fold-search + ;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case)) + input-start-position) + (goto-char (icicle-minibuffer-prompt-end)) + (setq input-start-position (point)) + (when (and (icicle-file-name-input-p) insert-default-directory) + (search-forward (icicle-file-name-directory-w-default input) nil t) + (setq input-start-position (point))) ; Skip directory. + ;; Locate completion root within current completion candidate. + (when (or (memq icicle-point-position-in-candidate '(root-start root-end)) + (memq icicle-mark-position-in-candidate '(root-start root-end))) + (save-excursion + (save-restriction + (narrow-to-region (point) (point-max)) ; Search within the completion candidate. + (re-search-forward (if icicle-regexp-quote-flag + (regexp-quote (icicle-minibuf-input-sans-dir input)) + (icicle-minibuf-input-sans-dir input)) + nil t)))) + ;; Position point. + (case icicle-point-position-in-candidate + (input-start (goto-char input-start-position)) + (input-end (goto-char (point-max))) + (root-start (goto-char (max input-start-position (match-beginning 0)))) + (root-end (goto-char (max input-start-position (match-end 0))))) + ;; Position mark. + (unless (eq icicle-point-position-in-candidate icicle-mark-position-in-candidate) + (push-mark (case icicle-mark-position-in-candidate + (input-start input-start-position) + (input-end (point-max)) + (root-start (max input-start-position (match-beginning 0))) + (root-end (max input-start-position (match-end 0)))) + 'nomsg + (not dont-activate-p))))) + +(defun icicle-highlight-candidate-in-Completions () + "Highlight the current candidate in *Completions*." + (let ((compl-win (get-buffer-window "*Completions*" 0)) + curr-cand-pos) + (when compl-win + (set-window-dedicated-p compl-win t) + (save-window-excursion (select-window compl-win) + (goto-char (icicle-start-of-candidates-in-Completions)) + (icicle-move-to-next-completion icicle-candidate-nb t) + (set-buffer-modified-p nil) + (setq curr-cand-pos (point))) + (set-window-point compl-win curr-cand-pos)))) + +(defun icicle-place-overlay (start end overlay face priority buffer &rest properties) + "Put OVERLAY with FACE and PRIORITY between START and END in BUFFER. +OVERLAY is a symbol whose value is the overlay. If nil, the overlay + is created. If non-nil, it is simply moved. +PROPERTIES are additional overlay properties to add: pairs of a +property and a value." + (if (symbol-value overlay) ; Overlay exists, just move it. + (move-overlay (symbol-value overlay) start end buffer) + (set overlay (make-overlay start end buffer)) + (overlay-put (symbol-value overlay) 'face face) + (overlay-put (symbol-value overlay) 'priority priority))) + +(defun icicle-strip-ignored-files-and-sort (candidates) + "Remove file names with ignored extensions, and \".\". Sort CANDIDATES. +If `icicle-sort-comparer' is nil, then do not sort." + (when (fboundp 'completion-ignored-build-apply) ; In `completion-ignored-build.el'. + (let ((completion-ignored-extensions completion-ignored-extensions)) + (completion-ignored-build-apply) + (icicle-update-ignored-extensions-regexp))) + (let* ((pred1 (lambda (cand) (or (save-match-data + (string-match icicle-ignored-extensions-regexp cand)) + (string= "./" cand)))) + (pred2 (lambda (cand) (string= "./" cand))) + (new-candidates (icicle-remove-if (if icicle-ignored-extensions-regexp pred1 pred2) + candidates))) + ;; If the only candidates have ignored extensions, then use them. + (unless new-candidates (setq new-candidates (icicle-remove-if pred2 candidates))) + (icicle-maybe-sort-maybe-truncate new-candidates))) + +(defun icicle-transform-candidates (candidates) + "Apply `icicle-transform-function' to CANDIDATES. +If `icicle-transform-function' is nil, return CANDIDATES. + +Note that this transformation is applied before completion candidates +are made available to the user, in particular, before they are +displayed in *Completions*. Its use is thus quite different from that +of `icicle-transform-sole-candidate'." + (if icicle-transform-function (funcall icicle-transform-function candidates) candidates)) + +(defun icicle-transform-multi-completion (candidate) + "Transform display CANDIDATE according to `icicle-list-use-nth-parts'. +If CANDIDATE is not a multi-completion, return CANDIDATE unchanged. +Return the possibly transformed candidate." + (if icicle-list-use-nth-parts + (let ((parts (split-string candidate icicle-list-join-string))) (icicle-join-nth-parts parts)) + candidate)) + +(defun icicle-join-nth-parts (parts) + "Join the elements in PARTS using `icicle-list-nth-parts-join-string'." + (let* ((maxpart (length parts)) + (indexes icicle-list-use-nth-parts) + (cand "") + (firstp t) + partnum) + (while indexes + (setq partnum (car indexes)) + (unless firstp (setq cand (concat cand icicle-list-nth-parts-join-string))) + (setq firstp nil) + (unless (> partnum maxpart) (setq cand (concat cand (nth (1- partnum) parts)))) + (setq indexes (cdr indexes))) + cand)) + +(defun icicle-display-cand-from-full-cand (cand) + "Return the display candidate corresponding to full candidate CAND." + (let ((parts (car cand))) + (if (atom parts) + parts ; Not a multi-completion. + (if icicle-list-use-nth-parts + (icicle-join-nth-parts parts) ; Join mult-completion parts per `icicle-list-use-nth-parts'. + ;; Multi-completion, but no joining specified. Reconstitute the display candidate. + (concat (mapconcat #'identity parts icicle-list-join-string) icicle-list-end-string))))) + +(defun icicle-file-name-directory (file) + "Like `file-name-directory', but backslash is not a directory separator. +Do not treat backslash as a directory separator, even on MS Windows. +Escape any backslashes, then call `file-name-directory' and return +what it returns." + (let* ((escaped-file (subst-char-in-string ?\\ ?\a file)) + (dir (file-name-directory escaped-file))) + (and dir (subst-char-in-string ?\a ?\\ dir)))) + +(defun icicle-file-name-directory-w-default (file) + "`icicle-file-name-directory', or `default-directory' if that is nil." + (or (icicle-file-name-directory file) default-directory)) + +(defun icicle-file-name-nondirectory (file) + "Like `file-name-nondirectory', but does not treat backslash specially. +That is, backslash is never treated as a directory separator." + (let ((escaped-file (subst-char-in-string ?\\ ?\a file))) + (subst-char-in-string ?\a ?\\ (file-name-nondirectory escaped-file)))) + +;; $$$$$ +;; (defun icicle-file-name-input-p () +;; "Return non-nil if expected input is a file name. +;; This is used, instead of variable `minibuffer-completing-file-name', +;; because we sometimes complete against an explicit alist of file names, +;; even in the overall context of file-name input. In that case, we do +;; not want to use file-name completion. An example of this is +;; completing against a history list of file names, using +;; `icicle-history'." +;; ;; Note that some Emacs 20 code uses this as the equivalent of +;; ;; `minibuffer-completing-file-name': +;; ;; (memq minibuffer-completion-table '(read-file-name-internal read-directory-name-internal)) +;; (and (symbolp minibuffer-completion-table) (stringp minibuffer-completion-predicate))) + +(defun icicle-file-name-input-p () + "Return non-nil if expected input is a file name." + minibuffer-completing-file-name) + +(defun icicle-file-directory-p (file) + "Local, faster replacement for `file-directory-p'. +This does not do all of the file-handler processing that +`file-directory-p' does, so it is not a general replacement." + (and (stringp file) (string= file (icicle-file-name-directory-w-default file)))) + +(defun icicle-minibuf-input () + "Return the user minibuffer input as a string, without text-properties." + (save-selected-window (select-window (minibuffer-window)) (icicle-input-from-minibuffer))) + +;;$$$ Do we need to double all $'s in output from `icicle-subst-envvar-in-file-name', +;; before calling `substitute-in-file-name'? +(defun icicle-input-from-minibuffer (&optional leave-envvars-p) + "Return the minibuffer input as a string, without text-properties. +Unless optional arg LEAVE-ENVVARS-P is non-nil, substitute any +environment vars by their values. +The current buffer must be a minibuffer." + (let ((input (if (fboundp 'minibuffer-contents) + (minibuffer-contents) ; e.g. Emacs 22 + (buffer-substring (point-min) (point-max))))) ; e.g. Emacs 20 + ;; $$$$$$$$ (if (fboundp 'minibuffer-contents-no-properties) + ;; (minibuffer-contents-no-properties) ; e.g. Emacs 22 + ;; (buffer-substring-no-properties (point-min) (point-max))))) ; e.g. Emacs 20 + (when (and (icicle-file-name-input-p) + (not (string= "" input)) ; Do nothing if user deleted everything in minibuffer. + (not leave-envvars-p)) + (let ((last-char "")) + (when (eq ?\$ (aref input (1- (length input)))) + (setq last-char "$" + input (substring input 0 (1- (length input))))) + (setq input + (save-match-data + (concat (subst-char-in-string ?\a ?\\ + (condition-case nil + (substitute-in-file-name + (icicle-subst-envvar-in-file-name + (subst-char-in-string ?\\ ?\a input 'in-place))) + (error input)) + 'in-place) + last-char))))) + input)) + +(defun icicle-minibuf-input-sans-dir (&optional input) + "Return the user input, except for a directory portion if reading a file." + (unless input (setq input (icicle-minibuf-input))) + (if (icicle-file-name-input-p) (icicle-file-name-nondirectory input) input)) + +(defun icicle-subst-envvar-in-file-name (input) + "Substitute any environment vars in INPUT by their values. +Unlike `substitute-in-file-name', this does not make any other +changes, such as switching `\\' to `/' on MS Windows." + (let ((pat1 "[^$]\\([$]{\\([^$}]+\\)}\\)") ; e.g. aaa${HOME} + (pat2 "^[$]{\\([^$}]+\\)}") ; e.g. ${HOME} + (pat3 "[^$]\\([$]\\([^$]+\\)\\)") ; e.g. aaa$HOME + (pat4 "^[$]\\([^$]+\\)")) ; e.g. $HOME + (cond ((string-match pat1 input) + (replace-regexp-in-string pat1 (or (getenv (match-string 2 input)) + (concat "$" (match-string 2 input))) + input t t 1)) + ((string-match pat2 input) + (replace-regexp-in-string pat2 (or (getenv (match-string 1 input)) + (concat "$" (match-string 1 input))) + input t t)) + ((string-match pat3 input) + (replace-regexp-in-string pat3 (or (getenv (match-string 2 input)) + (concat "$" (match-string 2 input))) + input t t 1)) + ((string-match pat4 input) + (replace-regexp-in-string pat4 (or (getenv (match-string 1 input)) + (concat "$" (match-string 1 input))) + input t t)) + (t input)))) + +;; Provide for Emacs 20. +;; +(unless (fboundp 'replace-regexp-in-string) + (defun replace-regexp-in-string (regexp rep string &optional + fixedcase literal subexp start) + "Replace all matches for REGEXP with REP in STRING. + +Return a new string containing the replacements. + +Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the +arguments with the same names of function `replace-match'. If START +is non-nil, start replacements at that index in STRING. + +REP is either a string used as the NEWTEXT arg of `replace-match' or a +function. If it is a function it is applied to each match to generate +the replacement passed to `replace-match'; the match-data at this +point are such that match 0 is the function's argument. + +To replace only the first match (if any), make REGEXP match up to \\' +and replace a sub-expression, e.g. + (replace-regexp-in-string \"\\\\(foo\\\\).*\\\\'\" \"bar\" \" foo foo\" nil nil 1) + => \" bar foo\" +" + + ;; To avoid excessive consing from multiple matches in long strings, + ;; don't just call `replace-match' continually. Walk down the + ;; string looking for matches of REGEXP and building up a (reversed) + ;; list MATCHES. This comprises segments of STRING which weren't + ;; matched interspersed with replacements for segments that were. + ;; [For a `large' number of replacements it's more efficient to + ;; operate in a temporary buffer; we can't tell from the function's + ;; args whether to choose the buffer-based implementation, though it + ;; might be reasonable to do so for long enough STRING.] + (let ((l (length string)) + (start (or start 0)) + matches str mb me) + (save-match-data + (while (and (< start l) (string-match regexp string start)) + (setq mb (match-beginning 0) + me (match-end 0)) + ;; If we matched the empty string, make sure we advance by one char + (when (= me mb) (setq me (min l (1+ mb)))) + ;; Generate a replacement for the matched substring. + ;; Operate only on the substring to minimize string consing. + ;; Set up match data for the substring for replacement; + ;; presumably this is likely to be faster than munging the + ;; match data directly in Lisp. + (string-match regexp (setq str (substring string mb me))) + (setq matches (cons (replace-match (if (stringp rep) + rep + (funcall rep (match-string 0 str))) + fixedcase literal str subexp) + (cons (substring string start mb) matches))) ; unmatched prefix + (setq start me)) + ;; Reconstruct a string from the pieces. + (setq matches (cons (substring string start l) matches)) ; leftover + (apply #'concat (nreverse matches)))))) + +(defun icicle-filter-wo-input (candidate) + "Filter completion (string) CANDIDATE using regexps and predicate. +If CANDIDATE passes the filtering, return CANDIDATE. Else return nil. + +In addition to filtering out empty-string candidates, these variables +are used for the filtering: + `icicle-must-match-regexp' + `icicle-must-not-match-regexp' + `icicle-must-pass-predicate' + +This filtering is in addition to and prior to matching user input. +Users do not see any candidates filtered out here. +This filtering does not affect proxy candidates or extra candidates." + (and (not (string= "" candidate)) ; Filter out empty strings. + (or (not icicle-must-match-regexp) + (save-match-data (string-match icicle-must-match-regexp candidate))) + (or (not icicle-must-not-match-regexp) + (not (save-match-data (string-match icicle-must-not-match-regexp candidate)))) + (or (not icicle-must-pass-predicate) (funcall icicle-must-pass-predicate candidate)) + candidate)) + +(defun icicle-complete-again-update (&optional no-display) + "Complete again and update completions list. +Update display too, if already shown and NO-DISPLAY is nil." + (setq icicle-completion-candidates + (condition-case nil + (funcall (case icicle-last-completion-command + ((icicle-prefix-complete icicle-prefix-complete-no-display + icicle-prefix-word-complete) + (if (icicle-file-name-input-p) + #'icicle-file-name-prefix-candidates + #'icicle-prefix-candidates)) + (t + (if (icicle-file-name-input-p) + #'icicle-file-name-apropos-candidates + #'icicle-apropos-candidates))) + icicle-current-input) + (error icicle-completion-candidates))) ; No change if completion error. + (when (and (get-buffer-window "*Completions*" 0) (not no-display)) + (icicle-display-candidates-in-Completions))) + +(defun icicle-msg-maybe-in-minibuffer (format-string &rest args) + "Display FORMAT-STRING as a message. +If called with the minibuffer inactive, use `message'. +Otherwise: + If `icicle-minibuffer-message-ok-p', then use `minibuffer-message'. + Else do nothing (no message display)." + (if (active-minibuffer-window) + (when icicle-minibuffer-message-ok-p + (save-selected-window + (select-window (minibuffer-window)) + (minibuffer-message (apply #'format (concat " [" format-string "]") args)))) + (apply #'message format-string args))) + +(defun icicle-delete-count (elt elts count) + "Delete by side effect the first COUNT occurrences of ELT from list ELTS. +This is like `delete', but it deletes only the first COUNT `equal' +occurrences." + (while (and elts (equal elt (car elts)) (>= (setq count (1- count)) 0)) + (setq elts (cdr elts))) + (let ((tail elts) + (nn count)) + (if (cdr tail) + (while (and (cdr tail) (> nn 0)) + (when (equal elt (cadr tail)) + (setq nn (1- nn)) + (setcdr tail (cddr tail))) + (setq tail (cdr tail))) + (when (and (equal elt (car tail)) (> count 0)) + (setq tail (cdr tail))))) ; Remove matching singleton. + elts) + +(defun icicle-remove-if (pred xs) + "A copy of list XS with no elements that satisfy predicate PRED." + (let ((result ())) + (dolist (x xs) (unless (funcall pred x) (push x result))) + (nreverse result))) + +(defun icicle-remove-if-not (pred xs) + "A copy of list XS with only elements that satisfy predicate PRED." + (let ((result ())) + (dolist (x xs) (when (funcall pred x) (push x result))) + (nreverse result))) + +(defun icicle-frames-on (buffer &optional frame) ; From `frames-on' in `frame-fns.el'. + "List of all live frames showing BUFFER (a buffer or its name). +The optional FRAME argument is as for function `get-buffer-window'." + (filtered-frame-list (function (lambda (fr) (get-buffer-window buffer fr))))) + +(defun icicle-candidate-set-1 (set-fn msg) + "Helper function for defining Icicle set commands. +SET-FN is the function to apply to the current and saved candidates. +MESSAGE is the confirmation message to display in the minibuffer." + (setq icicle-completion-candidates + (funcall set-fn icicle-completion-candidates icicle-saved-completion-candidates)) + (if (null icicle-completion-candidates) + (save-selected-window (select-window (minibuffer-window)) (minibuffer-message " [EMPTY SET]")) + (icicle-maybe-sort-and-strip-candidates) + (icicle-scroll-or-update-Completions msg))) + +(defun icicle-maybe-sort-and-strip-candidates () + "Sort `icicle-completion-candidates'. Strip ignored file names too." + (if (or (icicle-file-name-input-p) icicle-abs-file-candidates) ; File names: relative or absolute. + (setq icicle-completion-candidates + (icicle-strip-ignored-files-and-sort icicle-completion-candidates)) + (setq icicle-completion-candidates (icicle-maybe-sort-maybe-truncate + icicle-completion-candidates)))) + +(defun icicle-scroll-or-update-Completions (msg) + "Scroll *Completions* if this command was repeated; else update it." + (if (get-buffer-window "*Completions*" 0) + (if (eq last-command this-command) + ;; User repeated the command. Scroll window around. + (icicle-scroll-Completions) + ;; User did something else (e.g. changed input). Update the display. + (icicle-display-candidates-in-Completions) + (save-selected-window (select-window (minibuffer-window)) (minibuffer-message msg))) + ;; No window yet. Show window. + (icicle-display-candidates-in-Completions) + (save-selected-window (select-window (minibuffer-window)) (minibuffer-message msg)))) + +;; $$ No longer used. +(defun icicle-display-Completions () + "Display *Completions* buffer." + (let ((completions (all-completions "" minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag))) + (when (> (length icicle-completion-candidates) icicle-incremental-completion-threshold) + (message "Displaying completion candidates...")) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list (icicle-maybe-sort-maybe-truncate completions))))) + +(defun icicle-maybe-sort-maybe-truncate (cands) + "Return a copy of candidate list CANDS, maybe sorted, maybe truncated. +Sort according to `icicle-sort-comparer'. +Truncate according to `icicle-max-candidates'." + (let ((new-cands cands)) + (when icicle-sort-comparer (setq new-cands (icicle-reversible-sort new-cands))) + (when icicle-max-candidates + (let ((lighter (cadr (assoc 'icicle-mode minor-mode-alist))) + (regexp (concat (regexp-quote icicle-lighter-truncation) "$"))) + (cond ((and new-cands (< icicle-max-candidates ; Save total number before truncation + (setq icicle-nb-candidates-before-truncation (length new-cands)))) + (unless (string-match regexp lighter) + (icicle-clear-lighter 'not-truncated) + (add-to-list + 'minor-mode-alist `(icicle-mode ,(concat lighter icicle-lighter-truncation))))) + (new-cands + ;; Save total number before truncation in `icicle-nb-candidates-before-truncation'. + (setq icicle-nb-candidates-before-truncation (length new-cands)) + (when (string-match regexp lighter) + (icicle-clear-lighter 'truncated) + (add-to-list + 'minor-mode-alist + `(icicle-mode + ,(substring lighter 0 + (- (length lighter) (length icicle-lighter-truncation))))))))) + (setq new-cands (icicle-take icicle-max-candidates new-cands))) + new-cands)) + +(defun icicle-take (num xs) + "Return a copy of list XS but with only the first NUM items. +No error handling. NUM must be in the range 0 to (length XS)." + ;; Recursive version would be just this: + ;; (and xs (not (zerop num)) (cons (car xs) (icicle-take (1- num) (cdr xs))))) + (and xs (not (zerop num)) + (let ((new-xs ()) + (count 0)) + (catch 'icicle-take + (dolist (x xs) + (when (> (setq count (1+ count)) num) (throw 'icicle-take new-xs)) + (setq new-xs (cons x new-xs))) + new-xs)))) + +;; From `cl-seq.el', function `union', without keyword treatment. +;; Same as `simple-set-union' in `misc-fns.el'. +(defun icicle-set-union (list1 list2) + "Combine LIST1 and LIST2 using a set-union operation. +The result list contains all items that appear in either LIST1 or +LIST2. This is a non-destructive function; it copies the data if +necessary." + (cond ((null list1) list2) + ((null list2) list1) + ((equal list1 list2) list1) + (t + (unless (>= (length list1) (length list2)) + (setq list1 (prog1 list2 (setq list2 list1)))) ; Swap them. + (while list2 + (unless (member (car list2) list1) (setq list1 (cons (car list2) list1))) + (setq list2 (cdr list2))) + list1))) + +;; From `cl-seq.el', function `intersection', without keyword treatment. +;; Same as `simple-set-intersection' in `misc-fns.el'. +(defun icicle-set-intersection (list1 list2) + "Set intersection of lists LIST1 and LIST2. +This is a non-destructive operation: it copies the data if necessary." + (and list1 list2 + (if (equal list1 list2) + list1 + (let ((result ())) + (unless (>= (length list1) (length list2)) + (setq list1 (prog1 list2 (setq list2 list1)))) ; Swap them. + (while list2 + (when (member (car list2) list1) (setq result (cons (car list2) result))) + (setq list2 (cdr list2))) + result)))) + +;; From `cl-seq.el', function `set-difference', without keyword treatment. +;; Same as `simple-set-difference' in `misc-fns.el'. +(defun icicle-set-difference (list1 list2) + "Combine LIST1 and LIST2 using a set-difference operation. +The result list contains all items that appear in LIST1 but not LIST2. +This is non-destructive; it makes a copy of the data if necessary, to +avoid corrupting the original LIST1 and LIST2." + (if (or (null list1) (null list2)) list1 + (let ((result ())) + (while list1 + (unless (member (car list1) list2) (setq result (cons (car list1) result))) + (setq list1 (cdr list1))) + result))) + +(defun icicle-get-candidates-from-saved-set (set-name &optional dont-expand-filesets-p) + "Return the saved set of completion candidates named SET-NAME. +SET-NAME can be the name of either an Icicles saved completion set or, + if `icicle-filesets-as-saved-completion-sets-flag', an Emacs fileset. +If optional arg DONT-EXPAND-FILESETS-P is non-nil, then don't expand + fileset entries in a saved completion set. Instead, return them as +string candidates." + (let ((cache-file (cdr (assoc set-name icicle-saved-completion-sets))) + fst) + (cond ((and (not cache-file) ; Fileset - get explicit file list. + icicle-filesets-as-saved-completion-sets-flag (featurep 'filesets) filesets-data + (setq fst (filesets-get-fileset-from-name set-name))) + (icicle-explicit-saved-completion-candidates (list fst))) + ((not cache-file) (error "No such saved set: `%s'" set-name)) + ((not (icicle-file-readable-p cache-file)) (error "Cannot read cache file `%s'" cache-file)) + (t ; Icicles saved completion set. + (let ((list-buf (find-file-noselect cache-file 'nowarn)) + (cands-read ()) + (candidates ())) + (message "Retrieving saved candidates from `%s'..." cache-file) + (unwind-protect + (condition-case err + (when (listp (setq cands-read (read list-buf))) + (message "Set `%s' read from file `%s'" set-name cache-file)) + (error (error "Could not read cache file. %S" (error-message-string err)))) + (icicle-kill-a-buffer list-buf)) + (unless cands-read (error "No completion candidates in file `%s'" cache-file)) + (dolist (cand (nreverse cands-read)) ; Convert saved to displayable candidates. + (if (not (icicle-saved-fileset-p cand)) + (push (icicle-displayable-cand-from-saved-set cand) candidates) + (condition-case err + (require 'filesets) + (error "Set `%s' includes a fileset, but cannot load `fileset.el'" set-name)) + (filesets-init) + (if dont-expand-filesets-p + (push cand candidates) + (setq candidates + (append (mapcar #'icicle-displayable-cand-from-saved-set + (icicle-get-candidates-from-saved-set (cadr cand))) + candidates))))) + candidates))))) + +(defun icicle-explicit-saved-completion-candidates (&optional saved-set) + "Return the list of files represented by a saved completion set. +Any fileset entries in the saved set are expanded to an explicit list +of file names. +Optional arg SAVED-SET is the Icicles saved completion set to use. + It can be the set itself or its name. + If SAVED-SET is nil, use `icicle-saved-completion-candidates'." + (unless saved-set (setq saved-set icicle-saved-completion-candidates)) + (when (stringp saved-set) (setq saved-set (icicle-get-candidates-from-saved-set saved-set))) + (let ((files ()) + (mode nil)) + (dolist (entry saved-set) + (cond ((atom entry) (push entry files)) + ((and (featurep 'filesets) + (or (setq mode (filesets-entry-mode entry)) ; ("my-fs" (:files "a" "b")) + (setq entry (cons "dummy" entry) ; (:files "a" "b") + mode (filesets-entry-mode entry)))) + (message "Gathering file names...") + (dolist (file (filesets-get-filelist entry mode)) (push file files))) + (t (error "Bad `icicle-saved-completion-candidates' entry: `%S'" entry)))) + (nreverse files))) + +(defun icicle-saved-fileset-p (entry) + "Return non-nil if ENTRY is a fileset entry in a saved completion set. +ENTRY is a list whose car is `:fileset' - it is not a fileset name." + (and (consp entry) (eq (car entry) ':fileset))) + +(defun icicle-displayable-cand-from-saved-set (cand) + "Return display candidate for saved candidate CAND. +If CAND is an atom, then return it as is." + (let ((cand-w-mrkrs (icicle-readable-to-markers cand))) + (if (atom cand-w-mrkrs) + cand-w-mrkrs + (let ((icicle-whole-candidate-as-text-prop-p t)) + (car (icicle-mctized-full-candidate cand-w-mrkrs)))))) + +(defun icicle-readable-to-markers (cand) + "Convert (deserialize) Lisp-readable representation CAND of candidate. +A Lisp-readable candidate uses the following to represent a marker: + (icicle-file-marker FILE-NAME MARKER-POSITION) +or (icicle-marker BUFFER-NAME MARKER-POSITION)" + (if (and (consp cand) (consp (cdr cand)) (consp (cddr cand)) (null (cdr (cddr cand))) + (memq (car cand) '(icicle-file-marker icicle-marker))) + (let ((file-or-buf (cadr cand)) + (pos (car (cddr cand))) + mrker buf) + (if (eq (car cand) 'icicle-file-marker) + (let ((buf (find-file-noselect file-or-buf))) + (unless buf (error "Cannot find file `%s'" file-or-buf)) + (setq file-or-buf buf)) + (unless (get-buffer file-or-buf) (error "You must first visit buffer `%s'" file-or-buf))) + (set-marker (setq mrker (make-marker)) pos (get-buffer file-or-buf)) + mrker) + (if (consp cand) + (cons (icicle-readable-to-markers (car cand)) (icicle-readable-to-markers (cdr cand))) + cand))) + + +;; REPLACE ORIGINAL `filesets-get-filelist' in `filesets.el'. +;; The original is bugged (I filed Emacs bug #976 on 2008-09-13). +;; For `:tree': +;; * First get the tree from the ENTRY. +;; * Return all matching files under the directory, including in subdirs up to +;; `filesets-tree-max-level' for the entry. +;; +(eval-after-load 'filesets + '(defun filesets-get-filelist (entry &optional mode event) + "Get all files for fileset ENTRY. +Assume MODE (see `filesets-entry-mode'), if provided." + (let* ((mode (or mode (filesets-entry-mode entry))) + (fl (case mode + ((:files) (filesets-entry-get-files entry)) + ((:file) (list (filesets-entry-get-file entry))) + ((:ingroup) (let ((entry (expand-file-name + (if (stringp entry) + entry + (filesets-entry-get-master entry))))) + (cons entry (filesets-ingroup-cache-get entry)))) + ((:tree) (let* ((dirpatt (filesets-entry-get-tree entry)) ; Added this line. + (dir (nth 0 dirpatt)) ; Use DIRPATT, not ENTRY. + (patt (nth 1 dirpatt)) ; Use DIRPATT, not ENTRY. + (depth (or (filesets-entry-get-tree-max-level entry) + filesets-tree-max-level))) + (icicle-filesets-files-under 0 depth entry dir patt + (and icicle-mode + (icicle-file-name-input-p))))) + ((:pattern) (let ((dirpatt (filesets-entry-get-pattern entry))) + (if dirpatt + (let ((dir (filesets-entry-get-pattern--dir dirpatt)) + (patt (filesets-entry-get-pattern--pattern dirpatt))) + ;;(filesets-message 3 "Filesets: scanning %s" dirpatt) + (filesets-directory-files dir patt ':files t)) + ;; (message "Filesets: malformed entry: %s" entry))))))) + (filesets-error 'error "Filesets: malformed entry: " entry))))))) + (filesets-filter-list fl (lambda (file) (not (filesets-filetype-property file event))))))) + +(defun icicle-filesets-files-under (level depth entry dir patt &optional relativep) + "Files under DIR that match PATT. +LEVEL is the current level under DIR. +DEPTH is the maximal tree scanning depth for ENTRY. +ENTRY is a fileset. +DIR is a directory. +PATT is a regexp that included file names must match. +RELATIVEP non-nil means use relative file names." + (and (or (= depth 0) (< level depth)) + (let* ((dir (file-name-as-directory dir)) + (files-here (filesets-directory-files dir patt nil (not relativep) + (filesets-entry-get-filter-dirs-flag entry))) + (subdirs (filesets-filter-dir-names files-here)) ; Subdirectories at this level. + (files (filesets-filter-dir-names ; Remove directory names. + (apply #'append + files-here + (mapcar (lambda (subdir) ; Files below this level. + (let* ((subdir (file-name-as-directory subdir)) + (full-subdir (concat dir subdir))) + (icicle-filesets-files-under + (+ level 1) depth entry full-subdir patt))) + subdirs)) + t))) + files))) + +;; Note that initial and trailing spaces will not be noticeable. That's OK. +(defun icicle-highlight-complete-input () + "Highlight minibuffer input, showing that it is a sole completion. +Overlay `icicle-complete-input-overlay' is created with `match' face, +unless it exists." + (let ((case-fold-search + ;; Don't bother with buffer completion and `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case)) + input-start-position) + (save-excursion + (goto-char (icicle-minibuffer-prompt-end)) + (setq input-start-position (point)) + (when (and (icicle-file-name-input-p) insert-default-directory) + (search-forward (icicle-file-name-directory-w-default + (icicle-input-from-minibuffer 'leave-envvars)) + nil t) + (setq input-start-position (point))) ; Skip directory. + (if icicle-complete-input-overlay ; Don't recreate if exists. + (move-overlay icicle-complete-input-overlay + input-start-position (point-max) (current-buffer)) + (setq icicle-complete-input-overlay (make-overlay input-start-position (point-max))) + (overlay-put icicle-complete-input-overlay 'face 'icicle-complete-input))))) + +(defun icicle-call-then-update-Completions (fn &rest args) + "Call FN with ARGS, then update *Completions* with input matches." + (save-match-data + (apply fn args) + ;;$$$ (let ((tramp-completion-mode t)) ; Fool Tramp into thinking it is in completion mode. + (setq icicle-current-input (icicle-input-from-minibuffer) + icicle-input-fail-pos nil) + (setq icicle-last-input nil) ; $$$$$$$$ So icicle-save-or-restore-input => recompute candidates. + (when (overlayp icicle-complete-input-overlay) (delete-overlay icicle-complete-input-overlay)) + (icicle-highlight-initial-whitespace icicle-current-input) + (if (< (length icicle-current-input) icicle-Completions-display-min-input-chars) + (save-selected-window (icicle-remove-Completions-window)) + ;; `icicle-highlight-input-noncompletion' return value saves call to `icicle-file-remote-p'. + (let ((remote-test (icicle-highlight-input-noncompletion))) + ;; If ALL of the following are true, then update *Completions* (complete again): + ;; * incremental completion, + ;; * `icicle-highlight-input-noncompletion' determined that it's a remote or local file + ;; or we're not completing file names + ;; or user said not to test for remote file names + ;; or we check now and it's not a remote file, + ;; * *Completions* is already displayed or `icicle-incremental-completion-p' is not t, + ;; * there are not too many candidates or we have waited the full delay. + (when (and icicle-incremental-completion-p + (or (memq remote-test '(file-local-p file-remote-p)) + (not (icicle-file-name-input-p)) + (not icicle-test-for-remote-files-flag) + ;; Might still be remote if `icicle-highlight-input-completion-failure' + ;; is `always' or `explicit-remote' - cannot tell from `remote-test'. + (and (not (eq remote-test 'file-local-p)) ; We don't know if it's local. + (not (icicle-file-remote-p icicle-current-input)))) + (or (get-buffer-window "*Completions*" 0) ; Already displayed. + ;; If value is, say, `always' or `display' then update anyway. + (not (eq t icicle-incremental-completion-p))) + (let ((len (length icicle-completion-candidates))) + (or (and (> len 1) (> icicle-incremental-completion-threshold len)) ; Not many + (sit-for icicle-incremental-completion-delay)))) ; Wait, unless input. + (let ((icicle-edit-update-p t)) + (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))))) + (setq mark-active nil))) + +(defun icicle-highlight-input-noncompletion () + "Highlight the portion of the current input that does not complete. +See the doc strings of `icicle-highlight-input-completion-failure' and +`icicle-test-for-remote-files-flag' for information about when this +highlighting occurs. + +If we know the input is a remote file name, return `file-remote-p'. +If we know it is a local file name, return `file-local-p'. +If part of the input matches candidates, return that matching part. +If no highlighting was attempted, return nil." + (let ((input-start (icicle-minibuffer-prompt-end)) + (input (icicle-input-from-minibuffer)) + (file-local-p nil)) + (cond + ;; No input. + ((string= "" input) "") ; Return string: highlighting attempted. + + ;; One of these: pending input, + ;; not highlighting, + ;; highlighting `explicit-*' but not explicitly completing (TAB/S-TAB), + ;; highlighting `implicit-*' but not incrementally completing, + ;; highlighting `*-strict' but not strict completion (and testing remote files) + ;; there are more candidates than the threshold for highlighting. + ((or (input-pending-p) + (not icicle-highlight-input-completion-failure) + (and (not (get this-command 'icicle-completing-command)) + (memq icicle-highlight-input-completion-failure + '(explicit explicit-strict explicit-remote))) + (and (not icicle-incremental-completion-flag) + (memq icicle-highlight-input-completion-failure '(implicit implicit-strict))) + (and (not (icicle-require-match-p)) + icicle-test-for-remote-files-flag ; nil flag ignores strict setting for highlighting + (memq icicle-highlight-input-completion-failure '(implicit-strict explicit-strict))) + (let ((len (length icicle-completion-candidates))) + (and (> len 1) (> len icicle-highlight-input-completion-failure-threshold)))) + nil) ; Return nil: no highlighting attempted. + + ;; Cursor is to the left of the last mismatch position. + ((and icicle-input-fail-pos (< (point) icicle-input-fail-pos)) + (setq icicle-input-fail-pos nil) ; Reset failure position. + ;; Remove vestigial highlighting on matched part (e.g. from another completion mode). + (when (and (> (or icicle-input-fail-pos (point-max)) input-start) + (overlayp icicle-input-completion-fail-overlay)) + (delete-overlay icicle-input-completion-fail-overlay)) + nil) ; Return nil: no highlighting attempted. + + ;; Remote file-name input, user didn't say to skip testing for remote files, + ;; and highlighting is not `always' or `explicit-remote'. + ((and (icicle-file-name-input-p) + (not (memq icicle-highlight-input-completion-failure '(always explicit-remote))) + icicle-test-for-remote-files-flag + (let ((remotep (icicle-file-remote-p input))) + (unless remotep (setq file-local-p 'file-local-p)) ; We know it's local, so save that. + remotep)) + ;; Do the same as for the previous, except return indication that we know it is a remote file. + (setq icicle-input-fail-pos nil) + + (when (and (> (or icicle-input-fail-pos (point-max)) input-start) + (overlayp icicle-input-completion-fail-overlay)) + (delete-overlay icicle-input-completion-fail-overlay)) + 'file-remote-p) ; Return `file-remote-p': we know it is a remote file. + + ((and icicle-highlight-input-completion-failure-delay + (progn (message nil) ; Clear any message, e.g. "Computing completion candidates..." + (sit-for icicle-highlight-input-completion-failure-delay))) + ;; First, a quick check through last two chars. + ;; If last succeeds, then done. + ;; If last fails and next-to-last succeeds, then done. + ;; Otherwise, highlight the others using a binary search. + (let ((matchp (icicle-any-candidates-p input))) ; Entire input, through last char. + (unless matchp + ;; Record failure position and highlight last char. + (setq icicle-input-fail-pos (if icicle-input-fail-pos + (min icicle-input-fail-pos (point-max)) + (point-max))) + + (cond (icicle-input-completion-fail-overlay ; Don't recreate if exists. + (move-overlay icicle-input-completion-fail-overlay + (1- icicle-input-fail-pos) (point-max)) + (overlay-put icicle-input-completion-fail-overlay + 'face (if (icicle-require-match-p) + 'icicle-input-completion-fail + 'icicle-input-completion-fail-lax))) + (t + (setq icicle-input-completion-fail-overlay (make-overlay (1- icicle-input-fail-pos) + (point-max))) + (overlay-put icicle-input-completion-fail-overlay + 'face (if (icicle-require-match-p) + 'icicle-input-completion-fail + 'icicle-input-completion-fail-lax)))) + ;; See if next-to-last char gives a match. Typical use case: mistyping a char at end. + (setq input (substring input 0 (1- (length input)))) + (unless (string= "" input) + (setq matchp (icicle-any-candidates-p input)) + ;; If more than just the last char fails, highlight the others using binary search. + (unless matchp (icicle-highlight-input-noncompletion-rest))))) + ;; Highlighting attempted, so return non-nil. If we know it's local, return `file-local-p'. + ;; If we don't know that, return the part of INPUT that matches. + (or file-local-p input)) + (t nil)))) ; Return nil: no highlighting attempted. + +(defun icicle-highlight-input-noncompletion-rest () + "Helper function for `icicle-highlight-input-noncompletion'." + (let* ((input-start (icicle-minibuffer-prompt-end)) + (pos (1- icicle-input-fail-pos)) + (delta pos) + (last-pos input-start) + (matchp nil) + input) + (while (and (> pos input-start) (or (not matchp) (< pos icicle-input-fail-pos))) ; Binary search. + (setq input (buffer-substring input-start pos) + delta (max 1 (/ (abs (- pos last-pos)) 2)) + matchp (icicle-any-candidates-p input)) + ;; $$$$$$ Emacs BUG (prefix completion): c:/foo/$$ does not highlight the `$$', because + ;; (try-completion "c:/foo/$" 'read-file-name-internal "c:/foo/") returns "c:/foo/$". + ;; (However, c:/foo/$ highlights the `$' correctly.) + (unless matchp (setq icicle-input-fail-pos (min pos icicle-input-fail-pos))) + (setq last-pos pos + pos (if matchp (+ pos delta) (- pos delta)))) + (unless (or (< pos input-start) (> pos icicle-input-fail-pos)) + (cond (icicle-input-completion-fail-overlay ; Don't recreate if exists. + (move-overlay icicle-input-completion-fail-overlay (1- icicle-input-fail-pos) (point-max)) + (overlay-put icicle-input-completion-fail-overlay + 'face (if (icicle-require-match-p) + 'icicle-input-completion-fail + 'icicle-input-completion-fail-lax))) + (t + (setq icicle-input-completion-fail-overlay (make-overlay (1- icicle-input-fail-pos) + (point-max))) + (overlay-put icicle-input-completion-fail-overlay + 'face (if (icicle-require-match-p) + 'icicle-input-completion-fail + 'icicle-input-completion-fail-lax))))) + input)) ; Return part of INPUT that matches. + +(defun icicle-ms-windows-NET-USE (drive) + "Return result of calling MS Windows `NET USE' command on DRIVE. +DRIVE is a Windows drive name, such as `f:'. +A return value of zero means DRIVE is a mapped network drive." + (if (and (fboundp 'hash-table-p) (hash-table-p icicle-ms-windows-drive-hash)) + (let ((lookup (gethash drive icicle-ms-windows-drive-hash 'no-assoc))) + (if (eq lookup 'no-assoc) + (puthash drive (call-process shell-file-name nil nil nil shell-command-switch + (concat "NET USE " drive)) icicle-ms-windows-drive-hash) + lookup)) + ;; Don't bother to hash for Emacs 20, 21, unless `cl.el' happens to be loaded. + (call-process shell-file-name nil nil nil shell-command-switch (concat "NET USE " drive)))) + +;; $$$$$ TRYING WITHOUT `save-match-data', but probably need it. +(defun icicle-file-remote-p (file) + "Non-nil means FILE is likely to name a file on a remote system. +For MS Windows, this includes a file on a mapped network drive. +Otherwise, this uses `ffap-file-remote-p' and `file-remote-p' (if +defined)." + ;; $$$$ (save-match-data ; $$$$$ IS THIS NEEDED? + (if (and (eq system-type 'windows-nt) + (let ((case-fold-search t)) (string-match "\\`\\([a-z]:\\)" file))) + (eq 0 (condition-case nil + (icicle-ms-windows-NET-USE (match-string 1 file)) + (error nil))) + (or (and (fboundp 'ffap-file-remote-p) (ffap-file-remote-p file)) + (and (fboundp 'file-remote-p) (file-remote-p file))))) + +;;; $$$$$ Should these `*-any-*' fns call `icicle-transform-candidates'? For now, no, to save time. +(defun icicle-any-candidates-p (input) + "Return non-nil if there is any completion for INPUT, nil otherwise." + (condition-case nil + (funcall (case icicle-current-completion-mode + (apropos (if (icicle-file-name-input-p) + #'icicle-apropos-any-file-name-candidates-p + #'icicle-apropos-any-candidates-p)) + (otherwise (if (icicle-file-name-input-p) + #'icicle-prefix-any-file-name-candidates-p + #'icicle-prefix-any-candidates-p))) + input) + (error nil))) + +(defun icicle-prefix-any-candidates-p (input) + "Return non-nil if current partial INPUT has prefix completions." + (let ((minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate)) + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-try-completion input minibuffer-completion-table + minibuffer-completion-predicate + ;; $$$$$$ (- (point) (field-beginning))) + (length input)) + (try-completion input minibuffer-completion-table minibuffer-completion-predicate)))) + +(defun icicle-prefix-any-file-name-candidates-p (input) + "Return non-nil if partial file-name INPUT has prefix completions." + (let* ((minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate)) + (if (icicle-not-basic-prefix-completion-p) + (icicle-completion-try-completion input minibuffer-completion-table + minibuffer-completion-predicate (length input)) + (try-completion input minibuffer-completion-table default-directory)))) + +(defun icicle-apropos-any-candidates-p (input) + "Return non-nil if current partial INPUT has apropos completions." + (when icicle-regexp-quote-flag (setq input (regexp-quote input))) + (let* ((minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate) + (all + (all-completions "" minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag))) + (catch 'icicle-apropos-any-candidates-p + (dolist (cand all) + ;; Assume no match if error - e.g. due to `string-match' with binary data in Emacs 20. + ;; Do this everywhere we call `icicle-apropos-complete-match-fn'. + (when (condition-case nil (funcall icicle-apropos-complete-match-fn input cand) (error nil)) + (throw 'icicle-apropos-any-candidates-p cand))) + nil))) + +(defun icicle-apropos-any-file-name-candidates-p (input) + "Return non-nil if partial file-name INPUT has apropos completions." + (when (and input (not (string= "" input)) (eq (aref input (1- (length input))) ?\/)) + (setq input (substring input 0 (1- (length input))))) ; So we don't non-match highlight the /. + (let* ((default-directory (icicle-file-name-directory-w-default input)) + (minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate)) + (setq input (or (icicle-file-name-nondirectory input) "")) + (condition-case nil + (progn (when icicle-regexp-quote-flag (setq input (regexp-quote input))) + (let ((candidates (all-completions "" minibuffer-completion-table default-directory + icicle-ignore-space-prefix-flag)) + (case-fold-search (if (boundp 'read-file-name-completion-ignore-case) + read-file-name-completion-ignore-case + completion-ignore-case))) + (catch 'icicle-apropos-any-file-name-candidates-p + (dolist (cand candidates) + (when (if (member cand '("../" "./")) + (member input '(".." ".")) ; Prevent "" from matching "../" + (and (or (not icicle-apropos-complete-match-fn) + ;; Assume no match if error - e.g. due to `string-match' with + ;; binary data in Emacs 20. Do this everywhere we call + ;; `icicle-apropos-complete-match-fn'. + (condition-case nil + (funcall icicle-apropos-complete-match-fn input cand) + (error nil))))) + (throw 'icicle-apropos-any-file-name-candidates-p cand))) + nil))) + (quit (top-level))))) ; Let `C-g' stop it. + +(defun icicle-clear-minibuffer () + "Delete all user input in the minibuffer. +This must be called from the minibuffer." + (if (fboundp 'delete-minibuffer-contents) (delete-minibuffer-contents) (erase-buffer))) + +;; Borrowed from `ps-print.el' +(defun icicle-remove-duplicates (list) + "Copy of LIST with duplicate elements removed. Tested with `equal'." + (let ((tail list) + new) + (while tail + (unless (member (car tail) new) (push (car tail) new)) + (pop tail)) + (nreverse new))) + +(defun icicle-remove-dups-if-extras (list) + "`icicle-remove-duplicates' if `icicle-extra-candidates' is non-nil. +If `icicle-extra-candidates' is nil, then return LIST. + +Note: When you use this as the value of `icicle-transform-function', +be aware that during completion and before applying this function, +`icicle-extra-candidates' is redefined locally by removing its +candidates that don't match the current input. So this function then +has the effect of removing any duplicates that match the input. If +there are no such matching candidates, then LIST is returned." + (if icicle-extra-candidates + (let ((tail list) + new) + (while tail + (unless (member (car tail) new) (push (car tail) new)) + (pop tail)) + (nreverse new)) + list)) + +(defun icicle-file-readable-p (file) + "Return non-nil if FILE (a string) names a readable file." + (and (not (string= "" file)) (file-readable-p file) (not (file-directory-p file)))) + +(defun icicle-file-writable-p (file) + "Return non-nil if FILE (a string) names a writable file." + (and (not (string= "" file)) (file-writable-p file) (not (file-directory-p file)))) + +(defun icicle-files-within (file-list accum &optional no-symlinks-p) + "List of all readable files in FILE-LIST. +Accessible directories in FILE-LIST are processed recursively to +include their files and the files in their subdirectories. + +Optional arg NO-SYMLINKS-P non-nil means do not follow symbolic links. + +The list of files is accumulated in ACCUM, which is used for recursive +calls." + (let ((dirs-done ())) + (icicle-files-within-1 file-list accum no-symlinks-p))) + +(defun icicle-files-within-1 (file-list accum no-symlinks-p) + "Helper for `icicle-files-within'." + (let ((res accum) + file) + (while file-list + (setq file (car file-list)) + (unless (and no-symlinks-p (file-symlink-p file)) + (if (file-directory-p file) + ;; Skip directory if ignored, already treated, or inaccessible. + (when (and (not (member (file-name-nondirectory file) icicle-ignored-directories)) + (not (member (file-truename file) dirs-done)) ; `dirs-done' is free here. + (file-accessible-directory-p file)) + (setq res (icicle-files-within-1 (directory-files file 'full icicle-re-no-dot) + res + no-symlinks-p)) + (push (file-truename file) dirs-done)) + (when (file-readable-p file) (setq res (cons file res))))) + (pop file-list)) + res)) + +(defun icicle-delete-whitespace-from-string (string &optional from to) + "Remove whitespace from substring of STRING from FROM to TO. +If FROM is nil, then start at the beginning of STRING (FROM = 0). +If TO is nil, then end at the end of STRING (TO = length of STRING). +FROM and TO are zero-based indexes into STRING. +Character FROM is affected (possibly deleted). Character TO is not." + (setq from (or from 0) + to (or to (length string))) + (with-temp-buffer + (insert string) + (goto-char (+ from (point-min))) + (let ((count from) + char) + (while (and (not (eobp)) (< count to)) + (setq char (char-after)) + (if (memq char '(?\ ?\t ?\n)) (delete-char 1) (forward-char 1)) + (setq count (1+ count))) + (buffer-string)))) + +(defun icicle-barf-if-outside-minibuffer () + "Raise an error if `this-command' is called outside the minibuffer." + (unless (eq (current-buffer) (window-buffer (minibuffer-window))) + (error "Command `%s' must be called from the minibuffer" this-command))) + +(defun icicle-barf-if-outside-Completions () + "Raise an error if `this-command' is called outside buffer *Completions*." + (unless (eq (current-buffer) (get-buffer "*Completions*")) + (error "Command `%s' must be called from *Completions* buffer" this-command))) + +(defun icicle-barf-if-outside-Completions-and-minibuffer () + "Error if `this-command' called outside *Completions* and minibuffer." + (unless (or (eq (current-buffer) (window-buffer (minibuffer-window))) + (eq (current-buffer) (get-buffer "*Completions*"))) + (error "Command `%s' must be called from *Completions* buffer or the minibuffer" this-command))) + +(defun icicle-command-abbrev-save () + "Save `icicle-command-abbrev-alist'. Used on `kill-emacs-hook'." + (condition-case err ; Don't raise an error, since it's on `kill-emacs-hook. + (let ((sav (get 'icicle-command-abbrev-alist 'saved-value))) + (unless (and (or (null sav) + (and (consp sav) (consp (car sav)) (consp (cdar sav)) + (consp (car (cdar sav))))) + (equal icicle-command-abbrev-alist (car (cdar sav)))) + (funcall icicle-customize-save-variable-function 'icicle-command-abbrev-alist + icicle-command-abbrev-alist))) + (error (message "Cannot save new value of `icicle-command-abbrev-alist'") (sleep-for 3)))) + +(defun icicle-expand-file-name (input dir) + "Expand file-name INPUT in directory DIR. +Similar to `expand-file-name', except: + + - If INPUT does not end in a slash, and DIR/INPUT is a directory, + a trailing slash is added. + + - If INPUT ends in a slash, but DIR/INPUT is not a directory, then + the trailing slash is removed." + (let ((expanded-input (directory-file-name (expand-file-name input dir)))) + ;; Add trailing slash if input is a directory. + (when (file-directory-p expanded-input) + (setq expanded-input (file-name-as-directory expanded-input))) + expanded-input)) + +(defun icicle-start-of-candidates-in-Completions () + "Return buffer position of the first candidate in *Completions*." + (save-excursion + (goto-char (point-min)) + (forward-line (if icicle-show-Completions-help-flag 2 1)) + (point))) + +(defun icicle-key-description (keys &optional no-angles) + "`key-description', but non-nil NO-ANGLES means use no angle brackets." + (let ((result (key-description keys))) + (when no-angles ; Assume space separates angled keys. + (setq result (replace-regexp-in-string "<\\([^>]+\\)>" "\\1" result 'fixed-case))) + result)) + +;; $$ Not used. +;; (defun icicle-alist-delete-all (key alist &optional test) +;; "Delete from ALIST all elements whose car is the same as KEY. +;; Optional arg TEST is the equality test to use. If nil, `eq' is used. +;; Return the modified alist. +;; Elements of ALIST that are not conses are ignored." +;; (setq test (or test #'eq)) +;; (while (and (consp (car alist)) (funcall test (car (car alist)) key)) +;; (setq alist (cdr alist))) +;; (let ((tail alist) tail-cdr) +;; (while (setq tail-cdr (cdr tail)) +;; (if (and (consp (car tail-cdr)) (funcall test (car (car tail-cdr)) key)) +;; (setcdr tail (cdr tail-cdr)) +;; (setq tail tail-cdr)))) +;; alist) + +;; Standard Emacs 21+ function, defined here for Emacs 20. +(unless (fboundp 'assq-delete-all) + (defun assq-delete-all (key alist) + "Delete from ALIST all elements whose car is `eq' to KEY. +Return the modified alist. +Elements of ALIST that are not conses are ignored." + (while (and (consp (car alist)) (eq (car (car alist)) key)) (setq alist (cdr alist))) + (let ((tail alist) tail-cdr) + (while (setq tail-cdr (cdr tail)) + (if (and (consp (car tail-cdr)) (eq (car (car tail-cdr)) key)) + (setcdr tail (cdr tail-cdr)) + (setq tail tail-cdr)))) + alist)) + +(defun icicle-assoc-delete-all (key alist) + "Delete from ALIST all elements whose car is `equal' to KEY. +Return the modified alist. +Elements of ALIST that are not conses are ignored." + (while (and (consp (car alist)) (equal (car (car alist)) key)) + (setq alist (cdr alist))) + (let ((tail alist) tail-cdr) + (while (setq tail-cdr (cdr tail)) + (if (and (consp (car tail-cdr)) (equal (car (car tail-cdr)) key)) + (setcdr tail (cdr tail-cdr)) + (setq tail tail-cdr)))) + alist) + +(defun icicle-first-N (n list) + "Return a new list of at most the N first elements of LIST." + (let ((firstN ())) + (while (and list (> n 0)) + (push (car list) firstN) + (setq n (1- n) + list (cdr list))) + (setq firstN (nreverse firstN)))) + +(defun icicle-abbreviate-or-expand-file-name (filename &optional dir) + "Expand FILENAME, and abbreviate it if `icicle-use-~-for-home-dir-flag'. +If FILENAME is not absolute, call `expand-file-name' to make it absolute. +If `icicle-use-~-for-home-dir-flag', call `abbreviate-file-name'. + +If DIR is absolute, pass it to `expand-file-name'. Otherwise, ignore +it (treat it as nil)." + (unless (file-name-absolute-p filename) + (when (and dir (not (file-name-absolute-p dir))) (setq dir nil)) ; Don't use a relative dir. + (setq filename (expand-file-name filename dir))) + (if icicle-use-~-for-home-dir-flag (abbreviate-file-name filename) filename)) + +(defun icicle-reversible-sort (list &optional key) + "`sort' LIST using `icicle-sort-comparer'. +Reverse the result if `icicle-reverse-sort-p' is non-nil. +If `icicle-sort-comparer' is a cons (other than a lambda form), then + use `icicle-multi-sort' as the sort predicate. +Otherwise, use `icicle-sort-comparer' as the sort predicate. + +Optional arg KEY is a selector function to apply to each item to be be +compared. If nil, then the entire item is used." + ;;$$ (when (and icicle-edit-update-p icicle-completion-candidates + ;; (> (length icicle-completion-candidates) icicle-incremental-completion-threshold)) + ;; (message "Sorting candidates...")) + (unless key (setq key 'identity)) + (let ((sort-fn (and icicle-sort-comparer + (lambda (s1 s2) + (when icicle-transform-before-sort-p + (setq s1 (icicle-transform-multi-completion s1) + s2 (icicle-transform-multi-completion s2))) + ;; If we have an inappropriate sort order, get rid of it. This can happen if + ;; the user chooses a sort appropriate to one kind of candidate and then + ;; tries completion for a different kind of candidate. + (condition-case nil + (and icicle-sort-comparer ; nil in case of error earlier in list. + (if (and (not (functionp icicle-sort-comparer)) + (consp icicle-sort-comparer)) + (icicle-multi-sort (funcall key s1) (funcall key s2)) + (funcall icicle-sort-comparer (funcall key s1) (funcall key s2)))) + (error (message "Inappropriate sort order - reverting to unsorted") + (sit-for 1) + (setq icicle-sort-comparer nil) + nil)))))) + (when sort-fn + (setq list (sort list (if icicle-reverse-sort-p + (lambda (a b) (not (funcall sort-fn a b))) + sort-fn))))) + list) + +;; Essentially the same as `bmkp-multi-sort'. +(defun icicle-multi-sort (s1 s2) + "Try predicates in `icicle-sort-comparer', in order, until one decides. +The (binary) predicates are applied to S1 and S2. +See the description of `icicle-sort-comparer'. +If `icicle-reverse-multi-sort-p' is non-nil, then reverse the order +for using multi-sorting predicates." + (let ((preds (car icicle-sort-comparer)) + (final-pred (cadr icicle-sort-comparer)) + (result nil)) + (when icicle-reverse-multi-sort-p (setq preds (reverse preds))) + (catch 'icicle-multi-sort + (dolist (pred preds) + (setq result (funcall pred s1 s2)) + (when (consp result) + (when icicle-reverse-multi-sort-p (setq result (list (not (car result))))) + (throw 'icicle-multi-sort (car result)))) + (and final-pred (if icicle-reverse-multi-sort-p + (not (funcall final-pred s1 s2)) + (funcall final-pred s1 s2)))))) + +(defun icicle-make-plain-predicate (pred &optional final-pred) + "Return a plain predicate that corresponds to component-predicate PRED. +PRED and FINAL-PRED correspond to their namesakes in +`icicle-sort-comparer' (which see). + +PRED should return `(t)', `(nil)', or nil. + +Optional arg FINAL-PRED is the final predicate to use if PRED cannot +decide (returns nil). If FINAL-PRED is nil, then `icicle-alpha-p' is +used as the final predicate." + `(lambda (b1 b2) + (let ((res (funcall ',pred b1 b2))) + (if res (car res) (funcall ',(or final-pred 'icicle-alpha-p) b1 b2))))) + +(defun icicle-alpha-p (s1 s2) + "True if string S1 sorts alphabetically before string S2. +Comparison respects `case-fold-search'." + (when case-fold-search (setq s1 (icicle-upcase s1) + s2 (icicle-upcase s2))) + (string-lessp s1 s2)) + +(defun icicle-get-alist-candidate (string &optional no-error-p) + "Return full completion candidate that corresponds to displayed STRING. +STRING is the name of the candidate, as shown in *Completions*. +Non-nil optional argument NO-ERROR-P means display a message and +return nil instead of raising an error if STRING is ambiguous. +If the value of NO-ERROR-P is `no-error-no-msg', then show no message +and just return nil. + +If `icicle-whole-candidate-as-text-prop-p' is non-nil, then the full +candidate might be available as text property `icicle-whole-candidate' +of STRING. If so, then that is used. + +Otherwise, the full candidate is obtained from +`icicle-candidates-alist'. In this case: + If the user cycled among candidates or used `mouse-2', then use the + current candidate number, and ignore STRING. + Otherwise: + If only one candidate matches STRING, use that. + Else respect NO-ERROR-P and tell user to use cycling or `mouse-2'." + (or (and icicle-whole-candidate-as-text-prop-p + (get-text-property 0 'icicle-whole-candidate string)) + (and icicle-candidates-alist + (let ((cand-entries (icicle-filter-alist icicle-candidates-alist + icicle-completion-candidates))) + (if (wholenump icicle-candidate-nb) ; Cycled or used `mouse-2' to choose the candidate. + (elt cand-entries (mod icicle-candidate-nb (length icicle-candidates-alist))) + ;; If `icicle-completion-candidates' is nil, because user didn't use `TAB' or `S-TAB', + ;; then `icicle-candidates-alist' can contain non-matches. So, we check for more than + ;; one match. However, we cannot just use `assoc', because candidates might be + ;; multi-completions (lists). + (let ((first-match (icicle-first-matching-candidate string icicle-candidates-alist))) + (if (and first-match + (not (icicle-first-matching-candidate + string + (setq cand-entries (delete first-match cand-entries))))) + first-match ; Only one match, so use it. + (let ((msg "Ambiguous choice. Cycle or use `mouse-2' to choose unique matching \ +candidate.")) + (unless no-error-p (error msg)) + (unless (eq no-error-p 'no-error-no-msg) (icicle-msg-maybe-in-minibuffer msg)) + nil)))))))) ; Return nil for ambiguous string if NO-ERROR-P. + +(defun icicle-filter-alist (alist filter-keys) + "Filter ALIST, keeping items whose cars match FILTER-KEYS, in order. +The original ALIST is not altered; a copy is filtered and returned. +If FILTER-KEYS is empty, then ALIST is returned, not a copy." + (if filter-keys + (icicle-remove-if-not + (lambda (item) + (member (if (consp (car item)) + (concat (mapconcat #'identity (car item) icicle-list-join-string) + icicle-list-end-string) + (car item)) + filter-keys)) + alist) + alist)) + +;;; $$$$$$$$$$$$$$$$$$ +;;; (defun icicle-first-matching-candidate (cand candidates) +;;; "Return the first element of alist CANDIDATES that matches CAND. +;;; If CANDIDATES is a normal list of completion candidates, then this is +;;; just `assoc'. +;;; If CANDIDATES contains multi-completions, then matching means matching +;;; the concatenated multi-completion parts, joined by +;;; `icicle-list-join-string'." +;;; (cond ((null candidates) nil) +;;; ((if (consp (caar candidates)) ; Multi-completion candidate +;;; (save-match-data +;;; (string-match cand (mapconcat #'identity (caar candidates) +;;; icicle-list-join-string))) +;;; (equal cand (caar candidates))) ; This case is just `assoc'. +;;; (car candidates)) +;;; (t (icicle-first-matching-candidate cand (cdr candidates))))) + +(defun icicle-first-matching-candidate (cand candidates) + "Return the first element of alist CANDIDATES that matches CAND. +Return nil if there is no such element. +If CANDIDATES is a normal list of completion candidates, then this is +just `assoc'. +If CANDIDATES contains multi-completions, then matching means matching +the concatenated multi-completion parts, joined by +`icicle-list-join-string'." + (let ((res nil)) + (if (null candidates) + (setq res nil) + (while (and candidates (not res)) + (when (or (and (consp (caar candidates)) ; Multi-completion candidate + (save-match-data (string-match (regexp-quote cand) + (concat (mapconcat #'identity (caar candidates) + icicle-list-join-string) + icicle-list-end-string)))) + (equal cand (caar candidates))) + (setq res (car candidates))) + (setq candidates (cdr candidates)))) + res)) + +(defun icicle-completing-p () + "Non-nil if reading minibuffer input with completion. +This caches the value returned in variable `icicle-completing-p'. +Use the function, not the variable, to test, if not sure to be in the +minibuffer." + (setq icicle-completing-p ; Cache the value. + (and (active-minibuffer-window) + ;; $$$ (where-is-internal 'icicle-candidate-action nil 'first-only) + (let* ((loc-map (current-local-map)) + (parent (keymap-parent loc-map)) + (maps (if (boundp 'minibuffer-local-filename-completion-map) + (list minibuffer-local-completion-map + minibuffer-local-must-match-map + minibuffer-local-filename-completion-map + minibuffer-local-filename-must-match-map) + (list minibuffer-local-completion-map + minibuffer-local-must-match-map)))) + (and (or (and parent (member parent maps)) (member loc-map maps)) + t))))) ; Cache t, not the keymap portion. + +;; This is just `substring-no-properties', defined also for Emacs < 22. +(defun icicle-substring-no-properties (string &optional from to) + "Return a substring of STRING, without text properties. +It starts at index FROM and ending before TO. +TO may be nil or omitted; then the substring runs to the end of STRING. +If FROM is nil or omitted, the substring starts at the beginning of STRING. +If FROM or TO is negative, it counts from the end. + +With one argument, just copy STRING without its properties." + (if (fboundp 'substring-no-properties) + (substring-no-properties string from to) ; Emacs 22. + (let ((substrg (copy-sequence (substring string (or from 0) to)))) + (set-text-properties 0 (length substrg) nil substrg) + substrg))) + +(defun icicle-highlight-lighter () + "Highlight `Icy' mode-line indicator of Icicle mode. +Highlighting indicates the current completion status." + (when icicle-highlight-lighter-flag + (let ((strg + (if (if (and (icicle-file-name-input-p) ; Don't bother: `read-buffer-completion-ignore-case' + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case) + " ICY" + " Icy")) + (face (cond ((and icicle-candidate-action-fn (icicle-require-match-p)) + '(icicle-multi-command-completion icicle-mustmatch-completion)) + (icicle-candidate-action-fn 'icicle-multi-command-completion) + ((icicle-require-match-p) + '(icicle-completion icicle-mustmatch-completion)) + (t 'icicle-completion)))) + (when icicle-candidate-action-fn (setq strg (concat strg "+"))) + (put-text-property 0 (length strg) 'face face strg) + (icicle-clear-lighter) + (add-to-list 'minor-mode-alist `(icicle-mode ,strg))) + (condition-case nil + (if (fboundp 'redisplay) (redisplay t) (force-mode-line-update t)) + (error nil)))) ; Ignore errors from, e.g., killed buffers. + +(defun icicle-unhighlight-lighter () + "Unhighlight `Icy' mode-line indicator of Icicle mode." + (when icicle-highlight-lighter-flag + (let ((strg (if case-fold-search " ICY" " Icy"))) + (icicle-clear-lighter) + (add-to-list 'minor-mode-alist `(icicle-mode ,strg))) + (condition-case nil + (if (fboundp 'redisplay) (redisplay t) (force-mode-line-update t)) + (error nil)))) ; Ignore errors from, e.g., killed buffers. + +(defun icicle-clear-lighter (&optional only) + "Remove Icicle mode lighter from `minor-mode-alist'." + (unless (eq only 'truncated) + (setq minor-mode-alist (delete '(icicle-mode " Icy") minor-mode-alist) + minor-mode-alist (delete '(icicle-mode " Icy+") minor-mode-alist) + minor-mode-alist (delete '(icicle-mode " ICY") minor-mode-alist) + minor-mode-alist (delete '(icicle-mode " ICY+") minor-mode-alist))) + (unless (eq only 'not-truncated) + (setq minor-mode-alist (delete `(icicle-mode ,(concat " Icy" icicle-lighter-truncation)) + minor-mode-alist) + minor-mode-alist (delete `(icicle-mode ,(concat " Icy+" icicle-lighter-truncation)) + minor-mode-alist) + minor-mode-alist (delete `(icicle-mode ,(concat " ICY" icicle-lighter-truncation)) + minor-mode-alist) + minor-mode-alist (delete `(icicle-mode ,(concat " ICY+" icicle-lighter-truncation)) + minor-mode-alist)))) + +(defun icicle-ding () + "Same as `ding', but respects `icicle-inhibit-ding-flag'." + (unless icicle-inhibit-ding-flag (ding))) + +(defun icicle-kill-a-buffer (buf &optional nomsg) + "Kill buffer BUF. +Optional arg NOMSG non-nil means don't display an error message." + (save-selected-window + (setq buf (get-buffer buf)) + (if buf + (condition-case err + (if (not (buffer-live-p buf)) + (unless nomsg (message "Buffer already deleted: `%s'" buf)) + (let ((enable-recursive-minibuffers t)) ; In case called from minibuffer, and modified. + (if (fboundp 'kill-buffer-and-its-windows) + (kill-buffer-and-its-windows buf) ; Defined in `misc-cmds.el'. + (kill-buffer buf)))) + (error nil)) + (unless nomsg (message "No such live buffer: `%s'" buf))))) + +(defun icicle-unpropertize (string) + "Remove text properties from STRING. +If STRING is not a string, just return it (raise no error). +If `icicle-remove-icicles-props-p' is nil, just return STRING. This + is the case for some Icicles functions that need to further process + the completion result. +Otherwise, if option `icicle-unpropertize-completion-result-flag' is + non-nil, then remove all text properties. +Otherwise remove only Icicles internal text properties: + 1. any text properties in `icicle-candidate-properties-alist'. + 2. The following internal text properties added by Icicles: + `display', `help-echo', `icicle-fancy-candidates', + `icicle-keep-newline', `icicle-mode-line-help', + `icicle-special-candidate', `icicle-user-plain-dot', + `icicle-whole-candidate', `invisible'. + \(Property `mouse-face' is removed by `choose-completion-string'.\)" + (when (and (stringp string) icicle-remove-icicles-props-p) ; Do nothing if we're inhibiting removal. + (let ((len (length string))) + (if icicle-unpropertize-completion-result-flag + (set-text-properties 0 len nil string) + (remove-text-properties + 0 len '(display nil help-echo nil icicle-fancy-candidates nil icicle-keep-newline nil + icicle-mode-line-help nil icicle-special-candidate nil icicle-user-plain-dot nil + icicle-whole-candidate nil invisible nil) + string) + (dolist (entry icicle-candidate-properties-alist) + (put-text-property 0 len (car (cadr entry)) nil string))))) + string) + +(defun icicle-isearch-complete-past-string () + "Set `isearch-string' to a past search string chosen by completion." + (isearch-done 'nopush) + (let ((icicle-whole-candidate-as-text-prop-p nil) + (completion-ignore-case case-fold-search) + (enable-recursive-minibuffers t)) + (setq isearch-string + (completing-read + "Search string (completing): " + (mapcar #'list (icicle-remove-duplicates (symbol-value (if isearch-regexp + 'regexp-search-ring + 'search-ring)))) + nil nil isearch-string (if isearch-regexp 'regexp-search-ring 'search-ring))))) + +(defun icicle-completion-all-completions (string table pred point) + "Icicles version of `completion-all-completions'. +Append `$' to each candidate, if current input ends in `$'. +Also removes the last cdr, which might hold the base size." + (let ((res (completion-all-completions string table pred point))) + (when (consp res) + (let ((last (last res))) + (when last (setcdr last nil)))) + (let* ((input-sans-dir (icicle-minibuf-input-sans-dir icicle-current-input)) + (env-var-p (and (icicle-not-basic-prefix-completion-p) + (> (length input-sans-dir) 0) + (eq ?\$ (aref input-sans-dir 0))))) + (when env-var-p (setq res (mapcar #'(lambda (cand) (concat "$" cand)) res)))) + res)) + +;; $$$$$$ Filed Emacs BUG #4708. `completion-try-completion' does not return nil when it should. +;; E.g. (completion-try-completion "c:/some-dir/$HOMj" nil 17) returns: ("c:/some-dir/$$HOMj" . 18) +;; +;; This causes `icicle-highlight-input-noncompletion' not to highlight the `j' in the above example. +(defun icicle-completion-try-completion (string table pred point) + "Icicles version of `completion-try-completion'. +Removes the last cdr, which might hold the base size." + (let ((res (completion-try-completion string table pred point))) + (when (consp res) (setq res (car res))) + res)) + +(defun icicle-require-match-p () + "Return non-nil if completion is strict. +Return non-nil if current REQUIRE-MATCH arg to `completing-read' or +`read-file-name' really means require match (sheesh!)." + (if (> emacs-major-version 22) (eq t icicle-require-match-p) icicle-require-match-p)) + +(defun icicle-candidate-short-help (help string) + "Put string of text HELP on STRING as text properties. +Put `help-echo' property if `tooltip-mode' is non-nil. +Put `icicle-mode-line-help' property (on the first character only) if + `icicle-help-in-mode-line-flag' is non-nil. +Return STRING, whether propertized or not." + (when icicle-help-in-mode-line-flag (put-text-property 0 1 'icicle-mode-line-help help string)) + (when (and (boundp 'tooltip-mode) tooltip-mode) + (put-text-property 0 (length string) 'help-echo help string)) + string) + +;; Free vars here: `prompt', `icicle-candidate-help-fn', `completion-ignore-case', +;; `icicle-transform-function', `icicle-sort-orders-alist', +;; `icicle-list-nth-parts-join-string', `icicle-list-join-string', +;; `icicle-list-end-string', `icicle-proxy-candidate-regexp', `named-colors', +;; `icicle-proxy-candidates'. +(defun icicle-color-completion-setup () + "Set up for color-name/RGB-value completion (helper function). +Sets these variables, which are assumed to be already `let'-bound: + `prompt' + `icicle-candidate-help-fn' + `completion-ignore-case' + `icicle-transform-function' + `icicle-sort-orders-alist' + `icicle-list-nth-parts-join-string' + `icicle-list-join-string' + `icicle-list-end-string' + `icicle-proxy-candidate-regexp' + `named-colors' + `icicle-proxy-candidates' +Puts property `icicle-fancy-candidates' on string `prompt'." + (unless (featurep 'hexrgb) (error "`icicle-color-completion-setup' requires library `hexrgb.el'")) + (if (< emacs-major-version 22) + (require 'eyedropper nil t) + (or (require 'palette nil t) (require 'eyedropper nil t))) + (put-text-property 0 1 'icicle-fancy-candidates t prompt) + (icicle-highlight-lighter) + (setq icicle-candidate-help-fn 'icicle-color-help + completion-ignore-case t + icicle-sort-orders-alist + '(("by color name" . icicle-part-1-lessp) + ("by color hue" . (lambda (s1 s2) (not (icicle-color-hue-lessp s1 s2)))) + ("by color purity (saturation)" + . (lambda (s1 s2) (not (icicle-color-saturation-lessp s1 s2)))) + ("by color brightness (value)" + . (lambda (s1 s2) (not (icicle-color-value-lessp s1 s2)))) + ("by amount of red" . (lambda (s1 s2) (not (icicle-color-red-lessp s1 s2)))) + ("by amount of green" . (lambda (s1 s2) (not (icicle-color-green-lessp s1 s2)))) + ("by amount of blue" . (lambda (s1 s2) (not (icicle-color-blue-lessp s1 s2)))) + ("by color rgb" . (lambda (s1 s2) (not (icicle-part-2-lessp s1 s2)))) + ("turned OFF")) + ;; Make the two `*-join-string' variables the same, so past inputs are recognized. + ;; Do not use " " as the value, because color names such as "white smoke" would be + ;; split, and "smoke" would not be recognized as a color name when trying to list + ;; candidates in *Completions*. + icicle-list-nth-parts-join-string ": " + icicle-list-join-string ": " + icicle-list-end-string "" + icicle-proxy-candidate-regexp "^[*'].+[*']" + + named-colors (mapcar #'icicle-make-color-candidate + (hexrgb-defined-colors)) + icicle-proxy-candidates + (mapcar ; Convert multi-completions to strings. + (lambda (entry) + (concat (mapconcat #'identity (car entry) icicle-list-join-string) + icicle-list-end-string)) + (append + (and (fboundp 'eyedrop-foreground-at-point) + (append + (and eyedrop-picked-foreground ; Multi-completions. + `(,(icicle-make-color-candidate + "*copied foreground*" (downcase (hexrgb-color-name-to-hex + eyedrop-picked-foreground))))) + (and eyedrop-picked-background + `(,(icicle-make-color-candidate + "*copied background*" (downcase (hexrgb-color-name-to-hex + eyedrop-picked-background))))) + `(,(icicle-make-color-candidate + "*point foreground*" (downcase (hexrgb-color-name-to-hex + (eyedrop-foreground-at-point)))) + ,(icicle-make-color-candidate + "*point background*" (downcase (hexrgb-color-name-to-hex + (eyedrop-background-at-point))))))) + (let ((ipc ())) + (mapatoms + (lambda (cand) + (when (and (user-variable-p cand) + (icicle-var-is-of-type-p cand '(color)) + ;; This should not be necessary, but type `color' isn't + ;; enforced - it just means `string' (so far). + (x-color-defined-p (symbol-value cand))) + (push `,(icicle-make-color-candidate + (concat "'" (symbol-name cand) "'") + (downcase (hexrgb-color-name-to-hex (symbol-value cand)))) + ipc)))) + ipc))))) + +;; This is not used by Icicles, since the color functions require `hexrgb.el'. +(defun icicle-remove-color-duplicates (list) + "Copy of LIST with duplicate color candidates removed. +Candidates are considered duplicates if they have the same color name, +abstracting from whitespace and letter case." + (let ((tail list) + new) + (save-match-data (while tail + (let* ((this (car tail)) + (pseudo-color-p (string-match "^\*" this))) + (string-match ": " this) + (unless pseudo-color-p + (setq this (icicle-delete-whitespace-from-string + (downcase this) 0 (match-beginning 0)))) + (unless (member this new) (push this new))) + (pop tail))) + (nreverse new))) + +(defun icicle-color-help (color) + "Display help on COLOR." + (unless (featurep 'hexrgb) (error "`icicle-color-help' requires library `hexrgb.el'")) + (let ((icicle-list-use-nth-parts '(1 2))) + (with-output-to-temp-buffer "*Help*" + (setq icicle-list-use-nth-parts '(2) + color (icicle-transform-multi-completion color)) + (princ (format "Color: %s" color)) (terpri) (terpri) + (let* ((rgb (hexrgb-hex-to-rgb color)) + (hsv (apply #'hexrgb-rgb-to-hsv rgb))) + (princ "RGB:") (mapcar (lambda (component) (princ (format " %.18f" component))) rgb) + (terpri) (terpri) + (princ "HSV:") (mapcar (lambda (component) (princ (format " %.18f" component))) hsv))))) + +(defun icicle-make-color-candidate (color-name &optional hex-rgb) + "Return multi-completion candidate of COLOR-NAME and its hex RGB string. +If `icicle-WYSIWYG-Completions-flag' is non-nil, then the hex RGB +string has the color as its background text property. +Optional arg HEX-RGB is the hex RGB string. +If nil, then COLOR-NAME is used to determine the hex RGB string." + (unless (featurep 'hexrgb) (error "`icicle-make-color-candidate' requires library `hexrgb.el'")) + (let* ((rgb-string (or hex-rgb (hexrgb-color-name-to-hex color-name))) + (value (hexrgb-value rgb-string))) + (when icicle-WYSIWYG-Completions-flag + (put-text-property 0 (length rgb-string) 'face + (list (cons 'foreground-color (if (< value 0.6) "White" "Black")) + (cons 'background-color rgb-string)) + rgb-string)) + (when (or icicle-help-in-mode-line-flag ; Construct help only if user will see it. + (and (boundp 'tooltip-mode) tooltip-mode)) + (let* ((rgb (hexrgb-hex-to-rgb rgb-string)) + (hsv (apply #'hexrgb-rgb-to-hsv rgb)) + (help (format "RGB: %.6f, %.6f, %.6f; HSV: %.6f, %.6f, %.6f" + (nth 0 rgb) (nth 1 rgb) (nth 2 rgb) (nth 0 hsv) (nth 1 hsv) (nth 2 hsv)))) + (icicle-candidate-short-help help color-name) + (icicle-candidate-short-help help rgb-string))) + (list (list color-name rgb-string)))) + +(defun icicle-alt-act-fn-for-type (type) + "Returns an action function chosen by user for type TYPE (a string). +Typical use: Bind `icicle-candidate-alt-action-fn' and +`icicle-all-candidates-list-alt-action-fn' to the return value. +However, you must first bind `orig-window' to the window that is +current before user input is read from the minibuffer." + (lexical-let ((type type)) ; Does this binding really help? + `(lambda (cands) + (unless (listp cands) (setq cands (list cands))) ; So it works for both single and all cands. + (let* ((enable-recursive-minibuffers t) + (anything-actions (and (> emacs-major-version 21) + icicle-use-anything-candidates-flag + (require 'anything nil t) + (icicle-get-anything-actions-for-type + (intern ,type)))) + (actions ; Must sort, for `icicle-candidates-alist', + (sort ; or else `icicle-candidate-nb' will be wrong. + (append anything-actions + (mapcar (lambda (act) (cons (format "%s" act) act)) + (icicle-remove-if-not #'functionp + (cdr (assoc ,type icicle-type-actions-alist))))) + (lambda (a1 a2) (funcall 'string-lessp (car a1) (car a2))))) + (icicle-sort-comparer 'string-lessp) ; Must be the same order as actions. + (icicle-candidate-action-fn ; For "how". + (lambda (fn) + (let ((icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "function")) + icicle-saved-completion-candidate) + (icicle-with-selected-window + (if (boundp 'orig-window) orig-window (selected-window)) ; Punt wo `orig-window'. + (dolist (cand cands) + (setq icicle-saved-completion-candidate cand) + (icicle-apply-to-saved-candidate fn t ,type)))))) + ;; Save & restore these, so `icomplete-exhibit' on `post-command-hook' has no error. + (minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate)) + + (setq cands (mapcar (lambda (obj) + (setq obj (icicle-transform-multi-completion obj)) + (cond ((not (stringp obj)) obj) + ((memq (intern ,type) + '(command face function option symbol variable)) + (intern obj)) + ((and (eq (intern ,type) 'frame) (fboundp 'get-a-frame)) + (get-a-frame obj)) + (t obj))) + cands)) + (setq icicle-candidates-alist actions) + (let (icicle-saved-completion-candidate) + (cond ((null actions) ; Undefined TYPE - provide all Emacs fns as candidates. + (let ((action (completing-read "How (action): " obarray 'functionp))) + (dolist (cand cands) + (setq icicle-saved-completion-candidate cand) + (icicle-apply-to-saved-candidate action)))) + ((null (cdr actions)) + (dolist (cand cands) (funcall (cdar actions) cand))) + (t + (let* ((icicle-show-Completions-initially-flag t) + (action (completing-read "How (action): " + actions))) + (icicle-with-selected-window + (if (boundp 'orig-window) orig-window (selected-window)) ; Punt: no `orig-window'. + (let ((icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "function"))) + (dolist (cand cands) + (setq icicle-saved-completion-candidate cand) + (icicle-apply-to-saved-candidate action t ,type)))))))))))) + +(defun icicle-toggle-icicle-mode-twice () + "Toggle Icicle mode twice." + ;; Just a convenience function, to avoid Emacs warning about calling `icy-mode' with no arg. + (let ((curr (if (and (boundp 'icicle-mode) icicle-mode) 1 -1))) + (icy-mode (- curr)) (icy-mode curr))) + +(defun icicle-not-basic-prefix-completion-p () + "`icicle-current-TAB-method' is `vanilla', and Emacs > release 22." + (and (eq 'vanilla icicle-current-TAB-method) (boundp 'completion-styles))) + +;;(@* "Icicles functions - sort functions") + +;;; Icicles functions - sort functions ------------------------------- + +(defun icicle-historical-alphabetic-p (s1 s2) + "Non-nil means S1 is a past input and S2 is not or S1 < S2 (alphabet). +Return non-nil if S1 is a previous input and either S2 is not or +S1 `icicle-case-string-less-p' S2. S1 and S2 must be strings. + +When used as a comparison function for completion candidates, this +makes candidates matching previous inputs available first (at the top +of buffer *Completions*). Candidates are effectively in two groups, +each of which is sorted alphabetically separately: matching previous +inputs, followed by matching candidates that have not yet been used." + ;; We could use `icicle-delete-duplicates' to shorten the history, but that takes time too. + ;; And, starting in Emacs 22, histories will not contain duplicates anyway. + (let ((hist (and (symbolp minibuffer-history-variable) (boundp minibuffer-history-variable) + (symbol-value minibuffer-history-variable))) + (dir (and (icicle-file-name-input-p) + (icicle-file-name-directory-w-default + (or icicle-last-input icicle-current-input))))) + (if (not (consp hist)) + (icicle-case-string-less-p s1 s2) + (when dir (setq s1 (expand-file-name s1 dir) + s2 (expand-file-name s2 dir))) + (let ((s1-previous-p (member s1 hist)) + (s2-previous-p (member s2 hist))) + (or (and (not s1-previous-p) (not s2-previous-p) (icicle-case-string-less-p s1 s2)) + (and s1-previous-p (not s2-previous-p)) + (and s1-previous-p s2-previous-p (icicle-case-string-less-p s1 s2))))))) + +;; $$ Alternative definition, but it doesn't seem any faster, and is slightly less clear. +;; (defun icicle-most-recent-first-p (s1 s2) +;; "Non-nil means S1 was used more recently than S2. +;; Also: +;; S1 < S2 if S1 was used previously but S2 was not. +;; S1 < S2 if neither was used previously +;; and S1 `icicle-case-string-less-p' S2." +;; ;; We could use `icicle-delete-duplicates' to shorten the history, but that takes time too. +;; ;; And, starting in Emacs 22, histories will not contain duplicates anyway. +;; (let ((hist (and (symbolp minibuffer-history-variable) +;; (symbol-value minibuffer-history-variable))) +;; (dir (and (icicle-file-name-input-p) +;; (icicle-file-name-directory-w-default +;; (or icicle-last-input icicle-current-input)))) +;; (s1-in-hist nil) +;; (s2-in-hist nil)) +;; (if (not (consp hist)) +;; (icicle-case-string-less-p s1 s2) +;; (when dir (setq s1 (expand-file-name s1 dir) s2 (expand-file-name s2 dir))) +;; (while (and hist (not (setq s1-in-hist (equal s1 (car hist))))) +;; (when (setq s2-in-hist (equal s2 (car hist))) (setq hist nil)) +;; (setq hist (cdr hist))) +;; (or (and hist s1-in-hist) (and (not s2-in-hist) (icicle-case-string-less-p s1 s2)))))) + +(defun icicle-most-recent-first-p (s1 s2) + "Non-nil means S1 was used more recently than S2. +Also: + S1 < S2 if S1 was used previously but S2 was not. + S1 < S2 if neither was used previously + and S1 `icicle-case-string-less-p' S2." + ;; We could use `icicle-delete-duplicates' to shorten the history, but that takes time too. + ;; And, starting in Emacs 22, histories do not contain duplicates anyway. + (let ((hist (and (symbolp minibuffer-history-variable) (boundp minibuffer-history-variable) + (symbol-value minibuffer-history-variable))) + (dir (and (icicle-file-name-input-p) + (icicle-file-name-directory-w-default + (or icicle-last-input icicle-current-input)))) + (s1-tail ()) + (s2-tail ())) + (if (not (consp hist)) + (icicle-case-string-less-p s1 s2) + (when dir (setq s1 (expand-file-name s1 dir) + s2 (expand-file-name s2 dir))) + (setq s1-tail (member s1 hist) + s2-tail (member s2 hist)) + (cond ((and s1-tail s2-tail) (>= (length s1-tail) (length s2-tail))) + (s1-tail t) + (s2-tail nil) + (t (icicle-case-string-less-p s1 s2)))))) + + +(put 'icicle-buffer-smaller-p 'icicle-buffer-sort-predicate t) +;; This predicate is used for buffer-name completion. +(defun icicle-buffer-smaller-p (b1 b2) + "Non-nil means buffer named B1 is smaller than buffer named B2." + (< (with-current-buffer b1 (buffer-size)) (with-current-buffer b2 (buffer-size)))) + + +(put 'icicle-major-mode-name-less-p 'icicle-buffer-sort-predicate t) +;; This predicate is used for buffer-name completion. +(defun icicle-major-mode-name-less-p (b1 b2) + "Non-nil means major mode name of buffer B1 is `string-less-p' that of B2. +If those names are identical, then buffer names are compared. +Comparison is not case-sensitive." + (let ((bm1 (icicle-upcase (symbol-name (with-current-buffer b1 major-mode)))) + (bm2 (icicle-upcase (symbol-name (with-current-buffer b2 major-mode))))) + (if (string= bm1 bm2) (string-lessp b1 b2) (string-lessp bm1 bm2)))) + + +(when (fboundp 'format-mode-line) ; Emacs 22+ + (put 'icicle-mode-line-name-less-p 'icicle-buffer-sort-predicate t) + ;; This predicate is used for buffer-name completion. + (defun icicle-mode-line-name-less-p (b1 b2) + "Non-nil means buffer B1 mode in mode line is `string-less-p' that of B2. +If those names are identical, then buffer names are compared. +Comparison is not case-sensitive." + (let ((bm1 (icicle-upcase (with-current-buffer b1 (format-mode-line mode-name)))) + (bm2 (icicle-upcase (with-current-buffer b2 (format-mode-line mode-name))))) + (if (string= bm1 bm2) (string-lessp b1 b2) (string-lessp bm1 bm2))))) + + +(put 'icicle-buffer-file/process-name-less-p 'icicle-buffer-sort-predicate t) +;; This predicate is used for buffer-name completion. +(defun icicle-buffer-file/process-name-less-p (b1 b2) + "Non-nil means file/process name of buffer B1 is `string-less-p' that of B2. +The absolute file name of a buffer is used, not the relative name. +Comparison is case-insensitive on systems where file-name case is + insignificant. + +Buffers not associated with files or processes are sorted last." + (setq b1 (get-buffer b1) + b2 (get-buffer b2)) + (let ((fp-b1 (or (buffer-file-name b1) (let ((pb1 (get-buffer-process b1))) + (and (processp pb1) (process-name pb1))))) + (fp-b2 (or (buffer-file-name b2) (let ((pb2 (get-buffer-process b2))) + (and (processp pb2) (process-name pb2)))))) + (and fp-b1 (or (not fp-b2) + (if (memq system-type '(ms-dos windows-nt cygwin)) + (string-lessp (icicle-upcase fp-b1) (icicle-upcase fp-b2)) + (string-lessp fp-b1 fp-b2)))))) + + +(put 'icicle-dirs-first-p 'icicle-file-name-sort-predicate t) +;; This predicate is used for file-name completion. +(defun icicle-dirs-first-p (s1 s2) + "Non-nil means S1 is a dir and S2 a file, or S1 < S2 (alphabet). +If not doing file-name completion, then this is the same as +`icicle-case-string-less-p'." + (if (icicle-file-name-input-p) + (let ((s1-dir-p (icicle-file-directory-p s1)) + (s2-dir-p (icicle-file-directory-p s2))) + (if (or (and s1-dir-p s2-dir-p) ; Both or neither are directories. + (not (or s1-dir-p s2-dir-p))) + (icicle-case-string-less-p s1 s2) ; Compare equals. + s1-dir-p)) ; Directories come before files. + (icicle-case-string-less-p s1 s2))) + + +(put 'icicle-dirs-last-p 'icicle-file-name-sort-predicate t) +;; This predicate is used for file-name completion. +(defun icicle-dirs-last-p (s1 s2) + "Non-nil means S1 is a file and S2 a dir, or S1 < S2 (alphabet). +This is especially useful when `icicle-cycle-into-subdirs-flag' is +non-nil. Otherwise, cycling into subdirectories is depth-first, not +breadth-first. +If not doing file-name completion, then this is the same as +`icicle-case-string-less-p'." + (if (icicle-file-name-input-p) + (let ((s1-dir-p (icicle-file-directory-p s1)) + (s2-dir-p (icicle-file-directory-p s2))) + (if (or (and s1-dir-p s2-dir-p) ; Both or neither are directories. + (not (or s1-dir-p s2-dir-p))) + (icicle-case-string-less-p s1 s2) ; Compare equals. + s2-dir-p)) ; Files come before directories. + (icicle-case-string-less-p s1 s2))) + + +(put 'icicle-2nd-part-string-less-p 'icicle-multi-completion-sort-predicate t) +;; This predicate is used for multi-completion. +(defun icicle-2nd-part-string-less-p (s1 s2) + "`icicle-case-string-less-p' for second parts, then for first parts. +S1 and S2 are multi-completion strings. +Returns non-nil if either of these is true: + +* The second parts of S1 and S2 are the equivalent and the first part + of S1 comes before the first part of S2, alphabetically. + +* The second part of S1 comes before the second part of S2, + alphabetically. + +Alphabetical comparison is done using `icicle-case-string-less-p'." + (let* ((icicle-list-use-nth-parts '(2)) + (s1-2nd (icicle-transform-multi-completion s1)) + (s2-2nd (icicle-transform-multi-completion s2))) + (or (icicle-case-string-less-p s1-2nd s2-2nd) + (and (string= s1-2nd s2-2nd) + (let* ((icicle-list-use-nth-parts '(1)) + (s1-1st (icicle-transform-multi-completion s1)) + (s2-1st (icicle-transform-multi-completion s2)))))))) + + +(put 'icicle-last-modified-first-p 'icicle-file-name-sort-predicate t) +;; This predicate is used for file-name completion. +(defun icicle-last-modified-first-p (s1 s2) + "Non-nil means file S1 was last modified after S2. +If not doing file-name completion, then this is the same as +`icicle-case-string-less-p'." + (if (icicle-file-name-input-p) + (let ((mod-date1 (nth 5 (file-attributes s1))) + (mod-date2 (nth 5 (file-attributes s2)))) + (or (< (car mod-date2) (car mod-date1)) ; High-order bits. + (and (= (car mod-date2) (car mod-date1)) ; Low-order bits. + (< (cadr mod-date2) (cadr mod-date1))))) + (icicle-case-string-less-p s1 s2))) + + +(put 'icicle-command-abbrev-used-more-p 'icicle-command-sort-predicate t) +;; This predicate is used for command and abbreviation completion. +(defun icicle-command-abbrev-used-more-p (s1 s2) + "Return non-nil if S1 was invoked more often than S2 via an abbrev. +S1 and S2 are strings naming commands. +If neither was invoked or both were invoked the same number of times, +then return non-nil if S1 is `string-lessp' S2." + (let* ((alist-tails (mapcar #'cdr icicle-command-abbrev-alist)) + (s1-entry (assq (intern s1) alist-tails)) + (s2-entry (assq (intern s2) alist-tails))) + (if (and (not s1-entry) (not s2-entry)) + (string-lessp s1 s2) + (let ((s1-rank (elt s1-entry 1)) + (s2-rank (elt s2-entry 1))) + (cond ((and (not s1-rank) (not s2-rank)) (string-lessp s1 s2)) + ((and s1-rank s2-rank (eq s1-rank s2-rank)) (string-lessp s1 s2)) + (t (>= (or s1-rank 0) (or s2-rank 0)))))))) + +(defun icicle-part-N-lessp (n s1 s2) + "`icicle-case-string-less-p' applied to the Nth parts of S1 and S2. +The strings each have at least N parts, separated by +`icicle-list-join-string'. Parts other than the Nth are ignored. +Return non-nil if and only if the Nth part of S1 is less than the Nth +part of S2. The Nth parts are compared lexicographically without +regard to letter case. N is one-based, so a value of 1 means compare +the first parts." + (unless (and (wholenump n) (> n 0)) (error "`icicle-part-N-lessp': N must be > 0")) + (let ((case-fold-search t) + (part-N-s1 (elt (split-string s1 icicle-list-join-string) (1- n))) + (part-N-s2 (elt (split-string s2 icicle-list-join-string) (1- n)))) + (and part-N-s1 part-N-s2 ; In case strings were not multipart. + (icicle-case-string-less-p part-N-s1 part-N-s2)))) + +(defun icicle-part-1-lessp (s1 s2) + "`icicle-part-N-lessp', with N = 1." + (icicle-part-N-lessp 1 s1 s2)) + +(defun icicle-part-2-lessp (s1 s2) + "`icicle-part-N-lessp', with N = 2." + (icicle-part-N-lessp 2 s1 s2)) + +(defun icicle-part-3-lessp (s1 s2) + "`icicle-part-N-lessp', with N = 3." + (icicle-part-N-lessp 3 s1 s2)) + +(defun icicle-part-4-lessp (s1 s2) + "`icicle-part-N-lessp', with N = 4." + (icicle-part-N-lessp 4 s1 s2)) + +(defun icicle-cdr-lessp (s1 s2) + "Non-nil means the cdr of S1's entry < the cdr of S2's entry. +Entry here means the complete alist element candidate that corresponds +to the displayed candidate (string) S1 or S2. +Returns nil if comparing the cdrs using `<' would raise an error." + (condition-case nil + (< (cdr (funcall icicle-get-alist-candidate-function s1)) + (cdr (funcall icicle-get-alist-candidate-function s2))) + (error nil))) + +(defun icicle-part-1-cdr-lessp (s1 s2) + "First part and cdr of S1 are less than those of S2." + (or (icicle-part-1-lessp s1 s2) + (and (not (icicle-part-1-lessp s2 s1)) (icicle-cdr-lessp s1 s2)))) + +;; This predicate is used for color completion. +(defun icicle-color-red-lessp (s1 s2) + "Non-nil means the RGB in S1 has less red than in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-red-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-red rgb1) (hexrgb-red rgb2))))) + +;; This predicate is used for color completion. +(defun icicle-color-green-lessp (s1 s2) + "Non-nil means the RGB in S1 has less green than in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-green-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-green rgb1) (hexrgb-green rgb2))))) + +;; This predicate is used for color completion. +(defun icicle-color-blue-lessp (s1 s2) + "Non-nil means the RGB in S1 has less blue than in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-blue-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-blue rgb1) (hexrgb-blue rgb2))))) + +;; This predicate is used for color completion. +(defun icicle-color-hue-lessp (s1 s2) + "Non-nil means the RGB hue in S1 is less than that in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-hue-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-hue rgb1) (hexrgb-hue rgb2))))) + +;; This predicate is used for color completion. +(defun icicle-color-saturation-lessp (s1 s2) + "Non-nil means the RGB in S1 is less saturated than in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-saturation-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-saturation rgb1) (hexrgb-saturation rgb2))))) + +;; This predicate is used for color completion. +(defun icicle-color-value-lessp (s1 s2) + "Non-nil means the RGB value in S1 is darker than that in S2. +The strings are assumed to have at least two parts, with the parts +separated by `icicle-list-join-string' The RGB values are assumed to +be the second parts of the strings, and they are assumed to start with +`#'." + (unless (featurep 'hexrgb) (error "`icicle-color-value-lessp' requires library `hexrgb.el'")) + (let ((rgb1 (elt (split-string s1 icicle-list-join-string) 1)) + (rgb2 (elt (split-string s2 icicle-list-join-string) 1))) + (and rgb1 rgb2 ; Just in case strings were not multipart. + (< (hexrgb-value rgb1) (hexrgb-value rgb2))))) + +;; This predicate is used for key completion. +(defun icicle-prefix-keys-first-p (s1 s2) + "Non-nil if S1 is a prefix key and S2 is not or S1 < S2 (alphabet). +For this function, a prefix key is represented by a string that ends +in \"...\". + +When used as a comparison function for completion candidates, this +makes prefix keys that match your input available first (at the top of +buffer *Completions*). Candidates are effectively in two groups, each +of which is sorted alphabetically separately: prefix keys, followed by +non-prefix keys. Letter case is ignored. + +The special key representation \"..\" is, however, less than all other +keys, including prefix keys." + (let* ((prefix-string " = \\.\\.\\.$") + (parent-string "..") + (s1-prefix-p (save-match-data (string-match prefix-string s1))) + (s2-prefix-p (save-match-data (string-match prefix-string s2))) + (completion-ignore-case t)) + (and (not (string= parent-string s2)) + (or (string= parent-string s1) + (and (not s1-prefix-p) (not s2-prefix-p) (icicle-case-string-less-p s1 s2)) + (and s1-prefix-p (not s2-prefix-p)) + (and s1-prefix-p s2-prefix-p (icicle-case-string-less-p s1 s2)))))) + +;; This predicate is used for key completion. +(defun icicle-local-keys-first-p (s1 s2) + "Non-nil if S1 is a local key and S2 is not or S1 < S2 (alphabet). +For this function, a local key is highlighted as a special candidate. + +When used as a comparison function for completion candidates, this +makes local keys that match your input available first (at the top of +buffer *Completions*). Candidates are effectively in two groups, each +of which is sorted alphabetically separately: local keys, followed by +non-prefix keys. Letter case is ignored. + +The special key representation \"..\" is, however, less than all other +keys, including local keys." + (or (string= ".." s1) + (and (not (string= ".." s2)) (icicle-special-candidates-first-p s1 s2)))) + +;; This predicate is used for key completion. +(defun icicle-command-names-alphabetic-p (s1 s2) + "Non-nil if command name of S1 `icicle-case-string-less-p' that of S2. +When used as a comparison function for completion candidates, this +assumes that each candidate, S1 and S2, is composed of a key name +followed by \" = \", followed by the corresponding command name." + (let ((icicle-list-join-string " = ")) ; Fake a multi-completion. Candidate is key = cmd. + (icicle-part-2-lessp s1 s2))) + +(defun icicle-special-candidates-first-p (s1 s2) + "Non-nil if S1 is special candidate and S2 is not or S1 "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. +;; +;; (@> "Macros") +;; (@> "Functions") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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 3, 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: + +;; Byte-compiling this file, you will likely get some error or warning +;; messages. All of the following are benign. They are due to +;; differences between different versions of Emacs. +;; +;; Compiling in Emacs 20: +;; +;; the function x-focus-frame is not known to be defined. + +(eval-when-compile (when (< emacs-major-version 20) (require 'cl))) ;; when, unless + +;; Quiet the byte compiler for Emacs versions before 22. For some reason, a value is required. +(unless (boundp 'minibuffer-completing-symbol) + (defvar minibuffer-completing-symbol nil) + (defvar minibuffer-message-timeout 2) + (defvar minibuffer-prompt-properties nil)) + +;; Quiet the byte-compiler. +(defvar icicle-inhibit-try-switch-buffer) +(defvar read-file-name-completion-ignore-case) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Macros") + +;;; Macros ----------------------------------------------------------- + +(if (fboundp 'with-selected-window) ; Emacs 22+ + (defalias 'icicle-with-selected-window (symbol-function 'with-selected-window)) + (defmacro icicle-with-selected-window (window &rest body) + "Execute the forms in BODY with WINDOW as the selected window. +The value returned is the value of the last form in BODY. + +This macro saves and restores the selected window, as well as the +selected window of each frame. It does not change the order of +recently selected windows. If the previously selected window of +some frame is no longer live at the end of BODY, that frame's +selected window is left alone. If the selected window is no +longer live, then whatever window is selected at the end of BODY +remains selected. + +This macro uses `save-current-buffer' to save and restore the +current buffer, since otherwise its normal operation could +potentially make a different buffer current. It does not alter +the buffer list ordering." + (when (fboundp 'declare) (declare (indent 1) (debug t))) + ;; Most of this code is a copy of save-selected-window. + `(let ((save-selected-window-window (selected-window)) + ;; It is necessary to save all of these, because calling + ;; select-window changes frame-selected-window for whatever + ;; frame that window is in. + (save-selected-window-alist + (mapcar (lambda (frame) (list frame (frame-selected-window frame))) + (frame-list)))) + (save-current-buffer + (unwind-protect + (progn (if (> emacs-major-version 21) + (select-window ,window 'norecord) ; Emacs 22+ + (select-window ,window)) + ,@body) + (dolist (elt save-selected-window-alist) + (and (frame-live-p (car elt)) + (window-live-p (cadr elt)) + (if (> emacs-major-version 22) + (set-frame-selected-window (car elt) (cadr elt) 'norecord) ; Emacs 23+ + (set-frame-selected-window (car elt) (cadr elt))))) + (when (window-live-p save-selected-window-window) + (if (> emacs-major-version 21) + (select-window save-selected-window-window 'norecord) ; Emacs 22+ + (select-window save-selected-window-window)))))))) + +(defmacro icicle-define-add-to-alist-command (command doc-string construct-item-fn alist-var + &optional dont-save) + "Define COMMAND that adds an item to an alist user option. +Any items with the same key are first removed from the alist. +DOC-STRING is the doc string of COMMAND. +CONSTRUCT-ITEM-FN is a function that constructs the new item. + It reads user input. +ALIST-VAR is the alist user option. +Optional arg DONT-SAVE non-nil means do not call +`customize-save-variable' to save the updated variable." + `(defun ,command () + ,(concat doc-string "\n\nNote: Any items with the same key are first removed from the alist.") + (interactive) + (let ((new-item (funcall ,construct-item-fn))) + (setq ,alist-var (icicle-assoc-delete-all (car new-item) ,alist-var)) + (push new-item ,alist-var) + ,(unless dont-save `(customize-save-variable ',alist-var ,alist-var)) + (message "Added to `%s': `%S'" ',alist-var new-item)))) + +(defmacro icicle-buffer-bindings (&optional more-bindings) + "Bindings to use in multi-command definitions for buffer names. +MORE-BINDINGS is a list of additional bindings, which are created +before the others." + `(,@more-bindings + (completion-ignore-case (or (and (boundp 'read-buffer-completion-ignore-case) + read-buffer-completion-ignore-case) + completion-ignore-case)) + (icicle-show-Completions-initially-flag (or icicle-show-Completions-initially-flag + icicle-buffers-ido-like-flag)) + (icicle-top-level-when-sole-completion-flag (or icicle-top-level-when-sole-completion-flag + icicle-buffers-ido-like-flag)) + (icicle-default-value (if (and icicle-buffers-ido-like-flag + icicle-default-value) + icicle-buffers-ido-like-flag + icicle-default-value)) + (icicle-must-match-regexp icicle-buffer-match-regexp) + (icicle-must-not-match-regexp icicle-buffer-no-match-regexp) + (icicle-must-pass-predicate icicle-buffer-predicate) + (icicle-require-match-flag icicle-buffer-require-match-flag) + (icicle-extra-candidates icicle-buffer-extras) + (icicle-ignore-space-prefix-flag icicle-buffer-ignore-space-prefix-flag) + (icicle-delete-candidate-object 'icicle-kill-a-buffer) ; `S-delete' kills current buf + (icicle-transform-function 'icicle-remove-dups-if-extras) + (icicle-sort-comparer (or icicle-buffer-sort icicle-sort-comparer)) + (icicle-sort-orders-alist + (append (list + '("by last access") ; Renamed from "turned OFF'. + '("*...* last" . icicle-buffer-sort-*...*-last) + '("by buffer size" . icicle-buffer-smaller-p) + '("by major mode name" . icicle-major-mode-name-less-p) + (and (fboundp 'icicle-mode-line-name-less-p) + '("by mode-line mode name" . icicle-mode-line-name-less-p)) + '("by file/process name" . icicle-buffer-file/process-name-less-p)) + (delete '("turned OFF") icicle-sort-orders-alist))) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "buffer"))) + (bufflist + (if current-prefix-arg + (if (wholenump (prefix-numeric-value current-prefix-arg)) + (icicle-remove-if-not #'(lambda (bf) (buffer-file-name bf)) (buffer-list)) + (cdr (assq 'buffer-list (frame-parameters)))) + (buffer-list))))) + +(defmacro icicle-file-bindings (&optional more-bindings) + "Bindings to use in multi-command definitions for file names. +MORE-BINDINGS is a list of additional bindings, which are created +before the others." + `(,@more-bindings + (completion-ignore-case + (or (and (boundp 'read-file-name-completion-ignore-case) read-file-name-completion-ignore-case) + completion-ignore-case)) + (icicle-show-Completions-initially-flag (or icicle-show-Completions-initially-flag + icicle-files-ido-like-flag)) + (icicle-top-level-when-sole-completion-flag (or icicle-top-level-when-sole-completion-flag + icicle-files-ido-like-flag)) + (icicle-default-value (if (and icicle-files-ido-like-flag + icicle-default-value) + icicle-files-ido-like-flag + ;; Get default via `M-n', but do not insert it. + (and (memq icicle-default-value '(t nil)) + icicle-default-value))) + (icicle-must-match-regexp icicle-file-match-regexp) + (icicle-must-not-match-regexp icicle-file-no-match-regexp) + (icicle-must-pass-predicate icicle-file-predicate) + (icicle-require-match-flag icicle-file-require-match-flag) + (icicle-extra-candidates icicle-file-extras) + (icicle-transform-function 'icicle-remove-dups-if-extras) + (icicle-sort-comparer (or icicle-file-sort icicle-sort-comparer)) + (icicle-ignore-space-prefix-flag icicle-buffer-ignore-space-prefix-flag) + (icicle-candidate-alt-action-fn + (or icicle-candidate-alt-action-fn (icicle-alt-act-fn-for-type "file"))) + (icicle-all-candidates-list-alt-action-fn + (or icicle-all-candidates-list-alt-action-fn (icicle-alt-act-fn-for-type "file"))) + (icicle-delete-candidate-object 'icicle-delete-file-or-directory))) + +(defmacro icicle-define-command + (command doc-string function prompt collection &optional + predicate require-match initial-input hist def inherit-input-method + bindings first-sexp undo-sexp last-sexp not-interactive-p) + ;; Hard-code these in doc string, because \\[...] prefers ASCII + ;; `C-RET' instead of `\\[icicle-candidate-action]' + ;; `C-down' instead of `\\[icicle-next-prefix-candidate-action]' + ;; `C-up' instead of `\\[icicle-previous-prefix-candidate-action]' + ;; `C-next' instead of `\\[icicle-next-apropos-candidate-action]' + ;; `C-prior' instead of `\\[icicle-previous-apropos-candidate-action]' + "Define COMMAND with DOC-STRING based on FUNCTION. +COMMAND is a symbol. DOC-STRING is a string. +FUNCTION is a function that takes one argument, read as input. + (If the argument to FUNCTION is a file name or directory name, then + use macro `icicle-define-file-command', instead.) + +BINDINGS is a list of `let*' bindings added around the command code. + The following bindings are pre-included - you can refer to them in + the command body (including in FIRST-SEXP, LAST-SEXP, UNDO-SEXP). + + `orig-buff' is bound to (current-buffer) + `orig-window' is bound to (selected-window) +BINDINGS is macroexpanded, so it can also be a macro call that expands +to a list of bindings. For example, you can use +`icicle-buffer-bindings' here. + +In case of user quit (`C-g') or error, an attempt is made to restore +the original buffer. + +FIRST-SEXP is a sexp evaluated before the main body of the command. +UNDO-SEXP is a sexp evaluated in case of error or if the user quits. +LAST-SEXP is a sexp evaluated after the main body of the command. +NOT-INTERACTIVE-P non-nil means to define COMMAND as a non-interactive + function that reads multi-command input. + +Other arguments are as for `completing-read'. + +In order, the created command does this: + + - Uses DOC-STRING, with information about Icicles bindings appended. + - Binds BINDINGS for the rest of the command. + - Evaluates FIRST-SEXP. + - Reads input with `completing-read', using PROMPT, COLLECTION, + PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST, DEF, and + INHERIT-INPUT-METHOD. + - Calls FUNCTION on the input that was read. + - Evaluates UNDO-SEXP in case of error or if the user quits. + - Evaluates LAST-SEXP. + +The created command also binds `icicle-candidate-action-fn' to a +function that calls FUNCTION on the current completion candidate. +Note that the BINDINGS are of course not in effect within +`icicle-candidate-action-fn'." + `(defun ,command () + ,(concat doc-string "\n\nRead input, then " + (and (symbolp function) (concat "call `" (symbol-name function) "'\nto ")) + "act on it. + +Input-candidate completion and cycling are available. While cycling, +these keys with prefix `C-' are active: + +\\\ +`C-mouse-2', `C-RET' - Act on current completion candidate only +`C-down' - Move to next prefix-completion candidate and act +`C-up' - Move to previous prefix-completion candidate and act +`C-next' - Move to next apropos-completion candidate and act +`C-prior' - Move to previous apropos-completion candidate and act +`\\[icicle-all-candidates-action]' - Act on *all* candidates, successively (careful!) + +When candidate action and cycling are combined (e.g. `C-next'), user +option `icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or +`C-g' to quit. + +This is an Icicles command - see command `icicle-mode'.") + ,(and (not not-interactive-p) '(interactive)) + (let* ((orig-buff (current-buffer)) + (orig-window (selected-window)) + ,@(macroexpand bindings) + (icicle-candidate-action-fn + (lambda (candidate) + (let ((minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate) + (minibuffer-completion-confirm minibuffer-completion-confirm) + (minibuffer-completing-file-name minibuffer-completing-file-name) + (minibuffer-completing-symbol (and (boundp 'minibuffer-completing-symbol) + minibuffer-completing-symbol)) + (minibuffer-exit-hook minibuffer-exit-hook) + (minibuffer-help-form minibuffer-help-form) + (minibuffer-history-variable minibuffer-history-variable) + (minibuffer-history-case-insensitive-variables + minibuffer-history-case-insensitive-variables) + (minibuffer-history-sexp-flag minibuffer-history-sexp-flag) + (minibuffer-message-timeout (and (boundp 'minibuffer-message-timeout) + minibuffer-message-timeout)) + (minibuffer-prompt-properties (and (boundp 'minibuffer-prompt-properties) + minibuffer-prompt-properties)) + (minibuffer-setup-hook minibuffer-setup-hook) + (minibuffer-text-before-history minibuffer-text-before-history)) + (condition-case in-action-fn + ;; Treat 3 cases, because previous use of `icicle-candidate-action-fn' + ;; might have killed the buffer or deleted the window. + (cond ((and (buffer-live-p orig-buff) (window-live-p orig-window)) + (with-current-buffer orig-buff + (save-selected-window (select-window orig-window) + (funcall ',function candidate)))) + ((window-live-p orig-window) + (save-selected-window (select-window orig-window) + (funcall ',function candidate))) + (t + (funcall ',function candidate))) + (error (unless (string= "Cannot switch buffers in minibuffer window" + (error-message-string in-action-fn)) + (error "%s" (error-message-string in-action-fn))) + (when (window-live-p orig-window) + (select-window orig-window) + (select-frame-set-input-focus (selected-frame))) + (funcall ',function candidate))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + nil)))) ; Return nil for success. + ,first-sexp + (condition-case act-on-choice + (let ((cmd-choice (completing-read ,prompt ,collection ,predicate ,require-match + ,initial-input ,hist ,def ,inherit-input-method))) + ;; Reset after reading input, so that commands can tell whether input has been read. + (setq icicle-candidate-action-fn nil) + (funcall ',function cmd-choice)) + (quit (icicle-try-switch-buffer orig-buff) ,undo-sexp) + (error (icicle-try-switch-buffer orig-buff) ,undo-sexp + (error "%s" (error-message-string act-on-choice)))) + ,last-sexp))) + +(defmacro icicle-define-file-command + (command doc-string function prompt &optional + dir default-filename require-match initial-input predicate + bindings first-sexp undo-sexp last-sexp not-interactive-p) + ;; Hard-code these in doc string, because \\[...] prefers ASCII + ;; `C-RET' instead of `\\[icicle-candidate-action]' + ;; `C-down' instead of `\\[icicle-next-prefix-candidate-action]' + ;; `C-up' instead of `\\[icicle-previous-prefix-candidate-action]' + ;; `C-next' instead of `\\[icicle-next-apropos-candidate-action]' + ;; `C-prior' instead of `\\[icicle-previous-apropos-candidate-action]' + "Define COMMAND with DOC-STRING based on FUNCTION. +COMMAND is a symbol. DOC-STRING is a string. +FUNCTION is a function that takes one file-name or directory-name +argument, read as input. (Use macro `icicle-define-command' for a +FUNCTION whose argument is not a file or directory name.) + +BINDINGS is a list of `let*' bindings added around the command code. + The following bindings are pre-included - you can refer to them in + the command body (including in FIRST-SEXP, LAST-SEXP, UNDO-SEXP). + + `orig-buff' is bound to (current-buffer) + `orig-window' is bound to (selected-window) +BINDINGS is macroexpanded, so it can also be a macro call that expands +to a list of bindings. For example, you can use +`icicle-buffer-bindings' here. + +In case of user quit (`C-g') or error, an attempt is made to restore +the original buffer. + +FIRST-SEXP is a sexp evaluated before the main body of the command. +UNDO-SEXP is a sexp evaluated in case of error or if the user quits. +LAST-SEXP is a sexp evaluated after the main body of the command. +NOT-INTERACTIVE-P non-nil means to define COMMAND as a non-interactive + function that reads multi-command input. + +Other arguments are as for `read-file-name'. + +In order, the created command does this: + + - Uses DOC-STRING, with information about Icicles bindings appended. + - Binds BINDINGS for the rest of the command. + - Evaluates FIRST-SEXP. + - Reads input with `read-file-name', using PROMPT, DIR, + DEFAULT-FILENAME, REQUIRE-MATCH, INITIAL-INPUT, and PREDICATE. + - Calls FUNCTION on the input that was read. + - Evaluates UNDO-SEXP in case of error or if the user quits. + - Evaluates LAST-SEXP. + +The created command also binds `icicle-candidate-action-fn' to a +function that calls FUNCTION on the current completion candidate. +Note that the BINDINGS are of course not in effect within +`icicle-candidate-action-fn'." + `(defun ,command () + ,(concat doc-string "\n\nRead input, then " + (and (symbolp function) (concat "call `" (symbol-name function) "'\nto ")) + "act on it. + +Input-candidate completion and cycling are available. While cycling, +these keys with prefix `C-' are active: + +\\\ +`C-mouse-2', `C-RET' - Act on current completion candidate only +`C-down' - Move to next prefix-completion candidate and act +`C-up' - Move to previous prefix-completion candidate and act +`C-next' - Move to next apropos-completion candidate and act +`C-prior' - Move to previous apropos-completion candidate and act +`\\[icicle-all-candidates-action]' - Act on *all* candidates, successively (careful!) + +When candidate action and cycling are combined (e.g. `C-next'), user +option `icicle-act-before-cycle-flag' determines which occurs first. + +With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2', +`C-M-RET', `C-M-down', and so on) provide help about candidates. + +Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or +`C-g' to quit. + +This is an Icicles command - see command `icicle-mode'.") + ,(and (not not-interactive-p) '(interactive)) + (let* ((orig-buff (current-buffer)) + (orig-window (selected-window)) + ,@(macroexpand bindings) + (icicle-candidate-action-fn + (lambda (candidate) + (let ((minibuffer-completion-table minibuffer-completion-table) + (minibuffer-completion-predicate minibuffer-completion-predicate) + (minibuffer-completion-confirm minibuffer-completion-confirm) + (minibuffer-completing-file-name minibuffer-completing-file-name) + (minibuffer-completing-symbol (and (boundp 'minibuffer-completing-symbol) + minibuffer-completing-symbol)) + (minibuffer-exit-hook minibuffer-exit-hook) + (minibuffer-help-form minibuffer-help-form) + (minibuffer-history-variable minibuffer-history-variable) + (minibuffer-history-case-insensitive-variables + minibuffer-history-case-insensitive-variables) + (minibuffer-history-sexp-flag minibuffer-history-sexp-flag) + (minibuffer-message-timeout (and (boundp 'minibuffer-message-timeout) + minibuffer-message-timeout)) + (minibuffer-prompt-properties (and (boundp 'minibuffer-prompt-properties) + minibuffer-prompt-properties)) + (minibuffer-setup-hook minibuffer-setup-hook) + (minibuffer-text-before-history minibuffer-text-before-history)) + (setq candidate (expand-file-name + candidate (icicle-file-name-directory icicle-last-input))) + (condition-case in-action-fn + ;; Treat 3 cases, because previous use of `icicle-candidate-action-fn' + ;; might have deleted the file or the window. + (cond ((and (buffer-live-p orig-buff) (window-live-p orig-window)) + (with-current-buffer orig-buff + (save-selected-window (select-window orig-window) + (funcall ',function candidate)))) + ((window-live-p orig-window) + (save-selected-window (select-window orig-window) + (funcall ',function candidate))) + (t + (funcall ',function candidate))) + (error (unless (string= "Cannot switch buffers in minibuffer window" + (error-message-string in-action-fn)) + (error "%s" (error-message-string in-action-fn))) + (when (window-live-p orig-window) + (select-window orig-window) + (select-frame-set-input-focus (selected-frame))) + (funcall ',function candidate))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + nil)))) ; Return nil for success. + ,first-sexp + (condition-case act-on-choice + (let ((file-choice + (if (< emacs-major-version 21) ; No predicate arg for Emacs 20. + (read-file-name ,prompt ,dir ,default-filename ,require-match ,initial-input) + (read-file-name ,prompt ,dir ,default-filename ,require-match + ,initial-input ,predicate)))) + ;; Reset after reading input, so that commands can tell whether input has been read. + (setq icicle-candidate-action-fn nil) ; Reset after completion. + (funcall ',function file-choice)) + (quit (icicle-try-switch-buffer orig-buff) ,undo-sexp) + (error (icicle-try-switch-buffer orig-buff) ,undo-sexp + (error "%s" (error-message-string act-on-choice)))) + ,last-sexp))) + +(defmacro icicle-define-sort-command (sort-order comparison-fn doc-string) + "Define a command to sort completions by SORT-ORDER. +SORT-ORDER is a short string (or symbol) describing the sort order. + It is used after the phrase \"Sorting is now \". Examples: \"by date\", + \"alphabetically\", \"directories first\", and \"previously used first\". + +The new command is named by replacing any spaces in SORT-ORDER with +hyphens (`-') and then adding the prefix `icicle-sort-'. + +COMPARISON-FN is a function that compares two strings, returning + non-nil if and only if the first string sorts before the second. + +DOC-STRING is the doc string of the new command." + (unless (stringp sort-order) (setq sort-order (symbol-name sort-order))) + (let ((command (intern (concat "icicle-sort-" + (replace-regexp-in-string "\\s-+" "-" sort-order))))) + `(progn + (setq icicle-sort-orders-alist (icicle-assoc-delete-all + ,sort-order + icicle-sort-orders-alist)) + (push (cons ,sort-order ',comparison-fn) icicle-sort-orders-alist) + (defun ,command () + ,doc-string + (interactive) + (setq icicle-sort-comparer #',comparison-fn) + (message "Sorting is now %s%s" ,sort-order (if icicle-reverse-sort-p ", REVERSED" "")) + (icicle-complete-again-update))))) + +;;(@* "Functions") + +;;; Functions -------------------------------------------------------- + +(defun icicle-try-switch-buffer (buffer) + "Try to switch to BUFFER, first in same window, then in other window." + (when (and (buffer-live-p buffer) (not icicle-inhibit-try-switch-buffer)) + (condition-case err-switch-to + (switch-to-buffer buffer) + (error (and (string= "Cannot switch buffers in minibuffer window" + (error-message-string err-switch-to)) + ;; Try another window. Don't bother if the buffer to switch to is a minibuffer. + (condition-case err-switch-other + (unless (string-match "\\` \\*Minibuf-[0-9]+\\*\\'" (buffer-name buffer)) + (switch-to-buffer-other-window buffer)) + (error (error-message-string err-switch-other)))))))) + +(unless (fboundp 'select-frame-set-input-focus) ; Defined in Emacs 22. + (defun select-frame-set-input-focus (frame) + "Select FRAME, raise it, and set input focus, if possible." + (select-frame frame) + (raise-frame frame) + ;; Ensure, if possible, that frame gets input focus. + (cond ((eq window-system 'x) (x-focus-frame frame)) + ((eq window-system 'w32) (w32-focus-frame frame))) + (cond (focus-follows-mouse (set-mouse-position (selected-frame) (1- (frame-width)) 0))))) + + +;;; Miscellaneous ----------------------------------------- + +;; Make Emacs-Lisp mode fontify definitions of Icicles commands. +(font-lock-add-keywords + 'emacs-lisp-mode + `((,(concat "(" (regexp-opt '("icicle-define-add-to-alist-command" "icicle-define-command" + "icicle-define-file-command" "icicle-define-sort-command") + t) + ;; $$ "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)") + "\\>[ \t'\(]*\\(\\sw+\\)?") + (1 font-lock-keyword-face) + ;; Index (2 or 3) depends on whether or not shy groups are supported. + ,(list (if (string-match "\\(?:\\)" "") 2 3) font-lock-function-name-face nil t)))) + +;; This is commented out, but you might also want to use it or something similar. I use it in +;; my init file. The `icicle-define-*' lines cause doc strings to be indented correctly. +;; (defun lisp-indentation-hack () +;; "Better Lisp indenting. Use in Lisp mode hooks +;; such as `lisp-mode-hook', `emacs-lisp-mode-hook', and +;; `lisp-interaction-mode-hook'." +;; (unless (assoc "cl-indent" load-history) (load "cl-indent" nil t)) +;; (set (make-local-variable 'lisp-indent-function) 'common-lisp-indent-function) +;; (setq lisp-indent-maximum-backtracking 10) +;; (put 'define-derived-mode 'common-lisp-indent-function '(4 4 4 2 &body)) +;; (put 'if 'common-lisp-indent-function '(nil nil &body)) +;; (put 'icicle-define-command 'common-lisp-indent-function '(4 &body)) +;; (put 'icicle-define-file-command 'common-lisp-indent-function '(4 &body)) +;; (put 'icicle-define-sort-command 'common-lisp-indent-function '(4 4 &body)) +;; (put 'icicle-define-add-to-alist-command 'common-lisp-indent-function '(4 &body))) + +;; (add-hook 'emacs-lisp-mode-hook 'lisp-indentation-hack) +;; (add-hook 'lisp-mode-hook 'lisp-indentation-hack) +;; (add-hook 'lisp-interaction-mode-hook 'lisp-indentation-hack) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-mac) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-mac.el ends here diff --git a/.emacs.d/icicles/icicles-mcmd.el b/.emacs.d/icicles/icicles-mcmd.el new file mode 100644 index 0000000..7309c51 --- /dev/null +++ b/.emacs.d/icicles/icicles-mcmd.el @@ -0,0 +1,6690 @@ +;;; 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-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:25:04 2006 +;; Version: 22.0 +;; Last-Updated: Fri Jun 18 11:21:30 2010 (-0700) +;; By: dradams +;; Update #: 16043 +;; 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', `cl', `doremi', `el-swank-fuzzy', +;; `ffap', `ffap-', `fuzzy-match', `hexrgb', `icicles-face', +;; `icicles-fn', `icicles-opt', `icicles-var', `kmacro', +;; `levenshtein', `mwheel', `pp', `pp+', `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: +;; +;; `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-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-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-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-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', +;; `icicle-scroll-Completions-up', +;; `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-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-highlight-all-current', +;; `icicle-toggle-highlight-historical-candidates', +;; `icicle-toggle-ignored-extensions', +;; `icicle-toggle-ignored-space-prefix', +;; `icicle-toggle-incremental-completion', +;; `icicle-toggle-literal-replacement', +;; `icicle-toggle-proxy-candidates', `icicle-toggle-regexp-quote', +;; `icicle-toggle-remote-file-testing', +;; `icicle-toggle-search-cleanup', +;; `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-highlight-all-current', +;; `toggle-icicle-highlight-historical-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-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-all-candidates-action-1', `icicle-anychar-regexp', +;; `icicle-apply-to-saved-candidate', `icicle-apropos-complete-1', +;; `icicle-backward-delete-char-untabify-dots', +;; `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-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-candidate-in-Completions', +;; `icicle-nb-of-cand-in-Completions-horiz', +;; `icicle-prefix-complete-1', `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-successive-action', `icicle-transform-sole-candidate', +;; `icicle-transpose-chars-dots', `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)) ;; flet (plus for Emacs < 20, when, unless) + +(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-define-sort-command +(require 'icicles-opt) + ;; icicle-alternative-sort-comparer, icicle-Completions-frame-at-right-flag, + ;; icicle-cycling-respects-completion-mode, icicle-default-thing-insertion, + ;; icicle-expand-input-to-common-match-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)) + ;; 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-assoc-delete-all, 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 + +(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 filesets-data) ; Defined in `filesets.el'. +(defvar minibuffer-confirm-exit-commands) ; Defined in `minibuffer.el' in Emacs 23+. +(defvar icicle-complete-keys-alist) ; Defined in `icicles-var.el' for 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 the 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 the 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 `minibuffer-local-must-match-map'. +;;;###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)))))))) + +(defun icicle-upcase-if-ignore-case (string) + "Return (icicle-upcase STRING) if `completion-ignore-case', else STRING." + (if completion-ignore-case (icicle-upcase string) string)) + +;;;###autoload +(defun icicle-apropos-complete-and-exit () ; Bound to `S-RET' in `minibuffer-local-must-match-map'. + "If the minibuffer contents is a valid apropos completion, then exit. +Otherwise try to complete it. If completion leads to a valid +completion, then exit. +This is to `minibuffer-complete-and-exit' as `icicle-apropos-complete' +is to `minibuffer-complete'. That is, it is the regexp-match version." + (interactive) + (setq icicle-last-input (icicle-input-from-minibuffer)) + (let* ((icicle-apropos-complete-and-exit-p t) ; Suppress the throw or the msg plus the wait. + (candidates (icicle-apropos-complete))) + (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)) + ;; $$$$$$ (orig-buffer 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))) + ;; `icicle-insert-candidates' doesn't put `mouse-face' on the final \n of a candidate + ;; in *Completions*. Add the newline back. `icicle-insert-candidates' puts property + ;; `icicle-keep-newline' on the newline if it is part of the candidate, as opposed to + ;; being just part of the display in columns. + (when (and (eq ?\n (char-after end)) (get-text-property end 'icicle-keep-newline)) + (setq end (1+ end))) + ;; $$$$$$ (setq choice (buffer-substring-no-properties beg end))))) + (setq choice (buffer-substring beg end)))))) + ;; $$$$$ (if (eq orig-buffer (get-buffer "*Completions*")) + ;; (icicle-remove-Completions-window) + ;; (save-selected-window (icicle-remove-Completions-window))) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions (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-candidate-in-Completions (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 (eq icicle-completions-format-internal 'horizontal) + 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-internal nil) + 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))))) + (/ (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))) + (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 (condition-case 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'" current))))) + +;;(@* "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))) + +;;;###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))))) + +;;;###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-backward-char len killflag) + (delete-backward-char 1 killflag))))) + +;;;###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)) + +;;;###autoload +(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)) + +(defun icicle-replace-input-w-parent-dir () + "Replace minibuffer input with the parent directory." + (interactive) + (goto-char (point-max)) + (let ((directoryp (equal directory-sep-char (char-before))) + (bob (icicle-minibuffer-prompt-end))) + (while (and (> (point) bob) (not (equal directory-sep-char (char-before)))) + (delete-backward-char 1)) + (when directoryp + (delete-backward-char 1) + (while (and (> (point) bob) (not (equal directory-sep-char (char-before)))) + (delete-backward-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)) + +;;;###autoload +(when (fboundp 'yank-secondary) ; Defined 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) ; Defined 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 minibuf 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 +(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 +(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 +(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 +(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 +(icicle-define-sort-command "case insensitive" ; `icicle-sort-case-insensitive' + icicle-case-insensitive-string-less-p + "Sort completion candidates alphabetically, but case-insenstively.") + +;;;###autoload +(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 +(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 +(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 +(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 +(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 +(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 +(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 +(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 the 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)))) + +(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 the 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 (if icicle-search-replace-common-match-flag + "Replacing expanded common match is now ON" + "Replacing expanded common match is now OFF"))) + +(defalias 'toggle-icicle-search-replace-whole 'icicle-toggle-search-replace-whole) +;;;###autoload +(defun icicle-toggle-search-replace-whole () ; Bound to `C-,' in the minibuffer. + "Toggle the value of `icicle-search-replace-whole-candidate-flag'. +Bound to `C-,' 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 (if icicle-search-replace-whole-candidate-flag + "Replacing whole search context is now ON" + "Replacing whole search context is now OFF"))) + +(defalias 'toggle-icicle-dot 'icicle-toggle-dot) +(defalias 'toggle-icicle-. 'icicle-toggle-dot) +(defalias 'icicle-toggle-. 'icicle-toggle-dot) +;;;###autoload +(defun icicle-toggle-dot () ; Bound to `C-M-.' in the minibuffer. + "Toggle `icicle-dot-string' between `.' and `icicle-anychar-regexp'. +Bound to C-M-.' in the minibuffer." + (interactive) + (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) + "`.' now matches any char EXCEPT newline") + (t + (icicle-convert-dots (equal icicle-current-input icicle-last-input)) + "`.' now matches any char, including NEWLINE"))) + (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)))))))) + +;;;###autoload +(defun icicle-doremi-increment-max-candidates+ (&optional increment) ; `C-x #' in minibuffer + "Change `icicle-max-candidates' incrementally. +Use `up', `down' or 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 the minibuffer (swank only) + "Change `icicle-swank-timeout' incrementally. +Use `up', `down' or 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 the minibuffer (swank only) + "Change `icicle-swank-prefix-length' incrementally. +Use `up', `down' or 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 () ; Bound to `C-(' in the minibuffer. + "Cycle to the next `TAB' completion method. +Bound to \\`\\[icicle-next-TAB-completion-method]' \ +in the minibuffer. +Option `icicle-TAB-completion-methods' determines the TAB completion +methods that are available." + (interactive) + (let ((now (member icicle-current-TAB-method icicle-TAB-completion-methods))) + (setq icicle-current-TAB-method (if now + (or (cadr now) (car icicle-TAB-completion-methods)) + 'basic)) + ;; 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 'swank) (not (featurep 'el-swank-fuzzy))) + (and (eq icicle-current-TAB-method 'vanilla) (not (boundp 'completion-styles)))) + (setq now (member icicle-current-TAB-method + icicle-TAB-completion-methods) + icicle-current-TAB-method (if now + (or (cadr now) (car icicle-TAB-completion-methods)) + 'basic)))) + (cond ((and (eq icicle-current-TAB-method 'swank) (fboundp 'doremi)) + (define-key minibuffer-local-completion-map "\C-x1" + 'icicle-doremi-increment-swank-timeout+) + (define-key minibuffer-local-must-match-map "\C-x1" + 'icicle-doremi-increment-swank-timeout+) + (define-key minibuffer-local-completion-map "\C-x2" + 'icicle-doremi-increment-swank-prefix-length+) + (define-key minibuffer-local-must-match-map "\C-x2" + 'icicle-doremi-increment-swank-prefix-length+)) + ((fboundp 'doremi) + (define-key minibuffer-local-completion-map "\C-x1" nil) + (define-key minibuffer-local-must-match-map "\C-x1" nil) + (define-key minibuffer-local-completion-map "\C-x2" nil) + (define-key minibuffer-local-must-match-map "\C-x2" 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 now %s" icicle-current-TAB-method)) + +;;;###autoload +(defun icicle-next-S-TAB-completion-method () ; Bound to `M-(' in minibuffer. + "Cycle to the next `S-TAB' completion method. +Bound to `M-(' in minibuffer. +Option `icicle-S-TAB-completion-methods-alist' customizes the +available TAB completion methods." + (interactive) + (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 + (format "S-TAB completion is now %s%s" + (icicle-upcase (car (rassq icicle-apropos-complete-match-fn + icicle-S-TAB-completion-methods-alist))) + (if (memq icicle-apropos-complete-match-fn + '(icicle-levenshtein-match icicle-levenshtein-strict-match)) + (format " (%d)" icicle-levenshtein-distance) + ""))))) + ;; (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%s. Reverse: `C-9 C-,'" + (if alternativep "Alternative s" "S") next-order + (if icicle-reverse-sort-p ", REVERSED" "")))))) + +(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 the 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: `scan-fn-or-regexp' is bound in `icicle-search' (a parameter). +;;;###autoload +(defun icicle-search-define-replacement () ; Bound to `M-,' in the 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 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 + (format "Sort order is %s%s" + (icicle-current-sort-order nil) (if icicle-reverse-sort-p ", REVERSED" ""))))) + +;;(@* "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) + (with-output-to-temp-buffer "*Help*" + (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 prefix-match candidate C-M-down, C-M-up + Next, previous 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 prefix-match candidate C-down, C-up + Next, previous 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 "\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 + (princ (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 "\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)))))) + (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 + (substitute-command-keys + (concat + (format "\\ + + 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 \\\ +\\[icicle-apropos-complete-and-exit]\\ + + * Toggle/cycle Icicles options on the fly. Key: \tCurrently: + Highlighting of past inputs \\[icicle-toggle-highlight-historical-candidates]\t%S + Removal of duplicate candidates \\[icicle-toggle-transforming]\t%S + Change sort order \\[icicle-change-sort-order]\t%s + Change alternative sort order \\[icicle-dispatch-M-comma]\t%s + Swap alternative 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-toggle-incremental-completion]\t%S + Input expansion to common match \\[icicle-toggle-expand-to-common-match]\t%S + Hiding common match in *Completions* \\[icicle-toggle-hiding-common-match]\t%S + S-TAB completion method \\[icicle-next-S-TAB-completion-method]\t%s + TAB completion method \\[icicle-next-TAB-completion-method]\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 (if required match) \\\ +\\[icicle-apropos-complete-and-exit]\\ + 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 \\\ +\\[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]\\ + + * Cycle among input candidates. + Prefix-completion candidates down, up + Apropos-completion candidates 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 prefix-match candidate C-M-down, C-M-up + Next, previous 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 prefix-match candidate C-down, C-up + Next, previous 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-C-comma] + 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-prefix-length' \\[icicle-doremi-increment-swank-prefix-length+] + `icicle-swank-timeout' \\[icicle-doremi-increment-swank-timeout+] + `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 \\\\[quoted-insert]. + +Though it has no direct connection with completion, you can use \ +`\\\\[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-transform-function + (and icicle-sort-comparer (car (rassoc icicle-sort-comparer icicle-sort-orders-alist))) + (and icicle-alternative-sort-comparer (car (rassoc icicle-sort-comparer + icicle-sort-orders-alist))) + (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 + (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-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 "\\\ + 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 \\\\[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)) + (abort-recursive-edit)) + +(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))) + (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))) + (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))) + (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))) + +;;;###autoload +(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))))))) + +(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 (`\\\ +\\[icicle-retrieve-next-input]')." + (interactive "P") + (icicle-retrieve-previous-input arg 'interactive-p)) + +(defun icicle-retrieve-previous-input (&optional arg reversep) ; Bound to `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. + +You can use this command only from buffer *Completions or from the +minibuffer (`\\\ +\\[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 (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. + (if icicle-cycling-p icicle-last-input icicle-current-raw-input) + + ;; 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 + (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'. +(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-name input (icicle-file-name-directory input)) + input))) + +;;;###autoload +(defun icicle-insert-history-element () ; Bound to `M-o' in the 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'. + +`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 argument (not just plain `C-u'), then +function FORWARD-THING is used to retrieve the text to be inserted, +and the argument determines the number of things to grab. It also +determines the direction of thing-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 (`\\\ +\\[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 + (if (eq 'alternatives icicle-default-thing-insertion) + arg ; Either `C-u' or `C-u 3' flips it for `alternatives'. + (consp arg)))))) ; Only `C-u' flips it for `more-of-the-same'. + (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")) + (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 the 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. 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 (`\\\ +\\[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) + (enable-recursive-minibuffers t) + (var + (intern + (completing-read + "Insert text from variable: " + (mapcar #'list + (mapcar 'symbol-name + '(adaptive-fill-first-line-regexp adaptive-fill-regexp + add-log-current-defun-header-regexp + ange-ftp-gateway-prompt-pattern allout-bullets-string + allout-line-boundary-regexp allout-regexp + comment-start-skip comment-end comint-prompt-regexp + ffap-url-regexp find-face-regexp find-function-regexp + find-variable-regexp imenu-example--function-name-regexp-c + org-plain-time-of-day-regexp outline-heading-end-regexp + outline-line-boundary-regexp outline-plain-bullets-string + outline-regexp page-delimiter paragraph-separate paragraph-start + rmail-mime-charset-pattern sentence-end shell-prompt-pattern + telnet-prompt-pattern temp-file-name-pattern + thing-at-point-url-regexp))) + (lambda (cand) (boundp (intern (car cand)))) + 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 the minibuffer during completion. + "Insert `icicle-list-join-string' in the minibuffer." + (interactive) + (icicle-insert-thing icicle-list-join-string 'no-replace) + (let ((len (length icicle-list-join-string))) + (when (and (fboundp '1on1-fit-minibuffer-frame) ; Defined in `oneonone.el'. + (string= "\C-j" (substring icicle-list-join-string (1- len) len))) + (1on1-fit-minibuffer-frame)))) + +;;;###autoload +(defun icicle-dispatch-M-q (&optional arg) ; Bound to `M-q' in the 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)))) + +(defalias 'toggle-icicle-search-whole-word 'icicle-toggle-search-whole-word) +;;;###autoload +(defun icicle-toggle-search-whole-word () ; Bound to `M-q' in the minibuffer. + "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 (if icicle-search-whole-word-flag + "Whole-word searching is now ON, starting with next search" + "Whole-word searching is now OFF, starting with next search"))) + +;;;###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. + +`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." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (let* ((enable-recursive-minibuffers t) + (key + (progn (minibuffer-message " [Quoting key]") (read-event)))) + (insert (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' is defined, call it to fit a +standalone minibuffer frame to the new minibuffer contents." + (interactive "p") + (icicle-self-insert arg) + (when (fboundp '1on1-fit-minibuffer-frame) (1on1-fit-minibuffer-frame))) ; Defined in `oneonone.el'. + +;; Bound in minibuffer to keys in `icicle-modal-cycle-down-keys' (`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-cycling-respects-completion-mode' is non-nil, uses the next +history element instead. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-next-candidate-per-mode]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (case icicle-current-completion-mode + (prefix + (setq this-command 'icicle-next-prefix-candidate) + (icicle-next-prefix-candidate nth)) + (apropos + (setq this-command 'icicle-next-apropos-candidate) + (icicle-next-apropos-candidate nth)) + ((nil) + (when icicle-cycling-respects-completion-mode (next-history-element (or nth 1)))))) + +;; Bound in minibuffer to keys in `icicle-modal-cycle-up-keys' (`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-cycling-respects-completion-mode' is non-nil, uses the +previous history element instead. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-previous-candidate-per-mode]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (icicle-next-candidate-per-mode (- (or nth 1)))) + + +(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) ; Bound to `C-p', `up' in minibuffer. + "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 (`\\\ +\\[icicle-previous-prefix-candidate]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (setq nth (or nth 1)) + (icicle-next-prefix-candidate (- nth))) + + +(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) ; Bound to `down', `C-n' in minibuffer. + "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 (`\\\ +\\[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))) + + +(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) ; Bound to `prior', `M-v' in minibuffer. + "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 (`\\\ +\\[icicle-previous-apropos-candidate]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (setq nth (or nth 1)) + (icicle-next-apropos-candidate (- nth))) + + +(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) ; Bound to `next', `C-v' in minibuffer. + "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 (`\\\ +\\[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 (`\\\ +\\[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 (`\\\ +\\[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 (`\\\ +\\[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 (`\\\ +\\[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 (`\\\ +\\[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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-up', `M-{' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-down', `M-}' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-prior', `C-x >' in minib + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-next', `C-x <' in minibuffer + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-S-up' in minibuffer. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-S-down' in minibuffer. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-S-prior' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-S-next' in minibuffer. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-M-up' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-M-down' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-M-prior' in minibuf. + "`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 (`\\\ +\\[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)) + + +(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) ; Bound to `C-M-next' in minibuf. + "`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 (`\\\ +\\[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 NTH to ACTION-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 10 sec. Display the help after we do the action. + (let ((icicle-help-in-mode-line-flag nil)) (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))))) + + +(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 () ; Bound to `TAB' in minibuffer. + "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 (`\\\ +\\[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)) + + +(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 (`\\\ +\\[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))) + + +(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 () ; Bound to `M-SPC' in minibuffer. + "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 (`\\\ +\\[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 + (condition-case 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 (condition-case 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]") + (swank " [No swank (fuzzy symbol) completions]") + (vanilla " [No vanilla completions]") + (t " [No prefix completions]"))))) + ((null (cdr icicle-completion-candidates)) ; Single candidate. Update minibuffer. + ;; When `icicle-whole-candidate-as-text-prop-p' is t and + ;; `icicle-expand-input-to-common-match-flag' is nil, we need to expand the input anyway. + ;; That transfers any `icicle-whole-candidate' property from the candidate to + ;; `icicle-current-input', so things that use `icicle-candidates-alist' will work. + (when (and icicle-whole-candidate-as-text-prop-p + (not icicle-expand-input-to-common-match-flag)) + (setq icicle-common-match-string (icicle-expanded-common-match + icicle-current-input icicle-completion-candidates)) + (when icicle-common-match-string + (let ((common (if (and (icicle-file-name-input-p) insert-default-directory) + (if (string= "" icicle-common-match-string) + (or (icicle-file-name-directory icicle-current-input) "") + (directory-file-name (icicle-abbreviate-or-expand-file-name + icicle-common-match-string + (icicle-file-name-directory + icicle-current-input)))) + icicle-common-match-string))) + ;; Save as current input, unless input is a directory. + (unless (and (icicle-file-name-input-p) (file-directory-p icicle-current-input)) + (setq icicle-current-input common))))) + ;; Expand file-name input to the common match for the current candidate. + (when (icicle-file-name-input-p) + (setq icicle-common-match-string (icicle-expanded-common-match + (car icicle-completion-candidates) + icicle-completion-candidates)) + (when icicle-common-match-string + (let ((common (if (and (icicle-file-name-input-p) insert-default-directory) + (if (string= "" icicle-common-match-string) + (or (icicle-file-name-directory icicle-current-input) "") + (directory-file-name (icicle-abbreviate-or-expand-file-name + icicle-common-match-string + (icicle-file-name-directory + icicle-current-input)))) + icicle-common-match-string))) + (setq icicle-current-input common)))) + (setq icicle-nb-of-other-cycle-candidates 0) + (unless icicle-edit-update-p + (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 (concat 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 + (sit-for icicle-top-level-when-sole-completion-delay)) + (set minibuffer-history-variable + (cons icicle-current-input + (symbol-value minibuffer-history-variable))) + (condition-case 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 (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]") + (swank " [One swank (fuzzy symbol) completion: %s]") + (vanilla " [One vanilla 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]") + (swank " [Sole swank (fuzzy symbol) completion]") + (vanilla " [Sole vanilla completion]") + (t " [Sole prefix completion]"))) + (setq mode-line-help icicle-current-input))))) + (t ; Multiple candidates. + (if icicle-edit-update-p + (icicle-display-candidates-in-Completions nil no-display-p) + (unless word-p + (icicle-clear-minibuffer) + (save-window-excursion + ;; Shouldn't need to explicitly select minibuffer like this, since `*Completions*' + ;; input is directed there. But there seems to be an Emacs bug somewhere, because + ;; although using just `insert' inserts the input in the minibuffer OK, in some + ;; cases the cursor might not follow the insertion. + (select-window (active-minibuffer-window)) + (insert icicle-current-input)) + ;; Shouldn't need to do this if it is on `post-command-hook', but it seems we need to. + (when (and (boundp '1on1-fit-minibuffer-frame-flag) 1on1-fit-minibuffer-frame-flag) + (1on1-fit-minibuffer-frame))) ; Defined in `oneonone.el'. + (deactivate-mark) + (icicle-highlight-initial-whitespace icicle-current-input) + (when (and (icicle-file-name-input-p) + (icicle-file-directory-p icicle-last-completion-candidate)) + (setq icicle-default-directory (icicle-abbreviate-or-expand-file-name + icicle-last-completion-candidate))) + (when (and (icicle-input-is-a-completion-p icicle-current-input) + (not (boundp 'icicle-prefix-complete-and-exit-p))) + (icicle-highlight-complete-input) + (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-input-is-a-completion-p (&optional input) + "Return non-nil if the input is a valid completion. +Optional arg INPUT is passed to `icicle-minibuffer-input-sans-dir'. +This is essentially a `member' test, except for environment vars, for +which the initial `$' is ignored." + (let* ((input-sans-dir (icicle-minibuf-input-sans-dir input)) + (env-var-name (and (icicle-not-basic-prefix-completion-p) + (> (length input-sans-dir) 0) + (eq ?\$ (aref input-sans-dir 0)) + (substring input-sans-dir 1)))) + (member (icicle-upcase-if-ignore-case (or env-var-name input-sans-dir)) + (mapcar #'icicle-upcase-if-ignore-case icicle-completion-candidates)))) + + +(put 'icicle-apropos-complete 'icicle-cycling-command t) +(put 'icicle-apropos-complete 'icicle-apropos-cycling-command t) +(put 'icicle-apropos-complete 'icicle-completing-command t) +(put 'icicle-apropos-complete 'icicle-apropos-completing-command t) +;;;###autoload +(defun icicle-apropos-complete () ; Bound to `S-TAB' in minibuffer. + "Complete the minibuffer contents as far as possible. +Repeat this to cycle among candidate completions. +This uses \"apropos completion\", defined as follows: +A completion contains the minibuffer input somewhere, as a substring. +Display a list of possible completions in buffer *Completions*. +Candidate completions are appropriate names that match the current +input, taken as a regular expression, 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 (`\\\ +\\[icicle-apropos-complete]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (when (and (string= icicle-dot-string icicle-anychar-regexp) + (not (string= icicle-dot-string-internal icicle-anychar-regexp))) + (icicle-convert-dots (equal icicle-current-input icicle-last-input)) ; No confirm if same input. + (setq icicle-dot-string-internal (icicle-anychar-regexp))) + (let* ((error-msg nil) ; Apropos complete. + (candidates + (condition-case lossage + (icicle-apropos-complete-1) + (invalid-regexp + (setq error-msg (cadr lossage)) + (when (string-match "\\`Premature \\|\\`Unmatched \\|\\`Invalid " error-msg) + (setq error-msg "incomplete input"))) + (error (setq error-msg (error-message-string lossage)))))) + (when error-msg (minibuffer-message (concat " " error-msg))) + candidates)) + + +(put 'icicle-apropos-complete-no-display 'icicle-cycling-command t) +(put 'icicle-apropos-complete-no-display 'icicle-apropos-cycling-command t) +(put 'icicle-apropos-complete-no-display 'icicle-completing-command t) +(put 'icicle-apropos-complete-no-display 'icicle-apropos-completing-command t) +;;;###autoload +(defun icicle-apropos-complete-no-display (&optional no-msg-p) ; Bound to `C-M-S-TAB' in minibuffer. + "Like `icicle-apropos-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 (`\\\ +\\[icicle-apropos-complete-no-display]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (let* ((error-msg nil) + (candidates + (condition-case lossage + (icicle-apropos-complete-1 (if no-msg-p 'no-msg 'no-display)) + (invalid-regexp + (setq error-msg (cadr lossage)) + (when (string-match "\\`Premature \\|\\`Unmatched \\|\\`Invalid " error-msg) + (setq error-msg "incomplete input"))) + (error (setq error-msg (error-message-string lossage)))))) + (when error-msg (minibuffer-message (concat " " error-msg))) + candidates)) + +(defun icicle-apropos-complete-1 (&optional no-display-p) + "Helper function for `icicle-apropos-complete(-no-display)'. +This does everything except deal with regexp-match errors. +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." + (let ((iac1-was-cycling-p icicle-cycling-p) + (mode-line-help nil) + input-before-completion) + (setq icicle-current-input (if (and icicle-last-input + icicle-cycling-p + (not icicle-edit-update-p) + (eq icicle-current-completion-mode 'apropos) + (symbolp last-command) + (or (get last-command 'icicle-cycling-command) + (get last-command 'icicle-action-command)) + icicle-completion-candidates) + icicle-last-input + (icicle-input-from-minibuffer)) + icicle-current-completion-mode 'apropos + icicle-next-prefix-complete-cycles-p nil + icicle-input-fail-pos nil + icicle-cycling-p nil) + (when icicle-edit-update-p (setq icicle-next-apropos-complete-cycles-p nil)) + (when (icicle-file-name-input-p) + (setq icicle-current-input (abbreviate-file-name + (if icicle-regexp-quote-flag + (substitute-in-file-name icicle-current-input) + icicle-current-input)))) + (setq input-before-completion icicle-current-input) + (unless (or icicle-edit-update-p (get-buffer-window "*Completions*" 0) no-display-p) + (message "Computing completion candidates...")) + (unless (and (stringp icicle-current-input) (stringp icicle-last-input) + (string= icicle-current-input icicle-last-input) + (or (get last-command 'icicle-apropos-completing-command) + (get last-command 'icicle-action-command))) + (setq icicle-completion-candidates + (condition-case nil + (if (icicle-file-name-input-p) + (icicle-file-name-apropos-candidates icicle-current-input) + (icicle-apropos-candidates icicle-current-input)) + (error icicle-completion-candidates)))) ; No change if completion error. + (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 (let ((typ (car (rassq icicle-apropos-complete-match-fn + icicle-S-TAB-completion-methods-alist)))) + (concat " [No " typ (and typ " ") "completion]"))))) + ((null (cdr icicle-completion-candidates)) ; Single candidate. Update minibuffer. + ;; When `icicle-whole-candidate-as-text-prop-p' is t + ;; and `icicle-expand-input-to-common-match-flag' is nil, we need to expand the input anyway. + ;; That transfers any `icicle-whole-candidate' property from the candidate to + ;; `icicle-current-input', so things that use `icicle-candidates-alist' will work. + (when (and icicle-whole-candidate-as-text-prop-p + (not icicle-expand-input-to-common-match-flag)) + (setq icicle-common-match-string (icicle-expanded-common-match + icicle-current-input icicle-completion-candidates)) + (when icicle-common-match-string + (let ((common (if (and (icicle-file-name-input-p) insert-default-directory) + (if (string= "" icicle-common-match-string) + (or (icicle-file-name-directory icicle-current-input) "") + (directory-file-name (icicle-abbreviate-or-expand-file-name + icicle-common-match-string + (icicle-file-name-directory + icicle-current-input)))) + icicle-common-match-string))) + ;; Save as current input, unless input is a directory. + (unless (and (icicle-file-name-input-p) (file-directory-p icicle-current-input)) + (setq icicle-current-input common))))) + ;; Expand file-name input to the common match for the current candidate. + (when (icicle-file-name-input-p) + (setq icicle-common-match-string (icicle-expanded-common-match + (car icicle-completion-candidates) + icicle-completion-candidates)) + (when icicle-common-match-string + (let ((common (if (and (icicle-file-name-input-p) insert-default-directory) + (if (string= "" icicle-common-match-string) + (or (icicle-file-name-directory icicle-current-input) "") + (directory-file-name (icicle-abbreviate-or-expand-file-name + icicle-common-match-string + (icicle-file-name-directory + icicle-current-input)))) + icicle-common-match-string))) + (setq icicle-current-input common)))) + (setq icicle-nb-of-other-cycle-candidates 0) + (unless icicle-edit-update-p + (icicle-clear-minibuffer) + (if (icicle-file-name-input-p) + (let ((cand (car icicle-completion-candidates))) + (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 (concat icicle-current-input "/") + icicle-last-completion-candidate icicle-current-input)) + (t ; Non-dir - use the candidate file. + (setq icicle-last-completion-candidate (car icicle-completion-candidates))))) + (setq icicle-last-completion-candidate (car icicle-completion-candidates))) + (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-apropos-complete-and-exit-p) + (icicle-highlight-complete-input) + (cond ((and icicle-top-level-when-sole-completion-flag + (sit-for icicle-top-level-when-sole-completion-delay)) + (set minibuffer-history-variable (cons (car icicle-completion-candidates) + (symbol-value minibuffer-history-variable))) + (condition-case icicle-apropos-complete-1 + (throw 'icicle-read-top + (if (and (icicle-file-name-input-p) insert-default-directory + (or (not (member (car icicle-completion-candidates) + icicle-extra-candidates)) + icicle-extra-candidates-dir-insert-p)) + (expand-file-name (car icicle-completion-candidates)) + (car icicle-completion-candidates))) + (no-catch (setq icicle-current-input (car icicle-completion-candidates)) + (icicle-retrieve-last-input) + icicle-current-input) + (error (message (error-message-string icicle-apropos-complete-1))))) + ((and icicle-edit-update-p (not (eq no-display-p 'no-msg))) + (minibuffer-message (format " [One apropos completion: %s]" + (car icicle-completion-candidates))) + (setq mode-line-help (car icicle-completion-candidates))) + ((not (eq no-display-p 'no-msg)) + (minibuffer-message " [Sole apropos completion]") + (setq mode-line-help (car icicle-completion-candidates)))))) + (t ; Multiple candidates. + (if icicle-edit-update-p + (icicle-display-candidates-in-Completions nil no-display-p) + (icicle-clear-minibuffer) + (insert icicle-current-input) ; Update minibuffer. + ;; Shouldn't need to do this if it is on `post-command-hook', but it seems we need to. + (when (and (boundp '1on1-fit-minibuffer-frame-flag) 1on1-fit-minibuffer-frame-flag) + (1on1-fit-minibuffer-frame)) ; Defined in `oneonone.el'. + (deactivate-mark) + (icicle-highlight-initial-whitespace icicle-current-input) + (when (and (icicle-file-name-input-p) + (icicle-file-directory-p icicle-last-completion-candidate)) + (setq icicle-default-directory (icicle-abbreviate-or-expand-file-name + icicle-last-completion-candidate))) + (let ((input-sans-dir (icicle-minibuf-input-sans-dir icicle-current-input))) + (when (and (member (icicle-upcase-if-ignore-case input-sans-dir) + (mapcar #'icicle-upcase-if-ignore-case icicle-completion-candidates)) + (not (boundp 'icicle-apropos-complete-and-exit-p))) + (icicle-highlight-complete-input) + (setq mode-line-help input-sans-dir))) + (cond (;; Candidates already displayed. If second `S-TAB', cycle, else update candidates. + (get-buffer-window "*Completions*" 0) + (if (and (or iac1-was-cycling-p icicle-next-apropos-complete-cycles-p) + (get icicle-last-completion-command 'icicle-apropos-completing-command) + (or (get last-command 'icicle-apropos-completing-command) + (get last-command 'icicle-action-command))) + ;; Second `S-TAB' in a row. Cycle down. + (icicle-next-candidate 1 (if (icicle-file-name-input-p) + 'icicle-file-name-apropos-candidates + 'icicle-apropos-candidates) + 'regexp-p) + ;; User did something else (e.g. changed input). (Possibly) update the display. + (icicle-display-candidates-in-Completions nil no-display-p))) + (t + (if (not (and (or iac1-was-cycling-p icicle-next-apropos-complete-cycles-p) + (get icicle-last-completion-command + 'icicle-apropos-completing-command) + (or (get last-command 'icicle-apropos-completing-command) + (get last-command 'icicle-action-command)))) + (icicle-display-candidates-in-Completions nil no-display-p) + ;; Second apropos complete. If `S-TAB', it follows `C-M-S-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-apropos-candidates + 'icicle-apropos-candidates) + 'regexp-p))))))) + (setq icicle-last-completion-command (if no-display-p + 'icicle-apropos-complete-no-display + 'icicle-apropos-complete) + icicle-next-apropos-complete-cycles-p (equal input-before-completion + (icicle-input-from-minibuffer))) + (when mode-line-help (icicle-show-help-in-mode-line mode-line-help)) + icicle-completion-candidates)) + +(defun icicle-transform-sole-candidate () + "Transform matching candidate according to `icicle-list-use-nth-parts'." + (when icicle-list-use-nth-parts + ;; $$$$$$ (let ((newcand (icicle-transform-multi-completion (car icicle-completion-candidates)))) + (let ((newcand (icicle-transform-multi-completion icicle-current-input))) + (icicle-clear-minibuffer) + (insert newcand) + (setq icicle-completion-candidates (list newcand) + icicle-last-completion-candidate newcand)))) + +;;;###autoload +(defun icicle-switch-to-Completions-buf () ; Bound to `C-insert' in minibuffer. + "Select the completion list window. +The cursor is placed on the first occurrence of the current minibuffer +content. You can use \\\ +`\\[icicle-insert-completion]' to get back to the minibuffer. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-switch-to-Completions-buf]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (setq icicle-current-input (icicle-input-from-minibuffer)) + (let ((window (get-buffer-window "*Completions*" 0)) + (search-fn 'search-forward)) + (unless window ; Make sure we have a completions window. + (icicle-apropos-complete) + (setq window (get-buffer-window "*Completions*" 0) + search-fn 're-search-forward)) ; Use regexp search: input is not yet complete. + (when window + (select-window window) + (let ((case-fold-search + ;; Don't bother to detect buffer completion and check `read-buffer-completion-ignore-case'. + (if (and (icicle-file-name-input-p) + (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case + completion-ignore-case))) + (goto-char (icicle-start-of-candidates-in-Completions)) + (when (icicle-file-name-input-p) + (setq icicle-current-input (icicle-file-name-nondirectory icicle-current-input))) + (when (and (get icicle-last-completion-command 'icicle-apropos-completing-command) + ;; $$ Previously allowed the -action's. + (not (and (symbolp last-command) (get last-command 'icicle-cycling-command)))) + (setq search-fn 're-search-forward)) ; Use regexp search: input is not yet complete. + (while (and (not (eobp)) + (save-restriction + (narrow-to-region (point) (next-single-property-change (point) 'mouse-face + nil (point-max))) + (not (funcall search-fn icicle-current-input nil 'leave-at-end))))) + (unless (eobp) + (goto-char (match-beginning 0)) + (let ((prop (get-text-property (1- (point)) 'mouse-face))) + ;; If in a completion, move to the start of it. + (when (and prop (eq prop (get-text-property (point) 'mouse-face))) + (goto-char (previous-single-property-change (point) 'mouse-face nil (point-min))))) + (icicle-place-overlay + (point) (next-single-property-change (point) 'mouse-face nil (point-max)) + 'icicle-current-completion-candidate-overlay 'icicle-current-candidate-highlight + 100 (current-buffer))))))) + +;;;###autoload +(defun icicle-insert-completion (&optional completion) ; Bound to `C-insert' in *Completions*. + "Select the active minibuffer window. Insert current completion. +The current candidate in *Completions* (under the cursor) is inserted +into the minibuffer as the current input. You can use \\\ +`\\[icicle-switch-to-Completions-buf]' +to switch to the *Completions* window. + +You can use this command only from buffer *Completions* (`\\\ +\\[icicle-insert-completion]'). + +Non-interactively, optional arg COMPLETION is the completion inserted." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions)) + (when (active-minibuffer-window) + (unwind-protect ; If no current completion, return to minibuffer anyway. + (progn + (setq completion (or completion (icicle-current-completion-in-Completions))) + (select-window (active-minibuffer-window)) + (with-current-buffer (window-buffer) ; Needed if *Completions* is redirected to minibuffer. + (goto-char (icicle-minibuffer-prompt-end)) + (icicle-clear-minibuffer) + (insert (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)) + (icicle-file-name-directory-w-default icicle-current-input) + "") + completion) + (setq icicle-current-input (icicle-input-from-minibuffer)))) + (select-window (active-minibuffer-window))))) + +(defun icicle-current-completion-in-Completions () + "The completion candidate under the cursor in buffer *Completions*. +Return the name as a string." ; See also `choose-completion' and `mouse-choose-completion'. + (let ((buffer completion-reference-buffer) + (base-size completion-base-size) + (start-of-cands (icicle-start-of-candidates-in-Completions)) + beg end) + (when (and (not (eobp)) (get-text-property (point) 'mouse-face)) + (setq end (point) + beg (1+ (point)))) + (when (and (> (point) start-of-cands) (get-text-property (1- (point)) 'mouse-face)) + (setq end (1- (point)) + beg (point))) + (setq beg (previous-single-property-change (or beg (point)) 'mouse-face nil start-of-cands) + end (next-single-property-change (or end (point)) 'mouse-face nil (point-max))) + (unless beg (error "No completion here")) + ;; `icicle-insert-candidates' doesn't put `mouse-face' on the final \n of a candidate + ;; in *Completions*. Add the newline back. `icicle-insert-candidates' puts property + ;; `icicle-keep-newline' on the newline if it is part of the candidate, as opposed to + ;; being just part of the display in columns. + (when (and (eq ?\n (char-after end)) (get-text-property end 'icicle-keep-newline)) + (setq end (1+ end))) + ;; $$$$ (buffer-substring-no-properties beg end))) + (buffer-substring beg end))) + +;;;###autoload +(defun icicle-switch-to/from-minibuffer () ; Bound to `pause' in Icicle mode. + "Switch to minibuffer or previous buffer, in other window. +If current buffer is the minibuffer, then switch to the buffer that +was previously current. Otherwise, switch to the minibuffer." + (interactive) + (unless (active-minibuffer-window) (error "Minibuffer is not active")) + (if (eq (selected-window) (active-minibuffer-window)) + (switch-to-buffer-other-window icicle-pre-minibuffer-buffer) + (select-window (active-minibuffer-window)))) + + +;; Replaces `previous-completion' (defined in `simple.el'). +;;;###autoload +(defun icicle-move-to-previous-completion (n) ; Bound to `left', `S-TAB' in *Completions*. + "Move to the previous item in the completion list. + +You can use this command only from buffer *Completions* (`\\\ +\\[icicle-move-to-previous-completion]')." + (interactive "p") + (when (interactive-p) (icicle-barf-if-outside-Completions)) + (setq n (or n 0)) + (icicle-move-to-next-completion (- n))) + + +;; Replaces `next-completion' (defined in `simple.el'). +;; This is similar, except: +;; 1. This highlights the current candidate. +;; 2. This wraps around from first to last and last to first. +;; 3. Properly handles completions laid out vertically. +;; +;;;###autoload +(defun icicle-move-to-next-completion (n &optional no-minibuffer-follow-p) ; Bound to `right', + ; `TAB' in *Completions*. + "Move to the next item in the completion list. +With prefix argument N, move N items (negative N means move backward). +Optional second argument, if non-nil, means do not copy the completion +back to the minibuffer. + +You can use this command only from buffer *Completions* (`\\\ +\\[icicle-move-to-next-completion]')." + (interactive "p") + (when (interactive-p) (icicle-barf-if-outside-Completions)) + (setq n (or n 0)) + (when (eq icicle-completions-format-internal 'vertical) + (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))) + (setq n (icicle-row-wise-cand-nb n nb-cands rows cols)))) + (let ((beg (icicle-start-of-candidates-in-Completions)) + (end (point-max))) + + ;; Forward: n > 0. + (while (and (> n 0) (not (eobp))) + (when (get-text-property (point) 'mouse-face) ; If in a candidate, move to its end. + (goto-char (next-single-property-change (point) 'mouse-face nil end))) + (unless (get-text-property (point) 'mouse-face) ; Move to start of next candidate. + (goto-char (or (next-single-property-change (point) 'mouse-face) + beg))) ; Wrap back to first candidate. + (setq n (1- n))) + + ;; Backward: n < 0. + (while (and (< n 0) (>= (count-lines 1 (point)) (if icicle-show-Completions-help-flag 3 2))) + (let ((prop (get-text-property (1- (point)) 'mouse-face))) + (when (and prop (eq prop (get-text-property (point) 'mouse-face))) ; If in cand, move to start. + (goto-char (previous-single-property-change (point) 'mouse-face nil beg)))) + (unless (or (< (count-lines 1 (point)) ; Move to end of previous candidate. + (if icicle-show-Completions-help-flag 3 2)) + (get-text-property (1- (point)) 'mouse-face)) + (goto-char (or (previous-single-property-change (point) 'mouse-face) + end))) ; Wrap back to last candidate. + + ;; Move to the start of that candidate. + (goto-char (previous-single-property-change (point) 'mouse-face nil beg)) + (setq n (1+ n))) + + (icicle-place-overlay + (point) (next-single-property-change (point) 'mouse-face nil end) + 'icicle-current-completion-candidate-overlay 'icicle-current-candidate-highlight + 100 (current-buffer))) + (unless no-minibuffer-follow-p (save-excursion (save-window-excursion (icicle-insert-completion))))) + +;;;###autoload +(defun icicle-previous-line () ; Bound to `up' *Completions*. + "Move up a line, in *Completions* buffer. Wrap around first to last. +You can use this command only from buffer *Completions* (`\\\ +\\[icicle-previous-line]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions)) + (let ((opoint (point)) + (curr-col 1) + (next-line-cols 1) + (eol (save-excursion (end-of-line) (point)))) + (save-excursion + (beginning-of-line) + (while (and (< (point) opoint) (re-search-forward "[^ ] +" eol t)) + (setq curr-col (1+ curr-col)))) + (forward-line -1) + (when (< (point) (icicle-start-of-candidates-in-Completions)) + (goto-char (point-max)) (beginning-of-line)) ; Wrap around + (let ((eol (save-excursion (end-of-line) (point)))) + (save-excursion + (beginning-of-line) + (while (re-search-forward "[^ ] +[^ ]" eol t) (setq next-line-cols (1+ next-line-cols))))) + (if (> curr-col next-line-cols) + (icicle-move-to-next-completion (1- next-line-cols)) + (icicle-move-to-next-completion (1- curr-col))))) + +;;;###autoload +(defun icicle-next-line () ; Bound to `down' in *Completions*. + "Move down a line, in *Completions* buffer. Wrap around last to first. +You can use this command only from buffer *Completions* (`\\\ +\\[icicle-next-line]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions)) + (let ((opoint (point)) + (curr-col 1) + (next-line-cols 1) + (eol (save-excursion (end-of-line) (point)))) + (save-excursion + (beginning-of-line) + (while (and (< (point) opoint) (re-search-forward "[^ ] +" eol t)) + (setq curr-col (1+ curr-col)))) + (forward-line 1) + (when (eobp) (goto-char (icicle-start-of-candidates-in-Completions))) ; Wrap around + (let ((eol (save-excursion (end-of-line) (point)))) + (save-excursion + (beginning-of-line) + (while (re-search-forward "[^ ] +[^ ]" eol t) (setq next-line-cols (1+ next-line-cols))))) + (if (> curr-col next-line-cols) + (icicle-move-to-next-completion (1- next-line-cols)) + (icicle-move-to-next-completion (1- curr-col))))) + +;; Same as `end-of-line+' in `misc-cmds.el'. +;;;###autoload +(defun icicle-end-of-line+ (&optional n) ; Bound to `C-e' in minibuffer and in *Completions*. + "Move cursor to end of current line or end of next line if repeated. +This is similar to `end-of-line', but: + If called interactively with no prefix arg: + If the previous command was also `end-of-line+', then move to the + end of the next line. Else, move to the end of the current line. + Otherwise, move to the end of the Nth next line (Nth previous line + if N<0). Command `end-of-line', by contrast, moves to the end of + the (N-1)th next line." + (interactive + (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0))) + (unless n (setq n 0)) ; non-interactive with no arg + (if (and (eq this-command last-command) (not current-prefix-arg)) + (forward-line 1) + (forward-line n)) + (let ((inhibit-field-text-motion t)) ; Emacs 22+, so we get past the end of the prompt field. + (end-of-line))) + +;; Same as `beginning-of-line+' in `misc-cmds.el'. +;;;###autoload +(defun icicle-beginning-of-line+ (&optional n) ; Bound to `C-a' in minibuffer and in *Completions*. + "Move cursor to beginning of current line or next line if repeated. +This is the similar to `beginning-of-line', but: +1. With arg N, the direction is the opposite: this command moves + backward, not forward, N lines. +2. If called interactively with no prefix arg: + If the previous command was also `beginning-of-line+', then move + to the beginning of the previous line. Else, move to the + beginning of the current line. + Otherwise, move to the beginning of the Nth previous line (Nth next + line if N<0). Command `beginning-of-line', by contrast, moves to + the beginning of the (N-1)th next line." + (interactive + (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) 0))) + (unless n (setq n 0)) ; non-interactive with no arg + (if (and (eq this-command last-command) (not current-prefix-arg)) + (forward-line -1) + (forward-line (- n))) + (when (bobp) (goto-char (icicle-minibuffer-prompt-end)))) + + +(put 'icicle-all-candidates-action 'icicle-action-command t) +;;;###autoload +(defun icicle-all-candidates-action () ; Bound to `C-!' in minibuffer. + "Take action on each completion candidate, in turn. +Apply `icicle-candidate-action-fn' successively to each saved +completion candidate (if any) or each candidate that matches the +current input (a regular expression). The candidates that were not +successfully acted upon are listed in buffer *Help*. + +If there are saved completion candidates, then they are acted on; +if not, then all current matching candidates are acted on. + +If `icicle-candidate-action-fn' is nil but +`icicle-all-candidates-list-action-fn' is not, then apply the latter +to the list of candidates as a whole, instead. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-all-candidates-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (unless (or icicle-all-candidates-list-action-fn icicle-candidate-action-fn) + (error "No action defined")) + (if icicle-candidate-action-fn + (icicle-all-candidates-action-1 icicle-candidate-action-fn nil) + (icicle-all-candidates-action-1 icicle-all-candidates-list-action-fn t))) + + +(put 'icicle-all-candidates-alt-action 'icicle-action-command t) +;;;###autoload +(defun icicle-all-candidates-alt-action () ; Bound to `C-|' in minibuffer. + "Take alternative action on each completion candidate, in turn. +Apply `icicle-candidate-alt-action-fn' successively to each saved +completion candidate (if any) or each candidate that matches the +current input (a regular expression). The candidates that were not +successfully acted upon are listed in buffer *Help*. + +If there are saved completion candidates, then they are acted on; if +not, then all current matching candidates are acted on. + +If `icicle-candidate-alt-action-fn' is nil but +`icicle-all-candidates-list-alt-action-fn' is not, then apply the +latter to the list of candidates as a whole, instead. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-all-candidates-alt-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (unless (or icicle-all-candidates-list-alt-action-fn icicle-candidate-alt-action-fn) + (error "No alternative action defined")) + (if icicle-candidate-alt-action-fn + (icicle-all-candidates-action-1 icicle-candidate-alt-action-fn nil t) ; ALTP flag + (icicle-all-candidates-action-1 icicle-all-candidates-list-alt-action-fn t))) + + +(put 'icicle-all-candidates-list-action 'icicle-action-command t) +;;;###autoload +(defun icicle-all-candidates-list-action () ; Bound to `M-!' in minibuffer. + "Take action on the list of all completion candidates. +Apply `icicle-all-candidates-list-action-fn' to the list of saved +completion candidates or the list of candidates that match the current +input (a regular expression). + +If there are saved completion candidates, then they are acted on; if +not, then all current matching candidates are acted on. + +If `icicle-all-candidates-list-action-fn' is nil but +`icicle-candidate-action-fn' is not, then apply the latter to each +matching candidate in turn, and print the candidates that were not +successfully acted upon in buffer *Help*. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-all-candidates-list-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (unless (or icicle-all-candidates-list-action-fn icicle-candidate-action-fn) + (error "No action defined")) + (if icicle-all-candidates-list-action-fn + (icicle-all-candidates-action-1 icicle-all-candidates-list-action-fn t) + (icicle-all-candidates-action-1 icicle-candidate-action-fn nil))) + + +(put 'icicle-all-candidates-list-alt-action 'icicle-action-command t) +;;;###autoload +(defun icicle-all-candidates-list-alt-action () ; Bound to `M-|' in minibuffer. + "Take alternative action on the list of all completion candidates. +Apply `icicle-all-candidates-list-alt-action-fn' to the list of saved +completion candidates or the list of completion candidates that match +the current input (a regular expression). + +If there are saved completion candidates, then they are acted on; +if not, then all current matching candidates are acted on. + +If `icicle-all-candidates-list-alt-action-fn' is nil but +`icicle-candidate-alt-action-fn' is not, then apply the latter to each +matching candidate in turn, and print the candidates that were not +successfully acted upon in buffer *Help*. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-all-candidates-list-alt-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (unless (or icicle-all-candidates-list-alt-action-fn icicle-candidate-alt-action-fn) + (error "No alternative action defined.")) + (unless icicle-completion-candidates + (error "No completion candidates. Did you use `TAB' or `S-TAB'?")) + (if icicle-all-candidates-list-alt-action-fn + (icicle-all-candidates-action-1 icicle-all-candidates-list-alt-action-fn t) + (icicle-all-candidates-action-1 icicle-candidate-alt-action-fn nil t))) ; ALTP flag + +(defun icicle-all-candidates-action-1 (fn-var listp &optional altp) + "Helper function for `icicle-all-candidates(-alt)-action'. +ALTP is used only if LISTP is nil. +ALTP is passed to `icicle-candidate-action-1'." + (let* ((local-saved + (catch 'i-a-c-a-1 + (dolist (cand icicle-saved-completion-candidates icicle-saved-completion-candidates) + (unless (member cand icicle-completion-candidates) (throw 'i-a-c-a-1 nil))))) + (candidates (or local-saved icicle-completion-candidates)) + (failures nil) + (icicle-minibuffer-message-ok-p nil) ; Avoid delays from `icicle-msg-maybe-in-minibuffer'. + (icicle-help-in-mode-line-flag nil) ; Avoid delays for individual candidate help. + (icicle-all-candidates-action-p t)) + (when local-saved (setq icicle-completion-candidates local-saved)) + (if listp + (funcall fn-var candidates) + (while candidates + (let ((error-msg (condition-case act-on-each + (icicle-candidate-action-1 fn-var altp (car candidates)) + (error (error-message-string act-on-each))))) + (when error-msg (setq failures (cons (cons (car candidates) error-msg) failures))) + (setq candidates (cdr candidates)))) + (when failures + (with-output-to-temp-buffer "*Help*" + (princ "Action failures:")(terpri)(terpri) + (mapcar (lambda (entry) + (princ (car entry)) (princ ":") (terpri) (princ " ") + (princ (cdr entry)) (terpri)) + failures)))))) +;; $$$$$$ (icicle-abort-recursive-edit)) + + +(put 'icicle-candidate-action 'icicle-action-command t) +;;;###autoload +(defun icicle-candidate-action () ; Bound to `C-RET' in minibuffer. + "Take action on the current minibuffer-completion candidate. +If `icicle-candidate-action-fn' is non-nil, it is a function to apply +to the current candidate, to perform the action. + +If no action is available in the current context, help on the +candidate is shown - see `icicle-help-on-candidate'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (icicle-candidate-action-1 icicle-candidate-action-fn)) + + +(put 'icicle-candidate-alt-action 'icicle-action-command t) +;;;###autoload +(defun icicle-candidate-alt-action () ; Bound to `C-S-RET' in minibuffer. + "Take alternative action on the current completion candidate. +If `icicle-candidate-alt-action-fn' is non-nil, it is a +function to apply to the current candidate, to perform the action. + +For many Icicles commands, if `icicle-candidate-alt-action-fn' is nil, +you are prompted to choose an alternative action, using completion. + +In any case, any alternative action defined for the current context by +user option `icicle-alternative-actions-alist' always overrides +`icicle-candidate-alt-action'. That is, if +`icicle-alternative-actions-alist' says to use function `foo', then +Icicles uses `foo' as the alternative action, regardless of the value +of `icicle-candidate-alt-action'. + +If no alternative action is available in the current context, help on +the candidate is shown - see `icicle-help-on-candidate'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-alt-action]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (let ((alt-fn (or (cdr (assq icicle-cmd-reading-input icicle-alternative-actions-alist)) + icicle-candidate-alt-action-fn))) + (icicle-candidate-action-1 alt-fn 'alternative-p))) + +(defun icicle-candidate-action-1 (fn-var &optional altp cand) + "Helper function for `icicle-candidate(-alt)-action'. +FN-VAR is an Icicles action function or alternative action function. +Optional arg ALTP non-nil means FN-VAR is alternative action function. +Optional arg CAND non-nil means it is the candidate to act on." + (when cand (setq icicle-last-completion-candidate cand)) + (cond ((not fn-var) (icicle-help-on-candidate cand)) ; It doesn't `icicle-raise-Completions-frame'. + ((icicle-require-match-p) + ;; If no last candidate, then reset to first candidate matching input. + (unless (stringp icicle-last-completion-candidate) + (setq icicle-last-completion-candidate icicle-current-input + last-command (if altp + 'icicle-candidate-alt-action + 'icicle-candidate-action)) + (let ((icicle-help-in-mode-line-flag nil)) ; Avoid delay for candidate help. + (icicle-next-candidate 1 (if (eq icicle-current-completion-mode 'prefix) + 'icicle-prefix-candidates + 'icicle-apropos-candidates) + (not (eq icicle-current-completion-mode 'prefix))))) + + ;; NOTE: We no longer save and restore these things here. + ;; We purposely allow an action function to modify these for subsequent actions. + ;; If you need to save and restore these for a particular action function you define, + ;; then you must do so in the action function itself. This might be the case, for instance, + ;; if your action function does its own completion (e.g. calls `completing-read'), that is, if + ;; it uses a recursive minibuffer. (But do not save and restore if you want the side effect.) + (let (;; (icicle-candidate-nb icicle-candidate-nb) ; $$$$$$ + ;; (icicle-last-completion-candidate icicle-last-completion-candidate) ; $$$$$$ + ;; (icicle-completion-candidates icicle-completion-candidates) ; $$$$$$ + ) + (when icicle-completion-candidates + (funcall fn-var icicle-last-completion-candidate))) + (when (or icicle-use-candidates-only-once-flag + (and altp icicle-use-candidates-only-once-alt-p)) + (icicle-remove-candidate-display-others 'all)) + (icicle-raise-Completions-frame)) + (t + (let ((icicle-last-input (or cand (icicle-input-from-minibuffer))) + (icicle-default-directory icicle-default-directory)) + (when (and (icicle-file-name-input-p) (icicle-file-directory-p icicle-last-input)) + (setq icicle-default-directory icicle-last-input)) + ;; NOTE: We no longer save and restore these things here. + ;; We purposely allow an action function to modify these for subsequent actions. + ;; If you need to save and restore these for a particular action function you define, + ;; then you must do so in the action function itself. This might be the case, for instance, + ;; if your action function does its own completion (e.g. calls `completing-read'), that is, + ;; uses a recursive minibuffer. (But do not save and restore if you want the side effect.) + (let (;; (icicle-candidate-nb icicle-candidate-nb) ; $$$$$$ + ;; (icicle-last-completion-candidate icicle-last-completion-candidate) ; $$$$$$ + ;; (icicle-completion-candidates icicle-completion-candidates) ; $$$$$$ + ) + (funcall fn-var icicle-last-input)) + (when (and (or icicle-use-candidates-only-once-flag + (and altp icicle-use-candidates-only-once-alt-p)) + (equal icicle-last-input + (if (icicle-file-name-input-p) + (expand-file-name icicle-last-completion-candidate + (icicle-file-name-directory icicle-last-input)) + icicle-last-completion-candidate))) + (icicle-remove-candidate-display-others 'all)) + (icicle-raise-Completions-frame))))) + + +;; Bound to `C-down-mouse-2' (`C-mouse-2') in *Completions*. +(put 'icicle-mouse-candidate-action 'icicle-action-command t) +;;;###autoload +(defun icicle-mouse-candidate-action (event) ; `C-mouse-2' + "Take action on the completion candidate clicked by `mouse-2'. +If `icicle-candidate-action-fn' is non-nil, it is a function to apply +to the clicked candidate, to perform the action. + +If `icicle-candidate-action-fn' is nil, the default action is +performed: display help on the candidate - see +`icicle-help-on-candidate'." + (interactive "e") + (icicle-mouse-candidate-action-1 event icicle-candidate-action-fn)) + + +; Bound to `C-S-down-mouse-2' (`C-S-mouse-2') in *Completions*. +(put 'icicle-mouse-candidate-alt-action 'icicle-action-command t) +;;;###autoload +(defun icicle-mouse-candidate-alt-action (event) ; `C-S-mouse-2' + "Take alternative action on the candidate clicked by `mouse-2'. +If `icicle-candidate-alt-action-fn' is non-nil, it is a +function to apply to the clicked candidate, to perform the action. + +If `icicle-candidate-action-fn' is nil, the default action is +performed: display help on the candidate - see +`icicle-help-on-candidate'." + (interactive "e") + (icicle-mouse-candidate-action-1 event icicle-candidate-alt-action-fn)) + +(defun icicle-mouse-candidate-action-1 (event fn-var) + "Helper function for `icicle-mouse-candidate(-alt)-action'." + (run-hooks 'mouse-leave-buffer-hook) ; Give temp modes such as isearch a chance to turn off. + (let ((posn-buf (window-buffer (posn-window (event-start event)))) + (posn-pt (posn-point (event-start event))) + (posn-col (car (posn-col-row (event-start event)))) + (posn-row (cdr (posn-col-row (event-start event)))) + choice) + (read-event) ; Swallow mouse up event. + (with-current-buffer posn-buf + (save-excursion + (goto-char posn-pt) + (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))) + ;; `icicle-insert-candidates' doesn't put `mouse-face' on the final \n of a candidate + ;; in *Completions*. Add the newline back. `icicle-insert-candidates' puts property + ;; `icicle-keep-newline' on the newline if it is part of the candidate, as opposed to + ;; being just part of the display in columns. + (when (and (eq ?\n (char-after end)) (get-text-property end 'icicle-keep-newline)) + (setq end (1+ end))) + (setq choice (if (and (icicle-file-name-input-p) insert-default-directory + (or (not (member (buffer-substring-no-properties beg end) + icicle-extra-candidates)) + icicle-extra-candidates-dir-insert-p)) + (concat default-directory (buffer-substring-no-properties beg end)) + ;; $$$$$$ (buffer-substring-no-properties beg end)))))) + (buffer-substring beg end))) + (remove-text-properties 0 (length choice) '(mouse-face nil) choice)))) + (save-window-excursion + (select-window (active-minibuffer-window)) + (delete-region (icicle-minibuffer-prompt-end) (point-max)) + (insert choice)) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions posn-pt) + icicle-last-completion-candidate choice) + (if (not fn-var) + (icicle-help-on-candidate) ; Doesn't `icicle-raise-Completions-frame'. + + ;; NOTE: We no longer save and restore these things here. + ;; We purposely allow an action function to modify these for subsequent actions. + ;; If you need to save and restore these for a particular action function you define, + ;; then you must do so in the action function itself. This might be the case, for instance, + ;; if your action function does its own completion (e.g. calls `completing-read'), that is, if + ;; it uses a recursive minibuffer. (But do not save and restore if you want the side effect.) + (let (;; (icicle-candidate-nb icicle-candidate-nb) ; $$$$$$ + ;; (icicle-last-completion-candidate icicle-last-completion-candidate) ; $$$$$$ + ;; (icicle-completion-candidates icicle-completion-candidates) ; $$$$$$ + ) + (funcall fn-var icicle-last-completion-candidate)) + (when icicle-use-candidates-only-once-flag (icicle-remove-candidate-display-others 'all)) + (when icicle-completion-candidates (icicle-update-and-next)) + (icicle-raise-Completions-frame posn-col posn-row)))) + + +;; $$$$$ ??? (put 'icicle-remove-candidate 'icicle-action-command t) +;;;###autoload +(defun icicle-remove-candidate () ; Bound to `delete' in minibuffer during completion. + "Remove current completion candidate from the set of candidates. +This has no effect on the object, if any, represented by the +candidate; in particular, that object is not deleted. + +Note: For Emacs versions prior to 22, this does not really remove a +file-name candidate as a possible candidate. If you use \\\ +\\[icicle-prefix-complete] or \\[icicle-apropos-complete], +it will reappear as a possible candidate. + +You can use this command only from the minibuffer (`\\[icicle-remove-candidate]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (icicle-remove-candidate-display-others)) + + +;; $$$$$ ??? (put 'icicle-mouse-remove-candidate 'icicle-action-command t) +;;;###autoload +(defun icicle-mouse-remove-candidate (event) ; Bound to `S-mouse-2' in *Completions*. + "Remove clicked completion candidate from the set of candidates. +This has no effect on the object, if any, represented by the +candidate; in particular, that object is not deleted. + +See `icicle-remove-candidate' for more information." + (interactive "e") + (run-hooks 'mouse-leave-buffer-hook) ; Give temp modes such as isearch a chance to turn off. + (let ((posn-buf (window-buffer (posn-window (event-start event)))) + (posn-pt (posn-point (event-start event))) + beg end) + (read-event) ; Swallow mouse up event. + (with-current-buffer posn-buf + (save-excursion + (goto-char posn-pt) + (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))) + ;; `icicle-insert-candidates' doesn't put `mouse-face' on the final \n of a candidate + ;; in *Completions*. Add the newline back. `icicle-insert-candidates' puts property + ;; `icicle-keep-newline' on the newline if it is part of the candidate, as opposed to + ;; being just part of the display in columns. + (when (and (eq ?\n (char-after end)) (get-text-property end 'icicle-keep-newline)) + (setq end (1+ end))) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions posn-pt) + icicle-last-completion-candidate (buffer-substring beg end))))) + (icicle-remove-candidate-display-others)) + +(defun icicle-remove-candidate-display-others (&optional allp) + "Remove current completion candidate from list of possible candidates. +Redisplay *Completions*, unless there is only one candidate left. +Non-nil optional argument ALLP means remove all occurrences of the +current candidate. Otherwise (nil) means remove only the current +occurrence." + (unless (stringp icicle-last-completion-candidate) + (setq icicle-last-completion-candidate icicle-current-input + last-command 'icicle-delete-candidate-object) + (let ((icicle-help-in-mode-line-flag nil)) ; Avoid delay for candidate help. + (icicle-next-candidate 1 (if (eq icicle-current-completion-mode 'prefix) + 'icicle-prefix-candidates + 'icicle-apropos-candidates) + (not (eq icicle-current-completion-mode 'prefix))))) + (let ((maybe-mct-cand (cond ((consp minibuffer-completion-table) + (icicle-mctized-display-candidate icicle-last-completion-candidate)) + ((arrayp minibuffer-completion-table) + (intern icicle-last-completion-candidate)) + (t + icicle-last-completion-candidate)))) + (icicle-remove-cand-from-lists icicle-last-completion-candidate maybe-mct-cand allp)) + (icicle-update-and-next)) + + +(put 'icicle-delete-candidate-object 'icicle-action-command t) +;;;###autoload +(defun icicle-delete-candidate-object (&optional allp) ; Bound to `S-delete' in minibuffer. + "Delete the object named by the current completion candidate. +With a prefix argument, delete *ALL* objects named by the current set +of candidates, after confirmation. + +Do nothing if `icicle-deletion-action-flag' is nil. + +Otherwise: + +* If the value of variable `icicle-delete-candidate-object' is a + function, then apply it to the current completion candidate. This + should delete some object named by the completion candidate. + +* If `icicle-delete-candidate-object' is not a function, then it + should be a symbol bound to an alist. In this case, invoke + `icicle-delete-candidate-object' to delete the object named by the + current completion candidate from that alist. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-delete-candidate-object]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (when icicle-deletion-action-flag + (if (null icicle-completion-candidates) + (message "Nothing to delete - use `S-TAB', `TAB', or a cycle key") + (if allp + (if (not (let ((icicle-completion-candidates icicle-completion-candidates)) + (yes-or-no-p "Are you SURE you want to DELETE ALL of the matching objects? "))) + (message "OK, nothing deleted") + (dolist (cand icicle-completion-candidates) (icicle-delete-candidate-object-1 cand t)) + (icicle-erase-minibuffer)) + ;; If no last candidate, then reset to first candidate matching input. + (unless (stringp icicle-last-completion-candidate) + (setq icicle-last-completion-candidate icicle-current-input + last-command 'icicle-delete-candidate-object) + (let ((icicle-help-in-mode-line-flag nil)) ; Avoid delay for candidate help. + (icicle-next-candidate 1 (if (eq icicle-current-completion-mode 'prefix) + 'icicle-prefix-candidates + 'icicle-apropos-candidates) + (not (eq icicle-current-completion-mode 'prefix))))) + (icicle-delete-candidate-object-1 icicle-last-completion-candidate))))) + +(defun icicle-delete-candidate-object-1 (cand &optional no-display-p) + "Helper function for `icicle-delete-candidate-object'. +Delete object named CAND. +Optional arg NO-DISPLAY-P non-nil means don't update *Completions*." + (let ((display-cand cand) ; Use local vars: values might change. + (maybe-mct-cand + (cond ((consp minibuffer-completion-table) (icicle-mctized-display-candidate cand)) + ((arrayp minibuffer-completion-table) (intern cand)) + (t cand)))) + (save-selected-window + (let ((icicle-completion-candidates icicle-completion-candidates)) ; In case recursive minibuf. + (if (functionp icicle-delete-candidate-object) + (funcall icicle-delete-candidate-object cand) + (icicle-delete-current-candidate-object cand)))) + (icicle-remove-cand-from-lists display-cand maybe-mct-cand nil) ; Use local vars. + (unless no-display-p (message "Deleted object named: `%s'" display-cand) (sit-for 1.0))) + (unless no-display-p (icicle-update-and-next)) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame))) + +(defun icicle-delete-current-candidate-object (&optional cand) + "Delete the object(s) corresponding to the current completion candidate. +The value of `icicle-delete-candidate-object' must be a symbol +\(variable) that is bound to a list of completion-candidate objects. + +The entries in the list must be completion candidates for the current +call to `completing-read', but the list itself need not be the +COLLECTION argument to `completing-read'. For example, the list might +be a list of symbols, and the COLLECTION argument might be an obarray +that contains those symbols. + +The list can be an alist, a list of strings, or a list of symbols. +Delete, from this list, the objects that correspond to the current +completion candidate. If the variable is also a user option, then +save the option, after deleting the candidate object. + +The full candidate object is what is deleted. If the list contains +multiple identical objects that correspond to the current completion +candidate, they are all deleted." + (setq cand (or cand icicle-last-completion-candidate)) + (let ((val (and (symbolp icicle-delete-candidate-object) + (symbol-value icicle-delete-candidate-object)))) + ;; The message could more accurately say "Value of `icicle-delete-candidate-object' must be + ;; a symbol bound to a list", but this makes more sense. + (unless (and val (consp val)) (error "Cannot delete candidate objects now")) + (set icicle-delete-candidate-object ; Update the variable. + (cond ((or icicle-whole-candidate-as-text-prop-p icicle-candidates-alist) + (delete (funcall icicle-get-alist-candidate-function cand) val)) + ((consp (car val)) + (icicle-assoc-delete-all cand val)) + ((stringp (car val)) (delete cand val)) + ((symbolp (car val)) (delete (intern cand) val)) + (t (error "Entry in list value of `icicle-delete-candidate-object' is \ +not a cons, string, or symbol"))))) + (when (user-variable-p icicle-delete-candidate-object) ; Save the new user-option value. + (funcall icicle-customize-save-variable-function + icicle-delete-candidate-object + (symbol-value icicle-delete-candidate-object)))) + +(defun icicle-remove-cand-from-lists (disp-cand mct-cand allp) + "Delete first occurence or all occurences of candidate. +The appropriate form of the candidate is removed from each of these: + `icicle-candidates-alist' + `icicle-completion-candidates' + `minibuffer-completion-table' (if it is an alist) +DISP-CAND is the display form of the candidate to delete. +MCT-CAND is the MCT alist candidate that corresponds to DISP-CAND. +If any of these conditions is true, remove all occurrences of CAND: + * ALLP is non-nil + * `icicle-transform-function' is `icicle-remove-duplicates' + * `icicle-transform-function' is `icicle-remove-dups-if-extras' + and `icicle-extra-candidates' is non-nil" + (setq allp (or allp (eq icicle-transform-function 'icicle-remove-duplicates) + (and (eq icicle-transform-function 'icicle-remove-dups-if-extras) + icicle-extra-candidates))) + (when icicle-candidates-alist + (setq icicle-candidates-alist + (if allp + (icicle-assoc-delete-all disp-cand icicle-candidates-alist) + (delete (funcall icicle-get-alist-candidate-function disp-cand) icicle-candidates-alist)))) + (when (consp icicle-completion-candidates) + (setq icicle-completion-candidates + (if allp ; Delete only the first occurrence, or all if ALLP. + (delete disp-cand icicle-completion-candidates) + (icicle-delete-count disp-cand icicle-completion-candidates 1)))) + ;; Update `minibuffer-completion-predicate' or `read-file-name-predicate' + ;; to effectively remove this candidate. + (cond ((and (icicle-file-name-input-p) + (boundp 'read-file-name-predicate) ; Emacs 22+ only. + read-file-name-predicate) + (setq read-file-name-predicate + (if read-file-name-predicate + (lexical-let ((curr-pred read-file-name-predicate)) + `(lambda (file-cand) + (and (not (equal ',disp-cand file-cand)) (funcall ',curr-pred file-cand)))) + `(lambda (file-cand) (not (equal ',disp-cand file-cand)))))) + ;; < Emacs 22. Do nothing for file name. + ;; `TAB' or `S-TAB' will bring it back as a candidate. + ((icicle-file-name-input-p)) + (minibuffer-completion-predicate ; Add excluding candidate to existing predicate. + (setq minibuffer-completion-predicate + (lexical-let ((curr-pred minibuffer-completion-predicate)) + `(lambda (cand) ; This corresponds to what we do in `icicle-mctize-all'. + (and (not (equal cand ',(if (and (consp mct-cand) (stringp (car mct-cand))) + (cdr mct-cand) + mct-cand))) + (funcall ',curr-pred cand)))))) + (t ; Set predicate to excluding candidate. + (setq minibuffer-completion-predicate ; This corresponds to what we do in `icicle-mctize-all'. + `(lambda (cand) (not (equal cand ',(if (and (consp mct-cand) (stringp (car mct-cand))) + (cdr mct-cand) + mct-cand)))))))) +;; $$$$$$$$$$$$ COULD USE THIS INSTEAD of updating the predicate, +;; but it works only when `minibuffer-completion-table' is an alist. +;; (when (consp minibuffer-completion-table) +;; (setq minibuffer-completion-table +;; (if allp +;; (delete mct-cand minibuffer-completion-table) +;; (icicle-delete-count mct-cand minibuffer-completion-table 1))))) + +(defun icicle-update-and-next () + "Update *Completions* and make next candidate current. +If we don't know which candidate number this is, just display." + (cond ((and icicle-completion-candidates (cdr icicle-completion-candidates) ; > 1 candidates left. + (not (input-pending-p))) ; Do nothing if user hit another key. + (icicle-maybe-sort-and-strip-candidates) + (message "Displaying completion candidates...") + (save-selected-window (icicle-display-candidates-in-Completions)) + (when (wholenump icicle-candidate-nb) + (with-current-buffer "*Completions*" + (goto-char (icicle-start-of-candidates-in-Completions)) + (icicle-move-to-next-completion + (mod icicle-candidate-nb (length icicle-completion-candidates))) + (set-window-point (get-buffer-window "*Completions*" 0) (point)) + (setq icicle-last-completion-candidate (icicle-current-completion-in-Completions)) + (set-buffer-modified-p nil)))) + (icicle-completion-candidates ; Single candidate left + (save-selected-window (icicle-remove-Completions-window)) + (let ((completion (icicle-transform-multi-completion (car icicle-completion-candidates)))) + (select-window (active-minibuffer-window)) + (with-current-buffer (window-buffer) ; Needed if *Completions* redirected to minibuffer. + (goto-char (icicle-minibuffer-prompt-end)) + (icicle-clear-minibuffer) + (insert (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)) + (icicle-file-name-directory-w-default icicle-current-input) + "") + completion)))) + (t ; No candidates left + ;; $$$$$$$$ `icicle-abort-recursive-edit' and `exit-recursive-edit' don't work, + ;; because they take us back to top level. + ;; $$$$ DO NOTHING? Do (icicle-remove-Completions-window)? Do (icicle-erase-minibuffer)? + (icicle-erase-minibuffer)))) + + +(put 'icicle-mouse-help-on-candidate 'icicle-action-command t) +;;;###autoload +(defun icicle-mouse-help-on-candidate (event) ; Bound to `C-M-mouse-2' in minibuffer. + "Display help on the minibuffer-completion candidate clicked by mouse." + (interactive "e") + (let ((icicle-candidate-action-fn nil)) (icicle-mouse-candidate-action event))) + + +;; Free vars here: `orig-buf' is bound in `icicle-complete-keys'. +;; `icicle-complete-keys-alist' is bound in `icicles-var.el'. +(put 'icicle-help-on-candidate 'icicle-action-command t) +;;;###autoload +(defun icicle-help-on-candidate (&optional cand) ; Bound to `C-M-RET', `C-help', `C-f1' in minibuffer. + ; Bound to `C-M-RET' in *Completions. + "Display help on the current minibuffer-completion candidate. +The help displayed depends on the type of candidate, as follows: + + menu item - the corresponding command is described using + `describe-function' (only if `lacarte.el' is loaded) + command or other function - described using `describe-function' + keymap variable - described using `describe-keymap' + (if available - see library `help-fns+.el') + user option or other variable - described using `describe-variable' + face - described using `describe-face' + command abbreviation - described using `apropos-command' for matches + property list - described using `apropos-describe-plist' + buffer name - modes described using `describe-mode' (Emacs > 20) + file name - file properties described + +If the same candidate names a function, a variable, and a face, or any +two of these, then all such documentation is shown (Emacs 22+). + +In the minibuffer, you can also use `\\\ +\\[icicle-help-on-next-apropos-candidate]', `\\[icicle-help-on-previous-apropos-candidate]', +`\\[icicle-help-on-next-prefix-candidate]', and \ +`\\[icicle-help-on-previous-prefix-candidate]', to display help on the candidate and then +move to the next or previous candidate. See, for example, +`icicle-help-on-next-apropos-candidate'. +\ +You can use this command only from the minibuffer or *Completions* +\(`\\[icicle-help-on-candidate]')." + (interactive) ; Interactively, just describes itself. + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (let ((frame-with-focus (selected-frame)) + (cand-symb nil) + transformed-cand) + (cond (cand (setq icicle-last-completion-candidate cand)) + ((eq (current-buffer) (get-buffer "*Completions*")) + (setq icicle-last-completion-candidate (icicle-current-completion-in-Completions))) + ;; If no last candidate, then reset to first candidate matching input. + ((not (stringp icicle-last-completion-candidate)) + (setq icicle-last-completion-candidate icicle-current-input + last-command 'icicle-help-on-candidate) + (let ((icicle-help-in-mode-line-flag nil)) ; Avoid delay for candidate help. + (icicle-next-candidate 1 (if (eq icicle-current-completion-mode 'prefix) + 'icicle-prefix-candidates + 'icicle-apropos-candidates) + (not (eq icicle-current-completion-mode 'prefix)))))) + (cond (;; Use special help function. + icicle-candidate-help-fn + (funcall icicle-candidate-help-fn icicle-last-completion-candidate)) + + (;; Call to `lacarte-execute(-menu)-command' (defined in `lacarte.el'). + ;; Use command associated with menu item. + (consp lacarte-menu-items-alist) ; `lacarte-menu-items-alist' is in `lacarte.el'. + (setq cand-symb (cdr (assoc icicle-last-completion-candidate lacarte-menu-items-alist))) + (if cand-symb + (icicle-help-on-candidate-symbol cand-symb) + (icicle-msg-maybe-in-minibuffer "No help"))) ; Menu item with lambda definition. + + (;; A key-completion candidate. Get the true command from the candidate. + (and (boundp 'icicle-completing-keys-p) icicle-completing-keys-p) + (save-match-data + (string-match "\\(.+\\) = \\(.+\\)" icicle-last-completion-candidate) + (setq cand-symb (intern-soft (substring icicle-last-completion-candidate + (match-beginning 2) (match-end 2)))) + (cond ((eq '\.\.\. cand-symb) ; Prefix key - describe its binding. + (with-current-buffer orig-buff + (describe-key (car-safe + (cdr-safe + (assq (intern-soft + (substring icicle-last-completion-candidate + (match-beginning 0) (match-end 0))) + icicle-complete-keys-alist)))))) + (cand-symb (icicle-help-on-candidate-symbol cand-symb)) ; Describe key's command. + (t (icicle-msg-maybe-in-minibuffer "No help"))))) + + (t;; Transform candidate, in case it's a multi-completion. + (setq transformed-cand (icicle-transform-multi-completion + icicle-last-completion-candidate)) + ;; If buffer or file, describe its properties. Otherwise, create symbol and get its help. + (cond ((and (bufferp (get-buffer transformed-cand)) + (with-current-buffer transformed-cand (describe-mode) t))) + ((file-exists-p transformed-cand) (icicle-describe-file transformed-cand)) + (t (icicle-help-on-candidate-symbol (intern transformed-cand)))))) + ;;$$$ (icicle-raise-Completions-frame) + + ;; This is a hack for MS Windows - otherwise, we can't continue to get more candidates, + ;; because the *Help* frame takes the focus away from the minibuffer frame. + ;; MS Windows always gives focus to a newly created frame - in this case, *Help*. + (let* ((help-window (get-buffer-window "*Help*" 0)) + (help-frame (and help-window (window-frame help-window)))) + (when help-frame (redirect-frame-focus help-frame frame-with-focus)))) + (message nil)) ; Let minibuffer contents show immmediately. + +(defun icicle-help-on-candidate-symbol (symb) + "Helper function for `icicle-help-on-candidate'. The arg is a symbol." + (cond ((and (fboundp 'describe-keymap) (boundp symb) (keymapp (symbol-value symb))) + (describe-keymap symb)) + ((and (fboundp 'help-follow-symbol) ; Emacs 22+ + (or (fboundp symb) (boundp symb) (facep symb))) + (with-current-buffer (get-buffer-create "*Help*") + (let ((help-xref-following t)) (help-xref-interned symb))) + (when (fboundp 'fit-frame-if-one-window) + (save-selected-window (select-window (get-buffer-window "*Help*" 'visible)) + (fit-frame-if-one-window)))) + ((fboundp symb) (describe-function symb)) + ((boundp symb) (describe-variable symb)) + ((facep symb) (describe-face symb)) + ((assq symb (mapcar #'cdr icicle-command-abbrev-alist)) + (let ((regexp (icicle-command-abbrev-regexp symb))) (apropos-command regexp))) + ((symbol-plist symb) (apropos-describe-plist symb)) + (t + (setq symb (symbol-name symb)) ; Convert symbol to string, and try some more. + (cond ((and (bufferp (get-buffer symb)) + (with-current-buffer (get-buffer symb) (describe-mode) t))) + ((file-exists-p symb) (icicle-describe-file symb)) + (t (icicle-msg-maybe-in-minibuffer "No help")))))) + +;; This is the same as `describe-file' in `misc-cmds.el', but we avoid requiring that library. +;; This is a top-level command, but we put it here to avoid library require cycles. +;;;###autoload +(if (and (not (fboundp 'icicle-describe-file)) (fboundp 'describe-file)) + (defalias 'icicle-describe-file (symbol-function 'describe-file)) + (defun icicle-describe-file (filename) ; Suggestion: bind to `C-h M-f'. + "Describe the file named FILENAME. +If FILENAME is nil, describe the current directory." + (interactive "FDescribe file: ") + (unless filename (setq filename default-directory)) + (help-setup-xref (list #'icicle-describe-file filename) (interactive-p)) + (let ((attrs (file-attributes filename))) + (unless attrs (error(format "Cannot open file `%s'" filename))) + (let* ((type (nth 0 attrs)) + (numlinks (nth 1 attrs)) + (uid (nth 2 attrs)) + (gid (nth 3 attrs)) + (last-access (nth 4 attrs)) + (last-mod (nth 5 attrs)) + (last-status-chg (nth 6 attrs)) + (size (nth 7 attrs)) + (permissions (nth 8 attrs)) + ;; Skip 9: t iff file's gid would change if file were deleted and recreated. + (inode (nth 10 attrs)) + (device (nth 11 attrs)) + (help-text + (concat (format "Properties of `%s':\n\n" filename) + (format "Type: %s\n" + (cond ((eq t type) "Directory") + ((stringp type) (format "Symbolic link to `%s'" type)) + (t "Normal file"))) + (format "Permissions: %s\n" permissions) + (and (not (eq t type)) (format "Size in bytes: %g\n" size)) + (format-time-string + "Time of last access: %a %b %e %T %Y (%Z)\n" last-access) + (format-time-string + "Time of last modification: %a %b %e %T %Y (%Z)\n" last-mod) + (format-time-string + "Time of last status change: %a %b %e %T %Y (%Z)\n" last-status-chg) + (format "Number of links: %d\n" numlinks) + (format "User ID (UID): %s\n" uid) + (format "Group ID (GID): %s\n" gid) + (format "Inode: %S\n" inode) + (format "Device number: %s\n" device)))) + (with-output-to-temp-buffer "*Help*" (princ help-text)) + help-text)))) ; Return displayed text. + +;;;###autoload +(defun icicle-candidate-read-fn-invoke () ; Bound to `M-RET' in minibuffer. + "Read function name. Invoke function on current completion candidate. +Set `icicle-candidate-action-fn' to the interned name. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-read-fn-invoke]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + ;; If no last candidate, then reset to first candidate matching input. + (unless (stringp icicle-last-completion-candidate) + (setq icicle-last-completion-candidate icicle-current-input + last-command 'icicle-candidate-action) + (let ((icicle-help-in-mode-line-flag nil)) ; Avoid delay for candidate help. + (icicle-next-candidate 1 (if (eq icicle-current-completion-mode 'prefix) + 'icicle-prefix-candidates + 'icicle-apropos-candidates) + (not (eq icicle-current-completion-mode 'prefix))))) + (let ((icicle-whole-candidate-as-text-prop-p nil) + (enable-recursive-minibuffers t) + (icicle-saved-completion-candidate icicle-last-completion-candidate) + (icicle-candidate-action-fn 'icicle-apply-to-saved-candidate)) + (icicle-apply-to-saved-candidate + (completing-read (format "Function to apply to `%s': " icicle-saved-completion-candidate) + obarray 'functionp)))) + +;;;###autoload +(defun icicle-mouse-candidate-read-fn-invoke (event) ; Bound to `M-mouse-2' in *Completions*. + "Read function name. Invoke function on candidate clicked by mouse." + (interactive "e") + (run-hooks 'mouse-leave-buffer-hook) ; Give temp modes such as isearch a chance to turn off. + (let (;;$$$$$$ (buffer (window-buffer)) + (posn-win (posn-window (event-start event))) + (posn-col (car (posn-col-row (event-start event)))) + (posn-row (cdr (posn-col-row (event-start event)))) + choice base-size) + ;; (read-event) ; Swallow mouse up event. $$ Not needed if bound to up event. + (with-current-buffer (window-buffer posn-win) + (save-excursion + ;; $$$$$$ (when completion-reference-buffer (setq buffer completion-reference-buffer)) + (setq base-size completion-base-size) + (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)) + choice (buffer-substring-no-properties beg end))))) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions + (posn-point (event-start event))) + icicle-last-completion-candidate choice) + (let ((icicle-whole-candidate-as-text-prop-p nil) + (enable-recursive-minibuffers t) + (icicle-saved-completion-candidate icicle-last-completion-candidate) + (icicle-candidate-action-fn 'icicle-apply-to-saved-candidate)) + (icicle-apply-to-saved-candidate + (completing-read (format "Function to apply to `%s': " icicle-saved-completion-candidate) + obarray 'functionp))))) + +(defun icicle-apply-to-saved-candidate (function &optional use-icicle-candidates-alist-p type) + "Apply FUNCTION to `icicle-saved-completion-candidate'. +If `current-prefix-arg' is non-nil, then pretty-print the result using +`icicle-pp-eval-expression'. +The string FUNCTION is read to obtain the real function to apply. +If optional arg USE-ICICLE-CANDIDATES-ALIST-P is non-nil, then try to +get the real function using `icicle-get-alist-candidate-function'. +If that returns nil, then read string FUNCTION. +Optional arg TYPE is the type of object that FUNCTION applies to." + (let ((real-fn (or (and use-icicle-candidates-alist-p + (cdr (funcall icicle-get-alist-candidate-function + function 'no-error-no-msg))) + (car (read-from-string function)))) + (real-obj (if (equal type "buffer") ; $$$$$$$ Eventually, perhaps look up TYPE in a list etc. + (get-buffer icicle-saved-completion-candidate) + icicle-saved-completion-candidate))) + ;; Actually, we should test more than `functionp', to rule out macros and special forms. + (unless (functionp real-fn) (error "Not a function: `%S'" real-fn)) + (condition-case icicle-apply-to-saved-candidate + (if current-prefix-arg + (icicle-pp-eval-expression '(funcall real-fn real-obj)) + (funcall real-fn real-obj) + (when (current-message) (sit-for 3))) ; In case the function displays a message. + (error (message (format "ERROR invoking `%S' on `%s': %s" real-fn + icicle-saved-completion-candidate + (error-message-string icicle-apply-to-saved-candidate))) + (sleep-for 6))) + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + (icicle-raise-Completions-frame))) + +(defun icicle-raise-Completions-frame (&optional mouse-col mouse-row) + "Raise *Completions* frame, if displayed. +This helps keep *Completions* on top. + +If `icicle-Completions-frame-at-right-flag' is non-nil and +*Completions* is in its own frame, then move that frame to the right, +out of the way. + +Non-nil optional args MOUSE-COL and MOUSE-ROW move the mouse pointer +to column MOUSE-COL and row MOUSE-ROW. Do this because +`icicle-candidate-action-fn' can call `select-frame-set-input-focus', +which can position mouse pointer on a standalone minibuffer frame." + ;; Raise *Completions* frame, if displayed. This helps keep *Completions* on top. + (let ((compl-win (get-buffer-window "*Completions*" 'visible))) + (when compl-win + (save-window-excursion + (select-window compl-win) + ;; Move frame to the right, out of the way. + (when (and (one-window-p t) icicle-Completions-frame-at-right-flag) + (modify-frame-parameters + (selected-frame) ; Hard-code 7 here - what does it depend on? + `((left . ,(- (x-display-pixel-width) (+ (frame-pixel-width) 7))))) + (raise-frame) + (when (and (integerp mouse-col) (integerp mouse-row)) + (set-mouse-position (selected-frame) mouse-col mouse-row))))))) + +;;;###autoload +(defun icicle-Completions-mouse-3-menu (event) ; Bound to `C-mouse-3' in *Completions. + "Pop-up menu on `C-mouse-3' for the current candidate in *Completions*." + (interactive "e") + (run-hooks 'mouse-leave-buffer-hook) ; Give temp modes such as isearch a chance to turn off. + (let (;; $$$$$$ (buffer (window-buffer)) + (posn-win (posn-window (event-start event))) + (posn-col (car (posn-col-row (event-start event)))) + (posn-row (cdr (posn-col-row (event-start event)))) + candidate base-size menu-choice) + ;; (read-event) ; Swallow mouse up event. $$ Not needed if bound to up event. + (with-current-buffer (window-buffer posn-win) + (save-excursion + ;; $$$$$$ (when completion-reference-buffer (setq buffer completion-reference-buffer)) + (setq base-size completion-base-size) + (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)) + candidate (buffer-substring-no-properties beg end))))) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions (posn-point (event-start event))) + icicle-last-completion-candidate candidate + menu-choice + (x-popup-menu + event + (list + "Completion Candidate" + (list + "$$ NOT USED $$" + '("Help About (`C-M-RET')" . icicle-help-on-candidate) + '("Act On (`C-RET', `C-mouse-2')" . icicle-candidate-action) + '("Apply a Function To... (`M-RET', `M-mouse-2')" . icicle-candidate-read-fn-invoke) + '("Insert in Minibuffer (`insert')" . + (lambda () + (interactive) + (select-window (active-minibuffer-window)) + (goto-char (icicle-minibuffer-prompt-end)) + (icicle-clear-minibuffer) + (insert icicle-last-completion-candidate))) + '("--") + '("--") + '("Change Sort Order (`C-,')" . icicle-change-sort-order) + '("Change Alternative Sort Order (`M-,')" . icicle-change-alternative-sort-order) + '("Swap Alternative Sort (`C-M-,')" . icicle-toggle-alternative-sorting) + '("--") + '("Save All (`C-M->')" . icicle-candidate-set-save) + '(" to Variable... (`C-M-})' " . icicle-candidate-set-save-to-variable) + '(" to Cache File... (`C-})" . icicle-candidate-set-save-persistently) + '("Add All to Saved (`C->')" . icicle-candidate-set-save-more) + '("Save Selected (Region) Candidates (`C-M-)')" . icicle-candidate-set-save-selected) + '("Add Selected (Region) Candidates (`C-)')" . icicle-candidate-set-save-more-selected) + '("Retrieve Saved (`C-M-<')" . icicle-candidate-set-retrieve) + '("Retrieve More Saved (`C-<')" . icicle-candidate-set-retrieve-more) + '("--") + '("Complement All (`C-~')" . icicle-candidate-set-complement) + '("Or Match Alternative... (`M-+')" . icicle-widen-candidates) + '("Match Also Regexp... (`M-*')" . icicle-narrow-candidates) + '("Satisfy Also Predicate... (`M-&')" . icicle-narrow-candidates-with-predicate) + '("Save Predicate to Variable... (`C-M-&')" . icicle-save-predicate-to-variable) + '("Intersect Saved (`C-*')" . icicle-candidate-set-intersection) + '("Subtract Saved (`C--')" . icicle-candidate-set-difference) + '("Add (Union) Saved (`C-+')" . icicle-candidate-set-union) + '("Only Previously Entered (`M-pause')" . icicle-keep-only-past-inputs) + '("--") + '("Act on Each Individually (`C-!')" . icicle-all-candidates-action) + '("Act on All as a List (`M-!')" . icicle-all-candidates-list-action) + '("--") + '("Toggle Highlighting Past Inputs (`C-pause')" . + icicle-toggle-highlight-historical-candidates) + '("Toggle Duplicate Removal (`C-$')" . icicle-toggle-transforming) + '("Toggle Case Sensitivity (`C-A')" . icicle-toggle-case-sensitivity) + '("Regexp-Quote Input (`C-M-;')" . icicle-regexp-quote-input) + '("Toggle `.' Matching Newlines Too (`C-M-.')" . icicle-toggle-dot) + '("Toggle Escaping Special Regexp Chars (`C-`')" . icicle-toggle-regexp-quote) + '("Toggle Incremental Completion (`C-#')" . icicle-toggle-incremental-completion) + '("Toggle Common Match Expansion (`C-;')" . icicle-toggle-expand-to-common-match) + '("Toggle Hiding Common Match (`C-x .')" . icicle-toggle-hiding-common-match) + '("Next S-TAB Completion Method (`M-(')" . icicle-next-S-TAB-completion-method) + '("Next TAB Completion Method (`C-(')" . icicle-next-TAB-completion-method) + '("Toggle Including Proxy Candidates (`C-M-_')" . icicle-toggle-proxy-candidates) + '("Toggle WYSIWYG for *Completions*" . icicle-toggle-WYSIWYG-Completions) + '("Toggle Angle Brackets" . icicle-toggle-angle-brackets) + '("Toggle Ignored File Extensions (`C-.')" . icicle-toggle-ignored-extensions) + '("Toggle Checking Remote Files (`C-^')" . icicle-toggle-remote-file-testing) + '("Toggle Ignoring Space Prefix (`M-_')" . icicle-toggle-ignored-space-prefix) + '("Toggle Using `C-' for Actions (`M-g')" . icicle-toggle-C-for-actions) + '("Toggle Using `~' for $HOME (`M-~')" . icicle-toggle-~-for-home-dir) + '("--") + '("Toggle All-Current Search Highlighting (`C-^')" . + icicle-toggle-highlight-all-current) + '("Toggle Whole-Word Searching (`M-q')" . icicle-toggle-search-whole-word) + '("Toggle Removal of Search Highlighting (`C-.')" . icicle-toggle-search-cleanup) + '("Toggle Replacing Whole Search Hit (`M-_')" . icicle-toggle-search-replace-whole) + '("Toggle Replacing Expanded Common Match (`M-;')" . + icicle-toggle-search-replace-common-match) + '("--") + '("+ Toggle Any Option..." . icicle-toggle-option) + '("+ Turn Off Option..." . icicle-reset-option-to-nil) + '("+ Turn On Option..." . icicle-set-option-to-t) + '("--") + '("Restore Previous Completion Input (`C-l')" . icicle-retrieve-previous-input) + '("Restore Next Completion Input (`C-L')" . icicle-retrieve-next-input) + '("One-Off Eval... (`M-:')" . icicle-pp-eval-expression-in-minibuffer) + '("Insert `icicle-input-string' (`C-=')" . icicle-insert-string-from-variable) + '("--") + '("Icicles Help (`C-?')" . icicle-minibuffer-help))))) + (and menu-choice (call-interactively menu-choice)))) + +;;;###autoload +(defun icicle-widen-candidates () ; Bound to `M-+' in minibuffer. + "Complete, allowing also candidates that match an alternative regexp. +You are prompted for the alternative input pattern. Use `RET' to +enter it. + +To (apropos) complete using a wider set of candidates, you use this +command after you have completed (`TAB' or `S-TAB'). A shortcut is to +use `\\\\[icicle-apropos-complete-and-widen]' - \ +it is the same as `S-TAB' followed by `\\[icicle-widen-candidates]'. + +This command turns off `icicle-expand-input-to-common-match-flag', for +clarity. You can use `\\[icicle-toggle-expand-to-common-match]' \ +to toggle that option." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (unless icicle-completion-candidates + (error "No completion candidates. Did you use `TAB' or `S-TAB'?")) + (let* ((raw-input icicle-current-raw-input) + (enable-recursive-minibuffers t) + (new-regexp (icicle-read-string "Or match alternative (use RET): " + nil regexp-history))) + (setq icicle-current-raw-input + (concat (if (< emacs-major-version 22) "\\(" "\\(?:") raw-input "\\|" new-regexp "\\)") + icicle-expand-input-to-common-match-flag nil)) + (icicle-clear-minibuffer) + (insert icicle-current-raw-input) + (let ((icicle-edit-update-p t)) (icicle-apropos-complete)) + (icicle-msg-maybe-in-minibuffer "Expansion to common match is OFF. \ +`\\\\[icicle-toggle-expand-to-common-match]' to toggle")) + +;;;###autoload +(defun icicle-narrow-candidates () ; Bound to `M-*' in minibuffer. + "Narrow the set of completion candidates using another input regexp. +This, in effect, performs a set intersection operation on 1) the set +of candidates in effect before the operation and 2) the set of +candidates that match the current input. You can repeatedly use this +command to continue intersecting candidate sets, progressively +narrowing the set of matches. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-narrow-candidates]')." + ;; We handle `no-catch' errors here because `old-completing-read' and + ;; `old-read-file-file-name' can still be called in Icicle mode by, for instance, an + ;; `interactive' spec (e.g. (interactive "bBuffer: ")). In that case, we throw to a + ;; non-existant catch. After doing that, we just insert the result, to pass it to the + ;; next-higher recursive minibuffer. + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (let (;; Restore match function, in case it was bound to nil, e.g., by `C-h C-o'. + (icicle-apropos-complete-match-fn icicle-last-apropos-complete-match-fn) + (icicle-progressive-completing-p t) ; Inhibit completion by `icicle-minibuffer-setup'. + (enable-recursive-minibuffers t)) + (cond ((and icicle-completion-candidates (null (cdr icicle-completion-candidates))) + (if (not (and icicle-top-level-when-sole-completion-flag + (sit-for icicle-top-level-when-sole-completion-delay))) + (minibuffer-message " [Sole completion]") + (set minibuffer-history-variable (cons (car icicle-completion-candidates) + (symbol-value minibuffer-history-variable))) + ;; $$$$$$ Should this now use `icicle-current-input' + ;; instead of (car icicle-completion-candidates), for PCM? + (condition-case i-narrow-candidates + (throw 'icicle-read-top + (if (and (icicle-file-name-input-p) insert-default-directory + (or (not (member (car icicle-completion-candidates) + icicle-extra-candidates)) + icicle-extra-candidates-dir-insert-p)) + (expand-file-name (car icicle-completion-candidates)) + (car icicle-completion-candidates))) + (no-catch (setq icicle-current-input (car icicle-completion-candidates)) + (icicle-retrieve-last-input) + icicle-current-input) + (error (message (error-message-string i-narrow-candidates)))))) + (t + (let* (;; $$$$$$$$$$$$$ (icicle-whole-candidate-as-text-prop-p nil) + (minibuffer-setup-hook ; Make sure the new minibuffer is the reference buffer. + (cons + (lambda () + (with-current-buffer (get-buffer-create "*Completions*") + (set (make-local-variable 'completion-reference-buffer) + (window-buffer (active-minibuffer-window))))) + minibuffer-setup-hook)) + (current-candidates icicle-completion-candidates) + (result + (cond ((and (icicle-file-name-input-p) + (or (= emacs-major-version 22) ; Emacs 22 or 23.1 + (and (= emacs-major-version 23) (= emacs-minor-version 1)))) + (read-file-name "Match also (regexp): " + (icicle-file-name-directory-w-default icicle-current-input) + nil icicle-require-match-p nil + (lambda (file-cand) (member file-cand current-candidates)))) + + ((and (icicle-file-name-input-p) (> emacs-major-version 22)) ; Emacs 23.2+ + (completing-read "Match also (regexp): " + 'read-file-name-internal + (lambda (file-cand) (member file-cand current-candidates)) + icicle-require-match-p nil minibuffer-history-variable)) + + (t ; Emacs 20, 21 + ;; In Emacs < 22, there is no PREDICATE arg to `read-file-name', so + ;; we use `completing-read' even for file-name completion. In that case, we + ;; tack the `default-directory' onto each candidate, unless it is already an + ;; absolute file name. We also let completion functions (e.g. `S-TAB') know + ;; that this is not really file-name completion. + (completing-read + "Match also (regexp): " + (cond ((icicle-file-name-input-p) + (setq minibuffer-completing-file-name nil) ; Disavow completing file. + (let ((dir (icicle-file-name-directory-w-default + icicle-current-input))) + (mapcar (lambda (file) + (list (if (file-name-absolute-p file) + file + (concat dir file)))) + icicle-completion-candidates))) + (icicle-whole-candidate-as-text-prop-p + (mapcar (lambda (cand) + (funcall icicle-get-alist-candidate-function (car cand))) + (icicle-filter-alist minibuffer-completion-table + icicle-completion-candidates))) + (t + (mapcar #'list icicle-completion-candidates))) + nil icicle-require-match-p nil minibuffer-history-variable))))) + ;; Normally, `icicle-narrow-candidates' is called from the minibuffer. + ;; If not, just return the result read. + (if (> (minibuffer-depth) 0) + (condition-case i-narrow-candidates + (throw 'icicle-read-top result) + (no-catch (setq icicle-current-input result) + (icicle-retrieve-last-input) + icicle-current-input) + (error (message (error-message-string i-narrow-candidates)))) + result)))))) + +;;;###autoload +(defun icicle-apropos-complete-and-widen () ; Bound to `S-DEL' in minibuffer. + "Apropos complete, then `icicle-widen-candidates'. +You must enter the new, alternative input pattern using `RET'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-apropos-complete-and-widen]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + ;; $$$$$ (let ((icicle-top-level-when-sole-completion-flag t)) + (when (eq icicle-current-completion-mode 'prefix) + (let ((icicle-incremental-completion-p nil) + (regexp-quoted-input (regexp-quote icicle-last-input))) + (setq regexp-quoted-input (if (icicle-file-name-input-p) + (concat (icicle-file-name-directory regexp-quoted-input) "^" + (file-name-nondirectory regexp-quoted-input)) + (concat "^" regexp-quoted-input))) + (icicle-erase-minibuffer) + (insert regexp-quoted-input))) + (if (eq icicle-last-completion-command 'icicle-apropos-complete-no-display) + (icicle-apropos-complete-no-display) + (icicle-apropos-complete)) + (icicle-widen-candidates)) + +;;;###autoload +(defun icicle-apropos-complete-and-narrow () ; Bound to `S-SPC' in minibuffer. + "Apropos complete, then `icicle-narrow-candidates'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-apropos-complete-and-narrow]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + ;; $$$$$ (let ((icicle-top-level-when-sole-completion-flag t)) + (when (eq icicle-current-completion-mode 'prefix) + (let ((icicle-incremental-completion-p nil) + (regexp-quoted-input (regexp-quote icicle-last-input))) + (setq regexp-quoted-input (if (icicle-file-name-input-p) + (concat (icicle-file-name-directory regexp-quoted-input) "^" + (file-name-nondirectory regexp-quoted-input)) + (concat "^" regexp-quoted-input))) + (icicle-erase-minibuffer) + (insert regexp-quoted-input))) + (setq icicle-next-apropos-complete-cycles-p nil) + (if (eq icicle-last-completion-command 'icicle-apropos-complete-no-display) + (icicle-apropos-complete-no-display) + (icicle-apropos-complete)) + (icicle-narrow-candidates)) + +;;;###autoload +(defun icicle-narrow-candidates-with-predicate (&optional predicate) ; Bound to `M-&' in minibuffer. + "Narrow the set of completion candidates by applying a predicate. +You can repeatedly use this command to apply additional predicates, +progressively narrowing the set of candidates. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-narrow-candidates-with-predicate]'). + +When called from Lisp with non-nil arg PREDICATE, use that to narrow." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (let (;; Restore match function, in case it was bound to nil, e.g., by `C-h C-o'. + (icicle-apropos-complete-match-fn icicle-last-apropos-complete-match-fn) + (icicle-progressive-completing-p t) ; Inhibit completion by `icicle-minibuffer-setup'. + (last-completion-cmd (or icicle-last-completion-command 'icicle-apropos-complete)) + (enable-recursive-minibuffers t)) + (cond ((null icicle-completion-candidates) + (error "No completion candidates. Did you use `TAB' or `S-TAB'?")) + ((null (cdr icicle-completion-candidates)) + (if (not (and icicle-top-level-when-sole-completion-flag + (sit-for icicle-top-level-when-sole-completion-delay))) + (minibuffer-message " [Sole completion]") + (set minibuffer-history-variable (cons (car icicle-completion-candidates) + (symbol-value minibuffer-history-variable))) + ;; $$$$$$ Should this now use `icicle-current-input' + ;; instead of (car icicle-completion-candidates), for PCM? + (condition-case i-narrow-candidates + (throw 'icicle-read-top + (if (and (icicle-file-name-input-p) insert-default-directory + (or (not (member (car icicle-completion-candidates) + icicle-extra-candidates)) + icicle-extra-candidates-dir-insert-p)) + (expand-file-name (car icicle-completion-candidates)) + (car icicle-completion-candidates))) + (no-catch (setq icicle-current-input (car icicle-completion-candidates)) + (icicle-retrieve-last-input) + icicle-current-input) + (error (message (error-message-string i-narrow-candidates)))))) + (t + ;; Read new predicate to apply. + (let ((pred (or predicate + (icicle-read-from-minibuf-nil-default "Additional predicate to apply: " + nil read-expression-map t + (if (boundp 'function-name-history) + 'function-name-history + 'icicle-function-name-history))))) + ;; Update `read-file-name-predicate' or `minibuffer-completion-predicate' + ;; to also use new predicate, PRED. + (cond ((and (icicle-file-name-input-p) (boundp 'read-file-name-predicate)) + ;; File name input, Emacs 22+. Update `read-file-name-predicate'. + (setq read-file-name-predicate + (if read-file-name-predicate + (lexical-let ((curr-pred read-file-name-predicate)) + `(lambda (file-cand) + (and (funcall ',curr-pred file-cand) (funcall ',pred file-cand)))) + pred))) + ((icicle-file-name-input-p) + ;; File name input, Emacs < 22. We can do nothing for file name. + ;; `TAB' or `S-TAB' will unfortunately bring it back as a candidate. + ) + (t + ;; Non-file name input. Update `minibuffer-completion-predicate'. + (setq minibuffer-completion-predicate + (if minibuffer-completion-predicate + (lexical-let ((curr-pred minibuffer-completion-predicate)) + `(lambda (cand) + (and (funcall ',curr-pred cand) (funcall ',pred cand)))) + pred))))))) + (funcall last-completion-cmd))) + +;;;###autoload +(defun icicle-save-predicate-to-variable (askp) ; Bound to `C-M-&' in minibuffer. + "Save the current completion predicate to a variable. +By default, the variable is `icicle-input-string'. If you use a +prefix argument, then you are prompted for the variable to use. + +You can retrieve the saved predicate as a string using `\\\ +\\[icicle-insert-string-from-variable]'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-save-predicate-to-variable]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (let* ((pred minibuffer-completion-predicate) + (icicle-whole-candidate-as-text-prop-p nil) + (enable-recursive-minibuffers t) + (var (if askp + (intern (completing-read + "Save candidates in variable: " obarray + 'boundp nil nil + (if (boundp 'variable-name-history) + 'variable-name-history + 'icicle-variable-name-history))) + 'icicle-input-string))) + (set var (prin1-to-string pred)) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message (format " [Predicate SAVED to `%s']" var))))) + +;;;###autoload +(defun icicle-completing-read+insert () ; Bound to `C-M-S-c' (`C-M-C') in minibuffer. + "Read something with completion, and insert it. +Be sure to bind `icicle-completing-read+insert-candidates' to the set +of candidates. +Option `icicle-completing-read+insert-keys' controls which keys are +bound to this command. +Return the string that was inserted." + (interactive) + (if icicle-completing-read+insert-candidates + (let ((enable-recursive-minibuffers t) + (use-dialog-box nil) + (result + (icicle-completing-read "Choose: " icicle-completing-read+insert-candidates))) + (insert result) + result) + (icicle-msg-maybe-in-minibuffer "On-demand completion not available"))) + +;;;###autoload +(defun icicle-read+insert-file-name (dir-too-p) ; Bound to `C-M-S-f' (`C-M-F') in minibuffer. + "Read a file name and insert it, without its directory, by default. +With a prefix argument, insert its directory also. +Option `icicle-read+insert-file-name-keys' controls which keys are + bound to this command. +Return the string that was inserted." + (interactive "P") + (let ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) + (enable-recursive-minibuffers t) + (use-dialog-box nil) + (minibuffer-local-completion-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-completion-map) + (define-key map [(control backspace)] 'icicle-up-directory) + (define-key map "\C-c+" 'icicle-make-directory) + map)) + (minibuffer-local-must-match-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-must-match-map) + (define-key map [(control backspace)] 'icicle-up-directory) + (define-key map "\C-c+" 'icicle-make-directory) + map)) + result) + (setq result (icicle-read-file-name "Choose file: ")) + (unless dir-too-p ; Remove parent dir. + (setq result (if (file-directory-p result) + (file-name-as-directory (file-name-nondirectory (directory-file-name result))) + (file-name-nondirectory result)))) + (insert result) + result)) + +;;;###autoload +(defun icicle-candidate-set-swap () ; Bound to `C-%' in minibuffer. + "Swap the saved set and current sets of completion candidates. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-swap]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (setq icicle-saved-completion-candidates + (prog1 icicle-completion-candidates + (setq icicle-completion-candidates icicle-saved-completion-candidates))) + (minibuffer-message " [Saved set of candidates SWAPPED with current]")) + +;;;###autoload +(defun icicle-candidate-set-define () ; Bound to `C-:' in minibuffer. + "Define the set of current completion candidates by evaluating a sexp. +The Lisp sexp must evaluate to a list of strings, such as is returned +by `all-completions'. + +You can use this command at top level or from the minibuffer (`\\\ +\\[icicle-candidate-set-define]')." + (interactive) + (let* ((enable-recursive-minibuffers t) + (evald-sexp (eval-minibuffer + "Set the completion candidates to sexp (eval): "))) + (if (or (null evald-sexp) (and (consp evald-sexp) (stringp (car evald-sexp)))) + (setq icicle-completion-candidates evald-sexp) + (error "Sexp did not evaluate to a list of strings: %S" evald-sexp))) + (icicle-maybe-sort-and-strip-candidates) + (message "List of completion candidates DEFINED: %S" icicle-completion-candidates) + (when (> (minibuffer-depth) 0) + (message "Displaying completion candidates...") + (with-output-to-temp-buffer "*Completions*" + (display-completion-list icicle-completion-candidates)) + (icicle-narrow-candidates))) + +;;;###autoload +(defun icicle-candidate-set-difference () ; Bound to `C--' in minibuffer. + "Take the set difference between the current and saved candidates. +The new set of candidates is the set of candidates prior to executing +this command minus the saved set of candidates. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-difference]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-1 'icicle-set-difference " [saved set of candidates SUBTRACTED]")) + +;;;###autoload +(defun icicle-candidate-set-union () ; Bound to `C-+' in minibuffer. + "Take the set union between the current and saved candidates. +The new set of candidates is the union of the saved set of candidates +and the set of candidates prior to executing this command. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-union]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-1 'icicle-set-union " [saved set of candidates ADDED]")) + +;;;###autoload +(defun icicle-candidate-set-intersection () ; Bound to `C-*' in minibuffer. + "Take the set intersection between the current and saved candidates. +The new set of candidates is the intersection of the saved set of +candidates and the set of candidates prior to executing this command. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-intersection]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-1 'icicle-set-intersection + " [INTERSECTION of saved and current sets of candidates]")) + +;;;###autoload +(defun icicle-candidate-set-complement () ; Bound to `C-~' in minibuffer. + "Complement the set of current completion candidates. +The new set of candidates is the set of `all-completions' minus the +set of candidates prior to executing this command - that is, all +possible completions of the appropriate type, except for those that +are in the current set of completions. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-complement]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (setq icicle-completion-candidates + (icicle-set-difference + (all-completions "" minibuffer-completion-table minibuffer-completion-predicate + icicle-ignore-space-prefix-flag) + icicle-completion-candidates)) + (icicle-maybe-sort-and-strip-candidates) + (message "Displaying completion candidates...") + (with-output-to-temp-buffer "*Completions*" (display-completion-list icicle-completion-candidates)) + (minibuffer-message " [Set of candidates COMPLEMENTED]") + (icicle-narrow-candidates)) + +(defun icicle-candidate-set-truncate (n) ; Bound to `M-$' in minibuffer. + "Trim the set of current completion candidates at the end. +The first N candidates are kept. N is read." + ;; Ugly hack: `icicle-saved-completion-candidates-internal'. No way to bind a variable + ;; in `interactive' and have the binding be active in the function body. + (interactive + (list (let ((enable-recursive-minibuffers t)) + (setq icicle-saved-completion-candidates-internal icicle-completion-candidates) + (if current-prefix-arg + (prefix-numeric-value current-prefix-arg) + (read-number "Number of candidates to keep: "))))) + (setq icicle-completion-candidates icicle-saved-completion-candidates-internal) + (setcdr (nthcdr (1- n) icicle-completion-candidates) nil) + (icicle-maybe-sort-and-strip-candidates) + (message "Displaying completion candidates...") + (with-output-to-temp-buffer "*Completions*" (display-completion-list icicle-completion-candidates)) + (message (format " [Set of candidates TRUNCATED to %d]" n)) + (icicle-narrow-candidates)) + +;;;###autoload +(defun icicle-candidate-set-retrieve (&optional arg) ; Bound to `C-M-<' in minibuffer. + "Retrieve a saved set of completion candidates, making it current. +This retrieves candidates saved with `\\\ +\\[icicle-save/unsave-candidate]', `M-S-mouse-2', +`\\\\[icicle-candidate-set-save]', \ +`\\[icicle-candidate-set-save-to-variable]', or `\\[icicle-candidate-set-save-persistently]'. + +With no prefix arg, retrieve candidates from variable + `icicle-saved-completion-candidates'. +With a numeric prefix arg, retrieve candidates from another variable. +With a plain prefix arg (`C-u'), retrieve candidates from a cache file + or, if option `icicle-filesets-as-saved-completion-sets-flag' is + non-nil, an Emacs fileset name (Emacs 22 or later). To use filesets, + you must also load library `filesets' and use `(filesets-init)'. + +Completion is available when you are prompted for a cache file, +fileset, or variable name. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-retrieve]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-retrieve-1 arg)) + +;;;###autoload +(defun icicle-candidate-set-retrieve-1 (arg &optional morep) + "Helper function for `icicle-candidate-set-retrieve(-more)'. +ARG is the same as the raw prefix arg for `icicle-candidate-set-retrieve'. +MOREP non-nil means add the saved candidates, don't replace existing." + (let ((name nil) + (variablep (and arg (atom arg))) + (curr-cands icicle-completion-candidates) + saved-cands) + (if arg + (let ((icicle-whole-candidate-as-text-prop-p nil) + (enable-recursive-minibuffers t)) + (if variablep + ;; Retrieve from a variable. Prompt user for the variable to use. + (setq saved-cands + (append (and morep curr-cands) + (symbol-value + (setq name (intern + (completing-read ; Variable name. + "Retrieve candidates from variable: " + icicle-saved-candidates-variables-obarray + nil nil nil (if (boundp 'variable-name-history) + 'variable-name-history + 'icicle-variable-name-history))))))) + ;; Retrieve from a persistent set (and save to `icicle-saved-completion-candidates'). + (setq name (completing-read "Retrieve candidates from persistent set: " + (if (and icicle-filesets-as-saved-completion-sets-flag + (featurep 'filesets) filesets-data) + (append filesets-data icicle-saved-completion-sets) + icicle-saved-completion-sets) + nil nil nil 'icicle-completion-set-history)) + (icicle-retrieve-candidates-from-set name) + (setq saved-cands (append (and morep curr-cands) icicle-saved-completion-candidates)))) + ;; Retrieve from the default variable, `icicle-saved-completion-candidates'. + (setq saved-cands (append (and morep curr-cands) + icicle-saved-completion-candidates))) + (cond ((null saved-cands) + (deactivate-mark) + (icicle-display-candidates-in-Completions) + (message "No saved candidates to restore") (sit-for 2)) + (t + (setq icicle-completion-candidates ; Remove directories if completing file names + (if (icicle-file-name-input-p) ; using `read-file-name'. + (mapcar #'file-name-nondirectory saved-cands) + saved-cands)) + (cond ((and (consp icicle-completion-candidates) (null (cdr icicle-completion-candidates))) + ;; $$$$$$ Should this now use `icicle-current-input' + ;; instead of (car icicle-completion-candidates), for PCM? + (icicle-remove-Completions-window) + (icicle-insert-completion (car icicle-completion-candidates)) ; Insert sole cand. + (minibuffer-message " [Sole candidate restored]") + (save-selected-window (select-window (minibuffer-window)) + (icicle-highlight-complete-input)) + (icicle-show-help-in-mode-line (car icicle-completion-candidates))) + ((consp icicle-completion-candidates) + (deactivate-mark) + (icicle-display-candidates-in-Completions) + (save-selected-window + (select-window (minibuffer-window)) + (minibuffer-message (if name + (format " [Saved candidates RESTORED from %s `%s']" + (if variablep "variable" "cache file") name) + " [Saved candidates RESTORED]"))) + (icicle-narrow-candidates))))))) + +;;;###autoload +(defun icicle-candidate-set-retrieve-more (&optional arg) ; Bound to `C-<' in minibuffer. + "Retrieve a saved set of completion candidates, adding it current. +The saved candidates are added to those already current. +A prefix argument acts as for `icicle-candidate-set-retrieve'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-retrieve-more]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-retrieve-1 arg t)) + +;;;###autoload +(defun icicle-candidate-set-retrieve-from-variable () ; Bound to `C-M-{' in minibuffer. + "Retrieve a saved set of completion candidates, making it current. +This retrieves candidates saved with `\\\ +\\[icicle-save/unsave-candidate]', `M-S-mouse-2', or +`\\[icicle-candidate-set-save-to-variable]' (or `\\[icicle-candidate-set-save]' with a numeric \ +prefix arg). + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-retrieve-from-variable]')." + (interactive) + (icicle-candidate-set-retrieve 99)) + +;;;###autoload +(defun icicle-candidate-set-retrieve-persistent () ; Bound to `C-{' in minibuffer. + "Retrieve a saved set of completion candidates, making it current. +This retrieves candidates saved with `\\\ +\\[icicle-candidate-set-save-persistently]' or `C-u \\[icicle-candidate-set-save]'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-retrieve-persistent]')." + (interactive) + (icicle-candidate-set-retrieve '(1))) + +(defun icicle-retrieve-candidates-from-set (set-name) + "Retrieve the saved set of completion candidates named SET-NAME. +SET-NAME names an Icicles saved completion set or, if + `icicle-filesets-as-saved-completion-sets-flag' is non-nil, an Emacs + fileset. If that option is non-nil and SET-NAME names a saved + completion set that contains Emacs filesets, then the files specified + for the filesets are also retrieved. +The candidates are retrieved to `icicle-saved-completion-candidates', +and `icicle-candidates-alist' is updated." + (setq icicle-saved-completion-candidates (icicle-get-candidates-from-saved-set set-name)) + (when icicle-candidates-alist ; Redefine `icicle-candidates-alist'. + (let ((icicle-whole-candidate-as-text-prop-p t)) + (setq icicle-candidates-alist (mapcar icicle-get-alist-candidate-function + icicle-saved-completion-candidates))))) + +;;;###autoload +(defun icicle-save/unsave-candidate () ; Bound to `insert' in minibuffer. + "Add/remove current candidate to/from `icicle-saved-completion-candidates'. +If the candidate is already saved, then unsave it; otherwise, save it. +You can use this command only from the minibuffer (`\\\ +\\[icicle-save/unsave-candidate]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (if (not (wholenump icicle-candidate-nb)) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message " [No current candidate]")) + (let ((cand (elt icicle-completion-candidates icicle-candidate-nb))) + (cond ((member cand icicle-saved-completion-candidates) + (setq icicle-saved-completion-candidates + (delete icicle-last-completion-candidate icicle-saved-completion-candidates)) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message " [Candidate UNsaved]"))) + (t + (push cand icicle-saved-completion-candidates) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message " [Candidate SAVED]"))))))) +;;;###autoload +(defun icicle-mouse-save/unsave-candidate (event) ; Bound to `M-S-mouse-2' in *Completions. + "Add/remove clicked candidate to/from `icicle-saved-completion-candidates'. +If the candidate is already saved, then unsave it; otherwise, save it." + (interactive "e") + (run-hooks 'mouse-leave-buffer-hook) ; Give temp modes such as isearch a chance to turn off. + (let (;; $$$$$$ (buffer (window-buffer)) + (posn-win (posn-window (event-start event))) + (posn-col (car (posn-col-row (event-start event)))) + (posn-row (cdr (posn-col-row (event-start event)))) + choice base-size) + (read-event) ; Swallow mouse up event. + (with-current-buffer (window-buffer posn-win) + (save-excursion + ;; $$$$$$ (when completion-reference-buffer (setq buffer completion-reference-buffer)) + (setq base-size completion-base-size) + (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)) + choice (buffer-substring-no-properties beg end))))) + (setq icicle-candidate-nb (icicle-nb-of-candidate-in-Completions + (posn-point (event-start event))) + icicle-last-completion-candidate choice) + (cond ((member icicle-last-completion-candidate icicle-saved-completion-candidates) + (setq icicle-saved-completion-candidates + (delete icicle-last-completion-candidate icicle-saved-completion-candidates)) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message " [Candidate UNsaved]"))) + (t + (push icicle-last-completion-candidate icicle-saved-completion-candidates) + (save-selected-window (select-window (minibuffer-window)) + (minibuffer-message " [Candidate SAVED]")))) + (deactivate-mark) + (icicle-display-candidates-in-Completions) + (icicle-raise-Completions-frame posn-col posn-row))) + +;;;###autoload +(defun icicle-mouse-candidate-set-save (ignore &optional arg) ; `M-S-mouse-3' in *Completions*. + "`icicle-candidate-set-save(-selected)'. +If the region is active in *Completions*, then +`icicle-candidate-set-save-selected'. Otherwise, +`icicle-candidate-set-save'." + (interactive "e\nP") + (if (and (get-buffer "*Completions*") + (save-current-buffer + (set-buffer (get-buffer "*Completions*")) + (and mark-active (mark) (/= (point) (mark))))) + (icicle-candidate-set-save-selected arg) + (icicle-candidate-set-save arg))) + +;;;###autoload +(defun icicle-mouse-candidate-set-save-more (ignore &optional arg) ; `M-mouse-3' in *Completions*. + "`icicle-candidate-set-save-more(-selected)'. +If the region is active in *Completions*, then +`icicle-candidate-set-save-more-selected'. Otherwise, +`icicle-candidate-set-save-more'." + (interactive "e\nP") + (if (and (get-buffer "*Completions*") + (save-current-buffer + (set-buffer (get-buffer "*Completions*")) + (and mark-active (mark) (/= (point) (mark))))) + (icicle-candidate-set-save-more-selected arg) + (icicle-candidate-set-save-more arg))) + +;;;###autoload +(defun icicle-mouse-save-then-kill (click &optional arg) + "`mouse-save-then-kill', but click same place saves selected candidates." + (interactive "e\nP") + (flet ((mouse-save-then-kill-delete-region (beg end) + (icicle-mouse-candidate-set-save-more nil arg))) + (mouse-save-then-kill click)) + (setq this-command 'mouse-save-then-kill)) + +;;;###autoload +(defun icicle-candidate-set-save (&optional arg) ; Bound to `C-M->' in minibuffer. + "Save the set of current completion candidates, for later recall. +Saves candidates in variable `icicle-saved-completion-candidates', by +default. +With a plain prefix arg (`C-u'), save candidates in a cache file. +With a non-zero numeric prefix arg (`C-u N'), save candidates in a + variable for which you are prompted. +With a zero prefix arg (`C-0'), save candidates in a fileset (Emacs 22 + or later). Use this only for file-name candidates, obviously. To + subsequently use a fileset for candidate retrieval, option + `icicle-filesets-as-saved-completion-sets-flag' must be non-nil. + +You can retrieve the saved set of candidates with `\\\ +\\[icicle-candidate-set-retrieve]'. +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-save-1 icicle-completion-candidates arg)) + +;;;###autoload +(defun icicle-candidate-set-save-more (&optional arg) ; Bound to `C->' in minibuffer. + "Add current completion candidates to saved candidates set. +The current candidates are added to those already saved. +A prefix argument acts the same as for `icicle-candidate-set-save'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save-more]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (icicle-candidate-set-save-1 icicle-completion-candidates arg t)) + +;;;###autoload +(defun icicle-candidate-set-save-selected (&optional arg) ; Bound to `C-M-)' in minibuffer. + "`icicle-candidate-set-save', but only for the selected candidates. +Candidates at least partially in the region are saved. +A prefix argument acts the same as for `icicle-candidate-set-save'. + +As a special case, if no candidates are selected, then this empties +the current set of saved candidates. That is, it UNsaves all saved +candidates. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save-selected]')." + (interactive "P") + (icicle-candidate-set-save-selected-1 arg nil 'no-error)) + +;;;###autoload +(defun icicle-candidate-set-save-more-selected (&optional arg) ; Bound to `C-)' in minibuffer. + "`icicle-candidate-set-save-more', but only for the selected candidates. +Candidates at least partially in the region are added to those saved. +A prefix argument acts the same as for `icicle-candidate-set-save'. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save-more-selected]')." + (interactive "P") + (icicle-candidate-set-save-selected-1 arg t)) + +;; $$$$$$$ Maybe should also allow rectangle selection. +(defun icicle-candidate-set-save-selected-1 (arg &optional morep no-error-p) + "Helper function for `icicle-candidate-set-save(-more)(-region)'." + (when (or (get-buffer-window "*Completions*" 0) no-error-p) + (let ((beg-cand-nb 0) + (end-cand-nb 0) + (candidates ()) + (orig-buf (current-buffer))) + (when (get-buffer-window "*Completions*" 0) ; Do nothing if not displayed. + (with-current-buffer "*Completions*" + (when (and mark-active (mark) (/= (point) (mark)) icicle-completion-candidates) + (let ((bob (icicle-start-of-candidates-in-Completions)) + (eob (point-max)) + (beg (region-beginning)) + (end (region-end)) + temp) + + ;; Extend region ends to include all of first and last selected candidates. + (unless (get-text-property beg 'mouse-face) + (if (setq temp (next-single-property-change beg 'mouse-face)) + (setq beg temp) + (setq beg (next-single-property-change temp 'mouse-face)))) + + (when (> beg end) + (error "No candidates selected")) ; Active region but none selected. + + (unless (get-text-property end 'mouse-face) + (if (setq temp (previous-single-property-change end 'mouse-face)) + (setq end temp) + (setq end (previous-single-property-change temp 'mouse-face)))) + (when (> beg end) (setq beg (prog1 end (setq end beg)))) ; Swap them. + (while (and (>= beg bob) (get-text-property beg 'mouse-face)) (setq beg (1- beg))) + (while (and (<= end eob) (get-text-property end 'mouse-face)) (setq end (1+ end))) + (setq beg (1+ beg) + end (1- end) + beg-cand-nb (icicle-nb-of-candidate-in-Completions beg) + end-cand-nb (icicle-nb-of-candidate-in-Completions end)) + (when (> beg-cand-nb end-cand-nb) ; Swap them + (setq beg-cand-nb (prog1 end-cand-nb (setq end-cand-nb beg-cand-nb)))) + (while (<= beg-cand-nb end-cand-nb) + (push (elt icicle-completion-candidates beg-cand-nb) candidates) + (setq beg-cand-nb (1+ beg-cand-nb))))))) + (when (and morep (null candidates)) (error "No candidates selected")) ; Need selection for MOREP. + (setq candidates (nreverse candidates)) + (icicle-candidate-set-save-1 candidates arg morep t no-error-p) + (let ((win (get-buffer-window orig-buf 'visible))) + (when win (select-window win)))))) + +(defun icicle-candidate-set-save-1 (new-cands arg &optional morep only-selected-p no-error-p) + "Helper function for `icicle-candidate-set-save*' functions. +NEW-CANDS are the candidates to save. +ARG is the same as the raw prefix arg for `icicle-candidate-set-save'. +MOREP non-nil means add the candidates, don't replace existing set. +ONLY-SELECTED-P non-nil means NEW-CANDS are selected in *Completions*. +NO-ERROR-P non-nil means don't raise an error if NEW-CANDS is nil." + (unless (or new-cands no-error-p) + (error "Cannot save empty candidates set - did you use `S-TAB' or `TAB'?")) + (let (where) + (if arg + (let ((enable-recursive-minibuffers t)) + (cond ((consp arg) + ;; Save to cache file (and to `icicle-saved-completion-candidates'). + (let* ((file-name + (prog1 (let ((icicle-completion-candidates icicle-completion-candidates)) + (icicle-add/update-saved-completion-set)) + (when (minibuffer-window-active-p (minibuffer-window)) + (with-output-to-temp-buffer "*Completions*" ; Redisplay. + (display-completion-list icicle-completion-candidates))) + (select-window (minibuffer-window)))) + (list-buf (and morep (find-file-noselect file-name 'nowarn 'raw))) + (old-cands ())) + (when morep + (unwind-protect + (condition-case nil + (setq old-cands (read list-buf)) + (end-of-file + (save-selected-window + (select-window (minibuffer-window)) + (minibuffer-message (format " [No completion candidates in file `%s']" + file-name))))) + (kill-buffer list-buf))) + ;; Convert to readable alist form, from propertized text. Convert any markers + ;; to the form (icicle-file-marker FILE POS) or (icicle-marker BUFFER POS). + (when (and new-cands (get-text-property 0 'icicle-whole-candidate (car new-cands))) + (setq new-cands + (mapcar (lambda (cand) + (icicle-markers-to-readable + (or (funcall icicle-get-alist-candidate-function cand) cand))) + new-cands))) + (setq icicle-saved-completion-candidates (append new-cands old-cands) + where (format "cache file `%s'" file-name)) + (with-temp-message (format "Writing candidates to cache file `%s'..." file-name) + (condition-case err + (with-temp-file file-name + (prin1 icicle-saved-completion-candidates (current-buffer))) + (error (error "Could not write to cache file. %S" + (error-message-string err))))))) + ((zerop (prefix-numeric-value arg)) + ;; Save to a fileset (and to `icicle-saved-completion-candidates'). + (unless (require 'filesets nil t) + (error "Cannot save to a fileset - feature `filesets' not provided")) + (filesets-init) + (let ((icicle-completion-candidates icicle-completion-candidates)) + (setq where (completing-read "Save to fileset: " filesets-data))) + (dolist (cand new-cands) (icicle-add-file-to-fileset cand where)) + (when (minibuffer-window-active-p (minibuffer-window)) + (with-output-to-temp-buffer "*Completions*" ; Redisplay. + (display-completion-list icicle-completion-candidates))) + (select-window (minibuffer-window)) + (setq where (format "`%s'" where))) + (t ; Save to a variable. Prompt for the variable to use. + (let* ((varname + (prog1 (let ((icicle-completion-candidates + icicle-completion-candidates) + (icicle-whole-candidate-as-text-prop-p nil)) + (completing-read (if morep + "Add candidates to variable: " + "Save candidates in variable: ") + icicle-saved-candidates-variables-obarray + nil nil nil (if (boundp 'variable-name-history) + 'variable-name-history + 'icicle-variable-name-history))) + (when (minibuffer-window-active-p (minibuffer-window)) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list icicle-completion-candidates))) + (select-window (minibuffer-window)))) + (var (intern varname))) ; Intern in standard `obarray'. + (intern varname icicle-saved-candidates-variables-obarray) ; For completion. + (set var (if (and morep (boundp var) (listp (symbol-value var))) + (append new-cands (symbol-value var)) + new-cands)) + (setq where (format "`%s'" var)))))) + ;; Save to default variable, `icicle-saved-completion-candidates'. + (setq where "`icicle-saved-completion-candidates'" + icicle-saved-completion-candidates + (if (and morep (listp icicle-saved-completion-candidates)) + (append new-cands icicle-saved-completion-candidates) + new-cands))) + (deactivate-mark) + (when (and (minibuffer-window-active-p (minibuffer-window)) + (get-buffer-window "*Completions*" 'visible)) + (icicle-display-candidates-in-Completions)) + (save-selected-window + (select-window (minibuffer-window)) + (minibuffer-message + (if morep + (if new-cands + (format " [%sandidates ADDED to %s]" (if only-selected-p "Selected c" "C") where) + " [NO candidates selected to add]") + (if new-cands + (format " [%sandidates SAVED to %s]" (if only-selected-p "Selected c" "C") where) + " [Saved candidates reset to NONE]")))))) + +;; This is actually a top-level command, but it is in this file because it is used by +;; `icicle-candidate-set-save-1'. +;; +;; We don't define this using `icicle-define-add-to-alist-command', because we want to +;; return the cache-file name. +;;;###autoload +(defun icicle-add/update-saved-completion-set () + "Add or update an entry in `icicle-saved-completion-sets'. +That is, create a new saved completion set or update an existing one. +You are prompted for the name of a set of completion candidates and +its cache file. By default, the cache file name is the set name +without spaces, and with file extension `icy'. List +`icicle-saved-completion-sets' is updated to have an entry with these +set and file names. Return the cache-file name." + (interactive) + (let* ((icicle-whole-candidate-as-text-prop-p nil) + (set-name (icicle-substring-no-properties + (completing-read "Saved completion set: " + icicle-saved-completion-sets nil nil + nil 'icicle-completion-set-history))) + (file-name "")) + (setq file-name (expand-file-name + (read-file-name "Cache file for the set: " default-directory nil nil + (concat (icicle-delete-whitespace-from-string set-name) ".icy")))) + (while (not (icicle-file-writable-p file-name)) + (setq file-name (expand-file-name + (read-file-name + "Cannot write to that file. Cache file: " default-directory nil nil + (concat (icicle-delete-whitespace-from-string set-name) ".icy"))))) + (setq icicle-saved-completion-sets ; Remove any old definition of this set. + (icicle-assoc-delete-all set-name icicle-saved-completion-sets)) + (push (cons set-name file-name) icicle-saved-completion-sets) ; Add new set definition. + (funcall icicle-customize-save-variable-function + 'icicle-saved-completion-sets + icicle-saved-completion-sets) + (message "Added set to `icicle-saved-completion-sets': `%s'" set-name) + file-name)) ; Return cache-file name. + +;; Similar to `filesets-add-buffer', but that insists on a buffer. This is actually a top-level +;; command, but it is in this file because it is used by `icicle-candidate-set-save-1'. +(defun icicle-add-file-to-fileset (&optional file name) + "Add FILE to the fileset called NAME. +If FILE is nil, use file of current buffer. +If NAME is nil, prompt for the fileset." + (interactive) + (unless (require 'filesets nil t) (error "Cannot find library `filesets'")) + (setq file (or file (buffer-file-name) (and (interactive-p) (read-file-name "File to add: " + nil nil t)) + (error "Current buffer has no associated file")) + name (or name (and (interactive-p) (completing-read (format "Add `%s' to fileset: " file) + filesets-data)) + (error "No fileset"))) + (let ((entry (or (assoc name filesets-data) + (and (interactive-p) + (when (y-or-n-p (format "Fileset `%s' does not exist. Create it? " name)) + (add-to-list 'filesets-data (list name '(:files))) + (message "Fileset created. Use `M-x filesets-save-config' to save it.") + (car filesets-data)))))) + (if (not entry) + (when (interactive-p) (message "Operation cancelled - no fileset")) + (let* ((files (filesets-entry-get-files entry))) + (cond ((filesets-member file files :test 'filesets-files-equalp) + (message "`%s' is already in fileset `%s'" file name)) + ((and file (eq (filesets-entry-mode entry) ':files)) + (filesets-entry-set-files entry (cons file files) t) + (filesets-set-config name 'filesets-data filesets-data)) + (t (error "Cannot add file. Fileset `%s' is not of type Files (:files)" name))))))) + +(defun icicle-markers-to-readable (cand) + "Convert (serialize) candidate CAND to Lisp-readable representation. +CAND is a full completion candidate (collection alist entry). +A Lisp-readable candidate uses one of the following forms to represent +a marker: + (icicle-file-marker FILE-NAME MARKER-POSITION) + (icicle-marker BUFFER-NAME MARKER-POSITION)" + (if (atom cand) + (if (markerp cand) + (let ((buf (marker-buffer cand))) + (unless buf (error "Marker in no buffer")) + (list (if (buffer-file-name buf) 'icicle-file-marker 'icicle-marker) + (or (buffer-file-name buf) (buffer-name buf)) + (marker-position cand))) + cand) + (cons (icicle-markers-to-readable (car cand)) (icicle-markers-to-readable (cdr cand))))) + +;;;###autoload +(defun icicle-candidate-set-save-to-variable () ; Bound to `C-M-}' in minibuffer. + "Save the set of current completion candidates in a variable you choose. +You can retrieve the saved set of candidates with `\\\ +\\[icicle-candidate-set-retrieve-from-variable]' (or `\\[icicle-candidate-set-retrieve]' +with a numeric prefix arg). +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save-to-variable]')." + (interactive) + (icicle-candidate-set-save 99)) + +;;;###autoload +(defun icicle-candidate-set-save-persistently (filesetp) ; Bound to `C-}' in minibuffer. + "Save the set of current completion candidates persistently. +With no prefix arg, save in a cache file. +With a prefix arg, save in an Emacs fileset (Emacs 22 or later). + +You can retrieve the saved set of candidates with `\\\ +\\[icicle-candidate-set-retrieve-persistent]' or `C-u \\[icicle-candidate-set-retrieve]'. +You can use the saved set of candidates for operations such as +\\ +`icicle-candidate-set-union' (`\\[icicle-candidate-set-union]'), +`icicle-candidate-set-intersection' (`\\[icicle-candidate-set-intersection]'), and +`icicle-candidate-set-difference' (`\\[icicle-candidate-set-difference]'). + +You can use this command only from the minibuffer (`\\\ +\\[icicle-candidate-set-save-persistently]')." + (interactive "P") + (icicle-candidate-set-save (if filesetp 0 '(1)))) + +;;;###autoload +(defun icicle-keep-only-past-inputs (&optional recent-first) ; Bound to`M-pause' in minibuffer. + "Narrow completion candidates to those that have been used previously. +This filters the set of current completion candidates, keeping only +those that have been used before. (You must first use `TAB' or +`S-TAB' to establish an explicit candidate set.) + +With a prefix arg, the previous inputs are sorted chronologically, +most recent first. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-keep-only-past-inputs]')." + (interactive "P") + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (if (and recent-first (interactive-p) icicle-inhibit-sort-p) + (icicle-msg-maybe-in-minibuffer "Cannot sort candidates now") + (let ((icicle-sort-comparer (if recent-first 'icicle-most-recent-first-p icicle-sort-comparer))) + (when (or recent-first (eq icicle-last-completion-command 'icicle-keep-only-past-inputs)) + (icicle-complete-again-update 'no-display)) + (if (null icicle-completion-candidates) + (minibuffer-message " [No completion candidates to filter]") + (unless (boundp minibuffer-history-variable) (set minibuffer-history-variable nil)) + (when (consp (symbol-value minibuffer-history-variable)) + (setq icicle-completion-candidates + (icicle-remove-if-not + (lambda (candidate) + (when (icicle-file-name-input-p) + (setq candidate (expand-file-name + candidate (icicle-file-name-directory icicle-last-input)))) + (member candidate (symbol-value minibuffer-history-variable))) + icicle-completion-candidates)) + (cond ((null icicle-completion-candidates) + (save-selected-window (icicle-remove-Completions-window)) + (minibuffer-message " [None of the completions have been used before]")) + (t + (cond ((and (symbolp last-command) (get last-command 'icicle-cycling-command)) + (setq icicle-current-input icicle-last-input) + (icicle-retrieve-last-input)) + (t + (setq icicle-current-input (icicle-input-from-minibuffer)))) + (cond ((null icicle-completion-candidates) + (setq icicle-nb-of-other-cycle-candidates 0) + (save-selected-window (icicle-remove-Completions-window)) + (minibuffer-message " [No matching history element]")) + ((null (cdr icicle-completion-candidates)) ; Single cand. Update minibuffer. + (setq icicle-nb-of-other-cycle-candidates 0) + (icicle-clear-minibuffer) + (setq icicle-last-completion-candidate (car icicle-completion-candidates)) + (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)) + (save-selected-window (icicle-remove-Completions-window)) + (icicle-highlight-complete-input) + (icicle-show-help-in-mode-line icicle-last-completion-candidate) + (minibuffer-message (format " [One matching history element]"))) + (t + (when (member icicle-current-input icicle-completion-candidates) + (icicle-highlight-complete-input) + (icicle-show-help-in-mode-line icicle-current-input)) + (icicle-display-candidates-in-Completions) + (save-window-excursion + (select-window (active-minibuffer-window)) + (minibuffer-message + (concat " [Filtered to (matching) historical candidates" + (and recent-first ", most recent first") + "]"))))) + (setq icicle-last-completion-command 'icicle-keep-only-past-inputs))))) + icicle-completion-candidates))) + +;;;###autoload +(defun icicle-other-history (arg) ; Bound to `C-M-pause' in minibuffer. + "Choose a history, or complete against `icicle-interactive-history'. +For Emacs 23 or later, if no prefix arg and you are completing a + command, abbrev, or keyboard macro name, then complete against + (non-nil) `icicle-interactive-history'. +Otherwise, prompt with completion for a minibuffer history to use. + The history choice lasts only for the current (main) completion. + (To then complete against this history, use `M-h'.)" + (interactive "P") + (if (and (> emacs-major-version 22) + (memq minibuffer-history-variable + '(extended-command-history icicle-command-abbrev-history icicle-kmacro-history)) + (not arg) + icicle-interactive-history) + (icicle-use-interactive-command-history) + (call-interactively #'icicle-change-history-variable))) + +;;;###autoload +(defun icicle-use-interactive-command-history () + "Complete input against `icicle-interactive-history'. +This is a history of all Emacs commands called interactively. +This history is available only for Emacs 23 and later, and only if +option `icicle-populate-interactive-history-flag' is not nil." + (interactive) + (icicle-change-history-variable "icicle-interactive-history") + (icicle-history)) + +;;;###autoload +(defun icicle-change-history-variable (hist-var) + "Choose a history variable to use now for `minibuffer-history-variable'. +Use completion to choose the history to use. +The choice lasts only for the current (main) completion. +Non-interactively, arg HIST-VAR is the (string) name of a history var." + (interactive + (let ((enable-recursive-minibuffers t) + (icicle-hist-vars `((,(symbol-name minibuffer-history-variable)) + (,(symbol-name 'icicle-previous-raw-file-name-inputs)) + (,(symbol-name 'icicle-previous-raw-non-file-name-inputs))))) + (when (and (boundp 'icicle-populate-interactive-history-flag) ; Emacs 23+. + icicle-populate-interactive-history-flag) + (push (symbol-name 'icicle-interactive-history) icicle-hist-vars)) + (mapatoms (lambda (x) (when (and (boundp x) (consp (symbol-value x)) + (stringp (car (symbol-value x))) + (string-match "-\\(history\\|ring\\)\\'" (symbol-name x))) + (push (list (symbol-name x)) icicle-hist-vars)))) + (list (completing-read "Use history: " icicle-hist-vars nil t nil nil nil)))) + (when (interactive-p) (icicle-barf-if-outside-Completions-and-minibuffer)) + (setq minibuffer-history-variable (intern hist-var))) + +;;;###autoload +(defun icicle-scroll-Completions (&optional reverse) ; Mouse `wheel-down' in *Completions* + "Scroll the *Completions* window down." + (interactive "P") + (when (get-buffer-window "*Completions*" 0) + (save-selected-window + (select-window (get-buffer-window "*Completions*" 0)) + (when (if (interactive-p) reverse current-prefix-arg) ; Non-interactive use is for `TAB', `S-TAB'. + (setq icicle-scroll-Completions-backward-p (not icicle-scroll-Completions-backward-p))) + (cond (icicle-scroll-Completions-backward-p + (if (not (= (window-start) (point-min))) + (scroll-down nil) + (unless (= (window-end) (point-max)) + (goto-char (point-max)) + (scroll-down (1- (/ (window-height) 2))) + (beginning-of-line)))) + (t + (if (not (= (window-end) (point-max))) + (scroll-up nil) + (unless (= (window-start) (point-min)) + (goto-char (icicle-start-of-candidates-in-Completions))))))))) + +;;;###autoload +(defun icicle-scroll-Completions-up () ; Mouse `wheel-up' in *Completions* + "Scroll the *Completions* window up." + (interactive) + (let ((icicle-scroll-Completions-backward-p (not icicle-scroll-Completions-backward-p))) + (icicle-scroll-Completions))) + +;;;###autoload +(defun icicle-history () ; Bound to `M-h' in minibuffer. + "Access the appropriate history list using completion or cycling. +The current minibuffer input is interpreted as a regexp and matched +against items in the history list in use for the current command. + +Note: + +If the required input is a file or directory name, then the entire +minibuffer input is what is matched against the history list. The +reason for this is that file names in the history list are usually +absolute. This is unlike the case for normal file-name completion, +which assumes the default directory. + +Keep this in mind for apropos (regexp) completion; it means that to +match a file-name using a substring you must, in the minibuffer, +either not specify a directory or explicitly use \".*\" before the +file-name substring. + +For example, `/foo/bar/lph' will not apropos-match the previously +input file name `/foo/bar/alphabet-soup.el'; you should use either +`/foo/bar/.*lph' or `lph' (no directory). + +This also represents a difference in behavior compared to the similar +command `icicle-keep-only-past-inputs' (\\\ +\\[icicle-keep-only-past-inputs] in the minibuffer). +That command simply filters the current set of completion candidates, +which in the case of file-name completion is a set of relative file +names. + +You can use this command only from the minibuffer (`\\\ +\\[icicle-history]')." + (interactive) + (when (interactive-p) (icicle-barf-if-outside-minibuffer)) + (when (icicle-file-name-input-p) + (setq minibuffer-completion-predicate nil + minibuffer-completing-file-name nil)) + (when (and (arrayp minibuffer-completion-table) minibuffer-completion-predicate) + (setq minibuffer-completion-predicate + `(lambda (elt) (funcall ',minibuffer-completion-predicate + (intern (if (consp elt) (car elt) elt)))))) + (when (and (boundp minibuffer-history-variable) (consp (symbol-value minibuffer-history-variable))) + (setq minibuffer-completion-table + (mapcar #'list (icicle-remove-duplicates (symbol-value minibuffer-history-variable))))) + (save-selected-window (unless icicle-last-completion-command (icicle-apropos-complete))) + (cond (icicle-cycling-p ;; $$$ (and (symbolp last-command) (get last-command 'icicle-cycling-command)) + (setq icicle-current-input icicle-last-input) + (icicle-retrieve-last-input)) + (t + (setq icicle-current-input (icicle-input-from-minibuffer) + icicle-last-input nil ; So `icicle-save-or-restore-input' thinks input has changed. + last-command 'icicle-history) + (funcall (or icicle-last-completion-command 'icicle-apropos-complete))))) + +;; Not actually a minibuffer command, since `isearch' technically uses the echo area. This is not +;; shadowed by any `icicle-mode-map' binding, since `isearch-mode-map' is also a minor mode map. +;;;###autoload +(defun icicle-isearch-complete () ; Bound to `M-TAB' and `M-o' in `isearch-mode-map'. + "Complete the search string using candidates from the search ring." + (interactive) + (cond ((icicle-completing-p) ; Cannot use the var here, since not sure to be in minibuf. + (setq isearch-string (if (fboundp 'field-string) (field-string) (buffer-string))) + (when (icicle-isearch-complete-past-string) + (if (fboundp 'delete-field) (delete-field) (erase-buffer)) + (insert isearch-string))) + (t + (icicle-isearch-complete-past-string) + (setq isearch-message (mapconcat 'isearch-text-char-description isearch-string "")) + (isearch-edit-string)))) + +(when (fboundp 'text-scale-increase) ; Bound to `C-x -' in the minibuffer (Emacs 23+). + (defun icicle-doremi-zoom-Completions+ (&optional increment) + "Zoom the text in buffer `*Completions*' incrementally. +Use `=', `-', or the mouse wheel to increase or decrease text +size. You can use the `Meta' key (`M-=' or `M--') to increment in +larger steps." + (interactive "p") + (unless (require 'doremi-frm nil t) (error "This command needs library `doremi-frm.el'.")) + (unless (get-buffer-window "*Completions*" 'visible) + (if icicle-completion-candidates + (icicle-display-candidates-in-Completions) + (icicle-msg-maybe-in-minibuffer "Did you hit `TAB' or `S-TAB'?"))) + (let ((mini (active-minibuffer-window))) + (unwind-protect + (save-selected-window + (select-window (get-buffer-window "*Completions*" 'visible)) + (let ((enable-recursive-minibuffers t) + (doremi-up-keys '(?=)) + (doremi-down-keys '(?-)) + (doremi-boost-up-keys '(?\M-=)) + (doremi-boost-down-keys '(?\M--))) + (doremi-buffer-font-size+ increment)) + (setq unread-command-events ())) + (unless mini (icicle-remove-Completions-window)))))) + +(defun icicle-doremi-candidate-width-factor+ (&optional increment) ; Bound to `C-x w' in the minibuffer. + "Change `icicle-candidate-width-factor' incrementally. +Use `right', `left' or mouse wheel to increase or decrease. You can +use the `Meta' key (e.g. `M-right') to increment in larger steps. + +Use `up', `down', or mouse wheel to adjust +`icicle-inter-candidates-min-spaces'." + (interactive "p") + (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) + (doremi-up-keys '(left)) ; Rebind, so more intuitive for width. + (doremi-boost-up-keys '(M-left)) + (doremi-down-keys '(right)) + (doremi-boost-down-keys '(M-right))) + (doremi (lambda (new-val) + (setq new-val (doremi-wrap new-val 1 100) + icicle-candidate-width-factor new-val) + (icicle-display-candidates-in-Completions) + new-val) + icicle-candidate-width-factor + (- increment))) ; Reverse, so arrows correspond. + (when (member (car unread-command-events) + (append doremi-up-keys doremi-boost-up-keys + doremi-down-keys doremi-boost-down-keys)) + (icicle-doremi-inter-candidates-min-spaces+ increment)) + (setq unread-command-events ())) + (unless mini (icicle-remove-Completions-window))))) + +(defun icicle-doremi-inter-candidates-min-spaces+ (&optional increment) ; Bound to `C-x |' in minibuf. + "Change `icicle-inter-candidates-min-spaces' incrementally. +Use `up', `down' or mouse wheel to increase or decrease. You can use +the `Meta' key (e.g. `M-right') to increment in larger steps. + +Use `left', `right', or mouse wheel to adjust +`icicle-candidate-width-factor'." + (interactive "p") + (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)) + (doremi (lambda (new-val) + (setq new-val (doremi-limit new-val 1 nil) + icicle-inter-candidates-min-spaces new-val) + (icicle-display-candidates-in-Completions) + new-val) + icicle-inter-candidates-min-spaces + increment)) + (when (member (car unread-command-events)'(left right M-left M-right)) + (icicle-doremi-candidate-width-factor+ increment)) + (setq unread-command-events ())) + (unless mini (icicle-remove-Completions-window))))) + +(defalias 'toggle-icicle-WYSIWYG-Completions 'icicle-toggle-WYSIWYG-Completions) +;;;###autoload +(defun icicle-toggle-WYSIWYG-Completions () + "Toggle the value of option `icicle-WYSIWYG-Completions-flag'." + (interactive) + (setq icicle-WYSIWYG-Completions-flag (not icicle-WYSIWYG-Completions-flag)) + (icicle-msg-maybe-in-minibuffer (if icicle-WYSIWYG-Completions-flag + "Using WYSIWYG for *Completions* display is now ON" + "Using WYSIWYG for *Completions* display is now OFF"))) + +(defalias 'toggle-icicle-~-for-home-dir 'icicle-toggle-~-for-home-dir) +;;;###autoload +(defun icicle-toggle-~-for-home-dir () ; Bound to `M-~' in the minibuffer. + "Toggle the value of option `icicle-use-~-for-home-dir-flag'. +Bound to `M-~' in the minibuffer." + (interactive) + (setq icicle-use-~-for-home-dir-flag (not icicle-use-~-for-home-dir-flag)) + (icicle-msg-maybe-in-minibuffer (if icicle-use-~-for-home-dir-flag + "Using `~' for home directory is now ON" + "Using `~' for home directory is now OFF"))) + +(defalias 'toggle-icicle-C-for-actions 'icicle-toggle-C-for-actions) +;;;###autoload +(defun icicle-toggle-C-for-actions () ; Bound to `M-g' in the minibuffer. + "Toggle the value of option `icicle-use-C-for-actions-flag'. +Bound to `M-g' in the minibuffer." + (interactive) + (setq icicle-use-C-for-actions-flag (not icicle-use-C-for-actions-flag)) + (icicle-toggle-icicle-mode-twice) + (icicle-msg-maybe-in-minibuffer (if icicle-use-C-for-actions-flag + "Using `C-' prefix for multi-command actions is now ON" + "Using `C-' prefix for multi-command actions is now OFF"))) + +(defalias 'toggle-icicle-alternative-sorting 'icicle-toggle-alternative-sorting) +;;;###autoload +(defun icicle-toggle-alternative-sorting () ; Bound to `C-M-,' in the minibuffer. + "Toggle alternative sorting of minibuffer completion candidates. +This swaps `icicle-alternative-sort-comparer' and `icicle-sort-comparer'. +Bound to `C-M-,' in the minibuffer." + (interactive) + (let ((alt-sort-fn icicle-alternative-sort-comparer)) + (setq icicle-alternative-sort-comparer (or icicle-sort-comparer icicle-last-sort-comparer) + icicle-sort-comparer (or alt-sort-fn icicle-last-sort-comparer)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer + (format "Sorting: `%s', Alternative: `%s'" + icicle-sort-comparer icicle-alternative-sort-comparer)))) + +(defalias 'toggle-icicle-sorting 'icicle-toggle-sorting) +;;;###autoload +(defun icicle-toggle-sorting () ; Not bound to a key. + "Toggle sorting of minibuffer completion candidates. +When sorting is active, comparison is done by `icicle-sort-comparer'." + (interactive) + (if (and (interactive-p) icicle-inhibit-sort-p) + (icicle-msg-maybe-in-minibuffer "Cannot sort candidates now") + (if icicle-sort-comparer + (setq icicle-last-sort-comparer icicle-sort-comparer ; Save it, for restoring. + icicle-sort-comparer nil) + (setq icicle-sort-comparer icicle-last-sort-comparer)) ; Restore it. + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-sort-comparer + "Completion-candidate sorting is now ON" + "Completion-candidate sorting is now OFF")))) + +(defalias 'toggle-icicle-angle-brackets 'icicle-toggle-angle-brackets) +;;;###autoload +(defun icicle-toggle-angle-brackets () + "Toggle `icicle-key-descriptions-use-<>-flag'." + (interactive) + (setq icicle-key-descriptions-use-<>-flag (not icicle-key-descriptions-use-<>-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-key-descriptions-use-<>-flag + "Displaying <...> in key descriptions is now ON" + "Displaying <...> in key descriptions is now OFF"))) + +(defalias 'toggle-icicle-proxy-candidates 'icicle-toggle-proxy-candidates) +;;;###autoload +(defun icicle-toggle-proxy-candidates () ; Bound to `C-M-_' in the minibuffer. + "Toggle `icicle-add-proxy-candidates-flag'. +Bound to `\\\\[icicle-toggle-proxy-candidates]' in the minibuffer. +With some commands, you must re-invoke the command for the new value +to take effect. (This is for performance reasons.)" + (interactive) + (setq icicle-add-proxy-candidates-flag (not icicle-add-proxy-candidates-flag) + icicle-saved-proxy-candidates (prog1 icicle-proxy-candidates + (setq icicle-proxy-candidates + icicle-saved-proxy-candidates))) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-add-proxy-candidates-flag + "Including proxy candidates is now ON" + "Including proxy candidates is now OFF"))) + +(defalias 'toggle-icicle-transforming 'icicle-toggle-transforming) +;;;###autoload +(defun icicle-toggle-transforming () ; Bound to `C-$' in the minibuffer. + "Toggle transforming of minibuffer completion candidates. +When transforming is active, it is done by `icicle-transform-function'. + +By default, transformation, if active, simply removes duplicate +candidates. Icicles commands already \"do the right thing\" when it +comes to duplicate removal, so you might never need this command. + +Bound to `C-$' in the minibuffer." + (interactive) + (if icicle-transform-function + (setq icicle-last-transform-function icicle-transform-function ; Save it, for restoring. + icicle-transform-function nil) + (setq icicle-transform-function icicle-last-transform-function)) ; Restore it. + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-transform-function + "Completion-candidate transformation is now ON" + "Completion-candidate transformation is now OFF"))) + +(defalias 'toggle-icicle-incremental-completion 'icicle-toggle-incremental-completion) +;;;###autoload +(defun icicle-toggle-incremental-completion () ; Bound to `C-#' in the minibuffer. + "Toggle the value of option `icicle-incremental-completion-flag'. +If the current value is t or `always', then it is set to nil. +If the current value is nil, then it is set to t. +This command never sets the value to non-nil and non-t. + +Bound to `C-#' in the minibuffer." + (interactive) + (setq icicle-incremental-completion-flag (not icicle-incremental-completion-flag) + icicle-incremental-completion-p icicle-incremental-completion-flag) + (icicle-msg-maybe-in-minibuffer (if icicle-incremental-completion-flag + "Incremental completion is now ON" + "Incremental completion is now OFF"))) + +(defalias 'toggle-icicle-expand-to-common-match 'icicle-toggle-expand-to-common-match) +;;;###autoload +(defun icicle-toggle-expand-to-common-match () ; Bound to `C-;' in the minibuffer. + "Toggle the value of `icicle-expand-input-to-common-match-flag'. +Bound to `C-;' in the minibuffer." + (interactive) + (setq icicle-expand-input-to-common-match-flag (not icicle-expand-input-to-common-match-flag)) + (icicle-msg-maybe-in-minibuffer (if icicle-expand-input-to-common-match-flag + "Expanding input to common match is now ON" + "Expanding input to common match is now OFF"))) + +;;;###autoload +(defun icicle-dispatch-C-^ () ; Bound to `C-^' in the minibuffer. + "Do the right thing for `C-^' +When Icicles searching, call `icicle-toggle-highlight-all-current'. +Otherwise, call `icicle-toggle-remote-file-testing'. +Bound to `C-^' in the minibuffer." + (interactive) + (if (eq icicle-candidate-action-fn 'icicle-search-action) + (icicle-toggle-highlight-all-current) + (icicle-toggle-remote-file-testing))) + +(defalias 'toggle-icicle-remote-file-testing 'icicle-toggle-remote-file-testing) +;;;###autoload +(defun icicle-toggle-remote-file-testing () ; Bound to `C-^' in the minibuffer. + "Toggle `icicle-test-for-remote-files-flag'. +If you use Tramp for accessing remote files, then turning this off +also turns off Tramp file-name completion. Therefore, if you use this +command to turn off testing of remote file names, then use it also to +turn testing back on (instead of just setting the option to non-nil). + +Bound to `C-^' in the minibuffer, except during Icicles searching." + (interactive) + (setq icicle-test-for-remote-files-flag (not icicle-test-for-remote-files-flag)) + (when (require 'tramp nil t) + (if (not icicle-test-for-remote-files-flag) + (tramp-unload-file-name-handlers) ; Turn off Tramp remote file-name completion. + ;; Bind `partial-completion-mode' to force Tramp file-name handlers unconditionally, for older + ;; Tramp versions than 2.1 (ugly HACK). This code should work for all Tramp versions. + (let ((non-essential t) ; Emacs 23.2+ + (partial-completion-mode t)) + (condition-case nil + (tramp-register-file-name-handlers) ; Emacs 22+ + (void-function + (tramp-register-file-name-handler) ; The order of these two matters. + (tramp-register-completion-file-name-handler)))))) + (message "Updating completions...") + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-test-for-remote-files-flag + "Testing remote file names is now ON" + "Testing remote file names is now OFF"))) + +(defalias 'toggle-icicle-highlight-all-current 'icicle-toggle-highlight-all-current) +;;;###autoload +(defun icicle-toggle-highlight-all-current () ; Bound to `C-^' in the minibuffer. + "Toggle `icicle-search-highlight-all-current-flag'. +Bound to `C-^' in the minibuffer during Icicles searching (only)." + (interactive) + (setq icicle-search-highlight-all-current-flag (not icicle-search-highlight-all-current-flag)) + ;; Rehighlight to see effect of toggle. + (let ((icicle-candidate-nb icicle-candidate-nb)) + (let ((icicle-current-input icicle-current-input)) (icicle-erase-minibuffer)) + (icicle-retrieve-last-input) + (funcall (or icicle-last-completion-command + (if (eq icicle-current-completion-mode 'prefix) + #'icicle-prefix-complete + #'icicle-apropos-complete)))) + (icicle-search-highlight-all-input-matches icicle-current-input) + (when icicle-candidate-nb (icicle-search-action "DUMMY")) ; Get back to current. + (select-window (minibuffer-window)) + (select-frame-set-input-focus (selected-frame)) + (icicle-msg-maybe-in-minibuffer + (if icicle-search-highlight-all-current-flag + "Highlighting current input match in each main search hit is now ON" + "Highlighting current input match in each main search hit is now OFF"))) + +(defalias 'toggle-icicle-hiding-common-match 'icicle-toggle-hiding-common-match) +;;;###autoload +(defun icicle-toggle-hiding-common-match () ; Bound to `C-M-.' in the minibuffer. + "Toggle `icicle-hide-common-match-in-Completions-flag'. +Bound to `C-M-.' in the minibuffer." + (interactive) + (setq icicle-hide-common-match-in-Completions-flag + (not icicle-hide-common-match-in-Completions-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-hide-common-match-in-Completions-flag + "Hiding common match in *Completions* is now ON" + "Hiding common match in *Completions* is now OFF"))) + +(defalias 'toggle-icicle-show-multi-completion 'icicle-toggle-show-multi-completion) +;;;###autoload +(defun icicle-toggle-show-multi-completion () ; Bound to `M-m' in the minibuffer. + "Toggle `icicle-show-multi-completion-flag'. +Bound to `M-m' in the minibuffer." + (interactive) + (setq icicle-show-multi-completion-flag (not icicle-show-multi-completion-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer + (if icicle-show-multi-completion-flag + "Showing multi-completions (when available) is now ON" + "Showing multi-completions (when available) is now OFF"))) + +(defalias 'toggle-icicle-ignored-space-prefix 'icicle-toggle-ignored-space-prefix) +;;;###autoload +(defun icicle-toggle-ignored-space-prefix () ; Bound to `M-_' in the minibuffer, except when searching. + "Toggle `icicle-ignore-space-prefix-flag'. +Bound to `M-_' in the minibuffer, except during Icicles searching. + +Note: If the current command binds `icicle-ignore-space-prefix-flag' +locally, then it is the local, not the global, value that is changed. +For example, `icicle-buffer' binds it to the value of +`icicle-buffer-ignore-space-prefix-flag'. If that is non-nil, then +\\`\\[icicle-toggle-ignored-space-prefix]' toggles \ +`icicle-ignore-space-prefix-flag' to nil only for the +duration of `icicle-buffer'." + (interactive) + (setq icicle-ignore-space-prefix-flag (not icicle-ignore-space-prefix-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-ignore-space-prefix-flag + "Ignoring space prefix is now ON" + "Ignoring space prefix is now OFF"))) + +(defalias 'toggle-icicle-highlight-historical-candidates + 'icicle-toggle-highlight-historical-candidates) +;;;###autoload +(defun icicle-toggle-highlight-historical-candidates () ; Bound to `C-pause' in the minibuffer. + "Toggle `icicle-highlight-historical-candidates-flag'. +Bound to `C-pause' in the minibuffer." + (interactive) + (setq icicle-highlight-historical-candidates-flag + (not icicle-highlight-historical-candidates-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer + (if icicle-highlight-historical-candidates-flag + "Highlighting previously used inputs in *Completions* is now ON" + "Highlighting previously used inputs in *Completions* is now OFF"))) + +;;;###autoload +(defun icicle-dispatch-C-. () ; Bound to `C-.' in the minibuffer. + "Do the right thing for `C-.'. +When using Icicles search (`icicle-search' and similar commands), call + `icicle-toggle-search-cleanup'. +Otherwise, call `icicle-toggle-ignored-extensions'. + +Bound to `C-.' in the minibuffer." + (interactive) + (if icicle-searching-p (icicle-toggle-search-cleanup) (icicle-toggle-ignored-extensions))) + +(defalias 'toggle-icicle-ignored-extensions 'icicle-toggle-ignored-extensions) +;;;###autoload +(defun icicle-toggle-ignored-extensions () ; Bound to `C-.' in minibuffer except in Icicles search. + "Toggle respect of `completion-ignored-extensions'. +Bound to `C-.' in minibuffer during file-name input." + (interactive) + (if (consp completion-ignored-extensions) + (setq icicle-saved-ignored-extensions completion-ignored-extensions ; Save it. + completion-ignored-extensions () + icicle-ignored-extensions-regexp nil) + (setq completion-ignored-extensions icicle-saved-ignored-extensions ; Restore it. + icicle-ignored-extensions-regexp ; Make regexp for ignored file extensions. + (concat "\\(" (mapconcat #'regexp-quote completion-ignored-extensions "$\\|") "$\\)\\'"))) + ;; Flag to prevent updating `icicle-ignored-extensions-regexp' unless + ;; `completion-ignored-extensions' changes. + (setq icicle-ignored-extensions completion-ignored-extensions) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if completion-ignored-extensions + "Ignoring selected file extensions is now ON" + "Ignoring selected file extensions is now OFF"))) + +(defalias 'toggle-icicle-search-cleanup 'icicle-toggle-search-cleanup) +;;;###autoload +(defun icicle-toggle-search-cleanup () ; Bound to `C-.' in minibuffer during Icicles search. + "Toggle removal of `icicle-search' highlighting after a search. +This toggles option `icicle-search-cleanup-flag'. +Bound to `C-.' in the minibuffer, except for file-name input." + (interactive) + (setq icicle-search-cleanup-flag (not icicle-search-cleanup-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-search-cleanup-flag + "Removal of Icicles search highlighting is now ON" + "Removal of Icicles search highlighting is now OFF"))) + +;;$$$ (defun icicle-dispatch-C-backquote () ; Bound to `C-`' in the minibuffer. +;; "Do the right thing for `C-`'. +;; When searching, call `icicle-toggle-literal-replacement'. +;; Otherwise, call `icicle-toggle-regexp-quote'. + +;; Bound to `C-`' in the minibuffer." +;; (interactive) +;; (if icicle-searching-p (icicle-toggle-literal-replacement) (icicle-toggle-regexp-quote))) + +(defalias 'toggle-icicle-regexp-quote 'icicle-toggle-regexp-quote) +;;;###autoload +(defun icicle-toggle-regexp-quote () ; Bound to `C-`' in the minibuffer. + "Toggle escaping of regexp special chars (`icicle-regexp-quote-flag'). +Bound to `C-`' in the minibuffer." + (interactive) + (setq icicle-regexp-quote-flag (not icicle-regexp-quote-flag)) + (icicle-complete-again-update) + (icicle-msg-maybe-in-minibuffer (if icicle-regexp-quote-flag + "Escaping of regexp special characters is now ON" + "Escaping of regexp special characters is now OFF"))) + +(defun icicle-regexp-quote-input (beg end) ; Bound to `C-M-;' in the minibuffer. + "Regexp quote current input or its active region, then apropos-complete. +Use this if you want to literally match all what is currently in the +minibuffer or selected text there, but you also want to use that +literal text as part of a regexp for apropos completion. + +This turns off `icicle-expand-input-to-common-match-flag'. +You can toggle that option using `C-;'. + +Bound to `C-M-;' in the minibuffer." + (interactive "r") + (icicle-barf-if-outside-Completions-and-minibuffer) + (let ((regionp (and mark-active (mark) (/= (point) (mark)))) + quoted-part) + (save-excursion + (save-restriction + (narrow-to-region (if regionp beg (point-min)) (if regionp end (point-max))) + (setq quoted-part (regexp-quote (icicle-input-from-minibuffer))) + (delete-region (point-min) (point-max)) + (insert quoted-part)))) + (setq icicle-current-input (icicle-input-from-minibuffer) + icicle-expand-input-to-common-match-flag nil) + (icicle-apropos-complete) + (icicle-msg-maybe-in-minibuffer (substitute-command-keys "Expansion to common match is OFF. \ +`\\\\[icicle-toggle-expand-to-common-match]' to toggle"))) + +(defalias 'toggle-icicle-literal-replacement 'icicle-toggle-literal-replacement) +;;;###autoload +(defun icicle-toggle-literal-replacement () ; Bound to `C-M-`' in the minibuffer. + "Toggle escaping of regexp special chars in replacement text. +This toggles option `icicle-search-replace-literally-flag'. + +Bound to `C-M-`' in the minibuffer." + (interactive) + (setq icicle-search-replace-literally-flag (not icicle-search-replace-literally-flag)) + (icicle-msg-maybe-in-minibuffer (if icicle-search-replace-literally-flag + "Replacement of text literally is now ON" + "Replacement of text literally is now OFF"))) + +(defalias 'toggle-icicle-case-sensitivity 'icicle-toggle-case-sensitivity) +;;;###autoload +(defun icicle-toggle-case-sensitivity (file+buff-p) ; Bound to `C-S-a' in the minibuffer, i.e., `C-A'. + "Toggle case sensitivity. + +This toggles `case-fold-search' and `completion-ignore-case'. With a +prefix arg, it also toggles `read-file-name-completion-ignore-case' +\(Emacs 22 and later) and `read-buffer-completion-ignore-case' (Emacs +23 and later). + +More precisely, this command first toggles the default value of +`case-fold-search', and then it sets the other variables to the value +of `case-fold-search'. + +Note: +1. This toggles the default value of `case-fold-search'. This means +that it does not matter which buffer is current when you call this +command - all buffers are affected henceforth. + +2. Some Icicles commands bind one or more of these variables, so +invoking this command during command execution will not necessarily +toggle the global values of all of the variables. + +Bound to `C-A' in the minibuffer, that is, `C-S-a'." + (interactive "P") + (setq-default case-fold-search (not case-fold-search) + completion-ignore-case case-fold-search) + (when file+buff-p + (when (boundp 'read-file-name-completion-ignore-case) ; Emacs 22+ + (setq read-file-name-completion-ignore-case case-fold-search)) + (when (boundp 'read-buffer-completion-ignore-case) ; Emacs 23+ + (setq read-buffer-completion-ignore-case case-fold-search))) + (icicle-complete-again-update) + (icicle-highlight-lighter) + (icicle-msg-maybe-in-minibuffer + (cond ((and case-fold-search + (or (not (boundp 'read-file-name-completion-ignore-case)) + read-file-name-completion-ignore-case) + (or (not (boundp 'read-buffer-completion-ignore-case)) + read-buffer-completion-ignore-case)) + "Case-sensitive comparison is now OFF, everywhere") + (case-fold-search "Case-sensitive comparison is now OFF, except for files and buffers") + (t "Case-sensitive comparison is now ON, everywhere")))) + +;;;###autoload +(defun icicle-remove-Completions-window () ; `icicle-delete-window' (`C-x 0') does this in minibuffer. + "Remove the *Completions* window." + (interactive) + (when (and (get-buffer-window "*Completions*" 'visible) ; Only if visible and not the selected window. + (not (eq (window-buffer (selected-window)) (get-buffer "*Completions*")))) + ;; Ignore error, in particular, "Attempt to delete the sole visible or iconified frame". + (condition-case nil (icicle-delete-windows-on "*Completions*") (error nil)))) + +;; This is actually a top-level command, but it is in this file because it is used by +;; `icicle-remove-Completions-window'. +;;;###autoload +(defun icicle-delete-windows-on (buffer) + "Delete all windows showing BUFFER. +If such a window is alone in its frame, then delete the frame - unless +it is the only frame or a standalone minibuffer frame." + (interactive + (list (let ((enable-recursive-minibuffers t)) + (read-buffer "Remove all windows showing buffer: " (current-buffer) 'existing)))) + (setq buffer (get-buffer buffer)) ; Convert to buffer. + (when buffer ; Do nothing if null BUFFER. + ;; Avoid error message "Attempt to delete minibuffer or sole ordinary window". + (let* ((this-buffer-frames (icicle-frames-on buffer t)) + (this-frame (car this-buffer-frames))) + (unless (and this-frame (frame-visible-p this-frame) + (null (cdr this-buffer-frames)) ; Only one frame shows BUFFER. + (eq (cdr (assoc 'minibuffer (frame-parameters this-frame))) + (active-minibuffer-window)) ; Has an active minibuffer. + (save-window-excursion + (select-frame this-frame) + (one-window-p t 'SELECTED-FRAME-ONLY))) ; Only one window. + (let (win) + (dolist (fr this-buffer-frames) + (setq win (get-buffer-window buffer fr)) + (select-window win) + (if (and (one-window-p t) (cdr (visible-frame-list))) ; Sole window but not sole frame. + (delete-frame) + (delete-window (selected-window))))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-mcmd) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-mcmd.el ends here diff --git a/.emacs.d/icicles/icicles-mode.el b/.emacs.d/icicles/icicles-mode.el new file mode 100644 index 0000000..5705d63 --- /dev/null +++ b/.emacs.d/icicles/icicles-mode.el @@ -0,0 +1,3570 @@ +;;; icicles-mode.el --- Icicle Mode definition for Icicles +;; +;; Filename: icicles-mode.el +;; Description: Icicle Mode definition for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 10:21:10 2006 +;; Version: 22.0 +;; Last-Updated: Sat Jul 17 14:27:18 2010 (-0700) +;; By: dradams +;; Update #: 6610 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-mode.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+', `apropos-fn+var', `avoid', `cl', +;; `cus-edit', `cus-face', `cus-load', `cus-start', `custom', +;; `dired', `dired+', `dired-aux', `dired-x', `doremi', `easymenu', +;; `ediff-diff', `ediff-help', `ediff-init', `ediff-merg', +;; `ediff-mult', `ediff-util', `ediff-wind', `el-swank-fuzzy', +;; `ffap', `ffap-', `fit-frame', `frame-cmds', `frame-fns', +;; `fuzzy-match', `help+20', `hexrgb', `icicles-cmd1', +;; `icicles-cmd2', `icicles-face', `icicles-fn', `icicles-mcmd', +;; `icicles-opt', `icicles-var', `info', `info+', `kmacro', +;; `levenshtein', `menu-bar', `menu-bar+', `misc-cmds', `misc-fns', +;; `mkhtml', `mkhtml-htmlize', `mwheel', `pp', `pp+', `ring', +;; `ring+', `second-sel', `strings', `thingatpt', `thingatpt+', +;; `unaccent', `w32-browser', `w32browser-dlgopen', `wid-edit', +;; `wid-edit+', `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines the +;; command `icicle-mode'. For Icicles documentation, see +;; `icicles-doc1.el' and `icicles-doc2.el'. +;; +;; Commands defined here: +;; +;; `icicle-handle-switch-frame', `icicle-mode', `icy-mode', +;; `icicle-skip-this-command', `old-bbdb-complete-name', +;; `old-comint-dynamic-complete', +;; `old-comint-replace-by-expanded-filename', +;; `old-dired-read-shell-command', `old-ess-complete-object-name', +;; `old-gud-gdb-complete-command', `old-read-shell-command', +;; `orig-read-file-name'. +;; +;; Non-interactive functions defined here: +;; +;; `icicle-activate-mark', `icicle-add-menu-item-to-cmd-history', +;; `icicle-bind-completion-keys', `icicle-bind-isearch-keys', +;; `icicle-bind-key-completion-keys-for-map-var', +;; `icicle-bind-key-completion-keys-in-keymaps-from', +;; `icicle-bind-other-keymap-keys', +;; `icicle-cancel-Help-redirection', `icicle-define-cycling-keys', +;; `icicle-define-icicle-maps', `icicle-define-minibuffer-maps', +;; `icicle-minibuffer-setup', `icicle-rebind-global', +;; `icicle-redefine-standard-commands', +;; `icicle-redefine-standard-options', +;; `icicle-redefine-std-completion-fns', +;; `icicle-restore-completion-keys', +;; `icicle-restore-other-keymap-keys', +;; `icicle-restore-region-face', +;; `icicle-restore-standard-commands', +;; `icicle-restore-standard-options', +;; `icicle-restore-std-completion-fns', +;; `icicle-run-icicle-post-command-hook', +;; `icicle-run-icicle-pre-command-hook', +;; `icicle-select-minibuffer-contents', `icicle-set-calling-cmd', +;; `icicle-S-iso-lefttab-to-S-TAB', `icicle-top-level-prep', +;; `icicle-unbind-isearch-keys', +;; `icicle-unbind-key-completion-keys-for-map-var', +;; `icicle-unbind-key-completion-keys-in-keymaps-from', +;; `icicle-undo-std-completion-faces', `icicle-unmap', +;; `icicle-update-ignored-extensions-regexp'. +;; +;; User options defined here (in Custom group `Icicles'): +;; +;; `icicle-mode', `icicle-mode-hook'. +;; +;; Internal variables defined here: +;; +;; `icicle-bookmark-menu-map', `icicle-custom-menu-map', +;; `icicle-describe-menu-map', `icicle-edit-menu-map', +;; `icicle-file-menu-map', `icicle-frames-menu-map', +;; `icicle-info-menu-map', `icicle-mode-map', +;; `icicle-options-menu-map', `icicle-search-menu-map', +;; `icicle-search-tags-menu-map'. +;; +;; 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. +;; +;; (@> "User Options (alphabetical)") +;; (@> "Internal variables (alphabetical)") +;; (@> "Icicle mode command") +;; (@> "Other Icicles functions that define Icicle mode") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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: + +(require 'icicles-opt) + ;; icicle-buffer-configs, icicle-buffer-extras, icicle-change-region-background-flag, + ;; icicle-cycling-respects-completion-mode, icicle-incremental-completion-flag, + ;; icicle-default-value, icicle-kmacro-ring-max, icicle-minibuffer-setup-hook, + ;; icicle-modal-cycle-down-keys, icicle-modal-cycle-up-keys, + ;; icicle-redefine-standard-commands-flag, icicle-regexp-search-ring-max, + ;; icicle-region-background, icicle-search-ring-max, icicle-show-Completions-initially-flag, + ;; icicle-top-level-key-bindings, icicle-touche-pas-aux-menus-flag, + ;; icicle-word-completion-keys, icicle-yank-function +(require 'icicles-fn) ;; assq-delete-all, icicle-completing-p, + ;; icicle-isearch-complete-past-string, icicle-toggle-icicle-mode-twice, + ;; icicle-unhighlight-lighter +(require 'icicles-var) + ;; icicle-candidate-action-fn, icicle-candidate-nb, icicle-cmd-calling-for-completion, + ;; icicle-completing-p, icicle-completion-candidates, + ;; icicle-current-completion-mode, icicle-default-directory, icicle-ignored-extensions, + ;; icicle-ignored-extensions-regexp, icicle-incremental-completion-p, icicle-initial-value, + ;; icicle-last-completion-candidate, icicle-last-completion-command, icicle-last-input, + ;; icicle-menu-map, icicle-pre-minibuffer-buffer, icicle-minor-mode-map-entry, + ;; icicle-saved-completion-candidates, icicle-saved-kmacro-ring-max, + ;; icicle-saved-regexp-search-ring-max, icicle-saved-region-background, + ;; icicle-saved-search-ring-max, icicle-search-current-overlay, icicle-search-overlays, + ;; icicle-search-refined-overlays +(require 'icicles-cmd1) + ;; icicle-add-buffer-candidate, icicle-add-buffer-config, icicle-bbdb-complete-name, + ;; icicle-customize-face, icicle-customize-face-other-window, icicle-dabbrev-completion, + ;; icicle-select-bookmarked-region +(require 'icicles-cmd2) + ;; icicle-imenu, icicle-occur, icicle-search, icicle-search-bookmark, + ;; icicle-search-bookmarks-together, icicle-search-buffer, icicle-search-file + +;; Use `condition-case' because if `mb-depth.el' can't be found, `mb-depth+.el' is not provided. +(when (>= emacs-major-version 22) (condition-case nil (require 'mb-depth+ nil t) (error nil))) + ;; (no error if not found): minibuffer-depth-indicate-mode + +(eval-when-compile (require 'cl)) ;; push, dolist, case + ;; plus, for Emacs < 20: when, unless +(require 'dired+ nil t) ;; (no error if not found): + ;; diredp-menu-bar-operate-menu, diredp-menu-bar-subdir-menu +(require 'dired) ;; dired-mode-map +(require 'menu-bar+ nil t) ;; (no error if not found): + ;; menu-bar-apropos-menu, menu-bar-describe-menu, menu-bar-edit-menu, + ;; menu-bar-file-menu, menu-bar-frames-menu, menu-bar-options-menu, menu-bar-search-tags-menu + +;; `icicle-apropos-complete' is used here. It is defined in `icicles-mcmd.el'. +;; `icicle-file-name-input-p' is used here. It is defined in `icicles-fn.el'. + +;;; Defvars to quiet byte-compiler: +(when (< emacs-major-version 22) + (defvar kmacro-ring-max) + (defvar minibuffer-local-filename-completion-map) + (defvar minibuffer-local-must-match-filename-map) + (defvar minibuffer-local-filename-must-match-map) + (defvar mouse-wheel-down-event) + (defvar mouse-wheel-up-event) + (defvar read-file-name-function)) + +(defvar Buffer-menu-mode-map) ; Defined in `buff-menu.el'. +(defvar comint-mode-map) ; Defined in `comint.el'. +(defvar crm-local-completion-map) ; Defined in `crm.el'. +(defvar crm-local-must-match-map) ; Defined in `crm.el'. +(defvar dired-mode-map) ; Defined in `dired.el'. +(defvar gud-minibuffer-local-map) ; Defined in `gud.el'. +(defvar ibuffer-mode-map) ; Defined in `ibuffer.el'. +(defvar ibuffer-mode-operate-map) ; Defined in `ibuffer.el'. +(defvar icicle-crm-local-completion-map) ; In `icicles-fn.el' after load `crm.el'. +(defvar icicle-crm-local-must-match-map) ; In `icicles-fn.el' after load `crm.el'. +(defvar icicle-kmacro-ring-max) ; In `icicles-opt.el' for Emacs 22+. +(defvar icicle-saved-kmacro-ring-max) ; In `icicles-var.el' for Emacs 22+. +(defvar ielm-map) ; Defined in `ielm.el'. +(defvar inferior-tcl-mode-map) ; Defined in `tcl.el'. +(defvar Info-mode-map) ; Defined in `info.el'. +(defvar isearch-mode-map) ; Defined in `isearch.el'. +(defvar old-crm-local-completion-map) ; In `icicles-fn.el' after load `crm.el'. +(defvar old-crm-local-must-match-map) ; In `icicles-fn.el' after load `crm.el'. +(defvar shell-mode-map) ; Defined in `shell.el'. +(defvar sh-mode-map) ; Defined in `sh-script.el'. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "User Options (alphabetical)") + +;;; User Options (alphabetical) -------------------------------------- + +;; Emacs 20 only +(unless (fboundp 'define-minor-mode) + (defcustom icicle-mode nil + "*Toggle minibuffer input completion and cycling. +Setting this variable directly does not take effect; +use either \\[customize] or command `icy-mode' (aka `icicle-mode')." + :set (lambda (symbol value) (icicle-mode (if value 1 -1))) + :initialize 'custom-initialize-default + :type 'boolean :group 'Icicles-Miscellaneous :require 'icicles)) + +;;;###autoload +(defcustom icicle-mode-hook nil + "*Functions run after entering and exiting Icicle mode." + :type 'hook :group 'Icicles-Miscellaneous) + +;;(@* "Internal variables (alphabetical)") + +;;; Internal variables (alphabetical) -------------------------------- + +(defvar icicle-mode-map nil + "Keymap for Icicle mode. These are top-level key bindings. +See also `icicle-define-minibuffer-maps' for minibuffer bindings and +bindings in *Completions*.") + +;;(@* "Icicle mode command") + +;;; Icicle mode command ---------------------------------------------- + +;; Main command. Inspired from `icomplete-mode'. +(defalias 'icy-mode 'icicle-mode) +;;;###autoload +(when (fboundp 'define-minor-mode) ; Emacs 21+ ------------ + (when (> emacs-major-version 22) + (defadvice call-interactively (after icicle-save-to-history disable activate) + "Save command to `icicle-interactive-history'." + ;; If command's input is not a parameterized (e.g. mouse) event, record it. + (let* ((fn (ad-get-arg 0)) + (int (interactive-form fn))) + (when (and (symbolp fn) (consp int) (or (not (stringp (cadr int))) + (string= (cadr int) "") + (not (eq ?e (aref (cadr int) 0))))) + (pushnew (symbol-name fn) icicle-interactive-history)))) + (when (boundp 'savehist-save-hook) ; Do not save `icicle-interactive-history' (too large). + (add-hook 'savehist-save-hook + (lambda () (setq savehist-minibuffer-history-variables + (delq 'icicle-interactive-history + savehist-minibuffer-history-variables)))))) + (when (> emacs-major-version 21) + (defadvice describe-face (before icicle-respect-WYSIWYG activate) + "`read-face-name' respects `icicle-WYSIWYG-Completions-flag'. +If non-nil, then it does not use `completing-read-multiple' (which +cannot take advantage of WYSIWYG)." + (interactive (list (read-face-name "Describe face" "= `default' face" + (not icicle-WYSIWYG-Completions-flag)))))) + + (eval '(define-minor-mode icicle-mode + "Icicle mode: Toggle minibuffer input completion and cycling. +Non-nil prefix ARG turns mode on if ARG > 0, else turns it off. +Icicle mode is a global minor mode. It binds keys in the minibuffer. + +The following top-level commands are also available in Icicle mode. +In many cases there are also `other-window' versions. + +`clear-option' (alias) - Set binary option(s) to nil +`icicle-add-buffer-candidate' - Add always-candidate buffer +`icicle-add-buffer-config' - To `icicle-buffer-configs' +`icicle-add-entry-to-saved-completion-set' - Add completion to a set +`icicle-add/update-saved-completion-set' - To + `icicle-saved-completion-sets' +`icicle-apply' - Apply function to alist items +`icicle-apropos' - `apropos', but shows matches +`icicle-apropos-command' - Enhanced `apropos-command' +`icicle-apropos-variable' - Enhanced `apropos-variable' +`icicle-apropos-zippy' - Show matching Zippy quotes +`icicle-bookmark' - Jump to a bookmark +`icicle-bookmark-bookmark-list' - Jump to a bookmark list +`icicle-bookmark-desktop' - Jump to a desktop bookmark +`icicle-bookmark-dired' - Jump to a Dired bookmark +`icicle-bookmark-file' - Jump to a file bookmark +`icicle-bookmark-gnus' - Jump to a Gnus bookmark +`icicle-bookmark-info' - Jump to an Info bookmark +`icicle-bookmark-local-file' - Jump to local-file bookmark +`icicle-bookmark-man' - Jump to a `man'-page bookmark +`icicle-bookmark-non-file' - Jump to a buffer bookmark +`icicle-bookmark-region' - Jump to a region bookmark +`icicle-bookmark-remote-file' - Jump to a remote file +`icicle-bookmark-specific-buffers' - Jump to a bookmarked buffer +`icicle-bookmark-specific-files' - Jump to a bookmarked file +`icicle-bookmark-this-buffer' - Jump to bookmark for this buf +`icicle-bookmark-url' - Jump to a URL bookmark +`icicle-bookmark-w3m' - Jump to a W3M (URL) bookmark +`icicle-buffer' - Switch to buffer +`icicle-buffer-config' - Pick `icicle-buffer' options +`icicle-buffer-list' - Choose a list of buffer names +`icicle-change-alternative-sort-order' - Choose an alternative sort +`icicle-change-sort-order' - Choose a sort order +`icicle-clear-current-history' - Clear current history entries +`icicle-clear-history' - Clear entries from a history +`icicle-color-theme' - Change color theme +`icicle-comint-command' - Reuse shell etc. command +`icicle-comint-dynamic-complete' - Text completion in shell +`icicle-comint-search' - Reuse shell etc. command +`icicle-command-abbrev' - Multi-command `M-x' + abbrevs +`icicle-compilation-search' - `icicle-search' and show hits +`icicle-complete-keys' - Complete keys +`icicle-complete-thesaurus-entry' - Complete word using thesaurus +`icicle-completing-yank' - `yank' using completion +`icicle-customize-face' - Multi-`customize-face' +`icicle-customize-icicles-group' - Customize options and faces +`icicle-delete-file' - Delete file/directory +`icicle-delete-window' - Delete window (`C-u': buffer) +`icicle-delete-windows' - Delete all windows for buffer +`icicle-dired' - Multi-command Dired +`icicle-doc' - Show doc for fn, var, or face +`icicle-doremi-candidate-width-factor+' - +/- candidate column width +`icicle-doremi-increment-max-candidates+' - +/- max number candidates +`icicle-doremi-increment-swank-prefix-length+' - +/- swank prefix +`icicle-doremi-increment-swank-timeout+' - +/- swank completion msec +`icicle-doremi-increment-variable+' - Increment var using Do Re Mi +`icicle-doremi-inter-candidates-min-spaces+' - +/- candidate spacing +`icicle-doremi-zoom-Completions+' - +/- *Completions* text size +`icicle-execute-extended-command' - Multi-command `M-x' +`icicle-execute-named-keyboard-macro' - Execute named keyboard macro +`icicle-face-list' - Choose a list of face names +`icicle-file-list' - Choose a list of file names +`icicle-file' - Visit file/directory +`icicle-find-file' - same: relative only +`icicle-find-file-absolute' - same: absolute only +`icicle-find-file-in-tags-table' - File in tags table +`icicle-find-first-tag' - Visit definition with tag +`icicle-find-tag' - Visit definition with tag +`icicle-font' - Change font of frame +`icicle-frame-bg' - Change background of frame +`icicle-frame-fg' - Change foreground of frame +`icicle-fundoc' - Show function description +`icicle-goto-global-marker' - Go to a global marker +`icicle-goto-marker' - Go to a marker in this buffer +`icicle-imenu*' - Navigate among Imenu entries +`icicle-increment-option' - Increment numeric option +`icicle-increment-variable' - Increment numeric variable +`icicle-Info-goto-node' - Multi-cmd `Info-goto-node' +`icicle-Info-index' - Multi-command `Info-index' +`icicle-Info-menu' - Multi-command `Info-menu' +`icicle-Info-virtual-book' - Open a virtual Info book +`icicle-insert-buffer' - Multi-command `insert-buffer' +`icicle-insert-thesaurus-entry' - Insert thesaurus entry(s) +`icicle-keyword-list' - Choose a list of keywords +`icicle-kill-buffer' - Kill buffer +`icicle-kmacro' - Execute a keyboard macro +`icicle-locate-file' - Visit file(s) in a directory +`icicle-minibuffer-help' - Show Icicles minibuffer help +`icicle-mode' or `icy-mode' - Toggle Icicle mode +`icicle-next-S-TAB-completion-method' - Next S-TAB completion method +`icicle-next-TAB-completion-method' - Next TAB completion method +`icicle-occur' - Incremental `occur' +`icicle-other-window-or-frame' - Other window/frame or select +`icicle-plist' - Show symbols, property lists +`icicle-recent-file' - Open recently used file(s) +`icicle-recompute-shell-command-candidates' - Update from search path +`icicle-remove-buffer-candidate' - Remove always-candidate buf +`icicle-remove-buffer-config' - From `icicle-buffer-configs' +`icicle-remove-entry-from-saved-completion-set' - From a saved set +`icicle-remove-file-from-recentf-list' - Remove from recent files list +`icicle-remove-saved-completion-set' - From + `icicle-saved-completion-sets' +`icicle-reset-option-to-nil' - Set binary option(s) to nil +`icicle-save-string-to-variable' - Save text for use with `C-=' +`icicle-search' - Search with regexps & cycling +`icicle-search-bookmark' - Search bookmarks separately +`icicle-search-bookmark-list-bookmark' - Search bookmark lists +`icicle-search-bookmarks-together' - Search bookmarks together +`icicle-search-char-property' - Search for overlay/text props +`icicle-search-dired-bookmark' - Search Dired bookmarks +`icicle-search-dired-marked' - Search marked files in Dired +`icicle-search-file' - Search multiple files +`icicle-search-file-bookmark' - Search bookmarked files +`icicle-search-gnus-bookmark' - Search bookmarked Gnus msgs +`icicle-search-ibuffer-marked' - Search marked bufs in Ibuffer +`icicle-search-info-bookmark' - Search bookmarked Info nodes +`icicle-search-keywords' - Search with regexp keywords +`icicle-search-local-file-bookmark' - Search bookmarked local files +`icicle-search-man-bookmark' - Search bookmarked `man' pages +`icicle-search-non-file-bookmark' - Search bookmarked buffers +`icicle-search-overlay-property' - Search for overlay properties +`icicle-search-pages' - Search Emacs pages +`icicle-search-paragraphs' - Search Emacs paragraphs +`icicle-search-region-bookmark' - Search bookmarked regions +`icicle-search-remote-file-bookmark' - Search remote bookmarks +`icicle-search-sentences' - Search sentences as contexts +`icicle-search-text-property' - Search for faces etc. +`icicle-search-url-bookmark' - Search bookmarked URLs +`icicle-search-word' - Whole-word search +`icicle-select-bookmarked-region' - Select bookmarked regions +`icicle-select-frame' - Select a frame by name +`icicle-select-window' - Select window by buffer name +`icicle-send-bug-report' - Send Icicles bug report +`icicle-set-option-to-t' - Set binary option(s) to t +`icicle-toggle-~-for-home-dir' - Toggle using `~' for $HOME +`icicle-toggle-alternative-sorting' - Swap alternative sort +`icicle-toggle-angle-brackets' - Toggle using angle brackets +`icicle-toggle-C-for-actions' - Toggle using `C-' for actions +`icicle-toggle-case-sensitivity' - Toggle case sensitivity +`icicle-toggle-dot' - Toggle `.' matching newlines +`icicle-toggle-expand-to-common-match' - Toggle input ECM expansion +`icicle-toggle-hiding-common-match' - Toggle match in *Completions* +`icicle-toggle-highlight-all-current' - Toggle max search highlight +`icicle-toggle-highlight-historical-candidates' + - Toggle past-input highlight +`icicle-toggle-ignored-extensions' - Toggle ignored files +`icicle-toggle-ignored-space-prefix' - Toggle ignoring space prefix +`icicle-toggle-incremental-completion' - Toggle apropos icompletion +`icicle-toggle-option' - Toggle binary user option +`icicle-toggle-proxy-candidates' - Toggle proxy candidates +`icicle-toggle-regexp-quote' - Toggle regexp escaping +`icicle-toggle-search-cleanup' - Toggle search highlighting +`icicle-toggle-search-replace-common-match' - Toggle ECM replacement +`icicle-toggle-search-replace-whole' - Toggle replacing whole hit +`icicle-toggle-search-whole-word' - Toggle whole-word searching +`icicle-toggle-show-multi-completion' - Toggle multi-completions +`icicle-toggle-sorting' - Toggle sorting of completions +`icicle-toggle-transforming' - Toggle duplicate removal +`icicle-toggle-WYSIWYG-Completions' - Toggle WYSIWYG *Completions* +`icicle-vardoc' - Show variable description +`icicle-where-is' - `where-is' multi-command +`icicle-yank-maybe-completing' - `yank' maybe using completion +`toggle' (alias) - Toggle binary user option + +For more information, use `\\\\[icicle-minibuffer-help]' \ +when the minibuffer is active. + +Note: Depending on your platform, if you use Icicles in a text +terminal (that is, without a window system/manager), then you might +need to change some of the key bindings, if some of the default +bindings are not available to you." + :global t :group 'Icicles-Miscellaneous :lighter " Icy" :init-value nil + (cond (icicle-mode + ;; (when (interactive-p) + ;; (unless (or window-system (and (fboundp 'daemonp) (daemonp))) + ;; (with-output-to-temp-buffer "*Attention*" + ;; (princ "You are using Icicles in a text terminal (no window ") + ;; (princ "system/manager).\n\nIcicles makes use of many keys that are ") + ;; (princ "unavailable when running\nEmacs in a text terminal. You will ") + ;; (princ "want to rebind those keys.\n") + ;; (princ "See the Icicles doc, section Key Bindings.\n")) + ;; (message "Icicles uses keys that might not be suitable for a text terminal") + ;; (sit-for 5))) + (icicle-define-icicle-maps) + (icicle-bind-other-keymap-keys) + (add-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup) + (add-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection) + (add-hook 'minibuffer-exit-hook 'icicle-restore-region-face) + (add-hook 'minibuffer-exit-hook 'icicle-unhighlight-lighter) + (add-hook 'icicle-post-command-hook 'icicle-activate-mark 'append) + (add-hook 'completion-setup-hook 'icicle-set-calling-cmd 'append) + (when icicle-customize-save-flag + (add-hook 'kill-emacs-hook 'icicle-command-abbrev-save)) + (add-hook 'comint-mode-hook 'icicle-comint-hook-fn) + (add-hook 'compilation-mode-hook 'icicle-compilation-hook-fn) + (add-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn) + (add-hook 'temp-buffer-show-hook 'icicle-fit-completions-window) + (icicle-undo-std-completion-faces) + (icicle-redefine-std-completion-fns) + (icicle-redefine-standard-commands) + (icicle-redefine-standard-options) + (when (ad-find-some-advice 'describe-face 'before 'icicle-respect-WYSIWYG) + (ad-enable-advice 'describe-face 'before 'icicle-respect-WYSIWYG)) + (when (fboundp 'minibuffer-depth-indicate-mode) ; Defined in `mb-depth(+).el' + (minibuffer-depth-indicate-mode 99)) + (if icicle-menu-items-to-history-flag + (add-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history) + (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)) + (when (> emacs-major-version 22) + (when icicle-populate-interactive-history-flag + (ad-enable-advice 'call-interactively 'after 'icicle-save-to-history)) + (ad-activate 'call-interactively)) + (dolist (fn icicle-inhibit-advice-functions) + (when (and (fboundp fn) (ad-is-active fn)) + (push (cons fn (ad-copy-advice-info fn)) icicle-advice-info-list) + (ad-deactivate fn)))) + (t + (makunbound 'icicle-mode-map) + (icicle-restore-other-keymap-keys) + (remove-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup) + (remove-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection) + (remove-hook 'minibuffer-exit-hook 'icicle-restore-region-face) + (remove-hook 'icicle-post-command-hook 'icicle-activate-mark) + ;; The pre- and post-command hooks are local to the minibuffer, + ;; So they are added in `icicle-minibuffer-setup', not here. + ;; Nevertheless, they are removed here when Icicle mode is exited. + (remove-hook 'pre-command-hook 'icicle-top-level-prep) + (remove-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook t) + (remove-hook 'post-command-hook 'icicle-run-icicle-post-command-hook t) + (remove-hook 'completion-setup-hook 'icicle-set-calling-cmd) + (remove-hook 'kill-emacs-hook 'icicle-command-abbrev-save) + (remove-hook 'comint-mode-hook 'icicle-comint-hook-fn) + (remove-hook 'compilation-mode-hook 'icicle-compilation-hook-fn) + (remove-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn) + (remove-hook 'temp-buffer-show-hook 'icicle-fit-completions-window) + ;; $$ Should restore standard completion faces here. + (icicle-restore-std-completion-fns) + (icicle-restore-standard-commands) + (icicle-restore-standard-options) + (when (ad-find-some-advice 'describe-face 'before 'icicle-respect-WYSIWYG) + (ad-disable-advice 'describe-face 'before 'icicle-respect-WYSIWYG)) + (when (fboundp 'minibuffer-depth-indicate-mode) + (minibuffer-depth-indicate-mode -99)) + (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history) + (when (> emacs-major-version 22) + (ad-disable-advice 'call-interactively 'after 'icicle-save-to-history) + (ad-activate 'call-interactively)) + (dolist (fn icicle-inhibit-advice-functions) + (let ((info (memq fn icicle-advice-info-list))) + (when (and (fboundp fn) info) + (ad-set-advice-info fn info) + (when (ad-is-active fn) (ad-activate fn))))))) + (unless (eq icicle-guess-commands-in-path 'load) + (setq icicle-shell-command-candidates-cache ())) ; Reset - toggle Icy to update. + (message "Turning %s Icicle mode..." (if icicle-mode "ON" "OFF")) + (icicle-define-minibuffer-maps icicle-mode) + (run-hooks 'icicle-mode-hook) + (message "Turning %s Icicle mode...done" (if icicle-mode "ON" "OFF"))))) + +(unless (fboundp 'define-minor-mode) ; Emacs 20 ------------ + (defun icicle-mode (&optional arg) + "Icicle mode: Toggle minibuffer input completion and cycling. +Non-nil prefix ARG turns mode on if ARG > 0, else turns it off. +Icicle mode is a global minor mode. It binds keys in the minibuffer. + +The following top-level commands are also available in Icicle mode. +In many cases there are also `other-window' versions. + +`clear-option' (alias) - Set binary option(s) to nil +`icicle-add-buffer-candidate' - Add always-candidate buffer +`icicle-add-buffer-config' - To `icicle-buffer-configs' +`icicle-add-entry-to-saved-completion-set' - Add completion to a set +`icicle-add/update-saved-completion-set' - To + `icicle-saved-completion-sets' +`icicle-apply' - Apply function to alist items +`icicle-apropos' - `apropos', but shows matches +`icicle-apropos-command' - Enhanced `apropos-command' +`icicle-apropos-variable' - Enhanced `apropos-variable' +`icicle-apropos-zippy' - Show matching Zippy quotes +`icicle-bookmark' - Jump to a bookmark +`icicle-bookmark-bookmark-list' - Jump to a bookmark list +`icicle-bookmark-desktop' - Jump to a desktop bookmark +`icicle-bookmark-dired' - Jump to a Dired bookmark +`icicle-bookmark-file' - Jump to a file bookmark +`icicle-bookmark-gnus' - Jump to a Gnus bookmark +`icicle-bookmark-info' - Jump to an Info bookmark +`icicle-bookmark-local-file' - Jump to local-file bookmark +`icicle-bookmark-man' - Jump to a `man'-page bookmark +`icicle-bookmark-non-file' - Jump to a buffer bookmark +`icicle-bookmark-region' - Jump to a region bookmark +`icicle-bookmark-remote-file' - Jump to a remote file +`icicle-bookmark-specific-buffers' - Jump to a bookmarked buffer +`icicle-bookmark-specific-files' - Jump to a bookmarked file +`icicle-bookmark-this-buffer' - Jump to bookmark for this buf +`icicle-bookmark-url' - Jump to a URL bookmark +`icicle-bookmark-w3m' - Jump to a W3M (URL) bookmark +`icicle-buffer' - Switch to buffer +`icicle-buffer-config' - Pick `icicle-buffer' options +`icicle-buffer-list' - Choose a list of buffer names +`icicle-change-alternative-sort-order' - Choose an alternative sort +`icicle-change-sort-order' - Choose a sort order +`icicle-clear-current-history' - Clear current history entries +`icicle-clear-history' - Clear entries from a history +`icicle-color-theme' - Change color theme +`icicle-comint-command' - Reuse shell etc. command +`icicle-comint-dynamic-complete' - Text completion in shell +`icicle-comint-search' - Reuse shell etc. command +`icicle-command-abbrev' - Multi-command `M-x' + abbrevs +`icicle-compilation-search' - `icicle-search' and show hits +`icicle-complete-thesaurus-entry' - Complete word using thesaurus +`icicle-completing-yank' - `yank' using completion +`icicle-customize-face' - Multi-`customize-face' +`icicle-customize-icicles-group' - Customize options and faces +`icicle-delete-file' - Delete file/directory +`icicle-delete-window' - Delete window (`C-u': buffer) +`icicle-delete-windows' - Delete all windows for buffer +`icicle-dired' - Multi-command Dired +`icicle-doc' - Show doc for fn, var, or face +`icicle-doremi-candidate-width-factor+' - +/- candidate column width +`icicle-doremi-increment-max-candidates+' - +/- max number candidates +`icicle-doremi-increment-swank-prefix-length+' - +/- swank prefix +`icicle-doremi-increment-swank-timeout+' - +/- swank completion msec +`icicle-doremi-increment-variable+' - Increment var using Do Re Mi +`icicle-doremi-inter-candidates-min-spaces+' - +/- candidate spacing +`icicle-doremi-zoom-Completions+' - +/- *Completions* text size +`icicle-execute-extended-command' - Multi-command `M-x' +`icicle-execute-named-keyboard-macro' - Execute named keyboard macro +`icicle-face-list' - Choose a list of face names +`icicle-file-list' - Choose a list of file names +`icicle-file' - Visit file/directory +`icicle-find-file' - same: relative only +`icicle-find-file-absolute' - same: absolute only +`icicle-find-file-in-tags-table' - File in tags table +`icicle-find-first-tag' - Visit definition with tag +`icicle-find-tag' - Visit definition with tag +`icicle-font' - Change font of frame +`icicle-frame-bg' - Change background of frame +`icicle-frame-fg' - Change foreground of frame +`icicle-fundoc' - Show function description +`icicle-goto-global-marker' - Go to a global marker +`icicle-goto-marker' - Go to a marker in this buffer +`icicle-imenu*' - Navigate among Imenu entries +`icicle-increment-option' - Increment numeric option +`icicle-increment-variable' - Increment numeric variable +`icicle-Info-goto-node' - Multi-cmd `Info-goto-node' +`icicle-Info-index' - Multi-command `Info-index' +`icicle-Info-menu' - Multi-command `Info-menu' +`icicle-insert-buffer' - Multi-command `insert-buffer' +`icicle-insert-thesaurus-entry' - Insert thesaurus entry(s) +`icicle-keyword-list' - Choose a list of keywords +`icicle-kill-buffer' - Kill buffer +`icicle-locate-file' - Visit file(s) in a directory +`icicle-minibuffer-help' - Show Icicles minibuffer help +`icicle-mode' or `icy-mode' - Toggle Icicle mode +`icicle-next-S-TAB-completion-method' - Next S-TAB completion method +`icicle-next-TAB-completion-method' - Next TAB completion method +`icicle-occur' - Incremental `occur' +`icicle-other-window-or-frame' - Other window/frame or select +`icicle-plist' - Show symbols, property lists +`icicle-recent-file' - Open recently used file(s) +`icicle-recompute-shell-command-candidates' - Update from search path +`icicle-remove-buffer-candidate' - Remove always-candidate buf +`icicle-remove-buffer-config' - From `icicle-buffer-configs' +`icicle-remove-entry-from-saved-completion-set' - From a saved set +`icicle-remove-file-from-recentf-list' - Remove from recent files list +`icicle-remove-saved-completion-set' - From + `icicle-saved-completion-sets' +`icicle-reset-option-to-nil' - Set binary option(s) to nil +`icicle-save-string-to-variable' - Save text for use with `C-=' +`icicle-search' - Search with regexps & cycling +`icicle-search-bookmark' - Search bookmarks separately +`icicle-search-bookmark-list-bookmark' - Search bookmark lists +`icicle-search-bookmarks-together' - Search bookmarks together +`icicle-search-char-property' - Search for overlay/text props +`icicle-search-dired-bookmark' - Search Dired bookmarks +`icicle-search-dired-marked' - Search marked files in Dired +`icicle-search-file' - Search multiple files +`icicle-search-file-bookmark' - Search bookmarked files +`icicle-search-gnus-bookmark' - Search bookmarked Gnus msgs +`icicle-search-ibuffer-marked' - Search marked bufs in Ibuffer +`icicle-search-info-bookmark' - Search bookmarked Info nodes +`icicle-search-keywords' - Search with regexp keywords +`icicle-search-local-file-bookmark' - Search bookmarked local files +`icicle-search-man-bookmark' - Search bookmarked `man' pages +`icicle-search-non-file-bookmark' - Search bookmarked buffers +`icicle-search-overlay-property' - Search for overlay properties +`icicle-search-pages' - Search Emacs pages +`icicle-search-paragraphs' - Search Emacs paragraphs +`icicle-search-region-bookmark' - Search bookmarked regions +`icicle-search-remote-file-bookmark' - Search remote bookmarks +`icicle-search-sentences' - Search sentences as contexts +`icicle-search-text-property' - Search for faces etc. +`icicle-search-url-bookmark' - Search bookmarked URLs +`icicle-search-word' - Whole-word search +`icicle-select-bookmarked-region' - Select bookmarked regions +`icicle-select-frame' - Select a frame by name +`icicle-select-window' - Select window by buffer name +`icicle-send-bug-report' - Send Icicles bug report +`icicle-set-option-to-t' - Set binary option(s) to t +`icicle-toggle-~-for-home-dir' - Toggle using `~' for $HOME +`icicle-toggle-alternative-sorting' - Swap alternative sort +`icicle-toggle-angle-brackets' - Toggle using angle brackets +`icicle-toggle-C-for-actions' - Toggle using `C-' for actions +`icicle-toggle-case-sensitivity' - Toggle case sensitivity +`icicle-toggle-dot' - Toggle `.' matching newlines +`icicle-toggle-expand-to-common-match' - Toggle input ECM expansion +`icicle-toggle-hiding-common-match' - Toggle match in *Completions* +`icicle-toggle-highlight-all-current' - Toggle max search highlight +`icicle-toggle-highlight-historical-candidates' + - Toggle past-input highlight +`icicle-toggle-ignored-extensions' - Toggle ignored files +`icicle-toggle-ignored-space-prefix' - Toggle ignoring space prefix +`icicle-toggle-incremental-completion' - Toggle apropos icompletion +`icicle-toggle-option' - Toggle binary user option +`icicle-toggle-proxy-candidates' - Toggle proxy candidates +`icicle-toggle-regexp-quote' - Toggle regexp escaping +`icicle-toggle-search-cleanup' - Toggle search highlighting +`icicle-toggle-search-replace-common-match' - Toggle ECM replacement +`icicle-toggle-search-replace-whole' - Toggle replacing whole hit +`icicle-toggle-search-whole-word' - Toggle whole-word searching +`icicle-toggle-show-multi-completion' - Toggle multi-completions +`icicle-toggle-sorting' - Toggle sorting of completions +`icicle-toggle-transforming' - Toggle duplicate removal +`icicle-toggle-WYSIWYG-Completions' - Toggle WYSIWYG *Completions* +`icicle-vardoc' - Show variable description +`icicle-where-is' - `where-is' multi-command +`icicle-yank-maybe-completing' - `yank' maybe using completion +`toggle' (alias) - Toggle binary user option + +For more information, use `\\\\[icicle-minibuffer-help]' \ +when the minibuffer is active. + +Note: Depending on your platform, if you use Icicles in a text +terminal (that is, without a window system/manager), then you might +need to change some of the key bindings, if some of the default +bindings are not available to you." + (interactive "P") + (setq icicle-mode (if arg (> (prefix-numeric-value arg) 0) (not icicle-mode))) + (icicle-define-minibuffer-maps icicle-mode) + (cond (icicle-mode + ;; (when (interactive-p) + ;; (unless (or window-system (and (fboundp 'daemonp) (daemonp))) + ;; (with-output-to-temp-buffer "*Attention*" + ;; (princ "You are using Icicles in a text terminal (no window ") + ;; (princ "system/manager).\n\nIcicles makes use of many keys that are ") + ;; (princ "unavailable when running\nEmacs in a text terminal. You will ") + ;; (princ "want to rebind those keys.\n") + ;; (princ "See the Icicles doc, section Key Bindings.\n")) + ;; (message "Icicles uses keys that might not be suitable for a text terminal") + ;; (sit-for 5))) + (icicle-define-icicle-maps) + (icicle-bind-other-keymap-keys) + ;; This is not really necessary after the first time - no great loss. + (add-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup) + (add-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection) + (add-hook 'minibuffer-exit-hook 'icicle-restore-region-face) + (add-hook 'minibuffer-exit-hook 'icicle-unhighlight-lighter) + (add-hook 'icicle-post-command-hook 'icicle-activate-mark 'append) + (add-hook 'completion-setup-hook 'icicle-set-calling-cmd 'append) + (when icicle-customize-save-flag + (add-hook 'kill-emacs-hook 'icicle-command-abbrev-save)) + (add-hook 'comint-mode-hook 'icicle-comint-hook-fn) + (add-hook 'compilation-mode-hook 'icicle-compilation-hook-fn) + (add-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn) + (add-hook 'temp-buffer-show-hook 'icicle-fit-completions-window) + (icicle-redefine-std-completion-fns) + (icicle-redefine-standard-commands) + (icicle-redefine-standard-options) + (if icicle-menu-items-to-history-flag + (add-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history) + (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)) + (dolist (fn icicle-inhibit-advice-functions) + (when (and (fboundp fn) (ad-is-active fn)) + (push (cons fn (ad-copy-advice-info fn)) icicle-advice-info-list) + (ad-deactivate fn))) + (run-hooks 'icicle-mode-hook) + (message "Icicle mode is now ON")) + (t + (makunbound 'icicle-mode-map) + (icicle-restore-other-keymap-keys) + (remove-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup) + (remove-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection) + (remove-hook 'minibuffer-exit-hook 'icicle-restore-region-face) + (remove-hook 'icicle-post-command-hook 'icicle-activate-mark) + ;; The pre- and post-command hooks are local to the minibuffer, + ;; So they are added in `icicle-minibuffer-setup', not here. + ;; Nevertheless, they are removed here when Icicle mode is exited. + (remove-hook 'pre-command-hook 'icicle-top-level-prep) + (remove-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook t) + (remove-hook 'post-command-hook 'icicle-run-icicle-post-command-hook t) + (remove-hook 'completion-setup-hook 'icicle-set-calling-cmd) + (remove-hook 'kill-emacs-hook 'icicle-command-abbrev-save) + (remove-hook 'comint-mode-hook 'icicle-comint-hook-fn) + (remove-hook 'compilation-mode-hook 'icicle-compilation-hook-fn) + (remove-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn) + (remove-hook 'temp-buffer-show-hook 'icicle-fit-completions-window) + (icicle-restore-std-completion-fns) + (icicle-restore-standard-commands) + (icicle-restore-standard-options) + (unless (eq icicle-guess-commands-in-path 'load) + (setq icicle-shell-command-candidates-cache ())) ; Reset - toggle Icy to update. + (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history) + (dolist (fn icicle-inhibit-advice-functions) + (let ((info (memq fn icicle-advice-info-list))) + (when (and (fboundp fn) info) + (ad-set-advice-info fn info) + (when (ad-is-active fn) (ad-activate fn))))) + (run-hooks 'icicle-mode-hook) + (message "Icicle mode is now OFF"))) + + (add-to-list 'minor-mode-alist '(icicle-mode " Icy")))) + +(defun icicle-add-menu-item-to-cmd-history () + "Add `this-command' to command history, if it is a menu item. +Menu items that are not associated with a command symbol are ignored. +Used on `pre-command-hook'." + (condition-case nil ; Just in case, since this is on `pre-command-hook'. + (when (and (> (length (this-command-keys-vector)) 0) + (equal '(menu-bar) (elt (this-command-keys-vector) 0)) + ;; Exclude uninterned symbols such as `menu-function-356'. + (symbolp this-command) (or (< emacs-major-version 21) (intern-soft this-command))) + (pushnew (symbol-name this-command) extended-command-history)) + (error nil))) + +(defun icicle-top-level-prep () + "Do top-level stuff. Used in `pre-command-hook'." + ;; Reset `icicle-candidates-alist' to (); save top-level command. + (when (= 0 (recursion-depth)) + (setq icicle-last-top-level-command this-command + icicle-candidates-alist ()))) + +(defun icicle-define-icicle-maps () + "Define `icicle-mode-map' and `icicle-menu-map'." + (setq icicle-mode-map (make-sparse-keymap)) ; Recreate it each time, to capture latest bindings. + + ;; Define Icicles menu-bar menu. Create it only once. Sacrifice latest bindings for speed. + (unless icicle-menu-map + (setq icicle-menu-map (make-sparse-keymap "Icicles")) + (define-key icicle-menu-map [icicle-mode] '(menu-item "Turn Off Icicle Mode" icicle-mode)) + (define-key icicle-menu-map [icicle-abort] + '(menu-item "Cancel Minibuffer" icicle-abort-recursive-edit + :enable (active-minibuffer-window))) + (define-key icicle-menu-map [icicle-report-bug] + '(menu-item "Send Bug Report" icicle-send-bug-report)) + (define-key icicle-menu-map [icicle-customize-icicles-group] + '(menu-item "Customize Icicles" icicle-customize-icicles-group)) + (define-key icicle-menu-map [icicle-help] + '(menu-item "Help" icicle-minibuffer-help + :help "Display help for minibuffer input and completion" :keys "C-?")) + (define-key icicle-menu-map [icicle-separator-last] '("--")) + + (unless icicle-touche-pas-aux-menus-flag ; Use Dired > Multiple or Operate menu. + (defvar icicle-dired-multiple-menu-map (make-sparse-keymap) + "Icicles submenu for `Dired' > `Multiple' (or `Operate') menu.") + (if (boundp 'diredp-menu-bar-operate-menu) ; Defined in `dired+.el'. + (define-key diredp-menu-bar-operate-menu [icicles] + (list 'menu-item "Icicles" icicle-dired-multiple-menu-map :visible 'icicle-mode)) + (define-key dired-mode-map [menu-bar operate icicles] + (list 'menu-item "Icicles" icicle-dired-multiple-menu-map :visible 'icicle-mode))) + (define-key icicle-dired-multiple-menu-map [icicle-search-dired-marked] + '(menu-item "Search (and Replace)..." icicle-search-dired-marked + :visible icicle-mode :enable (eq major-mode 'dired-mode))) + (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked-more] + '(menu-item "Save as More Completion Candidates" icicle-dired-save-marked-more + :visible icicle-mode :enable (eq major-mode 'dired-mode))) + (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked] + '(menu-item "Save as Completion Candidates" icicle-dired-save-marked + :visible icicle-mode :enable (eq major-mode 'dired-mode))) + (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked-as-project] + '(menu-item "Save as Project" icicle-dired-save-marked-as-project + :visible icicle-mode :enable (eq major-mode 'dired-mode)))) + + (unless icicle-touche-pas-aux-menus-flag ; Use Dired > Multiple or Operate menu. + (defvar icicle-dired-dir-menu-map (make-sparse-keymap) + "Icicles submenu for `Dired' > `Dir' (or `Subdir') menu.") + (if (boundp 'diredp-menu-bar-subdir-menu) ; Defined in `dired+.el'. + (define-key diredp-menu-bar-subdir-menu [icicles] + (list 'menu-item "Icicles" icicle-dired-dir-menu-map :visible 'icicle-mode)) + (define-key dired-mode-map [menu-bar subdir icicles] + (list 'menu-item "Icicles" icicle-dired-dir-menu-map :visible 'icicle-mode))) + (define-key icicle-dired-dir-menu-map [icicle-dired-saved-file-candidates-other-window] + '(menu-item "Open Dired for Chosen Files..." + icicle-dired-saved-file-candidates-other-window + :visible icicle-mode + :enable (and icicle-saved-completion-candidates (eq major-mode 'dired-mode)))) + (define-key icicle-dired-dir-menu-map [icicle-dired-project-other-window] + '(menu-item "Open Dired for Project..." icicle-dired-project-other-window + :visible icicle-mode + :enable (and icicle-saved-completion-sets (eq major-mode 'dired-mode))))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'Info-mode-menu)) ; Use Info menu, if available. + (defvar icicle-info-menu-map (make-sparse-keymap) + "Icicles submenu for `Info' menu.") + (define-key Info-mode-menu [icicles] + (list 'menu-item "Icicles" icicle-info-menu-map :visible 'icicle-mode)) + (when (fboundp 'icicle-Info-virtual-book) + (define-key icicle-info-menu-map [icicle-Info-virtual-book] + '(menu-item "Virtual Book" icicle-Info-virtual-book :visible icicle-mode + :enable (eq major-mode 'Info-mode)))) + (define-key icicle-info-menu-map [icicle-Info-goto-node] + '(menu-item "+ Go to Node..." icicle-Info-goto-node :visible icicle-mode + :enable (eq major-mode 'Info-mode) :keys "g")) + (define-key icicle-info-menu-map [icicle-Info-menu] + '(menu-item "+ Go to Menu Node..." icicle-Info-menu :visible icicle-mode + :enable (eq major-mode 'Info-mode) :keys "m")) + (define-key icicle-info-menu-map [icicle-Info-index] + '(menu-item "+ Look Up in Index..." icicle-Info-index :visible icicle-mode + :enable (eq major-mode 'Info-mode) :keys "i"))) + (t + (when (fboundp 'icicle-Info-virtual-book) + (define-key icicle-menu-map [icicle-Info-virtual-book] + '(menu-item "Virtual Book" icicle-Info-virtual-book + :enable (eq major-mode 'Info-mode)))) + (define-key icicle-menu-map [icicle-Info-goto-node] + '(menu-item "+ Go to Node..." icicle-Info-goto-node + :enable (eq major-mode 'Info-mode))) + (define-key icicle-menu-map [icicle-Info-menu] + '(menu-item "+ Go to Menu Node..." icicle-Info-menu + :enable (eq major-mode 'Info-mode))) + (define-key icicle-menu-map [icicle-Info-index] + '(menu-item "+ Look Up in Index..." icicle-Info-index + :enable (eq major-mode 'Info-mode))) + (define-key icicle-menu-map [icicle-separator-Info] + '(menu-item "--" icicle-separator-Info :visible icicle-mode + :enable (eq major-mode 'Info-mode))))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-frames-menu)) ; Defined in `menu-bar+.el'. + (defvar icicle-frames-menu-map (make-sparse-keymap) + "Icicles submenu for `Frames' menu.") + (define-key menu-bar-frames-menu [icicles] + (list 'menu-item "Icicles" icicle-frames-menu-map :visible 'icicle-mode)) + (define-key icicle-frames-menu-map [icicle-font] + '(menu-item "+ Change Font" icicle-font :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-frames-menu-map [icicle-frame-fg] + '(menu-item "+ Change Foreground..." icicle-frame-fg :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-frames-menu-map [icicle-frame-bg] + '(menu-item "+ Change Background..." icicle-frame-bg :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (t + (define-key icicle-menu-map [icicle-font] + '(menu-item "+ Change Font of Frame..." icicle-font + :enable (and icicle-mode + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-frame-fg] + '(menu-item "+ Change Foreground of Frame..." icicle-frame-fg + :enable (and icicle-mode + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-frame-bg] + '(menu-item "+ Change Background of Frame..." icicle-frame-bg + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-separator-frame] '("--")))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-describe-menu)) ; Use Describe menu, if available. + (defvar icicle-describe-menu-map (make-sparse-keymap) + "Icicles submenu for `Describe' menu.") + (define-key menu-bar-describe-menu [icicles] + (list 'menu-item "Icicles" icicle-describe-menu-map :visible 'icicle-mode)) + (define-key icicle-describe-menu-map [icicle-plist] + '(menu-item "+ Symbol with Property List..." icicle-plist :visible icicle-mode)) + (define-key icicle-describe-menu-map [icicle-doc] + '(menu-item "+ Doc of Fun, Var, or Face..." icicle-doc :visible icicle-mode)) + (define-key icicle-describe-menu-map [icicle-fundoc] + '(menu-item "+ Function with Name, Doc..." icicle-fundoc :visible icicle-mode)) + (define-key icicle-describe-menu-map [icicle-vardoc] + '(menu-item "+ Variable with Name, Doc..." icicle-vardoc :visible icicle-mode)) + (define-key icicle-describe-menu-map [icicle-describe-option-of-type] + '(menu-item "+ Option of Type..." icicle-describe-option-of-type + :visible icicle-mode)) + (define-key icicle-describe-menu-map [icicle-where-is] + '(menu-item "+ Where Is..." icicle-where-is :visible icicle-mode))) + (t + (define-key icicle-menu-map [icicle-plist] + '(menu-item "+ Symbol with Property List..." icicle-plist)) + (define-key icicle-menu-map [icicle-doc] + '(menu-item "+ Doc of Fun, Var, or Face..." icicle-doc)) + (define-key icicle-menu-map [icicle-fundoc] + '(menu-item "+ Describe Function with Name, Doc..." icicle-fundoc)) + (define-key icicle-menu-map [icicle-vardoc] + '(menu-item "+ Describe Variable with Name, Doc..." icicle-vardoc)) + (define-key icicle-menu-map [icicle-describe-option-of-type] + '(menu-item "+ Option of Type..." icicle-describe-option-of-type)) + (define-key icicle-menu-map [icicle-where-is] + '(menu-item "+ Where Is..." icicle-where-is)) + (define-key icicle-menu-map [icicle-separator-doc] '("--")))) + + (define-key icicle-menu-map [icicle-apply] + '(menu-item "+ Apply Function to Alist Items..." icicle-apply)) + (define-key icicle-menu-map [icicle-save-string-to-variable] + '(menu-item "Save String to Variable..." icicle-save-string-to-variable)) + (define-key icicle-menu-map [icicle-color-theme] + '(menu-item "+ Choose Color Theme..." icicle-color-theme + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-remove-saved-completion-set] + '(menu-item "+ Remove Saved Candidate Set..." icicle-remove-saved-completion-set + :enable icicle-saved-completion-sets)) + (define-key icicle-menu-map [icicle-add/update-saved-completion-set] + '(menu-item "Add/Update Saved Candidate Set..." icicle-add/update-saved-completion-set)) + (when (fboundp 'icicle-kmacro) + (define-key icicle-menu-map [icicle-kmacro] + '(menu-item "+ Execute Nth Keyboard Macro..." icicle-kmacro + :enable (or (kmacro-ring-head) kmacro-ring)))) + (define-key icicle-menu-map [icicle-execute-named-keyboard-macro] + '(menu-item "+ Execute Named Keyboard Macro..." icicle-execute-named-keyboard-macro)) + (define-key icicle-menu-map [icicle-separator-misc] '("--")) + (define-key icicle-menu-map [icicle-imenu] + '(menu-item "+ Imenu..." icicle-imenu + :enable imenu-generic-expression)) + (define-key icicle-menu-map [icicle-goto-global-marker] + '(menu-item "+ Go To Global Marker..." icicle-goto-global-marker + :enable (consp (icicle-markers global-mark-ring)) :keys "C-- C-x C-SPC")) + (define-key icicle-menu-map [icicle-goto-marker] + '(menu-item "+ Go To Marker..." icicle-goto-marker + :enable (mark t) :keys "C-- C-SPC")) + (define-key icicle-menu-map [icicle-separator-goto] '("--")) + (define-key icicle-menu-map [icicle-search-bookmarks-together] + '(menu-item "+ Search Bookmarks Together..." icicle-search-bookmarks-together + :enable (featurep 'bookmark+) :keys "C-u C-`")) + (define-key icicle-menu-map [icicle-search-bookmark] + '(menu-item "+ Search Bookmarks Separately..." icicle-search-bookmark + :enable (featurep 'bookmark+))) + (define-key icicle-menu-map [icicle-select-bookmarked-region] + '(menu-item "+ Select Bookmarked Region..." icicle-select-bookmarked-region + :enable (featurep 'bookmark+) :keys "C-u C-x C-x")) + (define-key icicle-menu-map [icicle-separator-region] '("--")) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-apropos-menu)) ; Use Apropos menu, if available. + (defvar icicle-apropos-menu-map (make-sparse-keymap) + "Icicles submenu for `Apropos' menu.") + (define-key menu-bar-apropos-menu [icicles] + (list 'menu-item "Icicles" icicle-apropos-menu-map :visible 'icicle-mode)) + (define-key icicle-apropos-menu-map [icicle-apropos-zippy] + '(menu-item "Zippy..." icicle-apropos-zippy :visible icicle-mode)) + (cond ((fboundp 'apropos-option) + (define-key icicle-apropos-menu-map [icicle-apropos] + '(menu-item "Symbols..." icicle-apropos :visible icicle-mode)) + (define-key icicle-apropos-menu-map [icicle-apropos-function] + '(menu-item "Functions..." icicle-apropos-function :visible icicle-mode)) + (define-key icicle-apropos-menu-map [icicle-apropos-variable] + '(menu-item "Variables..." icicle-apropos-variable :visible icicle-mode)) + (define-key icicle-apropos-menu-map [icicle-apropos-option] + '(menu-item "Options..." icicle-apropos-option :visible icicle-mode)) + (define-key icicle-apropos-menu-map [icicle-apropos-command] + '(menu-item "Commands..." icicle-apropos-command :visible icicle-mode))) + (t + (define-key icicle-apropos-menu-map [icicle-apropos-variable] + '(menu-item "Variables..." icicle-apropos-variable + :visible icicle-mode)))) + (define-key icicle-apropos-menu-map [icicle-apropos-command] + '(menu-item "Commands..." icicle-apropos-command :visible icicle-mode))) + (t + (define-key icicle-menu-map [icicle-apropos-zippy] + '(menu-item "Apropos Zippy..." icicle-apropos-zippy)) + (cond ((fboundp 'apropos-option) + (define-key icicle-menu-map [icicle-apropos] + '(menu-item "Apropos..." icicle-apropos)) + (define-key icicle-menu-map [icicle-apropos-function] + '(menu-item "Apropos Functions..." icicle-apropos-function)) + (define-key icicle-menu-map [icicle-apropos-variable] + '(menu-item "Apropos Variables..." icicle-apropos-variable)) + (define-key icicle-menu-map [icicle-apropos-option] + '(menu-item "Apropos Options..." icicle-apropos-option)) + (define-key icicle-menu-map [icicle-apropos-command] + '(menu-item "Apropos Commands..." icicle-apropos-command))) + (t + (define-key icicle-menu-map [icicle-apropos-variable] + '(menu-item "Apropos Variables..." icicle-apropos-variable)) + (define-key icicle-menu-map [icicle-apropos-command] + '(menu-item "Apropos Commands..." icicle-apropos-command)))) + (define-key icicle-menu-map [icicle-separator-apropos] '("--")))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-options-menu)) ; Use Options menu, if available. + (defvar icicle-options-menu-map (make-sparse-keymap) + "Icicles submenu for `Options' menu.") + (define-key menu-bar-options-menu [icicles] + (list 'menu-item "Icicles" icicle-options-menu-map :visible 'icicle-mode)) + (define-key icicle-options-menu-map [icicle-set-option-to-t] + '(menu-item "+ Turn On Any Option..." icicle-set-option-to-t + :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-reset-option-to-nil] + '(menu-item "+ Turn Off Any Option..." icicle-reset-option-to-nil + :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-toggle-option] + '(menu-item "+ Toggle Any Option..." icicle-toggle-option :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-separator-options-general] '("--")) + (define-key icicle-options-menu-map [icicle-toggle-search-cleanup] + '(menu-item "Toggle Removal of Search Highlighting" + icicle-toggle-search-cleanup :visible icicle-mode :keys "C-.")) + (define-key icicle-options-menu-map [icicle-toggle-search-replace-common-match] + '(menu-item "Toggle Replacing Longest Common Match" + icicle-toggle-search-replace-common-match :visible icicle-mode + :enable icicle-searching-p :keys "M-;")) + (define-key icicle-options-menu-map [icicle-toggle-search-replace-whole] + '(menu-item "Toggle Replacing Whole Search Hit" + icicle-toggle-search-replace-whole :visible icicle-mode + :enable icicle-searching-p :keys "M-_")) + (define-key icicle-options-menu-map [icicle-toggle-highlight-all-current] + '(menu-item "Toggle All-Current Search Highlighting" + icicle-toggle-highlight-all-current :visible icicle-mode + :enable icicle-searching-p :keys "C-^")) + (define-key icicle-options-menu-map [icicle-separator-options-search] '("--")) + (define-key icicle-options-menu-map [icicle-regexp-quote-input] + '(menu-item "Regexp-Quote Input" icicle-regexp-quote-input + :visible icicle-mode :keys "C-M-;")) + (define-key icicle-options-menu-map [icicle-toggle-regexp-quote] + '(menu-item "Toggle Escaping Special Chars" icicle-toggle-regexp-quote + :visible icicle-mode :keys "C-`")) + (define-key icicle-options-menu-map [icicle-toggle-dot] + '(menu-item "Toggle `.' Matching Newlines Too" icicle-toggle-dot + :visible icicle-mode :keys "C-M-.")) + (define-key icicle-options-menu-map [icicle-toggle-incremental-completion] + '(menu-item "Toggle Incremental Completion" + icicle-toggle-incremental-completion :visible icicle-mode :keys "C-#")) + (define-key icicle-options-menu-map [icicle-toggle-show-multi-completion] + '(menu-item "Toggle Showing Multi-Completions" + icicle-toggle-show-multi-completion :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-toggle-hiding-common-match] + '(menu-item "Toggle Hiding Common Match" + icicle-toggle-hiding-common-match :visible icicle-mode :keys "C-x .")) + (define-key icicle-options-menu-map [icicle-toggle-expand-to-common-match] + '(menu-item "Toggle Longest Common Match" + icicle-toggle-expand-to-common-match :visible icicle-mode :keys "C-;")) + (define-key icicle-options-menu-map [icicle-toggle-ignored-space-prefix] + '(menu-item "Toggle Ignoring Space Prefix" icicle-toggle-ignored-space-prefix + :visible icicle-mode :keys "M-_")) + (define-key icicle-options-menu-map [icicle-toggle-ignored-extensions] + '(menu-item "Toggle Ignored File Extensions" icicle-toggle-ignored-extensions + :visible icicle-mode :keys "C-.")) + (define-key icicle-options-menu-map [icicle-toggle-remote-file-testing] + '(menu-item "Toggle Remote File Handling" icicle-toggle-remote-file-testing + :visible icicle-mode :enable (not icicle-searching-p) :keys "C-^")) + (define-key icicle-options-menu-map [icicle-toggle-angle-brackets] + '(menu-item "Toggle Angle Brackets" icicle-toggle-angle-brackets + :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-toggle-highlight-historical-candidates] + '(menu-item "Toggle Highlighting Past Inputs" + icicle-toggle-highlight-historical-candidates :visible icicle-mode :keys "C-pause")) + (define-key icicle-options-menu-map [icicle-toggle-case-sensitivity] + '(menu-item "Toggle Case Sensitivity" icicle-toggle-case-sensitivity + :visible icicle-mode :keys "C-A")) + (define-key icicle-options-menu-map [icicle-toggle-proxy-candidates] + '(menu-item "Toggle Including Proxy Candidates" icicle-toggle-proxy-candidates + :visible icicle-mode :keys "C-M-_")) + (define-key icicle-options-menu-map [icicle-toggle-transforming] + '(menu-item "Toggle Duplicate Removal" icicle-toggle-transforming + :visible icicle-mode :keys "C-$")) + (define-key icicle-options-menu-map [icicle-toggle-C-for-actions] + '(menu-item "Toggle Using `C-' for Actions" icicle-toggle-C-for-actions + :visible icicle-mode :keys "M-g")) + (define-key icicle-options-menu-map [icicle-toggle-~-for-home-dir] + '(menu-item "Toggle Using `~' for $HOME" icicle-toggle-~-for-home-dir + :visible icicle-mode :keys "M-~")) + (define-key icicle-options-menu-map [icicle-toggle-WYSIWYG-Completions] + '(menu-item "Toggle WYSIWYG For *Completions*" icicle-toggle-WYSIWYG-Completions + :visible icicle-mode)) + (define-key icicle-options-menu-map [icicle-next-TAB-completion-method] + '(menu-item "Next `TAB' Completion Method" + icicle-next-TAB-completion-method :visible icicle-mode :keys "C-(")) + (define-key icicle-options-menu-map [icicle-next-S-TAB-completion-method] + '(menu-item "Next `S-TAB' Completion Method" icicle-next-S-TAB-completion-method + :visible icicle-mode :keys "M-(")) + (define-key icicle-options-menu-map [icicle-separator-options-sort] '("--")) + (define-key icicle-options-menu-map [icicle-toggle-alternative-sorting] + '(menu-item "Swap Alternative Sort" icicle-toggle-alternative-sorting + :visible icicle-mode :keys "C-M-,")) + (define-key icicle-options-menu-map [icicle-change-alternative-sort-order] + '(menu-item "Change Alternative Sort Order" + icicle-change-alternative-sort-order :visible icicle-mode :keys "M-,")) + (define-key icicle-options-menu-map [icicle-change-sort-order] + '(menu-item "Change Sort Order" icicle-change-sort-order :visible icicle-mode + :enable (not icicle-inhibit-sort-p) :keys "C-,")) + (when (fboundp 'doremi) + (define-key icicle-options-menu-map [icicle-separator-options-doremi] + '(menu-item "--" nil :visible (or (get-buffer-window "*Completions*" 'visible) + (eq icicle-current-TAB-method 'swank) + (active-minibuffer-window)))) + (when (fboundp 'text-scale-increase) ; Emacs 23+. + (define-key icicle-options-menu-map [icicle-doremi-zoom-Completions+] + '(menu-item "*Completions* Zoom Factor - Do Re Mi" + icicle-doremi-zoom-Completions+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x -"))) + (define-key icicle-options-menu-map [icicle-doremi-inter-candidates-min-spaces+] + '(menu-item "Inter-Candidate Spacing - Do Re Mi" + icicle-doremi-inter-candidates-min-spaces+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x |")) + (define-key icicle-options-menu-map [icicle-doremi-candidate-width-factor+] + '(menu-item "Candidate Column Width - Do Re Mi" + icicle-doremi-candidate-width-factor+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x w")) + (define-key icicle-options-menu-map [icicle-doremi-increment-swank-prefix-length+] + '(menu-item "Swank Min Match Chars - Do Re Mi" + icicle-doremi-increment-swank-prefix-length+ + :visible (and icicle-mode (eq icicle-current-TAB-method 'swank)) :keys "C-x 2")) + (define-key icicle-options-menu-map [icicle-doremi-increment-swank-timeout+] + '(menu-item "Swank Timeout - Do Re Mi" + icicle-doremi-increment-swank-timeout+ + :visible (and icicle-mode (eq icicle-current-TAB-method 'swank)) :keys "C-x 1")) + (define-key icicle-options-menu-map [icicle-doremi-increment-max-candidates+] + '(menu-item "Max # of Completions - Do Re Mi" + icicle-doremi-increment-max-candidates+ + :visible (and icicle-mode (active-minibuffer-window)) :keys "C-x #")))) + (t + (define-key icicle-menu-map [icicle-set-option-to-t] + '(menu-item "+ Turn On Any Option..." icicle-set-option-to-t)) + (define-key icicle-menu-map [icicle-reset-option-to-nil] + '(menu-item "+ Turn Off Any Option..." icicle-reset-option-to-nil)) + (define-key icicle-menu-map [icicle-toggle-option] + '(menu-item "+ Toggle Any Option..." icicle-toggle-option)) + (define-key icicle-menu-map [icicle-toggle-C-for-actions] + '(menu-item "Toggle Using `C-' for Actions" icicle-toggle-C-for-actions :keys "M-g")) + (define-key icicle-menu-map [icicle-toggle-~-for-home-dir] + '(menu-item "Toggle Using `~' for $HOME" icicle-toggle-~-for-home-dir :keys "M-~")) + (define-key icicle-menu-map [icicle-next-TAB-completion-method] + '(menu-item "Next `TAB' Completion Method" icicle-next-TAB-completion-method + :keys "C-(")) + (define-key icicle-menu-map [icicle-next-S-TAB-completion-method] + '(menu-item "Next `S-TAB' Completion Method" icicle-next-S-TAB-completion-method + :keys "M-(")) + (define-key icicle-menu-map [icicle-toggle-WYSIWYG-Completions] + '(menu-item "Toggle WYSIWYG For *Completions*" icicle-toggle-WYSIWYG-Completions)) + (define-key icicle-menu-map [icicle-toggle-search-cleanup] + '(menu-item "Toggle Removal of Search Highlighting" icicle-toggle-search-cleanup + :keys "C-.")) + (define-key icicle-menu-map [icicle-toggle-search-replace-common-match] + '(menu-item "Toggle Replacing Longest Common Match" + icicle-toggle-search-replace-common-match :enable icicle-searching-p :keys "M-;")) + (define-key icicle-menu-map [icicle-toggle-search-replace-whole] + '(menu-item "Toggle Replacing Whole Search Hit" icicle-toggle-search-replace-whole + :enable icicle-searching-p :keys "M-_")) + (define-key icicle-menu-map [icicle-toggle-highlight-all-current] + '(menu-item "Toggle All-Current Search Highlighting" + icicle-toggle-highlight-all-current :enable icicle-searching-p :keys "C-^")) + (define-key icicle-menu-map [icicle-regexp-quote-input] + '(menu-item "Regexp-Quote Input" icicle-regexp-quote-input :keys "C-M-;")) + (define-key icicle-menu-map [icicle-toggle-regexp-quote] + '(menu-item "Toggle Escaping Special Chars" icicle-toggle-regexp-quote :keys "C-`")) + (define-key icicle-menu-map [icicle-toggle-dot] + '(menu-item "Toggle `.' Matching Newlines Too" icicle-toggle-dot :keys "C-M-.")) + (define-key icicle-menu-map [icicle-toggle-incremental-completion] + '(menu-item "Toggle Incremental Completion" icicle-toggle-incremental-completion + :keys "C-#")) + (define-key icicle-menu-map [icicle-toggle-show-multi-completion] + '(menu-item "Toggle Showing Multi-Completions" icicle-toggle-show-multi-completion)) + (define-key icicle-menu-map [icicle-toggle-hiding-common-match] + '(menu-item "Toggle Hiding Common Match" icicle-toggle-hiding-common-match + :keys "C-x .")) + (define-key icicle-menu-map [icicle-toggle-expand-to-common-match] + '(menu-item "Toggle Longest Common Match" icicle-toggle-expand-to-common-match + :keys "C-;")) + (define-key icicle-menu-map [icicle-toggle-ignored-space-prefix] + '(menu-item "Toggle Ignoring Space Prefix" icicle-toggle-ignored-space-prefix + :keys "M-_")) + (define-key icicle-menu-map [icicle-toggle-ignored-extensions] + '(menu-item "Toggle Ignored File Extensions" icicle-toggle-ignored-extensions + :keys "C-.")) + (define-key icicle-menu-map [icicle-toggle-remote-file-testing] + '(menu-item "Toggle Remote File Handling" icicle-toggle-remote-file-testing + :enable (not icicle-searching-p) :keys "C-^")) + (define-key icicle-menu-map [icicle-toggle-angle-brackets] + '(menu-item "Toggle Angle Brackets" icicle-toggle-angle-brackets)) + (define-key icicle-menu-map [icicle-toggle-highlight-historical-candidates] + '(menu-item "Toggle Highlighting Past Inputs" + icicle-toggle-highlight-historical-candidates :keys "C-pause")) + (define-key icicle-menu-map [icicle-toggle-case-sensitivity] + '(menu-item "Toggle Case Sensitivity" icicle-toggle-case-sensitivity :keys "C-A")) + (define-key icicle-menu-map [icicle-toggle-proxy-candidates] + '(menu-item "Toggle Including Proxy Candidates" icicle-toggle-proxy-candidates + :keys "C-M-_")) + (define-key icicle-menu-map [icicle-toggle-transforming] + '(menu-item "Toggle Duplicate Removal" icicle-toggle-transforming :keys "C-$")) + (define-key icicle-menu-map [icicle-toggle-alternative-sorting] + '(menu-item "Swap Alternative Sort" icicle-toggle-alternative-sorting :keys "C-M-,")) + (define-key icicle-menu-map [icicle-change-alternative-sort-order] + '(menu-item "Change Alternative Sort Order" icicle-change-alternative-sort-order + :keys "M-,")) + (define-key icicle-menu-map [icicle-change-sort-order] + '(menu-item "Change Sort Order" icicle-change-sort-order + :enable (not icicle-inhibit-sort-p) :keys "C-,")) + (when (fboundp 'doremi) + (when (fboundp 'text-scale-increase) ; Emacs 23+. + (define-key icicle-menu-map [icicle-doremi-zoom-Completions+] + '(menu-item "*Completions* Zoom Factor - Do Re Mi" + icicle-doremi-zoom-Completions+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x -"))) + (define-key icicle-menu-map [icicle-doremi-inter-candidates-min-spaces+] + '(menu-item "Inter-Candidate Spacing - Do Re Mi" + icicle-doremi-inter-candidates-min-spaces+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x |")) + (define-key icicle-menu-map [icicle-doremi-candidate-width-factor+] + '(menu-item "Candidate Column Width - Do Re Mi" + icicle-doremi-candidate-width-factor+ + :visible (and icicle-mode (get-buffer-window "*Completions*" 'visible)) + :keys "C-x w")) + (define-key icicle-menu-map [icicle-doremi-increment-swank-prefix-length+] + '(menu-item "Swank Min Match Chars - Do Re Mi" + icicle-doremi-increment-swank-prefix-length+ + :visible (and icicle-mode (eq icicle-current-TAB-method 'swank)) :keys "C-x 2")) + (define-key icicle-menu-map [icicle-doremi-increment-swank-timeout+] + '(menu-item "Swank Timeout - Do Re Mi" + icicle-doremi-increment-swank-timeout+ + :visible (and icicle-mode (eq icicle-current-TAB-method 'swank)) :keys "C-x 1")) + (define-key icicle-menu-map [icicle-doremi-increment-max-candidates+] + '(menu-item "Max # of Completions - Do Re Mi" + icicle-doremi-increment-max-candidates+ + :visible (and icicle-mode (active-minibuffer-window)) :keys "C-x #"))) + (define-key icicle-menu-map [icicle-separator-toggle] '("--")))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-custom-menu)) ; Use Customize menu, if available. + (defvar icicle-custom-menu-map (make-sparse-keymap) + "Icicles submenu for `Customize' menu.") + (define-key menu-bar-custom-menu [icicles] + (list 'menu-item "Icicles" icicle-custom-menu-map :visible 'icicle-mode)) + (define-key icicle-custom-menu-map [icicle-customize-apropos-groups] + '(menu-item "Groups Matching Regexp..." icicle-customize-apropos-groups + :visible icicle-mode)) + (define-key icicle-custom-menu-map [icicle-customize-apropos-faces] + '(menu-item "Faces Matching Regexp..." icicle-customize-apropos-faces + :visible icicle-mode)) + (define-key icicle-custom-menu-map [icicle-customize-face] + '(menu-item "+ Face..." icicle-customize-face :visible icicle-mode)) + (define-key icicle-custom-menu-map [icicle-customize-apropos-options] + '(menu-item "Options Matching Regexp..." icicle-customize-apropos-options + :visible icicle-mode)) + (define-key icicle-custom-menu-map [icicle-customize-apropos] + '(menu-item "Settings Matching Regexp..." icicle-customize-apropos + :visible icicle-mode))) + (t + (define-key icicle-menu-map [icicle-separator-customize] '("--")) + (define-key icicle-menu-map [icicle-customize-apropos-groups] + '(menu-item "Groups Matching Regexp..." icicle-customize-apropos-groups)) + (define-key icicle-menu-map [icicle-customize-apropos-faces] + '(menu-item "Faces Matching Regexp..." icicle-customize-apropos-faces)) + (define-key icicle-menu-map [icicle-customize-face] + '(menu-item "+ Face..." icicle-customize-face)) + (define-key icicle-menu-map [icicle-customize-apropos-options] + '(menu-item "Options Matching Regexp..." icicle-customize-apropos-options)) + (define-key icicle-menu-map [icicle-customize-apropos] + '(menu-item "Settings Matching Regexp..." icicle-customize-apropos)))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-edit-menu)) ; Use Edit menu, if available. + (defvar icicle-edit-menu-map (make-sparse-keymap) + "Icicles submenu for `Edit' menu.") + (define-key menu-bar-edit-menu [icicles] + (list 'menu-item "Icicles" icicle-edit-menu-map :visible 'icicle-mode)) + (define-key icicle-edit-menu-map [icicle-complete-thesaurus-entry] + '(menu-item "Complete with Thesaurus..." icicle-complete-thesaurus-entry + :visible icicle-mode + :enable (and (not buffer-read-only) (boundp 'synonyms-obarray)))) + (define-key icicle-edit-menu-map [icicle-insert-thesaurus-entry] + '(menu-item "+ Insert Thesaurus Entry..." icicle-insert-thesaurus-entry + :visible icicle-mode + :enable (and (not buffer-read-only) (boundp 'synonyms-obarray)))) + (define-key icicle-edit-menu-map [icicle-completing-yank] + '(menu-item "+ Paste Copied Text..." icicle-completing-yank :visible icicle-mode + :enable (not buffer-read-only) :keys "C-- C-y"))) + (t + (define-key icicle-menu-map [icicle-separator-edit] '("--")) + (define-key icicle-menu-map [icicle-complete-thesaurus-entry] + '(menu-item "Complete with Thesaurus..." icicle-complete-thesaurus-entry + :enable (and (not buffer-read-only) (boundp 'synonyms-obarray)))) + (define-key icicle-menu-map [icicle-insert-thesaurus-entry] + '(menu-item "+ Insert Thesaurus Entry..." icicle-insert-thesaurus-entry + :enable (and (not buffer-read-only) (boundp 'synonyms-obarray)))) + (define-key icicle-menu-map [icicle-completing-yank] + '(menu-item "+ Paste Copied Text..." icicle-completing-yank + :enable (not buffer-read-only) :keys "C-- C-y")))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-file-menu)) ; Use File menu, if available. + (defvar icicle-file-menu-map (make-sparse-keymap) + "Icicles submenu for `File' menu.") + (define-key menu-bar-file-menu [icicles] + (list 'menu-item "Icicles" icicle-file-menu-map :visible 'icicle-mode)) + (define-key icicle-file-menu-map [icicle-kill-buffer] + '(menu-item "+ Kill Buffer..." icicle-kill-buffer :visible icicle-mode :keys "C-x k")) + (define-key icicle-file-menu-map [icicle-delete-file] + '(menu-item "+ Delete File..." icicle-delete-file :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (when (featurep 'recentf) + (define-key icicle-file-menu-map [icicle-remove-file-from-recentf-list] + '(menu-item "+ Remove from Recent Files List..." + icicle-remove-file-from-recentf-list :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-file-menu-map [icicle-recent-file-other-window] + '(menu-item "+ Open Recent File (Other Window)..." + icicle-recent-file-other-window :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-file-menu-map [icicle-recent-file] + '(menu-item "+ Open Recent File..." icicle-recent-file :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-file-menu-map [icicle-dired-saved-file-candidates-other-window] + '(menu-item "Open Dired for Chosen Files..." + icicle-dired-saved-file-candidates-other-window :visible icicle-mode + :enable (and icicle-saved-completion-candidates + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-file-menu-map [icicle-dired-project-other-window] + '(menu-item "Open Dired for Project..." icicle-dired-project-other-window + :visible icicle-mode + :enable (and icicle-saved-completion-sets + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-file-menu-map [icicle-locate-file-other-window] + '(menu-item "+ Open File Under Directory (Other Window)..." + icicle-locate-file-other-window :visible icicle-mode)) + (define-key icicle-file-menu-map [icicle-locate-file] + '(menu-item "+ Open File Under Directory..." icicle-locate-file + :visible icicle-mode)) + (define-key icicle-file-menu-map [icicle-file-other-window] + '(menu-item "+ Open File or Directory (Other Window)..." + icicle-file-other-window :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-file-menu-map [icicle-file] + '(menu-item "+ Open File or Directory..." icicle-file :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (t + (define-key icicle-menu-map [icicle-kill-buffer] + '(menu-item "+ Kill Buffer..." icicle-kill-buffer)) + (define-key icicle-menu-map [icicle-delete-file] + '(menu-item "+ Delete File..." icicle-delete-file + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (when (featurep 'recentf) + (define-key icicle-menu-map [icicle-remove-file-from-recentf-list] + '(menu-item "+ Remove from Recent Files List..." + icicle-remove-file-from-recentf-list + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-recent-file-other-window] + '(menu-item "+ Open Recent File (Other Window)..." icicle-recent-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-recent-file] + '(menu-item "+ Open Recent File..." icicle-recent-file + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-dired-saved-file-candidates-other-window] + '(menu-item "Open Dired for Chosen Files..." + icicle-dired-saved-file-candidates-other-window + :enable (and icicle-saved-completion-candidates + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-dired-project-other-window] + '(menu-item "Open Dired for Project..." icicle-dired-project-other-window + :visible icicle-mode + :enable (and icicle-saved-completion-sets + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-locate-file-other-window] + '(menu-item "+ Open File Under Directory (Other Window)..." + icicle-locate-file-other-window)) + (define-key icicle-menu-map [icicle-locate-file] + '(menu-item "+ Open File Under Directory..." icicle-locate-file)) + (define-key icicle-menu-map [icicle-file-other-window] + '(menu-item "+ Open File or Directory (Other Window)..." + icicle-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-file] + '(menu-item "+ Open File or Directory ..." icicle-file + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))))) + (define-key icicle-menu-map [icicle-buffer-list] + '(menu-item "+ Buffer List..." icicle-buffer-list)) + (define-key icicle-menu-map [icicle-remove-buffer-config] + '(menu-item "+ Remove Buffer Configuration..." icicle-remove-buffer-config + :enable icicle-buffer-configs)) + (define-key icicle-menu-map [icicle-add-buffer-config] + '(menu-item "New Buffer Configuration..." icicle-add-buffer-config)) + (define-key icicle-menu-map [icicle-buffer-config] + '(menu-item "+ Choose Buffer Configuration..." icicle-buffer-config + :enable icicle-buffer-configs)) + (define-key icicle-menu-map [icicle-remove-buffer-candidate] + '(menu-item "+ Don't Always Include Buffer..." icicle-remove-buffer-candidate + :enable icicle-buffer-extras)) + (define-key icicle-menu-map [icicle-add-buffer-candidate] + '(menu-item "+ Always Include Buffer..." icicle-add-buffer-candidate)) + (define-key icicle-menu-map [icicle-kill-buffer] + '(menu-item "+ Kill Buffer..." icicle-kill-buffer)) + (define-key icicle-menu-map [icicle-insert-buffer] + '(menu-item "+ Insert Buffer..." icicle-insert-buffer)) + (define-key icicle-menu-map [icicle-delete-windows] + '(menu-item "+ Delete Windows on Buffer..." icicle-delete-windows :keys "C-u C-x 0")) + (define-key icicle-menu-map [icicle-buffer-other-window] + '(menu-item "+ Switch to Buffer (Other Window)..." icicle-buffer-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-buffer] + '(menu-item "+ Switch to Buffer..." icicle-buffer + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-bookmark-map)) ; Use Bookmarks menu, if available. + (require 'bookmark) ; `bookmark-buffer-name' is not autoloaded. + (defvar icicle-bookmark-menu-map (make-sparse-keymap) + "Icicles submenu for `Bookmarks' menu.") + (define-key menu-bar-bookmark-map [icicles] + (list 'menu-item "Icicles" icicle-bookmark-menu-map :visible 'icicle-mode)) + (define-key icicle-bookmark-menu-map [icicle-goto-global-marker] + '(menu-item "+ Go To Global Marker..." icicle-goto-global-marker + :visible icicle-mode + :enable (consp (icicle-markers global-mark-ring)) :keys "C-- C-x C-SPC")) + (define-key icicle-bookmark-menu-map [icicle-goto-marker] + '(menu-item "+ Go To Marker..." icicle-goto-marker + :visible icicle-mode + :enable (consp (icicle-markers mark-ring)) :keys "C-- C-SPC")) + (define-key icicle-bookmark-menu-map [icicle-separator-goto] '("--")) + (when (featurep 'bookmark+) + (define-key icicle-bookmark-menu-map [icicle-bookmark-non-file-other-window] + '(menu-item "+ Jump to Buffer (Non-File) Bookmark..." + icicle-bookmark-non-file-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-region-other-window] + '(menu-item "+ Jump to Region Bookmark..." icicle-bookmark-region-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-url-other-window] + '(menu-item "+ Jump to URL Bookmark..." icicle-bookmark-url-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-gnus-other-window] + '(menu-item "+ Jump to Gnus Bookmark..." icicle-bookmark-gnus-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-man-other-window] + '(menu-item "+ Jump to `man' Bookmark..." icicle-bookmark-man-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-info-other-window] + '(menu-item "+ Jump to Info Bookmark..." icicle-bookmark-info-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-remote-file-other-window] + '(menu-item "+ Jump to Remote-File Bookmark..." + icicle-bookmark-remote-file-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-local-file-other-window] + '(menu-item "+ Jump to Local-File Bookmark..." + icicle-bookmark-local-file-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-file-other-window] + '(menu-item "+ Jump to File Bookmark..." icicle-bookmark-file-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-dired-other-window] + '(menu-item "+ Jump to Dired Bookmark..." icicle-bookmark-dired-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-bookmark-list-other-window] + '(menu-item "+ Jump to Bookmark-List Bookmark..." + icicle-bookmark-bookmark-list-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark-desktop-other-window] + '(menu-item "+ Jump to Desktop Bookmark..." icicle-bookmark-desktop-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + ) + (define-key icicle-bookmark-menu-map [icicle-bookmark-other-window] + '(menu-item "+ Jump to Bookmark..." icicle-bookmark-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-bookmark-menu-map [icicle-bookmark] + '(menu-item "+ Jump to Bookmark (Same Window)..." icicle-bookmark :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (t + (when (featurep 'bookmark+) + (define-key icicle-menu-map [icicle-bookmark-non-file-other-window] + '(menu-item "+ Jump to Buffer (Non-File) Bookmark..." + icicle-bookmark-non-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-region-other-window] + '(menu-item "+ Jump to Region Bookmark..." icicle-bookmark-region-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-url-other-window] + '(menu-item "+ Jump to URL Bookmark..." icicle-bookmark-url-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-gnus-other-window] + '(menu-item "+ Jump to Gnus Bookmark..." icicle-bookmark-gnus-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-man-other-window] + '(menu-item "+ Jump to `man' Bookmark..." icicle-bookmark-man-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-info-other-window] + '(menu-item "+ Jump to Info Bookmark..." icicle-bookmark-info-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-remote-file-other-window] + '(menu-item "+ Jump to Remote-File Bookmark..." + icicle-bookmark-remote-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-local-file-other-window] + '(menu-item "+ Jump to Local-File Bookmark..." + icicle-bookmark-local-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-file-other-window] + '(menu-item "+ Jump to File Bookmark..." icicle-bookmark-file-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-dired-other-window] + '(menu-item "+ Jump to Dired Bookmark..." icicle-bookmark-dired-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-bookmark-list-other-window] + '(menu-item "+ Jump to Bookmark-List Bookmark..." + icicle-bookmark-bookmark-list-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark-desktop-other-window] + '(menu-item "+ Jump to Desktop Bookmark..." icicle-bookmark-desktop-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + ) + (define-key icicle-menu-map [icicle-bookmark-other-window] + '(menu-item "+ Jump To Bookmark..." icicle-bookmark-other-window + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-bookmark] + '(menu-item "+ Jump To Bookmark (Same Window)..." icicle-bookmark + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-separator-bookmark-buffer] '("--")))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-search-tags-menu)) ; Use Tags menu, if available - `menu-bar+.el' + (defvar icicle-search-tags-menu-map (make-sparse-keymap) + "Icicles submenu for `Tags' submenu of Search menu.") + (define-key menu-bar-search-tags-menu [icicles] + (list 'menu-item "Icicles" icicle-search-tags-menu-map :visible 'icicle-mode)) + (define-key icicle-search-tags-menu-map [icicle-tags-search] + '(menu-item "+ Search Tagged Files ..." icicle-tags-search :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-tags-menu-map [icicle-pop-tag-mark] + '(menu-item "+ Back (Pop Tag Mark)" icicle-pop-tag-mark :visible icicle-mode + :enable (and (boundp 'find-tag-marker-ring) + (not (ring-empty-p find-tag-marker-ring)) + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-search-tags-menu-map [icicle-find-first-tag-other-window] + '(menu-item "+ Find First Tag ..." icicle-find-first-tag-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-tags-menu-map [icicle-find-tag] + '(menu-item "+ Find Tag ..." icicle-find-tag :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + ((and (not icicle-touche-pas-aux-menus-flag) ; Use Search, if available and no Tags menu. + (boundp 'menu-bar-search-menu)) + (defvar icicle-search-menu-map (make-sparse-keymap) + "Icicles submenu for `Search' menu.") + (define-key menu-bar-search-menu [icicles] + (list 'menu-item "Icicles" icicle-search-menu-map :visible 'icicle-mode)) + (defvar icicle-search-tags-menu-map (make-sparse-keymap) + "Icicles submenu for `Tags' submenu of `Search' menu.") + (define-key icicle-search-menu-map [icicles-tags] + (list 'menu-item "Tags" icicle-search-tags-menu-map :visible 'icicle-mode)) + (define-key icicle-search-tags-menu-map [icicle-tags-search] + '(menu-item "+ Search Tagged Files ..." icicle-tags-search :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-tags-menu-map [icicle-pop-tag-mark] + '(menu-item "+ Back (Pop Tag Mark)" icicle-pop-tag-mark :visible icicle-mode + :enable (and (boundp 'find-tag-marker-ring) + (not (ring-empty-p find-tag-marker-ring)) + (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (define-key icicle-search-tags-menu-map [icicle-find-first-tag-other-window] + '(menu-item "+ Find First Tag ..." icicle-find-first-tag-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-tags-menu-map [icicle-find-tag] + '(menu-item "+ Find Tag ..." icicle-find-tag :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (t + (define-key icicle-search-tags-menu-map [icicle-tags-search] + '(menu-item "+ Search Tagged Files ..." icicle-tags-search + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-tags-menu-map [icicle-pop-tag-mark] + '(menu-item "+ Back (Pop Tag Mark)" icicle-pop-tag-mark :visible icicle-mode + :enable (and (boundp 'find-tag-marker-ring) + (not (ring-empty-p find-tag-marker-ring)) + (not (window-minibuffer-p + (frame-selected-window menu-updating-frame)))))) + (define-key icicle-menu-map [icicle-find-first-tag-other-window] + '(menu-item "Find First Tag ..." icicle-find-first-tag-other-window + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-find-tag] + '(menu-item "Find Tag ..." icicle-find-tag :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))))) + + (cond ((and (not icicle-touche-pas-aux-menus-flag) + (boundp 'menu-bar-search-menu)) ; Use Search menu, if available. + (defvar icicle-search-menu-map (make-sparse-keymap) + "Icicles submenu for `Search' menu.") + (define-key menu-bar-search-menu [icicles] + (list 'menu-item "Icicles" icicle-search-menu-map :visible 'icicle-mode)) + (define-key icicle-search-menu-map [icicle-goto-global-marker] + '(menu-item "+ Go To Global Marker..." icicle-goto-global-marker + :visible icicle-mode + :enable (consp (icicle-markers global-mark-ring)) :keys "C-- C-x C-SPC")) + (define-key icicle-search-menu-map [icicle-goto-marker] + '(menu-item "+ Go To Marker..." icicle-goto-marker + :visible icicle-mode + :enable (consp (icicle-markers mark-ring)) :keys "C-- C-SPC")) + (define-key icicle-search-menu-map [icicle-separator-goto] '("--")) + (define-key icicle-search-menu-map [icicle-search-highlight-cleanup] + '(menu-item "Remove Search Highlighting..." icicle-search-highlight-cleanup + :visible icicle-mode + :enable (or icicle-search-overlays (overlayp icicle-search-current-overlay) + (overlayp icicle-search-refined-overlays) icicle-search-refined-overlays))) + (define-key icicle-search-menu-map [icicle-compilation-search] + '(menu-item "+ Search Compilation/Grep Hits (Regexp)..." + icicle-compilation-search :visible icicle-mode + :enable (and (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) + (condition-case nil (eq (current-buffer) (compilation-find-buffer)) + (error nil))) + :keys "C-`")) + (define-key icicle-search-menu-map [icicle-grep-saved-file-candidates] + '(menu-item "Grep Saved File-Name Candidates..." + icicle-grep-saved-file-candidates + :visible icicle-mode :enable icicle-saved-completion-candidates)) + (define-key icicle-search-menu-map [icicle-imenu-non-interactive-function] + '(menu-item "+ Search Non-Command Fn Definition (Regexp)..." + icicle-imenu-non-interactive-function + :visible icicle-mode :enable (eq major-mode 'emacs-lisp-mode))) + (define-key icicle-search-menu-map [icicle-imenu-command] + '(menu-item "+ Search Command Definition (Regexp)..." icicle-imenu-command + :visible icicle-mode :enable (eq major-mode 'emacs-lisp-mode))) + (define-key icicle-search-menu-map [icicle-imenu] + '(menu-item "+ Search Definition (Regexp)..." icicle-imenu + :visible icicle-mode :enable imenu-generic-expression)) + (define-key icicle-search-menu-map [icicle-tags-search] + '(menu-item "+ Search Tagged Files ..." icicle-tags-search :visible icicle-mode)) + (define-key icicle-search-menu-map [icicle-search-bookmarks-together] + '(menu-item "+ Search Bookmarks Together..." icicle-search-bookmarks-together + :visible (and icicle-mode (featurep 'bookmark+)) :keys "C-u C-`")) + (define-key icicle-search-menu-map [icicle-search-bookmark] + '(menu-item "+ Search Bookmarks Separately..." icicle-search-bookmark + :visible (and icicle-mode (featurep 'bookmark+)))) + (define-key icicle-search-menu-map [icicle-search-file] + '(menu-item "+ Search Files (Regexp)..." icicle-search-file + :visible icicle-mode)) + (define-key icicle-search-menu-map [icicle-search-buffer] + '(menu-item "+ Search Buffers (Regexp)..." icicle-search-buffer + :visible icicle-mode)) + (define-key icicle-search-menu-map [icicle-search-text-property] + '(menu-item "+ Search Text Property..." icicle-search-text-property + :visible icicle-mode)) + (define-key icicle-search-menu-map [icicle-search-word] + '(menu-item "+ Search for Word..." icicle-search-word :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-menu-map [icicle-search-keywords] + '(menu-item "+ Search with Keywords (Regexps)..." icicle-search-keywords + :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-search-menu-map [icicle-search] + '(menu-item "+ Search (Regexp)..." icicle-search :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) + :keys "C-`")) + (define-key icicle-search-menu-map [icicle-occur] + '(menu-item "+ Occur (Regexp)..." icicle-occur :visible icicle-mode + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))) + (t + (define-key icicle-menu-map [icicle-search-highlight-cleanup] + '(menu-item "Remove Search Highlighting..." icicle-search-highlight-cleanup + :enable (or icicle-search-overlays (overlayp icicle-search-current-overlay) + (overlayp icicle-search-refined-overlays) + icicle-search-refined-overlays))) + (define-key icicle-menu-map [icicle-compilation-search] + '(menu-item "+ Search Compilation/Grep Hits (Regexp)..." icicle-compilation-search + :enable (and (not (window-minibuffer-p (frame-selected-window menu-updating-frame))) + (condition-case nil (eq (current-buffer) (compilation-find-buffer)) + (error nil))))) + (define-key icicle-menu-map [icicle-grep-saved-file-candidates] + '(menu-item "Grep Saved File-Name Candidates..." + icicle-grep-saved-file-candidates :enable icicle-saved-completion-candidates)) + (define-key icicle-menu-map [icicle-imenu-non-interactive-function] + '(menu-item "Search Non-Command Fn Definition (Regexp)..." + icicle-imenu-non-interactive-function :enable (eq major-mode 'emacs-lisp-mode))) + (define-key icicle-menu-map [icicle-imenu-command] + '(menu-item "Search Command Definition (Regexp)..." icicle-imenu-command + :enable (eq major-mode 'emacs-lisp-mode))) + (define-key icicle-menu-map [icicle-imenu] + '(menu-item "+ Search Definition (Regexp)..." icicle-imenu + :enable imenu-generic-expression)) + (define-key icicle-menu-map [icicle-tags-search] + '(menu-item "+ Search Tagged Files ..." icicle-tags-search)) + (define-key icicle-menu-map [icicle-search-bookmarks-together] + '(menu-item "+ Search Bookmarks Together..." icicle-search-bookmarks-together + :visible (featurep 'bookmark+) :keys "C-u C-`")) + (define-key icicle-menu-map [icicle-search-bookmark] + '(menu-item "+ Search Bookmarks Separately..." icicle-search-bookmark + :visible (featurep 'bookmark+))) + (define-key icicle-menu-map [icicle-search-file] + '(menu-item "+ Search Files (Regexp)..." icicle-search-file)) + (define-key icicle-menu-map [icicle-search-buffer] + '(menu-item "+ Search Buffers (Regexp)..." icicle-search-buffer)) + (define-key icicle-menu-map [icicle-search-text-property] + '(menu-item "+ Search Text Property..." icicle-search-text-property)) + (define-key icicle-menu-map [icicle-search-word] + '(menu-item "+ Search for Word..." icicle-search-word + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-search-keywords] + '(menu-item "+ Search with Keywords (Regexps)..." icicle-search-keywords + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-search] + '(menu-item "+ Search (Regexp)..." icicle-search + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))) + (define-key icicle-menu-map [icicle-occur] + '(menu-item "+ Occur (Regexp)..." icicle-occur + :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))))) + + ;; Install Icicles menu-bar menu. + (define-key icicle-mode-map [menu-bar icicles] (cons "Icicles" icicle-menu-map)) + + ;; Optional `icicle-mode-map' bindings - governed by `icicle-top-level-key-bindings'. + (icicle-bind-top-level-commands) + + ;; Install or update `icicle-mode-map'. + (if icicle-minor-mode-map-entry + (setcdr icicle-minor-mode-map-entry icicle-mode-map) + (setq icicle-minor-mode-map-entry (cons 'icicle-mode icicle-mode-map)) + (add-to-list 'minor-mode-map-alist icicle-minor-mode-map-entry))) + +(defun icicle-S-iso-lefttab-to-S-TAB (strg) + "Return string STRG, but with \"S-iso-lefttab\" replaced by \"S-TAB\"." + (replace-regexp-in-string "S-iso-lefttab" "S-TAB" strg)) + +(defun icicle-bind-other-keymap-keys () + "Bind some keys in maps other than minibuffer maps and `icicle-mode-map'" + + ;; Bind Isearch keys. + (icicle-bind-isearch-keys) + + ;; Bind keys in Comint mode. + (when (boundp 'comint-mode-map) + (define-key comint-mode-map "\C-c\C-i" 'icicle-comint-command) + (define-key comint-mode-map [(control ?c) tab] 'icicle-comint-command)) + + ;; Bind keys in Shell mode. + (when (and (boundp 'shell-mode-map) icicle-redefine-standard-commands-flag) + (define-key shell-mode-map "\t" 'icicle-comint-dynamic-complete)) + + ;; Bind keys in Shell Script mode. + (when (and (boundp 'sh-mode-map) icicle-redefine-standard-commands-flag) + (icicle-remap 'comint-dynamic-complete 'icicle-comint-dynamic-complete sh-mode-map)) + + ;; Bind keys in Ielm mode. + (when (and (boundp 'ielm-map) icicle-redefine-standard-commands-flag) + (define-key ielm-map "\t" 'icicle-comint-dynamic-complete)) + + ;; Bind keys in Tcl mode. + (when (and (boundp 'inferior-tcl-mode-map) icicle-redefine-standard-commands-flag) + (define-key inferior-tcl-mode-map "\t" 'icicle-comint-dynamic-complete)) + + ;; Bind keys in GUD (Debugger) mode. + (when (and (boundp 'gud-minibuffer-local-map) icicle-redefine-standard-commands-flag) + (define-key gud-minibuffer-local-map "\t" 'icicle-comint-dynamic-complete-filename)) + + ;; Bind keys in Info mode. + (when (and (boundp 'Info-mode-map) icicle-redefine-standard-commands-flag) + (icicle-remap 'Info-goto-node 'icicle-Info-goto-node-cmd Info-mode-map) ; `g' + (icicle-remap 'Info-index 'icicle-Info-index-cmd Info-mode-map) ; `i' + (icicle-remap 'Info-menu 'icicle-Info-menu-cmd Info-mode-map)) ; `m' + + ;; Bind some keys in Dired mode. + (when (boundp 'dired-mode-map) + (unless (lookup-key dired-mode-map [(control meta ?<)]) ; Dired `C-M-<' + (define-key dired-mode-map [(control meta ?<)] + 'icicle-dired-saved-file-candidates-other-window)) + (unless (lookup-key dired-mode-map [(control ?{)]) ; Dired `C-{' + (define-key dired-mode-map [(control ?{)] 'icicle-dired-project-other-window)) + (unless (lookup-key dired-mode-map [(control meta ?>)]) ; Dired `C-M->' + (define-key dired-mode-map [(control meta ?>)] 'icicle-dired-save-marked)) + (unless (lookup-key dired-mode-map [(control ?>)]) ; Dired `C->' + (define-key dired-mode-map [(control ?>)] 'icicle-dired-save-marked-more)) + (unless (lookup-key dired-mode-map [(control meta ?})]) ; Dired `C-M-}' + (define-key dired-mode-map [(control meta ?})] 'icicle-dired-save-marked-to-variable)) + (unless (lookup-key dired-mode-map [(control ?})]) ; Dired `C-}' + (define-key dired-mode-map [(control ?})] 'icicle-dired-save-marked-as-project)) + (let ((defn (lookup-key dired-mode-map "\M-si"))) ; Dired `M-s i' + (unless (and defn (not (integerp defn))) + (define-key dired-mode-map "\M-si" 'icicle-search-dired-marked)))) + + ;; Bind keys in Ibuffer mode. + (when (boundp 'ibuffer-mode-map) + (let ((defn (lookup-key ibuffer-mode-map "\M-si"))) ; Ibuffer `M-s i' + (unless (and defn (not (integerp defn))) + (define-key ibuffer-mode-map "\M-si" 'icicle-search-ibuffer-marked)) + (unless icicle-touche-pas-aux-menus-flag ; Use Ibuffer > Operate menu. + (define-key ibuffer-mode-operate-map [icicle-search-ibuffer-marked] + '(menu-item "Icicles Search (and Replace)..." icicle-search-ibuffer-marked + :visible icicle-mode :enable (eq major-mode 'ibuffer-mode)))))) + + ;; Bind keys in Buffer Menu mode. + (when (boundp 'Buffer-menu-mode-map) + (let ((defn (lookup-key Buffer-menu-mode-map "\M-si"))) ; Buffer-Menu `M-s i' + (unless (and defn (not (integerp defn))) + (define-key Buffer-menu-mode-map "\M-si" 'icicle-search-buff-menu-marked)))) + + ;; Bind `S-TAB' in major maps, for key completion. + (when (fboundp 'map-keymap) ; Emacs 22+. + (icicle-bind-key-completion-keys-in-keymaps-from (current-global-map)) + (mapcar #'icicle-bind-key-completion-keys-for-map-var icicle-keymaps-for-key-completion)) + + ;; Prevent `this-command' from being set to `handle-switch-frame'. + (define-key global-map [handle-switch-frame] 'icicle-skip-this-command) + (define-key global-map [switch-frame] 'icicle-handle-switch-frame)) + +(defun icicle-bind-isearch-keys () + "Bind Icicles Isearch commands." + (dolist (key icicle-search-from-isearch-keys) + (define-key isearch-mode-map key + (lambda () + (interactive) + (isearch-done) + (icicle-search (point-min) (point-max) (icicle-isearch-complete-past-string) t)))) + (dolist (key icicle-isearch-complete-keys) + (define-key isearch-mode-map key 'icicle-isearch-complete)) + (cond ((fboundp 'isearch-moccur) ; Defined in `moccur.el'. + (define-key isearch-mode-map (kbd "C-o") 'isearch-moccur)) + ((fboundp 'isearch-occur) ; Defined in `occur-schroeder.el'. + (define-key isearch-mode-map (kbd "C-o") 'isearch-occur)))) + +(defun icicle-bind-key-completion-keys-for-map-var (keymap-var) + "Bind `S-TAB' in keymaps accessible from keymap KEYMAP-VAR. +KEYMAP-VAR should be bound to a keymap that has at least one prefix +keymap. If KEYMAP-VAR is not bound to a keymap, it is ignored." + (let ((temp keymap-var)) + (when (boundp temp) + (setq temp (symbol-value temp)) + (when (keymapp temp) (icicle-bind-key-completion-keys-in-keymaps-from temp))))) + +(defun icicle-bind-key-completion-keys-in-keymaps-from (map) + "Bind keys in `icicle-key-complete-keys' to `icicle-complete-keys'. +Each key in `icicle-complete-keys' is bound in all keymaps accessible +from keymap MAP." + (dolist (key+map (accessible-keymaps map)) + (let ((map (cdr key+map))) + ;; We could try to exclude menu maps, by testing (not (keymap-prompt map)). + ;; But we want to include at least some menu maps - those, such as `facemenu-keymap', + ;; that are bound to keyboard keys. (when (and (keymapp map) (not (keymap-prompt map)))...) + (when (keymapp map) + (dolist (key icicle-key-complete-keys) + (when (or icicle-complete-key-anyway-flag (not (lookup-key map key))) + (condition-case nil (define-key map key 'icicle-complete-keys) (error nil)))))))) + +(defun icicle-restore-other-keymap-keys () + "Restore some bindings changed by `icicle-bind-other-keymap-keys'." + + ;; Unbind Isearch keys. + (icicle-unbind-isearch-keys) + + ;; Unbind keys in Comint mode. + (when (boundp 'comint-mode-map) + (define-key comint-mode-map "\C-c\C-i" nil) + (define-key comint-mode-map [(control ?c) tab] nil)) + + ;; Unbind keys in Shell mode. + (when (and (boundp 'shell-mode-map) icicle-redefine-standard-commands-flag) + (define-key shell-mode-map "\t" 'comint-dynamic-complete)) + + ;; Unbind keys in Shell Script mode. + (when (and (boundp 'sh-mode-map) icicle-redefine-standard-commands-flag) + (icicle-unmap 'comint-dynamic-complete sh-mode-map 'icicle-comint-dynamic-complete)) + + ;; Unbind keys in Ielm mode. + (when (and (boundp 'ielm-map) icicle-redefine-standard-commands-flag) + (define-key ielm-map "\t" 'comint-dynamic-complete)) + + ;; Unbind keys in Tcl mode. + (when (and (boundp 'inferior-tcl-mode-map) icicle-redefine-standard-commands-flag) + (define-key inferior-tcl-mode-map "\t" 'comint-dynamic-complete)) + + ;; Bind keys in GUD (Debugger) mode. + (when (and (boundp 'gud-minibuffer-local-map) icicle-redefine-standard-commands-flag) + (define-key gud-minibuffer-local-map "\t" 'comint-dynamic-complete-filename)) + + ;; Unbind keys in Info mode. + (when (and (boundp 'Info-mode-map) icicle-redefine-standard-commands-flag) + (icicle-unmap 'Info-goto-node Info-mode-map 'icicle-Info-goto-node-cmd) + (icicle-unmap 'Info-index Info-mode-map 'icicle-Info-index-cmd) + (icicle-unmap 'Info-menu Info-mode-map 'icicle-Info-menu-cmd)) + + ;; Unbind keys in Dired mode. + (when (boundp 'dired-mode-map) + (define-key dired-mode-map [(control meta ?<)] nil) + (define-key dired-mode-map [(control ?{)] nil) + (define-key dired-mode-map [(control meta ?>)] nil) + (define-key dired-mode-map [(control ?>)] nil) + (define-key dired-mode-map [(control meta ?})] nil) + (define-key dired-mode-map [(control ?})] nil) + (define-key dired-mode-map "\M-si" nil)) + + ;; Unbind keys in Ibuffer mode. + (when (boundp 'ibuffer-mode-map) + (define-key ibuffer-mode-map "\M-si" nil)) + + ;; Unbind keys in Buffer Menu mode. + (when (boundp 'Buffer-menu-mode-map) + (define-key Buffer-menu-mode-map "\M-si" nil)) + + ;; Unbind `S-TAB' in major maps. + (when (fboundp 'map-keymap) ; Emacs 22+. + (icicle-unbind-key-completion-keys-in-keymaps-from (current-global-map)) + (mapcar #'icicle-unbind-key-completion-keys-for-map-var icicle-keymaps-for-key-completion)) + + ;; Restore prevention of `this-command' being `handle-switch-frame'. + (define-key global-map [handle-switch-frame] nil) + (define-key global-map [switch-frame] 'handle-switch-frame)) + +(defun icicle-unbind-isearch-keys () + "Unbind Icicles Isearch commands." + (dolist (key icicle-search-from-isearch-keys) (define-key isearch-mode-map key nil)) + (dolist (key icicle-isearch-complete-keys) (define-key isearch-mode-map key nil)) + (define-key isearch-mode-map "\M-\t" 'isearch-complete) + (when (fboundp 'isearch-moccur) ; Restore `moccur.el' binding. + (define-key isearch-mode-map (kbd "M-o") 'isearch-moccur)) + (define-key isearch-mode-map (kbd "C-o") nil)) + +(defun icicle-unbind-key-completion-keys-for-map-var (keymap-var) + "Unbind `S-TAB' in keymaps accessible from keymap KEYMAP-VAR. +KEYMAP-VAR should be bound to a keymap that has at least one prefix +keymap. If KEYMAP-VAR is not bound to a keymap, it is ignored." + (let ((temp keymap-var)) + (when (boundp temp) + (setq temp (symbol-value temp)) + (when (keymapp temp) (icicle-unbind-key-completion-keys-in-keymaps-from temp))))) + +(defun icicle-unbind-key-completion-keys-in-keymaps-from (map) + "Unbind `icicle-key-complete-keys' in keymaps accessible from MAP." + (dolist (key+map (accessible-keymaps map)) + (let ((map (cdr key+map))) + (when (and (keymapp map) (not (stringp (car-safe (last map))))) ; Try to exclude menu maps. + (dolist (key icicle-key-complete-keys) + (when (eq (lookup-key map key) 'icicle-complete-keys) + (condition-case nil (define-key map key nil) (error nil)))))))) + +;;(@* "Other Icicles functions that define Icicle mode") + +;;; Other Icicles functions that define Icicle mode ------------------ + +(defun icicle-skip-this-command () + "Prevent `handle-switch-frame' from being added to `this-command'." + (interactive) + (setq this-command last-command)) + +(defun icicle-handle-switch-frame (event) + "Call `handle-switch-frame', but don't add it to `this-command'." + (interactive "e") + (handle-switch-frame event) + (setq this-command last-command)) + +(defun icicle-define-minibuffer-maps (turn-on-p) + "Define keymaps for the minibuffer and buffer *Completions*." + (cond + (turn-on-p ; TURN IT ON ******************************** + + ;; `minibuffer-local-map': default minibuffer map. + (let ((map minibuffer-local-map)) + (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit' + '(menu-item "Quit" icicle-abort-recursive-edit + :help "Cancel minibuffer input or recursive edit")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] '("--")) + (define-key map [menu-bar minibuf completion-help] + '(menu-item "Icicles Help" icicle-minibuffer-help + :help "Display help for minibuffer input and completion")) + (define-key map [menu-bar minibuf separator-last] '("--")) + (define-key map [menu-bar minibuf icicle-read+insert-file-name] + '(menu-item "Insert File Name" icicle-read+insert-file-name + :help "Read and insert a file name using (lax) completion.")) + (define-key map [menu-bar minibuf icicle-clear-current-history] + '(menu-item "Clear History Entries" icicle-clear-current-history + :help "Clear current minibuffer history of selected entries.")) + (define-key map [menu-bar minibuf icicle-insert-history-element] + '(menu-item "Insert Previously Entered Input" icicle-insert-history-element + :enable (consp (symbol-value minibuffer-history-variable)) + :help "Use completion to insert a previously entered input in the minibuffer.")) + + (define-key map [(control ??)] 'icicle-minibuffer-help) ; `C-?' + (define-key map [(control ?g)] 'icicle-abort-recursive-edit) ; `C-g' + (define-key map [M-S-backspace] 'icicle-erase-minibuffer) ; `M-S-backspace' + (define-key map [M-S-delete] 'icicle-erase-minibuffer) ; `M-S-delete' + (define-key map [(meta ?.)] 'icicle-insert-string-at-point) ; `M-.' + (define-key map [(control ?=)] 'icicle-insert-string-from-variable) ; `C-=' + (define-key map [(meta ?o)] 'icicle-insert-history-element) ; `M-o' + (define-key map [(meta ?i)] 'icicle-clear-current-history) ; `M-i' + (define-key map [(meta ?k)] 'icicle-erase-minibuffer-or-history-element) ; `M-k' + (define-key map [(meta ?:)] 'icicle-pp-eval-expression-in-minibuffer) ; `M-:' + (define-key map [(control ?a)] 'icicle-beginning-of-line+) ; `C-a' + (define-key map [(control ?e)] 'icicle-end-of-line+) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) + (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) + (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f' + (define-key map "\n" 'icicle-insert-newline-in-minibuffer) ; `C-j' + (when (fboundp 'yank-secondary) ; Defined in `second-sel.el'. + (define-key map "\C-\M-y" 'icicle-yank-secondary))) ; `C-M-y' + + ;; `minibuffer-local-ns-map': default minibuffer map when spaces are not allowed. + ;; In Emacs 22+, local is parent of local-ns. + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-ns-map)) + (let ((map minibuffer-local-ns-map)) + (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit' + '(menu-item "Quit" icicle-abort-recursive-edit + :help "Cancel minibuffer input or recursive edit")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] '("--")) + (define-key map [menu-bar minibuf completion-help] + '(menu-item "Icicles Help" icicle-minibuffer-help + :help "Display help for minibuffer input and completion")) + (define-key map [menu-bar minibuf separator-last] '("--")) + (define-key map [menu-bar minibuf icicle-read+insert-file-name] + '(menu-item "Insert File Name" icicle-read+insert-file-name + :help "Read and insert a file name using (lax) completion.")) + (define-key map [menu-bar minibuf icicle-clear-current-history] + '(menu-item "Clear History Entries" icicle-clear-current-history + :help "Clear current minibuffer history of selected entries.")) + (define-key map [menu-bar minibuf icicle-insert-history-element] + '(menu-item "Insert Previously Entered Input" icicle-insert-history-element + :enable (consp (symbol-value minibuffer-history-variable)) + :help "Use completion to insert a previously entered input in the minibuffer.")) + + (define-key map [(control ??)] 'icicle-minibuffer-help) ; `C-?' + (define-key map [(control ?g)] 'icicle-abort-recursive-edit) ; `C-g' + (define-key map [M-S-backspace] 'icicle-erase-minibuffer) ; `M-S-backspace' + (define-key map [M-S-delete] 'icicle-erase-minibuffer) ; `M-S-delete' + (define-key map [(meta ?.)] 'icicle-insert-string-at-point) ; `M-.' + (define-key map [(control ?=)] 'icicle-insert-string-from-variable) ; `C-=' + (define-key map [(meta ?o)] 'icicle-insert-history-element) ; `M-o' + (define-key map [(meta ?i)] 'icicle-clear-current-history) ; `M-i' + (define-key map [(meta ?k)] 'icicle-erase-minibuffer-or-history-element) ; `M-k' + (define-key map [(meta ?:)] 'icicle-pp-eval-expression-in-minibuffer) ; `M-:' + (define-key map [(control ?a)] 'icicle-beginning-of-line+) ; `C-a' + (define-key map [(control ?e)] 'icicle-end-of-line+) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) + (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) + (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f' + (define-key map "\n" 'icicle-insert-newline-in-minibuffer) ; `C-j' + (when (fboundp 'yank-secondary) ; Defined in `second-sel.el'. + (define-key map "\C-\M-y" 'icicle-yank-secondary)))) ; `C-M-y' + + ;; `minibuffer-local-isearch-map': minibuffer map for editing isearch strings. + ;; In Emacs 21+, local is parent of local-isearch. + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-isearch-map)) + (let ((map minibuffer-local-isearch-map)) + (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit' + '(menu-item "Quit" icicle-abort-recursive-edit + :help "Cancel minibuffer input or recursive edit")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] '("--")) + (define-key map [menu-bar minibuf completion-help] + '(menu-item "Icicles Help" icicle-minibuffer-help + :help "Display help for minibuffer input and completion")) + (define-key map [menu-bar minibuf separator-last] '("--")) + (define-key map [menu-bar minibuf icicle-read+insert-file-name] + '(menu-item "Insert File Name" icicle-read+insert-file-name + :help "Read and insert a file name using (lax) completion.")) + (define-key map [menu-bar minibuf icicle-clear-current-history] + '(menu-item "Clear History Entries" icicle-clear-current-history + :help "Clear current minibuffer history of selected entries.")) + (define-key map [menu-bar minibuf icicle-insert-history-element] + '(menu-item "Insert Previously Entered Input" icicle-insert-history-element + :enable (consp (symbol-value minibuffer-history-variable)) + :help "Use completion to insert a previously entered input in the minibuffer.")) + + (define-key map [(control ??)] 'icicle-minibuffer-help) ; `C-?' + (define-key map [(control ?g)] 'icicle-abort-recursive-edit) ; `C-g' + (define-key map [M-S-backspace] 'icicle-erase-minibuffer) ; `M-S-backspace' + (define-key map [M-S-delete] 'icicle-erase-minibuffer) ; `M-S-delete' + (define-key map [(meta ?.)] 'icicle-insert-string-at-point) ; `M-.' + (define-key map [(control ?=)] 'icicle-insert-string-from-variable) ; `C-=' + (define-key map [(meta ?o)] 'icicle-insert-history-element) ; `M-o' + (define-key map [(meta ?i)] 'icicle-clear-current-history) ; `M-i' + (define-key map [(meta ?k)] 'icicle-erase-minibuffer-or-history-element) ; `M-k' + (define-key map [(meta ?:)] 'icicle-pp-eval-expression-in-minibuffer) ; `M-:' + (define-key map [(control ?a)] 'icicle-beginning-of-line+) ; `C-a' + (define-key map [(control ?e)] 'icicle-end-of-line+) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) + (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) + (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f' + (define-key map "\n" 'icicle-insert-newline-in-minibuffer) ; `C-j' + (when (fboundp 'yank-secondary) ; Defined in `second-sel.el'. + (define-key map "\C-\M-y" 'icicle-yank-secondary)))) ; `C-M-y' + + ;; `minibuffer-local-completion-map': completion map. + (icicle-bind-completion-keys minibuffer-local-completion-map) + + ;; `minibuffer-local-must-match-map': must-match map. + ;; In Emacs 22+, local-completion is parent of local-must-match + (if (not (eq minibuffer-local-completion-map (keymap-parent minibuffer-local-must-match-map))) + (icicle-bind-completion-keys minibuffer-local-must-match-map) + (define-key minibuffer-local-must-match-map [(control ?g)] + 'icicle-abort-recursive-edit) ; `C-g' - need it anyway, even if inherit completion map. + ;; Override the binding of `C-j' to `minibuffer-complete-and-exit'. + (define-key minibuffer-local-must-match-map "\n" + 'icicle-insert-newline-in-minibuffer)) ; `C-j' (newline) + (define-key minibuffer-local-must-match-map [S-return] ; `S-RET' + 'icicle-apropos-complete-and-exit) + + ;; `minibuffer-local-filename-completion-map' and `minibuffer-local-must-match-filename-map' + ;; were introduced in Emacs 22, and they inherit from `minibuffer-local-completion' and + ;; `minibuffer-local-must-match-map', respectively. For Emacs 23.1, + ;; `minibuffer-local-must-match-filename-map' is an alias for + ;; `minibuffer-local-filename-must-match-map'. But for Emacs 23.2, there is no such alias! + (when (boundp 'minibuffer-local-filename-completion-map) + (when (and (featurep 'bookmark+) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-filename-completion-map + "\C-xm" 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-filename-completion-map + [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-filename-completion-map "\C-c+" 'icicle-make-directory)) + ;; Use the old map name, for Emacs 22-23.1. + (when (boundp 'minibuffer-local-must-match-filename-map) + (when (and (featurep 'bookmark+) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-must-match-filename-map + "\C-xm" 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-must-match-filename-map + [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-must-match-filename-map "\C-c+" 'icicle-make-directory)) + ;; Use the new name, for Emacs 23.2+. + (when (boundp 'minibuffer-local-filename-must-match-map) + (when (and (featurep 'bookmark+) (fboundp 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-filename-must-match-map + "\C-xm" 'icicle-bookmark-file-other-window)) + (define-key minibuffer-local-filename-must-match-map + [(control backspace)] 'icicle-up-directory) + (define-key minibuffer-local-filename-must-match-map "\C-c+" 'icicle-make-directory)) + + ;; `completion-list-mode-map': map for *Completions* buffer. + ;; Abort on `C-g' or `q'. Switch to minibuffer on `C-insert'. Do not allow normal input. + (let ((map completion-list-mode-map)) + (define-key map [(control ??)] 'icicle-minibuffer-help) ; `C-?' + (define-key map [(control ?g)] 'icicle-abort-recursive-edit) ; `C-g' + (define-key map "q" 'icicle-abort-recursive-edit) ; `q' + (define-key map [(control insert)] 'icicle-insert-completion) ; `C-insert' + (dolist (key icicle-prefix-cycle-next-keys) (define-key map key 'icicle-next-line)) ; `down' + (dolist (key icicle-prefix-cycle-previous-keys) + (define-key map key 'icicle-previous-line)) ; `up' + (dolist (key icicle-previous-candidate-keys) + (define-key map key 'icicle-move-to-previous-completion)) ; `S-TAB' + (define-key map [left] 'icicle-move-to-previous-completion) ; `left' + (define-key map [right] 'icicle-move-to-next-completion) ; `right' + (define-key map [(control ?i)] 'icicle-move-to-next-completion) ; `TAB' + (define-key map [tab] 'icicle-move-to-next-completion) ; `TAB' + (when (boundp 'mouse-wheel-down-event) ; Emacs 22+ - `wheel-down', `wheel-up' + (define-key map (vector mouse-wheel-down-event) 'icicle-scroll-Completions-up) + (define-key map (vector mouse-wheel-up-event) 'icicle-scroll-Completions)) + (define-key map [S-down-mouse-2] 'icicle-mouse-remove-candidate) ; `S-mouse-2' + (define-key map [S-mouse-2] 'ignore) + (define-key map [C-S-down-mouse-2] 'icicle-mouse-candidate-alt-action) ; `C-S-mouse-2' + (define-key map [C-S-mouse-2] 'ignore) + (define-key map [C-down-mouse-2] 'icicle-mouse-candidate-action) ; `C-mouse-2' + (define-key map [C-mouse-2] 'ignore) + (define-key map [C-M-return] 'icicle-help-on-candidate) ; `C-M-RET' + (define-key map [C-M-down-mouse-2] 'icicle-mouse-help-on-candidate) ; `C-M-mouse-2' + (define-key map [C-M-mouse-2] 'ignore) + (define-key map [M-S-down-mouse-2] 'icicle-mouse-save/unsave-candidate) ; `M-S-mouse-2' + (define-key map [M-S-mouse-2] 'ignore) + (define-key map [M-down-mouse-2] 'icicle-mouse-candidate-read-fn-invoke) ; `M-mouse-2' + (define-key map [M-mouse-2] 'ignore) + (define-key map [C-down-mouse-3] 'icicle-Completions-mouse-3-menu) ; `C-mouse-3' + (define-key map [C-mouse-3] 'ignore) + (define-key map [M-down-mouse-3] 'icicle-mouse-candidate-set-save-more) ; `M-mouse-3' + (define-key map [M-mouse-3] 'ignore) + (define-key map [M-S-down-mouse-3] 'icicle-mouse-candidate-set-save) ; `M-S-mouse-3' + (define-key map [M-S-mouse-3] 'ignore) + (define-key map [mouse-3] 'icicle-mouse-save-then-kill) ; `mouse-3' + (define-key map [(control ?>)] 'icicle-candidate-set-save-more) ; `C->' + (define-key map [(control meta ?>)] 'icicle-candidate-set-save) ; `C-M->' + (define-key map [(control ?\))] 'icicle-candidate-set-save-more-selected) ; `C-)' + (define-key map [(control meta ?\))] 'icicle-candidate-set-save-selected) ; `C-M-)' + (define-key map [(control meta ?<)] 'icicle-candidate-set-retrieve) ; `C-M-<' + (define-key map [(control ?l)] 'icicle-retrieve-previous-input) ; `C-l' + (define-key map [(control ?a)] 'icicle-beginning-of-line+) ; `C-a' + (define-key map [(control ?e)] 'icicle-end-of-line+) ; `C-e' + ;; (suppress-keymap map) ; Inhibit character self-insertion. + )) + + (t ; TURN IT OFF ******************************* + + ;; `minibuffer-local-map': default minibuffer map. + (let ((map minibuffer-local-map)) + (define-key map [menu-bar minibuf quit] + '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] nil) + (define-key map [menu-bar minibuf completion-help] nil) + (define-key map [menu-bar minibuf separator-last] nil) + (define-key map [menu-bar minibuf icicle-clear-current-history] nil) + (define-key map [menu-bar minibuf icicle-insert-history-element] nil) + + (define-key map [(control ??)] nil) ; `C-?' + (define-key map [(control ?g)] (if (and (fboundp 'minibuffer-keyboard-quit) + delete-selection-mode) + 'minibuffer-keyboard-quit + 'abort-recursive-edit)) ; `C-g' + (define-key map [M-S-backspace] nil) ; `M-S-DEL' + (define-key map [M-S-delete] nil) ; `M-S-delete' + (define-key map [(meta ?.)] nil) ; `M-.' + (define-key map [(control ?=)] nil) ; `C-=' + (define-key map [(meta ?o)] nil) ; `M-o' + (define-key map [(meta ?i)] nil) ; `M-i' + (define-key map [(meta ?k)] nil) ; `M-k' + (define-key map [(meta ?:)] nil) ; `M-:' + (define-key map [(control ?a)] nil) ; `C-a' + (define-key map [(control ?e)] nil) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f' + (define-key map "\n" 'exit-minibuffer) ; `C-j' + (define-key map "\C-\M-y" nil)) ; `C-M-y' + + ;; `minibuffer-local-ns-map': default minibuffer map when spaces are not allowed. + ;; In Emacs 22+, local is parent of local-ns. + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-ns-map)) + (let ((map minibuffer-local-ns-map)) + (define-key map [menu-bar minibuf quit] + '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] nil) + (define-key map [menu-bar minibuf completion-help] nil) + (define-key map [menu-bar minibuf separator-last] nil) + (define-key map [menu-bar minibuf icicle-clear-current-history] nil) + (define-key map [menu-bar minibuf icicle-insert-history-element] nil) + + (define-key map [(control ??)] nil) ; `C-?' + (define-key map [(control ?g)] (if (and (fboundp 'minibuffer-keyboard-quit) + delete-selection-mode) + 'minibuffer-keyboard-quit + 'abort-recursive-edit)) ; `C-g' + (define-key map [M-S-backspace] nil) ; `M-S-DEL' + (define-key map [M-S-delete] nil) ; `M-S-delete' + (define-key map [(meta ?.)] nil) ; `M-.' + (define-key map [(control ?=)] nil) ; `C-=' + (define-key map [(meta ?o)] nil) ; `M-o' + (define-key map [(meta ?i)] nil) ; `M-i' + (define-key map [(meta ?k)] nil) ; `M-k' + (define-key map [(meta ?:)] nil) ; `M-:' + (define-key map [(control ?a)] nil) ; `C-a' + (define-key map [(control ?e)] nil) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f' + (define-key map "\n" 'exit-minibuffer) ; `C-j' + (define-key map "\C-\M-y" nil))) ; `C-M-y' + + ;; `minibuffer-local-isearch-map': minibuffer map for editing isearch strings. + ;; In Emacs 21+, local is parent of local-isearch + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-isearch-map)) + (let ((map minibuffer-local-isearch-map)) + (define-key map [menu-bar minibuf quit] + '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] nil) + (define-key map [menu-bar minibuf completion-help] nil) + (define-key map [menu-bar minibuf separator-last] nil) + (define-key map [menu-bar minibuf icicle-clear-current-history] nil) + (define-key map [menu-bar minibuf icicle-insert-history-element] nil) + + (define-key map [(control ??)] nil) ; `C-?' + (define-key map [(control ?g)] (if (and (fboundp 'minibuffer-keyboard-quit) + delete-selection-mode) + 'minibuffer-keyboard-quit + 'abort-recursive-edit)) ; `C-g' + (define-key map [M-S-backspace] nil) ; `M-S-DEL' + (define-key map [M-S-delete] nil) ; `M-S-delete' + (define-key map [(meta ?.)] nil) ; `M-.' + (define-key map [(control ?=)] nil) ; `C-=' + (define-key map [(meta ?o)] nil) ; `M-o' + (define-key map [(meta ?i)] nil) ; `M-i' + (define-key map [(meta ?k)] nil) ; `M-k' + (define-key map [(meta ?:)] nil) ; `M-:' + (define-key map [(control ?a)] nil) ; `C-a' + (define-key map [(control ?e)] nil) ; `C-e' + (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c' + (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f' + (define-key map "\n" 'exit-minibuffer))) ; `C-j' + + ;; `minibuffer-local-completion-map': completion map. + (icicle-restore-completion-keys minibuffer-local-completion-map) + + ;; `minibuffer-local-must-match-map': must-match map. + ;; In Emacs 22+, local-completion is parent of local-must-match + (if (not (eq minibuffer-local-completion-map (keymap-parent minibuffer-local-must-match-map))) + (icicle-restore-completion-keys minibuffer-local-must-match-map) + (define-key minibuffer-local-must-match-map [(control ?g)] + (if (and (fboundp 'minibuffer-keyboard-quit) + delete-selection-mode) + 'minibuffer-keyboard-quit + 'abort-recursive-edit)) ; `C-g' - need it anyway, even if inherit completion map. + (define-key minibuffer-local-must-match-map "\n" 'minibuffer-complete-and-exit)) ; `C-j' + (define-key minibuffer-local-must-match-map [S-return] nil) + + ;; `minibuffer-local-filename-completion-map' and `minibuffer-local-must-match-filename-map' + ;; were introduced in Emacs 22, and they inherit from `minibuffer-local-completion' and + ;; `minibuffer-local-must-match-map', respectively. For Emacs 23.1, + ;; `minibuffer-local-must-match-filename-map' is an alias for + ;; `minibuffer-local-filename-must-match-map'. But for Emacs 23.2, there is no such alias! + (when (boundp 'minibuffer-local-filename-completion-map) + (define-key minibuffer-local-filename-completion-map "\C-xm" nil) + (define-key minibuffer-local-filename-completion-map [(control backspace)] nil) + (define-key minibuffer-local-filename-completion-map "\C-c+" nil)) + ;; Use the old name, for Emacs 22-23.1. + (when (boundp 'minibuffer-local-must-match-filename-map) + (define-key minibuffer-local-must-match-filename-map "\C-xm" nil) + (define-key minibuffer-local-must-match-filename-map [(control backspace)] nil)) + ;; Use the new name, for Emacs 23.2+. + (when (boundp 'minibuffer-local-filename-must-match-map) + (define-key minibuffer-local-filename-must-match-map "\C-xm" nil) + (define-key minibuffer-local-filename-must-match-map [(control backspace)] nil) + (define-key minibuffer-local-filename-must-match-map "\C-c+" nil)) + + ;; `completion-list-mode-map': map for *Completions* buffer. + (let ((map completion-list-mode-map)) + (define-key map [(control ?g)] nil) + (define-key map "q" nil) + (define-key map [(control insert)] nil) + (dolist (key icicle-prefix-cycle-next-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-keys) (define-key map key nil)) + (dolist (key icicle-previous-candidate-keys) (define-key map key nil)) + (define-key map [(control ?i)] nil) + (define-key map [tab] nil) + (define-key map [S-down-mouse-2] nil) + (define-key map [S-mouse-2] nil) + (define-key map [C-S-down-mouse-2] nil) + (define-key map [C-S-mouse-2] nil) + (define-key map [C-down-mouse-2] nil) + (define-key map [C-mouse-2] nil) + (define-key map [C-M-return] nil) + (define-key map [C-M-down-mouse-2] nil) + (define-key map [C-M-mouse-2] nil) + (define-key map [M-S-down-mouse-2] nil) + (define-key map [M-S-mouse-2] nil) + (define-key map [M-down-mouse-2] nil) + (define-key map [M-mouse-2] nil) + (define-key map [C-down-mouse-3] nil) + (define-key map [M-down-mouse-3] nil) + (define-key map [M-mouse-3] nil) + (define-key map [M-S-down-mouse-3] nil) + (define-key map [M-S-mouse-3] nil) + (define-key map [mouse-3] nil) + (define-key map [C-mouse-3] nil) + (define-key map [(control ?>)] nil) + (define-key map [(control meta ?>)] nil) + (define-key map [(control ?\))] nil) + (define-key map [(control meta ?\))] nil) + (define-key map [(control meta ?<)] nil) + (define-key map [(control ?l)] nil) + (define-key map [(control ?a)] nil) + (define-key map [(control ?e)] nil) + ;; Do these last: + (define-key map [left] 'previous-completion) + (define-key map [right] 'next-completion)))) + (when (and (interactive-p) turn-on-p) + (message (substitute-command-keys + "Use `\\\ +\\[icicle-minibuffer-help]' in minibuffer for help.")))) + +(defun icicle-unmap (command map current) + "In MAP, unbind any keys that are bound to COMMAND. +If command remapping is available, remap COMMAND to nil in MAP, +unbinding it. +Otherwise, bind COMMAND to whatever CURRENT is bound to in MAP." + (if (fboundp 'command-remapping) + (define-key map (vector 'remap command) nil) + (substitute-key-definition current command map))) + +(defun icicle-rebind-global (old new map) + "Bind command NEW in MAP to all keys currently bound globally to OLD." + (substitute-key-definition old new map (current-global-map))) + +(defun icicle-bind-completion-keys (map) + "Bind keys for minibuffer completion map MAP. +MAP is `minibuffer-local-completion-map', +`minibuffer-local-filename-completion-map', or +`minibuffer-local-must-match-map'." + + ;; Menu-bar Minibuf menu. + + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit' + '(menu-item "Quit" icicle-abort-recursive-edit + :help "Cancel minibuffer input or recursive edit")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] '("--")) + (define-key map [menu-bar minibuf completion-help] + '(menu-item "Icicles Help" icicle-minibuffer-help + :help "Display help for minibuffer input and completion")) + (define-key map [menu-bar minibuf separator-last] '("--")) + (define-key map [menu-bar minibuf icicle-read+insert-file-name] + '(menu-item "Insert File Name" icicle-read+insert-file-name + :help "Read and insert a file name using (lax) completion.")) + (define-key map [menu-bar minibuf icicle-clear-current-history] + '(menu-item "Clear History Entries" icicle-clear-current-history + :help "Clear current minibuffer history of selected entries.")) + (define-key map [menu-bar minibuf icicle-insert-history-element] + '(menu-item "Insert Previously Entered Input" icicle-insert-history-element + :enable (consp (symbol-value minibuffer-history-variable)) + :help "Use completion to insert a previously entered input in the minibuffer."))) + (define-key map [menu-bar minibuf icicle-retrieve-next-input] + '(menu-item "Restore Next Completion Input" icicle-retrieve-next-input + :enable (consp (symbol-value (if (icicle-file-name-input-p) + 'icicle-previous-raw-file-name-inputs + 'icicle-previous-raw-non-file-name-inputs))) + :help "Cycle forward to insert a previous completion input in the minibuffer (`C-u': \ +complete)")) + (define-key map [menu-bar minibuf icicle-retrieve-previous-input] + '(menu-item "Restore Previous Completion Input" icicle-retrieve-previous-input + :enable (consp (symbol-value (if (icicle-file-name-input-p) + 'icicle-previous-raw-file-name-inputs + 'icicle-previous-raw-non-file-name-inputs))) + :help "Cycle backward to insert a previous completion input in the minibuffer (`C-u': \ +complete)")) + (define-key map [menu-bar minibuf separator-C-l] '("--")) + (define-key map [menu-bar minibuf ?\?] nil) + (define-key map [menu-bar minibuf space] nil) + (define-key map [menu-bar minibuf tab] nil) + (define-key map [menu-bar minibuf alt-action-list-all] + '(menu-item "Alt Act on List of Candidates" icicle-all-candidates-list-alt-action + :help "Apply the alternative action to the list of matching completion candidates" + :enable icicle-all-candidates-list-alt-action-fn)) + (define-key map [menu-bar minibuf alt-action-all] + '(menu-item "Alt Act on Each Candidate" icicle-all-candidates-alt-action + :help "Apply the alternative action to each matching completion candidates" + :enable icicle-candidate-alt-action-fn)) + (define-key map [menu-bar minibuf action-list-all] + '(menu-item "Act on List of Candidates" icicle-all-candidates-list-action + :help "Apply the command action to the list of matching completion candidates" + :enable icicle-all-candidates-list-action-fn)) + (define-key map [menu-bar minibuf action-all] + '(menu-item "Act on Each Candidate" icicle-all-candidates-action + :help "Apply the command action to each matching completion candidates" + :enable icicle-candidate-action-fn)) + (define-key map [menu-bar minibuf separator-actions] '("--")) + (define-key map [menu-bar minibuf set-define] + '(menu-item "Define Candidates by Lisp Sexp" icicle-candidate-set-define + :help "Define the set of current completion candidates by evaluating a sexp")) + (define-key map [menu-bar minibuf icicle-keep-only-past-inputs] + '(menu-item "Keep Only Previously Entered" icicle-keep-only-past-inputs + :enable (and icicle-completion-candidates (consp (symbol-value minibuffer-history-variable))) + :help "Removed candidates that you have not previously chosen and entered")) + (define-key map [menu-bar minibuf set-union] + '(menu-item "Add (Union) Saved Candidate Set" icicle-candidate-set-union + :enable icicle-saved-completion-candidates + :help "Set union between the current and saved completion candidates")) + (define-key map [menu-bar minibuf set-difference] + '(menu-item "Subtract Saved Candidate Set" icicle-candidate-set-difference + :enable icicle-saved-completion-candidates + :help "Set difference between the current and saved completion candidates")) + (define-key map [menu-bar minibuf set-intersection] + '(menu-item "Intersect Saved Candidate Set" icicle-candidate-set-intersection + :enable icicle-saved-completion-candidates + :help "Set intersection between the current and saved candidates")) + (define-key map [menu-bar minibuf icicle-save-predicate-to-variable] + '(menu-item "Save Predicate to Variable" icicle-save-predicate-to-variable + :help "Save the current completion predicate to a variable")) + (define-key map [menu-bar minibuf icicle-narrow-candidates-with-predicate] + '(menu-item "Satisfy Also Predicate..." icicle-narrow-candidates-with-predicate + :help "Match another input pattern (narrow completions set)" + :enable icicle-completion-candidates)) + (define-key map [menu-bar minibuf icicle-narrow-candidates] + '(menu-item "Match Also Regexp..." icicle-narrow-candidates + :enable icicle-completion-candidates + :help "Match another input pattern (narrow completions set)")) + (define-key map [menu-bar minibuf icicle-widen-candidates] + '(menu-item "Match Alternative..." icicle-widen-candidates + :enable icicle-completion-candidates + :help "Match alternative input pattern (widen completions set)")) + (define-key map [menu-bar minibuf set-complement] + '(menu-item "Complement Candidates" icicle-candidate-set-complement + :help "Complement the set of current completion candidates")) + (define-key map [menu-bar minibuf separator-set1] '("--")) + (define-key map [menu-bar minibuf set-swap] + '(menu-item "Swap Saved and Current Sets" icicle-candidate-set-swap + :enable icicle-saved-completion-candidates + :help "Swap the saved and current sets of completion candidates")) + (define-key map [menu-bar minibuf icicle-candidate-set-save-more-selected] + '(menu-item "Save More Selected (Region) Candidates" + icicle-candidate-set-save-more-selected + :help "Add the candidates in the region to the saved candidates")) + (define-key map [menu-bar minibuf icicle-candidate-set-save-selected] + '(menu-item "Save Selected (Region) Candidates" + icicle-candidate-set-save-selected + :help "Save the candidates in the region, for later recall")) + (define-key map [menu-bar minibuf icicle-candidate-set-save-more] + '(menu-item "Save More Candidates" icicle-candidate-set-save-more + :help "Add current completion candidates to saved candidates set")) + (define-key map [menu-bar minibuf set-save-to-cache-file] + '(menu-item " to Cache File..." icicle-candidate-set-save-persistently + :help "Save current completion candidates to a cache file, for later recall")) + (define-key map [menu-bar minibuf set-save-to-variable] + '(menu-item " to Variable..." icicle-candidate-set-save-to-variable + :help "Save current completion candidates to a variable, for later recall")) + (define-key map [menu-bar minibuf set-save] + '(menu-item "Save Candidates" icicle-candidate-set-save + :help "Save the set of current completion candidates, for later recall")) + (define-key map [menu-bar minibuf icicle-candidate-set-retrieve-more] + '(menu-item "Retrieve More Saved Candidates" + icicle-candidate-set-retrieve-more + :help "Add saved candidates to current completion candidates")) + (define-key map [menu-bar minibuf set-retrieve-from-cache-file] + '(menu-item " from Cache File..." + icicle-candidate-set-retrieve-persistent + :help "Retrieve saved completion candidates from a cache file, making them current")) + (define-key map [menu-bar minibuf set-retrieve-from-variable] + '(menu-item " from Variable..." icicle-candidate-set-retrieve-from-variable + :help "Retrieve saved completion candidates from variable, making them current")) + (define-key map [menu-bar minibuf set-retrieve] + '(menu-item "Retrieve Saved Candidates" icicle-candidate-set-retrieve + :enable icicle-saved-completion-candidates + :help "Retrieve the saved set of completion candidates, making it current")) + (define-key map [menu-bar minibuf separator-set2] '("--")) + (define-key map [menu-bar minibuf word-complete] + '(menu-item "Word-Complete" icicle-prefix-word-complete + :help "Complete at most one word of prefix")) + (define-key map [menu-bar minibuf prefix-complete] + '(menu-item "Prefix-Complete" icicle-prefix-complete + :help "Complete prefix as far as possible")) + (define-key map [menu-bar minibuf apropos-complete] + '(menu-item "Apropos-Complete" icicle-apropos-complete :keys "S-TAB" + :help "Complete regular expression as far as possible and list completions")) + + ;; Remap some commands for completion. + (icicle-remap 'self-insert-command 'icicle-self-insert map (current-global-map)) + (icicle-remap 'universal-argument 'icicle-universal-argument ; `C-u' + map (current-global-map)) + (icicle-remap 'negative-argument 'icicle-negative-argument ; `M--' + map (current-global-map)) + (icicle-remap 'digit-argument 'icicle-digit-argument ; `C-9' + map (current-global-map)) + (icicle-remap 'backward-delete-char-untabify 'icicle-backward-delete-char-untabify ; `DEL' + map (current-global-map)) + (icicle-remap 'delete-backward-char 'icicle-delete-backward-char ; `DEL' + map (current-global-map)) + (icicle-remap 'delete-char 'icicle-delete-char ; `C-d', `deletechar' + map (current-global-map)) + (icicle-remap 'backward-kill-word 'icicle-backward-kill-word ; `M-DEL' + map (current-global-map)) + (icicle-remap 'kill-word 'icicle-kill-word ; `M-d' + map (current-global-map)) + (icicle-remap 'backward-kill-sexp 'icicle-backward-kill-sexp ; `C-M-backspace' + map (current-global-map)) + (icicle-remap 'kill-sexp 'icicle-kill-sexp ; `C-M-k', `C-M-delete' + map (current-global-map)) + (icicle-remap 'backward-kill-sentence 'icicle-backward-kill-sentence ; `C-x DEL' + map (current-global-map)) + (icicle-remap 'backward-kill-paragraph 'icicle-backward-kill-paragraph ; `C-backspace' + map (current-global-map)) + (icicle-remap 'kill-paragraph 'icicle-kill-paragraph ; `C-delete' + map (current-global-map)) + (icicle-remap 'kill-line 'icicle-kill-line ; `C-k', `deleteline' + map (current-global-map)) + (icicle-remap 'reposition-window 'icicle-goto/kill-failed-input ; `C-M-l' + map (current-global-map)) + (icicle-remap 'transpose-chars 'icicle-transpose-chars ; `C-t' + map (current-global-map)) + (icicle-remap 'transpose-words 'icicle-transpose-words ; `M-t' + map (current-global-map)) + (icicle-remap 'transpose-sexps 'icicle-transpose-sexps ; `C-M-t' + map (current-global-map)) + (icicle-remap 'yank-pop 'icicle-yank-pop ; `M-y', `M-insert' + map (current-global-map)) + (icicle-remap 'mouse-yank-secondary 'icicle-mouse-yank-secondary ; `M-mouse-2' + map (current-global-map)) + + ;; Bind additional keys. + (dolist (key icicle-word-completion-keys) + (define-key map key 'icicle-prefix-word-complete)) ; `M-SPC' + (dolist (key icicle-apropos-complete-keys) + (define-key map key 'icicle-apropos-complete)) ; `S-TAB' + (dolist (key icicle-prefix-complete-keys) (define-key map key 'icicle-prefix-complete)) ; `TAB' + (dolist (key icicle-apropos-complete-no-display-keys) + (define-key map key 'icicle-apropos-complete-no-display)) ; `C-M-S-TAB' + (dolist (key icicle-prefix-complete-no-display-keys) + (define-key map key 'icicle-prefix-complete-no-display)) ; `C-M-TAB' + + (icicle-define-cycling-keys map) ; `up', `down', `prior', `next', + ; `C-up', `C-down', `C-prior', `C-next', + ; `C-M-up', `C-M-down', `C-M-prior', `C-M-next', + ; `C-S-up', `C-S-down', `C-S-prior', `C-S-next', + (define-key map [(control help)] 'icicle-help-on-candidate) ; `C-help' + (define-key map [(control meta help)] 'icicle-help-on-candidate) ; `C-M-help' + (define-key map [(control f1)] 'icicle-help-on-candidate) ; `C-f1' + (define-key map [(control meta f1)] 'icicle-help-on-candidate) ; `C-M-f1' + (define-key map [(control meta return)] 'icicle-help-on-candidate) ; `C-M-RET' + (define-key map [(meta return)] 'icicle-candidate-read-fn-invoke) ;`M-RET' as `M-return' + (define-key map "\C-\M-m" 'icicle-candidate-read-fn-invoke) ;`M-RET' as `ESC RET' + (define-key map [(control shift return)] 'icicle-candidate-alt-action) ; `C-S-RET' + (define-key map [delete] 'icicle-remove-candidate) ; `delete' + (define-key map [(shift delete)] 'icicle-delete-candidate-object) ; `S-delete' + (define-key map [(control ?w)] 'icicle-kill-region) ; `C-w' + (define-key map [(control return)] 'icicle-candidate-action) ; `C-RET' + (define-key map [(control ?!)] 'icicle-all-candidates-action) ; `C-!' + (define-key map [(control ?|)] 'icicle-all-candidates-alt-action) ; `C-|' + (define-key map [(meta ?!)] 'icicle-all-candidates-list-action) ; `M-!' + (define-key map [(meta ?|)] 'icicle-all-candidates-list-alt-action) ; `M-|' + (define-key map [(control meta ?/)] 'icicle-prefix-complete) ; `C-M-/', for `dabbrev.el'. + (define-key map [(meta ?h)] 'icicle-history) ; `M-h' + (define-key map [(meta pause)] 'icicle-keep-only-past-inputs) ; `M-pause' + (define-key map [(control pause)] 'icicle-toggle-highlight-historical-candidates) ; `C-pause' + (define-key map [(control meta pause)] 'icicle-other-history) ; `C-M-pause' + (define-key map [(control insert)] 'icicle-switch-to-Completions-buf) ; `C-insert' + (define-key map [insert] 'icicle-save/unsave-candidate) ; `insert' + + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + ;; Note: `setup-keys.el' binds `C-o' to `1on1-fit-minibuffer-frame' if defined. + (define-key map [(control ?a)] 'icicle-beginning-of-line+) ; `C-a' + (define-key map [(control ?e)] 'icicle-end-of-line+) ; `C-e' + (define-key map [(control ?=)] 'icicle-insert-string-from-variable) ; `C-=' + ;; Replaces `tab-to-tab-stop': + (define-key map [(meta ?i)] 'icicle-clear-current-history) ; `M-i' + ;; Replaces `kill-sentence': + (define-key map [(meta ?k)] 'icicle-erase-minibuffer-or-history-element) ; `M-k' + (define-key map [(meta ?o)] 'icicle-insert-history-element) ; `M-o' + (define-key map [(meta ?.)] 'icicle-insert-string-at-point) ; `M-.' + (define-key map [(meta ?:)] 'icicle-pp-eval-expression-in-minibuffer) ; `M-:' + (when (fboundp 'yank-secondary) ; Defined in `second-sel.el'. + (define-key map "\C-\M-y" 'icicle-yank-secondary)) ; `C-M-y' + (define-key map [M-S-backspace] 'icicle-erase-minibuffer) ; `M-S-backspace' + (define-key map [M-S-delete] 'icicle-erase-minibuffer) ; `M-S-delete' + ) + + ;; Need `C-g', even if `minibuffer-local-completion-map' inherits from `minibuffer-local-map'. + (define-key map [(control ?g)] 'icicle-abort-recursive-edit) ; `C-g' + (define-key map [(meta ?q)] 'icicle-dispatch-M-q) ; `M-q' + (define-key map [(control ?l)] 'icicle-retrieve-previous-input) ; `C-l' + (define-key map [(control shift ?l)] 'icicle-retrieve-next-input) ; `C-L' (`C-S-l') + (define-key map [(meta ?$)] 'icicle-candidate-set-truncate) ; `M-$' + (define-key map [(control ?~)] 'icicle-candidate-set-complement) ; `C-~' + (define-key map [(control ?-)] 'icicle-candidate-set-difference) ; `C--' + (define-key map [(control ?+)] 'icicle-candidate-set-union) ; `C-+' + (define-key map [(control ?*)] 'icicle-candidate-set-intersection) ; `C-*' + (define-key map [(control ?>)] 'icicle-candidate-set-save-more) ; `C->' + (define-key map [(control meta ?>)] 'icicle-candidate-set-save) ; `C-M->' + (define-key map [(control ?\()] 'icicle-next-TAB-completion-method) ; `C-(' + (define-key map [(meta ?\()] 'icicle-next-S-TAB-completion-method) ; `M-(' + (define-key map [(control ?\))] 'icicle-candidate-set-save-more-selected) ; `C-)' + (define-key map [(control meta ?\))] 'icicle-candidate-set-save-selected) ; `C-M-)' + (define-key map [(control meta ?<)] 'icicle-candidate-set-retrieve) ; `C-M-<' + (define-key map [(control meta ?})] 'icicle-candidate-set-save-to-variable) ; `C-M-}' + (define-key map [(control meta ?{)] 'icicle-candidate-set-retrieve-from-variable) ; `C-M-{' + (define-key map [(control ?})] 'icicle-candidate-set-save-persistently) ; `C-}' + (define-key map [(control ?{)] 'icicle-candidate-set-retrieve-persistent) ; `C-{' + (define-key map [(control ?%)] 'icicle-candidate-set-swap) ; `C-%' + (define-key map [(control ?:)] 'icicle-candidate-set-define) ; `C-:' + (define-key map [(control meta ?j)] 'icicle-insert-list-join-string) ; `C-M-j' + (define-key map [(control ?,)] 'icicle-change-sort-order) ; `C-,' + (define-key map [(control meta ?\;)] 'icicle-regexp-quote-input) ; `C-M-;' + (define-key map [(control ?`)] 'icicle-toggle-regexp-quote) ; `C-`' + (define-key map [(control meta ?\.)] 'icicle-toggle-dot) ; `C-M-.' + (define-key map [(control meta ?`)] 'icicle-toggle-literal-replacement) ; `C-M-`' + (define-key map [(control ?<)] 'icicle-candidate-set-retrieve-more) ; `C-<' + (define-key map [(control meta ?_)] 'icicle-toggle-proxy-candidates) ; `C-M-_' + (define-key map [(control ?$)] 'icicle-toggle-transforming) ; `C-$' + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map [(control ??)] 'icicle-minibuffer-help)) ; `C-?' + (define-key map [(control ?.)] 'icicle-dispatch-C-.) ; `C-.' + (define-key map [(control ?#)] 'icicle-toggle-incremental-completion) ; `C-#' + (define-key map [(control ?\;)] 'icicle-toggle-expand-to-common-match) ; `C-;' + (define-key map [(meta ?\;)] 'icicle-toggle-search-replace-common-match) ; `M-;' + (define-key map [(control ?^)] 'icicle-dispatch-C-^) ; `C-^' + (define-key map [(control shift ?a)] 'icicle-toggle-case-sensitivity) ; `C-S-a' (`C-A') + (define-key map [(meta ?~)] 'icicle-toggle-~-for-home-dir) ; `M-~' + (define-key map [(meta ?g)] 'icicle-toggle-C-for-actions) ; `M-g' + (define-key map [(meta ?,)] 'icicle-dispatch-M-comma) ; `M-,' + (define-key map [(control meta ?,)] 'icicle-toggle-alternative-sorting) ; `C-M-,' + (define-key map [(meta ?+)] 'icicle-widen-candidates) ; `M-+' + (define-key map [(meta ?*)] 'icicle-narrow-candidates) ; `M-*' + (define-key map [(meta ?&)] 'icicle-narrow-candidates-with-predicate) ; `M-&' + (define-key map [(meta ?_)] 'icicle-dispatch-M-_) ; `M-_' + (define-key map [(control meta ?&)] 'icicle-save-predicate-to-variable) ; `C-M-&' + (define-key map [(shift ?\ )] 'icicle-apropos-complete-and-narrow) ; `S-SPC' + (define-key map [(shift backspace)] 'icicle-apropos-complete-and-widen) ; `S-DEL' + (define-key map "\C-v" 'icicle-scroll-Completions) ; `C-v' + (define-key map "\M-v" 'icicle-scroll-Completions-up) ; `M-v' + (define-key map "." 'icicle-insert-dot-command) ; `.' + (define-key map "\M-m" 'icicle-toggle-show-multi-completion) ; `M-m' + (define-key map "\C-x." 'icicle-toggle-hiding-common-match) ; `C-x .' + (when (fboundp 'doremi) + (define-key map "\C-xw" 'icicle-doremi-candidate-width-factor+) ; `C-x w' + (define-key map "\C-x|" 'icicle-doremi-inter-candidates-min-spaces+) ; `C-x |' + (define-key map "\C-x#" 'icicle-doremi-increment-max-candidates+) ; `C-x #' + (when (fboundp 'text-scale-increase) ; Emacs 23+. + (define-key map "\C-x-" 'icicle-doremi-zoom-Completions+)) ; `C-x -' + (when (eq icicle-current-TAB-method 'swank) + (define-key map "\C-x1" 'icicle-doremi-increment-swank-timeout+) + (define-key map "\C-x2" 'icicle-doremi-increment-swank-prefix-length+))) + ;; `minibuffer-completion-help' got wiped out by remap for self-insert. + (define-key map "?" 'icicle-self-insert) ; `?' + (define-key map " " 'icicle-self-insert) ; " " + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map "\n" 'icicle-insert-newline-in-minibuffer))) ; `C-j' + +(defun icicle-restore-completion-keys (map) + "Restore standard keys for minibuffer completion map MAP. +MAP is `minibuffer-local-completion-map', +`minibuffer-local-filename-completion-map', or +`minibuffer-local-must-match-map'." + + ;; Menu-bar Minibuf menu. + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map [menu-bar minibuf quit] + '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer")) + (define-key map [menu-bar minibuf return] + '(menu-item "Enter" exit-minibuffer + :help "Terminate input and exit minibuffer" :keys "RET")) + (define-key map [menu-bar minibuf separator-help] nil) + (define-key map [menu-bar minibuf completion-help] nil) + (define-key map [menu-bar minibuf separator-last] nil) + (define-key map [menu-bar minibuf icicle-clear-current-history] nil) + (define-key map [menu-bar minibuf icicle-insert-history-element] nil)) + (define-key map [menu-bar minibuf icicle-retrieve-next-input] nil) + (define-key map [menu-bar minibuf icicle-retrieve-previous-input] nil) + (define-key map [menu-bar minibuf separator-C-l] nil) + (define-key map [menu-bar minibuf alt-action-list-all] nil) + (define-key map [menu-bar minibuf alt-action-all] nil) + (define-key map [menu-bar minibuf action-list-all] nil) + (define-key map [menu-bar minibuf action-all] nil) + (define-key map [menu-bar minibuf separator-actions] nil) + (define-key map [menu-bar minibuf set-define] nil) + (define-key map [menu-bar minibuf icicle-keep-only-past-inputs] nil) + (define-key map [menu-bar minibuf set-union] nil) + (define-key map [menu-bar minibuf set-difference] nil) + (define-key map [menu-bar minibuf set-intersection] nil) + (define-key map [menu-bar minibuf icicle-save-predicate-to-variable] nil) + (define-key map [menu-bar minibuf icicle-narrow-candidates-with-predicate] nil) + (define-key map [menu-bar minibuf icicle-narrow-candidates] nil) + (define-key map [menu-bar minibuf icicle-widen-candidates] nil) + (define-key map [menu-bar minibuf set-complement] nil) + (define-key map [menu-bar minibuf separator-set1] nil) + (define-key map [menu-bar minibuf set-swap] nil) + (define-key map [menu-bar minibuf icicle-candidate-set-save-more-selected] nil) + (define-key map [menu-bar minibuf icicle-candidate-set-save-selected] nil) + (define-key map [menu-bar minibuf icicle-candidate-set-save-more] nil) + (define-key map [menu-bar minibuf set-retrieve-from-cache-file] nil) + (define-key map [menu-bar minibuf set-retrieve-from-variable] nil) + (define-key map [menu-bar minibuf set-retrieve] nil) + (define-key map [menu-bar minibuf set-save-to-cache-file] nil) + (define-key map [menu-bar minibuf set-save-to-variable] nil) + (define-key map [menu-bar minibuf set-save] nil) + (define-key map [menu-bar minibuf separator-set2] nil) + (define-key map [menu-bar minibuf word-complete] nil) + (define-key map [menu-bar minibuf prefix-complete] nil) + (define-key map [menu-bar minibuf apropos-complete] nil) + (define-key map [menu-bar minibuf ?\?] + '(menu-item "List Completions" minibuffer-completion-help + :help "Display all possible completions")) + (define-key map [menu-bar minibuf space] + '(menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word")) + (define-key map [menu-bar minibuf tab] + '(menu-item "Complete" minibuffer-complete :help "Complete as far as possible")) + + ;; Unmap commands that were bound for completion. + (icicle-unmap 'self-insert-command map 'icicle-self-insert) + (icicle-unmap 'universal-argument map 'icicle-universal-argument) + (icicle-unmap 'negative-argument map 'icicle-negative-argument) + (icicle-unmap 'digit-argument map 'icicle-digit-argument) + (icicle-unmap 'backward-delete-char-untabify map 'icicle-backward-delete-char-untabify) + (icicle-unmap 'delete-backward-char map 'icicle-delete-backward-char) + (icicle-unmap 'delete-char map 'icicle-delete-char) + (icicle-unmap 'backward-kill-word map 'icicle-backward-kill-word) + (icicle-unmap 'kill-word map 'icicle-kill-word) + (icicle-unmap 'backward-kill-sexp map 'icicle-backward-kill-sexp) + (icicle-unmap 'kill-sexp map 'icicle-kill-sexp) + (icicle-unmap 'backward-kill-sentence map 'icicle-backward-kill-sentence) + (icicle-unmap 'backward-kill-paragraph map 'icicle-backward-kill-paragraph) + (icicle-unmap 'kill-paragraph map 'icicle-kill-paragraph) + (icicle-unmap 'kill-line map 'icicle-kill-line) + (icicle-unmap 'reposition-window map 'icicle-goto/kill-failed-input) + (icicle-unmap 'transpose-chars map 'icicle-transpose-chars) + (icicle-unmap 'transpose-words map 'icicle-transpose-words) + (icicle-unmap 'transpose-sexps map 'icicle-transpose-sexps) + (icicle-unmap 'yank-pop map 'icicle-yank-pop) + (icicle-unmap 'mouse-yank-secondary map 'icicle-mouse-yank-secondary) + + ;; Restore additional bindings. + ;; Do the option keys first, so they can be rebound as needed. + (dolist (key icicle-word-completion-keys) (define-key map key nil)) + (dolist (key icicle-apropos-complete-keys) (define-key map key nil)) + (dolist (key icicle-prefix-complete-keys) (define-key map key nil)) + (dolist (key icicle-apropos-complete-no-display-keys) (define-key map key nil)) + (dolist (key icicle-prefix-complete-no-display-keys) (define-key map key nil)) + + (dolist (key icicle-prefix-cycle-previous-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-help-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-help-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-help-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-help-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-help-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-help-keys) (define-key map key nil)) + + (define-key map [(control help)] nil) + (define-key map [(control meta help)] nil) + (define-key map [(control f1)] nil) + (define-key map [(control meta f1)] nil) + (define-key map [(control meta return)] nil) + (define-key map [(meta return)] nil) + (define-key map "\C-\M-m" nil) + (define-key map [(control shift return)] nil) + (define-key map [delete] nil) + (define-key map [(shift delete)] nil) + (define-key map [(control ?w)] nil) + (define-key map [(control return)] nil) + (define-key map [(control ?!)] nil) + (define-key map [(control ?!)] nil) + (define-key map [(control ?|)] nil) + (define-key map [(meta ?!)] nil) + (define-key map [(meta ?|)] nil) + (define-key map [(control meta ?/)] nil) + (define-key map [(meta ?h)] nil) + (define-key map [(meta pause)] nil) + (define-key map [(control pause)] nil) + (define-key map [(control meta pause)] nil) + (define-key map [(control insert)] nil) + (define-key map [insert] nil) + + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map [(control ?a)] nil) + (define-key map [(control ?e)] nil) + (define-key map [(control ?=)] nil) + (define-key map [(meta ?i)] nil) + (define-key map [(meta ?k)] nil) + (define-key map [(meta ?o)] nil) + (define-key map [(meta ?.)] nil) + (define-key map [(meta ?:)] nil) + (define-key map "\C-\M-y" nil) + (define-key map [M-S-backspace] nil) + (define-key map [M-S-delete] nil) + ) + + (define-key map [(meta ?q)] nil) + (define-key map [(control ?l)] nil) + (define-key map [(control shift ?l)] nil) + (define-key map [(meta ?$)] nil) + (define-key map [(control ?~)] nil) + (define-key map [(control ?-)] nil) + (define-key map [(control ?+)] nil) + (define-key map [(control ?*)] nil) + (define-key map [(control ?>)] nil) + (define-key map [(control meta ?>)] nil) + (define-key map [(control ?\()] nil) + (define-key map [(meta ?\()] nil) + (define-key map [(control ?\))] nil) + (define-key map [(control meta ?\))] nil) + (define-key map [(control meta ?<)] nil) + (define-key map [(control meta ?})] nil) + (define-key map [(control meta ?{)] nil) + (define-key map [(control ?})] nil) + (define-key map [(control ?{)] nil) + (define-key map [(control ?%)] nil) + (define-key map [(control ?:)] nil) + (define-key map [(control meta ?j)] nil) + (define-key map [(control ?,)] nil) + (define-key map [(control ? )] nil) + (define-key map [(control meta ?\;)] nil) + (define-key map [(control ?`)] nil) + (define-key map [(control meta ?`)] nil) + (define-key map [(control ?<)] nil) + (define-key map [(control meta ?_)] nil) + (define-key map [(control ?$)] nil) + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map [(control ??)] nil)) + (define-key map [(control ?.)] nil) + (define-key map [(control ?#)] nil) + (define-key map [(control ?\;)] nil) + (define-key map [(control meta ?\.)] nil) + (define-key map [(meta ?\;)] nil) + (define-key map [(control ?^)] nil) + (define-key map [(control shift ?a)] nil) + (define-key map [(meta ?~)] nil) + (define-key map [(meta ?g)] nil) + (define-key map [(meta ?,)] nil) + (define-key map [(control meta ?,)] nil) + (define-key map [(meta ?+)] nil) + (define-key map [(meta ?*)] nil) + (define-key map [(meta ?&)] nil) + (define-key map [(meta ?_)] nil) + (define-key map [(control meta ?&)] nil) + (define-key map [(shift ?\ )] nil) + (define-key map [(shift backspace)] nil) + (define-key map "\C-v" nil) + (define-key map "\M-v" nil) + (define-key map "." nil) + (define-key map "\M-m" nil) + (define-key map "\C-x." nil) + (when (fboundp 'doremi) + (define-key map "\C-xw" nil) + (define-key map "\C-x|" nil) + (define-key map "\C-x#" nil) + (when (fboundp 'text-scale-increase) + (define-key map "\C-x-" nil)) + (define-key map "\C-x1" nil) + (define-key map "\C-x2" nil)) + ;; Do these last. ----------------- + (define-key map [(control ?i)] 'minibuffer-complete) + (define-key map [tab] 'minibuffer-complete) + (define-key map "?" 'minibuffer-completion-help) + (define-key map " " 'minibuffer-complete-word) + (define-key map [(control ?g)] (if (and (fboundp 'minibuffer-keyboard-quit) + delete-selection-mode) + 'minibuffer-keyboard-quit + 'abort-recursive-edit)) + ;; In Emacs 22+, local is parent of local-completion + (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map)) + (define-key map "\n" 'exit-minibuffer)) + (define-key map [(meta ?p)] 'previous-history-element) + (define-key map [(meta ?n)] 'next-history-element) + (define-key map [up] 'previous-history-element) + (define-key map [down] 'next-history-element) + (define-key map [(meta ?v)] 'switch-to-completions) + (define-key map [prior] 'switch-to-completions) + (define-key map [next] 'next-history-element)) + +(defun icicle-minibuffer-setup () + "Run in minibuffer on activation, to enable completion cycling. +Usually run by inclusion in `minibuffer-setup-hook'." + (when (and icicle-mode (window-minibuffer-p (selected-window)) (not executing-kbd-macro)) + ;; The pre- and post-command hooks are local to the + ;; minibuffer, so they are added here, not in `icicle-mode'. + ;; They are removed in `icicle-mode' when mode is exited. + (unless (fboundp 'define-minor-mode) (make-local-hook 'pre-command-hook)) + (add-hook 'pre-command-hook 'icicle-top-level-prep) + (add-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook nil t) + (unless (fboundp 'define-minor-mode) (make-local-hook 'post-command-hook)) + (add-hook 'post-command-hook 'icicle-run-icicle-post-command-hook nil t) + ;; Change the region background here dynamically. It would be better to + ;; just use a buffer-local face, but those don't yet exist. + (when (= 1 (recursion-depth)) + (setq icicle-saved-region-background (face-background 'region)) + (when icicle-change-region-background-flag + (set-face-background 'region icicle-region-background))) + ;; Reset prompt, because some commands (e.g. `find-file') don't use `read-file-name' + ;; or `completing-read'. Reset other stuff too. + (setq icicle-candidate-nb nil + icicle-completion-candidates nil + icicle-current-completion-mode (case icicle-cycling-respects-completion-mode + ((nil) nil) + (apropos 'apropos) + (prefix 'prefix) + (otherwise nil)) + icicle-next-apropos-complete-cycles-p nil + icicle-next-prefix-complete-cycles-p nil + icicle-default-directory default-directory + icicle-incremental-completion-p icicle-incremental-completion-flag + icicle-initial-value nil + icicle-cmd-reading-input this-command + icicle-last-completion-command nil + icicle-last-completion-candidate nil + icicle-last-input nil + icicle-input-fail-pos nil + icicle-saved-proxy-candidates nil + ;; `other-buffer' doesn't work, because it looks for a buffer only from the same frame. + icicle-pre-minibuffer-buffer (cadr (buffer-list)) ; $$$$$$ (other-buffer nil t) + ) + (when (and (icicle-completing-p) (> emacs-major-version 20)) + (let ((prompt-prefix (if icicle-candidate-action-fn "+ " ". "))) + (put-text-property 0 1 'face + (cond ((and icicle-candidate-action-fn (icicle-require-match-p)) + '(icicle-multi-command-completion icicle-mustmatch-completion)) + (icicle-candidate-action-fn 'icicle-multi-command-completion) + ((icicle-require-match-p) + '(icicle-completion icicle-mustmatch-completion)) + (t 'icicle-completion)) + prompt-prefix) + (if (overlayp icicle-completion-prompt-overlay) + (move-overlay icicle-completion-prompt-overlay (point-min) (point-min)) + (setq icicle-completion-prompt-overlay (make-overlay (point-min) (point-min)))) + (overlay-put icicle-completion-prompt-overlay 'before-string prompt-prefix))) + (unless icicle-add-proxy-candidates-flag + (setq icicle-saved-proxy-candidates (prog1 icicle-proxy-candidates + (setq icicle-proxy-candidates + icicle-saved-proxy-candidates)))) + (while icicle-saved-candidate-overlays + (delete-overlay (car icicle-saved-candidate-overlays)) + (setq icicle-saved-candidate-overlays (cdr icicle-saved-candidate-overlays))) + (icicle-update-ignored-extensions-regexp) + (when (memq icicle-default-value '(preselect-start preselect-end)) + (icicle-select-minibuffer-contents)) + (when (and icicle-show-Completions-initially-flag + (not icicle-progressive-completing-p) ; If narrowed, then we have already completed. + (icicle-completing-p) ; Function initializes variable `icicle-completing-p'. + (sit-for icicle-incremental-completion-delay)) ; Let user interrupt. + (case icicle-cycling-respects-completion-mode + (apropos (icicle-apropos-complete)) + (otherwise (icicle-prefix-complete)))) ; Prefix completion, by default. + (run-hooks 'icicle-minibuffer-setup-hook))) + +(defun icicle-define-cycling-keys (map) + "Define keys for cycling candidates." + ;; Cancel the alternatives not used now. + (cond (icicle-cycling-respects-completion-mode + ;; Cancel non-modal cycling keys. + (dolist (key icicle-prefix-cycle-previous-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-keys) + (define-key map key 'icicle-previous-candidate-per-mode)) + (dolist (key icicle-prefix-cycle-previous-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-action-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-previous-help-keys) (define-key map key nil)) + (dolist (key icicle-prefix-cycle-next-help-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-previous-help-keys) (define-key map key nil)) + (dolist (key icicle-apropos-cycle-next-help-keys) (define-key map key nil))) + (t + ;; Cancel modal cycling keys. + (dolist (key icicle-modal-cycle-up-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-alt-action-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-up-help-keys) (define-key map key nil)) + (dolist (key icicle-modal-cycle-down-help-keys) (define-key map key nil)))) + ;; Define the alternatives used now. + (cond (icicle-use-C-for-actions-flag ; Use `C-' for actions, no `C-' for plain cycling. + (cond (icicle-cycling-respects-completion-mode + ;; Define modal cycling keys. + (dolist (key icicle-modal-cycle-up-keys) + (define-key map key 'icicle-previous-candidate-per-mode)) ; `up' + (dolist (key icicle-modal-cycle-down-keys) + (define-key map key 'icicle-next-candidate-per-mode)) ; `down' + (dolist (key icicle-modal-cycle-up-action-keys) + (define-key map key 'icicle-previous-candidate-per-mode-action)) ; `C-up' + (dolist (key icicle-modal-cycle-down-action-keys) + (define-key map key 'icicle-next-candidate-per-mode-action))) ; `C-down' + (t + ;; Define non-modal cycling keys. + (dolist (key icicle-prefix-cycle-previous-keys) + (define-key map key 'icicle-previous-prefix-candidate)) ; `up' + (dolist (key icicle-prefix-cycle-next-keys) + (define-key map key 'icicle-next-prefix-candidate)) ; `down' + (dolist (key icicle-apropos-cycle-previous-keys) + (define-key map key 'icicle-previous-apropos-candidate)) ; `prior' + (dolist (key icicle-apropos-cycle-next-keys) + (define-key map key 'icicle-next-apropos-candidate)) ; `next' + (dolist (key icicle-prefix-cycle-previous-action-keys) + (define-key map key 'icicle-previous-prefix-candidate-action)) ; `C-up' + (dolist (key icicle-prefix-cycle-next-action-keys) + (define-key map key 'icicle-next-prefix-candidate-action)) ; `C-down' + (dolist (key icicle-apropos-cycle-previous-action-keys) + (define-key map key 'icicle-previous-apropos-candidate-action)) ; `C-prior' + (dolist (key icicle-apropos-cycle-next-action-keys) + (define-key map key 'icicle-next-apropos-candidate-action))))) ; `C-next' + (t ; Use `C-' for plain cycling, NO `C-' for action. + (cond (icicle-cycling-respects-completion-mode + ;; Define modal cycling keys. + (dolist (key icicle-modal-cycle-up-keys) + (define-key map key 'icicle-previous-candidate-per-mode-action)) ; `up' + (dolist (key icicle-modal-cycle-down-keys) + (define-key map key 'icicle-next-candidate-per-mode-action)) ; `down' + (dolist (key icicle-modal-cycle-up-action-keys) + (define-key map key 'icicle-previous-candidate-per-mode)) ; `C-up' + (dolist (key icicle-modal-cycle-down-action-keys) + (define-key map key 'icicle-next-candidate-per-mode))) ; `C-down' + (t + ;; Define non-modal cycling keys. + (dolist (key icicle-prefix-cycle-previous-keys) + (define-key map key 'icicle-previous-prefix-candidate-action)) ; `up' + (dolist (key icicle-prefix-cycle-next-keys) + (define-key map key 'icicle-next-prefix-candidate-action)) ; `down' + (dolist (key icicle-apropos-cycle-previous-keys) + (define-key map key 'icicle-previous-apropos-candidate-action)) ; `prior' + (dolist (key icicle-apropos-cycle-next-keys) + (define-key map key 'icicle-next-apropos-candidate-action)) ; `next' + (dolist (key icicle-prefix-cycle-previous-action-keys) + (define-key map key 'icicle-previous-prefix-candidate)) ; `C-up' + (dolist (key icicle-prefix-cycle-next-action-keys) + (define-key map key 'icicle-next-prefix-candidate)) ; `C-down' + (dolist (key icicle-apropos-cycle-previous-action-keys) + (define-key map key 'icicle-previous-apropos-candidate)) ; `C-prior' + (dolist (key icicle-apropos-cycle-next-action-keys) + (define-key map key 'icicle-next-apropos-candidate)))))) + ;; Help and alternative-action keys are not controlled by `icicle-use-C-for-actions-flag'. + (cond (icicle-cycling-respects-completion-mode + ;; Define modal cycling help and alternative action keys. + (dolist (key icicle-modal-cycle-up-help-keys) + (define-key map key 'icicle-previous-candidate-per-mode-help)) ; `C-M-up' + (dolist (key icicle-modal-cycle-down-help-keys) + (define-key map key 'icicle-next-candidate-per-mode-help)) ; `C-M-down' + (dolist (key icicle-modal-cycle-up-alt-action-keys) + (define-key map key 'icicle-previous-candidate-per-mode-alt-action)) ; `C-S-up' + (dolist (key icicle-modal-cycle-down-alt-action-keys) + (define-key map key 'icicle-next-candidate-per-mode-alt-action))) ; `C-S-down' + (t + ;; Define NON-modal cycling help and alternative action keys. + (dolist (key icicle-prefix-cycle-previous-help-keys) + (define-key map key 'icicle-help-on-previous-prefix-candidate)) ; `C-M-up' + (dolist (key icicle-prefix-cycle-next-help-keys) + (define-key map key 'icicle-help-on-next-prefix-candidate)) ; `C-M-down' + (dolist (key icicle-apropos-cycle-previous-help-keys) + (define-key map key 'icicle-help-on-previous-apropos-candidate)) ; `C-M-prior' + (dolist (key icicle-apropos-cycle-next-help-keys) + (define-key map key 'icicle-help-on-next-apropos-candidate)) ; `C-M-next' + (dolist (key icicle-prefix-cycle-previous-alt-action-keys) + (define-key map key 'icicle-previous-prefix-candidate-alt-action)) ; `C-S-up' + (dolist (key icicle-prefix-cycle-next-alt-action-keys) + (define-key map key 'icicle-next-prefix-candidate-alt-action)) ; `C-S-down' + (dolist (key icicle-apropos-cycle-previous-alt-action-keys) + (define-key map key 'icicle-previous-apropos-candidate-alt-action)) ; `C-S-prior' + (dolist (key icicle-apropos-cycle-next-alt-action-keys) + (define-key map key 'icicle-next-apropos-candidate-alt-action))))) ; `C-S-next' + +(defun icicle-select-minibuffer-contents () + "Select minibuffer contents and leave point at its beginning." + (let ((min (icicle-minibuffer-prompt-end))) + (set-mark (if (eq 'preselect-start icicle-default-value) (point-max) min)) + (goto-char (if (eq 'preselect-start icicle-default-value) min (point-max))))) + +;; $$$ (defadvice next-history-element (after icicle-select-minibuffer-contents activate) +;; "Select minibuffer contents and leave point at its beginning." +;; (when (and icicle-mode (memq icicle-default-value '(preselect-start preselect-end))) +;; (icicle-select-minibuffer-contents) +;; (setq deactivate-mark nil))) + +(defun icicle-cancel-Help-redirection () + "Cancel redirection of focus from *Help* buffer to minibuffer. +Focus was redirected during `icicle-help-on-candidate'." + (let* ((help-window (get-buffer-window "*Help*" 0)) + (help-frame (and help-window (window-frame help-window)))) + (when help-frame (redirect-frame-focus help-frame)))) + +(defun icicle-run-icicle-pre-command-hook () + "Run `icicle-pre-command-hook' functions. +Used in `pre-command-hook'." + (run-hooks 'icicle-pre-command-hook)) + +(defun icicle-run-icicle-post-command-hook () + "Run `icicle-post-command-hook' functions. +Used in `post-command-hook'." + (run-hooks 'icicle-post-command-hook)) + +(defun icicle-set-calling-cmd () + "Remember last command that called for completion. +Used in `completion-setup-hook'." + (setq icicle-cmd-calling-for-completion this-command)) + +(defun icicle-update-ignored-extensions-regexp () + "Update ignored extensions if `completion-ignored-extensions' changed." + (when (and (icicle-file-name-input-p) ; Defined in `icicles-fn.el'. + (not (equal icicle-ignored-extensions completion-ignored-extensions))) + (setq icicle-ignored-extensions-regexp ; Make regexp for ignored file extensions. + (concat "\\(" (mapconcat #'regexp-quote completion-ignored-extensions "\\|") "\\)\\'") + + ;; Flag to prevent updating `icicle-ignored-extensions-regexp' unless + ;; `completion-ignored-extensions' changes. + icicle-ignored-extensions completion-ignored-extensions))) + +;; We change the region background here dynamically. +;; It would be better to just use a buffer-local face, but those don't yet exist. +(defun icicle-restore-region-face () + "Restore region face. It was changed during minibuffer activity +if `icicle-change-region-background-flag' is non-nil." + (when (and icicle-change-region-background-flag (= 1 (recursion-depth))) + (set-face-background 'region icicle-saved-region-background))) + +(defun icicle-activate-mark () + "Prevent region from being deactivated. Use in `icicle-post-command-hook'." + (when (and (window-minibuffer-p (selected-window)) + icicle-completing-p + (not executing-kbd-macro)) + (setq deactivate-mark nil))) + +(defun icicle-redefine-standard-commands () + "Replace some standard Emacs functions and menus with Icicles versions. +No such replacement is done if option +`icicle-redefine-standard-commands-flag' is nil." + (when (and (fboundp 'icicle-completing-read) icicle-redefine-standard-commands-flag) + (when (fboundp 'old-bbdb-complete-name) + (defalias 'bbdb-complete-name 'icicle-bbdb-complete-name)) + (when (fboundp 'old-comint-dynamic-complete) + (defalias 'comint-dynamic-complete 'icicle-comint-dynamic-complete)) + (when (fboundp 'old-comint-dynamic-complete-filename) + (defalias 'comint-dynamic-complete-filename 'icicle-comint-dynamic-complete-filename)) + (when (fboundp 'old-comint-replace-by-expanded-filename) + (defalias 'comint-replace-by-expanded-filename 'icicle-comint-replace-by-expanded-filename)) + (when (fboundp 'old-ess-complete-object-name) + (defalias 'ess-complete-object-name 'icicle-ess-complete-object-name)) + (when (fboundp 'old-gud-gdb-complete-command) + (defalias 'gud-gdb-complete-command 'icicle-gud-gdb-complete-command)) + (when (fboundp 'old-dired-read-shell-command) + (defalias 'dired-read-shell-command 'icicle-dired-read-shell-command)) + (when (fboundp 'old-read-shell-command) + (defalias 'read-shell-command 'icicle-read-shell-command)) + (when (fboundp 'old-recentf-make-menu-items) + (defalias 'recentf-make-menu-items 'icicle-recentf-make-menu-items)) + (defalias 'customize-apropos 'icicle-customize-apropos) + (defalias 'customize-apropos-faces 'icicle-customize-apropos-faces) + (defalias 'customize-apropos-groups 'icicle-customize-apropos-groups) + (defalias 'customize-apropos-options 'icicle-customize-apropos-options) + (when (fboundp 'old-customize-apropos-options-of-type) + (defalias 'customize-apropos-options-of-type 'icicle-customize-apropos-options-of-type)) + (defalias 'customize-face 'icicle-customize-face) + (defalias 'customize-face-other-window 'icicle-customize-face-other-window) + (defalias 'dabbrev-completion 'icicle-dabbrev-completion) + (defalias 'lisp-complete-symbol 'icicle-lisp-complete-symbol) + (when (fboundp 'old-minibuffer-default-add-completions) + (defalias 'minibuffer-default-add-completions 'icicle-minibuffer-default-add-completions)) + (defalias 'read-from-minibuffer 'icicle-read-from-minibuffer) + (defalias 'read-string 'icicle-read-string) + (defalias 'repeat-complex-command 'icicle-repeat-complex-command) + )) + +(defun icicle-restore-standard-commands () + "Restore standard Emacs functions replaced in Icicle mode. +See `icicle-redefine-standard-commands'." + (when (and (fboundp 'old-completing-read) icicle-redefine-standard-commands-flag) + (when (fboundp 'old-bbdb-complete-name) + (defalias 'bbdb-complete-name 'old-bbdb-complete-name)) + (when (fboundp 'old-comint-dynamic-complete) + (defalias 'comint-dynamic-complete 'old-comint-dynamic-complete)) + (when (fboundp 'old-comint-dynamic-complete-filename) + (defalias 'comint-dynamic-complete-filename 'old-comint-dynamic-complete-filename)) + (when (fboundp 'old-comint-replace-by-expanded-filename) + (defalias 'comint-replace-by-expanded-filename 'old-comint-replace-by-expanded-filename)) + (when (fboundp 'old-ess-complete-object-name) + (defalias 'ess-complete-object-name 'old-ess-complete-object-name)) + (when (fboundp 'old-gud-gdb-complete-command) + (defalias 'gud-gdb-complete-command 'old-gud-gdb-complete-command)) + (when (fboundp 'old-dired-read-shell-command) + (defalias 'dired-read-shell-command 'old-dired-read-shell-command)) + (when (fboundp 'old-read-shell-command) + (defalias 'read-shell-command 'old-read-shell-command)) + (when (fboundp 'old-recentf-make-menu-items) + (defalias 'recentf-make-menu-items 'old-recentf-make-menu-items)) + (defalias 'customize-apropos 'old-customize-apropos) + (defalias 'customize-apropos-faces 'old-customize-apropos-faces) + (defalias 'customize-apropos-groups 'old-customize-apropos-groups) + (defalias 'customize-apropos-options 'old-customize-apropos-options) + (when (fboundp 'old-customize-apropos-options-of-type) + (defalias 'customize-apropos-options-of-type 'old-customize-apropos-options-of-type)) + (defalias 'customize-face 'old-customize-face) + (defalias 'customize-face-other-window 'old-customize-face-other-window) + (defalias 'dabbrev-completion 'old-dabbrev-completion) + (defalias 'lisp-complete-symbol 'old-lisp-complete-symbol) + (when (fboundp 'old-minibuffer-default-add-completions) + (defalias 'minibuffer-default-add-completions 'old-minibuffer-default-add-completions)) + (defalias 'read-from-minibuffer 'old-read-from-minibuffer) + (defalias 'read-string 'old-read-string) + (defalias 'repeat-complex-command 'old-repeat-complex-command) + )) + +;;; In Emacs versions before 22: +;;; Save original `read-file-name'. We redefine it as `icicle-read-file-name' (which calls it). +;;; Then we restore it when you quit Icicle mode. (In Emacs 22+, no redefinition is needed.) +(unless (or (boundp 'read-file-name-function) (fboundp 'orig-read-file-name)) +(defalias 'orig-read-file-name (symbol-function 'read-file-name))) + +(defun icicle-redefine-std-completion-fns () + "Replace some standard functions with versions for Icicle mode." + (when (fboundp 'icicle-completing-read) + (defalias 'choose-completion 'icicle-choose-completion) + (defalias 'choose-completion-string 'icicle-choose-completion-string) + (defalias 'completing-read 'icicle-completing-read) + (defalias 'completion-setup-function 'icicle-completion-setup-function) + (unless (> emacs-major-version 22) + (defalias 'dired-smart-shell-command 'icicle-dired-smart-shell-command)) + (defalias 'display-completion-list 'icicle-display-completion-list) + (defalias 'exit-minibuffer 'icicle-exit-minibuffer) + (when (fboundp 'face-valid-attribute-values) + (defalias 'face-valid-attribute-values 'icicle-face-valid-attribute-values)) + (defalias 'minibuffer-complete-and-exit 'icicle-minibuffer-complete-and-exit) + (defalias 'mouse-choose-completion 'icicle-mouse-choose-completion) + (defalias 'next-history-element 'icicle-next-history-element) + (defalias 'read-face-name 'icicle-read-face-name) + (if (boundp 'read-file-name-function) ; Emacs 22+ + (setq icicle-old-read-file-name-fn (prog1 (and (not (eq read-file-name-function + 'icicle-read-file-name)) + read-file-name-function) + (setq read-file-name-function + 'icicle-read-file-name))) + (defalias 'read-file-name 'icicle-read-file-name)) ; Emacs 20, 21 + (when (fboundp 'icicle-read-number) + (defalias 'read-number 'icicle-read-number)) + (unless (> emacs-major-version 22) + (defalias 'shell-command 'icicle-shell-command)) + (unless (> emacs-major-version 22) + (defalias 'shell-command-on-region 'icicle-shell-command-on-region)) + (defalias 'switch-to-completions 'icicle-switch-to-completions) + (when (fboundp 'icicle-completing-read-multiple) + (defalias 'completing-read-multiple 'icicle-completing-read-multiple) + (setq crm-local-completion-map icicle-crm-local-completion-map + crm-local-must-match-map icicle-crm-local-must-match-map)) + (when (> emacs-major-version 22) + (defalias 'sit-for 'icicle-sit-for)) + )) + +(defun icicle-restore-std-completion-fns () + "Restore some standard functions that were replaced in Icicle mode." + (when (fboundp 'old-completing-read) + (defalias 'choose-completion 'old-choose-completion) + (defalias 'choose-completion-string 'old-choose-completion-string) + (defalias 'completing-read 'old-completing-read) + (defalias 'completion-setup-function 'old-completion-setup-function) + (when (fboundp 'old-dired-smart-shell-command) ; Emacs 23 + (defalias 'dired-smart-shell-command 'old-dired-smart-shell-command)) + (defalias 'display-completion-list 'old-display-completion-list) + (defalias 'exit-minibuffer 'old-exit-minibuffer) + (when (fboundp 'old-face-valid-attribute-values) + (defalias 'face-valid-attribute-values 'old-face-valid-attribute-values)) + (defalias 'minibuffer-complete-and-exit 'old-minibuffer-complete-and-exit) + (defalias 'mouse-choose-completion 'old-mouse-choose-completion) + (defalias 'next-history-element 'old-next-history-element) + (defalias 'read-face-name 'old-read-face-name) + (if (boundp 'read-file-name-function) ; Emacs 22+ + (setq read-file-name-function (and (not (eq icicle-old-read-file-name-fn + 'icicle-read-file-name)) + icicle-old-read-file-name-fn)) + (defalias 'read-file-name 'orig-read-file-name)) ; Emacs 20, 21 + (when (fboundp 'old-read-number) + (defalias 'read-number 'old-read-number)) + (when (fboundp 'old-shell-command) ; Emacs 23 + (defalias 'shell-command 'old-shell-command)) + (when (fboundp 'old-shell-command-on-region) ; Emacs 23 + (defalias 'shell-command-on-region 'old-shell-command-on-region)) + (defalias 'switch-to-completions 'old-switch-to-completions) + (when (fboundp 'old-completing-read-multiple) + (defalias 'completing-read-multiple 'old-completing-read-multiple) + (setq crm-local-completion-map old-crm-local-completion-map + crm-local-must-match-map old-crm-local-must-match-map)) + (when (> emacs-major-version 22) + (defalias 'sit-for 'old-sit-for)) + )) + +;; Free vars here: `icicle-saved-kmacro-ring-max' is bound in `icicles-var.el'. +(defun icicle-redefine-standard-options () + "Replace certain standard Emacs options with Icicles versions." + (when (boundp 'icicle-search-ring-max) + (setq icicle-saved-search-ring-max search-ring-max ; Save it. + search-ring-max icicle-search-ring-max + icicle-saved-regexp-search-ring-max regexp-search-ring-max ; Save it. + regexp-search-ring-max icicle-regexp-search-ring-max)) + (when (boundp 'icicle-kmacro-ring-max) + (setq icicle-saved-kmacro-ring-max kmacro-ring-max ; Save it. + kmacro-ring-max icicle-kmacro-ring-max))) + +(defun icicle-restore-standard-options () + "Restore standard Emacs options replaced in Icicle mode." + (when (boundp 'icicle-saved-search-ring-max) + (setq search-ring-max icicle-saved-search-ring-max + regexp-search-ring-max icicle-saved-regexp-search-ring-max))) + +;; This is used only in Emacs 22+, but we define it always anyway. +(defun icicle-undo-std-completion-faces () + "Get rid of standard completion-root highlighting in *Completions*." + ;; Do this because the standard Emacs 22 highlighting can interfere with + ;; apropos-completion highlighting. + (when (fboundp 'face-spec-reset-face) + (when (facep 'completions-common-part) + (face-spec-reset-face 'completions-common-part) + (set-face-attribute 'completions-common-part nil :inherit nil)) + (when (facep 'completions-first-difference) + (face-spec-reset-face 'completions-first-difference) + (set-face-attribute 'completions-first-difference nil :inherit nil)))) + +;; Save original functions, so they can be restored when leave Icicle mode. +;; If load the original library when in Icicle mode, toggle the mode to +;; pick up the original defn. + +(eval-after-load "comint" ; `comint-dynamic-complete', + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) ; `comint-replace-by-expanded-filename' + (when icyp (icicle-mode -1)) + (when (and (fboundp 'comint-dynamic-complete) (not (fboundp 'old-comint-dynamic-complete))) +(defalias 'old-comint-dynamic-complete (symbol-function 'comint-dynamic-complete))) + (when (and (fboundp 'comint-replace-by-expanded-filename) + (not (fboundp 'old-comint-replace-by-expanded-filename))) +(defalias 'old-comint-replace-by-expanded-filename + (symbol-function 'comint-replace-by-expanded-filename))) + (when icyp (icicle-mode 1))))) + +(eval-after-load "ess-site" ; `ess-complete-object-name' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'ess-complete-object-name) (not (fboundp 'old-ess-complete-object-name))) +(defalias 'old-ess-complete-object-name (symbol-function 'ess-complete-object-name))) + (when icyp (icicle-mode 1))))) + +(eval-after-load "gud" ; `gud-gdb-complete-command' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'gud-gdb-complete-command) (not (fboundp 'old-gud-gdb-complete-command))) +(defalias 'old-gud-gdb-complete-command (symbol-function 'gud-gdb-complete-command))) + (when icyp (icicle-mode 1))))) + +(eval-after-load "bbdb-com" ; `bbdb-complete-name' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'bbdb-complete-name) (not (fboundp 'old-bbdb-complete-name))) +(defalias 'old-bbdb-complete-name (symbol-function 'bbdb-complete-name))) + (when icyp (icicle-mode 1))))) + +(eval-after-load "dired-x" ; `dired-read-shell-command' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'dired-read-shell-command) (not (fboundp 'old-dired-read-shell-command))) +(defalias 'old-dired-read-shell-command (symbol-function 'dired-read-shell-command))) + (unless (fboundp 'read-shell-command) ; Emacs < 23. + (when (and (fboundp 'dired-smart-shell-command) + (not (fboundp 'old-dired-smart-shell-command))) +(defalias 'old-dired-smart-shell-command (symbol-function 'dired-smart-shell-command)))) + (when icyp (icicle-mode 1))))) + +(eval-after-load "dired-aux" ; `dired-read-shell-command' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'dired-read-shell-command) (not (fboundp 'old-dired-read-shell-command))) +(defalias 'old-dired-read-shell-command (symbol-function 'dired-read-shell-command))) + (when icyp (icicle-mode 1))))) + +;; (when (> emacs-major-version 22) ; Not needed - `simple.el' is preloaded. +;; (eval-after-load "simple" ; `read-shell-command' +;; '(when (featurep 'icicles-mode) +;; (let ((icyp icicle-mode)) +;; (when icyp (icicle-mode -1)) +;; (when (and (fboundp 'read-shell-command) ; Defined in Emacs 23. +;; (not (fboundp 'old-read-shell-command))) +;; (defalias 'old-read-shell-command (symbol-function 'read-shell-command))) +;; (when icyp (icicle-mode 1)))))) + +(eval-after-load "recentf" ; `recentf' + '(when (featurep 'icicles-mode) + (let ((icyp icicle-mode)) + (when icyp (icicle-mode -1)) + (when (and (fboundp 'recentf-make-menu-items) (not (fboundp 'old-recentf-make-menu-items))) +(defalias 'old-recentf-make-menu-items (symbol-function 'recentf-make-menu-items))) + (when icyp (icicle-mode 1))))) + + +;; When these libraries are first loaded, toggle Icicle mode to pick up the definitions +(dolist (library '("bookmark+" "buff-menu" "comint" "dired" "ess-site" "gud" "ibuffer" + "idlw-shell" ; (untested - I don't have an `idl' program) + "ielm" "info" "net-utils" "rlogin" "shell" "sh-script" "tcl")) + (unless (if (fboundp 'load-history-regexp) ; Emacs 22+ + (load-history-filename-element (load-history-regexp library)) + (assoc library load-history)) + (eval-after-load library + '(when (featurep 'icicles-mode) (icicle-toggle-icicle-mode-twice))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-mode) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-mode.el ends here diff --git a/.emacs.d/icicles/icicles-opt.el b/.emacs.d/icicles/icicles-opt.el new file mode 100644 index 0000000..7182cd8 --- /dev/null +++ b/.emacs.d/icicles/icicles-opt.el @@ -0,0 +1,3209 @@ +;;; icicles-opt.el --- User options (variables) for Icicles +;; +;; Filename: icicles-opt.el +;; Description: User options (variables) for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:22:14 2006 +;; Version: 22.0 +;; Last-Updated: Sat Jul 17 14:31:19 2010 (-0700) +;; By: dradams +;; Update #: 3745 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-opt.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: +;; +;; `cl', `el-swank-fuzzy', `ffap', `ffap-', `fuzzy-match', +;; `hexrgb', `icicles-face', `kmacro', `levenshtein', `thingatpt', +;; `thingatpt+', `wid-edit', `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; user options (variables). For Icicles documentation, see +;; `icicles-doc1.el' and `icicles-doc2.el'. +;; +;; Widgets defined here: +;; +;; `icicle-key-definition'. +;; +;; Constants defined here: +;; +;; `icicle-anychar-regexp'. +;; +;; User options defined here (in Custom group `Icicles'): +;; +;; `icicle-act-before-cycle-flag', +;; `icicle-add-proxy-candidates-flag', +;; `icicle-alternative-actions-alist', +;; `icicle-alternative-sort-comparer', +;; `icicle-apropos-complete-keys', +;; `icicle-apropos-complete-no-display-keys', +;; `icicle-apropos-cycle-next-keys', +;; `icicle-apropos-cycle-next-action-keys', +;; `icicle-apropos-cycle-next-alt-action-keys', +;; `icicle-apropos-cycle-next-help-keys', +;; `icicle-apropos-cycle-previous-keys', +;; `icicle-apropos-cycle-previous-action-keys', +;; `icicle-apropos-cycle-previous-alt-action-keys', +;; `icicle-apropos-cycle-previous-help-keys', +;; `icicle-anything-transform-candidates-flag', +;; `icicle-bookmark-name-length-max', +;; `icicle-bookmark-refresh-cache-flag', `icicle-buffer-configs', +;; `icicle-buffer-extras', +;; `icicle-buffer-ignore-space-prefix-flag', +;; `icicle-buffer-match-regexp', `icicle-buffer-no-match-regexp', +;; `icicle-buffer-predicate', `icicle-buffer-require-match-flag' +;; `icicle-buffer-sort', `icicle-buffers-ido-like-flag', +;; `icicle-candidate-width-factor', +;; `icicle-change-region-background-flag', +;; `icicle-change-sort-order-completion-flag', +;; `icicle-C-l-uses-completion-flag', `icicle-color-themes', +;; `icicle-comint-dynamic-complete-replacements', +;; `icicle-command-abbrev-alist', +;; `icicle-command-abbrev-match-all-parts-flag', +;; `icicle-command-abbrev-priority-flag', +;; `icicle-complete-key-anyway-flag', +;; `icicle-complete-keys-self-insert-flag', +;; `icicle-completing-read+insert-keys', +;; `icicle-completion-history-max-length', +;; `icicle-Completions-display-min-input-chars', +;; `icicle-completions-format', +;; `icicle-Completions-frame-at-right-flag', +;; `icicle-Completions-text-scale-decrease', +;; `icicle-Completions-window-max-height', +;; `icicle-customize-save-flag', +;; `icicle-customize-save-variable-function', +;; `icicle-cycle-into-subdirs-flag', +;; `icicle-cycling-respects-completion-mode', +;; `icicle-default-thing-insertion', `icicle-default-value', +;; `icicle-define-alias-commands-flag', +;; `icicle-deletion-action-flag', `icicle-dot-show-regexp-flag', +;; `icicle-dot-string', `icicle-expand-input-to-common-match-flag', +;; `icicle-file-extras', `icicle-file-match-regexp', +;; `icicle-file-no-match-regexp', `icicle-file-predicate', +;; `icicle-file-require-match-flag', `icicle-file-sort', +;; `icicle-files-ido-like-flag', +;; `icicle-filesets-as-saved-completion-sets-flag', +;; `icicle-guess-commands-in-path', +;; `icicle-help-in-mode-line-flag', +;; `icicle-hide-common-match-in-Completions-flag', +;; `icicle-highlight-historical-candidates-flag', +;; `icicle-highlight-input-completion-failure', +;; `icicle-highlight-input-completion-failure-delay', +;; `icicle-highlight-input-completion-failure-threshold', +;; `icicle-highlight-input-initial-whitespace-flag', +;; `icicle-highlight-lighter-flag', `icicle-ignored-directories', +;; `icicle-ignore-space-prefix-flag', +;; `icicle-incremental-completion-delay', +;; `icicle-incremental-completion-flag', +;; `icicle-incremental-completion-threshold', +;; `icicle-inhibit-advice-functions', `icicle-inhibit-ding-flag', +;; `icicle-input-string', `icicle-inter-candidates-min-spaces', +;; `icicle-isearch-complete-keys', `icicle-key-complete-keys', +;; `icicle-key-descriptions-use-<>-flag', +;; `icicle-key-descriptions-use-angle-brackets-flag', +;; `icicle-keymaps-for-key-completion', `icicle-kmacro-ring-max', +;; `icicle-levenshtein-distance', `icicle-list-end-string', +;; `icicle-list-join-string', `icicle-list-nth-parts-join-string', +;; `icicle-mark-position-in-candidate', `icicle-max-candidates', +;; `icicle-menu-items-to-history-flag', +;; `icicle-minibuffer-setup-hook', `icicle-modal-cycle-down-keys', +;; `icicle-modal-cycle-down-action-keys', +;; `icicle-modal-cycle-down-alt-action-keys', +;; `icicle-modal-cycle-down-help-keys', +;; `icicle-modal-cycle-up-keys', +;; `icicle-modal-cycle-up-action-keys', +;; `icicle-modal-cycle-up-alt-action-keys', +;; `icicle-modal-cycle-up-help-keys', `icicle-no-match-hook', +;; `icicle-option-type-prefix-arg-list', +;; `icicle-point-position-in-candidate', +;; `icicle-populate-interactive-history-flag', +;; `icicle-pp-eval-expression-print-length', +;; `icicle-pp-eval-expression-print-level', +;; `icicle-prefix-complete-keys', +;; `icicle-prefix-complete-no-display-keys', +;; `icicle-prefix-cycle-next-keys', +;; `icicle-prefix-cycle-next-action-keys', +;; `icicle-prefix-cycle-next-alt-action-keys', +;; `icicle-prefix-cycle-next-help-keys', +;; `icicle-prefix-cycle-previous-keys', +;; `icicle-prefix-cycle-previous-action-keys', +;; `icicle-prefix-cycle-previous-alt-action-keys', +;; `icicle-prefix-cycle-previous-help-keys', +;; `icicle-previous-candidate-keys', +;; `icicle-quote-shell-file-name-flag', +;; `icicle-read+insert-file-name-keys', +;; `icicle-redefine-standard-commands-flag', +;; `icicle-regexp-quote-flag', `icicle-regexp-search-ring-max', +;; `icicle-region-background', `icicle-require-match-flag', +;; `icicle-saved-completion-sets', `icicle-search-cleanup-flag', +;; `icicle-search-context-match-predicate', +;; `icicle-search-from-isearch-keys', +;; `icicle-search-highlight-all-current-flag', +;; `icicle-search-highlight-context-levels-flag', +;; `icicle-search-highlight-threshold', `icicle-search-hook', +;; `icicle-search-replace-common-match-flag', +;; `icicle-search-replace-literally-flag', +;; `icicle-search-replace-whole-candidate-flag', +;; `icicle-search-ring-max', `icicle-search-whole-word-flag', +;; `icicle-shell-command-candidates-cache', +;; `icicle-show-Completions-help-flag', +;; `icicle-show-Completions-initially-flag', +;; `icicle-show-multi-completion-flag', `icicle-sort-comparer', +;; `icicle-sort-orders-alist', `icicle-special-candidate-regexp', +;; `icicle-S-TAB-completion-methods-alist', +;; `icicle-swank-prefix-length', `icicle-swank-timeout', +;; `icicle-TAB-completion-methods', +;; `icicle-TAB-shows-candidates-flag', +;; `icicle-test-for-remote-files-flag', +;; `icicle-thing-at-point-functions', +;; `icicle-top-level-key-bindings', +;; `icicle-top-level-when-sole-completion-delay', +;; `icicle-top-level-when-sole-completion-flag', +;; `icicle-touche-pas-aux-menus-flag', `icicle-transform-function', +;; `icicle-type-actions-alist', +;; `icicle-unpropertize-completion-result-flag', +;; `icicle-update-input-hook', `icicle-use-~-for-home-dir-flag', +;; `icicle-use-C-for-actions-flag', +;; `icicle-use-anything-candidates-flag', +;; `icicle-use-candidates-only-once-flag', +;; `icicle-word-completion-keys', +;; `icicle-WYSIWYG-Completions-flag', `icicle-yank-function'. +;; +;; Functions defined here: +;; +;; `icicle-bind-top-level-commands', +;; `icicle-buffer-sort-*...*-last', +;; `icicle-compute-shell-command-candidates', +;; `icicle-increment-color-value', `icicle-remap'. +;; +;; For descriptions of changes to this file, see `icicles-chg.el'. +;; +;; Note: Occasionally I have renamed or removed an Icicles option. +;; If you have customized such an option, then your customization +;; will no longer have any effect. With the exception of options +;; `icicle-mode' and `icicle-mode-hook', library `icicles-opt.el' +;; always contains the complete set of Icicles options. If your +;; custom file or init file contains an Icicles option that is not +;; listed above, then you can remove it because it is obsolete. + +;;(@> "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. +;; +;; (@> "User options, organized alphabetically, except for dependencies") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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: + +(require 'hexrgb nil t) ;; (no error if not found): hexrgb-color-values-to-hex, + ;; hexrgb-increment-(red|green|blue), hexrgb-rgb-to-hsv, + ;; hexrgb-color-values-to-hex, hexrgb-hsv-to-rgb +(require 'thingatpt) ;; symbol-at-point, thing-at-point, thing-at-point-url-at-point, +(require 'thingatpt+ nil t) ;; (no error if not found): symbol-name-nearest-point, + ;; word-nearest-point +(require 'icicles-face) ;; icicle-increment-color-hue. + +;; Quiet the byte-compiler. +(defvar shell-completion-execonly) ; In `shell.el'. + +(defvar icicle-mode-map) +(defvar icicle-dot-string-internal) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "User options, organized alphabetically, except for dependencies") + +;;; User options, organized alphabetically, except for dependencies -- + +;;;###autoload +(defcustom icicle-act-before-cycle-flag nil + "*Non-nil means act on current candidate, then cycle to next/previous. +Otherwise (nil), cycle to the next or previous candidate, and then act +on it. + +This affects keys such as the following\\: +`C-down', `C-up', `C-next', `C-prior', \ +`\\[icicle-help-on-next-prefix-candidate]', `\\[icicle-help-on-previous-prefix-candidate]', +`\\[icicle-help-on-next-apropos-candidate]', `\\[icicle-help-on-previous-apropos-candidate]', \ +`\\[icicle-next-prefix-candidate-alt-action]', \ +`\\[icicle-previous-prefix-candidate-alt-action]', \ +`\\[icicle-next-apropos-candidate-alt-action]', and +`\\[icicle-previous-apropos-candidate-alt-action]'. + +Note: A few Icicles commands ignore this setting, in order to \"do the +right thing\"." + :type 'boolean :group 'Icicles-Key-Bindings :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-add-proxy-candidates-flag nil ; Toggle with `C-M-_'. + "*Non-nil means to include proxy candidates whenever possible. +A proxy candidate is a special candidate (shown in *Completions* using +face `icicle-special-candidate') whose name is a placeholder for the +real candidate. The proxy candidate typically stands for some value +obtained from the cursor position or by some action such as clicking +the mouse. Example candidates include a color or file name, named by +proxy candidates such as `*copied foreground*' or `*file at point*'. + +You can toggle this option at any time from the minibuffer using +`\\\\[icicle-toggle-proxy-candidates]'. However, for \ +commands that provide many proxy candidates, if +the flag is off initially when input is read, then you must re-invoke +the completing command for the new value to take effect. (This is for +performance reasons.)" + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-alternative-actions-alist () + "*Alist of Emacs commands and alternative action functions. +This always overrides any alternative action defined by +`icicle-candidate-alt-action-fn'. + +Each alist element has the form (COMMAND . FUNCTION), where COMMAND is +a command (a symbol) that reads input and FUNCTION is the +alternative-action function it uses. To disable alternative action +for a given command, use `ignore' as the FUNCTION. + +This option has no effect on `icicle-all-candidates-list-alt-action', +that is, `M-|', but it does affect `C-|'." + :type '(alist + :key-type (symbol :tag "Command") + :value-type (function :tag "Alternative action (function)")) + :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-alternative-sort-comparer ; Toggle with `C-M-,'. + 'icicle-historical-alphabetic-p + "*An alternative sort function, in place of `icicle-sort-comparer'. +You can swap this with `icicle-sort-comparer' at any time by using +`icicle-toggle-alternative-sorting' (\\\ +`\\[icicle-toggle-alternative-sorting]' in the minibuffer)." + :type '(choice (const :tag "None" nil) function) :group 'Icicles-Completions-Display) + +;; Must be before `icicle-dot-string'. +(defconst icicle-anychar-regexp (let ((strg (copy-sequence "\\(.\\|[\n]\\)"))) + (set-text-properties 0 (length strg) + '(display "." face highlight) + strg) + strg) + "Regexp that matches any single character, including newline.") + +;;;###autoload +(defcustom icicle-anything-transform-candidates-flag nil + "*Non-nil means `icicle-anything' transforms completion candidates. +Function `anything-transform-candidates' is used for the transforming. + +The advantage of a nil value is that `icicle-anything' then acts as a +multi-command: you can act on multiple candidates, or apply multiple +actions for the same candidate, within a single invocation of +`icicle-anything' (or related commands). + +The advantage of a non-nil value is that some of the displayed +Anything candidates might be more readable. + +This option has no effect if library `anything.el' cannot be loaded." + :type 'boolean :group 'Icicles-Completions-Display :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-apropos-complete-keys '([S-tab] [S-iso-lefttab]) + ;; In Emacs 22 and later, `backtab' is the canonical key that represents both `S-tab' and + ;; `S-iso-lefttab', so in principle that could be used in the default value for Emacs 22+. + ;; + ;; In other words, the following should be sufficient: + ;; (if (> emacs-major-version 21) + ;; '([backtab]) + ;; '([S-tab] [S-iso-lefttab])) + ;; + ;; However, some Emacs 22+ libraries, such as `info.el', are brain-dead and explicitly + ;; bind both `backtab' and `S-tab'. I filed Emacs bug #1281. + "*Key sequences to use for `icicle-apropos-complete'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards - for example, `S-tab' and `S-iso-lefttab'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-complete-no-display-keys '([C-M-S-tab] [C-M-S-iso-lefttab]) + "*Key sequences to use for `icicle-apropos-complete-no-display'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards - for example, `C-M-S-tab' and `C-M-S-iso-lefttab'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-next-keys '([next]) + "*Key sequences for apropos completion to cycle to the next candidate. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-apropos-cycle-next-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-next-action-keys '([C-next]) + "*Keys for apropos completion to cycle next and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-apropos-cycle-next-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-next-alt-action-keys '([C-S-next]) + "*Keys for apropos completion to cycle next and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-next-help-keys '([(control meta next)]) ; `C-M-next' + "*Keys for apropos completion to cycle next and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-previous-keys '([prior]) + "*Key sequences for apropos completion to cycle to the previous candidate. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-apropos-cycle-previous-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-previous-action-keys '([C-prior]) + "*Keys for apropos completion to cycle previous and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-apropos-cycle-previous-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-previous-alt-action-keys '([C-S-prior]) + "*Keys for apropos completion to cycle previous and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-apropos-cycle-previous-help-keys '([(control meta prior)]) ; `C-M-prior' + "*Keys for apropos completion to cycle previous and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-bookmark-name-length-max 70 + "*Maximum number of characters used to name a bookmark. +When `icicle-bookmark-cmd' is used with a non-negative numeric prefix +arg, the name of the bookmark that is set has at most this many chars." + :type 'integer :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-bookmark-refresh-cache-flag t + "*t means `icicle-bookmark' refreshes the bookmark-list cache. +Use nil to speed up `icicle-bookmark(-other-window)' if you have a lot +of bookmarks, at the cost of having the bookmark list possibly not be +up to date. Use t if you want to be sure the list is refreshed. + +If nil, the list of bookmarks is updated only if you use `C-u'. +If t, the list is always updated unless you use `C-u'. + +This affects only commands such as `icicle-bookmark' that use the full +bookmark list. It does not affect more specific Icicles bookmark +commands such as `\\[icicle-bookmark-dired-other-window]' or the use +of a negative prefix arg with +`\\[icicle-bookmark-cmd]'. + +Regardless of the option value, the cache is refreshed whenever you +use `S-delete' to delete a candidate bookmark." + :type 'boolean :group 'Icicles-Completions-Display :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-extras nil + "*List of additional buffer-name candidates added to the normal list. +List elements are strings." + :type '(repeat string) :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-ignore-space-prefix-flag t + "*Override `icicle-ignore-space-prefix-flag' for `icicle-buffer*'. +Note: This option is provided mainly for use (binding) in +`icicle-define-command' and `icicle-define-file-command'. +You probably do not want to set this globally, but you can." + :type 'boolean :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-match-regexp nil + "*nil or a regexp that buffer-name completion candidates must match. +If nil, then this does nothing. If a regexp, then show only +candidates that match it (and match the user input). +See also `icicle-buffer-no-match-regexp'." + :type '(choice (const :tag "None" nil) regexp) + :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-no-match-regexp nil + "*nil or a regexp that buffer-name completion candidates must not match. +If nil, then this does nothing. If a regexp, then show only +candidates that do not match it. +See also `icicle-buffer-match-regexp'." + :type '(choice (const :tag "None" nil) regexp) + :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-predicate nil + "*nil or a predicate that buffer-name candidates must satisfy. +If nil, then this does nothing. Otherwise, this is a function of one +argument, a candidate, and only candidates that satisfy the predicate +are displayed. For example, this value will show only buffers that +are associated with files: + + (lambda (bufname) (buffer-file-name (get-buffer bufname)))" + :type '(choice (const :tag "None" nil) function) + :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-require-match-flag nil + "*Override `icicle-require-match-flag' for `icicle-buffer*' commands. +Controls the REQUIRE-MATCH arg to `completing-read' and `read-file-name'. +The possible values are as follows: +- nil means this option imposes nothing on completion; + the REQUIRE-MATCH argument provided to the function governs behavior +- `no-match-required' means the same as a nil value for REQUIRE-MATCH +- `partial-match-ok' means the same as a t value for REQUIRE-MATCH +- `full-match-required' means the same as a non-nil, non-t value for + REQUIRE-MATCH + +Note: This option is provided mainly for use (binding) in +`icicle-define-command' and `icicle-define-file-command'. +You probably do not want to set this globally, but you can." + :type '(choice + (const :tag "Do not impose any match behavior" nil) + (const :tag "Do not require a match" no-match-required) + (const :tag "Require a partial match, with RET" partial-match-ok) + (const :tag "Require a full match" full-match-required)) + :group 'Icicles-Buffers :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-buffer-sort 'icicle-buffer-sort-*...*-last + "*A sort function for buffer names, or nil. +Examples of sort functions are `icicle-buffer-sort-*...*-last' and +`string<'. If nil, then buffer names are not sorted. Option +`icicle-sort-comparer' is bound to `icicle-buffer-sort' by command +`icicle-buffer'." + :type '(choice (const :tag "None" nil) function) + :group 'Icicles-Buffers :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-buffers-ido-like-flag nil + "t means `icicle-buffer' and similar commands act more Ido-like. +Specifically, those commands then bind these options to t: + `icicle-show-Completions-initially-flag' + `icicle-top-level-when-sole-completion-flag' + `icicle-default-value'" + :type 'boolean + :group 'Icicles-Buffers :group 'Icicles-Completions-Display :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-candidate-width-factor 80 + "*Percentage of widest candidate width to use for calculating columns. +The number of columns of candidates displayed in *Completions* is no +more than the window width divided by this percentage of the maximum +candidate width. + +Increasing this toward 100 spreads columns out. Decreasing it +compresses columns together. The higher the value, the more +candidates will form well-defined columns, but the likelier that +horizontal space will be wasted between them. The lower the value, +the more candidates will not line up in columns, but the less +horizontal space will be wasted between them. + +When most candidates are almost as wide as the widest candidate, a +high value works well. When most candidates are much shorter than the +widest candidate, a low value works well. + +If you use Do Re Mi (library `doremi.el'), then you can modify this +option incrementally during completion, seeing the effect as it +changes. Use `C-x w' from the minibuffer, then use the `right' and +`left' arrow keys or the mouse wheel to increment and decrement the +value. WYSIWYG. + +See also option `icicle-inter-candidates-min-spaces' and (starting +with Emacs 23) option `icicle-Completions-text-scale-decrease'." + :type 'integer :group 'Icicles-Completions-Display) + +;; Must be before `icicle-change-region-background-flag'. +;;;###autoload +(defcustom icicle-mark-position-in-candidate 'input-end + "*Position of mark when you cycle through completion candidates. +This is the mark position in the minibuffer. +Possible values are those for `icicle-point-position-in-candidate'." + :type '(choice + (const :tag "Leave mark at the beginning of the minibuffer input" input-start) + (const :tag "Leave mark at the end of the minibuffer input" input-end) + (const :tag "Leave mark at the beginning of the completion root" root-start) + (const :tag "Leave mark at the end of the completion root" root-end)) + :group 'Icicles-Minibuffer-Display) + +;; Must be before `icicle-change-region-background-flag'. +;;;###autoload +(defcustom icicle-point-position-in-candidate 'root-end + "*Position of cursor when you cycle through completion candidates. +This is the cursor position in the minibuffer. +Possible values are: + `input-start': beginning of the minibuffer input + `input-end': end of the minibuffer input + `root-start': beginning of the completion root + `root-end': end of the completion root +When input is expected to be a file name, `input-start' is just after +the directory, which is added automatically during completion cycling. +See also `icicle-mark-position-in-candidate'." + :type '(choice + (const :tag "Leave cursor at the beginning of the minibuffer input" input-start) + (const :tag "Leave cursor at the end of the minibuffer input" input-end) + (const :tag "Leave cursor at the beginning of the completion root" root-start) + (const :tag "Leave cursor at the end of the completion root" root-end)) + :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-change-region-background-flag + (not (eq icicle-point-position-in-candidate icicle-mark-position-in-candidate)) + "*Non-nil means use color `icicle-region-background' during input. +See `icicle-region-background'. If you load library `hexrgb.el' +before Icicles, then `icicle-region-background' will be a slightly +different hue from your normal background color. This makes +minibuffer input easier to read than if your normal `region' face were +used. This has an effect only during minibuffer input. A non-nil +value for this option is particularly useful if you use +delete-selection mode." + :type 'boolean :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-change-sort-order-completion-flag nil + "*Non-nil means `icicle-change-sort-order' uses completion, by default. +Otherwise, it cycles among the possible sort orders. You can override +the behavior by using `C-u' with `icicle-change-sort-order'." + :type 'boolean :group 'Icicles-Completions-Display :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-C-l-uses-completion-flag nil + "*Non-nil means \\\ +`\\[icicle-retrieve-previous-input]' uses completion for choosing completion history +entries, by default. Otherwise, it cycles among the possible previous +inputs. You can override the behavior by using `C-u' with `\\[icicle-retrieve-previous-input]'." + :type 'boolean :group 'Icicles-Minibuffer-Display :group 'Icicles-Matching) + +;; Replace this list by your favorite color themes. Each must be the name of a defined function. +;; By default, this includes all color themes defined globally (variable `color-themes'). +;; +;; NOTE: We need the `condition-case' because of a BUG in `directory-files' for Emacs 20. +;; Bug reported to `color-theme.el' maintainer 2009-11-22. The problem is that the default value +;; of `color-theme-libraries' concats `file-name-directory', which ends in `/', with `/themes', +;; not with `themes'. So the result is `...//themes'. That is tolerated by Emacs 21+ +;; `directory-files', but not for Emacs 20. Until this `color-theme.el' bug is fixed, Emacs 20 +;; users will need to manually load `color-theme-libraries.el'. +;;;###autoload +(defcustom icicle-color-themes () + "*List of color themes to cycle through using `M-x icicle-color-theme'. +Note: Starting with Color Theme version 6.6.0, you will need to put +library `color-theme-library.el', as well as library `color-theme.el', +in your `load-path'." + :type 'hook :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-comint-dynamic-complete-replacements + '((comint-dynamic-complete-filename 'icicle-comint-dynamic-complete-filename) + (shell-dynamic-complete-command 'icicle-shell-dynamic-complete-command) + (shell-dynamic-complete-environment-variable + 'icicle-shell-dynamic-complete-environment-variable) + (shell-dynamic-complete-filename 'icicle-shell-dynamic-complete-filename) + (ess-complete-filename 'icicle-ess-complete-filename) + (ess-complete-object-name 'icicle-ess-complete-object-name) + ) + "*List of function replacements for `comint-dynamic-complete-functions'. +Instead of using `comint-dynamic-complete-functions' as is, command +`icicle-comint-dynamic-complete' replaces functions in that list +according to the value of this option. + +Each option list element is itself a list of two elements. The first +is a function to replace (a symbol), and the second is the replacement +function (a sexp that evaluates to a function). For example, this +list element says to replace completion function `foo' by completion +function `my-foo': (foo 'my-foo). + +You can use this option to provide Icicles completion for various +modes that inherit from Comint mode or otherwise use +`comint-dynamic-complete'." + :type '(repeat (list symbol sexp)) :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-command-abbrev-alist () + "*Alist of command abbreviations and commands, with frequency of use. +Each element has the form (COMMAND ABBREV N), where ABBREV is an +abbreviation of COMMAND and N is the number of times COMMAND has been +invoked via ABBREV. Both COMMAND and ABBREV are symbols." + :type '(alist :key-type symbol :value-type (list symbol integer)) :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-command-abbrev-match-all-parts-flag nil + "*Non-nil means `icicle-command-abbrev' matches each command-name part. +Otherwise, an abbrev need match only a prefix of the command name." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-command-abbrev-priority-flag nil + "*nil means commands take precedence over abbreviations for `\\\ +\\[icicle-command-abbrev]'." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-complete-key-anyway-flag nil + "*Non-nil means bind `S-TAB' for key completion even if already +bound. If nil, then each of the keys in `icicle-key-complete-keys' is +bound to `icicle-complete-keys' in each keymap of +`icicle-keymaps-for-key-completion' only if `S-TAB' is not already +bound in the keymap. + +Note: the keys in `icicle-key-complete-keys' are always bound to +`icicle-complete-keys' in `icicle-mode-map'. This option affects only +the binding of those keys in `icicle-keymaps-for-key-completion'." + :type 'boolean :group 'Icicles-Key-Completion :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-complete-keys-self-insert-flag nil + "*Non-nil means `icicle-complete-keys' includes self-inserting keys. +That means keys bound to `self-insert-command'." + :type 'boolean :group 'Icicles-Key-Completion) + +;;;###autoload +(defcustom icicle-completing-read+insert-keys '([(control meta shift ?c)]) + "*Key sequences to invoke `icicle-completing-read+insert'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Such a key has no effect unless +`icicle-completing-read+insert-candidates' is non-nil." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-completion-history-max-length (if icicle-C-l-uses-completion-flag 1000 100) + "*Maximum number of inputs to save in the completion history. +This is the history that you access using \\\ +`\\[icicle-retrieve-previous-input]' and `\\[icicle-retrieve-next-input]'." + :type 'integer :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-Completions-display-min-input-chars 0 + "**Completions* window is removed if fewer chars than this are input. +You might want to set this to, say 1 or 2, to avoid display of a large +set of candidates during incremental completion. The default value of +0 causes this option to have no effect: *Completions* is never removed +based only on the number of input characters." + :type 'integer :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-completions-format (if (boundp 'completions-format) + completions-format ; Defined in Emacs 23+. + 'horizontal) + "*Layout of completion candidates in buffer *Completions*. +`vertical' means display down columns first, then to the right. +`horizontal' or nil means display across rows first, then down. + +A `vertical' value is overridden (ignored) when multi-line +multi-completions are used. For clarity, the layout for such +multi-completions is always horizontal." + :type '(choice + (const :tag "Display vertically" vertical) + (other :tag "Display horizontally" horizontal)) + :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-Completions-frame-at-right-flag t + "*Non-nil means move *Completions* frame to right edge of display. +This is done by `icicle-candidate-action'. +It only happens if *Completions* is alone in its frame. +This can be useful to make *Completions* more visible." + :type 'boolean :group 'Icicles-Completions-Display) + +;;;###autoload +(when (fboundp 'text-scale-decrease) ; Emacs 23+ + (defcustom icicle-Completions-text-scale-decrease 0.66 + "*Initial height decrease for text in buffer `*Completions*'. +A value of 0.0 means the height is not decreased at all. +This is used as the argument to function `text-scale-decrease'. +If you use library `doremi-frm.el', you can use `C-x -' to +incrementally resize the text during completion. + +See also options `icicle-candidate-width-factor' and +`icicle-inter-candidates-min-spaces'." + :type 'number :group 'Icicles-Completions-Display)) + +;;;###autoload +(defcustom icicle-Completions-window-max-height 30 + "*Maximum height of *Completions* window, in lines. +The window is fit to the buffer size, with this as maximum height. +Not used if *Completions* is a special buffer with its own frame. +Not used in Emacs releases prior to 21." + :type 'integer :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-customize-save-flag t + "*Non-nil means save some updated Icicles options when you quit Emacs. +That is, add some functions to `kill-emacs-hook' that call +`customize-save-variable'. Currently, this includes only function +`icicle-command-abbrev-save', which saves updated option +`icicle-command-abbrev-alist'." + :type 'boolean :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-customize-save-variable-function 'customize-save-variable + "*Function used to save user option changes. +I RECOMMEND that you do NOT change this. + +The option value is a function that has the same signature as +`customize-save-variable' (perhaps with additional arguments after VAR +and VAL, the variable to save and its new value. + +If you do not want changes that Icicles commands make to certain user +options to be saved automatically, you can set this to the function +\(symbol) `ignore'. If you want to use your own function to somehow +save the current value, you can set this to your function." + :type 'function :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-cycle-into-subdirs-flag nil + "*Non-nil means minibuffer-input cycling explores subdirectories. +If this is non-nil, then you might want to use a function such as +`icicle-dirs-last-p' for option `icicle-sort-comparer', to prevent +cycling into subdirectories depth first. Command +`icicle-sort-by-directories-last' does that." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-cycling-respects-completion-mode nil + "*Non-nil means candidate cycling respects the current completion mode. +The default value of nil means that you use two separate sets of keys for +cycling apropos and prefix completions: + - `icicle-apropos-cycle-previous-keys' (backward apropos) + `icicle-apropos-cycle-next-keys' (forward apropos) + - `icicle-prefix-cycle-previous-keys' (backward prefix) + `icicle-prefix-cycle-next-keys' (forward prefix) + +Non-nil means that you can use a single set of keys (`up' and `down', +by default) to cycle both kinds of completion. The keys are the +values of `icicle-modal-cycle-up-keys' (backward) and +`icicle-modal-cycle-down-keys' (forward). + +The completion mode, and hence the behavior of these keys, is changed +whenever you hit `TAB' or `S-TAB' during completion: the mode is +prefix completion after `TAB' and `apropos' completion after `S-TAB'. + +Before you hit `TAB' or `S-TAB', the cycling behavior depends on the +particular non-nil value of the option: + +- `prefix' means cycle prefix completions +- `apropos' means cycle apropos completions +- Any other non-nil value means cycle inputs from the input history + +For example, if the value is `apropos' then you can immediately cycle +apropos completions without first hitting `S-TAB'. + +Once you have used `TAB' or `S-TAB', the only way to traverse the +history is using `M-p' and `M-n' - `up' and `down' will cycle +completions. + +Note: If the option is non-nil you can still use `M-p' and `M-n' to +traverse the input history, and `prior' and `next' to cycle apropos +completions (assuming that those default keys have not been changed). + +And if you customize either the modal cycling keys or the prefix +cycling keys so that they are different (e.g. one of those sets is no +longer `up'/`down'), then you can also still use the latter. In this +case, you need not use `TAB' and `S-TAB' to switch between the two +completion types, even when this option is non-nil - you can use the +separate apropos and prefix cycling keys. + +After you change the value of this option, toggle Icicle mode off, +then on again, for the change to take effect in the same session." + :type '(choice + (const :tag "No" nil) + (const :tag "Yes, and use prefix cycling by default" prefix) + (const :tag "Yes, and use apropos cycling by default" apropos) + (other :tag "Yes, and use history cycling by default" t)) + :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-default-thing-insertion 'alternatives + "*Behavior of successive `\\\\[icicle-insert-string-at-point]'. +If `alternatives', then the next function in the `car' of +`icicle-thing-at-point-functions' is used to retrieve the text to be +inserted. +If `more-of-the-same', then the function that is the `cdr' of +`icicle-thing-at-point-functions' is used to retrieve the text to be +inserted." + :type `(choice + (const :tag ,(substitute-command-keys + "Successive calls to `\\\ +\\[icicle-insert-string-at-point]' use different text-grabbing functions.") + alternatives) + (const :tag ,(substitute-command-keys + "Successive calls to `\\\ +\\[icicle-insert-string-at-point]' grab more text at point.") + more-of-the-same)) + :group 'Icicles-Key-Bindings) + +;; We don't use `define-obsolete-variable-alias' so that byte-compilation in older Emacs +;; works for newer Emacs too. +(when (fboundp 'defvaralias) ; Emacs 22+ + (defvaralias 'icicle-init-value-flag 'icicle-default-value) + (make-obsolete-variable 'icicle-init-value-flag 'icicle-default-value)) + +;;;###autoload +(defcustom icicle-default-value t + "*How to treat the default value when reading minibuffer input. + +When the default value argument to functions such as +`completing-read', `read-file-name', `read-from-minibuffer', and +`read-string' is non-nil and the initial-input argument is nil or +\"\", the default value can be added to the prompt as a hint or +inserted into the minibuffer as the initial input. + +Adding it to the prompt is the default behavior and corresponds to the +behavior of vanilla Emacs. + +Inserting the default value in the minibuffer as the initial input has +the advantage of not requiring you to use `M-n' to retrieve it. It +has the disadvantage of making you use `M-p' (or do something else) to +get rid of the default value in the minibuffer if you do not want to +use or edit it. If you often want to use or edit the default value, +then set `icicle-default-value' to non-nil and non-t. If you rarely +do so, then set it to nil or t. + +If inserted in the minibuffer, the value of this option also +determines whether or not the inserted text is preselected and where +the cursor is left: at the beginning or end of the text. + +These are the possible option values: + + nil - Do not insert default value or add it to prompt. + t - Add default value to prompt. Do not insert it. + `insert-start' - Insert default value and leave cursor at start. + `insert-end' - Insert default value and leave cursor at end. + `preselect-start' - Insert and preselect default value; + leave cursor at beginning. + `preselect-end' - Insert and preselect default value; + leave cursor at end. + +My own preference is `insert-end'. + +Preselection can be useful in Delete Selection mode or PC Selection +mode. It makes it easy to replace the value by typing characters, or +delete it by hitting `C-d' or `DEL' (backspace). However, all of the +initial input is lost if you type or hit `C-d' or `DEL'. That is +inconvenient if you want to keep most of it and edit it only slightly." + :type '(choice + (const :tag "Do not insert default value or add it to prompt" nil) + (const :tag "Add default value to prompt (do not insert in minibuffer)" t) + (const :tag "Insert default value. Leave cursor at beginning" insert-start) + (const :tag "Insert default value. Leave cursor at end" insert-end) + (const :tag "Insert default value, select it, leave cursor at beginning" + preselect-start) + (const :tag "Insert default value, select it, leave cursor at end" + preselect-end)) + :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-define-alias-commands-flag t + "*Non-nil means define some commands that do not begin with `icicle-'. +For convenience, a few top-level commands are defined, typically as +aliases for commands with longer names. For example, command `toggle' +is defined as an alias for command `icicle-toggle-option'. In any +case, no such command is ever defined by Icicles if a function with +the same name is already defined." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-deletion-action-flag t + "*Non-nil means `S-delete' during completion deletes the current object. +More precisely, it deletes the object named by the current completion +candidate, if a deletion action is defined for the current command. +If no deletion action is defined, then the value of this option has no +effect. + +If you are worried about inadvertently deleting an object by +accidentally hitting `S-delete', you can customize this to nil to +inhibit `S-delete' object deletion during completion." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-dot-show-regexp-flag nil + "*Non-nil means show `icicle-anychar-regexp' explicitly for `.'. +Otherwise, display it as a highlighted `.' only. +This has no effect for Emacs versions prior to 21: acts as if non-nil." + :type 'boolean :group 'Icicles-Matching :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-dot-string "." + "*String inserted by `icicle-insert-dot-command'. +It is either \".\" or the value of `icicle-anychar-regexp'. +You can toggle this at any time using command `icicle-toggle-dot', +bound to \\`\\[icicle-toggle-dot]' during completion." + :set #'(lambda (sym defs) + (custom-set-default sym defs) + (setq icicle-dot-string-internal icicle-dot-string)) + :type `(choice + (const :tag "Match any char EXCEPT newline" ".") + (const :tag "Match any char, including NEWLINE" ,icicle-anychar-regexp)) + :group 'Icicles-Matching :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-expand-input-to-common-match-flag t ; Toggle with `C-;'. + "*Non-nil means `S-TAB' expands input, still matching all candidates. +The expansion replaces your input in the minibuffer. + +Your expanded input is typically the longest substring common to all +completion candidates and that matches your (complete) input pattern. + +If you want to edit your original input, use \\\ +`\\[icicle-retrieve-previous-input]'. + +For apropos completion, your input is, in general, a regexp. Setting +this option to nil will let you always work with a regexp in the +minibuffer for apropos completion - your regexp is then never replaced +by the expanded common match. + +You can toggle this option at any time from the minibuffer using +`C-;'." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-extras nil + "*List of additional file-name candidates added to the normal list. +List elements are strings." + :type '(repeat string) :group 'Icicles-Files :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-match-regexp nil + "*nil or a regexp that file-name completion candidates must match. +If nil, then this does nothing. If a regexp, then show only +candidates that match it (and match the user input). +See also `icicle-file-no-match-regexp'." + :type '(choice (const :tag "None" nil) regexp) + :group 'Icicles-Files :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-no-match-regexp nil + "*nil or a regexp that file-name completion candidates must not match. +If nil, then this does nothing. If a regexp, then show only +candidates that do not match it. +See also `icicle-file-match-regexp'." + :type '(choice (const :tag "None" nil) regexp) + :group 'Icicles-Files :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-predicate nil + "*nil or a predicate that file-name candidates must satisfy. +If nil, then this does nothing. Otherwise, this is a function of one +argument, a candidate, and only candidates that satisfy the predicate +are displayed. For example, this value will show only names of files +with more than 5000 bytes: + + (lambda (fil) (> (nth 5 (file-attributes file)) 5000))" + :type '(choice (const :tag "None" nil) function) + :group 'Icicles-Files :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-require-match-flag nil + "*Override `icicle-require-match-flag' for file-name completion. +The possible values are as follows: +- nil means this option imposes nothing on completion; + the REQUIRE-MATCH argument provided to the function governs behavior +- `no-match-required' means the same as a nil value for REQUIRE-MATCH +- `partial-match-ok' means the same as a t value for REQUIRE-MATCH +- `full-match-required' means the same as a non-nil, non-t value for + REQUIRE-MATCH + +Note: This option is provided mainly for use (binding) in +`icicle-define-command' and `icicle-define-file-command'. +You probably do not want to set this globally, but you can." + :type '(choice + (const :tag "Do not impose any match behavior" nil) + (const :tag "Do not require a match" no-match-required) + (const :tag "Require a partial match, with RET" partial-match-ok) + (const :tag "Require a full match" full-match-required)) + :group 'Icicles-Files :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-file-sort nil + "*A sort function for file names, or nil. +Examples of sort functions are `icicle-dirs-last-p' and +`icicle-last-modified-first-p'. If nil, then file names are not +sorted." + :type '(choice (const :tag "None" nil) function) + :group 'Icicles-Files :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-files-ido-like-flag nil + "t means `icicle-file' and similar commands act more Ido-like. +Specifically, those commands then bind these options to t: + `icicle-show-Completions-initially-flag' + `icicle-top-level-when-sole-completion-flag' + `icicle-default-value'" + :type 'boolean + :group 'Icicles-Files :group 'Icicles-Completions-Display :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-filesets-as-saved-completion-sets-flag t + "*Non-nil means you can use filesets to save candidates persistently. +This means that you can save file-name candidates in a persistent +Icicles saved completion set (cache file) or in in an Emacs fileset. +It also means that an Icicles persistent completion set can contain +filesets, in addition to file names: any number of filesets, and +filesets of different type. Available only for Emacs 22 and later, +and you must load library `filesets.el'." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-guess-commands-in-path nil + "*Non-nil means all shell commands are available for completion. +This is used in Icicle mode whenever a shell-command is read. + +If non-nil, then all executable files (or all files, if option +`shell-completion-execonly' is nil) in your search path are included +among the completion candidates, in addition to any commands that are +guessed as being appropriate for the target files (e.g. marked files +in Dired). + +If non-nil and if option `icicle-shell-command-candidates-cache' is +nil, then the list of commands is computed once and cached as the +value of `icicle-shell-command-candidates-cache'. The particular +non-nil value of `icicle-guess-commands-in-path' determines when the +cache is filled, as follows: + +- If the value is `load', then the cache is filled when Icicles is + first loaded, and it is saved persistently. + +- If the value is `first-use', then the cache is filled when you first + complete a shell command, and the computed list is not saved + persistently. + +If the value is not `load', then whenever you enter Icicle mode the +cache is emptied. + +If your environment changes and you want to update the cached list, +you can use command `icicle-recompute-shell-command-candidates'. With +a prefix argument, that command also saves the cache persistently." + :type '(choice + (const :tag "Do not add shell commands from search path" nil) + (const :tag "Compute shell commands from path when Icicles is loaded" load) + (const :tag "Compute shell commands from path upon first use" first-use)) + :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-help-in-mode-line-flag t + "*Non-nil means show help in the mode-line for individual completions. +If buffer *Completions* is displayed, then use its mode-line. +Otherwise, use the mode-line of the current buffer. + +The help is shown when you cycle among completion candidates and when +your input is completed (entirely) to a candidate. + +Face `icicle-mode-line-help' is used for the help." + :type 'boolean :group 'Icicles-Completions-Display :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-hide-common-match-in-Completions-flag nil + "*Non-nil means hide the common match for your input in *Completions*. +The common match is elided using ellipsis (`...'). +You can use `C-M-.' during completion to toggle this option. + + The common match used here is governed by option +`icicle-expand-input-to-common-match-flag'." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-highlight-historical-candidates-flag t ; Toggle with `C-pause'. + "*Non-nil means highlight *Completions* candidates that have been used. +This is done using face `icicle-historical-candidate'. +Historical candidates are those that you have entered (using `RET' or +`S-RET') previously. You can toggle this option from the minibuffer +at any time using `C-pause'." + :type 'boolean :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-highlight-input-completion-failure 'implicit-strict + "*Non-nil means highlight the part of your input that does not complete. +This is done using face `icicle-input-completion-fail' or +`icicle-input-completion-fail-lax'. + +You can use `\\\\[icicle-goto/kill-failed-input]' \ +to go to the start of the highlighted part. +Repeat to kill it. + +This highlighting can have a negative impact on performance, because +it can mean recomputing completion candidates multiple times, in order +to determine the longest part that completes. For this reason, you +can fine tune when you want this highlighting to occur. The values of +this option and options +`icicle-highlight-input-completion-failure-delay' and +`icicle-highlight-input-completion-failure-threshold' determine when +the highlighting can take place. + +In particular, highlighting the non-matching part of remote file names +can be slow. Two values of this option allow remote file name +highlighting: `always' and `explicit-remote'. The other values do not +highlight remote file names. You probably do not want to use a value +of `always'. + +If the value is nil, then highlighting never occurs. If the value is +`explicit-strict', `explicit', or `explicit-remote', then highlighting +occurs only upon demand: when you hit `TAB' or `S-TAB' to request +completion. If the value is `implicit-strict', `implicit', or +`always', then highlighting occurs also when you update your input +during incremental completion. + +If the value is `implicit-strict' or `implicit', then highlighting +occurs not only upon demand but also during incremental completion if +`icicle-incremental-completion-flag' is non-nil. Remember that you +can toggle incremental completion, using `C-#' in the minibuffer. + +I use a value of `implicit' myself, but the default value is +`implicit-strict' because, depending on your setup and use cases, +`implicit' can impact performance for file-name completion (which is +lax, not strict). I suggest you try `implicit' to see - this feature +is especially useful for file names. + +Summary of choices for when to highlight: + +nil Never +`explicit-strict' When you hit `TAB'/`S-TAB' for strict completion +`explicit' When you hit `TAB'/`S-TAB' +`explicit-remote' When you hit `TAB'/`S-TAB', including remote files +`implicit-strict' During strict completion +`implicit' During lax or strict completion +`always' Always, even for names of remote files + +After highlighting, you can use `C-M-l' to move the cursor to the +start of the mismatch, for editing there. You can use a second +`C-M-l' to kill (delete) the mismatch up to the next input line (if +any). You can repeat `C-M-l' to kill additional input lines. + +See also: +* `icicle-highlight-input-completion-failure-delay' +* `icicle-highlight-input-completion-failure-threshold'" + :type '(choice + (const :tag "Never" nil) + (const :tag "Explicit (`TAB'/`S-TAB') strict completion" explicit-strict) + (const :tag "Explicit (`TAB'/`S-TAB') lax and strict completion" explicit) + (const :tag "Explicit completion, even of remote file names" explicit-remote) + (const :tag "Strict completion" implicit-strict) + (const :tag "Lax and strict completion" implicit) + (const :tag "Always (including for remote file names)" always)) + :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-highlight-input-completion-failure-delay 0.7 + "*Seconds to wait before highlighting non-completing part of your input. +Zero means there is no wait." + :type 'number :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-highlight-input-completion-failure-threshold 1000 + "*More candidates means do not highlight non-completing part of input. +See also `icicle-highlight-input-completion-failure'." + :type 'integer :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-highlight-input-initial-whitespace-flag t + "*Non-nil means highlight initial whitespace in your input. +This is done using face `icicle-whitespace-highlight'. +Purpose: Otherwise, you might not notice that you accidentally typed +some whitespace at the beginning of your input, so you might not +understand the set of matching candidates (or lack thereof). + +Note: Highlighting input completion failure (see option +`icicle-highlight-input-completion-failure') subsumes +initial-whitespace highlighting. This means that if no completion +candidate starts with whitespace, and if Icicles is highlighting input +completion failure, then only that highlighting is shown." + :type 'boolean :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-highlight-lighter-flag t + "*Non-nil means highlight the `Icy' mode-line lighter during completion. +See the Icicles doc, section `Nutshell View of Icicles', subsection +`Completion Status Indicators' for more information." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-ignored-directories (and (boundp 'vc-directory-exclusion-list) + vc-directory-exclusion-list) + "Directories ignored by `icicle-locate-file'." + :type '(repeat string) :group 'Icicles-Files) + +;;;###autoload +(defcustom icicle-ignore-space-prefix-flag nil ; Toggle with `M-_'. + "*Non-nil means ignore completion candidates that start with a space. +However, such candidates are not ignored for prefix completion when +the input also starts with a space. You can toggle this option from +the minibuffer using `M-_'. +Note: Some Icicles functionalities ignore the value of this option." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-incremental-completion-delay 0.7 + "*Number of seconds to wait before updating *Completions* incrementally. +There is no wait if the number of completion candidates is less than +or equal to `icicle-incremental-completion-threshold'. +See also `icicle-incremental-completion-flag'." + :type 'number :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-incremental-completion-flag t ; Toggle with `C-#'. + "*Non-nil means update *Completions* buffer incrementally, as you type. +nil means do not update *Completions* buffer incrementally, as you type. +t means do nothing if *Completions* is not already displayed. +Non-nil and non-t means display *Completions* and update it. +You can toggle this between t and nil from the minibuffer at any time +using `C-#'. + +Note: Incremental completion is effectively turned off when a remote +file name is read, that is, whenever your file-name input matches a +remote-file syntax. + +See also `icicle-incremental-completion-delay' and +`icicle-incremental-completion-threshold'." + :type '(choice + (const :tag "Do not update *Completions* incrementally" nil) + (const :tag "Update *Completions* incrementally if already displayed" t) + (other :tag "Update *Completions* incrementally always" always)) + :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-incremental-completion-threshold 1000 + "*More candidates means apply `icicle-incremental-completion-delay'. +See also `icicle-incremental-completion-flag' and +`icicle-incremental-completion-delay'. +This threshold is also used to decide when to display the message + \"Displaying completion candidates...\"." + :type 'integer :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-inhibit-advice-functions + '(choose-completion choose-completion-string completing-read + completion-setup-function dired-smart-shell-command + display-completion-list exit-minibuffer face-valid-attribute-values + minibuffer-complete-and-exit mouse-choose-completion + next-history-element read-face-name read-file-name read-number + shell-command shell-command-on-region switch-to-completions + completing-read-multiple) + "Functions that Icicles redefines, and for which advice is deactivated. +Icicle mode deactivates all advice for such functions. The advice is +reactivated when you leave Icicle mode." + :type '(repeat (function :tag "Function for which Icicles deactivates advice")) + :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-inhibit-ding-flag nil + "*Non-nil means Icicles never uses an audible bell (ding). +If nil, Icicles sometimes signals you with a sound." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-input-string ".*" + "*String to insert in minibuffer via `\\\ +\\[icicle-insert-string-from-variable]'. +Typically, this is a regexp or a portion of a regexp." + :type 'string :group 'Icicles-Miscellaneous) + +(when (fboundp 'defvaralias) ; Emacs 22+ + (defvaralias 'icicle-key-descriptions-use-angle-brackets-flag + 'icicle-key-descriptions-use-<>-flag)) + +;;;###autoload +(defcustom icicle-inter-candidates-min-spaces 1 + "*Minimum number of spaces between candidates displayed in *Completions*. +If you use Do Re Mi (library `doremi.el'), then you can modify this +option incrementally during completion, seeing the effect as it +changes. Use `\\\ +\\[icicle-doremi-inter-candidates-min-spaces+]' from the minibuffer, then use the `up' and +`down' arrow keys or the mouse wheel to increment and decrement the +value. WYSIWYG. + +See also option `icicle-candidate-width-factor' and (starting with +Emacs 23) option `icicle-Completions-text-scale-decrease'." + :type 'integer :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-isearch-complete-keys + '([C-M-tab] [M-tab] "\M-\t" [escape tab] ; Replace vanilla completion. + "\M-o") ; Like Icicles minibuffer `M-o'. + "*Key sequences to use for `icicle-isearch-complete'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. + +The default value includes `M-TAB', which replaces the vanilla binding +of `isearch-complete'. + +It also includes `ESC TAB' and `C-M-TAB', because some operating +systems intercept `M-TAB' for their own use. (Note: For MS Windows, +you can use (w32-register-hot-key [M-tab]) to allow Emacs to use +`M-TAB'.) + +It also includes `M-o', in keeping with the Icicles use of `M-o' +during minibuffer completion." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-key-complete-keys '([S-tab] [S-iso-lefttab]) + ;; $$$$$ The following should be sufficient, but some Emacs 22+ libraries, such as `info.el', + ;; are brain-dead and explicitly bind both `backtab' and `S-tab'. I filed Emacs bug #1281. + ;; (if (> emacs-major-version 21) + ;; '([backtab]) + ;; '([S-tab] [S-iso-lefttab])) + "*Key sequences to use for `icicle-complete-key'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards - for example, `S-tab' and `S-iso-lefttab'." +;; In Emacs 22 and later, `backtab' is the canonical key that represents +;; both `S-tab' and `S-iso-lefttab', so that is used in the default +;; value. If, for some reason, `backtab' is not being translated to +;; `S-tab' and `S-iso-lefttab' on your platform, you might want to +;; customize the value to ([S-tab] [S-iso-lefttab]). And if your Emacs +;; version is 22 or later, please file an Emacs bug about the lack of +;; translation. + :type '(repeat sexp) :group 'Icicles-Key-Completion :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-key-descriptions-use-<>-flag nil + "*Non-nil means Icicles key descriptions should use angle brackets (<>). +For example, non-nil gives `'; nil gives `mode-line'. + +This does not affect Emacs key descriptions outside of +Icicles (e.g. `C-h k' or `C-h w'). + +This has no effect for versions of Emacs prior to 21, because +they never use angle brackets." + :type 'boolean :group 'Icicles-Key-Completion :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-keymaps-for-key-completion + '(bookmark-bmenu-mode-map bmkp-jump-map bmkp-jump-other-window-map + calendar-mode-map dired-mode-map facemenu-keymap jde-mode-map jde-jdb-mode-map + senator-mode-map srecode-mode-map synonyms-mode-map vc-dired-mode-map) + "*List of keymaps in which to bind `S-TAB' to `icicle-complete-keys'. +List elements are symbols that are bound to keymaps. + +Each keymap should have at least one prefix key. `S-TAB' is bound in +each keymap, so that you can use it to complete the prefix keys. + +If one of the keymaps is not defined when Icicle mode is entered, then +it is ignored. If you later define it, then just exit and reenter +Icicle mode, to bind `S-TAB' in the newly defined map. For example, +use `M-x icy-mode' twice after entering Calendar mode, to be able to +complete `calendar-mode' prefix keys such as `A'. + +Do not add `global-map' or any keymaps, such as `ctl-x-map', that are +accessible from the global keymap to the list - they are already +treated, by default. + +Do not add any of the translation keymaps, `function-key-map', +`key-translation-map', or `iso-transl-ctl-x-8-map' to the list - that +will not work." + :type '(repeat symbol) :group 'Icicles-Key-Completion :group 'Icicles-Key-Bindings) + +;;;###autoload +(when (boundp 'kmacro-ring) ; Emacs 22+ + (defcustom icicle-kmacro-ring-max (if (boundp 'most-positive-fixnum) + most-positive-fixnum + 67108863) ; 1/2 of `most-positive-fixnum' on Windows. + "*Icicles version of `kmacro-ring-max'." + :type 'integer :group 'Icicles-Miscellaneous)) + +;;;###autoload +(defcustom icicle-levenshtein-distance 1 + "*Levenshtein distance allowed for strings to be considered as matching. +Icicles matching function `icicle-levenshtein-match' considers a +string to match another if the first string is within this distance of +some substring of the second. +This option is used only if you have library `levenshtein.el'." + :type 'integer :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-list-end-string " + +" + "*String appended to a completion candidate that is a list of strings. +When a completion candidate is a list of strings, they are joined +pairwise using `icicle-list-join-string', and `icicle-list-end-string' +is appended to the joined strings. The result is what is displayed as +a completion candidate in buffer *Completions*, and that is what is +matched by your minibuffer input. + +The purpose of `icicle-list-end-string' is to allow some separation +between the displayed completion candidates. Candidates that are +provided to input-reading functions such as `completing-read' as lists +of strings are often displayed using multiple lines of text. If +`icicle-list-end-string' is \"\", then the candidates appear run +together, with no visual separation. + +It is important to remember that `icicle-list-end-string' is part of +each completion candidate in such circumstances. This matters if you +use a regexp that ends in `$', matching the end of the candidate." + :type 'string :group 'Icicles-Completions-Display) + +;; Note: If your copy of this file does not have the two-character string "^G^J" +;; (Control-G, Control-J) or, equivalently, \007\012, as the default value, you will want +;; to change the file to have that. To insert these control characters in the file, use +;; `C-q'. Emacs Wiki loses the ^G from the file, so I use \007, which works OK. +;; +;;;###autoload +(defcustom icicle-list-join-string (let ((strg (copy-sequence "\007\012"))) + ;; Emacs 20 ignores `display', so don't bother. + ;; Emacs 21 has a big bug, which interprets `display' badly. + (when (> emacs-major-version 21) ; Avoid Emacs 21 bug. + (set-text-properties 0 1 '(display "") strg)) + strg) + "*String joining items in a completion that is a list of strings. +When a completion candidate is a list of strings, this string is used +to join the strings in the list, for display and matching purposes. +When completing input, you type regexps that match the strings, +separating them pairwise by the value of `icicle-list-join-string'. +Actually, what you enter is interpreted as a single regexp to be +matched against the joined strings. Typically, the candidate list +contains two strings: a name and its doc string. + +A good value for this option is a string that: + 1) does not normally occur in doc strings, + 2) visually separates the two strings it joins, and + 3) is not too difficult or too long to type. + +The default value is \"^G\^J\", that is, control-g followed by +control-j (newline): + 1) ^G does not normally occur in doc strings + 2) a newline visually separates the multiple component strings, which + helps readability in buffer *Completions* + 3) you can type the value using `C-q C-g C-q C-j'. + +For readability (in Emacs 22 and later), the default value has a +`display' property that makes it appear as simply a newline in +*Completions* - the `^G' is hidden. you can also make the default +value appear this way in your minibuffer input also, by using \ +`\\\\[icicle-insert-list-join-string].' + +If you like the default value of `^G^J', but you prefer that the `^G' +not be hidden, then just customize this option. In Customize, use +`Show initial Lisp expression' after clicking the `State' button, to +be able to edit the default value. Remove the `set-text-properties' +expression, which sets text property `display' to \"\"." + :type 'string :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-list-nth-parts-join-string " " + "*String joining candidate parts split by `icicle-list-use-nth-parts'. +This has an effect on multi-completion candidates only, and only if +the current command uses `icicle-list-use-nth-parts'." + :type 'string :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-max-candidates nil + "Non-nil means truncate completion candidates to at most this many. +If you use library `doremi.el' then you can use `C-x #' during +completion to increment or decrement the option value using the +vertical arrow keys or the mouse wheel. A numeric prefix argument for +`C-x #' sets the increment size. A plain prefix argument (`C-u') +resets `icicle-max-candidates' to nil, meaning no truncation." + :type '(choice (const :tag "None" nil) integer) + :group 'Icicles-Completions-Display :group 'Icicles-Matching + :group 'Icicles-Buffers :group 'Icicles-Files) + +;;;###autoload +(defcustom icicle-menu-items-to-history-flag t + "Non-nil means to add menu-item commands to the command history. +This history is `extended-command-history'. + +After you change the value of this option, toggle Icicle mode off, +then on again, for the change to take effect in the same session." + :type 'boolean :group 'Icicles-Miscellaneous) + +;; Inspired from `icomplete-minibuffer-setup-hook'. +;;;###autoload +(defcustom icicle-minibuffer-setup-hook nil + "*Functions run at the end of minibuffer setup for Icicle mode." + :type 'hook :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-modal-cycle-down-keys '([down]) + "*Key sequences to use for modal cycling to the next candidate. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-modal-cycle-down-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-down-action-keys '([C-down]) + "*Keys for modal completion to cycle next and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-modal-cycle-down-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-down-alt-action-keys '([C-S-down]) + "*Keys for modal completion to cycle next and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-down-help-keys '([(control meta down)]) ; `C-M-down' + "*Keys for modal completion to cycle next and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-up-keys '([up]) + "*Key sequences to use for modal cycling to the previous candidate. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-modal-cycle-up-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-up-action-keys '([C-up]) + "*Keys for modal completion to cycle previous and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-modal-cycle-up-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-up-alt-action-keys '([C-S-up]) + "*Keys for modal completion to cycle previous and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-modal-cycle-up-help-keys '([(control meta up)]) ; `C-M-up' + "*Keys for modal completion to cycle previous and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +This is used only if `icicle-cycling-respects-completion-mode' is +non-nil." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-no-match-hook nil + "*List of hook functions run during completion when there are no matches." + :type 'hook :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-option-type-prefix-arg-list '(direct inherit inherit-or-value direct-or-value + inherit-or-regexp direct-or-regexp) + "*Symbols controlling prefix args for `icicle-describe-option-of-type'. +A list of six symbols taken from this list: + + direct inherit inherit-or-value + direct-or-value inherit-or-regexp direct-or-regexp + +Choose the order you like. The list members map, in order left to +right, to these prefix argument keys: + + `C-u C-u' `C-0' `C-u' + `C-9' (positive) no prefix arg `C--' (negative) + +For the meanings of the symbols, see the doc string of +`icicle-describe-option-of-type', which describes the default +prefix-argument bindings for the command." + :type '(list symbol symbol symbol symbol symbol symbol) :group 'Icicles-Key-Bindings) + +;;;###autoload +(when (> emacs-major-version 22) + (defcustom icicle-populate-interactive-history-flag nil + "*Non-nil means populate `icicle-interactive-history'. +That means add commands invoked interactively to that history, for use +during completion by `C-M-pause'. + +After you change the value of this option, toggle Icicle mode off, +then on again, for the change to take effect in the same session. + +Be aware that this history can become quite long. + +Furthermore, there is an Emacs bug (#3984) that causes interactiveness +tests (`interactive-p' and `called-interactively-p') to fail, whenever +`call-interactively' is advised (which is how Icicles implements this +feature)." + :type 'boolean :group 'Icicles-Miscellaneous)) + +;;;###autoload +(defcustom icicle-pp-eval-expression-print-length nil + "*Value for `print-length' while printing value in `pp-eval-expression'. +A value of nil means no limit." + :type '(choice (const :tag "No Limit" nil) integer) :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-pp-eval-expression-print-level nil + "*Value for `print-level' while printing value in `pp-eval-expression'. +A value of nil means no limit." + :type '(choice (const :tag "No Limit" nil) integer) :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-prefix-complete-keys '([tab] [(control ?i)]) ; `C-i' is `TAB'. + "*Key sequences to use for `icicle-prefix-complete'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-complete-no-display-keys '([(control meta tab)]) + "*Key sequences to use for `icicle-prefix-complete-no-display'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-next-keys '([down]) + "*Key sequences for prefix completion to cycle to the next candidate. +This is also used to move down a line in the *Completions* buffer. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-prefix-cycle-next-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-next-action-keys '([C-down]) + "*Keys for prefix completion to cycle next and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-prefix-cycle-next-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-next-alt-action-keys '([C-S-down]) + "*Keys for prefix completion to cycle next and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-next-help-keys '([(control meta down)]) ; `C-M-down' + "*Keys for prefix completion to cycle next and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-previous-keys '([up]) + "*Key sequences for prefix completion to cycle to the previous candidate. +This is also used to move up a line in the *Completions* buffer. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-prefix-cycle-previous-action-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-previous-action-keys '([C-up]) + "*Keys for prefix completion to cycle previous and perform action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Option `icicle-use-C-for-actions-flag' swaps these keys with +`icicle-prefix-cycle-previous-keys'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-previous-alt-action-keys '([C-S-up]) + "*Keys for prefix completion to cycle previous and perform alt action. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-prefix-cycle-previous-help-keys '([(control meta up)]) ; `C-M-up' + "*Keys for prefix completion to cycle previous and show candidate help. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-previous-candidate-keys '([S-tab] [S-iso-lefttab]) + ;; $$$$$ The following should be sufficient, but some Emacs 22+ libraries, such as `info.el', + ;; are brain-dead and explicitly bind both `backtab' and `S-tab'. I filed Emacs bug #1281. + ;; (if (> emacs-major-version 21) + ;; '([backtab]) + ;; '([S-tab] [S-iso-lefttab])) + "*Key sequences to use for `icicle-move-to-previous-completion'. +In buffer *Completions*, this moves backward among candidates. + +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards - for example, `S-tab' and `S-iso-lefttab'." +;; In Emacs 22 and later, `backtab' is the canonical key that represents +;; both `S-tab' and `S-iso-lefttab', so that is used in the default +;; value. If, for some reason, `backtab' is not being translated to +;; `S-tab' and `S-iso-lefttab' on your platform, you might want to +;; customize the value to ([S-tab] [S-iso-lefttab]). And if your Emacs +;; version is 22 or later, please file an Emacs bug about the lack of +;; translation. + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-quote-shell-file-name-flag t + "Non-nil means to double-quote the file name that starts a shell command. +This is used by `icicle-read-shell-command-completing'. + +If this is nil, then Emacs commands such as `M-!' will not quote a +shell-command file name such as `c:/Program Files/My Dir/mycmd.exe'. +In that case, a shell such as `bash' fails for a shell command such as +`c:/Program Files/My Dir/mycmd.exe arg1 arg2 &', because it interprets +only `c:/Program' as the shell command. That is, it interprets the +space characters in the file name as separators. If this is non-nil, +then input such as `c:/Program Files/My Dir/mycmd.exe arg1 arg2 &' is +passed to the shell as +`\"c:/Program Files/My Dir/mycmd.exe\" arg1 arg2 &'. + +See the doc string of `icicle-quote-file-name-part-of-cmd' for +information about the characters that, like SPC, lead to quoting." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-read+insert-file-name-keys '([(control meta shift ?f)]) + "*Key sequences to invoke `icicle-read+insert-file-name'. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-redefine-standard-commands-flag t + "*Non-nil means Icicle mode redefines some standard Emacs commands." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-regexp-quote-flag nil ; Toggle with `C-`'. + "*Non-nil means special characters in regexps are escaped. +This means that no characters are recognized as special: they match +themselves. This turns apropos completion into simple substring +completion. It also turns Icicles searching into literal searching. +You can toggle this option from the minibuffer at any +time using `C-`'." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-regexp-search-ring-max (if (boundp 'most-positive-fixnum) + (/ most-positive-fixnum 10) + 13421772) ; 1/10 of `most-positive-fixnum' on Windows. + "*Icicles version of `regexp-search-ring-max'." + :type 'integer :group 'Icicles-Searching) + +;; This is essentially a version of `doremi-increment-color-component' for value only. +;; Must be before `icicle-region-background'. +(defun icicle-increment-color-value (color increment) + "Increase value component (brightness) of COLOR by INCREMENT." + (unless (featurep 'hexrgb) + (error "`icicle-increment-color-value' requires library `hexrgb.el'")) + (unless (string-match "#" color) ; Convert color name to #hhh... + (setq color (hexrgb-color-values-to-hex (x-color-values color)))) + ;; Convert RGB to HSV + (let* ((rgb (x-color-values color)) + (red (/ (float (nth 0 rgb)) 65535.0)) ; Convert from 0-65535 to 0.0-1.0 + (green (/ (float (nth 1 rgb)) 65535.0)) + (blue (/ (float (nth 2 rgb)) 65535.0)) + (hsv (hexrgb-rgb-to-hsv red green blue)) + (hue (nth 0 hsv)) + (saturation (nth 1 hsv)) + (value (nth 2 hsv))) + (setq value (+ value (/ increment 100.0))) + (when (> value 1.0) (setq value (1- value))) + (hexrgb-color-values-to-hex (mapcar (lambda (x) (floor (* x 65535.0))) + (hexrgb-hsv-to-rgb hue saturation value))))) + +;; You can use `icicle-increment-color-value' in place of `icicle-increment-color-hue', if you +;; prefer highlighting background to be slightly darker instead of a slightly different hue. +;; +;;;###autoload +(defcustom icicle-region-background + (if (featurep 'hexrgb) + (let* ((bg (or (and (boundp '1on1-active-minibuffer-frame-background) + 1on1-active-minibuffer-frame-background) ; In `oneonone.el'. + (let ((frame-bg (cdr (assq 'background-color (frame-parameters))))) + (when (member frame-bg '(nil unspecified "unspecified-bg")) + (setq frame-bg (if (eq frame-background-mode 'dark) "Black" "White"))) + (and frame-bg (x-color-defined-p frame-bg) frame-bg)) + (face-background 'region))) + (sat (condition-case nil (hexrgb-saturation bg) (error nil)))) + (if sat + (if (hexrgb-approx-equal sat 0.0) + (icicle-increment-color-value bg ; Grayscale - change bg value slightly. + (if (eq frame-background-mode 'dark) 20 -10)) + (icicle-increment-color-hue bg 24)) ; Color - change bg hue slightly. + (face-background 'region))) + (face-background 'region)) ; Use normal region background. + "*Background color to use for the region during minibuffer cycling. +This has no effect if `icicle-change-region-background-flag' is nil. +If you do not define this explicitly, and if you have loaded library +`hexrgb.el' (recommended), then this color will be slightly +different from your frame background. This still lets you notice the +region, but it makes the region less conspicuous, so you can more +easily read your minibuffer input." + :type (if (and (require 'wid-edit nil t) (get 'color 'widget-type)) 'color 'string) + :group 'Icicles-Minibuffer-Display) + +;;;###autoload +(defcustom icicle-require-match-flag nil + "*Control REQUIRE-MATCH arg to `completing-read' and `read-file-name'. +The possible values are as follows: +- nil means this option imposes nothing on completion; + the REQUIRE-MATCH argument provided to the function governs behavior +- `no-match-required' means the same as a nil value for REQUIRE-MATCH +- `partial-match-ok' means the same as a t value for REQUIRE-MATCH +- `full-match-required' means the same as a non-nil, non-t value for + REQUIRE-MATCH + +Note: This option is provided mainly for use (binding) in +`icicle-define-command' and `icicle-define-file-command'. +You probably do not want to set this globally, but you can." + :type '(choice + (const :tag "Do not impose any match behavior" nil) + (const :tag "Do not require a match" no-match-required) + (const :tag "Require a partial match, with RET" partial-match-ok) + (const :tag "Require a full match" full-match-required)) + :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-saved-completion-sets nil + "*Completion sets available for `icicle-candidate-set-retrieve'. +The form is ((SET-NAME . CACHE-FILE-NAME)...), where SET-NAME is the +name of a set of completion candidates and CACHE-FILE-NAME is the +absolute name of the cache file that contains those candidates. +You normally do not customize this directly, statically. +Instead, you add or remove sets using commands +`icicle-add/update-saved-completion-set' and +`icicle-remove-saved-completion-set'." + :type '(repeat (cons string file)) :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-search-cleanup-flag t + "*Controls whether to remove highlighting after a search. +If this is nil, highlighting can be removed manually with +`\\[icicle-search-highlight-cleanup]'." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-context-match-predicate nil + "*nil or a predicate that candidate search contexts must satisfy. +If nil, then this does nothing. Otherwise, this is a predicate of one +argument, a string, and only search contexts that satisfy it are +displayed. Command `icicle-search' binds internal variable +`icicle-must-pass-predicate' to this value. + +Note: This predicate is different from the predicate used by \ +`\\\\[icicle-narrow-candidates-with-predicate]'. +That predicate takes as argument a full search-context candidate, +which includes the context position." + :type '(choice (const :tag "None" nil) function) :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-search-from-isearch-keys '([S-tab] [S-iso-lefttab]) + ;; $$$$$ The following should be sufficient, but some Emacs 22+ libraries, such as `info.el', + ;; are brain-dead and explicitly bind both `backtab' and `S-tab'. I filed Emacs bug #1281. + ;; (if (> emacs-major-version 21) + ;; '([backtab]) + ;; '([S-tab] [S-iso-lefttab])) + "*Key sequences to use to start `icicle-search' from Isearch. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards - for example, `S-tab' and `S-iso-lefttab'." +;; In Emacs 22 and later, `backtab' is the canonical key that represents +;; both `S-tab' and `S-iso-lefttab', so that is used in the default +;; value. If, for some reason, `backtab' is not being translated to +;; `S-tab' and `S-iso-lefttab' on your platform, you might want to +;; customize the value to ([S-tab] [S-iso-lefttab]). And if your Emacs +;; version is 22 or later, please file an Emacs bug about the lack of +;; translation. + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-search-highlight-all-current-flag nil ; Toggle with `C-^'. + "*Non-nil means highlight input match in each context search hit. +Setting this to non-nil can impact performance negatively, because the +highlighting is updated with each input change. You can toggle this +option from the minibuffer during `C-c`' search using `C-^'." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-highlight-context-levels-flag t + "*Non-nil means highlight 1-8 context levels, within the search context. +Level highlighting is done only when this is non-nil and a subgroup is +not used as the search context, that is, the context corresponds to +the entire search regexp." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-highlight-threshold 100000 + "*Max number of context search hits to highlight at once. +This highlighting uses face `icicle-search-main-regexp-others'." + :type 'integer :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-hook nil + "*List of hook functions run by `icicle-search' (see `run-hooks')." + :type 'hook :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-replace-common-match-flag t ; Toggle with `M-;'. + "*Non-nil means to replace the expanded common match of your input. +This has no effect if either +`icicle-search-highlight-all-current-flag' or +`icicle-expand-input-to-common-match-flag' is nil. +You can toggle those options from the minibuffer using `C-^' and +`C-|', respectively. You can toggle +`icicle-search-replace-common-match-flag' using `M-;'." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-replace-literally-flag nil ; Toggle with `M-`'. + "*Non-nil means to treat replacement text literally. +Otherwise (nil), interpret `\\' specially in replacement text, as in +the LITERAL argument to `replace-match'. + +You can use `M-`' to toggle this at any time during Icicles search." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-replace-whole-candidate-flag t ; Toggle with `C-,'. + "*Non-nil means replacement during search replaces the entire search hit. +Otherwise (nil), replace only what matches your current input. + +You can use `C-,' to toggle this at any time during Icicles search." + :type 'boolean :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-ring-max (if (boundp 'most-positive-fixnum) + (/ most-positive-fixnum 10) + 13421772) ; 1/10 of `most-positive-fixnum' on Windows. + "*Icicles version of `search-ring-max'." + :type 'integer :group 'Icicles-Searching) + +;;;###autoload +(defcustom icicle-search-whole-word-flag nil ; Toggle with `M-q'. + "*Non-nil means that `icicle-search' looks for a whole word. +You can use `M-q' to toggle this at any time during Icicles search." + :type 'boolean :group 'Icicles-Searching) + +;; Based more or less on `shell-dynamic-complete-as-command'. +;; Must be before `icicle-shell-command-candidates-cache'. +(defun icicle-compute-shell-command-candidates () + "Compute shell command candidates from search path, and return them. +The candidates are the executable files in your search path or, if +`shell-completion-execonly' is nil, all files in your search path." + (require 'shell) ; `shell-completion-execonly' + (message "Finding commands in search path...") + (let* ((filenondir "") + (path-dirs (cdr (reverse exec-path))) + (cwd (file-name-as-directory (expand-file-name default-directory))) + (ignored-extensions (and comint-completion-fignore + (mapconcat #'(lambda (x) (concat (regexp-quote x) "$")) + comint-completion-fignore "\\|"))) + (dir "") + (comps-in-dir ()) + (file "") + (abs-file-name "") + (completions ())) + ;; Go through each dir in the search path, finding completions. + (while path-dirs + (setq dir (file-name-as-directory (comint-directory (or (car path-dirs) "."))) + comps-in-dir (and (file-accessible-directory-p dir) + (file-name-all-completions filenondir dir))) + ;; Go see whether it should be used. + (while comps-in-dir + (setq file (car comps-in-dir) + abs-file-name (concat dir file)) + (when (and (not (member file completions)) + (not (and ignored-extensions (string-match ignored-extensions file))) + (or (string-equal dir cwd) (not (file-directory-p abs-file-name))) + (or (null shell-completion-execonly) (file-executable-p abs-file-name))) + (setq completions (cons file completions))) + (setq comps-in-dir (cdr comps-in-dir))) + (setq path-dirs (cdr path-dirs))) + completions)) + +;;;###autoload +(defcustom icicle-shell-command-candidates-cache (and (eq icicle-guess-commands-in-path 'load) + (icicle-compute-shell-command-candidates)) + "Cache for shell command candidates. +You typically do not need to customize this option. +It is an option mainly to persist its value. +See `icicle-guess-commands-in-path'." + :type '(repeat sexp) :group 'Icicles-Miscellaneous) + +;;;###autoload +(if (and (fboundp 'defvaralias) (boundp 'completion-show-help)) + (defvaralias 'icicle-show-Completions-help-flag 'completion-show-help) + (defcustom icicle-show-Completions-help-flag t + "*Non-nil means display help lines at the top of buffer *Completions*." + :type 'boolean :group 'Icicles-Completions-Display)) + +;;;###autoload +(defcustom icicle-show-Completions-initially-flag nil + "*Non-nil means to show buffer *Completions* even without user input. +nil means that *Completions* is shown upon demand, via `TAB' or +`S-TAB'. + +For an alternative but similar behavior to using non-nil for +`icicle-show-Completions-initially-flag', you can set option +`icicle-incremental-completion-flag' to a value that is neither nil +nor t. That displays buffer *Completions* as soon as you type or +delete input, but not initially." + :type 'boolean :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-show-multi-completion-flag t + "*Non-nil means to show completion candidates as multi-completions. +This has an effect only where multi-completion is available. +Also, some commands, such as `icicle-locate-file', use a prefix arg to +determine whether to show multi-completions. Such commands generally +ignore this option. + +A typical example of showing multi-completions is adding buffer names +to candidates to show which buffer they are associated with. Some +commands, such as `icicle-search', append the name of the associated +buffer, highlighted, to the normal completion candidate. This lets +you easily see which buffer the candidate applies to. Also, the +buffer name is part of the candidate, so you can match against it. + +Note: Even when the option value is nil, you can use `C-M-mouse-2' and +so on to see information about a candidate. This information +typically includes whatever a non-nil value of the option would have +shown. + +You can toggle this option from the minibuffer using `M-m'. The new +value takes effect after you exit the minibuffer (i.e., for the next +command)." + :type 'boolean :group 'Icicles-Completions-Display) + +;; This is similar to `bmkp-sort-comparer'. +;;;###autoload +(defcustom icicle-sort-comparer 'icicle-case-string-less-p ; Cycle with `C-,'. + "*Predicate or predicates for sorting (comparing) two items. +Used in particular to sort completion candidates. In that case, this +determines the order of candidates when cycling and their order in +buffer *Completions*. + +When `icicle-cycle-into-subdirs-flag' is non-nil, you might want to +use a function such as `icicle-dirs-last-p' for this option, to +prevent cycling into subdirectories depth first. Command +`icicle-sort-by-directories-last' does that. + +You can cycle completion sort orders at any time using `C-,' in the +minibuffer. + +Although this is a user option, it may be changed by program +locally, for use in particular contexts. In particular, you can bind +this to nil in an Emacs-Lisp function, to inhibit sorting in that +context. + +Various sorting commands change the value of this option dynamically +\(but they do not save the changed value). + +The value must be one of the following: + +* nil, meaning do not sort + +* a predicate that takes two items as args + +* a list of the form ((PRED...) FINAL-PRED), where each PRED and + FINAL-PRED are binary predicates + +If the value is a list of predicates, then each PRED is tried in turn +until one returns a non-nil value. In that case, the result is the +car of that value. If no non-nil value is returned by any PRED, then +FINAL-PRED is used and its value is the result. + +Each PRED should return `(t)' for true, `(nil)' for false, or nil for +undecided. A nil value means that the next PRED decides (or +FINAL-PRED, if there is no next PRED). + +Thus, a PRED is a special kind of predicate that indicates either a +boolean value (as a singleton list) or \"I cannot decide - let the +next guy else decide\". (Essentially, each PRED is a hook function +that is run using `run-hook-with-args-until-success'.) + +Examples: + + nil - No sorting. + + string-lessp - Single predicate that returns nil or non-nil. + + ((p1 p2)) - Two predicates `p1' and `p2', which each return + (t) for true, (nil) for false, or nil for undecided. + + ((p1 p2) string-lessp) + - Same as previous, except if both `p1' and `p2' return + nil, then the return value of `string-lessp' is used. + +Note that these two values are generally equivalent, in terms of their +effect (*): + + ((p1 p2)) + ((p1) p2-plain) where p2-plain is (icicle-make-plain-predicate p2) + +Likewise, these three values generally act equivalently: + + ((p1)) + (() p1-plain) + p1-plain where p1-plain is (icicle-make-plain-predicate p1) + +The PRED form lets you easily combine predicates: use `p1' unless it +cannot decide, in which case try `p2', and so on. The value ((p2 p1)) +tries the predicates in the opposite order: first `p2', then `p1' if +`p2' returns nil. + +Using a single predicate or FINAL-PRED makes it easy to reuse an +existing predicate that returns nil or non-nil. + +You can also convert a PRED-type predicate (which returns (t), (nil), +or nil) into an ordinary predicate, by using function +`icicle-make-plain-predicate'. That lets you reuse elsewhere, as +ordinary predicates, any PRED-type predicates you define. + +Note: As a convention, predefined Icicles PRED-type predicate names +have the suffix `-cp' (for \"component predicate\") instead of `-p'." + ;; We don't bother to define a `icicle-reverse-multi-sort-order' + ;; analogous to `bmkp-reverse-multi-sort-order'. If we did, the doc + ;; string would need to be updated to say what the doc string of + ;; `bmkp-sort-comparer' says about `bmkp-reverse-multi-sort-order'. + :type '(choice + (const :tag "None (do not sort)" nil) + (function :tag "Sorting Predicate") + (list :tag "Sorting Multi-Predicate" + (repeat (function :tag "Component Predicate")) + (choice + (const :tag "None" nil) + (function :tag "Final Predicate")))) + :group 'Icicles-Matching :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-buffer-configs + `(("All" nil nil nil nil ,icicle-sort-comparer) + ("Files" nil nil (lambda (bufname) (buffer-file-name (get-buffer bufname))) nil + ,icicle-sort-comparer) + ("Files and Scratch" nil nil (lambda (bufname) (buffer-file-name (get-buffer bufname))) + ("*scratch*") ,icicle-sort-comparer) + ("All, *...* Buffers Last" nil nil nil nil icicle-buffer-sort-*...*-last)) + "*List of option configurations available for `icicle-buffer-config'. +The form is (CONFIG...), where CONFIG is a list of these items: + + - Configuration name (string) + - `icicle-buffer-match-regexp' value (regexp string) + - `icicle-buffer-no-match-regexp' value (regexp string) + - `icicle-buffer-predicate' value (function) + - `icicle-buffer-extras' value (list of strings) + - `icicle-buffer-sort' value (function) + +A configuration describes which buffer names are displayed during +completion and their order." + :type '(repeat (list + string ; Configuration name + (choice (const :tag "None" nil) (string :tag "Match regexp")) + (choice (const :tag "None" nil) (string :tag "No-match regexp")) + (choice (const :tag "None" nil) (function :tag "Predicate")) ; Predicate + (choice (const :tag "None" nil) (repeat (string :tag "Extra buffer"))) + (choice (const :tag "None" nil) (function :tag "Sort function")))) + :group 'Icicles-Buffers) + +(defun icicle-buffer-sort-*...*-last (buf1 buf2) + "Return non-nil if BUF1 is `string<' BUF2 or only BUF2 starts with \"*\"." + (let ((b1 (if completion-ignore-case (downcase buf1) buf1)) + (b2 (if completion-ignore-case (downcase buf2) buf2))) + (if (string-match "^\\*" b1) + (and (string-match "^\\*" b2) (string< b1 b2)) + (or (string-match "^\\*" b2) (string< b1 b2))))) + +(when (> emacs-major-version 20) + (defcustom icicle-sort-orders-alist () + "*Alist of available sort functions. +This is a pseudo option - you probably do NOT want to customize this. +Instead, use macro `icicle-define-sort-command' to define a new sort +function and automatically add it to this list. + +Each alist element has the form (SORT-ORDER . COMPARER): + + SORT-ORDER is a short string or symbol describing the sort order. + Examples: \"by date\", \"alphabetically\", \"directories first\". + + COMPARER compares two items. It must be acceptable as a value of + `icicle-sort-comparer'." + :type '(alist + :key-type (choice :tag "Sort order" string symbol) + :value-type (choice + (const :tag "None (do not sort)" nil) + (function :tag "Sorting Predicate") + (list :tag "Sorting Multi-Predicate" + (repeat (function :tag "Component Predicate")) + (choice + (const :tag "None" nil) + (function :tag "Final Predicate"))))) + :group 'Icicles-Completions-Display :group 'Icicles-Matching)) + +(unless (> emacs-major-version 20) ; Emacs 20: custom type `alist' doesn't exist. + (defcustom icicle-sort-orders-alist () + "*Alist of available sort functions. +This is a pseudo option - you probably do NOT want to customize this. +Instead, use macro `icicle-define-sort-command' to define a new sort +function and automatically add it to this list. + +Each alist element has the form (SORT-ORDER . COMPARER): + + SORT-ORDER is a short string or symbol describing the sort order. + Examples: \"by date\", \"alphabetically\", \"directories first\". + + COMPARER compares two items. It must be acceptable as a value of + `icicle-sort-comparer'." + :type '(repeat + (cons + (choice :tag "Sort order" string symbol) + (choice + (const :tag "None (do not sort)" nil) + (function :tag "Sorting Predicate") + (list :tag "Sorting Multi-Predicate" + (repeat (function :tag "Component Predicate")) + (choice + (const :tag "None" nil) + (function :tag "Final Predicate")))))) + :group 'Icicles-Completions-Display :group 'Icicles-Matching)) + +;;;###autoload +(defcustom icicle-special-candidate-regexp nil + "*Regexp to match special completion candidates, or nil to do nothing. +The candidates are highlighted in buffer *Completions* using face +`icicle-special-candidate'." + :type '(choice (const :tag "None" nil) regexp) :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-S-TAB-completion-methods-alist ; Cycle with `M-('. + `(("apropos" . string-match) + ("scatter" . icicle-scatter-match) + ,@(and (require 'levenshtein nil t) + '(("Levenshtein" . icicle-levenshtein-match) + ("Levenshtein strict" . icicle-levenshtein-strict-match)))) + "*Alist of completion methods used by `S-TAB'. +Each element has the form (NAME . FUNCTION), where NAME is a string +name and FUNCTION is the completion match function. NAME is used in +messages to indicate the type of completion matching. + +By default, `S-TAB' is the key for this completion. The actual keys +used are the value of option `icicle-apropos-complete-keys'. + +See also option `icicle-TAB-completion-methods'." + :type '(alist + :key-type (string :tag "Name used in messages") + :value-type (symbol :tag "Completion matching function")) + :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-swank-prefix-length 1 + "*Length (chars) of symbol prefix that much match, for swank completion." + :type 'integer :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-swank-timeout 3000 + "*Number of msec before swank (fuzzy symbol) completion gives up." + :type 'integer :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-TAB-completion-methods ; Cycle with `C-('. + (let ((methods ())) + (when (require 'el-swank-fuzzy nil t) (push 'swank methods)) + (when (require 'fuzzy-match nil t) (push 'fuzzy methods)) + (when (boundp 'completion-styles) (push 'vanilla methods)) + (push 'basic methods) + methods) + "*List of completion methods to use for \ +`\\\\[icicle-prefix-complete]'. +The first method in the list is the default method. + +The available methods can include these: + +1. `basic' +2. `vanilla' (provided you have Emacs 23 or later) +3. `fuzzy' (provided you have library `fuzzy-match.el') +4. `swank' (provided you have library `el-swank-fuzzy.el') + +1. Basic completion means ordinary prefix completion. It is the +`basic' completion style of Emacs 23 or later, and it is essentially +the completion style prior to Emacs 23 (Emacs 22 completion was +slightly different - see Emacs 23 option `custom-styles' for more +info). + +2. Vanilla completion respects option `completion-styles' (new in +Emacs 23), so that `TAB' behaves similarly in Icicles to what it does +in vanilla Emacs. The vanilla method also completes environment +variables during file-name completion and in shell commands. The +non-vanilla methods do not complete environment variables, but the +variables are expanded to their values when you hit `RET'. + +3. Fuzzy completion is a form of prefix completion in which matching +finds the candidates that have the most characters in common with your +input, in the same order, and with a minimum of non-matching +characters. It can skip over non-matching characters, as long as the +number of characters skipped in the candidate is less that those +following them that match. After the matching candidates are found, +they are sorted by skip length and then candidate length. + +Fuzzy completion is described in detail in the commentary of library +`fuzzy-match.el'. There is no fuzzy completion of file names - fuzzy +completion is the same as basic for file names. Fuzzy completion is +always case-sensitive. + +4. Swank completion in Icicles is the same as fuzzy completion, except +regarding symbols. That is, swank completion per se applies only to +symbols. Symbols are completed using the algorithm of library +`el-swank-fuzzy.el'. + +Icicles options `icicle-swank-timeout' and +`icicle-swank-prefix-length' give you some control over the behavior. +When the `TAB' completion method is `swank', you can use `C-x 1' +\(`icicle-doremi-increment-swank-timeout+') and `C-x 2' +\(`icicle-doremi-increment-swank-prefix-length+') in the minibuffer to +increment these options on the fly using the arrow keys `up' and +`down'. + +Swank symbol completion uses heuristics that relate to supposedly +typical patterns found in symbol names. It also uses a timeout that +can limit the number of matches. It is generally quite a bit slower +than fuzzy completion, and it sometimes does not provide all +candidates that you might think should match, even when all of your +input is a prefix (or even when it is already complete!). If swank +completion produces no match when you think it should, remember that +you can use `\\[icicle-next-TAB-completion-method]' on the fly to \ +change the completion method. + + +If you do not customize `icicle-TAB-completion-methods', then the +default value (that is, the available `TAB' completion methods) will +reflect your current Emacs version and whether you have loaded +libraries `fuzzy-match.el' and `el-swank-fuzzy.el'. + +By default, `TAB' is the key for this completion. The actual keys +used are the value of option `icicle-prefix-complete-keys'. + +See also option `icicle-S-TAB-completion-methods-alist'." + :type (let ((methods ())) + (when (require 'el-swank-fuzzy nil t) + (push '(const :tag "Swank (Fuzzy Symbol)" swank) methods)) + (when (require 'fuzzy-match nil t) + (push '(const :tag "Fuzzy" fuzzy) methods)) + (when (boundp 'completion-styles) + (push '(const :tag "Vanilla `completion-styles'" vanilla) methods)) + (push '(const :tag "Basic" basic) methods) + `(repeat (choice ,@methods))) + :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-TAB-shows-candidates-flag t + "*Non-nil means that `TAB' always shows completion candidates. +Otherwise (nil), follow the standard Emacs behavior of completing to +the longest common prefix, and only displaying the candidates after a +second `TAB'. + +Actually, the concerned keys are those defined by option +`icicle-prefix-complete-keys', not necessarily `TAB'." + :type 'boolean :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-test-for-remote-files-flag t ; Toggle with `C-^'. + "*Non-nil means Icicles tests for remote file names. +A value of nil turns off all handling of remote file names by Tramp, +including file-name completion. + +The testing due to a non-nil value takes a little time, but the test +result saves time with Tramp handling, and it is used to avoid some +other costly operations when a file is determined to be remote. These +operations are (a) incremental completion and (b) highlighting of the +part of your current input that does not complete. + +Use a nil value only when you are sure that the file names you are +completing are local. The effect will be a slight speed increase for +operations (a) and (b) for local files. + +In addition, a nil value has the effect of ignoring the restriction of +input mismatch highlighting to strict completion. That is, it treats +an `icicle-highlight-input-completion-failure' value of +`explicit-strict' or `implicit-strict' as if it were `implicit'. The +assumption here is that you use these highlighting values only to +avoid the cost of remote file name completion. + +You can toggle this option from the minibuffer using `C-^' (except +during Icicles search)." + :initialize (lambda (opt-name val) (set opt-name t)) + :set #'(lambda (opt-name val) + (or (not (require 'tramp nil t)) + (prog1 (set opt-name (not val)) + (icicle-toggle-remote-file-testing)))) + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-thing-at-point-functions + (progn (or (require 'ffap- nil t) (require 'ffap nil t)) ; Try `ffap-.el' first. + (cons + ;; 1) Lisp symbol or file name, 2) region-or-word, 3) Ffap, 4)url. + `(,(if (fboundp 'symbol-name-nearest-point) + 'symbol-name-nearest-point + (lambda () (symbol-name (symbol-at-point)))) + ,(if (fboundp 'region-or-word-nearest-point) + 'region-or-word-nearest-point + (lambda () (thing-at-point 'word))) + ,@(and (fboundp 'ffap-guesser) '(ffap-guesser)) + thing-at-point-url-at-point) + 'forward-word)) + "*Functions that return a string at or near the cursor when you use `M-.'. +A cons cell whose car and cdr may each be empty. + +The car of the cons cell is a list of functions that grab different +kinds of strings at or near point. By default, there are four +functions, which grab 1) whatever `ffap-guesser' finds, 2) the symbol +or file name, 3) the word, 4) the URL at point. Any number of +functions can be used. They are used in sequence by command +`icicle-insert-string-at-point' (bound to `M-.'). + +The cdr of the cons cell is nil or a function that advances point one +text thing. Each time command `icicle-insert-string-at-point' is +called successively, this is called to grab more things of text (of +the same kind). By default, successive words are grabbed. + +If either the car or cdr is empty, then the other alone determines the +behavior of `icicle-insert-string-at-point'. Otherwise, option +`icicle-default-thing-insertion' determines whether the car or cdr is +used by `icicle-insert-string-at-point'. `C-u' with no number +reverses the meaning of `icicle-default-thing-insertion'." + :type + '(cons + (choice + (repeat (function :tag "Function to grab some text at point and insert it in minibuffer")) + (const :tag "No alternative text-grabbing functions" nil)) + (choice + (const :tag "No function to successively grab more text" nil) + (function :tag "Function to advance point one text thing"))) + :group 'Icicles-Miscellaneous) + +;; Must be before `icicle-top-level-key-bindings'. +(define-widget 'icicle-key-definition 'lazy + "Key definition type for Icicle mode keys. +A list of three components: KEY, COMMAND, CONDITION, that represents +an `icicle-mode-map' binding of COMMAND according to KEY, if CONDITION +evaluates to non-nil. + +KEY is either a key sequence (string or vector) or a command. +COMMAND is a command. +CONDITION is a sexp. + +If KEY is a command, then the binding represented is its remapping to +COMMAND." + :indent 1 :offset 0 :tag "" ; $$$$$ "Icicle Mode Key Definition" + :type + '(list + (choice + (key-sequence :tag "Key" :value [ignore]) + ;; Use `symbolp' instead of `commandp', in case the library defining the + ;; command is not loaded. + (restricted-sexp :tag "Command to remap" :match-alternatives (symbolp) :value ignore)) + ;; Use `symbolp' instead of `commandp'... + (restricted-sexp :tag "Command" :match-alternatives (symbolp) :value ignore) + (sexp :tag "Condition"))) + +;; Must be before `icicle-top-level-key-bindings'. +(defun icicle-remap (old new map &optional oldmap) + "Bind command NEW in MAP to all keys currently bound to OLD. +If command remapping is available, use that. Otherwise, bind NEW to +whatever OLD is bound to in MAP, or in OLDMAP, if provided." + (if (fboundp 'command-remapping) + (define-key map (vector 'remap old) new) ; Ignore OLDMAP for Emacs 22. + (substitute-key-definition old new map oldmap))) + +;; Must be before `icicle-top-level-key-bindings'. +(defun icicle-bind-top-level-commands (&optional defs) + "Bind top-level commands for Icicle mode." + (unless defs (setq defs icicle-top-level-key-bindings)) + (let (key command condition) + (dolist (key-def defs) + (setq key (car key-def) + command (cadr key-def) + condition (car (cddr key-def))) + (when (eval condition) + (if (symbolp key) + (icicle-remap key command icicle-mode-map (current-global-map)) + (define-key icicle-mode-map key command)))))) + +;; Must be before `icicle-top-level-key-bindings'. +;;;###autoload +(defcustom icicle-yank-function 'yank + "*Yank function. A function that takes a prefix argument. This +should be a command that is bound to whatever key you use to yank +text, whether in Icicle mode or not. In Icicle mode, command +`icicle-yank-maybe-completing' calls this function, except when +`icicle-yank-maybe-completing' is called from the minibuffer or called +with a negative prefix argument. `icicle-yank-maybe-completing' +passes the raw prefix argument to `icicle-yank-function'. + +By default (see option `icicle-top-level-key-bindings'), the command +that is the value of this option is remapped to +`icicle-yank-maybe-completing' the first time you enter Icicle mode. +If you customize `icicle-yank-function', then, to take advantage of +this default remapping behavior, you will need to save your +customization and then restart Emacs. + +Alternatively, you can customize both `icicle-yank-function' and the +corresponding entry in `icicle-top-level-key-bindings', and then +toggle Icicle mode off and then back on." + :type 'function :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-top-level-key-bindings + `((,(kbd "") icicle-switch-to/from-minibuffer t) ; `pause' + (,(kbd "C-c `") icicle-search-generic t) ; `C-c `' + (,(kbd "C-c $") icicle-search-word t) ; `C-c $' + (,(kbd "C-c ^") icicle-search-keywords t) ; `C-c ^' + (,(kbd "C-c '") icicle-occur t) ; `C-c '' + (,(kbd "C-c =") icicle-imenu t) ; `C-c =' + (,(kbd "C-c \"") icicle-search-text-property t) ; `C-c "' + (,(kbd "C-c /") icicle-complete-thesaurus-entry t) ; `C-c /' + (,(kbd "C-x M-e") icicle-execute-named-keyboard-macro t) ; `C-x M-e' + (,(kbd "C-x SPC") icicle-command-abbrev t) ; `C-x SPC' + (,(kbd "C-x 5 o") icicle-select-frame t) ; `C-x 5 o' + (,(kbd "C-h C-o") icicle-describe-option-of-type t) ; `C-h C-o' + ,@(and (require 'kmacro nil t) ; (Emacs 22+) + `((,(kbd "S-") icicle-kmacro t))) ; `S-f4' + (abort-recursive-edit icicle-abort-recursive-edit t) ; `C-]' + (bookmark-jump icicle-bookmark t) ; `C-x r b' + (bookmark-jump-other-window icicle-bookmark-other-window t) ; `C-x 4 j j' + (bookmark-set icicle-bookmark-cmd t) ; `C-x r m' + (minibuffer-keyboard-quit icicle-abort-recursive-edit ; `C-g' (minibuffer - `delsel.el') + (fboundp 'minibuffer-keyboard-quit)) + (delete-window icicle-delete-window t) ; `C-x 0' + (delete-windows-for icicle-delete-window t) ; `C-x 0' (`frame-cmds.el') + (dired icicle-dired t) ; `C-x d' + (dired-other-window icicle-dired-other-window t) ; `C-x 4 d' + (exchange-point-and-mark icicle-exchange-point-and-mark t) ; `C-x C-x' + (execute-extended-command icicle-execute-extended-command t) ; `M-x' + (find-file icicle-file t) ; `C-x C-f' + (find-file-other-window icicle-file-other-window t) ; `C-x 4 f' + (find-file-read-only icicle-find-file-read-only t) ; `C-x C-r' + (find-file-read-only-other-window + icicle-find-file-read-only-other-window t) ; `C-x 4 r' + ;; There are no key bindings in vanilla Emacs for `insert-buffer'. + ;; If you use `setup-keys.el', then these are its bindings: `C-S-insert', `M-S-f1'. + (insert-buffer icicle-insert-buffer t) + (kill-buffer icicle-kill-buffer t) ; `C-x k' + (kill-buffer-and-its-windows icicle-kill-buffer t) ; `C-x k' (`misc-cmds.el') + (other-window icicle-other-window-or-frame t) ; `C-x o' + (other-window-or-frame icicle-other-window-or-frame t) ; `C-x o' (`frame-cmds.el') + (pop-global-mark + icicle-goto-global-marker-or-pop-global-mark t) ; `C-x C-@', `C-x C-SPC' + (set-mark-command + icicle-goto-marker-or-set-mark-command t) ; `C-@', `C-SPC' + (switch-to-buffer icicle-buffer t) ; `C-x b' + (switch-to-buffer-other-window icicle-buffer-other-window t) ; `C-x 4 b' + (where-is icicle-where-is t) ; `C-h w' + (,icicle-yank-function icicle-yank-maybe-completing t) ; `C-y' + + ;; These are available only if you use library `bookmark+.el'. + ;; + ;; (Other-window means nothing for a bookmark list or a desktop.) + (bmkp-bookmark-list-jump + icicle-bookmark-bookmark-list (featurep 'bookmark+)) ; `C-x j B' + (bmkp-desktop-jump + icicle-bookmark-desktop (featurep 'bookmark+)) ; `C-x j K' + (bmkp-dired-jump + icicle-bookmark-dired (featurep 'bookmark+)) ; `C-x j d' + (bmkp-dired-jump-other-window + icicle-bookmark-dired-other-window (featurep 'bookmark+)) ; `C-x 4 j d' + (bmkp-file-jump + icicle-bookmark-file (featurep 'bookmark+)) ; `C-x j f' + (bmkp-file-jump-other-window + icicle-bookmark-file-other-window (featurep 'bookmark+)) ; `C-x 4 j f' + (bmkp-gnus-jump + icicle-bookmark-gnus (featurep 'bookmark+)) ; `C-x j g' + (bmkp-gnus-jump-other-window + icicle-bookmark-gnus-other-window (featurep 'bookmark+)) ; `C-x 4 j g' + (bmkp-info-jump + icicle-bookmark-info (featurep 'bookmark+)) ; `C-x j i' + (bmkp-info-jump-other-window + icicle-bookmark-info-other-window (featurep 'bookmark+)) ; `C-x 4 j i' + (bmkp-local-file-jump + icicle-bookmark-local-file (featurep 'bookmark+)) ; `C-x j l' + (bmkp-local-file-jump-other-window + icicle-bookmark-local-file-other-window (featurep 'bookmark+)) ; `C-x 4 j l' + (bmkp-man-jump + icicle-bookmark-man (featurep 'bookmark+)) ; `C-x j m' + (bmkp-man-jump-other-window + icicle-bookmark-man-other-window (featurep 'bookmark+)) ; `C-x 4 j m' + (bmkp-non-file-jump + icicle-bookmark-non-file (featurep 'bookmark+)) ; `C-x j b' + (bmkp-non-file-jump-other-window + icicle-bookmark-non-file-other-window (featurep 'bookmark+)) ; `C-x 4 j b' + (bmkp-region-jump + icicle-bookmark-region (featurep 'bookmark+)) ; `C-x j r' + (bmkp-region-jump-other-window + icicle-bookmark-region-other-window (featurep 'bookmark+)) ; `C-x 4 j r' + (bmkp-remote-file-jump + icicle-bookmark-remote-file (featurep 'bookmark+)) ; `C-x j n' + (bmkp-remote-file-jump-other-window + icicle-bookmark-remote-file-other-window (featurep 'bookmark+)) ; `C-x 4 j n' + (bmkp-specific-buffers-jump + icicle-bookmark-specific-buffers (featurep 'bookmark+)) ; `C-x j = b' + (bmkp-specific-buffers-jump-other-window + icicle-bookmark-specific-buffers-other-window (featurep 'bookmark+)) ; `C-x 4 j = b' + (bmkp-specific-files-jump + icicle-bookmark-specific-files (featurep 'bookmark+)) ; `C-x j = f' + (bmkp-specific-files-jump-other-window + icicle-bookmark-specific-files-other-window (featurep 'bookmark+)) ; `C-x 4 j = f' + (bmkp-this-buffer-jump + icicle-bookmark-this-buffer (featurep 'bookmark+)) ; `C-x j .' + (bmkp-this-buffer-jump-other-window + icicle-bookmark-this-buffer-other-window (featurep 'bookmark+)) ; `C-x 4 j .' + (bmkp-all-tags-jump + icicle-bookmark-all-tags (featurep 'bookmark+)) ; `C-x j t *' + (bmkp-all-tags-jump-other-window + icicle-bookmark-all-tags-other-window (featurep 'bookmark+)) ; `C-x 4 j t *' + (bmkp-all-tags-jump + icicle-bookmark-all-tags-regexp (featurep 'bookmark+)) ; `C-x j t % *' + (bmkp-all-tags-regexp-jump-other-window + icicle-bookmark-all-tags-regexp-other-window (featurep 'bookmark+)) ; `C-x 4 j t % *' + (bmkp-some-tags-jump + icicle-bookmark-some-tags (featurep 'bookmark+)) ; `C-x j t +' + (bmkp-some-tags-jump-other-window + icicle-bookmark-some-tags-other-window (featurep 'bookmark+)) ; `C-x 4 j t +' + (bmkp-some-tags-jump + icicle-bookmark-some-tags-regexp (featurep 'bookmark+)) ; `C-x j t % +' + (bmkp-some-tags-regexp-jump-other-window + icicle-bookmark-some-tags-regexp-other-window (featurep 'bookmark+)) ; `C-x 4 j t % +' + (bmkp-url-jump + icicle-bookmark-url (featurep 'bookmark+)) ; `C-x j u' + (bmkp-url-jump-other-window + icicle-bookmark-url-other-window (featurep 'bookmark+)) ; `C-x 4 j u' + (bmkp-w3m-jump + icicle-bookmark-w3m (featurep 'bookmark+)) ; `C-x j w' + (bmkp-w3m-jump-other-window + icicle-bookmark-w3m-other-window (featurep 'bookmark+)) ; `C-x 4 j w' + + ;; Don't let Emacs 20 or 21 use `substitute-key-definition' on `M-.' or `M-*', since we need + ;; these keys for the minibuffer. Leave them unbound in `icicle-mode-map' until Emacs 22+. + (find-tag icicle-find-tag (fboundp 'command-remapping)) ; `M-.' + (find-tag-other-window icicle-find-first-tag-other-window t) ; `C-x 4 .' + (pop-tag-mark icicle-pop-tag-mark (fboundp 'command-remapping)) ; `M-*' + (eval-expression icicle-pp-eval-expression (fboundp 'command-remapping)) ; `M-:' + (pp-eval-expression icicle-pp-eval-expression (fboundp 'command-remapping)) ;`M-:' (`pp+.el') + ;; For La Carte (`lacarte.el'), not Icicles, but it's convenient to do this here. + (,(kbd "ESC M-x") lacarte-execute-command ; `ESC M-x' + (fboundp 'lacarte-execute-command)) + (,(kbd "M-`") lacarte-execute-menu-command ; `M-`' - replaces `tmm-menubar'. + (fboundp 'lacarte-execute-menu-command)) + (,(kbd "") lacarte-execute-menu-command ; `f10' - replaces `menu-bar-open'. + (fboundp 'lacarte-execute-menu-command))) + "*List of top-level commands to bind in Icicle mode. +Each list element is of custom type `icicle-key-definition' and has +the form (KEY COMMAND CONDITION). + +KEY is either a key sequence (string or vector) to bind COMMAND to or +a command to remap to COMMAND. +COMMAND is bound according to the value of KEY, unless the result of +evaluating CONDITION is nil. + +In Customize, to specify a key sequence, choose `Key' in the `Value +Menu', then enter a key description such as that returned by `C-h k'. +For convenience, you can use insert each key in the key description by +hitting `C-q' then the key. For example, to enter the key description +`C-c M-k' you can use `C-q C-c C-q M-k'. + +If you customize this option, then you must exit and re-enter Icicle +mode to ensure that the change takes effect. This is really necessary +only if your changes would undefine a key. + +For this option to have an effect upon startup, it must be set before +you enter Icicle mode. This means that you must ensure that the code +that sets it is invoked before you enter Icicle mode. If you use +Customize to change this option, then ensure that the code inserted by +Customize into your `user-init-file' or your `custom-file' is invoked +before you enter Icicle mode." + :type (if (> emacs-major-version 20) + '(repeat icicle-key-definition) + '(repeat + (list + (choice + (restricted-sexp :tag "Key" + :match-alternatives ((lambda (x) (or (stringp x) (vectorp x)))) + :value [ignore]) + (restricted-sexp :tag "Command to remap" + ;; Use `symbolp' instead of `commandp', in case the library defining the + ;; command is not loaded. + :match-alternatives (symbolp) :value ignore)) + ;; Use `symbolp' instead of `commandp'... + (restricted-sexp :tag "Command" + :match-alternatives (symbolp) :value ignore) + (sexp :tag "Condition")))) + :set #'(lambda (sym defs) + (custom-set-default sym defs) + (icicle-bind-top-level-commands defs)) + :initialize #'custom-initialize-default + :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-top-level-when-sole-completion-delay 0.7 + "*Number of secs to wait to return to top level if only one completion. +This has no effect if `icicle-top-level-when-sole-completion-flag' is +nil. Editing the completion (typing or deleting a character) before +the delay expires prevents its automatic acceptance. + +Do not set this to 0.0. Set it to slightly more than zero if you want +instant action." + :type 'number :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-top-level-when-sole-completion-flag nil + "*Non-nil means to return to top level if only one matching completion. +The sole completion is accepted." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-touche-pas-aux-menus-flag nil + "*Non-nil means do not add items to menus except Minibuf and Icicles. +This value is used only when Icicles mode is initially established, so +changing this has no effect after Icicles has been loaded. However, +you can change it and save the new value so it will be used next time. + +For this option to have an effect upon startup, it must be set before +you enter Icicle mode. This means that you must ensure that the code +that sets it is invoked before you enter Icicle mode. If you use +Customize to change this option, then ensure that the code inserted by +Customize into your `user-init-file' or your `custom-file' is invoked +before you enter Icicle mode." + :type 'boolean :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-transform-function nil ; Toggle with `C-$,'. + "*Function used to transform the list of completion candidates. +This is applied to the list of initial candidates. +If this is nil, then no transformation takes place. + +You can toggle this option at any time from the minibuffer using +`C-$,'. + +NOTE: Although this is a user option, you probably do *NOT* want to +customize it. Icicles commands already \"do the right thing\" when it +comes to candidate transformation. The value of this option may be +changed by program locally, for use in particular contexts. For +example, when you use `C-c C-`' (\ `icicle-search-generic') in a +*shell* buffer, Icicles uses this variable with a value of +`icicle-remove-duplicates', to remove duplicate shell commands from +your input history list. + +Emacs-Lisp programmers can use this variable to transform the list of +candidates in any way they like. A typical use is to remove +duplicates, by binding it to `icicle-remove-duplicates' or +`icicle-remove-dups-if-extras'." + :type '(choice (const :tag "None" nil) function) :group 'Icicles-Completions-Display) + +;;;###autoload +(defcustom icicle-type-actions-alist + '(("buffer" + (lambda (b) (with-current-buffer b (ps-print-buffer))) ; E.g. showing you can use lambda. + 1-window-frames-on another-buffer browse-url-of-buffer buffer-disable-undo + buffer-enable-undo buffer-file-name buffer-local-variables buffer-modified-p + buffer-name buffer-size bury-buffer choose-grep-buffer current-line-string + delete-1-window-frames-on delete-windows-for delete-windows-on + delete/iconify-windows-on describe-buffer-bindings diff-buffer-with-file + display-buffer display-buffer-other-frame echo-in-buffer eval-buffer fontify-buffer + generate-new-buffer get-buffer get-buffer-process get-buffer-window + get-buffer-window-list grepp-choose-grep-buffer ibuffer-jump-to-buffer + icicle-char-properties-in-buffer icicle-delete-window icicle-delete-windows-on + icicle-help-line-buffer icicle-kill-a-buffer insert-buffer insert-buffer-substring + insert-buffer-substring-as-yank insert-buffer-substring-no-properties kill-buffer + kill-buffer-and-its-windows kill-buffer-if-not-modified last-buffer + multi-window-frames-on other-buffer pop-to-buffer pr-interface remove-windows-on + replace-buffer-in-windows smiley-buffer switch-to-buffer switch-to-buffer-other-frame + switch-to-buffer-other-window view-buffer view-buffer-other-frame + view-buffer-other-window) + ("color" + color-defined-p color-gray-p color-supported-p color-values colors + doremi-set-background-color doremi-set-foreground-color eyedrop-color-message + facemenu-set-background facemenu-set-foreground hexrgb-blue hexrgb-color-name-to-hex + hexrgb-complement hexrgb-green hexrgb-hex-to-color-values hexrgb-hue hexrgb-red + hexrgb-saturation hexrgb-value icicle-color-help icicle-color-name-w-bg + palette-brightness-scale palette-color-message palette-complement-or-alternative + palette-hex-info palette-hsv-info palette-rgb-info palette-swatch ps-e-color-values + ps-e-x-color-values set-background-color set-border-color set-cursor-color + set-foreground-color set-mouse-color tty-color-canonicalize tty-color-desc + tty-color-standard-values tty-color-translate tty-color-values x-color-defined-p + x-color-values) + ("command" + command-remapping define-prefix-command describe-command disable-command + doremi-push-frame-config-for-command enable-command Info-find-emacs-command-nodes + Info-goto-emacs-command-node) + ("face" + color-theme-spec custom-facep customize-face customize-face-other-window + custom-theme-recalc-face describe-face face-all-attributes face-attr-construct + face-background face-background-20+ face-background-pixmap face-bold-p + face-default-spec face-differs-from-default-p face-doc-string face-documentation + face-font face-foreground face-foreground-20+ face-id face-inverse-video-p + face-italic-p face-nontrivial-p face-spec-reset-face face-stipple face-underline-p + face-user-default-spec facemenu-add-face facemenu-add-new-face facemenu-set-face + find-face-definition hlt-choose-default-face hlt-show-default-face + hlt-unhighlight-region-for-face icicle-customize-face + icicle-customize-face-other-window invert-face make-face make-face-bold + make-face-bold-italic make-face-italic make-face-unbold make-face-unitalic + moccur-face-check modify-face ps-face-attributes read-all-face-attributes + read-face-font) + ("file" + abbreviate-file-name ange-ftp-chase-symlinks ange-ftp-file-modtime apropos-library + auto-coding-alist-lookup bookmark-file-or-variation-thereof bookmark-load + browse-url-of-file byte-compile-file check-declare-file comint-append-output-to-file + comint-quote-filename comint-substitute-in-file-name comint-unquote-filename + comint-write-output compilation-get-file-structure cookie-insert create-file-buffer + delete-file describe-file dired-delete-file diredp-mouse-diff dired-show-file-type + dir-locals-find-file dir-locals-read-from-file do-after-load-evaluation ebnf-eps-file + ebnf-print-file ebnf-spool-file ebnf-syntax-file ediff-backup epa-decrypt-file + epa-import-keys epa-verify-file eval-next-after-load ffap-file-remote-p + ffap-locate-file file-attributes file-cache-add-file file-chase-links + file-dependents file-directory-p file-executable-p file-exists-p + file-loadhist-lookup file-local-copy file-modes file-name-nondirectory + file-newest-backup file-nlinks file-ownership-preserved-p file-provides + file-readable-p file-regular-p file-relative-name file-remote-p file-requires + file-symlink-p file-system-info file-truename file-writable-p find-alternate-file + find-alternate-file-other-window find-buffer-visiting finder-commentary find-file + find-file-at-point find-file-binary find-file-literally find-file-noselect + find-file-other-frame find-file-other-window find-file-read-only + find-file-read-only-other-frame find-file-read-only-other-window find-file-text + get-file-buffer gnus-audio-play gnus-convert-png-to-face hexl-find-file + highlight-compare-with-file icicle-add-file-to-fileset + icicle-delete-file-or-directory icicle-describe-file icicle-file-remote-p + icicle-help-line-file icicle-search-file icicle-shell-command-on-file + image-type-from-file-header image-type-from-file-name Info-find-file Info-index-nodes + info-lookup-file Info-toc-nodes info-xref-check insert-file insert-file-literally + insert-image-file list-tags lm-commentary lm-creation-date lm-keywords lm-keywords-list + lm-last-modified-date lm-summary lm-synopsis lm-verify lm-version load load-file + load-history-regexp make-backup-file-name move-file-to-trash open-dribble-file + open-termscript play-sound-file pr-ps-file-preview pr-ps-file-print + pr-ps-file-ps-print pr-ps-file-using-ghostscript recentf-add-file recentf-push + recentf-remove-if-non-kept recover-file rmail-input rmail-output set-file-times + set-visited-file-name substitute-in-file-name system-move-file-to-trash + untranslated-canonical-name untranslated-file-p url-basepath vc-backend + vc-delete-automatic-version-backups vc-file-clearprops vc-insert-file + vc-make-version-backup vc-name vc-state vc-working-revision view-file + view-file-other-frame view-file-other-window visit-tags-table w32-browser + w32-long-file-name w32-short-file-name w32explore woman-find-file write-file + xml-parse-file) + ("frame" + current-window-configuration delete-frame delete-other-frames thumfr-dethumbify-frame + doremi-undo-last-frame-color-change thumfr-fisheye fit-frame fit-frame-maximize-frame + fit-frame-minimize-frame fit-frame-restore-frame frame-char-height frame-char-width + frame-current-scroll-bars frame-extra-pixels-height frame-extra-pixels-width + frame-face-alist frame-first-window frame-focus frame-height frame-iconified-p + frame-parameters frame-pixel-height frame-pixel-width frame-root-window + frame-selected-window frame-set-background-mode frame-terminal + frame-update-face-colors frame-visible-p frame-width get-a-frame get-frame-name + hide-frame icicle-select-frame-by-name iconify-frame lower-frame + make-frame-invisible make-frame-visible maximize-frame maximize-frame-horizontally + maximize-frame-vertically menu-bar-open minimize-frame next-frame + thumfr-only-raise-frame previous-frame raise-frame really-iconify-frame + redirect-frame-focus redraw-frame restore-frame restore-frame-horizontally + restore-frame-vertically select-frame select-frame-set-input-focus set-frame-name + show-frame thumfr-thumbify-frame thumfr-thumbify-other-frames thumfr-thumbnail-frame-p + thumfr-toggle-thumbnail-frame toggle-max-frame toggle-max-frame-horizontally + toggle-max-frame-vertically toggle-zoom-frame tty-color-alist tty-color-clear + w32-focus-frame window-list window-system window-tree x-focus-frame zoom-frm-in + zoom-frm-out zoom-frm-unzoom) + ("function" + cancel-function-timers describe-function elp-instrument-function find-function + find-function-other-frame find-function-other-window symbol-function trace-function + trace-function-background) + ("option" custom-note-var-changed customize-option customize-option-other-window + describe-option icicle-binary-option-p tell-customize-var-has-changed) + ("process" + accept-process-output anything-kill-async-process clone-process continue-process + delete-process get-process interrupt-process kill-process process-buffer + process-coding-system process-command process-contact process-exit-status + process-filter process-filter-multibyte-p process-id + process-inherit-coding-system-flag process-kill-without-query process-mark + process-name process-plist process-query-on-exit-flag process-running-child-p + process-send-eof process-sentinel process-status process-tty-name process-type + quit-process set-process-coding-system stop-process tooltip-process-prompt-regexp + tq-create) + ("symbol" + apropos-describe-plist apropos-macrop apropos-score-symbol byte-compile-const-symbol-p + custom-guess-type custom-unlispify-tag-name custom-variable-type default-boundp + default-value describe-minor-mode-from-symbol fmakunbound + icicle-help-on-candidate-symbol info-lookup-symbol makunbound symbol-file + symbol-function symbol-plist symbol-value) + ("variable" + custom-type custom-variable-documentation custom-variable-p custom-variable-type + describe-variable find-variable find-variable-noselect find-variable-other-frame + find-variable-other-window help-custom-type icicle-custom-type kill-local-variable + local-variable-if-set-p local-variable-p make-local-variable make-variable-buffer-local + make-variable-frame-local symbol-value user-variable-p variable-binding-locus) + ("window" + balance-windows browse-kill-ring-fit-window compilation-set-window-height + delete-other-windows delete-other-windows-vertically delete-window + delete/iconify-window fit-frame-max-window-size fit-window-to-buffer + mouse-drag-vertical-line-rightward-window mouse-drag-window-above next-window + previous-window remove-window select-window shrink-window-if-larger-than-buffer + split-window truncated-partial-width-window-p window--display-buffer-1 + window--even-window-heights window--try-to-split-window window-body-height + window-buffer window-buffer-height window-current-scroll-bars window-dedicated-p + window-display-table window-edges window-end window-fixed-size-p window-frame + window-fringes window-full-width-p window-height window-hscroll window-inside-edges + window-inside-pixel-edges window-margins window-minibuffer-p window-parameters + window-pixel-edges window-point window-safely-shrinkable-p window-scroll-bars + window-start window-text-height window-vscroll window-width)) + "*Alist of Emacs object types and associated actions. +Each element has the form (TYPE FUNCTION...), where TYPE names an +object type, and each FUNCTION accepts an object of type TYPE as its +only required argument + +A FUNCTION here can be a symbol or a lambda form. You can use a +symbol that is not yet `fboundp', that is, one that does not yet have +a function definition. Any symbols that do not have function +definitions when this option is used are simply filtered out. + +However, just because a function is defined at runtime does not mean +that it will work. For example, function `buffer-size' is included in +the default value for type `buffer', but in Emacs 20 `buffer-size' +accepts no arguments, so applying it to a buffer name raises an error. + +\[Note: If you have suggestions or corrections for the default value, +send them in, using `\\[icicle-send-bug-report]'. The initial list +was drawn up quickly by looking at functions with the type in their +name and that accept a value of that type as only required argument. +There is no doubt that the default value could be improved.]" + :type '(alist + :key-type (string :tag "Object type") + ;; We cannot use type `function' because some symbols might not yet be `fboundp'. + :value-type (repeat (restricted-sexp :tag "Action (function)" + :match-alternatives (functionp symbolp)))) + :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-unpropertize-completion-result-flag nil + "*Non-nil means strip text properties from the completion result. +Set this option to non-nil only if you need to ensure, for some other +library, that the string returned by `completing-read' and (starting +with Emacs 23) `read-file-name' has no text properties. + +Typically, you will not use a non-nil value. Internal text properties +added by Icicles are always removed anyway. A non-nil value lets you +also remove properties such as `face'." + :type 'boolean :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-update-input-hook nil + "*Functions run when minibuffer input is updated (typing or deleting)." + :type 'hook :group 'Icicles-Miscellaneous) + +;;;###autoload +(defcustom icicle-use-~-for-home-dir-flag t ; Toggle with `M-~'. + "*Non-nil means abbreviate your home directory using `~'. +You can toggle this option from the minibuffer at any time using +`M-~'." + :type 'boolean :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-use-C-for-actions-flag t ; Toggle with `M-g'. + "*Non-nil means use modifier `C-' (Control) for multi-command actions. +If nil, then you need no `C-' modifier for actions, and, instead, you +need a `C-' modifier for ordinary candidate cycling. + +It is not strictly correct to speak in terms of the `C-' modifier - +that is only the default behavior. The actual keys concerned are +those defined by these options: + + `icicle-apropos-cycle-next-action-keys' + `icicle-apropos-cycle-previous-action-keys' + `icicle-prefix-cycle-next-action-keys' + `icicle-prefix-cycle-previous-action-keys' + `icicle-modal-cycle-down-action-keys' + `icicle-modal-cycle-up-action-keys' + +You can toggle this option from the minibuffer at any time using +`M-g'." + :type 'boolean :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-use-anything-candidates-flag t + "*Non-nil means Icicles can include Anything candidates for completion. +When non-nil, Anything actions are used for candidate alternate +actions in some Icicles commands, and Anything types and actions are +used by command `icicle-object-action' (aka `a' and `what-which-how'). + +This option has no effect if library `anything.el' cannot be loaded." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-use-candidates-only-once-flag nil + "*Non-nil means remove each candidate from the set after using it. +When you use a multi-command and act on a candidate (for example, with +`C-RET'), the candidate is removed from those available if this is +non-nil. If this is nil, then the candidate is not removed, so you +can act on it again. + +You can customize this option if you prefer the non-nil behavior all +of the time. However, most users will not want to do that. + +If you write Emacs-Lisp code, you can bind this to non-nil during +completion in contexts where it makes little sense for users to act on +the same candidate more than once. That way, users cannot choose it +again, and they are not distracted seeing it as a candidate. + +See also non-option variable `icicle-use-candidates-only-once-alt-p'." + :type 'boolean :group 'Icicles-Matching) + +;;;###autoload +(defcustom icicle-word-completion-keys '([(meta ?\ )]) + "*Key sequences to use for minibuffer prefix word completion. +A list of values that each has the same form as a key-sequence +argument to `define-key'. It is a list mainly in order to accommodate +different keyboards. + +Because file names, in particular, can contain spaces, some people +prefer such a key sequence to be non-printable, such as `M-SPC'. This +is the default value in Icicles. + +But because the spacebar is such a convenient key to hit, other people +prefer to use `SPC' for word completion, and to insert a space some +other way. The usual way to do that is via `C-q SPC', but command +`icicle-insert-a-space' is provided for convenience. You can bind +this to `M-SPC', for instance, in `minibuffer-local-completion-map', +`minibuffer-local-completion-map', and +`minibuffer-local-must-match-map'." + :type '(repeat sexp) :group 'Icicles-Key-Bindings) + +;;;###autoload +(defcustom icicle-WYSIWYG-Completions-flag "MMMM" + "*Non-nil means show candidates in *Completions* using WYSIWYG. +This has an effect only for completion of faces and colors. + +The particular non-nil value determines the appearance: +* If t, the candidate is shown with its text properties. +* If a string, the string is propertized and then appended to the + candidate, to serve as a color swatch. + +Some commands might override a string value with different text. This +is the case for `icicle-read-color', for instance: the color swatch +text is always the color's RGB code. + +Note that, starting with Emacs 22, if this option is non-nil, then +command `describe-face' does not use `completing-read-multiple', since +that (non-Icicles) function does not support WYSIWYG candidates." + :type '(choice + (string :tag "Show candidate plus a WYSIWYG swatch with text..." :value "MMMM") + (const :tag "Show candidate itself using WYSIWYG" t) + (const :tag "Show candidate as is, with no text properties" nil)) + :group 'Icicles-Completions-Display) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-opt) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-opt.el ends here diff --git a/.emacs.d/icicles/icicles-var.el b/.emacs.d/icicles/icicles-var.el new file mode 100644 index 0000000..8aaa3b8 --- /dev/null +++ b/.emacs.d/icicles/icicles-var.el @@ -0,0 +1,1362 @@ +;;; icicles-var.el --- Internal variables for Icicles +;; +;; Filename: icicles-var.el +;; Description: Internal variables for Icicles +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2009, Drew Adams, all rights reserved. +;; Created: Mon Feb 27 09:23:26 2006 +;; Version: 22.0 +;; Last-Updated: Sat Jul 17 13:17:37 2010 (-0700) +;; By: dradams +;; Update #: 1318 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles-var.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', `cl', `el-swank-fuzzy', `ffap', +;; `ffap-', `fuzzy-match', `hexrgb', `icicles-face', `icicles-opt', +;; `kmacro', `levenshtein', `thingatpt', `thingatpt+', `wid-edit', +;; `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; This is a helper library for library `icicles.el'. It defines +;; internal variables (not to be modified by users. For Icicles +;; documentation, see `icicles-doc1.el' and `icicles-doc2.el'. +;; +;; Internal variables defined here: +;; +;; `icicle-abs-file-candidates', `icicle-acting-on-next/prev', +;; `icicle-advice-info-list', `icicle-all-candidates-action-p', +;; `icicle-all-candidates-list-action-fn', +;; `icicle-all-candidates-list-alt-action-fn', +;; `icicle-apply-nomsg', `icicle-apropos-complete-match-fn', +;; `icicle-bookmark-history', `icicle-bookmark-types', +;; `icicle-buffer-config-history', `icicle-candidate-action-fn', +;; `icicle-candidate-alt-action-fn', `icicle-candidate-entry-fn', +;; `icicle-candidate-help-fn', `icicle-candidate-nb', +;; `icicle-candidate-properties-alist', `icicle-candidates-alist', +;; `icicle-char-property-value-history', +;; `icicle-cmd-calling-for-completion', `icicle-cmd-reading-input', +;; `icicle-color-history', `icicle-color-theme-history', +;; `icicle-command-abbrev-history', `icicle-commands-for-abbrev', +;; `icicle-common-match-string', +;; `icicle-comp-base-is-default-dir-p', +;; `icicle-complete-input-overlay', `icicle-complete-keys-alist', +;; `icicle-completing-p', +;; `icicle-completing-read+insert-candidates', +;; `icicle-completion-candidates', +;; `icicle-completion-prompt-overlay', +;; `icicle-completion-set-history', +;; `icicle-completions-format-internal', +;; `icicle-confirm-exit-commands', +;; `icicle-current-completion-candidate-overlay', +;; `icicle-current-completion-mode', `icicle-current-input', +;; `icicle-current-raw-input', `icicle-current-TAB-method', +;; `icicle-cycling-p', `icicle-default-directory', +;; `icicle-default-thing-insertion-flipped-p', +;; `icicle-delete-candidate-object', `icicle-dictionary-history', +;; `icicle-dir-candidate-can-exit-p', +;; `icicle-doc-last-initial-cand-set', +;; `icicle-dot-string-internal', `icicle-edit-update-p', +;; `icicle-explore-final-choice', +;; `icicle-explore-final-choice-full', `icicle-extra-candidates', +;; `icicle-extra-candidates-dir-insert-p', +;; `icicle-face-name-history', `icicle-fancy-candidates-p', +;; `icicle-fancy-cands-internal-p', +;; `icicle-filtered-default-value', `icicle-font-name-history', +;; `icicle-frame-alist', `icicle-frame-name-history', +;; `icicle-function-name-history', +;; `icicle-fundoc-last-initial-cand-set', +;; `icicle-general-help-string', +;; `icicle-get-alist-candidate-function', +;; `icicle-hist-cands-no-highlight', `icicle-ignored-extensions', +;; `icicle-ignored-extensions-regexp', +;; `icicle-incremental-completion-p', +;; `icicle-Info-only-rest-of-book-p', `icicle-inhibit-sort-p', +;; `icicle-inhibit-try-switch-buffer', `icicle-initial-value', +;; `icicle-input-completion-fail-overlay', `icicle-input-fail-pos', +;; `icicle-insert-string-at-pt-end', +;; `icicle-insert-string-at-pt-start', +;; `icicle-interactive-history', `icicle-kill-history', +;; `icicle-kmacro-alist', `icicle-kmacro-history', +;; `icicle-last-apropos-complete-match-fn', +;; `icicle-last-completion-candidate', +;; `icicle-last-completion-command', `icicle-last-input', +;; `icicle-last-sort-comparer', `icicle-last-top-level-command', +;; `icicle-last-transform-function', `icicle-lighter-truncation', +;; `icicle-list-use-nth-parts', `icicle-menu-map', +;; `icicle-minibuffer-message-ok-p', `icicle-minor-mode-map-entry', +;; `icicle-ms-windows-drive-hash', `icicle-must-match-regexp', +;; `icicle-must-not-match-regexp', `icicle-must-pass-predicate', +;; `icicle-nb-candidates-before-truncation', +;; `icicle-nb-of-other-cycle-candidates', +;; `icicle-next-apropos-complete-cycles-p', +;; `icicle-next-prefix-complete-cycles-p', +;; `icicle-old-read-file-name-fn', +;; `icicle-plist-last-initial-cand-set', +;; `icicle-predicate-types-alist', `icicle-pre-minibuffer-buffer', +;; `icicle-post-command-hook', `icicle-pre-command-hook', +;; `icicle-previous-raw-file-name-inputs', +;; `icicle-previous-raw-non-file-name-inputs', +;; `icicle-progressive-completing-p', +;; `icicle-proxy-candidate-regexp', `icicle-proxy-candidates', +;; `icicle-read-expression-map', `icicle-remove-icicles-props-p', +;; `icicle-re-no-dot', `icicle-require-match-p', +;; `icicle-reverse-multi-sort-p', `icicle-reverse-sort-p', +;; `icicle-saved-candidate-overlays', +;; `icicle-saved-candidates-variables-obarray', +;; `icicle-saved-completion-candidate', +;; `icicle-saved-completion-candidates', +;; `icicle-saved-completion-candidates-internal', +;; `icicle-saved-ignored-extensions', +;; `icicle-saved-kmacro-ring-max', `icicle-saved-proxy-candidates', +;; `icicle-saved-regexp-search-ring-max', +;; `icicle-saved-region-background', +;; `icicle-saved-search-ring-max', +;; `icicle-scroll-Completions-backward-p', `icicle-search-command', +;; `icicle-search-context-level', `icicle-search-context-regexp', +;; `icicle-search-current-overlay', `icicle-search-final-choice', +;; `icicle-search-history', `icicle-search-in-context-fn', +;; `icicle-searching-p', `icicle-search-level-overlays', +;; `icicle-search-overlays', `icicle-search-refined-overlays', +;; `icicle-search-replacement', +;; `icicle-search-replacement-history', +;; `icicle-successive-grab-count', +;; `icicle-text-property-value-history', +;; `icicle-thing-at-pt-fns-pointer', +;; `icicle-transform-before-sort-p', +;; `icicle-universal-argument-map', +;; `icicle-use-candidates-only-once-alt-p', +;; `icicle-vardoc-last-initial-cand-set', +;; `icicle-vardoc-last-initial-option-cand-set', +;; `icicle-variable-name-history', +;; `icicle-whole-candidate-as-text-prop-p', +;; `lacarte-menu-items-alist'. +;; +;; 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. +;; +;; (@> "Internal variables (alphabetical)") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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 ;; for Emacs < 21: push + (when (< emacs-major-version 21) (require 'cl)));; for Emacs < 20: when, unless + +(require 'apropos-fn+var nil t) ;; (no error if not found): apropos-command, + ;; apropos-function, apropos-option, apropos-variable +(require 'icicles-opt) ;; icicle-sort-comparer + +;;; Defvars to quiet byte-compiler: +(defvar kmacro-ring-max) ; Defined in `kmacro.el' in Emacs 22+. +(defvar minibuffer-confirm-exit-commands) ; Defined in `minibuffer.el' in Emacs 23+. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;(@* "Internal variables (alphabetical)") + +;;; Internal variables (alphabetical) -------------------------------- + +(defvar lacarte-menu-items-alist nil) ; Defined in `lacarte.el'. + +;; These two are defined here so they won't raise an error in `font-lock-add-keywords'. +(defvar font-lock-function-name-face 'font-lock-function-name-face ; In `font-lock.el'. + "Face name to use for function names.") + +(defvar font-lock-keyword-face 'font-lock-keyword-face ; Defined in `font-lock.el'. + "Face name to use for keywords.") + +(defvar icicle-abs-file-candidates nil + "Current list of absolute file-name candidates.") + +(defvar icicle-acting-on-next/prev nil + "Non-nil means this command acts on the previous or next candidate. +The particular non-nil value indicates the navigation direction: +`forward' or `backward'.") + +(defvar icicle-advice-info-list () + "List of advice information for functions that Icicles redefines. +If such redefined functions are advised, then Icicles deactivates the +advice when you turn on Icicle mode. It restores the recorded advice +activation state when you turn off Icicle mode.") + +(defvar icicle-all-candidates-action-p nil + "Non-nil means that we are acting on all candidates. +That is, `icicle-all-candidates-action-1' is in progress.") + +(defvar icicle-all-candidates-list-alt-action-fn nil + "Alternative action function to apply to a list of matching completions.") + +(defvar icicle-all-candidates-list-action-fn nil + "Action function to apply to a list of all matching completions.") + +(defvar icicle-apply-nomsg nil + "Non-nil means `icicle-apply' does not show status of applying function.") + +(defvar icicle-apropos-complete-match-fn 'string-match + "Function to filter apropos completion candidates. +Takes as arguments an input string and a completion candidate, and +returns non-nil if the string is considered to match the candidate. + +A value of nil instead of a function means completion candidates are +not filtered by the input, except possibly by a function-valued +`minibuffer-completion-table'.") + +(defvar icicle-bookmark-history nil "History for bookmark names.") + +(defvar icicle-bookmark-types () + "List of strings naming bookmark types. +The list represents the set of all bookmarks of the given types. +An empty list and the singleton list `(all)', where `all' is a symbol, +are equivalent and stand for the set of all bookmarks (of any type).") + +(defvar icicle-buffer-config-history nil "History for buffer configuration names.") + +(defvar icicle-candidate-action-fn nil + "Action function to apply to current completion candidate. +For `icicle-all-candidates-action' to be able to report successes, +this should return nil for \"success\" and non-nil for \"failure\".") + +(defvar icicle-candidate-alt-action-fn nil + "Alternative action function to apply to current completion candidate. +For `icicle-all-candidates-alt-action' to be able to report successes, +this should return nil for \"success\" and non-nil for \"failure\".") + +(defvar icicle-candidate-entry-fn nil + "Function to apply to selected entries in `icicle-candidates-alist'.") + +(defvar icicle-candidate-help-fn nil + "Help function to be applied to current completion candidate. +If non-nil, it must be a function that accepts a completion candidate + (a string or a symbol) as argument. +If nil, default help function `icicle-help-on-candidate' is used.") + +(defvar icicle-candidate-nb nil + "Current completion candidate number, or nil if not cycling candidates. +Numbering starts at zero.") + +(defvar icicle-candidate-properties-alist nil + "Alist of multi-completion indexes and associated text properties. +The text properties apply to candidates in *Completions*. Each alist +entry has the form (NTH PROPERTIES) or (NTH PROPERTIES JOIN-TOO). + +NTH is a whole-number index identifying the multi-completion part. + +PROPERTIES is a list of text properties to apply to the part. + +JOIN-TOO non-nil means to also apply PROPERTIES to the join string +that follows the part. + +Example alist: + + ((3 (face 'underline)) + (2 (invisible t) t)) + +The first entry underlines the third multi-completion part. +The second entry makes both the second part and the join string that +follows it invisible.") + +(defvar icicle-candidates-alist nil + "Alist of candidate entries. +The car (key) of each entry is treated as a completion candidate. +The cdr is some other data to be used when the candidate is chosen. + +This is reset to nil at the beginning of each top-level command. It +is used only by commands that use completion without allowing sorting +of completion candidates.") + +(defvar icicle-char-property-value-history nil "History for character property values.") + +(defvar icicle-cmd-calling-for-completion 'ignore + "Last command causing display of list of possible completions.") + +(defvar icicle-cmd-reading-input 'ignore + "Last command reading input in the minibuffer.") + +(defvar icicle-color-history nil "History for color names.") + +(defvar icicle-color-theme-history nil "History for color-theme names.") + +(defvar icicle-command-abbrev-history nil "History of command and abbrev entries.") + +(defvar icicle-commands-for-abbrev nil + "List of commands that match the current abbreviation.") + +(defvar icicle-common-match-string nil + "Expanded common match among all completion candidates. +nil means no such common match is available.") + +(defvar icicle-comp-base-is-default-dir-p nil + "Non-nil means to use `default-directory' as the completion base. +This means use its length as `completion-base-size'.") + +(defvar icicle-complete-input-overlay nil + "Overlay used to highlight minibuffer input when it is complete.") + +(when (fboundp 'map-keymap) ; Emacs 22+. + (defvar icicle-complete-keys-alist nil "Alist of keys and their bindings. +Each alist element is of the form (NAME KEY . BINDING), where: + NAME is a symbol naming the key and its binding, whose name has form: + KEYNAME = BINDING-NAME + KEY is the actual key sequence + BINDING is the actual binding of KEY.")) + +(defvar icicle-completing-p nil "Cached value of function `icicle-completing-p'.") + +(defvar icicle-completion-candidates nil "Current list of completion candidates.") + +(defvar icicle-completion-prompt-overlay nil + "Overlay used to highlight saved completion candidates.") + +(defvar icicle-completing-read+insert-candidates () + "`completing-read' COLLECTION arg to use for `icicle-completing-read+insert'.") + +(defvar icicle-completion-set-history nil "History for completion-set names.") + +(defvar icicle-completions-format-internal icicle-completions-format + "Internal version of `icicle-completions-format'. +Used to override the option for multi-completions.") + +(defvar icicle-confirm-exit-commands + (and (boundp 'minibuffer-confirm-exit-commands) + (append '(icicle-prefix-complete icicle-prefix-complete-no-display + icicle-prefix-word-complete + icicle-apropos-complete icicle-apropos-complete-no-display + icicle-apropos-complete-and-narrow ; ???? + ;; icicle-apropos-complete-and-exit ; ???? + ) + minibuffer-confirm-exit-commands)) + "Version of `minibuffer-confirm-exit-commands' for Icicle mode. +Effective starting with Emacs 23.") + +(defvar icicle-current-completion-candidate-overlay nil + "Overlay used to highlight current completion candidate.") + +(defvar icicle-current-completion-mode nil + "Symbol `prefix' or `apropos', specifying the current completion mode.") + +(defvar icicle-current-input "" "Current minibuffer input.") + +(defvar icicle-current-TAB-method 'basic + "*Current completion method for \ +`\\\\[icicle-prefix-complete]'.") + +(defvar icicle-current-raw-input "" "Current minibuffer raw (unexpanded) input. +This can be different from `icicle-current-input' only when +`icicle-expand-input-to-common-match-flag' is non-nil.") + +(defvar icicle-cycling-p nil + "Non-nil means the user is currently cycling completion candidates.") + +(defvar icicle-default-directory default-directory + "Local copy of `default-directory'. +Set whenever minibuffer is entered or input is completed.") + +(defvar icicle-default-thing-insertion-flipped-p nil + "Non-nil means a previous `M-.' in this succession was used with `C-u'. +This means that the meaning of `icicle-default-thing-insertion' has +been reversed.") + +(defvar icicle-delete-candidate-object nil + "Defines deletion action for command `icicle-delete-candidate-object'. +The value can be a function or a symbol bound to an alist. + +If the value is a function, then the function is called on the current +completion candidate (a string) to delete some corresponding object. + +If the value is a symbol (variable) bound to an alist, then +`icicle-delete-current-candidate-object' is called to delete the +corresponding object from that alist. If the variable is also a user +option, then the option is saved after the candidate is deleted. + +Note that if the value is a variable and you use multi-completion +candidates during completion, then the alist value of the variable +must itself contain multi-completions. Otherwise, no candidate will +be deleted, because `icicle-delete-current-candidate-object' deletes +the full candidate object.") + +(defvar icicle-dictionary-history nil "History for dictionary entries.") + +(defvar icicle-dir-candidate-can-exit-p nil + "Non-nil means you can exit the minibuffer when you choose a directory.") + +(defvar icicle-doc-history () "History for documentation entries.") + +(defvar icicle-doc-last-initial-cand-set () + "Cache for initial set of completion candidates for `icicle-doc'.") + +(defvar icicle-dot-string-internal icicle-dot-string + "Internal version of `icicle-dot-string' (same values). +This is changed automatically by Icicles when you switch completion +mode, whereas `icicle-dot-string' is changed only via user commands.") + +(defvar icicle-edit-update-p nil + "Internal flag: non-nil when editing text in minibuffer. +More precisely, non-nil when updating the completions list inside +simple character-editing commands such as `icicle-self-insert' and +`icicle-delete-backward-char'.") + +(defvar icicle-explore-final-choice "" + "Final `icicle-explore' completion choice (a string).") + +(defvar icicle-explore-final-choice-full nil + "Full alist element that corresponds to `icicle-explore-final-choice'. +This is an element of `icicle-candidates-alist'. +The element's car is a completion-candidate string.") + +(defvar icicle-extra-candidates nil "A list of extra completion candidates (strings).") + +(defvar icicle-extra-candidates-dir-insert-p t + "Non-nil means, for an extra candidate, insert a directory component. +Can be bound to nil to prevent adding a directory to non file-name +extra candidates during file-name completion. An extra candidate is +one that is a member of `icicle-extra-candidates'.") + +(defvar icicle-face-name-history nil "History for font names.") + +(defvar icicle-fancy-candidates-p nil + "Non-nil means we are completing using possibly fancy candidates. +That is, some candidates might have attached properties. + +You can bind this in your code if you need to treat fancy candidates +and your code has no direct access to the `completing-read' PROMPT +string. See section `Candidates with Text Properties' of the Icicles +doc. + +If you set this to non-nil, instead of binding it, then Icicles will +always check whether each completion candidate might be fancy. That +can be costly.") + +(defvar icicle-fancy-cands-internal-p nil + "Same as `icicle-fancy-candidates-p', but for internal use only. +Do not set or bind this. This is bound only by `completing-read'.") + +(defvar icicle-filtered-default-value nil + "Minibuffer default value, after filtering with `icicle-filter-wo-input'.") + +(defvar icicle-font-name-history nil "History for font names.") + +(defvar icicle-frame-alist nil "Alist of frames, returned by `icicle-make-frame-alist'.") + +(defvar icicle-frame-name-history nil "History for frame names.") + +(defvar icicle-function-name-history nil "History for function names. +Each name is a symbol name or a lambda form, as a string.") + +(defvar icicle-fundoc-last-initial-cand-set () + "Cache for initial set of completion candidates for `icicle-fundoc'.") + +(defvar icicle-general-help-string " + + +Customize Icicles: `M-x icicle-customize-icicles-group'. +Summary of customizable options and faces (alphabetical order). + +Some of the options can be toggled or cycled - the keys for this are +noted in parentheses. + +* `case-fold-search', `completion-ignore-case', + (`C-u') `read-file-name-completion-ignore-case' + - Case sensitivity? (`C-A') +* `completion-ignored-extensions' - Ignored filenames (`C-.') +* `icicle-act-before-cycle-flag' - Act then cycle or reverse? +* `icicle-add-proxy-candidates-flag' - Include proxies? (`C-M-_') +* `icicle-alternative-actions-alist' - Overriding alt actions +* `icicle-alternative-sort-comparer' - Other sort (`M-,', `C-M-,') +* `icicle-apropos-complete-keys*' - Keys to apropos-complete +* `icicle-apropos-cycle-*-keys' - Keys to apropos-cycle +* `icicle-bookmark-name-length-max' - Max length of bookmark name +* `icicle-bookmark-refresh-cache-flag' - Refresh bookmarks cache? +* `icicle-top-level-key-bindings' - Bind top-level commands +* `icicle-buffer-*' - `icicle-buffer' options +* `icicle-candidate-width-factor' - Width %%, candidate columns +* `icicle-change-region-background-flag' - Change region color? +* `icicle-change-sort-order-completion-flag' - Control `C-,' behavior +* `icicle-C-l-uses-completion-flag' - `C-l' uses completion? +* `icicle-color-themes' - For `icicle-color-theme' +* `icicle-comint-dynamic-complete-replacements' - Comint complete fns +* `icicle-command-abbrev*' - Command abbrev behavior +* `icicle-complete-key-anyway-flag' - `S-TAB' must complete keys +* `icicle-complete-keys-self-insert-flag'- `S-TAB' for self-insert? +* `icicle-completing-read+insert-keys' - Keys for complete-on-demand +* `icicle-completion-history-max-length' - Completion history length +* `icicle-Completions-display-min-input-chars' - Remove *Completions* + if fewer chars input +* `icicle-completions-format' - *Completions* layout format +* `icicle-Completions-frame-at-right-flag'- *Completions* at right? +* `icicle-Completions-text-scale-decrease'- *Completions* text shrink +* `icicle-Completions-window-max-height' - Max lines in *Completions* +* `icicle-customize-save-flag' - Save some options on quit? +* `icicle-cycle-into-subdirs-flag' - Explore subdirectories? +* `icicle-cycling-respects-completion-mode' - Completion mode affects + cycling mode? +* `icicle-default-thing-insertion' - Control behavior of \ +\\\\[icicle-insert-string-at-point] +* `icicle-default-value' - How to treat default value +* `icicle-define-alias-commands-flag' - Define top-level aliases? +* `icicle-deletion-action-flag' - `S-delete' deletes? +* `icicle-dot-show-regexp-flag' - Show regexp for `.'? +* `icicle-dot-string' - String that `.' inserts +* `icicle-expand-input-to-common-match-flag'- Expand input? (`C-;') +* `icicle-file-*' - `icicle-file' options +* `icicle-filesets-as-saved-completion-sets-flag'- Use filesets? +* `icicle-guess-commands-in-path' - Shell commands to complete +* `icicle-help-in-mode-line-flag' - Candidate mode-line help? +* `icicle-hide-common-match-in-Completions-flag'- Show common match? +* `icicle-highlight-historical-candidates-flag' + - Highlight past input? +* `icicle-highlight-input-completion-failure*'- Input non-match sign +* `icicle-highlight-input-initial-whitespace-flag' + - Highlight input whitespace? +* `icicle-highlight-lighter-flag' - Highlight mode-line `Icy' +* `icicle-ignore-space-prefix-flag' - See initial space? (`M-_') +* `icicle-incremental-completion-delay' - Before update *Completions* +* `icicle-incremental-completion-flag' - Icompletion? (`C-#') +* `icicle-incremental-completion-threshold'- # of candidates for delay +* `icicle-inhibit-advice-functions' - Advice-inhibited functions +* `icicle-inhibit-ding-flag' - Suppress audible bell +* `icicle-input-string' - String inserted by `C-=' +* `icicle-inter-candidates-min-spaces' - Min spaces among candidates +* `icicle-isearch-complete-keys' - Keys to complete search +* `icicle-key-complete-keys' - Keys to complete keys +* `icicle-key-descriptions-use-<>-flag' - Show key names with \"<>\"? +* `icicle-keymaps-for-key-completion' - `S-TAB' = key-complete maps +* `icicle-kmacro-ring-max' - Icicles `kmacro-ring-max' +* `icicle-levenshtein-distance' - Levenshtein match distance +* `icicle-list-end-string', `icicle-list-join-string' + - Multi-completion join/end +* `icicle-list-nth-parts-join-string' - Join split-candidate parts +* `icicle-mark-position-in-candidate' - Mark position in cycling +* `icicle-menu-items-to-history-flag' - Add menus to history? +* `icicle-minibuffer-setup-hook' - Functions run after setup +* `icicle-modal-cycle-*-keys' - Keys for modal cycling +* `icicle-option-type-prefix-arg-list' - Prefix-args for `C-h C-o' +* `icicle-point-position-in-candidate' - Cursor position in cycling +* `icicle-populate-interactive-history-flag'- Track interactive use? +* `icicle-pp-eval-expression-print-*' - Print control for `pp-*' +* `icicle-prefix-complete-keys*' - Keys to prefix-complete +* `icicle-prefix-cycle-*-keys' - Keys to prefix-cycle +* `icicle-previous-candidate-keys' - Back keys for *Completions* +* `icicle-quote-shell-file-name-flag' - Quote file name in shell? +* `icicle-read+insert-file-name-keys' - Keys for on-demand file +* `icicle-redefine-standard-commands-flag'- Redefine std commands? +* `icicle-regexp-quote-flag' - Escape chars? (`C-`') +* `icicle-regexp-search-ring-max' - `regexp-search-ring-max' +* `icicle-region-background' - Background for region +* `icicle-require-match-flag' - Override REQUIRE-MATCH? +* `icicle-saved-completion-sets' - Completion sets for \ +`\\[icicle-candidate-set-retrieve]' +* `icicle-search-cleanup-flag' - Remove search highlighting? + (`C-.') +* `icicle-search-context-match-predicate'- Search-context predicate +* `icicle-search-from-isearch-keys' - Isearch-to-Icicles keys +* `icicle-search-highlight-all-current-flag'- In each hit (`C-^') +* `icicle-search-highlight-context-levels-flag' - + Highlight match subgroups? +* `icicle-search-highlight-threshold' - # hits to highlight at once +* `icicle-search-hook' - Functions run by `C-c `' +* `icicle-search-replace-common-match-flag' - Replace ECM? (`M-;') +* `icicle-search-replace-literally-flag' - Replace text literally? +* `icicle-search-replace-whole-candidate-flag' - Replace input match + or whole search hit?(`C-,') +* `icicle-search-ring-max' - Icicles `search-ring-max' +* `icicle-search-whole-word-flag' - Find whole words? (`M-q') +* `icicle-show-Completions-help-flag' - Show *Completions* help? +* `icicle-show-Completions-initially-flag'- Show *Completions* first? +* `icicle-show-multi-completion-flag' - Show extra candidate info? +* `icicle-sort-comparer' - Sort candidates (`C-,') +* `icicle-sort-orders-alist' - Predicates for sorting +* `icicle-special-candidate-regexp' - To highlight special cands +* `icicle-S-TAB-completion-methods-alist'- `S-TAB' methods (`M-(') +* `icicle-swank-*' - Swank completion control +* `icicle-TAB-completion-methods' - `TAB' methods (`C-(') +* `icicle-TAB-shows-candidates-flag' - 1st `TAB' shows candidates? +* `icicle-test-for-remote-files-flag' - Check remote files? (`C-^') +* `icicle-thing-at-point-functions' - Functions to yank things +* `icicle-top-level-key-bindings' - Top-level key bindings +* `icicle-top-level-when-sole-completion-*'- Exiting if one completion +* `icicle-touche-pas-aux-menus-flag' - Add to standard menus? +* `icicle-transform-function' - Remove duplicates (`C-$') +* `icicle-type-actions-alist' - Objects and their types +* `icicle-unpropertize-completion-result-flag'- Properties in result? +* `icicle-update-input-hook' - Fns run when input changes +* `icicle-use-~-for-home-dir-flag' - Use `~' for $HOME? (`M-~') +* `icicle-use-C-for-actions-flag' - `C-' for actions? (`M-g') +* `icicle-use-candidates-only-once-flag' - Remove used candidate? +* `icicle-word-completion-keys' - Keys for word completion +* `icicle-WYSIWYG-Completions-flag' - WYSIWYG for *Completions*? +* `icicle-yank-function' - Yank function to use + +Faces that highlight input in minibuffer. + +* `icicle-complete-input' - Input when it is complete +* `icicle-completion' - Completing? +* `icicle-input-completion-fail*' - Non-match part of input +* `icicle-match-highlight-minibuffer' - Matched part of input +* `icicle-multi-command-completion' - Multi-command completion? +* `icicle-mustmatch-completion' - Strict completion? +* `icicle-whitespace-highlight' - Initial whitespace in input + +Faces that highlight candidates in buffer *Completions*. + +* `icicle-candidate-part' - Part of candidate +* `icicle-common-match-highlight-Completions' - Max common substring +* `icicle-current-candidate-highlight' - Current candidate (cycling) +* `icicle-extra-candidate' - Extra candidate +* `icicle-historical-candidate' - Highlight candidates used +* `icicle-match-highlight-Completions' - Matched part of input +* `icicle-proxy-candidate' - Proxy candidate +* `icicle-saved-candidate' - Saved candidate +* `icicle-special-candidate' - Special candidate + +Faces that highlight information in the mode line. + +* `icicle-completion' - Completing? +* `icicle-mode-line-help' - Candidate help +* `icicle-multi-command-completion' - Multi-command completion? +* `icicle-mustmatch-completion' - Strict completion? + +Faces that highlight for command `icicle-search'. + +* `icicle-search-context-level-*' - Regexp subgroup highlighting +* `icicle-search-current-input' - What input matches +* `icicle-search-main-regexp-current' - Current match of 1st regexp +* `icicle-search-main-regexp-others' - Other matches of 1st regexp + + +Some top-level Icicles commands (alphabetical order, with exceptions). + +Some are bound in Icicle mode. Bind the others to keys you like. +See recommended bindings in `icicles.el'. +Multi-commands are indicated by `+': They act any number of times. +You can tell a multi-command when you execute it by the fact that the +input prompt is prefixed by `+'. + ++ `clear-option' (alias) - Set binary option to nil ++ `icicle-add-buffer-candidate' - To always-candidate buffer ++ `icicle-remove-buffer-candidate' - From same + `icicle-add-buffer-config' - To `icicle-buffer-configs' ++ `icicle-remove-buffer-config' - From same + `icicle-add/update-saved-completion-set' - To + `icicle-saved-completion-sets' ++ `icicle-remove-saved-completion-set' - From same + `icicle-add-entry-to-saved-completion-set' - Add completion to a set + `icicle-remove-entry-from-saved-completion-set' - Remove from set ++ `icicle-apply' - Apply function to alist items + `icicle-apropos' - `apropos', but shows matches + `icicle-apropos-command' - Enhanced `apropos-command' + `icicle-apropos-variable' - Enhanced `apropos-variable' + `icicle-apropos-zippy' - Show matching Zippy quotes ++ `icicle-bookmark'(`-other-window') - Jump to a bookmark ++ `icicle-bookmark-bookmark-list-other-window' - Jump to bookmark list ++ `icicle-bookmark-desktop-other-window' - Jump to desktop bookmark ++ `icicle-bookmark-dired-other-window' - Jump to a Dired bookmark ++ `icicle-bookmark-file-other-window' - Jump to a file bookmark ++ `icicle-bookmark-gnus-other-window' - Jump to a Gnus bookmark ++ `icicle-bookmark-info-other-window' - Jump to an Info bookmark ++ `icicle-bookmark-local-file-other-window' - Jump to a local file ++ `icicle-bookmark-man-other-window' - Jump to a `man'-page bookmark ++ `icicle-bookmark-non-file-other-window' - Jump to buffer bookmark ++ `icicle-bookmark-region-other-window' - Jump to a region bookmark ++ `icicle-bookmark-remote-file-other-window' - Jump to a remote file ++ `icicle-bookmark-url-other-window' - Jump to a URL bookmark ++ `icicle-buffer'(`-other-window') - Switch to buffer (`C-x b') ++ `icicle-buffer-config' - Pick `icicle-buffer' options ++ `icicle-buffer-list' - Choose a list of buffer names + `icicle-change-alternative-sort-order' - Choose an alternative sort + `icicle-change-sort-order' - Choose a sort order ++ `icicle-clear-current-history' - Clear current history entries ++ `icicle-clear-history' - Clear entries from a history ++ `icicle-color-theme' - Change color theme ++ `icicle-comint-command' - Reuse command (`C-c TAB') + `icicle-comint-dynamic-complete' - Text completion in shell ++ `icicle-comint-search' - Reuse command (`C-c `') ++ `icicle-command-abbrev' - `M-x' + abbrevs (`C-x SPC') ++ `icicle-compilation-search' - Search, show hits (`C-c `') ++ `icicle-complete-keys' - Complete keys (`S-TAB') + `icicle-complete-thesaurus-entry' - Complete word (`C-c /') ++ `icicle-completing-yank' - `yank' using completion ++ `icicle-customize-face' - Multi-`customize-face' + `icicle-customize-icicles-group' - Customize options and faces ++ `icicle-delete-file' - Delete file/directory + `icicle-delete-window' - Delete window (`C-u': buffer) ++ `icicle-delete-windows' - Delete windows (`C-u C-x 0') ++ `icicle-dired' - Multi-command Dired ++ `icicle-doc' - Show doc for fn, var, or face + `icicle-doremi-candidate-width-factor+' - +/- candidate column width + `icicle-doremi-increment-max-candidates+' - +/ max candidates shown + `icicle-doremi-increment-swank-prefix-length+' - +/- swank prefix + `icicle-doremi-increment-swank-timeout+' - +/- swank match timeout + `icicle-doremi-increment-variable+' - Increment var using Do Re Mi + `icicle-doremi-inter-candidates-min-spaces+' - +/- candidate spacing + `icicle-doremi-zoom-Completions+' - +/- *Completions* text size ++ `icicle-execute-extended-command' - Multi-command `M-x' ++ `icicle-execute-named-keyboard-macro' - Execute named keyboard macro + `icicle-face-list' - Choose a list of face names + `icicle-file-list' - Choose a list of file names ++ `icicle-file'(`-other-window') - Visit file/dir (`C-x C-f') ++ `icicle-find-file'(`-other-window') - same: relative only ++ `icicle-find-file-absolute'(`-other-window') - same: absolute only ++ `icicle-find-file-in-tags-table'(`-other-window') - Tags-table file ++ `icicle-find-first-tag'(`-other-window') - Find source def (tag) ++ `icicle-find-tag' - Find definition (tag) (`M-.') ++ `icicle-font' - Change font of frame ++ `icicle-frame-bg' - Change background of frame ++ `icicle-frame-fg' - Change foreground of frame ++ `icicle-fundoc' - Show function description ++ `icicle-goto-global-marker' - Go to a global marker ++ `icicle-goto-marker' - Go to a marker in this buffer ++ `icicle-imenu*' - Navigate among Imenu entries + `icicle-increment-option' - Increment a numeric option + `icicle-increment-variable' - Increment a numeric variable ++ `icicle-Info-goto-node' - Multi-cmd `Info-goto-node' ++ `icicle-Info-index' - Multi-command `Info-index' ++ `icicle-Info-menu' - Multi-command `Info-menu' + `icicle-Info-virtual-book' - Open a virtual Info book + `icicle-insert-buffer' - Multi-command `insert-buffer' ++ `icicle-insert-thesaurus-entry' - Insert thesaurus entry ++ `icicle-keyword-list' - Choose a list of keywords ++ `icicle-kill-buffer' - Kill buffer (`C-x k') ++ `icicle-kmacro' - Call keyboard macro (`S-f4') ++ `icicle-locate-file'(`-other-window') - Visit file in a directory + `icicle-minibuffer-help' - Show Icicles minibuffer help + `icy-mode' or `icicle-mode' - Toggle Icicle mode + `icicle-next-S-TAB-completion-method' - Next `S-TAB' method (`M-(') + `icicle-next-TAB-completion-method' - Next `TAB' method (`C-(') ++ `icicle-occur' - Incremental `occur' (`C-c '') ++ `icicle-other-window-or-frame' - Other window/frame (`C-x o') ++ `icicle-plist' - Show symbols, property lists ++ `icicle-recent-file'(`-other-window') - Open recently used file + `icicle-recompute-shell-command-candidates' - Update from $PATH ++ `icicle-remove-file-from-recentf-list' - Remove from recent files ++ `icicle-reset-option-to-nil' - Set binary option to nil + `icicle-save-string-to-variable' - Save text for use with \ +`\\[icicle-insert-string-from-variable]' ++ `icicle-search' - Search (`C-c `') ++ `icicle-search-bookmark' - Search bookmarks separately ++ `icicle-search-bookmark-list-bookmark' - Search bookmark lists ++ `icicle-search-bookmarks-together' - Search bookmarks together ++ `icicle-search-char-property' - Search for overlay/text props ++ `icicle-search-dired-bookmark' - Search Dired bookmarks ++ `icicle-search-dired-marked' - Search marked files in Dired ++ `icicle-search-file' - Search multiple files ++ `icicle-search-file-bookmark' - Search bookmarked files ++ `icicle-search-gnus-bookmark' - Search bookmarked Gnus msgs ++ `icicle-search-ibuffer-marked' - Search marked bufs in Ibuffer ++ `icicle-search-info-bookmark' - Search bookmarked Info nodes ++ `icicle-search-keywords' - Search for keywords (`C-c ^') ++ `icicle-search-local-file-bookmark' - Search bookmarked local files ++ `icicle-search-man-bookmark' - Search bookmarked `man' pages ++ `icicle-search-non-file-bookmark' - Search bookmarked buffers ++ `icicle-search-overlay-property' - Search for overlay properties ++ `icicle-search-pages' - Search Emacs pages ++ `icicle-search-paragraphs' - Search Emacs paragraphs ++ `icicle-search-region-bookmark' - Search bookmarked regions ++ `icicle-search-remote-file-bookmark' - Search remote bookmarks ++ `icicle-search-sentences' - Search sentences as contexts ++ `icicle-search-text-property' - Search for face... (`C-c \"') ++ `icicle-search-url-bookmark' - Search bookmarked URLs ++ `icicle-search-word' - Whole-word search ++ `icicle-select-bookmarked-region' - Select bookmarked regions ++ `icicle-select-frame' - Select a frame by name ++ `icicle-select-window' - Select window by buffer name + `icicle-send-bug-report' - Send Icicles bug report ++ `icicle-set-option-to-t' - Set binary option to t + `icicle-toggle-~-for-home-dir' - Toggle using `~' for $HOME + `icicle-toggle-alternative-sorting' - Swap alternative sort + `icicle-toggle-angle-brackets' - Toggle using angle brackets + `icicle-toggle-C-for-actions' - Toggle using `C-' for actions + `icicle-toggle-case-sensitivity' - Toggle case sensitivity + `icicle-toggle-dot' - Toggle `.' matching newlines + `icicle-toggle-expand-to-common-match' - Toggle input ECM expansion + `icicle-toggle-hiding-common-match' - Toggle match in *Completions* + `icicle-toggle-highlight-all-current' - Toggle max search highlight + `icicle-toggle-highlight-historical-candidates' + - Toggle past-input highlight + `icicle-toggle-ignored-extensions' - Toggle ignored files + `icicle-toggle-ignored-space-prefix' - Toggle ignoring space prefix + `icicle-toggle-incremental-completion' - Toggle apropos icompletion ++ `icicle-toggle-option' - Toggle binary user option + `icicle-toggle-proxy-candidates' - Toggle proxy candidates + `icicle-toggle-regexp-quote' - Toggle regexp escaping + `icicle-toggle-search-cleanup' - Toggle search highlighting + `icicle-toggle-search-replace-common-match' - Toggle ECM replacement + `icicle-toggle-search-whole-word' - Toggle whole-word searching + `icicle-toggle-show-multi-completion' - Toggle multi-completions + `icicle-toggle-sorting' - Toggle sorting of completions + `icicle-toggle-transforming' - Toggle duplicate removal + `icicle-toggle-WYSIWYG-Completions' - Toggle WYSIWYG *Completions* ++ `icicle-vardoc' - Show variable description ++ `icicle-where-is' - `where-is' multi-command + `icicle-yank-maybe-completing' - `yank' + completion (`C-y') ++ `toggle' (alias) - Toggle binary user option + + +These are all of the top-level bindings in Icicle mode: + +\\{icicle-mode-map}" + "General help string included in `icicle-minibuffer-help'.") + +(defvar icicle-get-alist-candidate-function 'icicle-get-alist-candidate + "Function used to retrieve a full completion candidate. +The signature must match that of the default value, +`icicle-get-alist-candidate'.") + +(defvar icicle-hist-cands-no-highlight () + "List of candidates not highlighted using `icicle-historical-candidate'. +Bind, don't assign this, since the same string can have different +meanings in different contexts.") + +(defvar icicle-ignored-extensions completion-ignored-extensions + "Copy of `completion-ignored-extensions', serving as a control flag. +When `completion-ignored-extensions' changes, we remake +`icicle-ignored-extensions-regexp'.") + +(defvar icicle-ignored-extensions-regexp + (concat "\\(" (mapconcat #'regexp-quote completion-ignored-extensions "$\\|") + "$\\)\\'") + "Regular expression matching ignored file extensions. +If this is nil, then no file extensions are ignored. +The ignored file extensions come from `completion-ignored-extensions'.") + +(defvar icicle-incremental-completion-p nil + "Takes the place of `icicle-incremental-completion-flag' during input. +The program updates this to `always' from `t' after *Completions* has +been displayed.") + +(defvar icicle-Info-only-rest-of-book-p nil + "Non-nil means complete only Info nodes from the rest of the book.") + +(defvar icicle-inhibit-sort-p nil + "Non-nil means that users cannot sort completion candidates. +They also cannot remove duplicates.") + +(defvar icicle-inhibit-try-switch-buffer nil + "Non-nil means `icicle-try-switch-buffer' does not switch to `orig-buff'.") + +(defvar icicle-initial-value "" + "Initial value used in minibuffer completion. +Any function that reads from the minibuffer and accepts a default +value or initial value should, before reading, put that value in +`icicle-initial-value'. For example, `completing-read' does that. + +In addition, `completing-read' and `read-file-name' will respect this +value, using it as the initial value if none is provided explicitly. +This means that you can bind `icicle-initial-value' around an +expression that calls `completing-read' or `read-file-name', and the +bound value will be used as the initial value.") + +(defvar icicle-input-completion-fail-overlay nil + "Overlay used to highlight the input portion that does not complete.") + +(defvar icicle-input-fail-pos nil + "Position in minibuffer of start of completion match failure. +Nil means no match failure is known.") + +(defvar icicle-insert-string-at-pt-end nil + "Position of end of text `icicle-insert-string-at-point' inserted.") + +(defvar icicle-insert-string-at-pt-start nil + "Position of start of text `icicle-insert-string-at-point' inserted.") + +(defvar icicle-interactive-history () + "History of commands called using `call-interactively'.") + +(defvar icicle-kill-history nil "History of kill-ring entries.") + +(when (boundp 'kmacro-ring) ; Emacs 22+ + (defvar icicle-kmacro-alist nil + "Alist with elements (CANDIDATE-NAME . RING-ITEM). +CANDIDATE-NAME is 1, 2, 3.... + +RING-ITEM is an item in `kmacro-ring' or `(kmacro-ring-head)'.") + (defvar icicle-kmacro-history nil "History for keyboard-macro names.")) + +(defvar icicle-last-apropos-complete-match-fn 'string-match + "Last value of `icicle-apropos-complete-match-fn'.") + +(defvar icicle-last-completion-candidate "" + "Last completion candidate used in minibuffer completion.") + +(defvar icicle-last-completion-command nil "Last completion command used.") + +(defvar icicle-last-input "" "Last minibuffer input typed (not from cycling).") + +(defvar icicle-last-sort-comparer (or icicle-sort-comparer 'icicle-case-string-less-p) + "Local copy of `icicle-sort-comparer', so we can restore it.") + +(defvar icicle-last-top-level-command nil "Last top-level command used.") + +(defvar icicle-last-transform-function (or icicle-transform-function + 'icicle-remove-duplicates) + "Local copy of `icicle-transform-function', so we can restore it.") + +(defvar icicle-lighter-truncation "..." + "String appended to Icy lighter to show candidates-list truncation.") + +(defvar icicle-list-use-nth-parts nil + "List of indexes of multi-completion pieces to use. +This is not an internal variable. You can bind this in your own Lisp +code to affect completion behavior. + +An empty list means use the entire multi-completion. Otherwise, +concatenate, in order, the Nth parts of the multi-completion, where N +is each of the (one-based) indexes, in turn. Any index larger than +the actual number of parts in the multi-completion means use the last +part. + +For example: If the value is (1), then use only the first part of the +multi-completion as the completion candidate. If the value is (2 1), +then use as candidate the second part followed by the first part, the +two parts being joined by option `icicle-list-nth-parts-join-string'. +If the value is (1 99) and the multi-completion has fewer than 99 +parts, then use the first and last parts, joined by +`icicle-list-nth-parts-join-string'. If the value is (2 1 2), then +use the second part, first part, and second part again - you can use a +given part any number of times.") + +(defvar icicle-menu-map nil "Icicles menu-bar menu keymap.") + +(defvar icicle-minibuffer-message-ok-p t + "Non-nil means we can show messages in minibuffer. +This affects only `icicle-msg-maybe-in-minibuffer'.") + +(defvar icicle-minor-mode-map-entry nil "Icicles mode entry in `minor-mode-map-alist'.") + +(defvar icicle-ms-windows-drive-hash (and (fboundp 'make-hash-table) + (make-hash-table :test 'equal)) + "Hash table for caching result of MS Windows `NET USE' system calls. +For Emacs 20 and 21, this is not used unless you load library `cl.el' +at runtime.") + +(defvar icicle-must-match-regexp nil + "A regexp that completion candidates must match, or nil. +If nil, then this does nothing. If a regexp (string), then show only +candidates whose display form matches it (and matches the user input). +The display form is the string shown in `*Completions*'. + +Note: This is similar to the standard variable +`completion-regexp-list', except: +* `completion-regexp-list' is a list of regexps, not just one. +* `icicle-must-match-regexp' is used after filtering using option + `icicle-transform-function'. + +See also `icicle-must-not-match-regexp'.") + +(defvar icicle-must-not-match-regexp nil + "A regexp that completion candidates must not match, or nil. +If nil, then this does nothing. If a regexp (string), then show only +candidates whose display form does not match it. +The display form is the string shown in `*Completions*'. +See also `icicle-must-match-regexp'.") + +(defvar icicle-must-pass-predicate nil + "A predicate that completion candidates must satisfy, or nil. +If nil, then this does nothing. Otherwise, this is a function of one +argument, a candidate, and only candidates whose display form +satisfies the predicate are displayed. The display form is the string +shown in `*Completions*'.") + +(defvar icicle-nb-candidates-before-truncation 0 + "Number of candidates, before truncation per `icicle-max-candidates'.") + +(defvar icicle-nb-of-other-cycle-candidates 0 + "Number of other candidates available for cycling. +This is for use by other libraries, in particular, `icomplete+.el'.") + +(defvar icicle-next-apropos-complete-cycles-p nil + "Whether the next apropos-completion command should cycle.") + +(defvar icicle-next-prefix-complete-cycles-p nil + "Whether the next prefix-completion command should cycle.") + +(defvar icicle-plist-last-initial-cand-set () + "Cache for initial set of completion candidates for `icicle-plist'.") + +(defvar icicle-post-command-hook nil + "Functions added to `post-command-hook' when in Icicle mode. +Use command `icy-mode' (aka `icicle-mode') to set this up properly.") + +(defvar icicle-pre-command-hook nil + "Functions added to `pre-command-hook' when in Icicle mode. +Use command `icy-mode' (aka `icicle-mode') to set this up properly.") + +(defvar icicle-old-read-file-name-fn (and (not (boundp 'read-file-name-function)) ; Em 22+ + 'orig-read-file-name) ; Emacs 20, 21 + "Value of `read-file-name-function' outside of Icicle mode. +For versions of Emacs before 22, this is `read-file-name'.") + +(defvar icicle-predicate-types-alist + '(("arrayp") ("atom") ("auto-save-file-name-p" . "file") ("backup-file-name-p" . "file") + ("booleanp") ("bool-vector-p") ("bufferp" . "buffer") + ("byte-code-function-p" . "function") ("byte-compile-const-symbol-p" . "symbol") + ("case-table-p") ("char-or-string-p") ("char-table-p") ("color-defined-p" . "color") + ("commandp" . "command") ("consp") ("custom-variable-p" . "option") + ("display-table-p") ("facep" . "face") ("fboundp" . "function") + ("ffap-file-remote-p" . "file") ("file-accessible-directory-p" . "file") + ("file-directory-p" . "file") ("file-executable-p" . "file") + ("file-exists-p" . "file") ("file-name-absolute-p" . "file") + ("file-readable-p" . "file") ("file-regular-p" . "file") ("file-remote-p" . "file") + ("file-symlink-p" . "file") ("file-writable-p" . "file") ("floatp") + ("frame-configuration-p") ("frame-iconified-p" . "frame") ("frame-live-p" . "frame") + ("frame-visible-p" . "frame") ("framep" . "frame") ("functionp" . "function") + ("hash-table-p") ("icicle-binary-option-p" . "option") ("info-file-exists-p" . "file") + ("integer-or-marker-p") ("integerp") ("keymapp") ("keywordp") ("listp") + ("local-variable-p" . "variable") ("markerp") ("wholenump") ("nlistp") ("numberp") + ("number-or-marker-p") ("overlayp") ("processp" . "process") + ("process-running-child-p" . "process") ("risky-local-variable-p" . "variable") + ("safe-local-variable-p" . "variable") ("sequencep") ("string-or-null-p") ("stringp") + ("subrp") ("symbolp" . "symbol") ("syntax-table-p") + ("thumfr-thumbnail-frame-p" . "frame") ("truncated-partial-width-window-p" . "window") + ("user-variable-p" . "option") ("vectorp") ("window-configuration-p") + ("window-fixed-size-p" . "window") ("window-full-width-p" . "window") + ("window-live-p" . "window") ("window-minibuffer-p" . "window") ("windowp" . "window") + ("window-safely-shrinkable-p" . "window") ("x-color-defined-p" . "color")) + "Alist of type names that are predicate names. +Each element is cons of a predicate name and the associated type from +`icicle-type-actions-alist' (or nil if there is no associated type).") + +(defvar icicle-pre-minibuffer-buffer nil + "Buffer that was current before the minibuffer became active.") + +(defvar icicle-previous-raw-file-name-inputs nil + "Previous inputs user has typed during file-name completion. +These are inputs typed but not necessarily entered with `RET'.") + +(defvar icicle-previous-raw-non-file-name-inputs nil + "Previous inputs user has typed during non-file-name completion. +These are inputs typed but not necessarily entered with `RET'.") + +(defvar icicle-progressive-completing-p nil + "Non-nil means this completion is a narrowing completion.") + +(defvar icicle-proxy-candidate-regexp nil + "Regexp to match proxy candidates, or nil to do nothing. +The candidates are highlighted in buffer *Completions* using face +`icicle-proxy-candidate'.") + +(defvar icicle-proxy-candidates nil "List of proxy completion candidates (strings).") + +(defvar icicle-read-expression-map nil + "Icicle mode version of `read-expression-map'. +Several Emacs-Lisp mode key bindings are used.") +(unless icicle-read-expression-map + (let ((map (make-sparse-keymap))) + (define-key map "\M-\t" 'lisp-complete-symbol) + (define-key map "\t" 'lisp-indent-line) + (define-key map "\e\C-q" 'indent-sexp) + (define-key map "\e\t" 'lisp-complete-symbol) + (define-key map "\e\C-x" 'eval-defun) + (define-key map "\e\C-q" 'indent-pp-sexp) + ;;(define-key map "\177" 'backward-delete-char-untabify) + (set-keymap-parent map minibuffer-local-map) + (setq icicle-read-expression-map map))) + +(defvar icicle-remove-icicles-props-p t + "Non-nil means to remove Icicles text properties from completion result. +Icicles binds this internal variable to nil in contexts where it needs +the completion result string to retain its Icicles text properties. + +Otherwise, function `icicle-unpropertize' removes at least the Icicles +internal text properties from the final completion result. Depending +on the value of option `icicle-unpropertize-completion-result-flag', +it may also remove all text properties.") + +(defvar icicle-re-no-dot "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*" + "Regexp that matches anything except `.' and `..'.") + +(defvar icicle-require-match-p nil + "Current REQUIRE-MATCH arg to `completing-read' or `read-file-name'. +Starting with Emacs 23, this is no longer enough to tell whether a +match is required - use function `icicle-require-match-p' instead.") + +(defvar icicle-reverse-multi-sort-p nil + "Non-nil means the truth values returned by predicates are complemented. +This changes the order of the sorting groups, but it does not in +general reverse that order. The order within each group is unchanged +\(not reversed).") + +(defvar icicle-reverse-sort-p nil + "Non-nil means that candidates are being sorted in the reverse order.") + +(defvar icicle-saved-candidate-overlays nil + "Overlays used to highlight saved completion candidates.") + +(defvar icicle-saved-candidates-variables-obarray (make-vector 100 0) + "Obarray of variables you have saved sets of completion candidates in. +Used for completion in `icicle-candidate-set-retrieve-from-variable'.") + +(defvar icicle-saved-completion-candidate nil + "Completion candidate to be restored after recursive `completing-read'.") + +(defvar icicle-saved-completion-candidates nil + "Completion candidates saved using `icicle-candidate-set-save'.") + +(defvar icicle-saved-completion-candidates-internal nil + "Completion candidates saved temporarily by program.") + +(defvar icicle-saved-ignored-extensions nil + "Local copy of `icicle-ignored-extensions', so we can restore it.") + +(when (boundp 'kmacro-ring) ; Emacs 22+ + (defvar icicle-saved-kmacro-ring-max kmacro-ring-max + "Saved value of `kmacro-ring-max', so it can be restored.")) + +(defvar icicle-saved-regexp-search-ring-max regexp-search-ring-max + "Saved value of `search-ring-max', so it can be restored.") + +(defvar icicle-saved-proxy-candidates nil "Saved value of `icicle-proxy-candidates'.") + +(defvar icicle-saved-region-background nil + "Background of `region' face. Saved so it can be restored.") + +(defvar icicle-saved-search-ring-max search-ring-max + "Saved value of `search-ring-max', so it can be restored.") + +(defvar icicle-scroll-Completions-backward-p nil + "Non-nil means repeated `TAB' or `S-TAB' scrolls *Completions* backward.") + +(defvar icicle-search-command 'icicle-search + "Command to use for Icicles searches. +You can set a buffer-local value of this variable, to use a specific +search command in a particular mode.") + +(defvar icicle-search-context-level 0 + "Match level for `icicle-search' context regexp. +0 means use whatever matches the whole context regexp as the search +context. 1 means use whatever matches the first subgroup of the +regexp as the search context, and so on.") + +(defvar icicle-search-context-regexp "" + "Current search-context regexp used in `icicle-search'.") + +(defvar icicle-search-current-overlay nil + "Overlay used to highlight current match of `icicle-search' regexp arg.") + +(defvar icicle-search-final-choice nil + "Final user input from `icicle-search'. +This might or might not be one of the possible search candidates.") + +(defvar icicle-search-history nil "History for `icicle-search' final choices.") + +(defvar icicle-search-in-context-fn 'icicle-search-in-context-default-fn + "Function used by `icicle-search-action' to act on search context. +The default value is `icicle-search-in-context-default-fn'. +The function must take two arguments: + - A full search candidate object, which is a cons of the candidate + name and its source-file marker. + - A replacement string, or nil, if no replacement is to be made. + +When the function is called, the region has been narrowed to the +current search context.") + +(defvar icicle-searching-p nil "Non-nil means an Icicles search command is in progress.") + +(defvar icicle-search-level-overlays nil + "Overlays used to highlight context levels other than the top level.") + +(defvar icicle-search-overlays nil + "Overlays used to highlight match of `icicle-search' regexp argument.") + +(defvar icicle-search-refined-overlays nil + "Overlay(s) used to highlight match of current input for `icicle-search'. +If `icicle-search-highlight-threshold' is less than one, then this is +a single overlay (or nil). Otherwise, this is a list of overlays.") + +(defvar icicle-search-replacement nil + "Replacement string for use during `icicle-search'.") + +(defvar icicle-search-replacement-history nil + "History variable for reading replacement string for `icicle-search'.") + +(defvar icicle-successive-grab-count 0 + "Number of text things to be grabbed by next `\\\ +\\[icicle-insert-string-at-point]'.") + +(defvar icicle-text-property-value-history nil + "History variable for reading text properties.") + +;; (defvar icicle-text-properties-alist +;; '(;; Properties listed in Elisp manual node `Special Properties': +;; ("category") ("face") ("font-lock-face") ("mouse-face") ("fontified") ("display") +;; ("help-echo") ("keymap") ("local-map") ("syntax-table") ("read-only") ("invisible") +;; ("intangible") ("field") ("cursor") ("pointer") ("line-spacing") ("line-height") +;; ("modification-hooks") ("insert-in-front-hooks") ("insert-behind-hooks") +;; ("point-entered") ("point-left") +;; ;; Properties listed in Elisp manual node `Format Properties': +;; ("hard") ("right-margin") ("left-margin") ("justification") +;; ;; Properties listed in Elisp manual node `Links and Mouse-1': +;; ("follow-link") +;; ;; Others in Emacs-Lisp libraries in directory `lisp': +;; ("allout-was-hidden") ("ansi-color") ("buffer") ("buffer-name") ("column") +;; ("button") ("skip") ("literal") ("front-sticky") ("rear-nonsticky") ("composition") +;; ("untranslated-utf-8") ("yank-handler") ("dired-filename") ("read-face-name") +;; ("directory") ("message") ("debug") ("font-lock-multiline") ("unknown") +;; ("insert-in-front-hooks") ("kbd-help") ("hilit-chg") ("ibuffer-filter-group-name") +;; ("ibuffer-properties") ("ibuffer-title") ("ibuffer-summary") +;; ("ibuffer-title-header") ("inhibit-line-move-field-capture") ("image-counter") +;; ("header-line") ("cvs-goal-column") ("occur-target") ("occur-match") +;; ("foreign-selection") ("before-string") ("after-string") ("ses") +;; ("smerge-force-highlighting") ("speedbar-function") ("speedbar-token") +;; ("speedbar-text") ("type") ("stroke-glyph") ("data") ("thumb-image-file") +;; ("original-file-name") ("associated-dired-buffer") ("tags") ("comment") +;; ("tumme-thumbnail") ("tutorial-remark") ("vc-cvs-annotate-time") ("end-name") +;; ("old-name") ("end-link") ("old-link") ("end-perm") ("old-perm") ("perm-changed") +;; ("widget-doc") ("secret") ("real-field") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/emacs-lisp': +;; ("elp-symname") ("printed-value") ("duplicable") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/emulation': +;; ("cursor") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/erc': +;; ("erc-callback") ("erc-data") ("erc-identified") ("erc-parsed") ("erc-parsed") +;; ("timestamp") ("erc-prompt") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/eshell': +;; ("comment") ("arg-begin") ("arg-end") ("escaped") ("history") ("number") +;; ("test-func") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/gnus': +;; ("earcon-data") ("earcon-callback") ("gnus-category") ("gnus-part") +;; ("article-type") ("gnus-decoration") ("dummy-invisible") ("original-date") +;; ("gnus-data") ("gnus-callback") ("gnus-prev") ("gnus-next") ("gnus-mime-details") +;; ("gnus-line-format") ("gnus-backlog") ("gnus-image-category") +;; ("gnus-image-text-deletable") ("gnus-group") ("gnus-level") ("gnus-indentation") +;; ("gnus-unread") ("gnus-number") ("articles") ("gnus-server") ("gnus-named-server") +;; ("gnus-intangible") ("gnus-topic") ("gnus-topic-level") ("gnus-topic-unread") +;; ("gnus-topic-visible") ("gnus-active") ("gnus-position") ("gnus-time") +;; ("gnus-face") ("gnus-undeletable") ("message-rank") ("egg-end") ("egg-lang") +;; ("egg-start") ("message-hidden") ("message-deletable") ("buffer") ("from") ("mm") +;; ("script-name") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/international': +;; ("kkc-conversion-index") ("advice") ("untranslated-utf-8") ("composition") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/mail': +;; ("footnote-number") ("rmail-fontified") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/mh-e': +;; ("mh-data") ("mh-mime-inserted") ("mh-part") ("mh-region") ("mh-callback") +;; ("mh-button-pressed") ("mh-line-format") ("mh-folder") ("mh-children-p") +;; ("mh-expanded") ("mh-level") ("mh-count") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/net': +;; ("feed") ("w3m-image") ("nt-age") ("nt-title") ("nt-guid") ("nt-desc") +;; ("org-invisible") ("nt-link") ("nt-type") ("nt-face") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/progmodes': +;; ("c-type") ("c-awk-NL-prop") ("c-is-sws") ("c-decl-arg-start") ("c-decl-end") +;; ("c-decl-id-start") ("c-decl-type-start") ("message") ("REx-interpolated") +;; ("in-pod") ("here-doc-group") ("syntax-type") ("indentable") ("REx-part2") +;; ("first-format-line") ("attrib-group") ("cperl-postpone") ("cpp-data") +;; ("cpp-callback") ("token") ("ebrowse-tree") ("ebrowse-member") ("ebrowse-what") +;; ("gdb-enabled") ("gdb-bptno") ("gdb-max-frames") ("link") ("fetch") ("begin-glyph") +;; ("begin-glyph-layout") ("idlwave-class") ("data") ("source") ("keyword") +;; ("find-args") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/term': +;; ("mac-ts-active-input-string") +;; ;; Others in Emacs-Lisp libraries in directory `lisp/textmodes': +;; ("fill-space") ("priority") ("test") ("end-glyph") ("begin-glyph") ("org-cwidth") +;; ("org-dwidth") ("org-dwidth-n") ("org-linked-text") (":org-clock-minutes") +;; ("org-protected") ("org-date-line") ("org-today") ("day") ("org-agenda-type") +;; ("time-of-day") ("org-not-done-regexp") ("prefix-length") ("tags") ("org-marker") +;; ("org-agenda-diary-link") ("org-hd-marker") ("dotime") ("org-category") +;; ("undone-face") ("done-face") ("xr-alist") ("table-cell") ("text-clones") +;; ;; Others in my own libraries: +;; ("font-lock-ignore") ("highlight") ("back-link") ("forward-link")) +;; "Alist of text properties known to Emacs. +;; Each element is of form (PROP), where PROP is the name of a text +;; property (a string).") + +(defvar icicle-thing-at-pt-fns-pointer 0 + "Current index into the car of `icicle-thing-at-point-functions'. +This points to the current function in the list.") + +(defvar icicle-transform-before-sort-p nil + "Non-nil means transform each multi-completion candidate before sorting. +Bind this to non-nil if you do not want sorting to use the whole +multi-completion.") + +(defvar icicle-universal-argument-map + (let ((map (make-sparse-keymap))) + (define-key map [t] 'icicle-universal-argument-other-key) + (define-key map (vector meta-prefix-char t) 'icicle-universal-argument-other-key) + (define-key map [switch-frame] nil) + (define-key map [?\C-u] 'icicle-universal-argument-more) + (define-key map [?-] 'icicle-universal-argument-minus) + (define-key map [?0] 'icicle-digit-argument) + (define-key map [?1] 'icicle-digit-argument) + (define-key map [?2] 'icicle-digit-argument) + (define-key map [?3] 'icicle-digit-argument) + (define-key map [?4] 'icicle-digit-argument) + (define-key map [?5] 'icicle-digit-argument) + (define-key map [?6] 'icicle-digit-argument) + (define-key map [?7] 'icicle-digit-argument) + (define-key map [?8] 'icicle-digit-argument) + (define-key map [?9] 'icicle-digit-argument) + (define-key map [kp-0] 'icicle-digit-argument) + (define-key map [kp-1] 'icicle-digit-argument) + (define-key map [kp-2] 'icicle-digit-argument) + (define-key map [kp-3] 'icicle-digit-argument) + (define-key map [kp-4] 'icicle-digit-argument) + (define-key map [kp-5] 'icicle-digit-argument) + (define-key map [kp-6] 'icicle-digit-argument) + (define-key map [kp-7] 'icicle-digit-argument) + (define-key map [kp-8] 'icicle-digit-argument) + (define-key map [kp-9] 'icicle-digit-argument) + (define-key map [kp-subtract] 'icicle-universal-argument-minus) + map) + "Keymap used while processing `C-u' during Icicles completion.") + +(defvar icicle-use-candidates-only-once-alt-p nil + "*Non-nil means remove each candidate from the set after using it. +This is similar to `icicle-use-candidates-only-once-flag', but it is +used only for alternative actions (e.g. `C-S-RET').") + +(defvar icicle-vardoc-last-initial-cand-set () + "Cache for initial set of completion candidates for `icicle-vardoc'.") + +(defvar icicle-vardoc-last-initial-option-cand-set () + "Cache for initial option completion candidates for `icicle-vardoc'.") + +(defvar icicle-whole-candidate-as-text-prop-p nil + "Non-nil means string candidate has candidate data as text property. +If non-nil, then the value of text property `icicle-whole-candidate' +for a string completion candidate (e.g. what is displayed) is the cdr +of the full completion-candidate alist element. The car of that +element is the string.") + +(defvar icicle-variable-name-history nil "History for variable names.") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles-var) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles-var.el ends here diff --git a/.emacs.d/icicles/icicles.el b/.emacs.d/icicles/icicles.el new file mode 100644 index 0000000..d466383 --- /dev/null +++ b/.emacs.d/icicles/icicles.el @@ -0,0 +1,1196 @@ +;;; icicles.el --- Minibuffer input completion and cycling. +;; +;; Filename: icicles.el +;; Description: Minibuffer completion and cycling. +;; Author: Drew Adams +;; Maintainer: Drew Adams +;; Copyright (C) 1996-2010, Drew Adams, all rights reserved. +;; Created: Tue Aug 1 14:21:16 1995 +;; Version: 22.0 +;; Last-Updated: Sat Jul 17 14:18:32 2010 (-0700) +;; By: dradams +;; Update #: 22767 +;; URL: http://www.emacswiki.org/cgi-bin/wiki/icicles.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+', `apropos-fn+var', `avoid', `cl', +;; `cus-edit', `cus-face', `cus-load', `cus-start', `custom', +;; `dired', `dired+', `dired-aux', `dired-x', `doremi', `easymenu', +;; `ediff-diff', `ediff-help', `ediff-init', `ediff-merg', +;; `ediff-mult', `ediff-util', `ediff-wind', `el-swank-fuzzy', +;; `ffap', `ffap-', `fit-frame', `frame-cmds', `frame-fns', +;; `fuzzy-match', `help+20', `hexrgb', `icicles-cmd1', +;; `icicles-cmd2', `icicles-face', `icicles-fn', `icicles-mac', +;; `icicles-mcmd', `icicles-mode', `icicles-opt', `icicles-var', +;; `info', `info+', `kmacro', `levenshtein', `menu-bar', +;; `menu-bar+', `misc-cmds', `misc-fns', `mkhtml', +;; `mkhtml-htmlize', `mwheel', `pp', `pp+', `ring', `ring+', +;; `second-sel', `strings', `thingatpt', `thingatpt+', `unaccent', +;; `w32-browser', `w32browser-dlgopen', `wid-edit', `wid-edit+', +;; `widget'. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; Minibuffer input completion and cycling of completion candidates. +;; +;; Input completion takes as input a string and returns a name that +;; contains the input string. This library enables minibuffer +;; cycling of completion candidates, and provides additional support +;; for input completion. +;; +;; Two kinds of completion are offered here, which are distinguished +;; by how the input string is matched against the completed name: +;; +;; - Prefix completion - The input string is a prefix of the +;; completed name. This is the usual Emacs +;; completion. +;; +;; - Apropos completion - The input string is a regular expression +;; that matches somewhere (anywhere) within +;; the completed name. You can think of the +;; name as having been returned by `apropos' +;; (except it also works for file and buffer +;; names). +;; +;; Files `icicles-doc1.el' and `icicles-doc2.el' contain the doc for +;; Icicles, including how to install and use Icicles. You can also +;; read the Icicles doc, in formatted form, on the Emacs-Wiki Web +;; site: http://www.emacswiki.org/cgi-bin/wiki/Icicles. Emacs Wiki +;; also has a few addtional pages about Icicles. In particular, if +;; you are new to Emacs, as well as Icicles, see this page: +;; http://www.emacswiki.org/cgi-bin/wiki/EmacsNewbieWithIcicles. +;; +;; See also: Library `lacarte.el', which lets you execute menu +;; commands, cycling and completing them. It is not part of Icicles, +;; but it is greatly enhanced by Icicles. + +;;(@> "Index") +;; +;; 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. +;; +;; (@> "Things Defined in Icicles") + +;;(@* "Things Defined in Icicles") +;; +;; Things Defined in Icicles +;; ------------------------- +;; +;; Key bindings defined in Icicles: see (@> "Key Bindings"), below. +;; +;; Macros defined in Icicles: +;; +;; `icicle-buffer-bindings', `icicle-define-add-to-alist-command', +;; `icicle-define-bookmark-command', +;; `icicle-define-bookmark-command-1', +;; `icicle-define-bookmark-other-window-command', +;; `icicle-define-command', `icicle-define-file-command', +;; `icicle-define-search-bookmark-command', +;; `icicle-define-sort-command', `icicle-file-bindings', +;; `icicle-with-selected-window'. +;; +;; Commands defined in Icicles - +;; +;; Commands to be used mainly at top level: +;; +;; `a', `any', `buffer', `clear-option', `file', +;; `icicle-add-buffer-candidate', `icicle-add-buffer-config', +;; `icicle-add-entry-to-saved-completion-set', +;; `icicle-add-file-to-fileset', +;; `icicle-add/update-saved-completion-set', `icicle-anything', +;; `icicle-apply' `icicle-apropos', `icicle-apropos-command', +;; `icicle-apropos-function', `icicle-apropos-option', +;; `icicle-apropos-variable', `icicle-apropos-zippy', +;; `icicle-bbdb-complete-name', `icicle-bookmark', +;; `icicle-bookmark-all-tags', +;; `icicle-bookmark-all-tags-other-window', +;; `icicle-bookmark-all-tags-regexp', +;; `icicle-bookmark-all-tags-regexp-other-window', +;; `icicle-bookmark-bookmark-list', `icicle-bookmark-cmd', +;; `icicle-bookmark-desktop', `icicle-bookmark-dired', +;; `icicle-bookmark-dired-other-window', +;; `icicle-bookmarked-buffer-list', `icicle-bookmarked-file-list', +;; `icicle-bookmark-file', `icicle-bookmark-file-other-window', +;; `icicle-bookmark-gnus', `icicle-bookmark-gnus-other-window', +;; `icicle-bookmark-info', `icicle-bookmark-info-other-window', +;; `icicle-bookmark-jump', `icicle-bookmark-jump-other-window', +;; `icicle-bookmark-list', `icicle-bookmark-local-file', +;; `icicle-bookmark-local-file-other-window', +;; `icicle-bookmark-man', `icicle-bookmark-man-other-window', +;; `icicle-bookmark-non-file', +;; `icicle-bookmark-non-file-other-window', +;; `icicle-bookmark-other-window', `icicle-bookmark-region', +;; `icicle-bookmark-region-other-window', +;; `icicle-bookmark-remote-file', +;; `icicle-bookmark-remote-file-other-window', +;; `icicle-bookmark-set', `icicle-bookmark-some-tags', +;; `icicle-bookmark-some-tags-other-window', +;; `icicle-bookmark-some-tags-regexp', +;; `icicle-bookmark-some-tags-regexp-other-window', +;; `icicle-bookmark-specific-buffers', +;; `icicle-bookmark-specific-buffers-other-window', +;; `icicle-bookmark-specific-files', +;; `icicle-bookmark-specific-files-other-window', +;; `icicle-bookmark-this-buffer', +;; `icicle-bookmark-this-buffer-other-window', +;; `icicle-bookmark-url', `icicle-bookmark-url-other-window' +;; `icicle-bookmark-w3m-other-window', `icicle-buffer', +;; `icicle-buffer-config', `icicle-buffer-list', +;; `icicle-buffer-other-window', +;; `icicle-change-alternative-sort-order', +;; `icicle-change-history-variable', `icicle-clear-history', +;; `icicle-clear-current-history', `icicle-color-theme', +;; `icicle-comint-command', `icicle-comint-dynamic-complete', +;; `icicle-comint-dynamic-complete-filename', +;; `icicle-comint-replace-by-expanded-filename', +;; `icicle-comint-search', `icicle-command-abbrev', +;; `icicle-compilation-search', `icicle-complete-keys', +;; `icicle-complete-thesaurus-entry', `icicle-completing-yank', +;; `icicle-customize-apropos', `icicle-customize-apropos-faces', +;; `icicle-customize-apropos-groups', +;; `icicle-customize-apropos-options', +;; `icicle-customize-apropos-options-of-type', +;; `icicle-customize-face', `icicle-customize-icicles-group', +;; `icicle-dabbrev-completion', `icicle-delete-file', +;; `icicle-delete-window', `icicle-delete-windows', +;; `icicle-delete-windows-on', `icicle-describe-file', +;; `icicle-describe-option-of-type', `icicle-directory-list', +;; `icicle-dired', `icicle-dired-chosen-files', +;; `icicle-dired-chosen-files-other-window', +;; `icicle-dired-other-window', `icicle-dired-project', +;; `icicle-dired-project-other-window', +;; `icicle-dired-saved-file-candidates', +;; `icicle-dired-saved-file-candidates-other-window', +;; `icicle-dired-save-marked', +;; `icicle-dired-save-marked-as-project', +;; `icicle-dired-save-marked-more', +;; `icicle-dired-save-marked-persistently', +;; `icicle-dired-save-marked-to-variable', `icicle-doc', +;; `icicle-doremi-candidate-width-factor+', +;; `icicle-doremi-increment-max-candidates+', +;; `icicle-doremi-increment-swank-prefix-length+', +;; `icicle-doremi-increment-swank-timeout+', +;; `icicle-doremi-increment-variable+', +;; `icicle-doremi-inter-candidates-min-spaces+', +;; `icicle-ess-complete-filename', +;; `icicle-ess-complete-object-name', +;; `icicle-ess-internal-complete-object-name', +;; `icicle-ess-R-complete-object-name', +;; `icicle-exchange-point-and-mark', +;; `icicle-execute-extended-command', +;; `icicle-execute-named-keyboard-macro', `icicle-face-list', +;; `icicle-file', `icicle-file-list', `icicle-file-other-window', +;; `icicle-find-file', `icicle-find-file-absolute', +;; `icicle-find-file-absolute-other-window', +;; `icicle-find-file-in-tags-table', +;; `icicle-find-file-in-tags-table-other-window', +;; `icicle-find-file-other-window', `icicle-find-file-read-only', +;; `icicle-find-file-read-only-other-window', +;; `icicle-find-first-tag', `icicle-find-first-tag-other-window', +;; `icicle-find-tag', `icicle-font', `icicle-frame-bg', +;; `icicle-frame-fg', `icicle-fundoc', `icicle-goto-global-marker', +;; `icicle-goto-global-marker-or-pop-global-mark', +;; `icicle-goto-marker', `icicle-goto-marker-or-set-mark-command', +;; `icicle-grep-saved-file-candidates', +;; `icicle-gud-gdb-complete-command', `icicle-handle-switch-frame', +;; `icicle-ido-like-mode', `icicle-imenu', `icicle-imenu-command', +;; `icicle-imenu-non-interactive-function', +;; `icicle-increment-option', `icicle-increment-variable', +;; `icicle-Info-goto-node', `icicle-Info-goto-node-cmd', +;; `icicle-Info-index', `icicle-Info-index-20', +;; `icicle-Info-index-cmd', `icicle-Info-menu', +;; `icicle-Info-menu-cmd', `icicle-Info-virtual-book', +;; `icicle-insert-buffer', `icicle-insert-char', +;; `icicle-insert-thesaurus-entry', `icicle-keyword-list', +;; `icicle-kill-buffer', `icicle-kmacro', +;; `icicle-lisp-complete-symbol', `icicle-locate-file', +;; `icicle-locate-file-no-symlinks', +;; `icicle-locate-file-no-symlinks-other-window', +;; `icicle-locate-file-other-window', `icicle-mode', `icy-mode', +;; `icicle-object-action', `icicle-occur', +;; `icicle-other-window-or-frame', `icicle-plist', +;; `icicle-pop-tag-mark', `icicle-pp-eval-expression', +;; `icicle-read-color', `icicle-read-kbd-macro', +;; `icicle-recent-file', `icicle-recent-file-other-window', +;; `icicle-recompute-shell-command-candidates', +;; `icicle-regexp-list', `icicle-remove-buffer-candidate', +;; `icicle-remove-buffer-config', +;; `icicle-remove-entry-from-saved-completion-set', +;; `icicle-remove-file-from-recentf-list', +;; `icicle-remove-saved-completion-set', +;; `icicle-repeat-complex-command', `icicle-reset-option-to-nil', +;; `icicle-save-string-to-variable', `icicle-search', +;; `icicle-search-all-tags-bookmark', +;; `icicle-search-all-tags-regexp-bookmark', +;; `icicle-search-bookmark', +;; `icicle-search-bookmark-list-bookmark', +;; `icicle-search-bookmarks-together', `icicle-search-buffer', +;; `icicle-search-buff-menu-marked', `icicle-search-char-property', +;; `icicle-search-defs', `icicle-search-desktop-bookmark', +;; `icicle-search-dired-bookmark', `icicle-search-dired-marked', +;; `icicle-search-file', `icicle-search-file-bookmark', +;; `icicle-search-generic', `icicle-search-gnus-bookmark', +;; `icicle-search-highlight-cleanup', +;; `icicle-search-ibuffer-marked', `icicle-search-info-bookmark', +;; `icicle-search-keywords', `icicle-search-lines', +;; `icicle-search-local-file-bookmark', +;; `icicle-search-man-bookmark', `icicle-search-non-file-bookmark', +;; `icicle-search-overlay-property', `icicle-search-pages', +;; `icicle-search-paragraphs', `icicle-search-region-bookmark', +;; `icicle-search-remote-file-bookmark', `icicle-search-sentences', +;; `icicle-search-some-tags-bookmark', +;; `icicle-search-some-tags-regexp-bookmark', +;; `icicle-search-specific-buffers-bookmark', +;; `icicle-search-specific-files-bookmark', +;; `icicle-search-text-property', +;; `icicle-search-this-buffer-bookmark', +;; `icicle-search-url-bookmark', `icicle-search-w3m-bookmark', +;; `icicle-search-word', `icicle-select-bookmarked-region', +;; `icicle-select-frame', `icicle-select-frame-by-name', +;; `icicle-select-window', `icicle-select-window-by-name', +;; `icicle-send-bug-report', `icicle-set-option-to-t', +;; `icicle-shell-command-on-file', +;; `icicle-shell-dynamic-complete-command', +;; `icicle-shell-dynamic-complete-environment-variable', +;; `icicle-shell-dynamic-complete-filename', `icicle-sit-for', +;; `icicle-skip-this-command', `icicle-sort-alphabetical', +;; `icicle-sort-by-abbrev-frequency', +;; `icicle-sort-by-directories-first', +;; `icicle-sort-by-directories-last', +;; `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-special-candidates-first', +;; `icicle-sort-turned-OFF', `icicle-tags-search', +;; `icicle-toggle-~-for-home-dir', +;; `icicle-toggle-alternative-sorting', +;; `icicle-toggle-angle-brackets', +;; `icicle-toggle-case-sensitivity', `icicle-toggle-C-for-actions', +;; `icicle-toggle-hiding-common-match', +;; `icicle-toggle-highlight-all-current', +;; `icicle-toggle-highlight-historical-candidates', +;; `icicle-toggle-ignored-extensions', +;; `icicle-toggle-ignored-space-prefix', +;; `icicle-toggle-incremental-completion', +;; `icicle-toggle-literal-replacement', `icicle-toggle-option', +;; `icicle-toggle-proxy-candidates', `icicle-toggle-regexp-quote', +;; `icicle-toggle-remote-file-testing', +;; `icicle-toggle-search-cleanup', +;; `icicle-toggle-search-replace-whole', +;; `icicle-toggle-search-whole-word', `icicle-toggle-sorting', +;; `icicle-toggle-transforming', +;; `icicle-toggle-WYSIWYG-Completions', `icicle-vardoc', +;; `icicle-where-is', `icicle-yank-maybe-completing', +;; `old-bbdb-complete-name', `old-comint-dynamic-complete', +;; `old-comint-replace-by-expanded-filename', +;; `old-dired-read-shell-command', `old-ess-complete-object-name', +;; `old-gud-gdb-complete-command', `old-read-shell-command', +;; `orig-read-file-name', `toggle', `toggle-icicle-~-for-home-dir', +;; `toggle-icicle-alternative-sorting', +;; `toggle-icicle-angle-brackets', +;; `toggle-icicle-case-sensitivity', `toggle-icicle-C-for-actions', +;; `toggle-icicle-fuzzy-completion', +;; `toggle-icicle-highlight-all-current', +;; `toggle-icicle-highlight-historical-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-replace-whole', +;; `toggle-icicle-search-whole-word', +;; `toggle-icicle-show-multi-completion', `toggle-icicle-sorting', +;; `toggle-icicle-transforming', +;; `toggle-icicle-WYSIWYG-Completions', `what-which-how'. +;; +;; Commands to be used mainly in the minibuffer or `*Completions*': +;; +;; `icicle-abort-recursive-edit', `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-bookmark-bookmark-list-narrow', +;; `icicle-bookmark-desktop-narrow', +;; `icicle-bookmark-dired-narrow',`icicle-bookmark-file-narrow', +;; `icicle-bookmark-gnus-narrow', `icicle-bookmark-info-narrow', +;; `icicle-bookmark-local-file-narrow', +;; `icicle-bookmark-man-narrow', `icicle-bookmark-non-file-narrow', +;; `icicle-bookmark-region-narrow', +;; `icicle-bookmark-remote-file-narrow', +;; `icicle-bookmark-specific-buffers-narrow', +;; `icicle-bookmark-specific-files-narrow', +;; `icicle-bookmark-this-buffer-narrow', +;; `icicle-bookmark-url-narrow', `icicle-bookmark-w3m-narrow', +;; `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-cd-for-abs-files', +;; `icicle-cd-for-loc-files', +;; `icicle-change-alternative-sort-order', +;; `icicle-change-sort-order', `icicle-change-sort-order', +;; `icicle-choose-completion', `icicle-clear-current-history', +;; `icicle-completing-read+insert', +;; `icicle-Completions-mouse-3-menu', +;; `icicle-search-define-replacement', +;; `icicle-delete-backward-char', `icicle-delete-candidate-object', +;; `icicle-delete-char', `icicle-digit-argument', +;; `icicle-dispatch-C-^', `icicle-dispatch-C-.', +;; `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-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-candidate-per-mode-help', `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-other-history', +;; `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-candidate-per-mode-help', +;; `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-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', +;; `icicle-scroll-Completions-up', +;; `icicle-search-define-replacement', `icicle-self-insert', +;; `icicle-sort-alphabetical', `icicle-sort-by-abbrev-frequency', +;; `icicle-sort-by-directories-first', +;; `icicle-sort-by-directories-last', +;; `icicle-sort-by-last-file-modification-time', +;; `icicle-sort-by-last-use-as-input', +;; `icicle-sort-by-previous-use-alphabetically', +;; `icicle-sort-case-insensitive', +;; `icicle-sort-proxy-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-C-for-actions', +;; `icicle-toggle-alternative-sorting', +;; `icicle-toggle-angle-brackets', +;; `icicle-toggle-case-sensitivity', `icicle-toggle-dot', +;; `icicle-toggle-expand-to-common-match', +;; `icicle-toggle-highlight-all-current', +;; `icicle-toggle-highlight-historical-candidates', +;; `icicle-toggle-ignored-extensions', +;; `icicle-toggle-ignored-space-prefix', +;; `icicle-toggle-incremental-completion', +;; `icicle-toggle-literal-replacement', +;; `icicle-toggle-proxy-candidates', `icicle-toggle-regexp-quote', +;; `icicle-toggle-search-cleanup', +;; `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-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-C-for-actions', +;; `toggle-icicle-alternative-sorting', +;; `toggle-icicle-angle-brackets', +;; `toggle-icicle-case-sensitivity', `toggle-icicle-dot', +;; `toggle-icicle-expand-to-common-match', +;; `toggle-icicle-fuzzy-completion', +;; `toggle-icicle-highlight-all-current', +;; `toggle-icicle-highlight-historical-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-search-cleanup', +;; `toggle-icicle-search-replace-common-match', +;; `toggle-icicle-search-replace-whole', +;; `toggle-icicle-search-whole-word', `toggle-icicle-sorting', +;; `toggle-icicle-transforming'. +;; +;; Faces defined in Icicles (in Custom group `icicles'): +;; +;; `icicle-candidate-part', +;; `icicle-common-match-highlight-Completions', +;; `icicle-complete-input', `icicle-completion', +;; `icicle-Completions-instruction-1', +;; `icicle-Completions-instruction-2', +;; `icicle-current-candidate-highlight', `icicle-extra-candidate', +;; `icicle-historical-candidate', `icicle-input-completion-fail', +;; `icicle-input-completion-fail-lax', +;; `icicle-match-highlight-Completions', +;; `icicle-match-highlight-minibuffer', `icicle-mode-line-help', +;; `icicle-mustmatch-completion', `icicle-proxy-candidate', +;; `icicle-saved-candidate', `icicle-search-context-level-1', +;; `icicle-search-context-level-2', +;; `icicle-search-context-level-3', +;; `icicle-search-context-level-4', +;; `icicle-search-context-level-5', +;; `icicle-search-context-level-6', +;; `icicle-search-context-level-7', +;; `icicle-search-context-level-8', `icicle-search-current-input', +;; `icicle-search-main-regexp-current', +;; `icicle-search-main-regexp-others', `icicle-special-candidate', +;; `icicle-whitespace-highlight', `minibuffer-prompt'. +;; +;; User options defined in Icicles: +;; +;; `icicle-act-before-cycle-flag', +;; `icicle-add-proxy-candidates-flag', +;; `icicle-alternative-actions-alist', +;; `icicle-alternative-sort-comparer', +;; `icicle-anything-transform-candidates-flag', +;; `icicle-apropos-complete-keys', +;; `icicle-apropos-complete-no-display-keys', +;; `icicle-apropos-cycle-next-keys', +;; `icicle-apropos-cycle-next-action-keys', +;; `icicle-apropos-cycle-next-alt-action-keys', +;; `icicle-apropos-cycle-next-help-keys', +;; `icicle-apropos-cycle-previous-keys', +;; `icicle-apropos-cycle-previous-action-keys', +;; `icicle-apropos-cycle-previous-alt-action-keys', +;; `icicle-apropos-cycle-previous-help-keys', +;; `icicle-bookmark-name-length-max', +;; `icicle-bookmark-refresh-cache-flag', `icicle-buffer-configs', +;; `icicle-buffer-extras', +;; `icicle-buffer-ignore-space-prefix-flag', +;; `icicle-buffer-match-regexp', `icicle-buffer-no-match-regexp', +;; `icicle-buffer-predicate', `icicle-buffer-require-match-flag' +;; `icicle-buffer-sort', `icicle-buffers-ido-like-flag', +;; `icicle-candidate-width-factor', +;; `icicle-change-region-background-flag', +;; `icicle-change-sort-order-completion-flag', +;; `icicle-C-l-uses-completion-flag', `icicle-color-themes', +;; `icicle-comint-dynamic-complete-replacements', +;; `icicle-command-abbrev-alist', +;; `icicle-command-abbrev-match-all-parts-flag', +;; `icicle-command-abbrev-priority-flag', +;; `icicle-complete-key-anyway-flag', +;; `icicle-complete-keys-self-insert-flag', +;; `icicle-completing-read+insert-keys', +;; `icicle-completion-history-max-length', +;; `icicle-Completions-display-min-input-chars', +;; `icicle-completions-format', +;; `icicle-Completions-frame-at-right-flag', +;; `icicle-Completions-text-scale-decrease', +;; `icicle-Completions-window-max-height', +;; `icicle-customize-save-flag', +;; `icicle-customize-save-variable-function', +;; `icicle-cycle-into-subdirs-flag', +;; `icicle-cycling-respects-completion-mode', +;; `icicle-default-thing-insertion', `icicle-default-value', +;; `icicle-define-alias-commands-flag', +;; `icicle-deletion-action-flag', `icicle-dot-show-regexp-flag', +;; `icicle-dot-string', `icicle-expand-input-to-common-match-flag', +;; `icicle-file-extras', `icicle-file-match-regexp', +;; `icicle-file-no-match-regexp', `icicle-file-predicate', +;; `icicle-file-require-match-flag', `icicle-file-sort', +;; `icicle-files-ido-like-flag', +;; `icicle-filesets-as-saved-completion-sets-flag', +;; `icicle-guess-commands-in-path', +;; `icicle-help-in-mode-line-flag', +;; `icicle-hide-common-match-in-Completions-flag', +;; `icicle-highlight-historical-candidates-flag', +;; `icicle-highlight-input-completion-failure', +;; `icicle-highlight-input-completion-failure-delay', +;; `icicle-highlight-input-completion-failure-threshold', +;; `icicle-highlight-input-initial-whitespace-flag', +;; `icicle-highlight-lighter-flag', `icicle-ignored-directories', +;; `icicle-ignore-space-prefix-flag', +;; `icicle-incremental-completion-delay', +;; `icicle-incremental-completion-flag', +;; `icicle-incremental-completion-threshold', +;; `icicle-inhibit-advice-functions', `icicle-inhibit-ding-flag', +;; `icicle-input-string', `icicle-inter-candidates-min-spaces', +;; `icicle-isearch-complete-keys', `icicle-key-complete-keys', +;; `icicle-key-descriptions-use-<>-flag', +;; `icicle-key-descriptions-use-angle-brackets-flag', +;; `icicle-keymaps-for-key-completion', `icicle-kmacro-ring-max', +;; `icicle-levenshtein-distance', `icicle-list-end-string', +;; `icicle-list-join-string', `icicle-list-nth-parts-join-string', +;; `icicle-mark-position-in-candidate', `icicle-max-candidates', +;; `icicle-menu-items-to-history-flag', +;; `icicle-minibuffer-setup-hook', `icicle-modal-cycle-down-keys', +;; `icicle-modal-cycle-down-action-keys', +;; `icicle-modal-cycle-down-alt-action-keys', +;; `icicle-modal-cycle-down-help-keys', +;; `icicle-modal-cycle-up-keys', +;; `icicle-modal-cycle-up-action-keys', +;; `icicle-modal-cycle-up-alt-action-keys', +;; `icicle-modal-cycle-up-help-keys', `icicle-mode', +;; `icicle-mode-hook', `icicle-no-match-hook', +;; `icicle-option-type-prefix-arg-list', +;; `icicle-point-position-in-candidate', +;; `icicle-populate-interactive-history-flag', +;; `icicle-pp-eval-expression-print-length', +;; `icicle-pp-eval-expression-print-level', +;; `icicle-prefix-complete-keys', +;; `icicle-prefix-complete-no-display-keys', +;; `icicle-prefix-cycle-next-keys', +;; `icicle-prefix-cycle-next-action-keys', +;; `icicle-prefix-cycle-next-alt-action-keys', +;; `icicle-prefix-cycle-next-help-keys', +;; `icicle-prefix-cycle-previous-keys', +;; `icicle-prefix-cycle-previous-action-keys', +;; `icicle-prefix-cycle-previous-alt-action-keys', +;; `icicle-prefix-cycle-previous-help-keys', +;; `icicle-previous-candidate-keys', +;; `icicle-quote-shell-file-name-flag', +;; `icicle-read+insert-file-name-keys', +;; `icicle-redefine-standard-commands-flag', +;; `icicle-regexp-quote-flag', `icicle-regexp-search-ring-max', +;; `icicle-region-background', `icicle-require-match-flag', +;; `icicle-saved-completion-sets', `icicle-search-cleanup-flag', +;; `icicle-search-context-match-predicate', +;; `icicle-search-from-isearch-keys', +;; `icicle-search-highlight-all-current-flag', +;; `icicle-search-highlight-context-levels-flag', +;; `icicle-search-highlight-threshold', `icicle-search-hook', +;; `icicle-search-replace-common-match-flag', +;; `icicle-search-replace-literally-flag', +;; `icicle-search-replace-whole-candidate-flag', +;; `icicle-search-ring-max', `icicle-search-whole-word-flag', +;; `icicle-shell-command-candidates-cache', +;; `icicle-show-Completions-help-flag', +;; `icicle-show-Completions-initially-flag', +;; `icicle-show-multi-completion-flag', `icicle-sort-comparer', +;; `icicle-sort-orders-alist', `icicle-special-candidate-regexp', +;; `icicle-S-TAB-completion-methods-alist', +;; `icicle-swank-prefix-length', `icicle-swank-timeout', +;; `icicle-TAB-completion-methods', +;; `icicle-TAB-shows-candidates-flag', +;; `icicle-test-for-remote-files-flag', +;; `icicle-thing-at-point-functions', +;; `icicle-top-level-key-bindings', +;; `icicle-top-level-when-sole-completion-delay', +;; `icicle-top-level-when-sole-completion-flag', +;; `icicle-touche-pas-aux-menus-flag', `icicle-transform-function', +;; `icicle-type-actions-alist', +;; `icicle-unpropertize-completion-result-flag', +;; `icicle-update-input-hook', `icicle-use-~-for-home-dir-flag', +;; `icicle-use-C-for-actions-flag', +;; `icicle-use-anything-candidates-flag', +;; `icicle-use-candidates-only-once-flag', +;; `icicle-word-completion-keys', +;; `icicle-WYSIWYG-Completions-flag', `icicle-yank-function'. +;; +;; Non-interactive functions in Icicles: +;; +;; `custom-variable-p', `icicle-2nd-part-string-less-p', +;; `icicle-abbreviate-or-expand-file-name', `icicle-activate-mark', +;; `icicle-add-key+cmd', `icicle-add-menu-item-to-cmd-history', +;; `icicle-all-candidates-action-1', `icicle-alpha-p', +;; `icicle-alt-act-fn-for-type', `icicle-any-candidates-p', +;; `icicle-anychar-regexp', `icicle-anything-candidate-value', +;; `icicle-apply-action', `icicle-apply-list-action', +;; `icicle-apply-to-saved-candidate', +;; `icicle-apropos-any-candidates-p', +;; `icicle-apropos-any-file-name-candidates-p', +;; `icicle-apropos-candidates', `icicle-apropos-complete-1', +;; `icicle-backward-delete-char-untabify-dots', +;; `icicle-barf-if-outside-Completions', +;; `icicle-barf-if-outside-Completions-and-minibuffer', +;; `icicle-barf-if-outside-minibuffer', `icicle-binary-option-p', +;; `icicle-bind-completion-keys', `icicle-bind-isearch-keys', +;; `icicle-bind-key-completion-keys-for-map-var', +;; `icicle-bind-key-completion-keys-in-keymaps-from', +;; `icicle-bind-other-keymap-keys', +;; `icicle-bind-top-level-commands', `icicle-bookmark-cleanup', +;; `icicle-bookmark-cleanup-on-quit', +;; `icicle-bookmark-delete-action', `icicle-bookmark-help-string', +;; `icicle-bookmark-jump-1', +;; `icicle-buffer-file/process-name-less-p', +;; `icicle-buffer-smaller-p', `icicle-buffer-sort-*...*-last', +;; `icicle-call-then-update-Completions', +;; `icicle-cancel-Help-redirection', `icicle-candidate-action-1', +;; `icicle-candidate-set-1', `icicle-candidate-set-retrieve-1', +;; `icicle-candidate-set-save-1', +;; `icicle-candidate-set-save-selected-1', +;; `icicle-candidate-short-help', +;; `icicle-case-insensitive-string-less-p', +;; `icicle-case-string-less-p', `icicle-cdr-lessp', +;; `icicle-char-properties-in-buffer', +;; `icicle-char-properties-in-buffers', +;; `icicle-choose-anything-candidate', +;; `icicle-choose-candidate-of-type', +;; `icicle-choose-completion-string', `icicle-clear-history-1', +;; `icicle-clear-history-entry', `icicle-clear-lighter', +;; `icicle-clear-minibuffer', `icicle-color-blue-lessp', +;; `icicle-color-completion-setup', `icicle-color-green-lessp', +;; `icicle-color-help', `icicle-color-hue-lessp', +;; `icicle-color-red-lessp', `icicle-color-saturation-lessp', +;; `icicle-color-value-lessp', `icicle-column-wise-cand-nb', +;; `icicle-comint-dynamic-complete-as-filename', +;; `icicle-comint-dynamic-simple-complete', +;; `icicle-comint-hook-fn', +;; `icicle-comint-replace-orig-completion-fns', +;; `icicle-comint-search-get-final-choice', +;; `icicle-comint-search-get-minibuffer-input', +;; `icicle-comint-search-send-input', +;; `icicle-command-abbrev-action', `icicle-command-abbrev-command', +;; `icicle-command-abbrev-matching-commands', +;; `icicle-command-abbrev-record', `icicle-command-abbrev-regexp', +;; `icicle-command-abbrev-save', +;; `icicle-command-abbrev-used-more-p', +;; `icicle-command-names-alphabetic-p', +;; `icicle-compilation-hook-fn', +;; `icicle-compilation-search-in-context-fn', +;; `icicle-complete-again-update', `icicle-complete-keys-1', +;; `icicle-complete-keys-action', `icicle-completing-p', +;; `icicle-completing-read', , `icicle-completing-read-multiple', +;; `icicle-completing-read-history', +;; `icicle-completion-all-completions', +;; `icicle-completion-setup-function', +;; `icicle-completion-try-completion', +;; `icicle-compute-shell-command-candidates', +;; `icicle-convert-dots', +;; `icicle-current-completion-in-Completions', +;; `icicle-current-sort-functions', `icicle-current-sort-order', +;; `icicle-customize-faces', `icicle-custom-type', +;; `icicle-dabbrev--abbrev-at-point', +;; `icicle-default-buffer-names', +;; `icicle-define-crm-completion-map', , +;; `icicle-define-cycling-keys', `icicle-define-icicle-maps', +;; `icicle-define-minibuffer-maps', +;; `icicle-delete-backward-char-dots', +;; `icicle-delete-candidate-object-1', `icicle-delete-char-dots', +;; `icicle-delete-count', `icicle-delete-current-candidate-object', +;; `icicle-delete-file-or-directory', +;; `icicle-delete-whitespace-from-string', +;; `icicle-describe-opt-action', +;; `icicle-describe-opt-of-type-complete', `icicle-ding', +;; `icicle-dired-read-shell-command', +;; `icicle-dired-smart-shell-command', +;; `icicle-dir-prefix-wo-wildcards', `icicle-dirs-first-p', +;; `icicle-dirs-last-p', `icicle-displayable-cand-from-saved-set', +;; `icicle-display-cand-from-full-cand', +;; `icicle-display-completion-list', `icicle-display-Completions', +;; `icicle-display-candidates-in-Completions', `icicle-doc-action', +;; `icicle-edmacro-parse-keys', +;; `icicle-ensure-overriding-map-is-bound', +;; `icicle-execute-extended-command-1', +;; `icicle-expanded-common-match', +;; `icicle-expanded-common-match-1', `icicle-expand-file-name', +;; `icicle-explicit-saved-completion-candidates', `icicle-explore', +;; `icicle-extra-candidates-first-p', +;; `icicle-face-valid-attribute-values', `icicle-file-directory-p', +;; `icicle-file-name-apropos-candidates', +;; `icicle-file-name-directory', +;; `icicle-file-name-directory-w-default', +;; `icicle-file-name-input-p', `icicle-file-name-nondirectory', +;; `icicle-file-name-prefix-candidates', `icicle-file-readable-p', +;; `icicle-file-remote-p', `icicle-file-writable-p', +;; `icicle-filesets-files-under', `icicle-files-within', +;; `icicle-files-within-1', `icicle-filter-alist', +;; `icicle-filter-wo-input', `icicle-find-first-tag-action', +;; `icicle-find-first-tag-other-window-action', +;; `icicle-find-tag-action', `icicle-find-tag-define-candidates', +;; `icicle-find-tag-define-candidates-1', +;; `icicle-find-tag-final-act', `icicle-find-tag-help', +;; `icicle-find-tag-quit-or-error', +;; `icicle-first-matching-candidate', `icicle-first-N', +;; `icicle-fit-completions-window', `icicle-fix-default-directory', +;; `icicle-flat-list', `icicle-fn-doc-minus-sig', +;; `icicle-font-w-orig-size', `icicle-frame-name-history', +;; `icicle-frames-on', `icicle-function-name-history', +;; `icicle-funvardoc-action', `icicle-fuzzy-candidates', +;; `icicle-get-alist-candidate', +;; `icicle-get-anything-actions-for-type', +;; `icicle-get-anything-cached-candidates', +;; `icicle-get-anything-candidates', +;; `icicle-get-anything-candidates-of-type', +;; `icicle-get-anything-default-actions-for-type', +;; `icicle-get-anything-input-delay', +;; `icicle-get-anything-req-pat-chars', +;; `icicle-get-anything-types', +;; `icicle-get-candidates-from-saved-set', `icicle-goto-marker-1', +;; `icicle-goto-marker-1-action', `icicle-group-regexp', +;; `icicle-dired-guess-shell-command', +;; `icicle-help-on-candidate-symbol', `icicle-help-line-buffer', +;; `icicle-help-line-file', `icicle-help-string-completion', +;; `icicle-highlight-candidate-in-Completions', +;; `icicle-highlight-complete-input', +;; `icicle-highlight-initial-whitespace', +;; `icicle-highlight-input-noncompletion', +;; `icicle-highlight-input-noncompletion-rest', +;; `icicle-highlight-lighter', `icicle-historical-alphabetic-p', +;; `icicle-imenu-command-p', `icicle-imenu-in-buffer-p', +;; `icicle-imenu-non-interactive-function-p', +;; `icicle-increment-cand-nb+signal-end', +;; `icicle-increment-color-hue', `icicle-increment-color-value', +;; `icicle-Info-book-order-p', +;; `icicle-Info-build-node-completions', +;; `icicle-Info-build-node-completions-1', +;; `icicle-Info-goto-node-1', `icicle-Info-goto-node-action', +;; `icicle-Info-index-action', `icicle-Info-read-node-name', +;; `icicle-input-from-minibuffer', +;; `icicle-input-is-a-completion-p', `icicle-insert-candidates', +;; `icicle-insert-cand-in-minibuffer', +;; `icicle-insert-Completions-help-string', `icicle-insert-dot', +;; `icicle-insert-for-yank', `icicle-insert-input', +;; `icicle-insert-thesaurus-entry-cand-fn', `icicle-insert-thing', +;; `icicle-isearch-complete-past-string', `icicle-join-nth-parts', +;; `icicle-key-description', `icicle-keys+cmds-w-prefix', +;; `icicle-kill-a-buffer', +;; `icicle-kill-a-buffer-and-update-completions', +;; `icicle-kmacro-action', `icicle-last-modified-first-p', +;; `icicle-levenshtein-match', `icicle-levenshtein-one-match', +;; `icicle-levenshtein-one-regexp', +;; `icicle-levenshtein-strict-match', +;; `icicle-lisp-vanilla-completing-read', +;; `icicle-local-keys-first-p', `icicle-locate-file-1', +;; `icicle-locate-file-action', +;; `icicle-locate-file-other-window-action', +;; `icicle-looking-at-anychar-regexp-p', +;; `icicle-looking-back-at-anychar-regexp-p', +;; `icicle-major-mode-name-less-p', `icicle-make-color-candidate', +;; `icicle-make-face-candidate', `icicle-make-frame-alist', +;; `icicle-make-plain-predicate', `icicle-make-window-alist', +;; `icicle-markers', `icicle-markers-to-readable', +;; `icicle-marker+text', +;; `icicle-maybe-multi-completion-completing-p', +;; `icicle-maybe-sort-and-strip-candidates', +;; `icicle-maybe-sort-maybe-truncate', `icicle-mctize-all', +;; `icicle-mctized-display-candidate', +;; `icicle-mctized-full-candidate', +;; `icicle-minibuffer-default-add-completions', +;; `icicle-minibuf-input', `icicle-minibuf-input-sans-dir', +;; `icicle-minibuffer-default-add-dired-shell-commands', +;; `icicle-minibuffer-prompt-end', `icicle-minibuffer-setup', +;; `icicle-mode-line-name-less-p', `icicle-most-recent-first-p', +;; `icicle-mouse-candidate-action-1', +;; `icicle-msg-maybe-in-minibuffer', `icicle-ms-windows-NET-USE', +;; `icicle-multi-sort', `icicle-nb-Completions-cols', +;; `icicle-nb-of-candidate-in-Completions', +;; `icicle-nb-of-cand-in-Completions-horiz', +;; `icicle-next-candidate', +;; `icicle-next-single-char-property-change', +;; `icicle-non-whitespace-string-p', +;; `icicle-not-basic-prefix-completion-p', +;; `icicle-part-1-cdr-lessp', `icicle-part-1-lessp', +;; `icicle-part-2-lessp', `icicle-part-3-lessp', +;; `icicle-part-4-lessp', `icicle-part-N-lessp', +;; `icicle-place-cursor', `icicle-place-overlay', +;; `icicle-prefix-any-candidates-p', +;; `icicle-prefix-any-file-name-candidates-p', +;; `icicle-prefix-candidates', `icicle-prefix-complete-1', +;; `icicle-prefix-keys-first-p', `icicle-proxy-candidate-first-p', +;; `icicle-put-at-head', `icicle-put-whole-cand-prop', +;; `icicle-quote-file-name-part-of-cmd', +;; `icicle-raise-Completions-frame', `icicle-readable-to-markers', +;; `icicle-read-char-exclusive', `icicle-read-face-name', +;; `icicle-read-file-name', `icicle-read-from-minibuffer', +;; `icicle-read-from-minibuf-nil-default', +;; `icicle-read-single-key-description', `icicle-read-number', +;; `icicle-read-shell-command', +;; `icicle-read-shell-command-completing', `icicle-read-string', +;; `icicle-read-string-completing', +;; `icicle-read-var-value-satisfying', `icicle-rebind-global', +;; `icicle-recentf-make-menu-items', `icicle-recompute-candidates', +;; `icicle-redefine-standard-commands', +;; `icicle-redefine-standard-options', +;; `icicle-redefine-std-completion-fns', +;; `icicle-region-or-buffer-limits', `icicle-remap', +;; `icicle-remove-buffer-candidate-action', +;; `icicle-remove-buffer-config-action', +;; `icicle-remove-cand-from-lists', +;; `icicle-remove-candidate-display-others', +;; `icicle-remove-color-duplicates', `icicle-remove-dots', +;; `icicle-remove-duplicates', `icicle-remove-dups-if-extras', +;; `icicle-remove-from-recentf-candidate-action', +;; `icicle-remove-if', `icicle-remove-if-not', +;; `icicle-remove-property', `icicle-remove-saved-set-action', +;; `icicle-replace-input-w-parent-dir', `icicle-require-match-p', +;; `icicle-restore-completion-keys', +;; `icicle-restore-other-keymap-keys', +;; `icicle-restore-region-face', +;; `icicle-restore-standard-commands', +;; `icicle-restore-standard-options', +;; `icicle-restore-std-completion-fns', +;; `icicle-retrieve-candidates-from-set', `icicle-reversible-sort', +;; `icicle-row-wise-cand-nb', +;; `icicle-run-icicle-post-command-hook', +;; `icicle-run-icicle-pre-command-hook', `icicle-saved-fileset-p', +;; `icicle-save-or-restore-input', `icicle-save-raw-input', +;; `icicle-scatter', `icicle-scatter-match', +;; `icicle-scroll-or-update-Completions', `icicle-search-action', +;; `icicle-search-action-1', `icicle-search-bookmark-action', +;; `icicle-search-char-property-scan', +;; `icicle-search-choose-buffers', `icicle-search-cleanup', +;; `icicle-search-define-candidates', +;; `icicle-search-define-candidates-1', `icicle-search-final-act', +;; `icicle-search-help', +;; `icicle-search-highlight-all-input-matches', +;; `icicle-search-highlight-and-maybe-replace', +;; `icicle-search-highlight-input-matches-here', +;; `icicle-search-in-context-default-fn', +;; `icicle-search-property-args', `icicle-search-quit-or-error', +;; `icicle-search-read-context-regexp', `icicle-search-read-word', +;; `icicle-search-regexp-scan', +;; `icicle-search-replace-all-search-hits', +;; `icicle-search-replace-cand-in-alist', +;; `icicle-search-replace-cand-in-mct', +;; `icicle-search-replace-fixed-case-p', +;; `icicle-search-replace-match', `icicle-search-where-arg', +;; `icicle-select-minibuffer-contents' `icicle-set-calling-cmd', +;; `icicle-set-difference', `icicle-set-intersection', +;; `icicle-set-union', `icicle-shell-command', +;; `icicle-shell-command-on-region', +;; `icicle-shell-dynamic-complete-as-command', +;; `icicle-shell-dynamic-complete-as-environment-variable', +;; `icicle-show-help-in-mode-line', `icicle-show-in-mode-line', +;; `icicle-signum', `icicle-S-iso-lefttab-to-S-TAB', +;; `icicle-special-candidates-first-p', +;; `icicle-start-of-candidates-in-Completions', +;; `icicle-strip-ignored-files-and-sort', +;; `icicle-subst-envvar-in-file-name', +;; `icicle-substring-no-properties', `icicle-substrings-of-length', +;; `icicle-successive-action', `icicle-take', +;; `icicle-this-command-keys-prefix', +;; `icicle-toggle-icicle-mode-twice', `icicle-top-level-prep', +;; `icicle-transform-candidates', +;; `icicle-transform-multi-completion', +;; `icicle-transform-sole-candidate', +;; `icicle-transpose-chars-dots', `icicle-try-switch-buffer', +;; `icicle-unbind-isearch-keys', +;; `icicle-unbind-key-completion-keys-for-map-var', +;; `icicle-unbind-key-completion-keys-in-keymaps-from', +;; `icicle-undo-std-completion-faces', +;; `icicle-unhighlight-lighter', `icicle-unmap', +;; `icicle-unpropertize', `icicle-unsorted-apropos-candidates', +;; `icicle-unsorted-file-name-apropos-candidates', +;; `icicle-unsorted-file-name-prefix-candidates', +;; `icicle-unsorted-prefix-candidates', `icicle-upcase', +;; `icicle-upcase-if-ignore-case', `icicle-update-and-next', +;; `icicle-update-ignored-extensions-regexp', +;; `icicle-value-satisfies-type-p', `icicle-var-inherits-type-p', +;; `icicle-var-is-of-type-p', `icicle-var-matches-type-p', +;; `icicle-var-val-satisfies-type-p', +;; `old-choose-completion-string', `old-completing-read', +;; `old-completing-read-multiple', `old-completion-setup-function', +;; `old-dired-smart-shell-command', `old-display-completion-list', +;; `old-face-valid-attribute-values', +;; `old-minibuffer-default-add-completions', `old-read-face-name', +;; `old-read-file-name', `old-read-from-minibuffer', +;; `old-read-number', `old-read-string', `old-shell-command', +;; `old-shell-command-on-region'. +;; +;; Internal variables and constants defined in Icicles: +;; +;; `icicle-abs-file-candidates', `icicle-acting-on-next/prev', +;; `icicle-advice-info-list', `icicle-all-candidates-action-p', +;; `icicle-all-candidates-list-action-fn', +;; `icicle-all-candidates-list-alt-action-fn', +;; `icicle-anychar-regexp', `icicle-apply-nomsg', +;; `icicle-apropos-complete-match-fn', `icicle-bookmark-history', +;; `icicle-bookmark-menu-map', `icicle-bookmark-types', +;; `icicle-buffer-config-history', `icicle-candidate-action-fn', +;; `icicle-candidate-alt-action-fn', `icicle-candidate-entry-fn', +;; `icicle-candidate-help-fn', `icicle-candidate-nb', +;; `icicle-candidate-properties-alist', `icicle-candidates-alist', +;; `icicle-char-property-value-history', +;; `icicle-cmd-calling-for-completion', `icicle-cmd-reading-input', +;; `icicle-color-history', `icicle-color-theme-history', +;; `icicle-command-abbrev-history', `icicle-commands-for-abbrev', +;; `icicle-common-match-string', +;; `icicle-comp-base-is-default-dir-p', +;; `icicle-complete-input-overlay', `icicle-complete-keys-alist', +;; `icicle-completing-p', +;; `icicle-completing-read+insert-candidates', +;; `icicle-completion-candidates', +;; `icicle-completion-prompt-overlay', +;; `icicle-completion-set-history', +;; `icicle-completions-format-internal', +;; `icicle-confirm-exit-commands', +;; `icicle-crm-local-completion-map', +;; `icicle-crm-local-must-match-map', +;; `icicle-current-completion-candidate-overlay', +;; `icicle-current-completion-mode', `icicle-current-input', +;; `icicle-current-raw-input', `icicle-current-TAB-method', +;; `icicle-custom-menu-map', `icicle-cycling-p', +;; `icicle-default-directory', +;; `icicle-default-thing-insertion-flipped-p', +;; `icicle-delete-candidate-object', `icicle-describe-menu-map', +;; `icicle-dictionary-history', `icicle-dir-candidate-can-exit-p', +;; `icicle-doc-last-initial-cand-set', +;; `icicle-dot-string-internal', `icicle-edit-menu-map', +;; `icicle-edit-update-p', `icicle-explore-final-choice', +;; `icicle-explore-final-choice-full', `icicle-extra-candidates', +;; `icicle-extra-candidates-dir-insert-p', +;; `icicle-face-name-history', `icicle-fancy-candidates-p', +;; `icicle-fancy-cands-internal-p', `icicle-file-menu-map', +;; `icicle-filtered-default-value', `icicle-font-name-history', +;; `icicle-frame-alist', `icicle-frame-name-history', +;; `icicle-frames-menu-map', `icicle-function-name-history', +;; `icicle-fundoc-last-initial-cand-set', +;; `icicle-general-help-string', +;; `icicle-get-alist-candidate-function', +;; `icicle-hist-cands-no-highlight', `icicle-ignored-extensions', +;; `icicle-ignored-extensions-regexp', +;; `icicle-incremental-completion-p', `icicle-info-menu-map', +;; `icicle-Info-only-rest-of-book-p', `icicle-inhibit-sort-p', +;; `icicle-inhibit-try-switch-buffer', `icicle-initial-value', +;; `icicle-input-completion-fail-overlay', `icicle-input-fail-pos', +;; `icicle-insert-string-at-pt-end', +;; `icicle-insert-string-at-pt-start', +;; `icicle-interactive-history', `icicle-kill-history', +;; `icicle-kmacro-alist', `icicle-kmacro-history', +;; `icicle-last-apropos-complete-match-fn', +;; `icicle-last-completion-candidate', +;; `icicle-last-completion-command', `icicle-last-input', +;; `icicle-last-sort-comparer', `icicle-last-top-level-command', +;; `icicle-last-transform-function', `icicle-lighter-truncation', +;; `icicle-list-use-nth-parts', `icicle-menu-map', +;; `icicle-minibuffer-message-ok-p', `icicle-minor-mode-map-entry', +;; `icicle-mode-map', `icicle-ms-windows-drive-hash', +;; `icicle-must-match-regexp', `icicle-must-not-match-regexp', +;; `icicle-must-pass-predicate', +;; `icicle-nb-candidates-before-truncation', +;; `icicle-nb-of-other-cycle-candidates', +;; `icicle-next-apropos-complete-cycles-p', +;; `icicle-next-prefix-complete-cycles-p', +;; `icicle-old-read-file-name-fn', `icicle-options-menu-map', +;; `icicle-plist-last-initial-cand-set', +;; `icicle-pre-minibuffer-buffer', `icicle-post-command-hook', +;; `icicle-pre-command-hook', `icicle-predicate-types-alist', +;; `icicle-previous-raw-file-name-inputs', +;; `icicle-previous-raw-non-file-name-inputs', +;; `icicle-progressive-completing-p', +;; `icicle-proxy-candidate-regexp', `icicle-proxy-candidates', +;; `icicle-read-expression-map', `icicle-remove-icicles-props-p', +;; `icicle-re-no-dot', `icicle-require-match-p', +;; `icicle-reverse-multi-sort-p', `icicle-reverse-sort-p', +;; `icicle-saved-candidate-overlays', +;; `icicle-saved-candidates-variables-obarray', +;; `icicle-saved-completion-candidate', +;; `icicle-saved-completion-candidates', +;; `icicle-saved-completion-candidates-internal', +;; `icicle-saved-ignored-extensions', +;; `icicle-saved-kmacro-ring-max', `icicle-saved-proxy-candidates', +;; `icicle-saved-regexp-search-ring-max', +;; `icicle-saved-region-background', +;; `icicle-saved-search-ring-max', +;; `icicle-scroll-Completions-backward-p', `icicle-search-command', +;; `icicle-search-context-level', `icicle-search-context-regexp', +;; `icicle-search-current-overlay', `icicle-search-final-choice', +;; `icicle-search-history', `icicle-search-in-context-fn', +;; `icicle-searching-p', `icicle-search-level-overlays', +;; `icicle-search-menu-map', `icicle-search-tags-menu-map', +;; `icicle-search-overlays', `icicle-search-refined-overlays', +;; `icicle-search-replacement', +;; `icicle-search-replacement-history', +;; `icicle-successive-grab-count', +;; `icicle-text-property-value-history', +;; `icicle-thing-at-pt-fns-pointer', +;; `icicle-transform-before-sort-p', +;; `icicle-universal-argument-map', +;; `icicle-vardoc-last-initial-cand-set', +;; `icicle-vardoc-last-initial-option-cand-set', +;; `icicle-variable-name-history', +;; `icicle-whole-candidate-as-text-prop-p', +;; `lacarte-menu-items-alist', `old-crm-local-completion-map', +;; `old-crm-local-must-match-map'. +;; +;; Emacs functions defined in Icicles for older Emacs versions: +;; +;; `select-frame-set-input-focus'. +;; +;; Widgets (customization types) defined in Icicles: +;; +;; `icicle-key-definition'. +;; +;; +;; ***** NOTE: These EMACS PRIMITIVES have been REDEFINED in Icicles: +;; +;; `completing-read' - (See below and doc string.) +;; `display-completion-list' - (See below and doc string.) +;; `exit-minibuffer' - Remove *Completion* window. +;; `minibuffer-complete-and-exit' - Remove *Completion* window. +;; `read-file-name' - (See below and doc string.) +;; `read-from-minibuffer' - (See below and doc string.) +;; `read-string' - (See below and doc string.) +;; +;; +;; ***** NOTE: The following functions defined in `dabbrev.el' have +;; been REDEFINED in Icicles: +;; +;; `dabbrev-completion' - Use Icicles completion when you repeat +;; (`C-M-/'). +;; +;; +;; ***** NOTE: The following functions defined in `lisp.el' have +;; been REDEFINED in Icicles: +;; +;; `lisp-complete-symbol' - Selects *Completions* window even if on +;; another frame. +;; +;; +;; ***** NOTE: The following functions defined in `mouse.el' have +;; been REDEFINED in Icicles: +;; +;; `mouse-choose-completion' - Return the number of the completion. +;; +;; +;; ***** NOTE: The following functions defined in `simple.el' have +;; been REDEFINED in Icicles: +;; +;; `choose-completion-string' - +;; Don't exit minibuffer after `lisp-complete-symbol' completion. +;; `completion-setup-function' - 1. Put faces on inserted string(s). +;; 2. Help on help. +;; `switch-to-completions' - Always selects *Completions* window. +;; +;; `next-history-element' (advised only) - +;; Depending on `icicle-default-value', select minibuffer +;; contents. +;; +;; `repeat-complex-command' - Use `completing-read' to read command. +;; +;; For descriptions of changes to this file, see `icicles-chg.el'. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; 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 + (when (< emacs-major-version 20) (require 'cl))) ;; when, unless + +;;;;;;;;;;;;; + + +;;; Load other Icicles files (except documentation) ------------------ + +(require 'icicles-opt) +(require 'icicles-var) +(require 'icicles-face) + +(require 'icicles-fn) ;; Requires opt, var +(require 'icicles-mac) ;; Requires var +(require 'icicles-mcmd) ;; Requires opt, var, fn, mac +(require 'icicles-cmd1) ;; Requires mac, opt, var, fn, mcmd +(require 'icicles-cmd2) ;; Requires mac, opt, var, fn, mcmd, cmd1 +(require 'icicles-mode) ;; Requires face, opt, cmd + +;;;;;;;;;;;;;;;;;;;;;;; + +(provide 'icicles) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; icicles.el ends here diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 154db87..799dfc1 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -4,6 +4,10 @@ (add-to-list 'load-path "~/.emacs.d") (add-to-list 'load-path "~/.emacs.d/auto-complete") +(add-to-list 'load-path "~/.emacs.d/icicles") + +(require 'icicles) +(icy-mode 1) ; Requires (require 'vimpulse) @@ -13,14 +17,21 @@ ;(require 'highlight-symbol) (require 'auto-complete-config) + + (add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/dict") (ac-config-default) (setq ac-dwim t) (setq ac-expand-on-auto-complete nil) (setq ac-use-fuzzy t) (setq viper-search-wrap-around t) +(setq viper-no-multiple-ESC t) +(setq viper-translate-all-ESC-keysequences nil) +(setq viper-vi-style-in-minibuffer nil) ;(define-key ac-completing-map "\t" 'ac-fuzzy-complete) ;(define-key ac-completing-map "\r" nil) +(define-key ac-completing-map (kbd "") 'ac-stop) + ; This is the other Vim-mode. Maybe should delete this.. ; @@ -52,6 +63,7 @@ (tabbar-mode) (add-to-list 'ex-token-alist '("ls" (list-buffers))) +(add-to-list 'ex-token-alist '("mx" (icicle-execute-extended-command))) (vimpulse-map "gn" 'tabbar-forward-tab) (vimpulse-map "gp" 'tabbar-backward-tab) (vimpulse-map "gw" 'vimpulse-search-forward-for-symbol-at-point)