Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

6833 lines (6257 sloc) 378.129 kB
;;; 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-2012, Drew Adams, all rights reserved.
;; Created: Mon Feb 27 09:25:04 2006
;; Version: 22.0
;; Last-Updated: Fri Jan 20 09:28:13 2012 (-0800)
;; By: dradams
;; Update #: 23254
;; 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', `backquote', `bytecomp',
;; `cl', `cus-edit', `cus-face', `cus-load', `cus-start', `doremi',
;; `easymenu', `el-swank-fuzzy', `ffap', `ffap-', `frame-cmds',
;; `frame-fns', `fuzzy', `fuzzy-match', `hexrgb', `icicles-face',
;; `icicles-fn', `icicles-mcmd', `icicles-opt', `icicles-var',
;; `image-dired', `kmacro', `levenshtein', `misc-fns', `mouse3',
;; `mwheel', `naked', `pp', `pp+', `regexp-opt', `ring', `ring+',
;; `second-sel', `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.
;;
;; 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-autofile',
;; `icicle-bookmark-autofile-narrow',
;; (+)`icicle-bookmark-autofile-other-window',
;; (+)`icicle-bookmark-autonamed',
;; `icicle-bookmark-autonamed-narrow',
;; (+)`icicle-bookmark-autonamed-other-window',
;; (+)`icicle-bookmark-autonamed-this-buffer',
;; `icicle-bookmark-autonamed-this-buffer-narrow',
;; (+)`icicle-bookmark-autonamed-this-buffer-other-window',
;; (+)`icicle-bookmark-bookmark-file',
;; `icicle-bookmark-bookmark-file-narrow',
;; (+)`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-narrow',
;; (+)`icicle-bookmark-dired-other-window',
;; (+)`icicle-bookmarked-buffer-list',
;; (+)`icicle-bookmarked-file-list', (+)`icicle-bookmark-file',
;; (+)`icicle-bookmark-file-all-tags',
;; (+)`icicle-bookmark-file-all-tags-other-window',
;; (+)`icicle-bookmark-file-all-tags-regexp',
;; (+)`icicle-bookmark-file-all-tags-regexp-other-window',
;; (+)`icicle-bookmark-file-other-window',
;; `icicle-bookmark-file-narrow',
;; (+)`icicle-bookmark-file-some-tags',
;; (+)`icicle-bookmark-file-some-tags-other-window',
;; (+)`icicle-bookmark-file-some-tags-regexp',
;; (+)`icicle-bookmark-file-some-tags-regexp-other-window',
;; (+)`icicle-bookmark-file-this-dir',
;; (+)`icicle-bookmark-file-this-dir-other-window',
;; (+)`icicle-bookmark-file-this-dir-all-tags',
;; (+)`icicle-bookmark-file-this-dir-all-tags-other-window',
;; (+)`icicle-bookmark-file-this-dir-all-tags-regexp',
;; (+)`icicle-bookmark-file-this-dir-all-tags-regexp-other-window',
;; `icicle-bookmark-file-this-dir-narrow',
;; (+)`icicle-bookmark-file-this-dir-some-tags',
;; (+)`icicle-bookmark-file-this-dir-some-tags-other-window',
;; (+)`icicle-bookmark-file-this-dir-some-tags-regexp',
;; (+)`icicle-bookmark-file-this-dir-some-tags-regexp-other-window',
;; (+)`icicle-bookmark-gnus', `icicle-bookmark-gnus-narrow',
;; (+)`icicle-bookmark-gnus-other-window',
;; (+)`icicle-bookmark-image', `icicle-bookmark-image-narrow',
;; (+)`icicle-bookmark-image-other-window',
;; (+)`icicle-bookmark-info', `icicle-bookmark-info-narrow',
;; (+)`icicle-bookmark-info-other-window', `icicle-bookmark-jump',
;; `icicle-bookmark-jump-other-window', (+)`icicle-bookmark-list',
;; (+)`icicle-bookmark-local-file',
;; `icicle-bookmark-local-file-narrow',
;; (+)`icicle-bookmark-local-file-other-window',
;; (+)`icicle-bookmark-man', `icicle-bookmark-man-narrow',
;; (+)`icicle-bookmark-man-other-window',
;; (+)`icicle-bookmark-non-file',
;; `icicle-bookmark-non-file-narrow',
;; (+)`icicle-bookmark-non-file-other-window',
;; (+)`icicle-bookmark-other-window', (+)`icicle-bookmark-region',
;; `icicle-bookmark-region-narrow',
;; (+)`icicle-bookmark-region-other-window',
;; (+)`icicle-bookmark-remote-file',
;; `icicle-bookmark-remote-file-narrow',
;; (+)`icicle-bookmark-remote-file-other-window',
;; `icicle-bookmark-save-marked-files',
;; `icicle-bookmark-save-marked-files-as-project',
;; `icicle-bookmark-save-marked-files-more',
;; `icicle-bookmark-save-marked-files-persistently',
;; `icicle-bookmark-save-marked-files-to-variable',
;; `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-temporary',
;; `icicle-bookmark-temporary-narrow',
;; (+)`icicle-bookmark-temporary-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-narrow',
;; (+)`icicle-bookmark-w3m-other-window', (+)`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-keyword-list', (+)`icicle-kill-buffer',
;; (+)`icicle-kmacro', `icicle-lisp-complete-symbol',
;; (+)`icicle-locate', (+)`icicle-locate-file',
;; (+)`icicle-locate-file-no-symlinks',
;; (+)`icicle-locate-file-no-symlinks-other-window',
;; (+)`icicle-locate-file-other-window',
;; (+)`icicle-locate-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-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-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-sexp-list',
;; `icicle-shell-dynamic-complete-command',
;; `icicle-shell-dynamic-complete-environment-variable',
;; `icicle-shell-dynamic-complete-filename',
;; (+)`icicle-string-list', (+)`icicle-toggle-option',
;; (+)`icicle-yank-maybe-completing',
;; (+)`icicle-yank-pop-commands', `icicle-zap-to-char',
;; (+)`toggle'.
;;
;; Non-interactive functions defined here:
;;
;; `custom-variable-p', `icicle-binary-option-p',
;; `icicle-bookmark-bind-narrow-commands',
;; `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-lisp-completion-at-point',
;; (+)`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-command-on-file',
;; `icicle-shell-dynamic-complete-as-command',
;; `icicle-shell-dynamic-complete-as-environment-variable'.
;;
;; Internal variables defined here:
;;
;; `icicle-locate-file-action-fn',
;; `icicle-locate-file-no-symlinks-p',
;; `icicle-locate-file-use-locate-p'.
;;
;;
;; ***** 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)
(require 'second-sel nil t) ;; (no error if not found):
;; secondary-selection-yank-commands, secondary-selection-yank-secondary-commands,
;; yank-pop-secondary
(eval-when-compile
(or (condition-case nil
(load-library "icicles-mac") ; Use load-library to ensure latest .elc.
(error nil))
(require 'icicles-mac))) ; Require, so can load separately if not on `load-path'.
;; icicle-assoc-delete-all, icicle-bind-file-candidate-keys, icicle-(buffer|file)-bindings,
;; icicle-condition-case-no-debug, icicle-define-bookmark(-other-window)-command, icicle-kbd,
;; icicle-define(-file)-command, icicle-define-add-to-alist-command, icicle-unbind-file-candidate-keys
(require 'icicles-mcmd)
;; icicle-yank
(require 'icicles-opt) ; (This is required anyway by `icicles-var.el'.)
;; 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-var) ; (This is required anyway by `icicles-fn.el'.)
;; icicle-abs-file-candidates, icicle-all-candidates-list-action-fn,
;; icicle-all-candidates-list-alt-action-fn, icicle-bookmark-history,
;; icicle-bookmark-list-names-only-p, icicle-bookmark-types, icicle-buffer-config-history,
;; icicle-bufflist, icicle-candidate-action-fn, icicle-candidate-alt-action-fn,
;; icicle-candidate-help-fn, icicle-candidate-nb, icicle-candidate-properties-alist,
;; icicle-candidates-alist, icicle-color-theme-history, icicle-command-abbrev-history,
;; icicle-commands-for-abbrev, icicle-comp-base-is-default-dir-p, icicle-completion-candidates,
;; icicle-completion-set-history, icicle-current-input, icicle-delete-candidate-object,
;; icicle-explore-final-choice, icicle-explore-final-choice-full, icicle-extra-candidates,
;; icicle-face-name-history, icicle-frame-alist, icicle-frame-name-history, icicle-full-cand-fn,
;; icicle-function-name-history, icicle-get-alist-candidate-function, icicle-hist-var,
;; icicle-incremental-completion-p, icicle-inhibit-sort-p, icicle-inhibit-try-switch-buffer,
;; icicle-kill-history, icicle-kmacro-alist, icicle-kmacro-history,icicle-list-use-nth-parts,
;; icicle-must-match-regexp, icicle-must-not-match-regexp, icicle-must-pass-after-match-predicate,
;; icicle-new-last-cmd, icicle-orig-buff, icicle-orig-must-pass-after-match-pred,
;; icicle-orig-pt-explore, icicle-orig-window, icicle-orig-win-explore, icicle-pref-arg,
;; icicle-previous-raw-file-name-inputs, icicle-previous-raw-non-file-name-inputs, icicle-prompt,
;; icicle-proxy-candidates, icicle-read-expression-map, icicle-remove-icicles-props-p,
;; icicle-re-no-dot, icicle-saved-completion-candidates, icicle-search-history,
;; icicle-transform-before-sort-p, icicle-use-candidates-only-once-alt-p,
;; icicle-whole-candidate-as-text-prop-p, icicle-variable-name-history
(require 'icicles-fn) ; (This is required anyway by `icicles-mcmd.el'.)
;; icicle-delete-dups, 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-bookmark-name-length-max) ; In `bookmark+-1.el'
(defvar bmkp-non-file-filename) ; In `bookmark+-1.el'
(defvar bmkp-prompt-for-tags-flag) ; In `bookmark+-1.el'
(defvar bmkp-sorted-alist) ; In `bookmark+-1.el'
(defvar bookmark-current-point) ; In `bookmark.el' for Emacs <
(defvar color-theme) ; In `color-theme.el'
(defvar color-themes) ; 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 locate-make-command-line) ; In `locate.el'
(defvar shell-completion-execonly) ; In `shell.el'
(defvar snarf-tag-function) ; In `etags.el'
(defvar translation-table-for-input) ; Built-in, Emacs 21+.
(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)
;; Avoid `let'-binding because `change-major-mode-hook' is local.
;; IOW, avoid this runtime message:
;; "Making change-major-mode-hook buffer-local while locally let-bound!"
;; Suggestion from Stefan M.: Can just set these hooks instead of binding,
;; because they are not permanent-local. They'll be emptied and
;; repopulated as needed by the call to emacs-lisp-mode.
(set (make-local-variable 'emacs-lisp-mode-hook) nil)
(set (make-local-variable 'change-major-mode-hook) nil)
(emacs-lisp-mode)
(set (make-local-variable 'font-lock-verbose) nil)
(font-lock-fontify-buffer)))))
(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.
(icicle-condition-case-no-debug 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")))
;; It's not unique. Let user choose a completion.
((or comint-completion-autolist (string-equal filenondir completion))
(icicle-condition-case-no-debug 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 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))
(icicle-condition-case-no-debug 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)
(bol (save-excursion (comint-bol nil) (point)))
(eol (line-end-position))
(line-buffer (buffer-substring bol eol))
(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) bol)))
(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) nil 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 <net-addr>\" (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
(setq bol (line-beginning-position))
(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.
(icicle-condition-case-no-debug 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' (< Emacs 23.2),
;; defined in `lisp.el', saving it for restoration when you toggle `icicle-mode'.
;;
;; Select `*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)
(icicle-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))))))
;; $$$$$ Could bind `icicle-must-pass-after-match-predicate' to a predicate on interned
;; candidate and pass nil as PRED to `completing-read'. Don't bother for now.
(setq new (save-excursion (completing-read "Complete Lisp symbol: "
obarray predicate t new)))))
(delete-region beg end)
(insert new)))
;; REPLACE ORIGINAL `lisp-completion-at-point' (>= Emacs 23.2),
;; defined in `lisp.el', saving it for restoration when you toggle `icicle-mode'.
;;
;; Select `*Completions*' window even if on another frame.
;;
(when (fboundp 'completion-at-point) ; Emacs 23.2+.
(unless (fboundp 'old-lisp-completion-at-point)
(defalias 'old-lisp-completion-at-point (symbol-function 'lisp-completion-at-point))
;; Return a function that does all of the completion.
(defun icicle-lisp-completion-at-point () #'icicle-lisp-complete-symbol)))
;;;###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-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)
(icicle-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))
;; 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 &optional other-window)
"Customize face FACE. If OTHER-WINDOW is non-nil, use another window.
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 completion candidate and act
`C-up' - Move to previous 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-end' - Move to next prefix-completion candidate and act
`C-home' - Move to previous prefix-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)
(icicle-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: ")))))
(if other-window
(if (> emacs-major-version 23)
(old-customize-face face t)
(old-customize-face-other-window face))
(old-customize-face 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)
(icicle-must-pass-after-match-predicate
#'(lambda (s)
(setq s (intern s))
(or (get s 'custom-group)
(custom-facep s)
(and (boundp s) (or (get s 'saved-value)
(custom-variable-p s)
(if (null pref-arg)
(user-variable-p s)
(get s 'variable-documentation))))))))
(list (completing-read "Customize (regexp): " obarray nil 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
(let ((icicle-must-pass-after-match-predicate #'(lambda (s) (custom-facep (intern s)))))
(list (completing-read "Customize faces (regexp): " obarray nil 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
(let ((icicle-must-pass-after-match-predicate #'(lambda (s) (get (intern s) 'custom-group))))
(list (completing-read "Customize groups (regexp): " obarray nil 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)
(icicle-must-pass-after-match-predicate
#'(lambda (s)
(setq s (intern s))
(and (boundp s) (or (get s 'saved-value)
(custom-variable-p s)
(if (null pref-arg)
(user-variable-p s)
(get s 'variable-documentation)))))))
(list (completing-read "Customize options (regexp): " obarray nil 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 (let ((icicle-must-pass-after-match-predicate
#'(lambda (s)
(setq s (intern s))
(and (boundp s)
(or (not (fboundp 'indirect-variable)) (eq (indirect-variable s) s))
(or (get s 'saved-value) (custom-variable-p s))
(or (not typ) ; `typ' = nil means use all types.
(if pref-arg
(condition-case nil
(icicle-var-is-of-type-p s (list typ))
(error nil))
(equal (get s 'custom-type) typ)))))))
(completing-read "Customize options matching (regexp): "
obarray nil 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 `\\<minibuffer-local-map>\\[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', `home', `end') 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
(icicle-propertize entry 'face 'icicle-msg-emphasis)
(icicle-propertize set-name 'face 'icicle-msg-emphasis)
(icicle-propertize file-name 'face 'icicle-msg-emphasis))))))
;;;###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)
(icicle-remove-icicles-props-p nil) ; Need prop `icicle-whole-candidate' for now.
(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-completion (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'"
(icicle-propertize entry 'face 'icicle-msg-emphasis)
(icicle-propertize set-name 'face 'icicle-msg-emphasis)))
(message "`%s' not in fileset `%s'"
(icicle-propertize entry 'face 'icicle-msg-emphasis)
(icicle-propertize set-name 'face 'icicle-msg-emphasis)))))))
(when entry
(icicle-msg-maybe-in-minibuffer
"`%s' removed from %s `%s'%s"
(icicle-propertize (if (icicle-saved-fileset-p entry) (cadr entry) entry)
'face 'icicle-msg-emphasis)
(if (icicle-saved-fileset-p entry) "fileset" "saved set")
(icicle-propertize set-name 'face 'icicle-msg-emphasis)
(if file-name
(format ", file `%s'" (icicle-propertize file-name'face 'icicle-msg-emphasis))
"")))))
;;;###autoload (autoload 'icicle-remove-saved-completion-set "icicles-cmd1.el")
(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'? "
(icicle-propertize cache 'face 'icicle-msg-emphasis)))
(when (condition-case err
(progn (delete-file cache) t)
(error (progn (message "%s" (error-message-string err)) nil)))
(message "%s `%s'" (icicle-propertize "DELETED" 'face 'icicle-msg-emphasis) 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" (icicle-propertize set-name 'face 'icicle-msg-emphasis)))
;;;###autoload
(defun icicle-bookmark-save-marked-files (&optional arg) ; Bound to `C-M->' in *Bookmark List*.
"Save file names of marked bookmarks as a set of completion candidates.
Saves file names in variable `icicle-saved-completion-candidates', by
default. Marked bookmarks that have no associated file are ignored.
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 `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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 bookmark-list display buffer
\(`*Bookmark List*')."
(interactive "P")
(unless (fboundp 'bmkp-bmenu-get-marked-files)
(error "Command `icicle-bookmark-save-marked-files' requires library `Bookmark+'"))
(bmkp-bmenu-barf-if-not-in-menu-list)
(icicle-candidate-set-save-1 (bmkp-bmenu-get-marked-files) arg))
;;;###autoload
(defun icicle-bookmark-save-marked-files-more (&optional arg) ; Bound to `C->' in *Bookmark List*.
"Add the file names of the marked bookmarks to the saved candidates set.
Marked bookmarks that have no associated file are ignored.
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 remain 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
\\<minibuffer-local-completion-map>
`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 bookmark-list display buffer
\(`*Bookmark List*')."
(interactive "P")
(unless (fboundp 'bmkp-bmenu-get-marked-files)
(error "Command `icicle-bookmark-save-marked-files-more' requires library `Bookmark+'"))
(bmkp-bmenu-barf-if-not-in-menu-list)
(icicle-candidate-set-save-1 (bmkp-bmenu-get-marked-files) arg t))
;;;###autoload
(defun icicle-bookmark-save-marked-files-to-variable () ; Bound to `C-M-}' in *Bookmark List*.
"Save the file names of the marked bookmarks to a variable.
Marked bookmarks that have no associated file are ignored.
You can retrieve the saved set of file-name candidates during
completion using `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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 bookmark-list display buffer
\(`*Bookmark List*')."
(interactive)
(unless (fboundp 'bmkp-bmenu-get-marked-files)
(error "Command `icicle-bookmark-save-marked-files-to-variable' requires library `Bookmark+'"))
(bmkp-bmenu-barf-if-not-in-menu-list)
(icicle-candidate-set-save-1 (bmkp-bmenu-get-marked-files) 99))
;;;###autoload
(defalias 'icicle-bookmark-save-marked-files-as-project ; Bound to `C-}' in *Bookmark List*.
'icicle-bookmark-save-marked-files-persistently)
;;;###autoload
(defun icicle-bookmark-save-marked-files-persistently (filesetp)
"Save the file names of the marked bookmarks as a persistent set.
Marked bookmarks that have no associated file are ignored.
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 `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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 bookmark-list display buffer
\(`*Bookmark List*')."
(interactive "P")
(unless (fboundp 'bmkp-bmenu-get-marked-files)
(error "This command requires library `Bookmark+'"))
(bmkp-bmenu-barf-if-not-in-menu-list)
(icicle-candidate-set-save-1 (bmkp-bmenu-get-marked-files) (if filesetp 0 '(1))))
;;;###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 `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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
\\<minibuffer-local-completion-map>
`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 "`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 to a variable as a candidate set.
You can retrieve the saved set of file-name candidates during
completion using `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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))
;;;###autoload
(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 `\\<minibuffer-local-completion-map>\\[icicle-candidate-set-retrieve]'.
You can use the saved set of candidates for operations such as
\\<minibuffer-local-completion-map>
`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)
;;;###autoload
(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 \\<minibuffer-local-completion-map>\
`\\[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 "%s" (substitute-command-keys "No saved completion candidates. \
Use \\<minibuffer-local-completion-map>`\\[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)))))
;;;###autoload
(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 \\<minibuffer-local-completion-map>\
`\\[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+'."
(interactive "P")
(when (require 'bookmark+ nil t)
(define-key minibuffer-local-completion-map (icicle-kbd "C-x m") ; `C-x m'
'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 (icicle-kbd "C-x m") 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+'."
(interactive "P")
(when (require 'bookmark+ nil t)
(define-key minibuffer-local-completion-map (icicle-kbd "C-x m") ; `C-x m'
'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 (icicle-kbd "C-x m") nil)))
;;;###autoload
(defun icicle-grep-saved-file-candidates (command-args)
"Run `grep' on the set of completion candidates saved with \\<minibuffer-local-completion-map>\
`\\[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 "%s" (substitute-command-keys "No saved completion candidates. \
Use \\<minibuffer-local-completion-map>`\\[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 <pattern> <files> : "
(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)
(icicle-orig-pt-explore (point-marker))
(icicle-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
(icicle-condition-case-no-debug 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-completion result)) ; Remove any Icicles text properties.
(when cleanup-fn (funcall cleanup-fn)))
result))
;;;###autoload (autoload 'icicle-execute-extended-command "icicles-cmd1.el")
(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 nil t nil 'extended-command-history nil nil
(;; Bindings
(last-command last-command) ; Save and restore the last command.
(use-file-dialog nil) ; `mouse-2' in `*Completions*' won't use dialog box.
(alt-fn nil)
(icicle-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate #'(lambda (c) (commandp (intern c))))
(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-new-last-cmd) ; Set in `icicle-execute-extended-command-1'.
nil nil ; First code, undo code
(setq this-command icicle-new-last-cmd)) ; Last code: this will update `last-command'
;; Free vars here: `icicle-orig-buff' and `icicle-orig-window' are bound by `icicle-define-command'.
;; `icicle-new-last-cmd' and `icicle-orig-must-pass-after-match-pred' are 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 icicle-orig-buff) (set-buffer icicle-orig-buff))
(when (window-live-p icicle-orig-window) (select-window icicle-orig-window))
(when (string= "" cmd-name) (error "No command name"))
(let* ((cmd (intern cmd-name))
(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)
;; 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)
(setq arg (icicle-transform-multi-completion 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))))))
;; 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))
(wait-time (or (and (numberp suggest-key-bindings) suggest-key-bindings) 2)))
(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 invoke command `%s' using `%s'" (symbol-name cmd)
(icicle-propertize (key-description bindings) 'face 'icicle-msg-emphasis)))
(when (and (sit-for wait-time) curr-msg) (message "%s" 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)
;; Restore this before we invoke command, since it might use completion.
(icicle-must-pass-after-match-predicate icicle-orig-must-pass-after-match-pred)
;; 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 icicle-new-last-cmd cmd)))
;; Inspired by Emacs partial completion and by library `exec-abbrev-cmd.el' (Tassilo Horn
;; <tassilo@member.fsf.org>). The idea of command abbreviation is combined here with normal
;; command invocation, in an Icicles multi-command.
;;;###autoload (autoload 'icicle-command-abbrev "icicles-cmd1.el")
(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 `\\<minibuffer-local-completion-map>\\[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 nil nil nil 'icicle-command-abbrev-history nil nil ; `completing-read' args
((prompt "Command or abbrev: ")
(last-command last-command) ; Save and restore the last command.
(icicle-sort-comparer 'icicle-command-abbrev-used-more-p) ; Bindings.
(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)))))
(use-file-dialog nil) ; `mouse-2' in `*Completions*' won't use dialog box.
(alt-fn nil)
(icicle-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate #'(lambda (c) (commandp (intern c))))
(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"))))
(when icicle-proxy-candidates (put-text-property 0 1 'icicle-fancy-candidates t prompt)) ; First code
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)
;; Restore this before we invoke command, since it might use completion.
;; Free var `orig-must-pass...' is bound in `icicle-command-abbrev'.
(icicle-must-pass-after-match-predicate icicle-orig-must-pass-after-match-pred)
;; 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 (autoload 'icicle-command-abbrev-command "icicles-cmd1.el")
(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.
icicle-new-last-cmd) ; Set in `icicle-execute-extended-command-1'.
nil nil ; First code, undo code
(setq this-command icicle-new-last-cmd) ; Last 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 (autoload 'icicle-execute-named-keyboard-macro "icicles-cmd1.el")
(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 nil t nil 'icicle-kmacro-history nil nil
((last-command last-command) ; Save and restore the last command.
(alt-fn nil)
(icicle-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate
#'(lambda (fn) (setq fn (intern fn)) (and (commandp fn) (arrayp (symbol-function fn)))))
(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")))))
;;;###autoload (autoload 'icicle-kmacro "icicles-cmd1.el")
(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
((icicle-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: `icicle-orig-buff' & `icicle-orig-window' are bound by `icicle-define-command'.
;; `icicle-pref-arg' is bound in `icicle-kmacro'.
(defun icicle-kmacro-action (cand)
"Action function for `icicle-kmacro'."
(when (get-buffer icicle-orig-buff) (set-buffer icicle-orig-buff))
(when (window-live-p icicle-orig-window) (select-window icicle-orig-window))
(let* ((count (if current-prefix-arg (prefix-numeric-value current-prefix-arg) icicle-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 "(%s times)" (icicle-propertize count 'face 'icicle-msg-emphasis))))))
;;;###autoload (autoload 'icicle-set-option-to-t "icicles-cmd1.el")
(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 nil 'must-confirm nil ; `completing-read' args
(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-must-pass-after-match-predicate
(cond ((and current-prefix-arg (wholenump (prefix-numeric-value current-prefix-arg)))
#'(lambda (x)
(setq x (intern x)) (and (boundp x) (user-variable-p x) (eq nil (symbol-value x)))))
(current-prefix-arg
#'(lambda (x)
(setq x (intern x)) (and (boundp x) (eq nil (symbol-value x)))))
(t
#'(lambda (x)
(setq x (intern x))
(and (boundp x) (icicle-binary-option-p x) (eq nil (symbol-value x)))))))
(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 (autoload 'icicle-clear-history "icicles-cmd1.el")
(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
((icicle-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: `icicle-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 icicle-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 (autoload 'icicle-clear-current-history "icicles-cmd1.el")
(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
((icicle-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 icicle-pref-arg ; First code
(icicle-ding) ; Use `error' just to exit and make sure message is seen.
(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 (autoload 'icicle-reset-option-to-nil "icicles-cmd1.el")
(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 nil t nil ; `completing-read' args
(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-must-pass-after-match-predicate
(if current-prefix-arg
#'(lambda (x) (setq x (intern x)) (and (boundp x) (symbol-value x)))
#'(lambda (x) (setq x (intern x)) (and (boundp x) (user-variable-p x) (symbol-value x)))))
(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 (autoload 'icicle-toggle-option "icicles-cmd1.el")
(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 (icicle-propertize (eval sym) 'face 'icicle-msg-emphasis))))
"Toggle value of option: " obarray nil 'must-confirm nil ; `completing-read' args
(if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil
((enable-recursive-minibuffers t) ; Bindings
(alt-fn nil)
(icicle-must-pass-after-match-predicate
(cond ((and current-prefix-arg (wholenump (prefix-numeric-value current-prefix-arg)))
#'(lambda (c) (user-variable-p (intern c))))
(current-prefix-arg #'(lambda (c) (boundp (intern c))))
(t #'(lambda (c) (icicle-binary-option-p (intern c))))))
(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 (autoload 'icicle-increment-option "icicles-cmd1.el")
(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))
;; Restore this before we read number, since that might use completion.
(icicle-must-pass-after-match-predicate icicle-orig-must-pass-after-match-pred))
(icicle-doremi-increment-variable+ sym (icicle-read-number "Increment (amount): ") t)
(message "`%s' is now `%s'" opt (icicle-propertize (eval sym) 'face 'icicle-msg-emphasis))))
"Increment value of option: " obarray nil 'must-confirm nil ; `completing-read' args
(if (boundp 'variable-name-history) 'variable-name-history 'icicle-variable-name-history) nil nil
((enable-recursive-minibuffers t) ; Bindings
(alt-fn nil)
(icicle-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate
#'(lambda (s) (memq (get (intern s) 'custom-type) '(number integer float))))
(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 (autoload 'icicle-increment-variable "icicles-cmd1.el")
(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.
With no prefix arg, all variables are candidates, even those that are
not numeric.
This command needs library `doremi.el'." ; Doc string
(lambda (var) ; Action function
(let ((sym (intern var))
;; Restore this before we read number, since that might use completion.
(icicle-must-pass-after-match-predicate icicle-orig-must-pass-after-match-pred))
(icicle-doremi-increment-variable+ sym (icicle-read-number "Increment (amount): ") prefix-arg)
(message "`%s' is now `%s'" var (icicle-propertize (eval sym) 'face 'icicle-msg-emphasis))))
"Increment value of variable: " obarray nil 'must-confirm nil ; `completing-read' args
(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-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate
(if prefix-arg
#'(lambda (s) (memq (get (intern s) 'custom-type) '(number integer float)))
#'(lambda (s) (boundp (intern s)))))
(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 arrow key `up' or `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)
(icicle-orig-must-pass-after-match-pred icicle-must-pass-after-match-predicate)
(icicle-must-pass-after-match-predicate (if current-prefix-arg
#'(lambda (s) (user-variable-p (intern s)))
#'(lambda (s) (boundp (intern s))))))
(list (intern (completing-read "Increment variable: " obarray nil t nil nil
(and symb (symbol-name symb)) t))
;; Restore this before we read number, since that might use completion.
(let ((icicle-must-pass-after-match-predicate icicle-orig-must-pass-after-match-pred))
(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
(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) (line-end-position)))
(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+', this is the same as vanilla Emacs
`bookmark-set'.
If you use library `Bookmark+', then you can narrow the current
completion candidates to bookmarks of a given type. The keys for this
are the same as for `icicle-bookmark' and for the bookmark-jumping
keys at the top level."
(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-omit
(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))
(icicle-bookmark-bind-narrow-commands map)))
(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)
(line-end-position)))))
(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 (if (boundp 'bookmark-history)
'bookmark-history
'icicle-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))) ; Don't bother to refresh tags. (?)
(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-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 (autoload 'icicle-bookmark "icicles-cmd1.el")
(icicle-define-command icicle-bookmark ; Bound to `C-x j j', `C-x p b', `C-x r b'.
"Jump to a bookmark.
With a plain prefix argument (`C-u'), reverse the effect of option
`icicle-bookmark-refresh-cache-flag'. See the doc for that option.
In particular, if the option value is nil and you try to jump to a
bookmark that is not up to date or does not exist, then try using a
prefix arg to refresh the cache.
During completion, you can use `S-delete' on a bookmark to delete it.
If you also use library `Bookmark+', 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:
`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. The keys for this are the same as the bookmark-jumping
keys at the top level.
`C-x j a' - autofile bookmarks
`C-x j b' - non-file (buffer) bookmarks
`C-x j B' - bookmark-list bookmarks
`C-x j d' - Dired bookmarks
`C-x j f' - file bookmarks
`C-x j C-f' - bookmarks to files in the current directory
`C-x j g' - Gnus bookmarks
`C-x j i' - Info bookmarks
`C-x j M-i' - image bookmarks
`C-x j K' - desktop bookmarks
`C-x j l' - local-file bookmarks
`C-x j m' - `man' pages
`C-x j n' - remote-file bookmarks
`C-x j r' - bookmarks with regions
`C-x j u' - URL bookmarks
`C-x j w' - W3M (URL) bookmarks
`C-x j x' - temporary bookmarks
`C-x j y' - bookmark-file bookmarks
`C-x j .' - bookmarks for the current buffer
`C-x j = b' - bookmarks for specific buffers
`C-x j = f' - bookmarks for specific files
`C-x j # #' - autonamed bookmarks
`C-x j # .' - autonamed bookmarks for the current buffer
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)
;; Ignore errors, e.g. from bad or stale bookmark records.
(icicle-condition-case-no-debug nil
(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)
;; Ignore errors, e.g. from bad or stale bookmark records.
(icicle-condition-case-no-debug nil
(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-omit 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))
(icicle-bookmark-bind-narrow-commands map))))
(icicle-bookmark-cleanup-on-quit) ; Undo code
(icicle-bookmark-cleanup)) ; Last code
;;;###autoload (autoload 'icicle-bookmark-other-window "icicles-cmd1.el")
(icicle-define-command icicle-bookmark-other-window
; Bound to `C-x 4 j j', `C-x p j', `C-x p o', `C-x p q'.
"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)
;; Ignore errors, e.g. from bad or stale bookmark records.
(icicle-condition-case-no-debug nil
(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)
;; Ignore errors, e.g. from bad or stale bookmark records.
(icicle-condition-case-no-debug nil
(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-omit 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))
(icicle-bookmark-bind-narrow-commands map))))
(icicle-bookmark-cleanup-on-quit) ; Undo code
(icicle-bookmark-cleanup)) ; Last code
(defun icicle-bookmark-bind-narrow-commands (map)
"Bind keys to narrow bookmark candidates by type."
(when (featurep 'bookmark+)
;; Lax completion is for multi-completion case.
(dolist (map '(minibuffer-local-must-match-map minibuffer-local-completion-map))
(define-key (symbol-value map) (icicle-kbd "C-x j # #") ; `C-x j # #'
'icicle-bookmark-autonamed-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j # .") ; `C-x j # .'
'icicle-bookmark-autonamed-this-buffer-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j a") ; `C-x j a'
'icicle-bookmark-autofile-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j b") ; `C-x j b'
'icicle-bookmark-non-file-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j B") ; `C-x j B'
'icicle-bookmark-bookmark-list-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j d") ; `C-x j d'
'icicle-bookmark-dired-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j f") ; `C-x j f'
'icicle-bookmark-file-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j C-f") ; `C-x j C-f'
'icicle-bookmark-file-this-dir-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j g") ; `C-x j g'
'icicle-bookmark-gnus-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j i") ; `C-x j i'
'icicle-bookmark-info-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j M-i") ; `C-x j M-i'
'icicle-bookmark-image-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j K") ; `C-x j K'
'icicle-bookmark-desktop-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j l") ; `C-x j l'
'icicle-bookmark-local-file-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j m") ; `C-x j m'
'icicle-bookmark-man-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j n") ; `C-x j n'
'icicle-bookmark-remote-file-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j r") ; `C-x j r'
'icicle-bookmark-region-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j u") ; `C-x j u'
'icicle-bookmark-url-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j w") ; `C-x j w'
'icicle-bookmark-w3m-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j x") ; `C-x j x'
'icicle-bookmark-temporary-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j y") ; `C-x j y'
'icicle-bookmark-bookmark-file-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j .") ; `C-x j .'
'icicle-bookmark-this-buffer-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j = b") ; `C-x j = b'
'icicle-bookmark-specific-buffers-narrow)
(define-key (symbol-value map) (icicle-kbd "C-x j = f") ; `C-x j = f'
'icicle-bookmark-specific-files-narrow))))
(defun icicle-bookmark-delete-action (cand)