Update icicles
[emacs.git] / .emacs.d / elisp / icicle / icicles-mode.el
1 ;;; icicles-mode.el --- Icicle Mode definition for Icicles
2 ;;
3 ;; Filename: icicles-mode.el
4 ;; Description: Icicle Mode definition for Icicles
5 ;; Author: Drew Adams
6 ;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
7 ;; Copyright (C) 1996-2014, Drew Adams, all rights reserved.
8 ;; Created: Mon Feb 27 10:21:10 2006
9 ;; Last-Updated: Sat Mar 8 09:41:16 2014 (-0800)
10 ;; By: dradams
11 ;; Update #: 9870
12 ;; URL: http://www.emacswiki.org/icicles-mode.el
13 ;; Doc URL: http://www.emacswiki.org/Icicles
14 ;; Keywords: internal, extensions, help, abbrev, local, minibuffer,
15 ;; keys, apropos, completion, matching, regexp, command
16 ;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x
17 ;;
18 ;; Features that might be required by this library:
19 ;;
20 ;; `advice', `advice-preload', `apropos', `apropos+',
21 ;; `apropos-fn+var', `autofit-frame', `avoid', `bookmark',
22 ;; `bookmark+', `bookmark+-1', `bookmark+-bmu', `bookmark+-key',
23 ;; `bookmark+-lit', `cl', `cmds-menu', `cus-edit', `cus-face',
24 ;; `cus-load', `cus-start', `cus-theme', `dired', `dired+',
25 ;; `dired-aux', `dired-x', `doremi', `easymenu', `el-swank-fuzzy',
26 ;; `ffap', `ffap-', `fit-frame', `frame-cmds', `frame-fns',
27 ;; `fuzzy', `fuzzy-match', `help+20', `hexrgb', `icicles-cmd1',
28 ;; `icicles-cmd2', `icicles-fn', `icicles-mcmd', `icicles-opt',
29 ;; `icicles-var', `image-dired', `info', `info+', `kmacro',
30 ;; `levenshtein', `menu-bar', `menu-bar+', `misc-cmds', `misc-fns',
31 ;; `mouse3', `mwheel', `naked', `pp', `pp+', `regexp-opt', `ring',
32 ;; `second-sel', `strings', `subr-21', `thingatpt', `thingatpt+',
33 ;; `unaccent', `w32-browser', `w32browser-dlgopen', `wid-edit',
34 ;; `wid-edit+', `widget'.
35 ;;
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37 ;;
38 ;;; Commentary:
39 ;;
40 ;; This is a helper library for library `icicles.el'. It defines the
41 ;; command `icicle-mode'. For Icicles documentation, see
42 ;; `icicles-doc1.el' and `icicles-doc2.el'.
43 ;;
44 ;; Commands defined here:
45 ;;
46 ;; `icicle-handle-switch-frame', `icicle-mode', `icy-mode',
47 ;; `icicle-ORIG-bbdb-complete-mail',
48 ;; `icicle-ORIG-bbdb-complete-name',
49 ;; `icicle-ORIG-comint-dynamic-complete',
50 ;; `icicle-ORIG-comint-dynamic-complete-filename',
51 ;; `icicle-ORIG-comint-replace-by-expanded-filename',
52 ;; `icicle-ORIG-dired-read-shell-command',
53 ;; `icicle-ORIG-ess-complete-object-name',
54 ;; `icicle-ORIG-gud-gdb-complete-command',
55 ;; `icicle-ORIG-read-file-name', `icicle-ORIG-read-shell-command',
56 ;; `icicle-skip-this-command'.
57 ;;
58 ;; Non-interactive functions defined here:
59 ;;
60 ;; `icicle-activate-mark', `icicle-add-menu-item-to-cmd-history',
61 ;; `icicle-bind-completion-keys',
62 ;; `icicle-bind-custom-minibuffer-keys',
63 ;; `icicle-bind-isearch-keys',
64 ;; `icicle-bind-key-completion-keys-for-map-var',
65 ;; `icicle-bind-key-completion-keys-in-keymaps-from',
66 ;; `icicle-bind-other-keymap-keys',
67 ;; `icicle-cancel-Help-redirection', `icicle-define-cycling-keys',
68 ;; `icicle-define-icicle-maps', `icicle-define-minibuffer-maps',
69 ;; `icicle-minibuffer-setup', `icicle-rebind-global',
70 ;; `icicle-redefine-standard-functions',
71 ;; `icicle-redefine-standard-options',
72 ;; `icicle-redefine-std-completion-fns',
73 ;; `icicle-restore-completion-keys',
74 ;; `icicle-restore-custom-minibuffer-keys',
75 ;; `icicle-restore-other-keymap-keys',
76 ;; `icicle-restore-region-face',
77 ;; `icicle-restore-standard-functions',
78 ;; `icicle-restore-standard-options',
79 ;; `icicle-restore-std-completion-fns',
80 ;; `icicle-run-icicle-post-command-hook',
81 ;; `icicle-run-icicle-pre-command-hook',
82 ;; `icicle-select-minibuffer-contents', `icicle-set-calling-cmd',
83 ;; `icicle-show-current-help-in-mode-line',
84 ;; `icicle-S-iso-lefttab-to-S-TAB', `icicle-top-level-prep',
85 ;; `icicle-unbind-isearch-keys',
86 ;; `icicle-unbind-key-completion-keys-for-map-var',
87 ;; `icicle-unbind-key-completion-keys-in-keymaps-from',
88 ;; `icicle-undo-std-completion-faces', `icicle-unmap',
89 ;; `icicle-update-ignored-extensions-regexp'.
90 ;;
91 ;; User options defined here (in Custom group `Icicles'):
92 ;;
93 ;; `icicle-mode', `icicle-mode-hook'.
94 ;;
95 ;; Internal variables defined here:
96 ;;
97 ;; `icicle-bookmark-menu-map', `icicle-custom-menu-map',
98 ;; `icicle-describe-menu-map', `icicle-dired-multiple-menu-map',
99 ;; `icicle-dired-recursive-marked-menu-map',
100 ;; `icicle-edit-menu-map', `icicle-file-menu-map',
101 ;; `icicle-frames-menu-map', `icicle-info-menu-map',
102 ;; `icicle-mode-map', `icicle-options-menu-map',
103 ;; `icicle-search-menu-map', `icicle-search-tags-menu-map'.
104 ;;
105 ;; For descriptions of changes to this file, see `icicles-chg.el'.
106
107 ;;(@> "Index")
108 ;;
109 ;; If you have library `linkd.el' and Emacs 22 or later, load
110 ;; `linkd.el' and turn on `linkd-mode' now. It lets you easily
111 ;; navigate around the sections of this doc. Linkd mode will
112 ;; highlight this Index, as well as the cross-references and section
113 ;; headings throughout this file. You can get `linkd.el' here:
114 ;; http://dto.freeshell.org/notebook/Linkd.html.
115 ;;
116 ;; (@> "User Options (alphabetical)")
117 ;; (@> "Internal variables (alphabetical)")
118 ;; (@> "Icicle mode command")
119 ;; (@> "Other Icicles functions that define Icicle mode")
120
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 ;;
123 ;; This program is free software; you can redistribute it and/or modify
124 ;; it under the terms of the GNU General Public License as published by
125 ;; the Free Software Foundation; either version 2, or (at your option)
126 ;; any later version.
127 ;;
128 ;; This program is distributed in the hope that it will be useful,
129 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
130 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131 ;; GNU General Public License for more details.
132 ;;
133 ;; You should have received a copy of the GNU General Public License
134 ;; along with this program; see the file COPYING. If not, write to the
135 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth
136 ;; ;; Floor, Boston, MA 02110-1301, USA.
137 ;;
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
139 ;;
140 ;;; Code:
141
142 (eval-when-compile (require 'cl)) ;; flet, pushnew, case
143 ;; plus, for Emacs < 21: push, dolist
144 (require 'advice)
145 ;; ad-activate, ad-copy-advice-info, ad-deactivate, ad-disable-advice, ad-enable-advice,
146 ;; ad-find-some-advice, ad-get-arg, ad-is-active, ad-set-advice-info, defadvice
147
148 (require 'icicles-opt) ; (This is required anyway by `icicles-var.el'.)
149 ;; icicle-buffer-configs, icicle-buffer-extras, icicle-change-region-background-flag,
150 ;; icicle-default-cycling-mode, icicle-incremental-completion, icicle-default-value, icicle-kbd,
151 ;; icicle-kmacro-ring-max, icicle-minibuffer-setup-hook, icicle-modal-cycle-down-keys,
152 ;; icicle-modal-cycle-up-keys, icicle-functions-to-redefine, icicle-regexp-search-ring-max,
153 ;; icicle-region-background, icicle-search-ring-max, icicle-show-Completions-initially-flag,
154 ;; icicle-top-level-key-bindings, icicle-touche-pas-aux-menus-flag, icicle-word-completion-keys
155 (require 'icicles-fn) ; (This is required anyway by `icicles-cmd1.el'.)
156 ;; icicle-completing-p, icicle-toggle-icicle-mode-twice, icicle-unhighlight-lighter
157 (require 'icicles-var) ; (This is required anyway by `icicles-fn.el'.)
158 ;; icicle-candidate-action-fn, icicle-candidate-nb, icicle-cmd-calling-for-completion,
159 ;; icicle-completing-p, icicle-completion-candidates, icicle-current-completion-mode,
160 ;; icicle-ignored-extensions, icicle-ignored-extensions-regexp, icicle-incremental-completion-p,
161 ;; icicle-initial-value, icicle-last-completion-candidate, icicle-last-completion-command,
162 ;; icicle-last-input, icicle-menu-map, icicle-pre-minibuffer-buffer, icicle-minor-mode-map-entry,
163 ;; icicle-saved-completion-candidates, icicle-saved-kmacro-ring-max,
164 ;; icicle-saved-regexp-search-ring-max, icicle-saved-region-background, icicle-saved-search-ring-max,
165 ;; icicle-search-current-overlay, icicle-search-overlays, icicle-search-refined-overlays
166 (require 'icicles-cmd1) ; (This is required anyway by `icicles-cmd2.el'.)
167 ;; icicle-add-buffer-candidate, icicle-add-buffer-config, icicle-customize-face-other-window,
168 ;; icicle-select-bookmarked-region
169 (require 'icicles-cmd2)
170 ;; icicle-imenu, icicle-imenu-command, icicle-imenu-command-full, icicle-imenu-face,
171 ;; icicle-imenu-face-full, icicle-imenu-full, icicle-imenu-key-explicit-map,
172 ;; icicle-imenu-key-explicit-map-full, icicle-imenu-key-implicit-map,
173 ;; icicle-imenu-key-implicit-map-full, icicle-imenu-macro, icicle-imenu-macro-full,
174 ;; icicle-imenu-non-interactive-function, icicle-imenu-non-interactive-function-full,
175 ;; icicle-imenu-user-option, icicle-imenu-user-option-full, icicle-imenu-variable,
176 ;; icicle-imenu-variable-full, icicle-occur, icicle-occur-dired-marked,
177 ;; icicle-occur-dired-marked-recursive, icicle-search, icicle-search-all-tags-bookmark,
178 ;; icicle-search-all-tags-regexp-bookmark, icicle-search-autofile-bookmark,
179 ;; icicle-search-autonamed-bookmark, icicle-search-bookmark, icicle-search-bookmark-list-bookmark,
180 ;; icicle-search-bookmark-list-marked, icicle-search-bookmarks-together, icicle-search-buffer,
181 ;; icicle-search-buff-menu-marked, icicle-search-char-property, icicle-search-dired-bookmark,
182 ;; icicle-search-dired-marked, icicle-search-dired-marked-recursive, icicle-search-file,
183 ;; icicle-search-file-bookmark, icicle-search-gnus-bookmark, icicle-search-highlight-cleanup,
184 ;; icicle-search-ibuffer-marked, icicle-search-info-bookmark, icicle-search-keywords,
185 ;; icicle-search-local-file-bookmark, icicle-search-man-bookmark, icicle-search-non-file-bookmark,
186 ;; icicle-search-overlay-property, icicle-search-pages, icicle-search-paragraphs,
187 ;; icicle-search-region-bookmark, icicle-search-remote-file-bookmark, icicle-search-sentences,
188 ;; icicle-search-some-tags-bookmark, icicle-search-some-tags-regexp-bookmark,
189 ;; icicle-search-specific-buffers-bookmark, icicle-search-specific-files-bookmark,
190 ;; icicle-search-temporary-bookmark, icicle-search-text-property, icicle-search-thing,
191 ;; icicle-search-this-buffer-bookmark, icicle-search-url-bookmark, icicle-search-w3m-bookmark,
192 ;; icicle-search-w-isearch-string, icicle-search-word, icicle-search-xml-element,
193 ;; icicle-search-xml-element-text-node
194
195 ;; Use `condition-case' because if `mb-depth.el' can't be found, `mb-depth+.el' is not provided.
196 (when (>= emacs-major-version 22) (condition-case nil (require 'mb-depth+ nil t) (error nil)))
197 ;; (no error if not found): minibuffer-depth-indicate-mode
198
199 (require 'dired+ nil t) ;; (no error if not found):
200 ;; diredp-menu-bar-operate-menu, diredp-menu-bar-recursive-marked-menu,
201 ;; diredp-menu-bar-subdir-menu
202 (require 'dired) ;; dired-mode-map
203 (require 'menu-bar+ nil t) ;; (no error if not found):
204 ;; menu-bar-apropos-menu, menu-bar-describe-menu, menu-bar-edit-menu, menu-bar-file-menu,
205 ;; menu-bar-frames-menu, menu-bar-options-menu, menu-bar-search-tags-menu
206
207 ;; `icicle-apropos-complete' is used here. It is defined in `icicles-mcmd.el'.
208 ;; `icicle-file-name-input-p' is used here. It is defined in `icicles-fn.el'.
209
210 ;;; Defvars to quiet byte-compiler:
211 (when (< emacs-major-version 22)
212 (defvar kmacro-ring-max)
213 (defvar minibuffer-local-filename-completion-map)
214 (defvar minibuffer-local-must-match-filename-map)
215 (defvar minibuffer-local-filename-must-match-map)
216 (defvar mouse-wheel-down-event)
217 (defvar mouse-wheel-up-event)
218 (defvar read-file-name-function))
219
220 (defvar Buffer-menu-mode-map) ; In `buff-menu.el'.
221 (defvar comint-mode-map) ; In `comint.el'.
222 (defvar crm-local-completion-map) ; In `crm.el'.
223 (defvar crm-local-must-match-map) ; In `crm.el'.
224 (defvar dired-mode-map) ; In `dired.el'.
225 (defvar gud-minibuffer-local-map) ; In `gud.el'.
226 (defvar ibuffer-mode-map) ; In `ibuffer.el'.
227 (defvar ibuffer-mode-operate-map) ; In `ibuffer.el'.
228 (defvar icicle-crm-local-completion-map) ; In `icicles-fn.el' after load `crm.el'.
229 (defvar icicle-crm-local-must-match-map) ; In `icicles-fn.el' after load `crm.el'.
230 (defvar icicle-kmacro-ring-max) ; In `icicles-opt.el' for Emacs 22+.
231 (defvar icicle-ORIG-crm-local-completion-map) ; In `icicles-fn.el' after load `crm.el'.
232 (defvar icicle-ORIG-crm-local-must-match-map) ; In `icicles-fn.el' after load `crm.el'.
233 (defvar icicle-saved-kmacro-ring-max) ; In `icicles-var.el' for Emacs 22+.
234 (defvar ielm-map) ; In `ielm.el'.
235 (defvar inferior-tcl-mode-map) ; In `tcl.el'.
236 (defvar Info-mode-map) ; In `info.el'.
237 (defvar isearch-mode-map) ; In `isearch.el'.
238 (defvar menu-bar-buffers-menu-command-entries) ; In `menu-bar.el' for Emacs 24+.
239 (defvar menu-bar-goto-menu) ; In `menu-bar.el'.
240 (defvar savehist-minibuffer-history-variables) ; In `savehist.el'
241 (defvar shell-mode-map) ; In `shell.el'.
242 (defvar sh-mode-map) ; In `sh-script.el'.
243
244 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245
246 ;;(@* "User Options (alphabetical)")
247
248 ;;; User Options (alphabetical) --------------------------------------
249
250 ;; Emacs 20 only
251 (unless (fboundp 'define-minor-mode)
252 (defcustom icicle-mode nil
253 "*Non-nil means use Icicles minibuffer input completion and cycling.
254 Setting this variable directly does not take effect;
255 use either \\[customize] or command `icy-mode' (aka `icicle-mode')."
256 :set (lambda (symbol value) (icicle-mode (if value 1 -1)))
257 :initialize 'custom-initialize-default
258 :type 'boolean :group 'Icicles-Miscellaneous :require 'icicles))
259
260 (defcustom icicle-mode-hook nil
261 "*Functions run after entering and exiting Icicle mode."
262 :type 'hook :group 'Icicles-Miscellaneous)
263
264 ;;(@* "Internal variables (alphabetical)")
265
266 ;;; Internal variables (alphabetical) --------------------------------
267
268 (defvar icicle-mode-map nil
269 "Keymap for Icicle mode. These are top-level key bindings.
270 See also `icicle-define-minibuffer-maps' for minibuffer bindings and
271 bindings in `*Completions*'.")
272
273 ;;(@* "Icicle mode command")
274
275 ;;; Icicle mode command ----------------------------------------------
276
277 ;; Main command.
278 (defalias 'icy-mode 'icicle-mode)
279 (when (fboundp 'define-minor-mode) ; Emacs 21+ ------------
280 (when (> emacs-major-version 22)
281 (defadvice call-interactively (after icicle-save-to-history disable activate)
282 "Save command to `icicle-interactive-history'."
283 ;; If command's input is not a parameterized (e.g. mouse) event, record it.
284 (let* ((fn (ad-get-arg 0))
285 (int (interactive-form fn)))
286 (when (and (symbolp fn) (consp int) (or (not (stringp (cadr int)))
287 (string= (cadr int) "")
288 (not (eq ?e (aref (cadr int) 0)))))
289 (pushnew (symbol-name fn) icicle-interactive-history))))
290 (when (boundp 'savehist-save-hook) ; Do not save `icicle-interactive-history' (too large).
291 (add-hook 'savehist-save-hook
292 (lambda () (setq savehist-minibuffer-history-variables
293 (delq 'icicle-interactive-history
294 savehist-minibuffer-history-variables)))))
295
296 ;; Just replace the original ESS definitions so that the new ones use Icicles completion.
297 (defadvice ess-internal-complete-object-name (around icicle-ess-internal-complete-object-name
298 disable activate)
299 "`ess-internal-complete-object-name', but in Icicle mode use Icicles completion."
300 (flet ((comint-dynamic-simple-complete (stub candidates)
301 (icicle-comint-dynamic-simple-complete stub candidates)))
302 ad-do-it))
303
304 (defadvice ess-complete-filename (around icicle-ess-complete-filename disable activate)
305 "`ess-complete-filename', but in Icicle mode use Icicles completion."
306 (flet ((comint-dynamic-complete-filename (&optional replace-to-eol-p)
307 (icicle-comint-dynamic-complete-filename replace-to-eol-p))
308 (comint-replace-by-expanded-filename () ; This one is not used for recent ESS versions.
309 (icicle-comint-replace-by-expanded-filename)))
310 ad-do-it))
311
312 (defadvice ess-R-complete-object-name (around icicle-ess-R-complete-object-name disable activate)
313 "`ess-R-complete-object-name', but in Icicle mode use Icicles completion."
314 (flet ((comint-dynamic-simple-complete (stub candidates)
315 (icicle-comint-dynamic-simple-complete stub candidates)))
316 ad-do-it))
317
318 (defadvice ess-completing-read (around icicle-ess-completing-read disable activate)
319 "Make `ess-completing-read' use Icicles completion in Icicle mode."
320 (let ((ess-use-ido (or icicle-ess-use-ido nil)))
321 ad-do-it)))
322
323 (when (> emacs-major-version 21)
324 (defadvice describe-face (before icicle-respect-WYSIWYG activate)
325 "`read-face-name' respects `icicle-WYSIWYG-Completions-flag'.
326 If non-nil, then it does not use `completing-read-multiple' (which
327 cannot take advantage of WYSIWYG)."
328 (interactive (list (read-face-name "Describe face" "= `default' face"
329 (not icicle-WYSIWYG-Completions-flag))))))
330
331 ;; Eval this so that even if the library is byte-compiled with Emacs 20,
332 ;; loading it into Emacs 21+ will define variable `icicle-mode'.
333 (eval '(define-minor-mode icicle-mode
334 "Icicle mode: Toggle minibuffer input completion and cycling.
335 Non-nil prefix ARG turns mode on if ARG > 0, else turns it off.
336 Icicle mode is a global minor mode. It binds keys in the minibuffer.
337
338 You can use `customize-group Icicles' or `C-u customize-mode
339 icicle-mode' to customize Icicles options and faces.
340
341 For more information, use `\\<minibuffer-local-completion-map>\\[icicle-minibuffer-help]' \
342 when the minibuffer is active.
343
344 Depending on your platform, if you use Icicles in a text terminal
345 \(that is, without a window system/manager), you might need to change
346 some of the key bindings if some of the default bindings are not
347 available to you.
348
349 Icicle mode defines many top-level commands. For a list, see the
350 Commentary headers of files `icicles-cmd1.el' and `icicles-cmd2.el'."
351 :global t :group 'Icicles :lighter " Icy" :init-value nil
352 (cond (icicle-mode
353 ;; (when (interactive-p)
354 ;; (unless (or window-system (and (fboundp 'daemonp) (daemonp)))
355 ;; (with-output-to-temp-buffer "*Attention*"
356 ;; (princ "You are using Icicles in a text terminal (no window ")
357 ;; (princ "system/manager).\n\nIcicles makes use of many keys that are ")
358 ;; (princ "unavailable when running\nEmacs in a text terminal. You will ")
359 ;; (princ "want to rebind those keys.\n")
360 ;; (princ "See the Icicles doc, section Key Bindings.\n"))
361 ;; (message "Icicles uses keys that might not be suitable for a text terminal")
362 ;; (sit-for 5)))
363 (icicle-define-icicle-maps)
364 (icicle-bind-other-keymap-keys)
365 (add-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup)
366 (add-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection)
367 (add-hook 'minibuffer-exit-hook 'icicle-restore-region-face)
368 (add-hook 'minibuffer-exit-hook 'icicle-unhighlight-lighter)
369 (add-hook 'icicle-post-command-hook 'icicle-activate-mark 'append)
370 (add-hook 'icicle-post-command-hook 'icicle-show-current-help-in-mode-line 'append)
371 (add-hook 'completion-setup-hook 'icicle-set-calling-cmd 'append)
372 (when icicle-customize-save-flag
373 (add-hook 'kill-emacs-hook 'icicle-command-abbrev-save))
374 (add-hook 'comint-mode-hook 'icicle-comint-hook-fn)
375 (add-hook 'compilation-mode-hook 'icicle-compilation-hook-fn)
376 (add-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn)
377 ;; $$$$$$ Do this only in `icicle-display-candidates-in-Completions' now.
378 ;; $$$$$$ (add-hook 'temp-buffer-show-hook 'icicle-fit-completions-window)
379 (icicle-undo-std-completion-faces)
380 (icicle-redefine-std-completion-fns)
381 (icicle-redefine-standard-functions)
382 (icicle-redefine-standard-options)
383 (icicle-redefine-standard-widgets)
384 (when (ad-find-some-advice 'describe-face 'before 'icicle-respect-WYSIWYG)
385 (ad-enable-advice 'describe-face 'before 'icicle-respect-WYSIWYG)
386 (unless (ad-is-active 'describe-face) (ad-activate 'describe-face)))
387 (when (ad-find-some-advice 'ess-internal-complete-object-name 'around
388 'icicle-ess-internal-complete-object-name)
389 (ad-enable-advice 'ess-internal-complete-object-name 'around
390 'icicle-ess-internal-complete-object-name)
391 (unless (ad-is-active 'ess-internal-complete-object-name)
392 (ad-activate 'ess-internal-complete-object-name)))
393 (when (ad-find-some-advice 'ess-complete-filename 'around
394 'icicle-ess-complete-filename)
395 (ad-enable-advice 'ess-complete-filename 'around 'icicle-ess-complete-filename)
396 (unless (ad-is-active 'ess-complete-filename) (ad-activate 'ess-complete-filename)))
397 (when (ad-find-some-advice 'ess-R-complete-object-name 'around
398 'icicle-ess-R-complete-object-name)
399 (ad-enable-advice 'ess-R-complete-object-name 'around
400 'icicle-ess-R-complete-object-name)
401 (unless (ad-is-active 'ess-R-complete-object-name)
402 (ad-activate 'ess-R-complete-object-name)))
403 (when (ad-find-some-advice 'ess-completing-read 'around 'icicle-ess-completing-read)
404 (ad-enable-advice 'ess-completing-read 'around 'icicle-ess-completing-read)
405 (unless (ad-is-active 'ess-completing-read) (ad-activate 'ess-completing-read)))
406 (when (fboundp 'minibuffer-depth-indicate-mode) ; In `mb-depth(+).el'
407 (minibuffer-depth-indicate-mode 99))
408 (if icicle-menu-items-to-history-flag
409 (add-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)
410 (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history))
411 (when (> emacs-major-version 22)
412 (when icicle-populate-interactive-history-flag
413 (ad-enable-advice 'call-interactively 'after 'icicle-save-to-history))
414 (ad-activate 'call-interactively))
415 (dolist (fn icicle-inhibit-advice-functions)
416 (when (and (fboundp fn) (ad-is-active fn))
417 (push (cons fn (ad-copy-advice-info fn)) icicle-advice-info-list)
418 (ad-deactivate fn))))
419 (t
420 (makunbound 'icicle-mode-map)
421 (icicle-restore-other-keymap-keys)
422 (remove-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup)
423 (remove-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection)
424 (remove-hook 'minibuffer-exit-hook 'icicle-restore-region-face)
425 (remove-hook 'icicle-post-command-hook 'icicle-activate-mark)
426 (remove-hook 'icicle-post-command-hook 'icicle-show-current-help-in-mode-line)
427 ;; The pre- and post-command hooks are local to the minibuffer,
428 ;; So they are added in `icicle-minibuffer-setup', not here.
429 ;; Nevertheless, they are removed here when Icicle mode is exited.
430 (remove-hook 'pre-command-hook 'icicle-top-level-prep)
431 (remove-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook t)
432 (remove-hook 'post-command-hook 'icicle-run-icicle-post-command-hook t)
433 (remove-hook 'completion-setup-hook 'icicle-set-calling-cmd)
434 (remove-hook 'kill-emacs-hook 'icicle-command-abbrev-save)
435 (remove-hook 'comint-mode-hook 'icicle-comint-hook-fn)
436 (remove-hook 'compilation-mode-hook 'icicle-compilation-hook-fn)
437 (remove-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn)
438 ;; $$$$$$ Do this only in `icicle-display-candidates-in-Completions' now.
439 ;; $$$$$$ (remove-hook 'temp-buffer-show-hook 'icicle-fit-completions-window)
440
441 ;; $$ Should restore standard completion faces here.
442 (icicle-restore-std-completion-fns)
443 (icicle-restore-standard-functions)
444 (icicle-restore-standard-options)
445 (icicle-restore-standard-widgets)
446 (when (ad-find-some-advice 'describe-face 'before 'icicle-respect-WYSIWYG)
447 (ad-disable-advice 'describe-face 'before 'icicle-respect-WYSIWYG))
448 (when (ad-find-some-advice 'ess-internal-complete-object-name 'around
449 'icicle-ess-internal-complete-object-name)
450 (ad-disable-advice 'ess-internal-complete-object-name 'around
451 'icicle-ess-internal-complete-object-name))
452 (when (ad-find-some-advice 'ess-complete-filename 'around
453 'icicle-ess-complete-filename)
454 (ad-disable-advice 'ess-complete-filename 'around 'icicle-ess-complete-filename))
455 (when (ad-find-some-advice 'ess-R-complete-object-name 'around
456 'icicle-ess-R-complete-object-name)
457 (ad-disable-advice 'ess-R-complete-object-name 'around
458 'icicle-ess-R-complete-object-name))
459 (when (ad-find-some-advice 'ess-completing-read 'around 'icicle-ess-completing-read)
460 (ad-disable-advice 'ess-completing-read 'around 'icicle-ess-completing-read))
461 (when (fboundp 'minibuffer-depth-indicate-mode)
462 (minibuffer-depth-indicate-mode -99))
463 (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)
464 (when (> emacs-major-version 22)
465 (ad-disable-advice 'call-interactively 'after 'icicle-save-to-history)
466 (ad-activate 'call-interactively))
467 (dolist (fn icicle-inhibit-advice-functions)
468 (let ((info (memq fn icicle-advice-info-list)))
469 (when (and (fboundp fn) info)
470 (ad-set-advice-info fn info)
471 (when (ad-is-active fn) (ad-activate fn)))))))
472 (unless (eq icicle-guess-commands-in-path 'load)
473 (setq icicle-shell-command-candidates-cache ())) ; Reset - toggle Icy to update.
474 (message "Turning %s Icicle mode..."
475 (icicle-propertize (if icicle-mode "ON" "OFF") 'face 'icicle-msg-emphasis))
476 (icicle-define-minibuffer-maps icicle-mode)
477 (run-hooks 'icicle-mode-hook)
478 (message "Turning %s Icicle mode...done"
479 (icicle-propertize (if icicle-mode "ON" "OFF") 'face 'icicle-msg-emphasis))))
480
481 ;; Do this so users can do `C-u customize-mode icicle-mode'. See Emacs bugs #11299 and #11301.
482 (put 'icicle-mode 'custom-mode-group 'Icicles))
483
484 (unless (fboundp 'define-minor-mode) ; Emacs 20 ------------
485 (defun icicle-mode (&optional arg)
486 "Icicle mode: Toggle minibuffer input completion and cycling.
487 Non-nil prefix ARG turns mode on if ARG > 0, else turns it off.
488 Icicle mode is a global minor mode. It binds keys in the minibuffer.
489
490 For more information, use `\\<minibuffer-local-completion-map>\\[icicle-minibuffer-help]' \
491 when the minibuffer is active.
492
493 Depending on your platform, if you use Icicles in a text terminal
494 \(that is, without a window system/manager), you might need to change
495 some of the key bindings if some of the default bindings are not
496 available to you.
497
498 Icicle mode defines many top-level commands. For a list, see the
499 Commentary headers of files `icicles-cmd1.el' and `icicles-cmd2.el'."
500 (interactive "P")
501 (setq icicle-mode (if arg (> (prefix-numeric-value arg) 0) (not icicle-mode)))
502 (icicle-define-minibuffer-maps icicle-mode)
503 (cond (icicle-mode
504 ;; (when (interactive-p)
505 ;; (unless (or window-system (and (fboundp 'daemonp) (daemonp)))
506 ;; (with-output-to-temp-buffer "*Attention*"
507 ;; (princ "You are using Icicles in a text terminal (no window ")
508 ;; (princ "system/manager).\n\nIcicles makes use of many keys that are ")
509 ;; (princ "unavailable when running\nEmacs in a text terminal. You will ")
510 ;; (princ "want to rebind those keys.\n")
511 ;; (princ "See the Icicles doc, section Key Bindings.\n"))
512 ;; (message "Icicles uses keys that might not be suitable for a text terminal")
513 ;; (sit-for 5)))
514 (icicle-define-icicle-maps)
515 (icicle-bind-other-keymap-keys)
516 ;; This is not really necessary after the first time - no great loss.
517 (add-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup)
518 (add-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection)
519 (add-hook 'minibuffer-exit-hook 'icicle-restore-region-face)
520 (add-hook 'minibuffer-exit-hook 'icicle-unhighlight-lighter)
521 (add-hook 'icicle-post-command-hook 'icicle-activate-mark 'append)
522 (add-hook 'icicle-post-command-hook 'icicle-show-current-help-in-mode-line 'append)
523 (add-hook 'completion-setup-hook 'icicle-set-calling-cmd 'append)
524 (when icicle-customize-save-flag
525 (add-hook 'kill-emacs-hook 'icicle-command-abbrev-save))
526 (add-hook 'comint-mode-hook 'icicle-comint-hook-fn)
527 (add-hook 'compilation-mode-hook 'icicle-compilation-hook-fn)
528 (add-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn)
529 ;; $$$$$$ Do this only in `icicle-display-candidates-in-Completions' now.
530 ;; $$$$$$ (add-hook 'temp-buffer-show-hook 'icicle-fit-completions-window)
531 (icicle-redefine-std-completion-fns)
532 (icicle-redefine-standard-functions)
533 (icicle-redefine-standard-options)
534 (icicle-redefine-standard-widgets)
535 (if icicle-menu-items-to-history-flag
536 (add-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)
537 (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history))
538 (dolist (fn icicle-inhibit-advice-functions)
539 (when (and (fboundp fn) (ad-is-active fn))
540 (push (cons fn (ad-copy-advice-info fn)) icicle-advice-info-list)
541 (ad-deactivate fn)))
542 (run-hooks 'icicle-mode-hook)
543 (message "Icicle mode is now ON"))
544 (t
545 (makunbound 'icicle-mode-map)
546 (icicle-restore-other-keymap-keys)
547 (remove-hook 'minibuffer-setup-hook 'icicle-minibuffer-setup)
548 (remove-hook 'minibuffer-exit-hook 'icicle-cancel-Help-redirection)
549 (remove-hook 'minibuffer-exit-hook 'icicle-restore-region-face)
550 (remove-hook 'icicle-post-command-hook 'icicle-activate-mark)
551 (remove-hook 'icicle-post-command-hook 'icicle-show-current-help-in-mode-line)
552 ;; The pre- and post-command hooks are local to the minibuffer,
553 ;; So they are added in `icicle-minibuffer-setup', not here.
554 ;; Nevertheless, they are removed here when Icicle mode is exited.
555 (remove-hook 'pre-command-hook 'icicle-top-level-prep)
556 (remove-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook t)
557 (remove-hook 'post-command-hook 'icicle-run-icicle-post-command-hook t)
558 (remove-hook 'completion-setup-hook 'icicle-set-calling-cmd)
559 (remove-hook 'kill-emacs-hook 'icicle-command-abbrev-save)
560 (remove-hook 'comint-mode-hook 'icicle-comint-hook-fn)
561 (remove-hook 'compilation-mode-hook 'icicle-compilation-hook-fn)
562 (remove-hook 'compilation-minor-mode-hook 'icicle-compilation-hook-fn)
563 ;; $$$$$$ Do this only in `icicle-display-candidates-in-Completions' now.
564 ;; $$$$$$ (remove-hook 'temp-buffer-show-hook 'icicle-fit-completions-window)
565 (icicle-restore-std-completion-fns)
566 (icicle-restore-standard-functions)
567 (icicle-restore-standard-options)
568 (icicle-restore-standard-widgets)
569 (unless (eq icicle-guess-commands-in-path 'load)
570 (setq icicle-shell-command-candidates-cache ())) ; Reset - toggle Icy to update.
571 (remove-hook 'pre-command-hook 'icicle-add-menu-item-to-cmd-history)
572 (dolist (fn icicle-inhibit-advice-functions)
573 (let ((info (memq fn icicle-advice-info-list)))
574 (when (and (fboundp fn) info)
575 (ad-set-advice-info fn info)
576 (when (ad-is-active fn) (ad-activate fn)))))
577 (run-hooks 'icicle-mode-hook)
578 (message "Icicle mode is now OFF")))
579
580 (add-to-list 'minor-mode-alist '(icicle-mode " Icy"))))
581
582
583 ;; `Minibuf' > `Save/Retrieve Candidates' Menu------------------------
584 (defvar icicle-minibuf-save-retrieve-menu-map (make-sparse-keymap)
585 "`Minibuf' > `Save/Retrieve Candidates' submenu.")
586
587 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-saved-completion-candidates]
588 '(menu-item "Swap Saved and Current Sets" icicle-candidate-set-swap
589 :enable icicle-saved-completion-candidates
590 :help "Swap the saved and current sets of completion candidates"))
591 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save-more-selected]
592 '(menu-item "Save More Selected (Region) Candidates"
593 icicle-candidate-set-save-more-selected
594 :help "Add the candidates in the region to the saved candidates"))
595 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save-selected]
596 '(menu-item "Save Selected (Region) Candidates"
597 icicle-candidate-set-save-selected
598 :help "Save the candidates in the region, for later recall"))
599 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save-more]
600 '(menu-item "Save More Candidates" icicle-candidate-set-save-more
601 :help "Add current completion candidates to saved candidates set"))
602 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save-persistently]
603 '(menu-item " to Cache File..." icicle-candidate-set-save-persistently
604 :help "Save current completion candidates to a cache file, for later recall"))
605 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save-to-variable]
606 '(menu-item " to Variable..." icicle-candidate-set-save-to-variable
607 :help "Save current completion candidates to a variable, for later recall"))
608 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-save]
609 '(menu-item "Save Candidates" icicle-candidate-set-save
610 :help "Save the set of current completion candidates, for later recall"))
611 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-retrieve-more]
612 '(menu-item "Retrieve More Saved Candidates" icicle-candidate-set-retrieve-more
613 :help "Add saved candidates to current completion candidates"))
614 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-retrieve-persistent]
615 '(menu-item " from Cache File..."
616 icicle-candidate-set-retrieve-persistent
617 :help "Retrieve saved completion candidates from a cache file, making them current"))
618 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-retrieve-from-variable]
619 '(menu-item " from Variable..." icicle-candidate-set-retrieve-from-variable
620 :help "Retrieve saved completion candidates from variable, making them current"))
621 (define-key icicle-minibuf-save-retrieve-menu-map [icicle-candidate-set-retrieve]
622 '(menu-item "Retrieve Saved Candidates" icicle-candidate-set-retrieve
623 :enable icicle-saved-completion-candidates
624 :help "Retrieve the saved set of completion candidates, making it current"))
625
626
627 ;; `Minibuf' > `Candidate Set' Menu-----------------------------------
628
629 (defvar icicle-minibuf-candidate-set-menu-map (make-sparse-keymap)
630 "`Minibuf' > `Candidate Set' submenu.")
631
632 (define-key icicle-minibuf-candidate-set-menu-map [icicle-candidate-set-define]
633 '(menu-item "Define Candidates by Lisp Sexp" icicle-candidate-set-define
634 :help "Define the set of current completion candidates by evaluating a sexp"))
635 (define-key icicle-minibuf-candidate-set-menu-map [icicle-keep-only-past-inputs]
636 '(menu-item "Keep Only Previously Entered" icicle-keep-only-past-inputs
637 :enable (and icicle-completion-candidates (consp (symbol-value minibuffer-history-variable)))
638 :help "Removed candidates that you have not previously chosen and entered"))
639 (define-key icicle-minibuf-candidate-set-menu-map [icicle-candidate-set-union]
640 '(menu-item "Add (Union) Saved Candidate Set" icicle-candidate-set-union
641 :enable icicle-saved-completion-candidates
642 :help "Set union between the current and saved completion candidates"))
643 (define-key icicle-minibuf-candidate-set-menu-map [icicle-candidate-set-difference]
644 '(menu-item "Subtract Saved Candidate Set" icicle-candidate-set-difference
645 :enable icicle-saved-completion-candidates
646 :help "Set difference between the current and saved completion candidates"))
647 (define-key icicle-minibuf-candidate-set-menu-map [icicle-candidate-set-intersection]
648 '(menu-item "Intersect Saved Candidate Set" icicle-candidate-set-intersection
649 :enable icicle-saved-completion-candidates
650 :help "Set intersection between the current and saved candidates"))
651 (define-key icicle-minibuf-candidate-set-menu-map [icicle-save-predicate-to-variable]
652 '(menu-item "Save Predicate to Variable" icicle-save-predicate-to-variable
653 :help "Save the current completion predicate to a variable"))
654 (define-key icicle-minibuf-candidate-set-menu-map [icicle-narrow-candidates-with-predicate]
655 '(menu-item "Satisfy Also Predicate..." icicle-narrow-candidates-with-predicate
656 :help "Match another input pattern (narrow completions set)"
657 :enable icicle-completion-candidates))
658 (define-key icicle-minibuf-candidate-set-menu-map [icicle-narrow-candidates]
659 '(menu-item "Match Also Regexp..." icicle-narrow-candidates
660 :enable icicle-completion-candidates
661 :help "Match another input pattern (narrow completions set)"))
662 (define-key icicle-minibuf-candidate-set-menu-map [icicle-widen-candidates]
663 '(menu-item "Match Alternative..." icicle-widen-candidates
664 :enable icicle-completion-candidates
665 :help "Match alternative input pattern (widen completions set)"))
666 (define-key icicle-minibuf-candidate-set-menu-map [icicle-candidate-set-complement]
667 '(menu-item "Complement Candidates" icicle-candidate-set-complement
668 :help "Complement the set of current completion candidates"))
669
670
671 ;; `Minibuf' > `Act on All Candidates' Menu---------------------------
672
673 (defvar icicle-minibuf-act-on-all-menu-map (make-sparse-keymap)
674 "`Minibuf' > `Act on All Candidates' submenu.")
675
676 (define-key icicle-minibuf-act-on-all-menu-map [icicle-all-candidates-list-alt-action]
677 '(menu-item "Alternate Act on List" icicle-all-candidates-list-alt-action
678 :help "Apply the alternative action to the list of matching completion candidates"
679 :enable icicle-all-candidates-list-alt-action-fn))
680 (define-key icicle-minibuf-act-on-all-menu-map [icicle-all-candidates-alt-action]
681 '(menu-item "Alternate Act on Each" icicle-all-candidates-alt-action
682 :help "Apply the alternative action to each matching completion candidates"
683 :enable icicle-candidate-alt-action-fn))
684 (define-key icicle-minibuf-act-on-all-menu-map [separator-alt] '("--"))
685 (define-key icicle-minibuf-act-on-all-menu-map [icicle-all-candidates-list-action]
686 '(menu-item "Act on List" icicle-all-candidates-list-action
687 :help "Apply the command action to the list of matching completion candidates"
688 :enable icicle-all-candidates-list-action-fn))
689 (define-key icicle-minibuf-act-on-all-menu-map [icicle-all-candidates-action]
690 '(menu-item "Act on Each" icicle-all-candidates-action
691 :help "Apply the command action to each matching completion candidates"
692 :enable icicle-candidate-action-fn))
693
694
695 ;; `Minibuf' > `History' Menu--------------------------------------------
696
697 (defvar icicle-minibuf-history-menu-map (make-sparse-keymap)
698 "`Minibuf' > `History' submenu.")
699
700 (define-key icicle-minibuf-history-menu-map [icicle-clear-current-history]
701 '(menu-item "Clear History Entries" icicle-clear-current-history
702 :help "Clear current minibuffer history of selected entries"))
703 (define-key icicle-minibuf-history-menu-map [icicle-erase-minibuffer]
704 '(menu-item "Delete from History" icicle-erase-minibuffer-or-history-element
705 :visible (memq last-command
706 '(previous-history-element next-history-element
707 icicle-erase-minibuffer-or-history-element
708 previous-matching-history-element next-matching-history-element))
709 :help "Delete current history element (in minibuffer now)" :keys "M-k"))
710 (define-key icicle-minibuf-history-menu-map [history-isearch-forward]
711 '(menu-item "Isearch History Forward" isearch-forward
712 :help "Incrementally search minibuffer history forward"))
713 (define-key icicle-minibuf-history-menu-map [history-isearch-backward]
714 '(menu-item "Isearch History Backward" isearch-backward
715 :help "Incrementally search minibuffer history backward"))
716 (define-key icicle-minibuf-history-menu-map [history-next]
717 '(menu-item "Next History Item" next-history-element
718 :help "Put next minibuffer history element in the minibuffer"))
719 (define-key icicle-minibuf-history-menu-map [history-previous]
720 '(menu-item "Previous History Item" previous-history-element
721 :help "Put previous minibuffer history element in the minibuffer"))
722
723
724 ;; `Minibuf' > `Edit' Menu--------------------------------------------
725
726 (defvar icicle-minibuf-edit-menu-map (make-sparse-keymap)
727 "`Minibuf' > `Edit' submenu.")
728
729 (define-key icicle-minibuf-edit-menu-map [icicle-delete-history-element]
730 '(menu-item "Clear (Erase) Minibuffer" icicle-erase-minibuffer-or-history-element
731 :visible (not (memq last-command
732 '(previous-history-element next-history-element
733 icicle-erase-minibuffer-or-history-element
734 previous-matching-history-element next-matching-history-element)))
735 :help "Erase the Minibuffer" :keys "M-k"))
736 (define-key icicle-minibuf-edit-menu-map [icicle-goto/kill-failed-input]
737 '(menu-item "Cursor to Mismatch (Repeat: Kill)" icicle-goto/kill-failed-input
738 :visible icicle-completing-p
739 :enable (and (overlayp icicle-input-completion-fail-overlay)
740 (overlay-start icicle-input-completion-fail-overlay))
741 :help "Put cursor where input fails to complete - repeat to kill mismatch"))
742 (define-key icicle-minibuf-edit-menu-map [icicle-retrieve-next-input]
743 '(menu-item "Restore Next Completion Input" icicle-retrieve-next-input
744 :visible icicle-completing-p
745 :enable (consp (symbol-value (if (icicle-file-name-input-p)
746 'icicle-previous-raw-file-name-inputs
747 'icicle-previous-raw-non-file-name-inputs)))
748 :help "Cycle forward to insert a previous completion input in the minibuffer (`C-u': \
749 complete)"))
750 (define-key icicle-minibuf-edit-menu-map [icicle-retrieve-previous-input]
751 '(menu-item "Restore Previous Completion Input" icicle-retrieve-previous-input
752 :visible icicle-completing-p
753 :enable (consp (symbol-value (if (icicle-file-name-input-p)
754 'icicle-previous-raw-file-name-inputs
755 'icicle-previous-raw-non-file-name-inputs)))
756 :help "Cycle backward to insert a previous completion input in the minibuffer (`C-u': \
757 complete)"))
758 (define-key icicle-minibuf-edit-menu-map [icicle-regexp-quote-input]
759 '(menu-item "Regexp-Quote Input" icicle-regexp-quote-input
760 :enable (with-current-buffer (window-buffer (minibuffer-window))
761 (goto-char (icicle-minibuffer-prompt-end)) (not (eobp)))
762 :help "Regexp-quote current input or its active region, then apropos-complete" :keys "M-%"))
763 (define-key icicle-minibuf-edit-menu-map [icicle-insert-key-description]
764 '(menu-item "Insert Key Description" icicle-insert-key-description
765 :visible (not icicle-searching-p) :keys "M-q"
766 :help "Read key and insert its description - e.g., reading ^F inserts `C-f'"))
767 (define-key icicle-minibuf-edit-menu-map [icicle-roundup]
768 '(menu-item "Insert Completion Candidate(s)" icicle-roundup
769 :visible icicle-completing-p
770 :enable icicle-completion-candidates
771 :help "Insert one or more completion candidates in the minibuffer" :keys "M-r"))
772 (define-key icicle-minibuf-edit-menu-map [icicle-insert-string-from-a-var]
773 '(menu-item "Insert String from a Variable..." icicle-insert-string-from-variable
774 :visible current-prefix-arg :keys "C-="
775 :help "Read a variable name and insert its string value into the minibuffer"))
776 (define-key icicle-minibuf-edit-menu-map [icicle-insert-string-from-std-var]
777 '(menu-item "Insert `icicle-input-string'" icicle-insert-string-from-variable
778 :visible (not current-prefix-arg) :keys "C-="
779 :help "Insert text from variable `icicle-input-string' into the minibuffer"))
780 (define-key icicle-minibuf-edit-menu-map [icicle-completing-read+insert]
781 '(menu-item "Insert On-Demand Completion" icicle-completing-read+insert
782 :visible (consp icicle-completing-read+insert-candidates)
783 :help "Read and insert something using (lax) completion"))
784 (define-key icicle-minibuf-edit-menu-map [icicle-read+insert-file-name]
785 '(menu-item "Insert File Name" icicle-read+insert-file-name
786 :help "Read and insert a file name using (lax) completion"))
787 (define-key icicle-minibuf-edit-menu-map [icicle-insert-history-element]
788 '(menu-item "Insert Past Input(s) using Completion" icicle-insert-history-element
789 :enable (consp (symbol-value minibuffer-history-variable))
790 :help "Use completion to insert a previous input into the minibuffer"))
791 (define-key icicle-minibuf-edit-menu-map [icicle-insert-list-join-string]
792 '(menu-item "Insert Join-String" icicle-insert-list-join-string
793 :visible icicle-multi-completing-p
794 :help "Insert `icicle-list-join-string' into the minibuffer" :keys "C-M-j"))
795 (define-key icicle-minibuf-edit-menu-map [icicle-insert-string-at-point]
796 '(menu-item "Insert Text from Point" icicle-insert-string-at-point
797 :help "Insert text at or near the cursor into the minibuffer"))
798
799
800
801 (defun icicle-add-menu-item-to-cmd-history ()
802 "Add `this-command' to command history, if it is a menu item.
803 Menu items that are not associated with a command symbol are ignored.
804 Used on `pre-command-hook'."
805 (condition-case nil ; Just in case, since this is on `pre-command-hook'.
806 (when (and (> (length (this-command-keys-vector)) 0)
807 (equal '(menu-bar) (elt (this-command-keys-vector) 0))
808 ;; Exclude uninterned symbols such as `menu-function-356'.
809 (symbolp this-command) (or (< emacs-major-version 21) (intern-soft this-command)))
810 (pushnew (symbol-name this-command) extended-command-history))
811 (error nil)))
812
813 (defun icicle-top-level-prep ()
814 "Do top-level stuff. Used in `pre-command-hook'."
815 ;; Reset `icicle-current-TAB-method' and `icicle-apropos-complete-match-fn' if temporary.
816 ;; Save this top-level command as `icicle-last-top-level-command'.
817 ;; Reset `icicle-candidates-alist' to ().
818 (unless (> (minibuffer-depth) 0)
819 (let ((TAB-method (get 'icicle-last-top-level-command 'icicle-current-TAB-method))
820 (apropos-fn (get 'icicle-last-top-level-command 'icicle-apropos-complete-match-fn)))
821 (when TAB-method (setq icicle-current-TAB-method TAB-method))
822 (when apropos-fn (setq icicle-apropos-complete-match-fn apropos-fn)))
823 (unless (memq this-command '(minibuffer-complete-and-exit icicle-minibuffer-complete-and-exit
824 exit-minibuffer icicle-exit-minibuffer))
825 (setq icicle-last-top-level-command this-command))
826 (setq icicle-candidates-alist ())))
827
828 (defun icicle-define-icicle-maps ()
829 "Define `icicle-mode-map' and `icicle-menu-map'."
830 (setq icicle-mode-map (make-sparse-keymap)) ; Recreate it each time, to capture latest bindings.
831
832 ;; Define `Icicles' menu-bar menu. Create it only once: sacrifice any new bindings for speed.
833 (unless icicle-menu-map
834 (setq icicle-menu-map (make-sparse-keymap "Icicles"))
835
836 ;; End of `Icicles' menu -----------------------------------------
837 (define-key icicle-menu-map [icicle-report-bug]
838 '(menu-item "Send Icicles Bug Report" icicle-send-bug-report))
839 (define-key icicle-menu-map [icicle-customize-icicles-group]
840 '(menu-item "Customize Icicles" icicle-customize-icicles-group))
841 (when (fboundp 'icicle-complete-keys)
842 (define-key icicle-menu-map [icicle-complete-keys]
843 '(menu-item "Show Available Keys (Complete Key)" icicle-complete-keys
844 :help "Show available keys (`C-g') or complete prefix key")))
845 (define-key icicle-menu-map [icicle-help]
846 '(menu-item "Icicles Help" icicle-minibuffer-help
847 :help "Display help for minibuffer input and completion" :keys "M-? in minibuf"))
848
849
850 ;; `Options' -----------------------------------------------------
851 (cond ((not icicle-touche-pas-aux-menus-flag)
852 (defvar icicle-options-menu-map (make-sparse-keymap)
853 "`Options' > `Icicles' submenu.")
854 (define-key menu-bar-options-menu [icicles]
855 (list 'menu-item "Icicles" icicle-options-menu-map :visible 'icicle-mode)))
856 (t
857 (defvar icicle-options-menu-map (make-sparse-keymap)
858 "`Icicles' > `Icicles Options' submenu.")
859 (define-key icicle-menu-map [options]
860 (list 'menu-item "Icicles Options" icicle-options-menu-map))))
861
862 (define-key icicle-options-menu-map [icicle-set-option-to-t]
863 '(menu-item "+ Turn On Any Option..." icicle-set-option-to-t
864 :help "Set boolean option to `t' (C-u: any user option, C--: any var)"))
865 (define-key icicle-options-menu-map [icicle-reset-option-to-nil]
866 '(menu-item "+ Turn Off Any Option..." icicle-reset-option-to-nil
867 :help "Reset an option to `nil' (C-u: reset any variable)"))
868 (define-key icicle-options-menu-map [icicle-toggle-option]
869 '(menu-item "+ Toggle Any Option..." icicle-toggle-option
870 :help "Toggle boolean option (C-u: any user option, C--: any var)"))
871 (define-key icicle-options-menu-map [icicle-toggle-C-for-actions]
872 '(menu-item "Toggle Using `C-' for Actions" icicle-toggle-C-for-actions :keys "M-g"
873 :help "Toggle option `icicle-use-C-for-actions-flag'"))
874 (define-key icicle-options-menu-map [icicle-toggle-~-for-home-dir]
875 '(menu-item "Toggle Using `~' for $HOME" icicle-toggle-~-for-home-dir :keys "M-~"
876 :help "Toggle option `icicle-use-~-for-home-dir-flag'"))
877 (define-key icicle-options-menu-map [icicle-next-TAB-completion-method]
878 '(menu-item "Next `TAB' Completion Method" icicle-next-TAB-completion-method
879 :keys "C-(" :help "Cycle to the next `TAB' completion method (C-u: ONE-OFF)"))
880 (define-key icicle-options-menu-map [icicle-next-S-TAB-completion-method]
881 '(menu-item "Next `S-TAB' Completion Method" icicle-next-S-TAB-completion-method
882 :keys "M-(" :help "Cycle to the next `S-TAB' completion method (C-u: ONE-OFF)"))
883 (when (fboundp 'icicle-cycle-image-file-thumbnail)
884 (define-key icicle-options-menu-map [icicle-cycle-image-file-thumbnail]
885 '(menu-item "Next Image-File Thumbnail Setting" icicle-cycle-image-file-thumbnail
886 :keys "C-x t" :help "Cycle Thumbnail Image File Setting")))
887 (define-key icicle-options-menu-map [icicle-toggle-search-cleanup]
888 '(menu-item "Toggle Icicle-Search Highlighting Cleanup" icicle-toggle-search-cleanup
889 :keys "C-." :help "Toggle option `icicle-search-cleanup-flag'"))
890 (define-key icicle-options-menu-map [icicle-toggle-search-replace-common-match]
891 '(menu-item "Toggle Replacing Longest Common Match"
892 icicle-toggle-search-replace-common-match :enable icicle-searching-p :keys "M-;"
893 :help "Toggle option `icicle-search-replace-common-match-flag'"))
894 (define-key icicle-options-menu-map [icicle-toggle-search-replace-whole]
895 '(menu-item "Toggle Replacing Whole Search Hit" icicle-toggle-search-replace-whole
896 :enable icicle-searching-p :keys "M-_"
897 :help "Toggle option `icicle-search-replace-whole-candidate-flag'"))
898 (define-key icicle-options-menu-map [icicle-toggle-search-whole-word]
899 '(menu-item "Toggle Whole-Word Searching (Icicles Search)"
900 icicle-toggle-search-whole-word
901 :enable icicle-searching-p :keys "M-q"
902 :help "Toggle `icicle-search-whole-word-flag'"))
903 (define-key icicle-options-menu-map [icicle-toggle-regexp-quote]
904 '(menu-item "Toggle Escaping Special Chars" icicle-toggle-regexp-quote :keys "C-`"
905 :help "Toggle option `icicle-regexp-quote-flag'"))
906 (define-key icicle-options-menu-map [icicle-toggle-dot]
907 '(menu-item "Toggle `.' Matching Newlines Too" icicle-toggle-dot :keys "C-M-."
908 :help "Toggle `icicle-dot-string' between `.' and `icicle-anychar-regexp'"))
909 (define-key icicle-options-menu-map [icicle-cycle-incremental-completion]
910 '(menu-item "Cycle Incremental Completion" icicle-cycle-incremental-completion
911 :keys "C-#" :help "Cycle option `icicle-incremental-completion'"))
912 (define-key icicle-options-menu-map [icicle-toggle-icomplete-mode]
913 '(menu-item "Toggle Icomplete Mode" icicle-toggle-icomplete-mode
914 :help "Toggle Icomplete mode" :enable (featurep 'icomplete-mode) :keys "C-M-#"))
915 (define-key icicle-options-menu-map [icicle-toggle-show-multi-completion]
916 '(menu-item "Toggle Showing Multi-Completions" icicle-toggle-show-multi-completion
917 :help "Toggle option `icicle-show-multi-completion-flag'"))
918 (define-key icicle-options-menu-map [icicle-toggle-completions-format]
919 '(menu-item "Toggle Horizontal/Vertical Layout" icicle-toggle-completions-format
920 :help "Toggle option `icicle-hide-non-matching-lines-flag'"))
921 (define-key icicle-options-menu-map [icicle-toggle-hiding-non-matching-lines]
922 '(menu-item "Toggle Hiding Non-Matching Lines"
923 icicle-toggle-hiding-non-matching-lines
924 :keys "C-u C-x ." :help "Toggle option `icicle-hide-non-matching-lines-flag'"))
925 (define-key icicle-options-menu-map [icicle-toggle-hiding-common-match]
926 '(menu-item "Toggle Hiding Common Match" icicle-toggle-hiding-common-match
927 :keys "C-x ." :help "Toggle option `icicle-hide-common-match-in-Completions-flag'"))
928 (define-key icicle-options-menu-map [icicle-toggle-expand-to-common-match]
929 '(menu-item "Toggle Expansion to Common Match" icicle-toggle-expand-to-common-match
930 :keys "C-\"" :help "Toggle option `icicle-expand-input-to-common-match'"))
931 (define-key icicle-options-menu-map [icicle-toggle-ignoring-comments]
932 '(menu-item "Toggle Ignoring Comments" icicle-toggle-ignoring-comments
933 :keys "C-M-;" :help "Toggle option `icicle-ignore-comments-flag'"))
934 (define-key icicle-options-menu-map [icicle-toggle-ignored-space-prefix]
935 '(menu-item "Toggle Ignoring Space Prefix" icicle-toggle-ignored-space-prefix
936 :keys "M-_" :help "Toggle option `icicle-buffer-ignore-space-prefix-flag'"))
937 (define-key icicle-options-menu-map [icicle-toggle-ignored-extensions]
938 '(menu-item "Toggle Ignored File Extensions" icicle-toggle-ignored-extensions
939 :keys "C-." :help "Toggle respect of `completion-ignored-extensions'"))
940 (define-key icicle-options-menu-map [icicle-toggle-remote-file-testing]
941 '(menu-item "Toggle Remote File Handling" icicle-toggle-remote-file-testing
942 :enable (not icicle-searching-p) :keys "C-^"
943 :help "Toggle option `icicle-test-for-remote-files-flag'"))
944 (when (> emacs-major-version 20)
945 (define-key icicle-options-menu-map [icicle-toggle-angle-brackets]
946 '(menu-item "Toggle Angle Brackets" icicle-toggle-angle-brackets
947 :help "Toggle option `icicle-key-descriptions-use-<>-flag'")))
948 (define-key icicle-options-menu-map [icicle-toggle-annotation]
949 '(menu-item "Toggle Candidate Annotation"
950 icicle-toggle-annotation :keys "C-x C-a"
951 :help "Toggle option `icicle-show-annotations-flag': hide/show annotations"))
952 (define-key icicle-options-menu-map [icicle-toggle-WYSIWYG-Completions]
953 '(menu-item "Toggle WYSIWYG for `*Completions*'" icicle-toggle-WYSIWYG-Completions
954 :keys "C-S-pause" :help "Toggle option `icicle-WYSIWYG-Completions-flag'"))
955 (define-key icicle-options-menu-map [icicle-toggle-highlight-saved-candidates]
956 '(menu-item "Toggle Highlighting Saved Candidates"
957 icicle-toggle-highlight-saved-candidates :keys "S-pause"
958 :help "Toggle option `icicle-highlight-saved-candidates-flag'"))
959 (define-key icicle-options-menu-map [icicle-toggle-highlight-historical-candidates]
960 '(menu-item "Toggle Highlighting Past Inputs"
961 icicle-toggle-highlight-historical-candidates :keys "C-pause"
962 :help "Toggle option `icicle-highlight-historical-candidates-flag'"))
963 (define-key icicle-options-menu-map [icicle-toggle-case-sensitivity]
964 '(menu-item "Toggle Case Sensitivity" icicle-toggle-case-sensitivity :keys "C-A"
965 :help "Toggle `case-fold-search', `completion-ignore-case' (C-u: file & buffer too)"))
966 (define-key icicle-options-menu-map [icicle-toggle-proxy-candidates]
967 '(menu-item "Toggle Including Proxy Candidates" icicle-toggle-proxy-candidates
968 :keys "C-M-_" :help "Toggle option `icicle-add-proxy-candidates-flag'"))
969 (define-key icicle-options-menu-map [icicle-toggle-transforming]
970 '(menu-item "Toggle Duplicate Removal" icicle-toggle-transforming :keys "C-$"
971 :help "Toggle use of `icicle-transform-function' (default: remove dups)"))
972 (define-key icicle-options-menu-map [icicle-toggle-alternative-sorting]
973 '(menu-item "Swap Alternative Sort" icicle-toggle-alternative-sorting :keys "C-M-,"
974 :help "Swap current sort order for current alternative sort order"))
975 (define-key icicle-options-menu-map [icicle-change-alternative-sort-order]
976 '(menu-item "Change Alternative Sort Order" icicle-change-alternative-sort-order
977 :keys "M-," :help "Choose alt sort order (C-9: reverse, C-u: cyle/complete)"))
978 (define-key icicle-options-menu-map [icicle-change-sort-order]
979 '(menu-item "Change Sort Order" icicle-change-sort-order
980 :enable (not icicle-inhibit-sort-p) :keys "C-,"
981 :help "Choose sort order (C-9: reverse, C-u: cyle/complete)"))
982 (when (fboundp 'doremi)
983 (when (fboundp 'text-scale-increase) ; Emacs 23+.
984 (define-key icicle-options-menu-map [icicle-doremi-zoom-Completions+]
985 '(menu-item "*Completions* Zoom Factor - Do Re Mi"
986 icicle-doremi-zoom-Completions+
987 :visible (get-buffer-window "*Completions*" 'visible) :keys "C-x -"
988 :help "Zoom text in `*Completions*' incrementally")))
989 (define-key icicle-options-menu-map [icicle-doremi-inter-candidates-min-spaces+]
990 '(menu-item "*Completions* Candidate Spacing - Do Re Mi"
991 icicle-doremi-inter-candidates-min-spaces+
992 :visible (get-buffer-window "*Completions*" 'visible) :keys "C-x |"
993 :help "Change `icicle-inter-candidates-min-spaces' incrementally"))
994 (define-key icicle-options-menu-map [icicle-doremi-candidate-width-factor+]
995 '(menu-item "*Completions* Column Width - Do Re Mi"
996 icicle-doremi-candidate-width-factor+
997 :visible (get-buffer-window "*Completions*" 'visible) :keys "C-x w"
998 :help "Change `icicle-candidate-width-factor' incrementally"))
999 (define-key icicle-options-menu-map [icicle-doremi-increment-swank-prefix-length+]
1000 '(menu-item "Swank Min Match Chars - Do Re Mi"
1001 icicle-doremi-increment-swank-prefix-length+
1002 :visible (eq (icicle-current-TAB-method) 'swank) :keys "C-x 2"
1003 :help "Change `icicle-swank-prefix-length' incrementally"))
1004 (define-key icicle-options-menu-map [icicle-doremi-increment-swank-timeout+]
1005 '(menu-item "Swank Timeout - Do Re Mi"
1006 icicle-doremi-increment-swank-timeout+
1007 :visible (eq (icicle-current-TAB-method) 'swank) :keys "C-x 1"
1008 :help "Change `icicle-swank-timeout' incrementally"))
1009 (define-key icicle-options-menu-map [icicle-doremi-increment-max-candidates+]
1010 '(menu-item "Max # of Completions - Do Re Mi"
1011 icicle-doremi-increment-max-candidates+
1012 :visible (active-minibuffer-window) :keys "C-x #"
1013 :help "Change `icicle-max-candidates' incrementally")))
1014
1015
1016 ;; Beginning of non-submenu `Icicles' menu -----------------------
1017 (define-key icicle-menu-map [icicle-separator-help] '("--"))
1018
1019 (define-key icicle-menu-map [icicle-mode]
1020 '(menu-item "Turn Off Icicle Mode" icicle-mode))
1021 (define-key icicle-menu-map [icicle-top-level]
1022 '(menu-item "Top Level (Cancel All Minibuffers)" icicle-top-level
1023 :enable (active-minibuffer-window)
1024 :help "Cancel all minibuffers and return to the top level" :keys "C-M-T"))
1025 (define-key icicle-menu-map [icicle-abort]
1026 '(menu-item "Cancel This Minibuffer" icicle-abort-recursive-edit
1027 :enable (active-minibuffer-window)
1028 :help "Cancel this minibuffer and return to the next higher level"))
1029 (define-key icicle-menu-map [icicle-recomplete-from-original-domain]
1030 '(menu-item "Recompute Completions" icicle-recomplete-from-original-domain
1031 :enable (and (active-minibuffer-window) icicle-completing-p)
1032 :help "Recomplete your last typed input, using the original domain."))
1033 (define-key icicle-menu-map [icicle-separator-levels] '("--"))
1034
1035 (define-key icicle-menu-map [icicle-apply]
1036 '(menu-item "+ Apply Function to Alist Items..." icicle-apply
1037 :help "Selectively apply a function to elements in an alist"))
1038 (define-key icicle-menu-map [icicle-save-string-to-variable]
1039 '(menu-item "Save String to Variable..." icicle-save-string-to-variable
1040 :help "Save a string (text) you are prompted for to a variable"))
1041 (define-key icicle-menu-map [icicle-color-theme]
1042 '(menu-item "+ Choose Color Theme..." icicle-color-theme
1043 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1044 :help "Change color theme (cycling etc.)"))
1045 (define-key icicle-menu-map [icicle-remove-saved-completion-set]
1046 '(menu-item "+ Remove Saved Candidate Set..." icicle-remove-saved-completion-set
1047 :enable icicle-saved-completion-sets
1048 :help "Remove an entry from `icicle-saved-completion-sets'"))
1049 (define-key icicle-menu-map [icicle-add/update-saved-completion-set]
1050 '(menu-item "Add/Update Saved Candidate Set..." icicle-add/update-saved-completion-set
1051 :help "Add or update an entry in `icicle-saved-completion-sets'"))
1052 (when (fboundp 'icicle-kmacro)
1053 (define-key icicle-menu-map [icicle-kmacro]
1054 '(menu-item "+ Execute Nth Keyboard Macro..." icicle-kmacro
1055 :enable (or (kmacro-ring-head) kmacro-ring)
1056 :help "Execute a keyboard macro according to its position in `kmacro-ring'")))
1057 (define-key icicle-menu-map [icicle-execute-named-keyboard-macro]
1058 '(menu-item "+ Execute Named Keyboard Macro..." icicle-execute-named-keyboard-macro
1059 :help "Read the name of a keyboard macro, then execute it"))
1060
1061
1062 ;; `Customize' ---------------------------------------------------
1063 (cond ((not icicle-touche-pas-aux-menus-flag)
1064 (defvar icicle-custom-menu-map (make-sparse-keymap)
1065 "`Customize Emacs' > `Icicles' submenu.")
1066 (define-key menu-bar-custom-menu [icicles]
1067 (list 'menu-item "Icicles" icicle-custom-menu-map :visible 'icicle-mode)))
1068 (t
1069 (defvar icicle-custom-menu-map (make-sparse-keymap)
1070 "`Icicles' > `Customize' submenu.")
1071 (define-key icicle-menu-map [customize]
1072 (list 'menu-item "Customize" icicle-custom-menu-map))))
1073
1074 (define-key icicle-custom-menu-map [icicle-customize-apropos]
1075 '(menu-item "Groups, Faces & Options Matching..." icicle-customize-apropos
1076 :help "Customize groups, faces, and options that match a regexp"))
1077 (define-key icicle-custom-menu-map [icicle-customize-face-other-window]
1078 '(menu-item "+ Face..." icicle-customize-face-other-window
1079 :help "Customize any number of faces (`C-RET')"))
1080 (define-key icicle-custom-menu-map [icicle-customize-apropos-faces]
1081 '(menu-item "Faces Matching..." icicle-customize-apropos-faces
1082 :help "Customize faces that match a regexp"))
1083 (define-key icicle-custom-menu-map [icicle-customize-apropos-opts-w-val-satisfying]
1084 '(menu-item "Options Matching with a Value Satisfying..."
1085 icicle-customize-apropos-opts-w-val-satisfying
1086 :help "Customize options whose values satisfy a predicate that match a regexp"))
1087 (define-key icicle-custom-menu-map [icicle-customize-apropos-options-of-type]
1088 '(menu-item "Options of Type Matching..."
1089 icicle-customize-apropos-options-of-type
1090 :help "Customize user options of a given type that match a regexp"))
1091 (define-key icicle-custom-menu-map [icicle-customize-apropos-options]
1092 '(menu-item "Options Matching..." icicle-customize-apropos-options
1093 :help "Customize user options that match a regexp"))
1094 (define-key icicle-custom-menu-map [icicle-customize-apropos-groups]
1095 '(menu-item "Groups Matching..." icicle-customize-apropos-groups
1096 :help "Customize customization groups that match a regexp"))
1097
1098
1099 ;; `Apropos' -----------------------------------------------------
1100 (cond ((and (not icicle-touche-pas-aux-menus-flag) (boundp 'menu-bar-apropos-menu))
1101 (defvar icicle-apropos-menu-map (make-sparse-keymap)
1102 "`Help' > `Apropos' > `Icicles' submenu.")
1103 (define-key menu-bar-apropos-menu [icicles]
1104 (list 'menu-item "Icicles" icicle-apropos-menu-map :visible 'icicle-mode)))
1105 (t
1106 (defvar icicle-apropos-menu-map (make-sparse-keymap)
1107 "`Icicles' > `Apropos' submenu.")
1108 (define-key icicle-menu-map [apropos]
1109 (list 'menu-item "Apropos" icicle-apropos-menu-map))))
1110
1111 (define-key icicle-apropos-menu-map [icicle-apropos-zippy]
1112 '(menu-item "Zippy..." icicle-apropos-zippy
1113 :help "Show all Zippy quotes matching a regular-expression"))
1114 (cond ((fboundp 'apropos-option)
1115 (define-key icicle-apropos-menu-map [icicle-apropos]
1116 '(menu-item "Symbols..." icicle-apropos
1117 :help "Like `apropos', but lets you see the list of matches (with `S-TAB')"))
1118 (define-key icicle-apropos-menu-map [icicle-apropos-vars-w-val-satisfying]
1119 '(menu-item "Variables with a Value Satisfying..." icicle-apropos-vars-w-val-satisfying
1120 :help "Show variables whose values satisfy a given predicate"))
1121 (define-key icicle-apropos-menu-map [icicle-apropos-value]
1122 '(menu-item "Variables with Values..." icicle-apropos-value
1123 :help "Show variables that match by name and/or value"))
1124 (define-key icicle-apropos-menu-map [icicle-apropos-variable]
1125 '(menu-item "Variables..." icicle-apropos-variable
1126 :help "Show variables that match PATTERN"))
1127 (define-key icicle-apropos-menu-map [icicle-apropos-options-of-type]
1128 '(menu-item "Options of Type..." icicle-apropos-options-of-type
1129 :help "Show user options (variables) of a given `defcustom' type"))
1130 (define-key icicle-apropos-menu-map [icicle-apropos-option]
1131 '(menu-item "Options..." icicle-apropos-option
1132 :help "Show user options (variables) that match PATTERN"))
1133 (define-key icicle-apropos-menu-map [icicle-apropos-function]
1134 '(menu-item "Functions..." icicle-apropos-function
1135 :help "Show functions that match PATTERN"))
1136 (define-key icicle-apropos-menu-map [icicle-apropos-command]
1137 '(menu-item "Commands..." icicle-apropos-command
1138 :help "Show commands that match PATTERN")))
1139 (t
1140 (define-key icicle-apropos-menu-map [icicle-apropos-vars-w-val-satisfying]
1141 '(menu-item "Variables with a Value Satisfying..." icicle-apropos-vars-w-val-satisfying
1142 :help "Show variables whose values satisfy a given predicate"))
1143 (define-key icicle-apropos-menu-map [icicle-apropos-value]
1144 '(menu-item "Variables with Values..." icicle-apropos-value
1145 :help "Show variables that match by name and/or value"))
1146 (define-key icicle-apropos-menu-map [icicle-apropos-variable]
1147 '(menu-item "Variables..." icicle-apropos-variable
1148 :help "Show variables that match PATTERN"))
1149 (define-key icicle-apropos-menu-map [icicle-apropos-command]
1150 '(menu-item "Commands..." icicle-apropos-command
1151 :help "Show commands that match PATTERN"))))
1152
1153
1154 ;; `Describe' ----------------------------------------------------
1155 (cond ((not icicle-touche-pas-aux-menus-flag)
1156 (defvar icicle-describe-menu-map (make-sparse-keymap)
1157 "`Describe' > `Icicles' submenu.")
1158 (define-key menu-bar-describe-menu [icicles]
1159 (list 'menu-item "Icicles" icicle-describe-menu-map :visible 'icicle-mode)))
1160 (t
1161 (defvar icicle-describe-menu-map (make-sparse-keymap)
1162 "`Icicles' > `Describe' submenu.")
1163 (define-key icicle-menu-map [describe]
1164 (list 'menu-item "Describe" icicle-describe-menu-map :visible 'icicle-mode))))
1165
1166 (define-key icicle-describe-menu-map [icicle-plist]
1167 '(menu-item "+ Symbol with Property List..." icicle-plist
1168 :help "Choose a symbol and its property list"))
1169 (define-key icicle-describe-menu-map [icicle-doc]
1170 '(menu-item "+ Doc of Fun, Var, or Face..." icicle-doc
1171 :help "Choose documentation for a symbol"))
1172 (define-key icicle-describe-menu-map [icicle-fundoc]
1173 '(menu-item "+ Function with Name, Doc..." icicle-fundoc
1174 :help "Choose a function description"))
1175 (define-key icicle-describe-menu-map [icicle-vardoc]
1176 '(menu-item "+ Variable with Name, Doc..." icicle-vardoc
1177 :help "Choose a variable description"))
1178 (define-key icicle-describe-menu-map [icicle-describe-var-w-val-satisfying]
1179 '(menu-item "+ Variable with Value Satifying..." icicle-describe-var-w-val-satisfying
1180 :help "Describe a variable that satisfies a given predicate"))
1181 (define-key icicle-describe-menu-map [icicle-describe-option-of-type]
1182 '(menu-item "+ Option of Type..." icicle-describe-option-of-type
1183 :help "Describe a user option that was defined with a given `defcustom' type"))
1184 (define-key icicle-describe-menu-map [icicle-where-is]
1185 '(menu-item "+ Where Is..." icicle-where-is
1186 :help "Show keyboard/menu/mouse sequences that invoke specified command"))
1187 (when icicle-touche-pas-aux-menus-flag
1188 (define-key icicle-menu-map [icicle-separator-about] '("--")))
1189
1190
1191 ;; `Search' and `Emacs Tags' (or `Tags') -------------------------
1192 (cond ((not icicle-touche-pas-aux-menus-flag)
1193 (cond ((boundp 'menu-bar-search-tags-menu) ; `Tags' menu defined in `menu-bar+.el'.
1194 (defvar icicle-search-menu-map (make-sparse-keymap)
1195 "`Search' > `Icicles' menu.")
1196 (define-key menu-bar-search-menu [icicles]
1197 (list 'menu-item "Icicles" icicle-search-menu-map :visible 'icicle-mode))
1198 (defvar icicle-search-tags-menu-map (make-sparse-keymap)
1199 "`Search' > `Tags' > `Icicles' menu.")
1200 (define-key menu-bar-search-tags-menu [icicles]
1201 (list 'menu-item "Icicles" icicle-search-tags-menu-map :visible 'icicle-mode)))
1202 (t
1203 (defvar icicle-search-menu-map (make-sparse-keymap)
1204 "`Search' > `Icicles' menu.")
1205 (define-key menu-bar-search-menu [icicles]
1206 (list 'menu-item "Icicles" icicle-search-menu-map :visible 'icicle-mode))
1207 (defvar icicle-search-tags-menu-map (make-sparse-keymap)
1208 "`Search' > `Icicles' > `Emacs Tags' menu.")
1209 (define-key icicle-search-menu-map [emacs-tags]
1210 (list 'menu-item "Emacs Tags" icicle-search-tags-menu-map
1211 :visible 'icicle-mode)))))
1212 (t
1213 (defvar icicle-search-menu-map (make-sparse-keymap)
1214 "`Icicles' > `Search' menu.")
1215 (define-key icicle-menu-map [search]
1216 (list 'menu-item "Search" icicle-search-menu-map))
1217 (defvar icicle-search-tags-menu-map (make-sparse-keymap)
1218 "`Icicles' > `Search' > `Emacs Tags' menu.")
1219 (define-key icicle-search-menu-map [emacs-tags]
1220 (list 'menu-item "Emacs Tags" icicle-search-tags-menu-map :visible 'icicle-mode))))
1221
1222 ;; `Go To' -------------------------------------------------------
1223 (cond ((not icicle-touche-pas-aux-menus-flag)
1224 (cond ((boundp 'menu-bar-goto-menu)
1225 (defvar icicle-search-goto-menu-map (make-sparse-keymap)
1226 "`Go To' > `Icicles' menu.")
1227 (define-key menu-bar-goto-menu [icicles]
1228 (list 'menu-item "Icicles" icicle-search-goto-menu-map)))
1229 (t
1230 (defvar icicle-search-goto-menu-map (make-sparse-keymap)
1231 "Icicles `Go To' submenu of `Search' menu.")
1232 (define-key icicle-search-menu-map [goto]
1233 (list 'menu-item "Go To" icicle-search-goto-menu-map)))))
1234 (t
1235 (defvar icicle-search-goto-menu-map (make-sparse-keymap)
1236 "`Icicles' > `Go To' menu.")
1237 (define-key icicle-menu-map [search]
1238 (list 'menu-item "Go To" icicle-search-menu-map))))
1239
1240 (define-key icicle-search-goto-menu-map [icicle-goto-global-marker]
1241 '(menu-item "+ Global Marker..." icicle-goto-global-marker
1242 :enable (consp (icicle-markers global-mark-ring)) :keys "C-- C-x C-SPC"
1243 :help "Go to a global marker, choosing it by the line that includes it"))
1244 (define-key icicle-search-goto-menu-map [icicle-goto-marker]
1245 '(menu-item "+ Marker..." icicle-goto-marker
1246 :enable (mark t) :keys "C-- C-SPC"
1247 :help "Go to a marker in this buffer, choosing it by the line that includes it"))
1248 (define-key icicle-search-goto-menu-map [icicle-select-bookmarked-region]
1249 '(menu-item "+ Select Bookmarked Region..." icicle-select-bookmarked-region
1250 :enable (featurep 'bookmark+) :keys "C-u C-x C-x"
1251 :help "Jump to a bookmarked region in other window, and select (activate) it"))
1252
1253 ;; `Go To' > `Definition' menu.
1254 (defvar icicle-search-goto-imenu-menu-map (make-sparse-keymap)
1255 "Icicles `Definition' submenu of `Go To' menu.")
1256 (define-key icicle-search-goto-menu-map [imenu]
1257 (list 'menu-item "Definition" icicle-search-goto-imenu-menu-map
1258 :visible 'imenu-generic-expression))
1259
1260 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-key-explicit-map]
1261 '(menu-item "+ Key in Map..." icicle-imenu-key-explicit-map
1262 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1263 :help "Go to a key definition in some map, using `icicle-search'"))
1264 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-key-implicit-map]
1265 '(menu-item "+ Key..." icicle-imenu-key-implicit-map
1266 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1267 :help "Go to a (global) key definition using `icicle-search'"))
1268 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-variable]
1269 '(menu-item "+ Variable..." icicle-imenu-variable
1270 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1271 :help "Go to a variable definition using `icicle-search'"))
1272 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-user-option]
1273 '(menu-item "+ User Option..." icicle-imenu-user-option
1274 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1275 :help "Go to an option definition using `icicle-search'"))
1276 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-face]
1277 '(menu-item "+ Face..." icicle-imenu-face
1278 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1279 :help "Go to a face definition using `icicle-search'"))
1280 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-macro]
1281 '(menu-item "+ Macro..." icicle-imenu-macro
1282 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1283 :help "Go to a Lisp macro definition using `icicle-search'"))
1284 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-non-interactive-function]
1285 '(menu-item "+ Non-Interactive Function..." icicle-imenu-non-interactive-function
1286 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1287 :help "Go to a non-command function definition using `icicle-search'"))
1288 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu-command]
1289 '(menu-item "+ Command..." icicle-imenu-command
1290 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1291 :help "Go to a command definition using `icicle-search'"))
1292 (define-key icicle-search-goto-imenu-menu-map [icicle-imenu]
1293 '(menu-item "+ Any..." icicle-imenu
1294 :enable imenu-generic-expression :help "Go to a definition using `icicle-search'"))
1295
1296 ;; `Search' > `Emacs Tags' (or `Tags') menu
1297 (define-key icicle-search-tags-menu-map [icicle-tags-search]
1298 '(menu-item "+ Search Tagged Files ..." icicle-tags-search
1299 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1300 :help "Search all source files listed in tags tables for matches for a regexp"))
1301 (define-key icicle-search-tags-menu-map [icicle-pop-tag-mark]
1302 '(menu-item "+ Back (Pop Tag Mark)" icicle-pop-tag-mark
1303 :enable (and (boundp 'find-tag-marker-ring)
1304 (not (ring-empty-p find-tag-marker-ring))
1305 (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
1306 :help "Pop back to where `M-.' was last invoked"))
1307 (define-key icicle-search-tags-menu-map [icicle-find-first-tag-other-window]
1308 '(menu-item "+ Find First Tag ..." icicle-find-first-tag-other-window
1309 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1310 :help "Find first tag in current tags table whose name matches your input"))
1311 (define-key icicle-search-tags-menu-map [icicle-find-tag]
1312 '(menu-item "+ Find Tag ..." icicle-find-tag
1313 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1314 :help "Navigate among all tags that match a regexp"))
1315
1316 ;; `Search' menu
1317 (define-key icicle-search-menu-map [icicle-search-highlight-cleanup]
1318 '(menu-item "Remove Icicle-Search Highlighting..." icicle-search-highlight-cleanup
1319 :enable (or icicle-search-overlays
1320 (overlayp icicle-search-current-overlay)
1321 (overlayp icicle-search-refined-overlays) icicle-search-refined-overlays)
1322 :help "Remove all highlighting from the last use of `icicle-search'"))
1323 (define-key icicle-search-menu-map [icicle-search-define-replacement]
1324 '(menu-item "Define Replacement String..." icicle-search-define-replacement
1325 :help "Set the replacement string for use in `icicle-search'"))
1326 (define-key icicle-search-menu-map [separator-search-1] '("--"))
1327
1328 (define-key icicle-search-menu-map [icicle-compilation-search]
1329 '(menu-item "+ Search Compilation/Grep Hits (Regexp)..."
1330 icicle-compilation-search
1331 :visible (and (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1332 (condition-case nil (eq (current-buffer) (compilation-find-buffer))
1333 (error nil)))
1334 :keys "C-`" :help "Icicles search, showing the matching compilation-buffer hit"))
1335 (define-key icicle-search-menu-map [icicle-grep-saved-file-candidates]
1336 '(menu-item "Grep Saved File-Name Candidates..."
1337 icicle-grep-saved-file-candidates
1338 :enable icicle-saved-completion-candidates
1339 :help "Run `grep' on the set of completion candidates saved using `C-M->'"))
1340 (define-key icicle-search-menu-map [icicle-tags-search]
1341 '(menu-item "+ Search Tagged Files ..." icicle-tags-search
1342 :help "Search all source files listed in tags tables for matches for a regexp"))
1343 (define-key icicle-search-menu-map [icicle-search-file]
1344 '(menu-item "+ Search Files (Regexp)..." icicle-search-file
1345 :help "Search multiple files completely"))
1346 (define-key icicle-search-menu-map [icicle-search-buffer]
1347 '(menu-item "+ Search Buffers (Regexp)..." icicle-search-buffer
1348 :help "Search multiple buffers completely"))
1349 (define-key icicle-search-menu-map [separator-search-2] '("--"))
1350
1351 (define-key icicle-search-menu-map [icicle-search-overlay-property]
1352 '(menu-item "+ Search Overlay Property..." icicle-search-overlay-property
1353 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1354 :help "Search for an overlay that has a property with a certain value"))
1355 (define-key icicle-search-menu-map [icicle-search-char-property]
1356 '(menu-item "+ Search Character Property..." icicle-search-char-property
1357 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1358 :help "Search for text that has a property with a certain value"))
1359 (define-key icicle-search-menu-map [icicle-search-text-property]
1360 '(menu-item "+ Search Text Property..." icicle-search-text-property
1361 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1362 :help "Search for text or overlay that has a property with a certain value"))
1363 (define-key icicle-search-menu-map [separator-search-3] '("--"))
1364
1365 (define-key icicle-search-menu-map [icicle-search-xml-element-text-node]
1366 '(menu-item "+ Search XML text() Nodes..." icicle-search-xml-element-text-node
1367 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1368 :help "Icicles search with text() nodes of ELEMENTs as search contexts"))
1369 (define-key icicle-search-menu-map [icicle-search-xml-element]
1370 '(menu-item "+ Search XML Elements..." icicle-search-xml-element
1371 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1372 :help "Icicles search with XML ELEMENTs as search contexts - you are prompted for ELEMENT"))
1373 (define-key icicle-search-menu-map [icicle-search-pages]
1374 '(menu-item "+ Search Pages..." icicle-search-pages
1375 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1376 :help "Icicles search with pages as search contexts"))
1377 (define-key icicle-search-menu-map [icicle-search-paragraphs]
1378 '(menu-item "+ Search Paragraphs..." icicle-search-paragraphs
1379 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1380 :help "Icicles search with paragraphs as search contexts"))
1381 (define-key icicle-search-menu-map [icicle-search-sentences]
1382 '(menu-item "+ Search Sentences..." icicle-search-sentences
1383 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1384 :help "Icicles search with sentences as search contexts"))
1385 (define-key icicle-search-menu-map [icicle-occur]
1386 '(menu-item "+ Search Lines (`icicle-occur')..." icicle-occur
1387 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1388 :help "Icicles search with lines as search contexts"))
1389 (define-key icicle-search-menu-map [icicle-search-thing]
1390 '(menu-item "+ Search Things..." icicle-search-thing
1391 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1392 :help "Icicles search with THINGs as search contexts - you are prompted for THING"))
1393 (define-key icicle-search-menu-map [separator-search-4] '("--"))
1394
1395 (define-key icicle-search-menu-map [icicle-search-word]
1396 '(menu-item "+ Search for Word..." icicle-search-word
1397 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1398 :help "Whole-word Icicles search"))
1399 (define-key icicle-search-menu-map [icicle-search-w-isearch-string]
1400 '(menu-item "+ Search with Isearch Contexts..." icicle-search-w-isearch-string
1401 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1402 :help "Icicles search with search contexts that match a previous Isearch string"))
1403 (define-key icicle-search-menu-map [icicle-search-keywords]
1404 '(menu-item "+ Search with Keywords (Regexps)..." icicle-search-keywords
1405 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1406 :help "Icicles search with one or more keywords, which can each be a regexp"))
1407 (define-key icicle-search-menu-map [icicle-search]
1408 '(menu-item "+ Search (Regexp)..." icicle-search
1409 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1410 :keys "C-`"
1411 :help "Icicles search for regexp matches, with completion, cycling, & hit replacement"))
1412
1413 ;; `M-s M-s m' - mode-specific search
1414 (define-key icicle-search-menu-map [icicle-search-dired-marked-recursive]
1415 '(menu-item "+ Search Marked, Here and Below..." icicle-search-dired-marked-recursive
1416 :help "Search the marked files, including those in marked subdirs"
1417 :visible (eq major-mode 'dired-mode)))
1418 (define-key icicle-search-menu-map [icicle-search-bookmark-list-marked]
1419 '(menu-item "+ Search Marked..." icicle-search-bookmark-list-marked
1420 :help "Search the target files of the marked bookmarks"
1421 :visible (eq major-mode 'bookmark-bmenu-mode)))
1422 (define-key icicle-search-menu-map [icicle-search-ibuffer-marked]
1423 '(menu-item "+ Search Marked..." icicle-search-ibuffer-marked
1424 :help "Search the marked files" :visible (eq major-mode 'ibuffer-mode)))
1425 (define-key icicle-search-menu-map [icicle-search-buff-menu-marked]
1426 '(menu-item "+ Search Marked..." icicle-search-buff-menu-marked
1427 :help "Search the marked files" :visible (eq major-mode 'Buffer-menu-mode)))
1428
1429 ;; `Search' > `Bookmarks' menu.
1430 (defvar icicle-search-bookmarks-menu-map (make-sparse-keymap)
1431 "Icicles `Bookmarks' submenu of `Search' menu.")
1432 (define-key icicle-search-menu-map [bookmarks]
1433 (list 'menu-item "Bookmarks" icicle-search-bookmarks-menu-map :visible 'icicle-mode))
1434
1435 (define-key icicle-search-bookmarks-menu-map [icicle-search-w3m-bookmark]
1436 '(menu-item "+ W3M Bookmarks..." icicle-search-w3m-bookmark
1437 :visible (featurep 'bookmark+)
1438 :help "Search text of W3M bookmarks"))
1439 (define-key icicle-search-bookmarks-menu-map [icicle-search-url-bookmark]
1440 '(menu-item "+ URL Bookmarks..." icicle-search-url-bookmark
1441 :visible (featurep 'bookmark+)
1442 :help "Search text of bookmarks whose targets are defined by URLs"))
1443 (define-key icicle-search-bookmarks-menu-map [icicle-search-gnus-bookmark]
1444 '(menu-item "+ Gnus Bookmarks..." icicle-search-gnus-bookmark
1445 :visible (featurep 'bookmark+)
1446 :help "Search text of Gnus bookmarks"))
1447 (define-key icicle-search-bookmarks-menu-map [icicle-search-man-bookmark]
1448 '(menu-item "+ Man Bookmarks..." icicle-search-man-bookmark
1449 :visible (featurep 'bookmark+)
1450 :help "Search text of `man' bookmarks"))
1451 (define-key icicle-search-bookmarks-menu-map [icicle-search-info-bookmark]
1452 '(menu-item "+ Info Bookmarks..." icicle-search-info-bookmark
1453 :visible (featurep 'bookmark+)
1454 :help "Search text of Info (manual) bookmarks"))
1455 (define-key icicle-search-bookmarks-menu-map [icicle-search-bookmark-list-bookmark]
1456 '(menu-item "+ Bookmark-List Bookmarks..." icicle-search-bookmark-list-bookmark
1457 :visible (featurep 'bookmark+)
1458 :help "Search text of bookmark-list bookmarks"))
1459 (define-key icicle-search-bookmarks-menu-map [icicle-search-dired-bookmark]
1460 '(menu-item "+ Dired Bookmarks..." icicle-search-dired-bookmark
1461 :visible (featurep 'bookmark+)
1462 :help "Search buffers of Dired bookmarks"))
1463 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-6]
1464 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1465
1466 (define-key icicle-search-bookmarks-menu-map [icicle-search-some-tags-regexp-bookmark]
1467 '(menu-item "+ Bookmarks Tagged Some Regexp..." icicle-search-some-tags-regexp-bookmark
1468 :visible (featurep 'bookmark+)
1469 :help "Search text of bookmarks some of whose tags matches a regexp"))
1470 (define-key icicle-search-bookmarks-menu-map [icicle-search-all-tags-regexp-bookmark]
1471 '(menu-item "+ Bookmarks Tagged All Regexp..." icicle-search-all-tags-regexp-bookmark
1472 :visible (featurep 'bookmark+)
1473 :help "Search text of bookmarks all of whose tags match a regexp"))
1474 (define-key icicle-search-bookmarks-menu-map [icicle-search-some-tags-bookmark]
1475 '(menu-item "+ Bookmarks Tagged Some..." icicle-search-some-tags-bookmark
1476 :visible (featurep 'bookmark+)
1477 :help "Search text of bookmarks some of whose tags are among those tags you choose"))
1478 (define-key icicle-search-bookmarks-menu-map [icicle-search-all-tags-bookmark]
1479 '(menu-item "+ Bookmarks Tagged All..." icicle-search-all-tags-bookmark
1480 :visible (featurep 'bookmark+)
1481 :help "Search text of bookmarks all of whose tags are among those tags you choose"))
1482 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-5]
1483 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1484
1485 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-5]
1486 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1487
1488 (define-key icicle-search-bookmarks-menu-map [icicle-search-non-file-bookmark]
1489 '(menu-item "+ Non-File Bookmarks..." icicle-search-non-file-bookmark
1490 :visible (featurep 'bookmark+)
1491 :help "Search text of bookmarks whose targets are not files - e.g., buffers"))
1492 (define-key icicle-search-bookmarks-menu-map [icicle-search-remote-file-bookmark]
1493 '(menu-item "+ Remote File Bookmarks..." icicle-search-remote-file-bookmark
1494 :visible (featurep 'bookmark+)
1495 :help "Search text of bookmarks whose targets are remote files"))
1496 (define-key icicle-search-bookmarks-menu-map [icicle-search-local-file-bookmark]
1497 '(menu-item "+ Local File Bookmarks..." icicle-search-local-file-bookmark
1498 :visible (featurep 'bookmark+)
1499 :help "Search text of bookmarks whose targets are local files"))
1500 (define-key icicle-search-bookmarks-menu-map [icicle-search-file-bookmark]
1501 '(menu-item "+ File Bookmarks..." icicle-search-file-bookmark
1502 :visible (featurep 'bookmark+)
1503 :help "Search text of bookmarks whose targets are files"))
1504 (define-key icicle-search-bookmarks-menu-map [icicle-search-autofile-bookmark]
1505 '(menu-item "+ Autofile Bookmarks..." icicle-search-autofile-bookmark
1506 :visible (featurep 'bookmark+)
1507 :help "Search text of autofile bookmarks: files bookmarked under their own names"))
1508 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-3]
1509 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1510
1511 (define-key icicle-search-bookmarks-menu-map [icicle-search-specific-files-bookmark]
1512 '(menu-item "+ Bookmarks for Specific Files..." icicle-search-specific-files-bookmark
1513 :visible (featurep 'bookmark+)
1514 :help "Search text of bookmarks defined for specific files that you choose"))
1515 (define-key icicle-search-bookmarks-menu-map [icicle-search-specific-buffers-bookmark]
1516 '(menu-item "+ Bookmarks for Specific Buffers..." icicle-search-specific-buffers-bookmark
1517 :visible (featurep 'bookmark+)
1518 :help "Search text of bookmarks defined for specific buffers that you choose"))
1519 (define-key icicle-search-bookmarks-menu-map [icicle-search-this-buffer-bookmark]
1520 '(menu-item "+ Bookmarks for This Buffer..." icicle-search-this-buffer-bookmark
1521 :visible (featurep 'bookmark+)
1522 :help "Search text of bookmarks defined for this buffer"))
1523 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-2]
1524 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1525
1526 (define-key icicle-search-bookmarks-menu-map [icicle-search-temporary-bookmark]
1527 '(menu-item "+ Temporary Bookmarks..." icicle-search-temporary-bookmark
1528 :visible (featurep 'bookmark+)
1529 :help "Search text of temporary bookmarks"))
1530 (define-key icicle-search-bookmarks-menu-map [icicle-search-autonamed-bookmark]
1531 '(menu-item "+ Autonamed Bookmarks..." icicle-search-autonamed-bookmark
1532 :visible (featurep 'bookmark+)
1533 :help "Search text of autonamed bookmarks"))
1534 (define-key icicle-search-bookmarks-menu-map [separator-search-bookmarks-1]
1535 '(menu-item "--" nil :visible (featurep 'bookmark+)))
1536
1537 (define-key icicle-search-bookmarks-menu-map [icicle-search-region-bookmark]
1538 '(menu-item "+ Bookmarked Regions..." icicle-search-region-bookmark
1539 :visible (featurep 'bookmark+)
1540 :help "Search bookmarked regions"))
1541 (define-key icicle-search-bookmarks-menu-map [icicle-search-bookmark]
1542 '(menu-item "+ Bookmarks..." icicle-search-bookmark
1543 :help "Search bookmarked text"))
1544 (define-key icicle-search-bookmarks-menu-map [icicle-search-bookmarks-together]
1545 '(menu-item "+ Bookmarks Together..." icicle-search-bookmarks-together
1546 :help "Search text of bookmarks, taken together" :keys "C-u C-`"))
1547
1548 ;; `Search' > `Definitions' menu.
1549 (defvar icicle-search-imenu-menu-map (make-sparse-keymap)
1550 "Icicles `Definitions' submenu of `Search' menu.")
1551 (define-key icicle-search-menu-map [imenu]
1552 (list 'menu-item "Definitions" icicle-search-imenu-menu-map
1553 :visible 'imenu-generic-expression))
1554
1555 (define-key icicle-search-imenu-menu-map [icicle-imenu-key-explicit-map-full]
1556 '(menu-item "+ Key in Map..." icicle-imenu-key-explicit-map-full
1557 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1558 :help "Search a key definition in some map, using `icicle-search'"))
1559 (define-key icicle-search-imenu-menu-map [icicle-imenu-key-implicit-map-full]
1560 '(menu-item "+ Key..." icicle-imenu-key-implicit-map-full
1561 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1562 :help "Search a global key definition using `icicle-search'"))
1563 (define-key icicle-search-imenu-menu-map [icicle-imenu-variable-full]
1564 '(menu-item "+ Variable..." icicle-imenu-variable-full
1565 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1566 :help "Search a variable definition using `icicle-search'"))
1567 (define-key icicle-search-imenu-menu-map [icicle-imenu-user-option-full]
1568 '(menu-item "+ User Option..." icicle-imenu-user-option-full
1569 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1570 :help "Search an option definition using `icicle-search'"))
1571 (define-key icicle-search-imenu-menu-map [icicle-imenu-face-full]
1572 '(menu-item "+ Face..." icicle-imenu-face-full
1573 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1574 :help "Search a face definition using `icicle-search'"))
1575 (define-key icicle-search-imenu-menu-map [icicle-imenu-macro-full]
1576 '(menu-item "+ Macro..." icicle-imenu-macro-full
1577 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1578 :help "Search a Lisp macro definition using `icicle-search'"))
1579 (define-key icicle-search-imenu-menu-map [icicle-imenu-non-interactive-function-full]
1580 '(menu-item "+ Non-Interactive Function..." icicle-imenu-non-interactive-function-full
1581 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1582 :help "Search a non-command function definition using `icicle-search'"))
1583 (define-key icicle-search-imenu-menu-map [icicle-imenu-command-full]
1584 '(menu-item "+ Command..." icicle-imenu-command-full
1585 :enable (and imenu-generic-expression (eq major-mode 'emacs-lisp-mode))
1586 :help "Search a command definition using `icicle-search'"))
1587 (define-key icicle-search-imenu-menu-map [icicle-imenu-full]
1588 '(menu-item "+ Any..." icicle-imenu-full
1589 :enable imenu-generic-expression :help "Search a definition using `icicle-search'"))
1590
1591
1592 ;; `Frames' ----------------------------------------------------
1593 (cond ((and (not icicle-touche-pas-aux-menus-flag)
1594 (boundp 'menu-bar-frames-menu)) ; Use `Frames' menu, defined in `menu-bar+.el'.
1595 (defvar icicle-frames-menu-map (make-sparse-keymap)
1596 "`Frames' > `Icicles' submenu.")
1597 (define-key menu-bar-frames-menu [icicles]
1598 (list 'menu-item "Icicles" icicle-frames-menu-map :visible 'icicle-mode)))
1599 (t
1600 (defvar icicle-frames-menu-map (make-sparse-keymap)
1601 "`Icicles' > `Frames' submenu.")
1602 (define-key icicle-menu-map [frames]
1603 (list 'menu-item "Frames" icicle-frames-menu-map))))
1604
1605 (define-key icicle-frames-menu-map [icicle-font]
1606 '(menu-item "+ Change Font of Frame..." icicle-font
1607 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1608 :help "Change font of current frame."))
1609 (define-key icicle-frames-menu-map [icicle-frame-fg]
1610 '(menu-item "+ Change Foreground of Frame..." icicle-frame-fg
1611 :visible (fboundp 'icicle-frame-fg) ; Requires `hexrgb.el'
1612 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1613 :help "Change foreground of current frame."))
1614 (define-key icicle-frames-menu-map [icicle-frame-bg]
1615 '(menu-item "+ Change Background of Frame..." icicle-frame-bg
1616 :visible (fboundp 'icicle-frame-bg) ; Requires `hexrgb.el'
1617 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1618 :help "Change background of current frame."))
1619
1620
1621 ;; `Bookmarks' ---------------------------------------------------
1622 (require 'bookmark) ; `bookmark-buffer-name' is not autoloaded.
1623 (cond ((not icicle-touche-pas-aux-menus-flag)
1624 (cond ((boundp 'bmkp-jump-menu)
1625
1626 ;; Bookmark+: `Bookmarks' > `Jump To'.
1627 ;; Use `copy-keymap' so that turning off Icicle mode restores the ordinary commands.
1628 (defvar icicle-bookmark-menu-map (copy-keymap bmkp-jump-menu)
1629 "`Bookmarks' > `Jump To' > `Icicles' submenu.")
1630
1631 ;; Bookmark+: `Bookmarks' > `Jump To' > `With Tags'.
1632 ;; Use `copy-keymap' so that turning off Icicle mode restores the ordinary commands.
1633 (defvar icicle-bookmark-with-tags-menu-map (copy-keymap bmkp-jump-tags-menu)
1634 "`Bookmarks' > `Jump To' > `With Tags' > `Icicles' submenu."))
1635 (t ; Vanilla `bookmark.el' only, not Bookmark+.
1636 (defvar icicle-bookmark-menu-map (make-sparse-keymap)
1637 "`Bookmarks' > `Icicles' submenu.")
1638 (define-key menu-bar-bookmark-map [icicles]
1639 (list 'menu-item "Icicles" icicle-bookmark-menu-map :visible 'icicle-mode))
1640 (defvar icicle-bookmark-with-tags-menu-map (make-sparse-keymap)
1641 "For tags commands on `icicle-bookmark-menu-map'.")
1642 (setq icicle-bookmark-with-tags-menu-map icicle-bookmark-menu-map))))
1643 (t
1644 (defvar icicle-bookmark-menu-map (make-sparse-keymap)
1645 "`Icicles' > `Bookmarks' submenu.")
1646 (define-key icicle-menu-map [bookmarks]
1647 (list 'menu-item "Bookmarks" icicle-bookmark-menu-map))
1648 (defvar icicle-bookmark-with-tags-menu-map (make-sparse-keymap)
1649 "For tags commands on `icicle-bookmark-menu-map'.")
1650 (setq icicle-bookmark-with-tags-menu-map icicle-bookmark-menu-map)))
1651
1652 (when (featurep 'bookmark+)
1653 (define-key icicle-bookmark-with-tags-menu-map
1654 [bmkp-file-this-dir-all-tags-regexp-jump-other-window]
1655 '(menu-item "File This Dir, All Tags Matching Regexp..."
1656 icicle-bookmark-file-this-dir-all-tags-regexp-other-window
1657 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1658 :help "Jump to a file bookmark for this dir, where each tag matches a regexp"))
1659 (define-key icicle-bookmark-with-tags-menu-map
1660 [bmkp-file-this-dir-some-tags-regexp-jump-other-window]
1661 '(menu-item "File This Dir, Any Tag Matching Regexp..."
1662 icicle-bookmark-file-this-dir-some-tags-regexp-other-window
1663 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1664 :help "Jump to a file bookmark for this dir, where some tag matches a regexp"))
1665 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-this-dir-all-tags-jump-other-window]
1666 '(menu-item "File This Dir, All Tags in Set..."
1667 icicle-bookmark-file-this-dir-all-tags-other-window
1668 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1669 :help "Jump to a file bookmark for this dir, which has all of a set of tags"))
1670 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-this-dir-some-tags-jump-other-window]
1671 '(menu-item "File This Dir, Any Tag in Set..."
1672 icicle-bookmark-file-this-dir-some-tags-other-window
1673 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1674 :help "Jump to a file bookmark for this dir, which has some of a set of tags"))
1675 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-all-tags-regexp-jump-other-window]
1676 '(menu-item "File, All Tags Matching Regexp..."
1677 icicle-bookmark-file-all-tags-regexp-other-window
1678 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1679 :help "Jump to a file or dir bookmark where each tag matches a regexp"))
1680 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-some-tags-regexp-jump-other-window]
1681 '(menu-item "File, Any Tag Matching Regexp..."
1682 icicle-bookmark-file-some-tags-regexp-other-window
1683 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1684 :help "Jump to a file or dir bookmark where at least one tag matches a regexp"))
1685 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-all-tags-jump-other-window]
1686 '(menu-item "File, All Tags in Set..." icicle-bookmark-file-all-tags-other-window
1687 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1688 :help "Jump to a file or dir bookmark that has all of a set of tags"))
1689 (define-key icicle-bookmark-with-tags-menu-map [bmkp-file-some-tags-jump-other-window]
1690 '(menu-item "File, Any Tag in Set..." icicle-bookmark-file-some-tags-other-window
1691 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1692 :help "Jump to a file or dir bookmark that has some of a set of tags"))
1693 (define-key icicle-bookmark-with-tags-menu-map [bmkp-autofile-all-tags-regexp-jump-other-window]
1694 '(menu-item "Autofile, All Tags Matching Regexp..."
1695 icicle-bookmark-autofile-all-tags-regexp-other-window
1696 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1697 :help "Jump to an autofile bookmark where each tag matches a regexp"))
1698 (define-key icicle-bookmark-with-tags-menu-map [bmkp-autofile-some-tags-regexp-jump-other-window]
1699 '(menu-item "Autofile, Any Tag Matching Regexp..."
1700 icicle-bookmark-autofile-some-tags-regexp-other-window
1701 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1702 :help "Jump to an autofile bookmark where at least one tag matches a regexp"))
1703 (define-key icicle-bookmark-with-tags-menu-map [bmkp-autofile-all-tags-jump-other-window]
1704 '(menu-item "Autofile, All Tags in Set..."
1705 icicle-bookmark-autofile-all-tags-other-window
1706 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1707 :help "Jump to an autofile bookmark that has all of a set of tags"))
1708 (define-key icicle-bookmark-with-tags-menu-map [bmkp-autofile-some-tags-jump-other-window]
1709 '(menu-item "Autofile, Any Tag in Set..."
1710 icicle-bookmark-autofile-some-tags-other-window
1711 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1712 :help "Jump to an autofile bookmark that has some of a set of tags"))
1713 (define-key icicle-bookmark-with-tags-menu-map [bmkp-all-tags-regexp-jump-other-window]
1714 '(menu-item "All Tags Matching Regexp..." icicle-bookmark-all-tags-regexp-other-window
1715 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1716 :help "Jump to a bookmark that has each tag matching a regexp that you enter"))
1717 (define-key icicle-bookmark-with-tags-menu-map [bmkp-some-tags-regexp-jump-other-window]
1718 '(menu-item "Any Tag Matching Regexp..." icicle-bookmark-some-tags-regexp-other-window
1719 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1720 :help "Jump to a bookmark with at least one tag matching a regexp"))
1721 (define-key icicle-bookmark-with-tags-menu-map [bmkp-all-tags-jump-other-window]
1722 '(menu-item "All Tags in Set..." icicle-bookmark-all-tags-other-window
1723 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1724 :help "Jump to a bookmark that has all of a set of tags that you enter"))
1725 (define-key icicle-bookmark-with-tags-menu-map [bmkp-some-tags-jump-other-window]
1726 '(menu-item "Any Tag in Set..." icicle-bookmark-some-tags-other-window
1727 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1728 :help "Jump to a bookmark that has some of a set of tags that you enter"))
1729 (define-key icicle-bookmark-menu-map [bmkp-temporary-jump-other-window]
1730 '(menu-item "+ Jump to Temporary Bookmark..." icicle-bookmark-temporary-other-window
1731 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1732 :help "Jump to a temporary bookmark"))
1733 (define-key icicle-bookmark-menu-map [bmkp-autofile-jump-other-window]
1734 '(menu-item "+ Jump to Autofile Bookmark..." icicle-bookmark-autofile-other-window
1735 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1736 :help "Jump to an autofile bookmark"))
1737 (define-key icicle-bookmark-menu-map [bmkp-autonamed-this-buffer-jump]
1738 '(menu-item "+ Jump to Autonamed Bookmark for This Buffer..."
1739 icicle-bookmark-autonamed-this-buffer-other-window
1740 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1741 :help "Jump to an autonamed bookmark for this buffer"))
1742 (define-key icicle-bookmark-menu-map [bmkp-autonamed-jump-other-window]
1743 '(menu-item "+ Jump to Autonamed Bookmark..."
1744 icicle-bookmark-autonamed-other-window
1745 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1746 :help "Jump to an autonamed bookmark"))
1747 (define-key icicle-bookmark-menu-map [bmkp-specific-files-jump-other-window]
1748 '(menu-item "+ Jump to Bookmark for Specific Files..."
1749 icicle-bookmark-specific-files-other-window
1750 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1751 :help "Jump to bookmarks for specific files that you choose"))
1752 (define-key icicle-bookmark-menu-map [bmkp-specific-buffers-jump-other-window]
1753 '(menu-item "+ Jump to Bookmark for Specific Buffers..."
1754 icicle-bookmark-specific-buffers-other-window
1755 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1756 :help "Jump to bookmarks for specific buffers that you choose"))
1757 (define-key icicle-bookmark-menu-map [bmkp-this-buffer-jump]
1758 '(menu-item "+ Jump to Bookmark for This Buffer..."
1759 icicle-bookmark-this-buffer-other-window
1760 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1761 :help "Jump to a bookmark for this buffer"))
1762 (define-key icicle-bookmark-menu-map [bmkp-url-jump-other-window]
1763 '(menu-item "+ Jump to URL Bookmark..." icicle-bookmark-url-other-window
1764 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1765 :help "Jump to a URL bookmark"))
1766 (define-key icicle-bookmark-menu-map [bmkp-gnus-jump-other-window]
1767 '(menu-item "+ Jump to Gnus Bookmark..." icicle-bookmark-gnus-other-window
1768 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1769 :help "Jump to a Gnus bookmark"))
1770 (define-key icicle-bookmark-menu-map [bmkp-man-jump-other-window]
1771 '(menu-item "+ Jump to `man' Bookmark..." icicle-bookmark-man-other-window
1772 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1773 :help "Jump to a `man'-page bookmark"))
1774 (define-key icicle-bookmark-menu-map [bmkp-info-jump-other-window]
1775 '(menu-item "+ Jump to Info Bookmark..." icicle-bookmark-info-other-window
1776 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1777 :help "Jump to an Info bookmark"))
1778 (define-key icicle-bookmark-menu-map [bmkp-image-jump-other-window]
1779 '(menu-item "+ Jump to Image Bookmark..."
1780 icicle-bookmark-image-other-window
1781 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1782 :help "Jump to an image bookmark"))
1783 (define-key icicle-bookmark-menu-map [bmkp-non-file-jump-other-window]
1784 '(menu-item "+ Jump to Buffer (Non-File) Bookmark..."
1785 icicle-bookmark-non-file-other-window
1786 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1787 :help "Jump to a buffer (i.e., a non-file) bookmark"))
1788 (define-key icicle-bookmark-menu-map [bmkp-region-jump-other-window]
1789 '(menu-item "+ Jump to Region Bookmark..." icicle-bookmark-region-other-window
1790 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1791 :help "Jump to a bookmark and activate its recorded region"))
1792 (define-key icicle-bookmark-menu-map [bmkp-remote-file-jump-other-window]
1793 '(menu-item "+ Jump to Remote-File Bookmark..."
1794 icicle-bookmark-remote-file-other-window
1795 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1796 :help "Jump to a remote-file bookmark"))
1797 (define-key icicle-bookmark-menu-map [bmkp-local-file-jump-other-window]
1798 '(menu-item "+ Jump to Local-File Bookmark..."
1799 icicle-bookmark-local-file-other-window
1800 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1801 :help "Jump to a local-file bookmark"))
1802 (define-key icicle-bookmark-menu-map [bmkp-file-jump-other-window]
1803 '(menu-item "+ Jump to File Bookmark..." icicle-bookmark-file-other-window
1804 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1805 :help "Jump to a file bookmark"))
1806 (define-key icicle-bookmark-menu-map [bmkp-dired-jump-other-window]
1807 '(menu-item "+ Jump to Dired Bookmark..." icicle-bookmark-dired-other-window
1808 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1809 :help "Jump to a Dired bookmark"))
1810 (define-key icicle-bookmark-menu-map [bmkp-bookmark-file-jump]
1811 '(menu-item "+ Jump to Bookmark-File Bookmark..."
1812 icicle-bookmark-bookmark-file
1813 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1814 :help "Jump to a bookmark-file bookmark"))
1815 (define-key icicle-bookmark-menu-map [bmkp-bookmark-list-jump]
1816 '(menu-item "+ Jump to Bookmark-List Bookmark..."
1817 icicle-bookmark-bookmark-list
1818 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1819 :help "Jump to a bookmark-list bookmark"))
1820 (define-key icicle-bookmark-menu-map [bmkp-desktop-jump]
1821 '(menu-item "+ Jump to Desktop Bookmark..." icicle-bookmark-desktop
1822 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1823 :help "Jump to an Emacs desktop bookmark")))
1824
1825 (define-key icicle-bookmark-menu-map [bookmark-jump-other-window]
1826 '(menu-item "+ Jump to Bookmark..." icicle-bookmark-other-window
1827 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1828 :help "Jump to a bookmark (C-u: reverse `icicle-bookmark-refresh-cache-flag')"))
1829 (define-key icicle-bookmark-menu-map [bookmark-jump]
1830 '(menu-item "+ Jump to Bookmark (Same Window)..." icicle-bookmark
1831 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1832 :help "Jump to a bookmark (C-u: reverse `icicle-bookmark-refresh-cache-flag')"))
1833
1834
1835 ;; `Edit' --------------------------------------------------------
1836 (cond ((not icicle-touche-pas-aux-menus-flag)
1837 (defvar icicle-edit-menu-map (make-sparse-keymap)
1838 "`Edit' > `Icicles' submenu.")
1839 (define-key menu-bar-edit-menu [icicles]
1840 (list 'menu-item "Icicles" icicle-edit-menu-map :visible 'icicle-mode)))
1841 (t
1842 (defvar icicle-edit-menu-map (make-sparse-keymap)
1843 "`Icicles' > `Edit' submenu.")
1844 (define-key icicle-menu-map [Edit]
1845 (list 'menu-item "Edit" icicle-edit-menu-map))))
1846
1847 (define-key icicle-edit-menu-map [icicle-complete-thesaurus-entry]
1848 '(menu-item "Complete with Thesaurus..." icicle-complete-thesaurus-entry
1849 :enable (and (not buffer-read-only) (boundp 'synonyms-obarray))
1850 :help "Complete a word to an entry from a thesaurus"))
1851 (define-key icicle-edit-menu-map [icicle-insert-thesaurus-entry]
1852 '(menu-item "+ Insert Thesaurus Entry..." icicle-insert-thesaurus-entry
1853 :enable (and (not buffer-read-only) (boundp 'synonyms-obarray))
1854 :help "Insert an entry from a thesaurus"))
1855 (define-key icicle-edit-menu-map [icicle-completing-yank]
1856 '(menu-item "+ Paste Copied Text..." icicle-completing-yank
1857 :enable (not buffer-read-only) :keys "C-- C-y"
1858 :help "Yank an entry from the `kill-ring', choosing it using completion"))
1859
1860
1861 ;; `File' --------------------------------------------------------
1862 (cond ((not icicle-touche-pas-aux-menus-flag)
1863 (defvar icicle-file-menu-map (make-sparse-keymap)
1864 "`File' > `Icicles' submenu.")
1865 (define-key menu-bar-file-menu [icicles]
1866 (list 'menu-item "Icicles" icicle-file-menu-map :visible 'icicle-mode)))
1867 (t
1868 (defvar icicle-file-menu-map (make-sparse-keymap)
1869 "`Icicles' > `File' submenu.")
1870 (define-key icicle-menu-map [file]
1871 (list 'menu-item "File" icicle-file-menu-map :visible 'icicle-mode))))
1872
1873 (define-key icicle-file-menu-map [icicle-delete-file]
1874 '(menu-item "+ Delete File..." icicle-delete-file :visible icicle-mode
1875 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1876 :help "Delete a file or directory"))
1877 (when (featurep 'recentf)
1878 (define-key icicle-file-menu-map [icicle-remove-file-from-recentf-list]
1879 '(menu-item "+ Remove from Recent Files List..."
1880 icicle-remove-file-from-recentf-list :visible icicle-mode
1881 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1882 :help "Remove file from `recentf-list' - the list of recently used files"))
1883 (define-key icicle-file-menu-map [icicle-recent-file-other-window]
1884 '(menu-item "+ Open Recent File (Other Window)..."
1885 icicle-recent-file-other-window :visible icicle-mode
1886 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1887 :help "Open a recently used file in another window"))
1888 (define-key icicle-file-menu-map [icicle-recent-file]
1889 '(menu-item "+ Open Recent File..." icicle-recent-file :visible icicle-mode
1890 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1891 :help "Open a recently used file")))
1892 (define-key icicle-file-menu-map [icicle-dired-saved-file-candidates-other-window]
1893 '(menu-item "Open Dired for Chosen Files..."
1894 icicle-dired-saved-file-candidates-other-window :visible icicle-mode
1895 :enable (and icicle-saved-completion-candidates
1896 (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
1897 :help "Open Dired on a set of files & directories of your choice"))
1898 (define-key icicle-file-menu-map [icicle-dired-project-other-window]
1899 '(menu-item "Open Dired for Project..." icicle-dired-project-other-window
1900 :visible icicle-mode
1901 :enable (and icicle-saved-completion-sets
1902 (not (window-minibuffer-p (frame-selected-window menu-updating-frame))))
1903 :help "Open Dired on a saved project (in another window)"))
1904 (define-key icicle-file-menu-map [icicle-locate-file-other-window]
1905 '(menu-item "+ Open File Under Directory (Other Window)..."
1906 icicle-locate-file-other-window :visible icicle-mode
1907 :help "Visit a file within a directory or its subdirectories, in another window"))
1908 (define-key icicle-file-menu-map [icicle-locate-file]
1909 '(menu-item "+ Open File Under Directory..." icicle-locate-file :visible icicle-mode
1910 :help "Visit a file within a directory or its subdirectories"))
1911 (define-key icicle-file-menu-map [icicle-file-other-window]
1912 '(menu-item "+ Open File or Directory (Other Window)..." icicle-file-other-window
1913 :visible icicle-mode
1914 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1915 :help "Visit a file or directory in another window"))
1916 (define-key icicle-file-menu-map [icicle-file]
1917 '(menu-item "+ Open File or Directory..." icicle-file :visible icicle-mode
1918 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1919 :help "Visit a file or directory (C-u absolute, C-- absolute by date)"))
1920
1921
1922 ;; `Buffers' -----------------------------------------------------
1923 (cond ((not icicle-touche-pas-aux-menus-flag)
1924 (cond ((boundp 'menu-bar-buffers-menu-command-entries) ; Emacs 22+.
1925 (defvar icicle-buffers-menu-map (make-sparse-keymap)
1926 "`Buffers' > `Icicles' submenu.")
1927 (setq menu-bar-buffers-menu-command-entries
1928 (cons (list 'Icicles 'menu-item "Icicles" icicle-buffers-menu-map)
1929 menu-bar-buffers-menu-command-entries)))
1930 (t
1931 (defvar icicle-buffers-menu-map (make-sparse-keymap)
1932 "`File' > `Icicles' > `Buffers' submenu.")
1933 (define-key icicle-file-menu-map [buffers]
1934 (list 'menu-item "Buffers" icicle-buffers-menu-map)))))
1935 (t
1936 (defvar icicle-buffers-menu-map (make-sparse-keymap)
1937 "`Icicles' > `Buffers' submenu.")
1938 (define-key icicle-menu-map [buffers]
1939 (list 'menu-item "Buffers" icicle-buffers-menu-map))))
1940
1941 (define-key icicle-buffers-menu-map [icicle-buffer-list]
1942 '(menu-item "+ Buffer List..." icicle-buffer-list
1943 :help "Choose a list of buffer names"))
1944 (define-key icicle-buffers-menu-map [icicle-remove-buffer-config]
1945 '(menu-item "+ Remove Buffer Configuration..." icicle-remove-buffer-config
1946 :enable icicle-buffer-configs
1947 :help "Remove buffer configuration from `icicle-buffer-configs'"))
1948 (define-key icicle-buffers-menu-map [icicle-add-buffer-config]
1949 '(menu-item "New Buffer Configuration..." icicle-add-buffer-config
1950 :help "Add buffer configuration to `icicle-buffer-configs'"))
1951 (define-key icicle-buffers-menu-map [icicle-buffer-config]
1952 '(menu-item "+ Choose Buffer Configuration..." icicle-buffer-config
1953 :enable icicle-buffer-configs
1954 :help "Choose a configuration of user options for `icicle-buffer'"))
1955 (define-key icicle-buffers-menu-map [icicle-remove-buffer-candidate]
1956 '(menu-item "+ Don't Always Include Buffer..." icicle-remove-buffer-candidate
1957 :enable icicle-buffer-extras
1958 :help "Remove buffer as an always-show completion candidate"))
1959 (define-key icicle-buffers-menu-map [icicle-add-buffer-candidate]
1960 '(menu-item "+ Always Include Buffer..." icicle-add-buffer-candidate
1961 :help "Add buffer as an always-show completion candidate"))
1962 (define-key icicle-buffers-menu-map [icicle-kill-buffer]
1963 '(menu-item "+ Kill Buffer..." icicle-kill-buffer
1964 :help "Kill a buffer (C-0: same-mode, C-9: file, C-- this-frame"))
1965 (define-key icicle-buffers-menu-map [icicle-insert-buffer]
1966 '(menu-item "+ Insert Buffer..." icicle-insert-buffer
1967 :help "Multi-command version of `insert-buffer'"))
1968 (define-key icicle-buffers-menu-map [icicle-delete-windows]
1969 '(menu-item "+ Delete Windows on Buffer..." icicle-delete-windows :keys "C-u C-x 0"
1970 :help "Delete windows showing a buffer, anywhere"))
1971 (define-key icicle-buffers-menu-map [icicle-buffer-other-window]
1972 '(menu-item "+ Switch to Buffer (Other Window)..." icicle-buffer-other-window
1973 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))))
1974 (define-key icicle-buffers-menu-map [icicle-buffer]
1975 '(menu-item "+ Switch to Buffer..." icicle-buffer
1976 :enable (not (window-minibuffer-p (frame-selected-window menu-updating-frame)))
1977 :help "Switch to a buffer (C-0: same mode, C-9: file buffer, C--: same frame"))
1978
1979
1980 ;; `Dired Marked' ------------------------------------------------
1981 (cond ((not icicle-touche-pas-aux-menus-flag)
1982 (defvar icicle-dired-multiple-menu-map (make-sparse-keymap)
1983 "`Icicles' submenu for Dired's `Multiple' (or `Operate') menu.")
1984 (if (boundp 'diredp-menu-bar-operate-menu) ; In `dired+.el'.
1985 (define-key diredp-menu-bar-operate-menu [icicles]
1986 (list 'menu-item "Icicles" icicle-dired-multiple-menu-map :visible 'icicle-mode))
1987 (define-key dired-mode-map [menu-bar operate icicles]
1988 (list 'menu-item "Icicles" icicle-dired-multiple-menu-map :visible 'icicle-mode)))
1989
1990 (when (boundp 'diredp-menu-bar-recursive-marked-menu) ; Defined in `dired+.el'
1991 (defvar icicle-dired-recursive-marked-menu-map (make-sparse-keymap)
1992 "`Icicles' submenu for Dired+'s `Multiple' > `Marked Here and Below' menu.")
1993 (define-key diredp-menu-bar-recursive-marked-menu [icicles]
1994 (list 'menu-item "Icicles" icicle-dired-recursive-marked-menu-map
1995 :visible 'icicle-mode))))
1996
1997 (t
1998 (defvar icicle-dired-multiple-menu-map (make-sparse-keymap)
1999 "`Icicles' > `Dired Marked' submenu, in Dired mode.")
2000 (define-key icicle-menu-map [dired-marked]
2001 (list 'menu-item "Dired Marked" icicle-dired-multiple-menu-map
2002 :visible '(eq major-mode 'dired-mode)))
2003
2004 (when (boundp 'diredp-menu-bar-recursive-marked-menu) ; Defined in `dired+.el'
2005 (defvar icicle-dired-recursive-marked-menu-map (make-sparse-keymap)
2006 "`Icicles' > `Dired Marked Here and Below' menu.")
2007 (define-key icicle-dired-multiple-menu-map [here-and-below]
2008 (list 'menu-item "Here and Below" icicle-dired-recursive-marked-menu-map
2009 :visible '(eq major-mode 'dired-mode))))))
2010
2011 (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked-as-project]
2012 '(menu-item "Save Names Persistently (Project)" icicle-dired-save-marked-as-project
2013 :help "Save the marked names as a persistent set"))
2014 (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked-to-variable]
2015 '(menu-item "Save Names to Variable" icicle-dired-save-marked-to-variable
2016 :help "Save the marked names to a variable"))
2017 (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked-more]
2018 '(menu-item "Add to Saved Candidates" icicle-dired-save-marked-more
2019 :help "Add the marked names to the saved completion-candidates set"))
2020 (define-key icicle-dired-multiple-menu-map [icicle-dired-save-marked]
2021 '(menu-item "Save Names as Completion Candidates" icicle-dired-save-marked
2022 :help "Save the marked names as a set of completion candidates"))
2023 (define-key icicle-dired-multiple-menu-map [separator-dired-multiple-1] '(menu-item "--" nil))
2024 (define-key icicle-dired-multiple-menu-map [icicle-search-dired-marked]
2025 '(menu-item "Icicles Search (and Replace)..." icicle-search-dired-marked
2026 :help "Search the marked files"
2027 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2028 (dired-get-marked-files nil nil (lambda (file) (not (file-directory-p file))))
2029 (error nil))))
2030 (define-key icicle-dired-multiple-menu-map [icicle-occur-dired-marked]
2031 '(menu-item "Icicles Occur..." icicle-occur-dired-marked
2032 :help "Search lines of the marked files"
2033 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2034 (dired-get-marked-files nil nil (lambda (file) (not (file-directory-p file))))
2035 (error nil))))
2036 (define-key icicle-dired-multiple-menu-map [icicle-visit-marked-file-of-content-other-window]
2037 '(menu-item "Open File of Content (Other Window)"
2038 icicle-visit-marked-file-of-content-other-window
2039 :help "Visit a marked file whose content matches a regexp, in another window"
2040 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2041 (dired-get-marked-files nil nil (lambda (file) (not (file-directory-p file))))
2042 (error nil))))
2043 (define-key icicle-dired-multiple-menu-map [icicle-visit-marked-file-of-content]
2044 '(menu-item "Open File of Content" icicle-visit-marked-file-of-content
2045 :help "Visit a marked file whose content matches a regexp"
2046 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2047 (dired-get-marked-files nil nil (lambda (file) (not (file-directory-p file))))
2048 (error nil))))
2049
2050 (when (boundp 'diredp-menu-bar-recursive-marked-menu) ; Defined in `dired+.el'
2051 (define-key icicle-dired-recursive-marked-menu-map
2052 [icicle-dired-save-marked-to-fileset-recursive]
2053 '(menu-item "Save Names to Fileset" icicle-dired-save-marked-to-fileset-recursive
2054 :help "Save marked names, including those in marked subdirs, to an Emacs fileset"))
2055 (define-key icicle-dired-recursive-marked-menu-map
2056 [icicle-dired-save-marked-to-cache-file-recursive]
2057 '(menu-item "Save Names to Cache File" icicle-dired-save-marked-to-cache-file-recursive
2058 :help "Save marked names, including those in marked subdirs, to an Icicles cache file"))
2059 (define-key icicle-dired-recursive-marked-menu-map
2060 [icicle-dired-save-marked-to-variable-recursive]
2061 '(menu-item "Save Names to Variable" icicle-dired-save-marked-to-variable-recursive
2062 :help "Save marked names, including those in marked subdirs, to a variable"))
2063 (define-key icicle-dired-recursive-marked-menu-map [icicle-dired-save-marked-more-recursive]
2064 '(menu-item "Add to Saved Candidates" icicle-dired-save-marked-more-recursive
2065 :help "Add marked files, including those in marked subdirs, to saved candidates"))
2066 (define-key icicle-dired-recursive-marked-menu-map [icicle-dired-save-marked-recursive]
2067 '(menu-item "Save Names as Completion Candidates" icicle-dired-save-marked-recursive
2068 :help "Save the marked file names in Dired, including those in marked subdirs"))
2069 (define-key icicle-dired-recursive-marked-menu-map [separator-dired-recursive-1]
2070 '(menu-item "--" nil))
2071 (define-key icicle-dired-recursive-marked-menu-map [icicle-search-dired-marked-recursive]
2072 '(menu-item "Icicles Search (and Replace)..." icicle-search-dired-marked-recursive
2073 :help "Search the marked files, including those in marked subdirs"
2074 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2075 (let ((files (dired-get-marked-files nil nil nil 'DISTINGUISH-ONE-MARKED)))
2076 (and files (cdr files))) ; Must have at least one actual mark.
2077 (error nil))))
2078 (define-key icicle-dired-recursive-marked-menu-map [icicle-occur-dired-marked-recursive]
2079 '(menu-item "Icicles Occur..." icicle-occur-dired-marked-recursive
2080 :help "Search lines of the marked files, including those in marked subdirs"
2081 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2082 (let ((files (dired-get-marked-files nil nil nil 'DISTINGUISH-ONE-MARKED)))
2083 (and files (cdr files))) ; Must have at least one actual mark.
2084 (error nil))))
2085 (define-key icicle-dired-recursive-marked-menu-map
2086 [icicle-visit-marked-file-of-content-recursive-other-window]
2087 '(menu-item "Open File of Content (Other Window)"
2088 icicle-visit-marked-file-of-content-recursive-other-window
2089 :help "Visit marked file, including in marked subdir, whose content matches, in other window"
2090 ;; Do not test with `diredp-get-files' - no need to, and too slow
2091 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2092 (let ((files (dired-get-marked-files nil nil nil 'DISTINGUISH-ONE-MARKED)))
2093 (and files (cdr files))) ; Must have at least one actual mark.
2094 (error nil))))
2095 (define-key icicle-dired-recursive-marked-menu-map
2096 [icicle-visit-marked-file-of-content-recursive]
2097 '(menu-item "Open File of Content" icicle-visit-marked-file-of-content-recursive
2098 :help "Visit marked file, including in a marked subdir, whose content matches"
2099 ;; Do not test with `diredp-get-files' - no need to, and too slow
2100 :enable (condition-case nil ; Avoid an Emacs 22 error with cursor on ./ or ../
2101 (let ((files (dired-get-marked-files nil nil nil 'DISTINGUISH-ONE-MARKED)))
2102 (and files (cdr files))) ; Must have at least one actual mark.
2103 (error nil)))))
2104
2105 ;; `Dired Dirs' ------------------------------------------------
2106 (cond ((not icicle-touche-pas-aux-menus-flag)
2107 (defvar icicle-dired-dir-menu-map (make-sparse-keymap)
2108 "`Icicles' submenu for Dired's `Dir' (or `Subdir') menu.")
2109 (if (boundp 'diredp-menu-bar-subdir-menu) ; In `dired+.el'.
2110 (define-key diredp-menu-bar-subdir-menu [icicles]
2111 (list 'menu-item "Icicles" icicle-dired-dir-menu-map :visible 'icicle-mode))
2112 (define-key dired-mode-map [menu-bar subdir icicles]
2113 (list 'menu-item "Icicles" icicle-dired-dir-menu-map :visible 'icicle-mode))))
2114 (t
2115 (defvar icicle-dired-dir-menu-map (make-sparse-keymap)
2116 "`Icicles' > `Dired Dirs' submenu, in Dired mode.")
2117 (define-key icicle-menu-map [dired-dirs]
2118 (list 'menu-item "Dired Dirs" icicle-dired-dir-menu-map
2119 :visible '(eq major-mode 'dired-mode)))))
2120
2121 (when (fboundp 'icicle-dired-insert-as-subdir) ; Emacs 21+
2122 (define-key icicle-dired-dir-menu-map [icicle-dired-insert-as-subdir]
2123 '(menu-item "Insert Dir into Ancestor Dired..." icicle-dired-insert-as-subdir
2124 :help "Insert a directory into a Dired ancestor directory listing")))
2125 (define-key icicle-dired-dir-menu-map [icicle-dired-saved-file-candidates-other-window]
2126 '(menu-item "Open Dired for Chosen Files..."
2127 icicle-dired-saved-file-candidates-other-window
2128 :enable icicle-saved-completion-candidates
2129 :help "Open Dired on a set of files & directories of your choice"))
2130 (define-key icicle-dired-dir-menu-map [icicle-dired-project-other-window]
2131 '(menu-item "Open Dired for Project..." icicle-dired-project-other-window
2132 :enable icicle-saved-completion-sets
2133 :help "Open Dired on a saved project"))
2134
2135
2136 ;; `Info' --------------------------------------------------------
2137 (require 'info) ; `Info-mode-menu' is not preloaded.
2138 (cond ((not icicle-touche-pas-aux-menus-flag)
2139 (defvar icicle-info-menu-map (make-sparse-keymap)
2140 "`Info' > `Icicles' submenu.")
2141 (define-key Info-mode-menu [icicles]
2142 (list 'menu-item "Icicles" icicle-info-menu-map :visible 'icicle-mode)))
2143 (t
2144 (defvar icicle-info-menu-map (make-sparse-keymap)
2145 "`Icicles' > `Info' submenu, in Info mode.")
2146 (define-key icicle-menu-map [info]
2147 (list 'menu-item "Info Mode" icicle-info-menu-map :visible '(eq major-mode 'Info-mode)))))
2148
2149 (when (fboundp 'icicle-Info-virtual-book)
2150 (define-key icicle-info-menu-map [icicle-Info-virtual-book]
2151 '(menu-item "Virtual Book" icicle-Info-virtual-book
2152 :help "Open Info on a virtual book of saved Info nodes")))
2153 (define-key icicle-info-menu-map [icicle-Info-goto-node]
2154 '(menu-item "+ Go to Node..." icicle-Info-goto-node
2155 :help "Go to an Info node by name"))
2156 (define-key icicle-info-menu-map [icicle-Info-menu]
2157 '(menu-item "+ Go to Menu Node..." icicle-Info-menu
2158 :help "Choose a menu node by name"))
2159 (define-key icicle-info-menu-map [icicle-Info-index]
2160 '(menu-item "+ Look Up in Index..." icicle-Info-index
2161 :help "Go to an indexed topic - multi-command version of `Info-index'"))
2162
2163
2164 ;; `Bookmark+', in buffer `*Bookmark List*' ----------------------
2165 ;;
2166 ;; Do this regardless of `icicle-touche-pas-aux-menus-flag', since `Bookmark+' is my menu.
2167 (when (boundp 'bmkp-bmenu-menubar-menu) ; In `bookmark+-bmu.el'.
2168 (defvar icicle-bookmark+-menu-map (make-sparse-keymap)
2169 "`Bookmark+' > `Icicles' submenu.")
2170 (define-key bmkp-bmenu-menubar-menu [icicles]
2171 (list 'menu-item "Icicles" icicle-bookmark+-menu-map :visible 'icicle-mode))
2172 (define-key icicle-bookmark+-menu-map [icicle-search-bookmark-list-marked]
2173 '(menu-item "Search & Replace in Marked Files..." icicle-search-bookmark-list-marked
2174 :help "Search the files of the marked bookmarks"))
2175 (define-key icicle-bookmark+-menu-map [icicle-bookmark-save-marked-files-more]
2176 '(menu-item "Save File Names of Marked as More Candidates..."
2177 icicle-bookmark-save-marked-files-more
2178 :help "Add file names of marked bookmarks to saved file-completion candidates"))
2179 (define-key icicle-bookmark+-menu-map [icicle-bookmark-save-marked-files]
2180 '(menu-item "Save File Names of Marked as Candidates..." icicle-bookmark-save-marked-files
2181 :help "Save file names of marked bookmarks as a set of file-completion candidates"))
2182 (define-key icicle-bookmark+-menu-map [icicle-bookmark-save-marked-files-as-project]
2183 '(menu-item "Save Marked as Project" icicle-bookmark-save-marked-files-as-project
2184 :help "Save the file names of the marked bookmarks as a persistent set")))
2185
2186 )
2187
2188
2189 ;; Install `Icicles' menu-bar menu.
2190 (define-key icicle-mode-map [menu-bar icicles] (cons "Icicles" icicle-menu-map))
2191
2192 ;; Optional `icicle-mode-map' bindings - governed by `icicle-top-level-key-bindings'.
2193 (icicle-bind-top-level-commands)
2194
2195 ;; Put all Icicles search commands on a common prefix key, `icicle-search-key-prefix'.
2196 (define-key icicle-mode-map icicle-search-key-prefix icicle-search-map)
2197
2198 ;; Install or update `icicle-mode-map'.
2199 (if icicle-minor-mode-map-entry
2200 (setcdr icicle-minor-mode-map-entry icicle-mode-map)
2201 (setq icicle-minor-mode-map-entry (cons 'icicle-mode icicle-mode-map))
2202 (add-to-list 'minor-mode-map-alist icicle-minor-mode-map-entry)))
2203
2204 (defun icicle-S-iso-lefttab-to-S-TAB (strg)
2205 "Return string STRG, but with \"S-iso-lefttab\" replaced by \"S-TAB\"."
2206 (replace-regexp-in-string "S-iso-lefttab" "S-TAB" strg))
2207
2208 (defun icicle-bind-other-keymap-keys ()
2209 "Bind some keys in maps other than minibuffer maps and `icicle-mode-map'"
2210
2211 ;; Bind Isearch keys.
2212 (icicle-bind-isearch-keys)
2213
2214 ;; Bind keys in Comint mode.
2215 (when (boundp 'comint-mode-map)
2216 (define-key comint-mode-map (icicle-kbd "C-c C-i") 'icicle-comint-command) ; `C-c TAB'
2217 (define-key comint-mode-map (icicle-kbd "C-c tab") 'icicle-comint-command)) ; `C-c TAB'
2218
2219 (when (boundp 'facemenu-keymap)
2220 (define-key 'facemenu-keymap "n" 'icicle-next-font-lock-keywords-repeat) ; `M-o n'
2221 (define-key 'facemenu-keymap "I" 'icicle-font-lock-keyword)) ; `M-o I'
2222
2223 ;; Bind keys in Shell mode.
2224 (when (and (boundp 'shell-mode-map) (memq 'comint-dynamic-complete icicle-functions-to-redefine))
2225 (define-key shell-mode-map (icicle-kbd "C-i") 'icicle-comint-dynamic-complete))
2226
2227 ;; Bind keys in Shell Script mode.
2228 (when (and (boundp 'sh-mode-map) (memq 'comint-dynamic-complete icicle-functions-to-redefine))
2229 (icicle-remap 'comint-dynamic-complete 'icicle-comint-dynamic-complete sh-mode-map))
2230
2231 ;; Bind keys in Ielm mode.
2232 (when (and (boundp 'ielm-map) (memq 'comint-dynamic-complete icicle-functions-to-redefine))
2233 (define-key ielm-map (icicle-kbd "C-i") 'icicle-comint-dynamic-complete))
2234
2235 ;; Bind keys in Tcl mode.
2236 (when (and (boundp 'inferior-tcl-mode-map) (memq 'comint-dynamic-complete
2237 icicle-functions-to-redefine))
2238 (define-key inferior-tcl-mode-map (icicle-kbd "C-i") 'icicle-comint-dynamic-complete))
2239
2240 ;; Bind keys in GUD (Debugger) mode.
2241 (when (and (boundp 'gud-minibuffer-local-map) (memq 'comint-dynamic-complete-filename
2242 icicle-functions-to-redefine))
2243 (define-key gud-minibuffer-local-map (icicle-kbd "C-i")
2244 'icicle-comint-dynamic-complete-filename))
2245
2246 ;; Bind some keys in `bookmark-bmenu-mode' mode (*Bookmark List*) - requires Bookmark+.
2247 (when (and (featurep 'bookmark+) (boundp 'bookmark-bmenu-mode-map))
2248 (unless (lookup-key bookmark-bmenu-mode-map (icicle-kbd "C-M->")) ; *Bookmark List* `C-M->'
2249 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-M->") 'icicle-bookmark-save-marked-files))
2250 (unless (lookup-key bookmark-bmenu-mode-map (icicle-kbd "C->")) ; *Bookmark List* `C->'
2251 (define-key bookmark-bmenu-mode-map (icicle-kbd "C->")
2252 'icicle-bookmark-save-marked-files-more))
2253 (unless (lookup-key bookmark-bmenu-mode-map (icicle-kbd "C-M-}")) ; *Bookmark List* `C-M-}'
2254 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-M-}")
2255 'icicle-bookmark-save-marked-files-to-variable))
2256 (unless (lookup-key bookmark-bmenu-mode-map (icicle-kbd "C-}")) ; *Bookmark List* `C-}'
2257 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-}")
2258 'icicle-bookmark-save-marked-files-as-project))
2259 (let* ((key (apply 'vector (append (listify-key-sequence icicle-search-key-prefix)
2260 (listify-key-sequence (icicle-kbd "m"))))) ; `M-s M-s m'
2261 (def (lookup-key bookmark-bmenu-mode-map key)))
2262 (unless (and def (not (integerp def)))
2263 (define-key bookmark-bmenu-mode-map key 'icicle-search-bookmark-list-marked))))
2264
2265 ;; Bind some keys in Dired mode.
2266 (when (boundp 'dired-mode-map)
2267 (unless (lookup-key dired-mode-map (icicle-kbd "C-M-<")) ; Dired `C-M-<'
2268 (define-key dired-mode-map (icicle-kbd "C-M-<")
2269 'icicle-dired-saved-file-candidates-other-window))
2270 (unless (lookup-key dired-mode-map (icicle-kbd "C-{")) ; Dired `C-{'
2271 (define-key dired-mode-map (icicle-kbd "C-{") 'icicle-dired-project-other-window))
2272 (unless (lookup-key dired-mode-map (icicle-kbd "C-M->")) ; Dired `C-M->'
2273 (define-key dired-mode-map (icicle-kbd "C-M->") 'icicle-dired-save-marked))
2274 (unless (lookup-key dired-mode-map (icicle-kbd "C->")) ; Dired `C->'
2275 (define-key dired-mode-map (icicle-kbd "C->") 'icicle-dired-save-marked-more))
2276 (unless (lookup-key dired-mode-map (icicle-kbd "C-M-}")) ; Dired `C-M-}'
2277 (define-key dired-mode-map (icicle-kbd "C-M-}") 'icicle-dired-save-marked-to-variable))
2278 (unless (lookup-key dired-mode-map (icicle-kbd "C-}")) ; Dired `C-}'
2279 (define-key dired-mode-map (icicle-kbd "C-}") 'icicle-dired-save-marked-as-project))
2280 (unless (lookup-key dired-mode-map (icicle-kbd "C-S-f")) ; Dired `C-S-f', aka `C-F'
2281 (define-key dired-mode-map (icicle-kbd "C-S-f") 'icicle-visit-marked-file-of-content))
2282 (unless (lookup-key dired-mode-map (icicle-kbd "C-M-S-f")) ; Dired `C-M-S-f', aka `C-M-F'
2283 (define-key dired-mode-map (icicle-kbd "C-M-S-f")
2284 'icicle-visit-marked-file-of-content-other-window))
2285 (unless (lookup-key dired-mode-map (icicle-kbd "C-S-o")) ; Dired `C-S-o', aka `C-O'
2286 (define-key dired-mode-map (icicle-kbd "C-S-o") 'icicle-occur-dired-marked))
2287 (unless (lookup-key dired-mode-map (icicle-kbd "C-S-s")) ; Dired `C-S-s', aka `C-S'
2288 (define-key dired-mode-map (icicle-kbd "C-S-s") 'icicle-search-dired-marked))
2289
2290
2291 )
2292
2293 ;; More Dired keys, but these require `dired+.el'.
2294 (when (boundp 'diredp-recursive-map)
2295
2296 ;; `dired-mode-map'.
2297 (let* ((key (apply 'vector
2298 (append (listify-key-sequence icicle-search-key-prefix)
2299 (listify-key-sequence (icicle-kbd "m")))))
2300 (def (lookup-key dired-mode-map key)))
2301 (unless (and def (not (integerp def)))
2302 (define-key dired-mode-map key 'icicle-search-dired-marked-recursive))) ; `M-s M-s m'
2303 (let* ((key (apply 'vector
2304 (append (listify-key-sequence icicle-search-key-prefix)
2305 (listify-key-sequence (icicle-kbd "M")))))
2306 (def (lookup-key dired-mode-map key)))
2307 (unless (and def (not (integerp def)))
2308 (define-key dired-mode-map key 'icicle-occur-dired-marked-recursive))) ; `M-s M-s M'
2309
2310 ;; `diredp-recursive-map'.
2311 (define-key diredp-recursive-map (icicle-kbd "C-S-s") ; `M-+ C-S-s', aka `M-+ C-S'
2312 'icicle-search-dired-marked-recursive) ; and `C-0 M-s M-s M-s' and `C-0 C-`'
2313 (define-key diredp-recursive-map (icicle-kbd "C-S-o") ; `M-+ C-S-o', aka `M-+ C-O'
2314 'icicle-occur-dired-marked-recursive)
2315 (define-key diredp-recursive-map (icicle-kbd "C-{") ; `M-+ C-{'
2316 'icicle-dired-project-other-window)
2317 (define-key diredp-recursive-map (icicle-kbd "C-M->") ; `M-+ C-M->'
2318 'icicle-dired-save-marked-recursive)
2319 (define-key diredp-recursive-map (icicle-kbd "C->") ; `M-+ C->'
2320 'icicle-dired-save-marked-more-recursive)
2321 (define-key diredp-recursive-map (icicle-kbd "C-M-}") ; `M-+ C-M-}'
2322 'icicle-dired-save-marked-to-variable-recursive)
2323 (define-key diredp-recursive-map (icicle-kbd "C-}") ; `M-+ C-}'
2324 'icicle-dired-save-marked-to-cache-file-recursive)
2325 (define-key diredp-recursive-map (icicle-kbd "C-S-f") ; `M-+ C-S-f', aka `M-+ C-F'
2326 'icicle-visit-marked-file-of-content-recursive)
2327 (define-key diredp-recursive-map (icicle-kbd "C-M-S-f") ; `M-+ C-M-S-f', aka `M-+ C-M-F'
2328 'icicle-visit-marked-file-of-content-recursive-other-window))
2329
2330 ;; Bind keys in Ibuffer mode.
2331 (when (boundp 'ibuffer-mode-map)
2332 (let* ((key (apply 'vector ; Ibuffer `M-s M-s m'
2333 (append (listify-key-sequence icicle-search-key-prefix)
2334 (listify-key-sequence (icicle-kbd "m")))))
2335 (def (lookup-key ibuffer-mode-map icicle-search-key-prefix)))
2336 (unless (and def (not (integerp def)))
2337 (define-key ibuffer-mode-map key 'icicle-search-ibuffer-marked))
2338 (unless icicle-touche-pas-aux-menus-flag ; Use Ibuffer's `Operate' menu.
2339 (define-key ibuffer-mode-operate-map [icicle-search-ibuffer-marked]
2340 '(menu-item "Icicles Search (and Replace)..." icicle-search-ibuffer-marked
2341 :visible icicle-mode :enable (eq major-mode 'ibuffer-mode))))))
2342
2343 ;; Bind keys in Buffer Menu mode.
2344 (when (boundp 'Buffer-menu-mode-map)
2345 (let* ((key (apply 'vector ; Buffer-Menu `M-s M-s m'
2346 (append (listify-key-sequence icicle-search-key-prefix)
2347 (listify-key-sequence (icicle-kbd "m")))))
2348 (def (lookup-key Buffer-menu-mode-map icicle-search-key-prefix)))
2349 (unless (and def (not (integerp def)))
2350 (define-key Buffer-menu-mode-map key 'icicle-search-buff-menu-marked))))
2351
2352 ;; Bind `S-TAB' in major maps, for key completion.
2353 (when (fboundp 'map-keymap) ; Emacs 22+.
2354 (icicle-bind-key-completion-keys-in-keymaps-from (current-global-map))
2355 (mapcar #'icicle-bind-key-completion-keys-for-map-var icicle-keymaps-for-key-completion))
2356
2357 ;; Bind `M-S-TAB' in `minibuffer-local-map', for key completion.
2358 (when (fboundp 'map-keymap) ; Emacs 22+.
2359 (icicle-bind-key-completion-keys-for-map-var 'minibuffer-local-map
2360 icicle-key-complete-keys-for-minibuffer))
2361
2362 ;; Prevent `this-command' from being set to `handle-switch-frame'.
2363 (define-key global-map [handle-switch-frame] 'icicle-skip-this-command)
2364 (define-key global-map [switch-frame] 'icicle-handle-switch-frame))
2365
2366 (defun icicle-bind-isearch-keys ()
2367 "Bind Icicles Isearch commands."
2368 (dolist (key icicle-search-from-isearch-keys)
2369 (define-key isearch-mode-map key 'icicle-search-w-isearch-string)) ; In `icicles-cmd2.el'.
2370 (dolist (key icicle-isearch-complete-keys)
2371 (define-key isearch-mode-map key 'icicle-isearch-complete))
2372 (dolist (key icicle-isearch-history-insert-keys)
2373 (define-key isearch-mode-map key 'icicle-isearch-history-insert))
2374 (cond ((fboundp 'isearch-moccur) ; In `moccur.el'.
2375 (define-key isearch-mode-map (icicle-kbd "C-o") 'isearch-moccur)) ; `C-s C-o'
2376 ((fboundp 'isearch-occur) ; In `occur-schroeder.el'.
2377 (define-key isearch-mode-map (icicle-kbd "C-o") 'isearch-occur)))) ; `C-s C-o'
2378
2379 (defun icicle-bind-key-completion-keys-for-map-var (keymap-var &optional keys)
2380 "Bind `S-TAB' in keymaps accessible from keymap KEYMAP-VAR.
2381 KEYMAP-VAR should be bound to a keymap that has at least one prefix
2382 keymap. If KEYMAP-VAR is not bound to a keymap, it is ignored.
2383
2384 Actually, by default, it is the keys in `icicle-key-complete-keys'
2385 that are bound, not `S-TAB'. And if optional arg KEYS is non-nil then
2386 it, not `icicle-key-complete-keys', is the list of keys that are
2387 bound."
2388 (let ((temp keymap-var))
2389 (when (boundp temp)
2390 (setq temp (symbol-value temp))
2391 (when (keymapp temp) (icicle-bind-key-completion-keys-in-keymaps-from temp keys)))))
2392
2393 (defun icicle-bind-key-completion-keys-in-keymaps-from (map &optional keys)
2394 "Bind keys in `icicle-key-complete-keys' to `icicle-complete-keys'.
2395 Each key in `icicle-complete-keys' (or optional arg KEYS, if non-nil)
2396 is bound in all keymaps accessible from keymap MAP."
2397 (dolist (key+map (accessible-keymaps map))
2398 (let ((map (cdr key+map)))
2399 ;; We could try to exclude menu maps, by testing (not (keymap-prompt map)).
2400 ;; But we want to include at least some menu maps - those, such as `facemenu-keymap',
2401 ;; that are bound to keyboard keys. (when (and (keymapp map) (not (keymap-prompt map)))...)
2402 (when (keymapp map)
2403 (dolist (key (or keys icicle-key-complete-keys))
2404 (when (or icicle-complete-key-anyway-flag (not (lookup-key map key)))
2405 (condition-case nil (define-key map key 'icicle-complete-keys) (error nil))))))))
2406
2407 (defun icicle-restore-other-keymap-keys ()
2408 "Restore some bindings changed by `icicle-bind-other-keymap-keys'."
2409
2410 ;; Unbind Isearch keys.
2411 (icicle-unbind-isearch-keys)
2412
2413 ;; Unbind keys in Comint mode.
2414 (when (boundp 'comint-mode-map)
2415 (define-key comint-mode-map (icicle-kbd "C-c C-i") nil)
2416 (define-key comint-mode-map (icicle-kbd "C-c tab") nil))
2417
2418 ;; Unbind keys in Facemenu.
2419 (when (boundp 'facemenu-keymap)
2420 (define-key 'facemenu-keymap "n" nil) ; `M-o n'
2421 (define-key 'facemenu-keymap "I" nil)) ; `M-o I'
2422
2423 ;; Unbind keys in Shell mode.
2424 (when (and (boundp 'shell-mode-map) (memq 'icicle-comint-dynamic-complete
2425 icicle-functions-to-redefine))
2426 (define-key shell-mode-map (icicle-kbd "C-i") (if (> emacs-major-version 23)
2427 'completion-at-point
2428 'comint-dynamic-complete)))
2429
2430 ;; Unbind keys in Shell Script mode.
2431 (when (and (boundp 'sh-mode-map) (memq 'icicle-comint-dynamic-complete
2432 icicle-functions-to-redefine))
2433 (icicle-unmap 'comint-dynamic-complete sh-mode-map 'icicle-comint-dynamic-complete))
2434
2435 ;; Unbind keys in Ielm mode.
2436 (when (and (boundp 'ielm-map) (memq 'icicle-comint-dynamic-complete
2437 icicle-functions-to-redefine))
2438 (define-key ielm-map (icicle-kbd "C-i") 'comint-dynamic-complete))
2439
2440 ;; Unbind keys in Tcl mode.
2441 (when (and (boundp 'inferior-tcl-mode-map) (memq 'icicle-comint-dynamic-complete
2442 icicle-functions-to-redefine))
2443 (define-key inferior-tcl-mode-map (icicle-kbd "C-i") 'comint-dynamic-complete))
2444
2445 ;; Bind keys in GUD (Debugger) mode.
2446 (when (and (boundp 'gud-minibuffer-local-map) (memq 'icicle-comint-dynamic-complete-filename
2447 icicle-functions-to-redefine))
2448 (define-key gud-minibuffer-local-map (icicle-kbd "C-i") 'comint-dynamic-complete-filename))
2449
2450 ;; Unbind keys in `bookmark-bmenu-mode' mode (*Bookmark List*) - requires Bookmark+.
2451 (when (and (featurep 'bookmark+) (boundp 'bookmark-bmenu-mode-map))
2452 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-M->") nil)
2453 (define-key bookmark-bmenu-mode-map (icicle-kbd "C->") nil)
2454 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-M-}") nil)
2455 (define-key bookmark-bmenu-mode-map (icicle-kbd "C-}") nil)
2456 (define-key bookmark-bmenu-mode-map icicle-search-key-prefix nil))
2457
2458 ;; Unbind keys in Dired mode.
2459 (when (boundp 'dired-mode-map)
2460 (define-key dired-mode-map (icicle-kbd "C-M-<") nil)
2461 (define-key dired-mode-map (icicle-kbd "C-{") nil)
2462 (define-key dired-mode-map (icicle-kbd "C-M->") nil)
2463 (define-key dired-mode-map (icicle-kbd "C->") nil)
2464 (define-key dired-mode-map (icicle-kbd "C-M-}") nil)
2465 (define-key dired-mode-map (icicle-kbd "C-}") nil)
2466 (define-key dired-mode-map (icicle-kbd "C-S-f") nil)
2467 (define-key dired-mode-map (icicle-kbd "C-S-o") nil)
2468 (define-key dired-mode-map icicle-search-key-prefix nil))
2469
2470 ;; Unbind keys in Ibuffer mode.
2471 (when (boundp 'ibuffer-mode-map)
2472 (define-key ibuffer-mode-map icicle-search-key-prefix nil))
2473
2474 ;; Unbind keys in Buffer Menu mode.
2475 (when (boundp 'Buffer-menu-mode-map)
2476 (define-key Buffer-menu-mode-map icicle-search-key-prefix nil))
2477
2478 ;; Unbind `S-TAB' in major maps.
2479 (when (fboundp 'map-keymap) ; Emacs 22+.
2480 (icicle-unbind-key-completion-keys-in-keymaps-from (current-global-map))
2481 (mapcar #'icicle-unbind-key-completion-keys-for-map-var icicle-keymaps-for-key-completion))
2482
2483 ;; Unbind `M-S-TAB' in `minibuffer-local-map'.
2484 (when (fboundp 'map-keymap) ; Emacs 22+.
2485 (icicle-unbind-key-completion-keys-for-map-var 'minibuffer-local-map
2486 icicle-key-complete-keys-for-minibuffer))
2487 ;; Restore prevention of `this-command' being `handle-switch-frame'.
2488 (define-key global-map [handle-switch-frame] nil)
2489 (define-key global-map [switch-frame] 'handle-switch-frame))
2490
2491 (defun icicle-unbind-isearch-keys ()
2492 "Unbind Icicles Isearch commands."
2493 (dolist (key icicle-search-from-isearch-keys) (define-key isearch-mode-map key nil))
2494 (dolist (key icicle-isearch-complete-keys) (define-key isearch-mode-map key nil))
2495 (define-key isearch-mode-map (icicle-kbd "C-M-i") 'isearch-complete)
2496 (dolist (key icicle-isearch-history-insert-keys) (define-key isearch-mode-map key nil))
2497 (when (fboundp 'isearch-moccur) ; Restore `moccur.el' binding.
2498 (define-key isearch-mode-map (icicle-kbd "M-o") 'isearch-moccur))
2499 (define-key isearch-mode-map (icicle-kbd "C-o") nil))
2500
2501 (defun icicle-unbind-key-completion-keys-for-map-var (keymap-var &optional keys)
2502 "Unbind `S-TAB' in keymaps accessible from keymap KEYMAP-VAR.
2503 KEYMAP-VAR should be bound to a keymap that has at least one prefix
2504 keymap. If KEYMAP-VAR is not bound to a keymap, it is ignored.
2505
2506 Actually, by default, it is the keys in `icicle-key-complete-keys'
2507 that are unbound, not `S-TAB'. And if optional arg KEYS is non-nil
2508 then it, not `icicle-key-complete-keys', is the list of keys that are
2509 unbound."
2510 (let ((temp keymap-var))
2511 (when (boundp temp)
2512 (setq temp (symbol-value temp))
2513 (when (keymapp temp) (icicle-unbind-key-completion-keys-in-keymaps-from temp keys)))))
2514
2515 (defun icicle-unbind-key-completion-keys-in-keymaps-from (map &optional keys)
2516 "Unbind `icicle-key-complete-keys' in keymaps accessible from MAP.
2517 Each key in `icicle-complete-keys' (or optional arg KEYS, if non-nil)
2518 is unbound in all keymaps accessible from keymap MAP."
2519 (dolist (key+map (accessible-keymaps map))
2520 (let ((map (cdr key+map)))
2521 (while (and (symbolp map) (fboundp map)) (setq map (symbol-function map))) ; Get a list.
2522 (when (and (keymapp map)
2523 (not (eq 'autoload (car-safe map))) ; Skip autoload keymaps.
2524 (not (stringp (car-safe (last map))))) ; Try to exclude menu maps.
2525 (dolist (key (or keys icicle-key-complete-keys))
2526 (when (eq (lookup-key map key) 'icicle-complete-keys)
2527 (condition-case nil (define-key map key nil) (error nil))))))))
2528
2529 ;;(@* "Other Icicles functions that define Icicle mode")
2530
2531 ;;; Other Icicles functions that define Icicle mode ------------------
2532
2533 (defun icicle-skip-this-command ()
2534 "Prevent `handle-switch-frame' from being added to `this-command'."
2535 (interactive)
2536 (setq this-command last-command))
2537
2538 (defun icicle-handle-switch-frame (event)
2539 "Call `handle-switch-frame', but don't add it to `this-command'."
2540 (interactive "e")
2541 (handle-switch-frame event)
2542 (setq this-command last-command))
2543
2544 (defun icicle-define-minibuffer-maps (turn-on-p)
2545 "Define keymaps for the minibuffer and buffer `*Completions*'."
2546 (cond
2547 (turn-on-p ; TURN IT ON ********************************
2548
2549 ;; `minibuffer-local-map': default minibuffer map.
2550 (let ((map minibuffer-local-map))
2551
2552 ;; Menu-bar `Minibuf' menu.
2553
2554 ;; First, remove some standard bindings that are on submenus here.
2555 (define-key map [menu-bar minibuf isearch-forward] nil)
2556 (define-key map [menu-bar minibuf isearch-backward] nil)
2557 (define-key map [menu-bar minibuf next] nil)
2558 (define-key map [menu-bar minibuf previous] nil)
2559
2560 (define-key-after (lookup-key map [menu-bar minibuf]) [icicle-top-level]
2561 '(menu-item "Top Level" icicle-top-level
2562 :help "Cancel all minibuffers and return to the top level")
2563 'quit)
2564 (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit'
2565 '(menu-item "Quit" icicle-abort-recursive-edit
2566 :help "Cancel this minibuffer and return to the next higher level"))
2567 (define-key map [menu-bar minibuf return]
2568 '(menu-item "Enter" exit-minibuffer
2569 :help "Terminate input and exit minibuffer" :keys "RET"))
2570 (define-key map [menu-bar minibuf separator-help] '("--"))
2571
2572 (when (fboundp 'icicle-complete-keys)
2573 (define-key map [menu-bar minibuf icicle-complete-keys]
2574 '(menu-item "Show Available Keys (Complete Key)" icicle-complete-keys
2575 :help "Show available keys (`C-g') or complete prefix key")))
2576 (define-key map [menu-bar minibuf completion-help]
2577 '(menu-item "Icicles Help" icicle-minibuffer-help
2578 :help "Display help for minibuffer input and completion" :keys "M-?"))
2579 (define-key map [menu-bar minibuf separator-last] '("--"))
2580
2581 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain]
2582 '(menu-item "Toggle Searching Complement"
2583 icicle-toggle-search-complementing-domain
2584 :help "Toggle `icicle-search-complement-domain-p'" :keys "C-M-~"))
2585 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current]
2586 '(menu-item "Toggle All-Current Icicle-Search Highlighting"
2587 icicle-toggle-highlight-all-current :enable icicle-searching-p
2588 :help "Toggle `icicle-search-highlight-all-current-flag'" :keys "C-^"))
2589 (define-key map [menu-bar minibuf icicle-multi-inputs-save]
2590 '(menu-item "Save Multiple Inputs for Completion" icicle-multi-inputs-save
2591 :help "Add inputs in minibuffer to saved candidates set for completion"))
2592 (define-key map [menu-bar minibuf icicle-multi-inputs-act]
2593 '(menu-item "Act on Multiple Inputs" icicle-multi-inputs-act
2594 :help "Parse minibuffer input into a list of candidates, then act on each"))
2595 (define-key map [menu-bar minibuf separator-misc] '("--"))
2596
2597 (define-key map [menu-bar minibuf edit]
2598 (list 'menu-item "Edit" icicle-minibuf-edit-menu-map))
2599
2600 (define-key map [menu-bar minibuf history]
2601 (list 'menu-item "History" icicle-minibuf-history-menu-map))
2602
2603 ;; Keyboard keys
2604 (icicle-bind-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2605 (define-key map (icicle-kbd "C-g") 'icicle-abort-recursive-edit) ; `C-g'
2606 (dolist (key icicle-completing-read+insert-keys)
2607 (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c'
2608 (dolist (key icicle-read+insert-file-name-keys)
2609 (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f'
2610 ) ; End `minibuffer-local-map'.
2611
2612 ;; `minibuffer-local-ns-map': default minibuffer map when spaces are not allowed.
2613 ;; In Emacs 22+, local is parent of local-ns.
2614 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-ns-map))
2615 (let ((map minibuffer-local-ns-map))
2616 (define-key-after (lookup-key map [menu-bar minibuf]) [icicle-top-level]
2617 '(menu-item "Top Level" icicle-top-level
2618 :help "Cancel all minibuffers and return to the top level")
2619 'quit)
2620 (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit'
2621 '(menu-item "Quit" icicle-abort-recursive-edit
2622 :help "Cancel this minibuffer and return to the next higher level"))
2623 (define-key map [menu-bar minibuf return]
2624 '(menu-item "Enter" exit-minibuffer
2625 :help "Terminate input and exit minibuffer" :keys "RET"))
2626 (define-key map [menu-bar minibuf separator-help] '("--"))
2627
2628 (when (fboundp 'icicle-complete-keys)
2629 (define-key map [menu-bar minibuf icicle-complete-keys]
2630 '(menu-item "Show Available Keys (Complete Key)" icicle-complete-keys
2631 :help "Show available keys (`C-g') or complete prefix key")))
2632 (define-key map [menu-bar minibuf completion-help]
2633 '(menu-item "Icicles Help" icicle-minibuffer-help
2634 :help "Display help for minibuffer input and completion" :keys "M-?"))
2635 (define-key map [menu-bar minibuf separator-last] '("--"))
2636
2637 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain]
2638 '(menu-item "Toggle Searching Complement"
2639 icicle-toggle-search-complementing-domain
2640 :help "Toggle `icicle-search-complement-domain-p'" :keys "C-M-~"))
2641 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current]
2642 '(menu-item "Toggle All-Current Icicle-Search Highlighting"
2643 icicle-toggle-highlight-all-current :enable icicle-searching-p
2644 :help "Toggle `icicle-search-highlight-all-current-flag'" :keys "C-^"))
2645 (define-key map [menu-bar minibuf icicle-multi-inputs-save]
2646 '(menu-item "Save Multiple Inputs for Completion" icicle-multi-inputs-save
2647 :help "Add inputs in minibuffer to saved candidates set for completion"))
2648 (define-key map [menu-bar minibuf icicle-multi-inputs-act]
2649 '(menu-item "Act on Multiple Inputs" icicle-multi-inputs-act
2650 :help "Parse minibuffer input into a list of candidates, then act on each"))
2651 (define-key map [menu-bar minibuf separator-misc] '("--"))
2652
2653 (define-key map [menu-bar minibuf edit]
2654 (list 'menu-item "Edit" icicle-minibuf-edit-menu-map))
2655
2656 (define-key map [menu-bar minibuf history]
2657 (list 'menu-item "History" icicle-minibuf-history-menu-map))
2658
2659 ;; Keyboard keys
2660 (icicle-bind-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2661 (define-key map (icicle-kbd "C-g") 'icicle-abort-recursive-edit) ; `C-g'
2662 (dolist (key icicle-completing-read+insert-keys)
2663 (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c'
2664 (dolist (key icicle-read+insert-file-name-keys)
2665 (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f'
2666 )) ; End `minibuffer-local-ns-map'.
2667
2668 ;; `minibuffer-local-isearch-map': minibuffer map for editing isearch strings.
2669 ;; In Emacs 21+, local is parent of local-isearch.
2670 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-isearch-map))
2671
2672 (let ((map minibuffer-local-isearch-map))
2673 (define-key-after (lookup-key map [menu-bar minibuf]) [icicle-top-level]
2674 '(menu-item "Top Level" icicle-top-level
2675 :help "Cancel all minibuffers and return to the top level")
2676 'quit)
2677 (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit'
2678 '(menu-item "Quit" icicle-abort-recursive-edit
2679 :help "Cancel this minibuffer and return to the next higher level"))
2680 (define-key map [menu-bar minibuf return]
2681 '(menu-item "Enter" exit-minibuffer
2682 :help "Terminate input and exit minibuffer" :keys "RET"))
2683 (define-key map [menu-bar minibuf separator-help] '("--"))
2684
2685 (when (fboundp 'icicle-complete-keys)
2686 (define-key map [menu-bar minibuf icicle-complete-keys]
2687 '(menu-item "Show Available Keys (Complete Key)" icicle-complete-keys
2688 :help "Show available keys (`C-g') or complete prefix key")))
2689 (define-key map [menu-bar minibuf completion-help]
2690 '(menu-item "Icicles Help" icicle-minibuffer-help
2691 :help "Display help for minibuffer input and completion" :keys "M-?"))
2692 (define-key map [menu-bar minibuf separator-last] '("--"))
2693
2694 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain]
2695 '(menu-item "Toggle Searching Complement"
2696 icicle-toggle-search-complementing-domain
2697 :help "Toggle `icicle-search-complement-domain-p'" :keys "C-M-~"))
2698 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current]
2699 '(menu-item "Toggle All-Current Icicle-Search Highlighting"
2700 icicle-toggle-highlight-all-current :enable icicle-searching-p
2701 :help "Toggle `icicle-search-highlight-all-current-flag'" :keys "C-^"))
2702 (define-key map [menu-bar minibuf icicle-multi-inputs-save]
2703 '(menu-item "Save Multiple Inputs for Completion" icicle-multi-inputs-save
2704 :help "Add inputs in minibuffer to saved candidates set for completion"))
2705 (define-key map [menu-bar minibuf icicle-multi-inputs-act]
2706 '(menu-item "Act on Multiple Inputs" icicle-multi-inputs-act
2707 :help "Parse minibuffer input into a list of candidates, then act on each"))
2708 (define-key map [menu-bar minibuf separator-misc] '("--"))
2709
2710 (define-key map [menu-bar minibuf edit]
2711 (list 'menu-item "Edit" icicle-minibuf-edit-menu-map))
2712
2713 (define-key map [menu-bar minibuf history]
2714 (list 'menu-item "History" icicle-minibuf-history-menu-map))
2715
2716 ;; Keyboard keys
2717 (icicle-bind-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2718 (define-key map (icicle-kbd "C-g") 'icicle-abort-recursive-edit) ; `C-g'
2719 (dolist (key icicle-completing-read+insert-keys)
2720 (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c'
2721 (dolist (key icicle-read+insert-file-name-keys)
2722 (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f'
2723 )) ; End `minibuffer-local-isearch-map'.
2724
2725 ;; `minibuffer-local-completion-map': completion map.
2726 (icicle-bind-completion-keys minibuffer-local-completion-map)
2727
2728 ;; `minibuffer-local-must-match-map': must-match map.
2729 ;; In Emacs 22+, local-completion is parent of local-must-match.
2730 (let ((map minibuffer-local-must-match-map))
2731 (if (not (eq minibuffer-local-completion-map (keymap-parent map)))
2732 (icicle-bind-completion-keys map)
2733 ;; Keyboard keys
2734 (icicle-bind-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2735 ;; Need `C-g' anyway, even if `minibuffer-local-must-match-map' inherits completion map.
2736 (define-key map (icicle-kbd "C-g") 'icicle-abort-recursive-edit) ; `C-g'
2737 (dolist (key icicle-completing-read+insert-keys)
2738 (define-key map key 'icicle-completing-read+insert)) ; `C-M-S-c'
2739 (dolist (key icicle-read+insert-file-name-keys)
2740 (define-key map key 'icicle-read+insert-file-name)) ; `C-M-S-f'
2741 )) ; End `minibuffer-local-must-match-map'.
2742
2743 ;; `completion-list-mode-map': map for `*Completions*' buffer.
2744 ;; Abort on `C-g' or `q'. Switch to minibuffer on `C-insert'. Do not allow normal input.
2745 (let ((map completion-list-mode-map))
2746 ;; Keyboard keys
2747 (icicle-bind-custom-minibuffer-keys map icicle-completion-list-key-bindings)
2748 (dolist (key icicle-candidate-help-keys) ; `C-M-return', `C-help', `C-M-help', `C-f1',
2749 (define-key map key 'icicle-help-on-candidate)) ; `C-M-f1'
2750 (define-key map (icicle-kbd "C-g") 'icicle-abort-recursive-edit) ; `C-g'
2751 (define-key map (icicle-kbd "C-M-S-t") 'icicle-top-level) ; `C-M-S-t' (aka `C-M-T')
2752 )) ; End `completion-list-mode-map'.
2753
2754 (t ; TURN IT OFF *******************************
2755
2756 ;; `minibuffer-local-map': default minibuffer map.
2757 (let ((map minibuffer-local-map))
2758
2759 ;; Menu-bar `Minibuf' menu.
2760 (define-key map [menu-bar minibuf quit]
2761 '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer"))
2762 (define-key map [menu-bar minibuf return]
2763 '(menu-item "Enter" exit-minibuffer
2764 :help "Terminate input and exit minibuffer" :keys "RET"))
2765 (define-key map [menu-bar minibuf separator-help] nil)
2766 (define-key map [menu-bar minibuf completion-help] nil)
2767 (define-key map [menu-bar minibuf separator-last] nil)
2768 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain] nil)
2769 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current] nil)
2770 (define-key map [menu-bar minibuf icicle-regexp-quote-input] nil)
2771 (define-key map [menu-bar minibuf separator-set2] nil)
2772 (define-key map [menu-bar minibuf icicle-clear-current-history] nil)
2773 (define-key map [menu-bar minibuf icicle-erase-minibuffer] nil)
2774 (define-key map [menu-bar minibuf icicle-delete-history-element] nil)
2775 (define-key map [menu-bar minibuf icicle-insert-list-join-string] nil)
2776 (define-key map [menu-bar minibuf icicle-insert-key-description] nil)
2777 (define-key map [menu-bar minibuf icicle-insert-history-element] nil)
2778 (define-key map [menu-bar minibuf icicle-insert-string-from-a-var] nil)
2779 (define-key map [menu-bar minibuf icicle-insert-string-from-std-var] nil)
2780 (define-key map [menu-bar minibuf icicle-insert-string-at-point] nil)
2781 (define-key map [menu-bar minibuf icicle-completing-read+insert] nil)
2782 (define-key map [menu-bar minibuf icicle-read+insert-file-name] nil)
2783
2784 ;; Keyboard keys
2785 (icicle-restore-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2786 (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c'
2787 (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f'
2788 ;; Do the non-nil bindings no matter what might be in `icicle-minibuffer-key-bindings'.
2789 (define-key map (icicle-kbd "C-g") (if (and (fboundp 'minibuffer-keyboard-quit)
2790 delete-selection-mode)
2791 'minibuffer-keyboard-quit
2792 'abort-recursive-edit)) ; `C-g'
2793 (define-key map (icicle-kbd "M-r") 'previous-matching-history-element) ; `M-r'
2794 (define-key map (icicle-kbd "M-s") 'next-matching-history-element) ; `M-s'
2795 (define-key map (icicle-kbd "C-j") 'exit-minibuffer) ; `C-j'
2796 ) ; End `minibuffer-local-map'.
2797
2798 ;; `minibuffer-local-ns-map': default minibuffer map when spaces are not allowed.
2799 ;; In Emacs 22+, local is parent of local-ns.
2800 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-ns-map))
2801 (let ((map minibuffer-local-ns-map))
2802 (define-key map [menu-bar minibuf quit]
2803 '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer"))
2804 (define-key map [menu-bar minibuf return]
2805 '(menu-item "Enter" exit-minibuffer
2806 :help "Terminate input and exit minibuffer" :keys "RET"))
2807 (define-key map [menu-bar minibuf separator-help] nil)
2808 (define-key map [menu-bar minibuf completion-help] nil)
2809 (define-key map [menu-bar minibuf separator-last] nil)
2810 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain] nil)
2811 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current] nil)
2812 (define-key map [menu-bar minibuf icicle-regexp-quote-input] nil)
2813 (define-key map [menu-bar minibuf separator-set2] nil)
2814 (define-key map [menu-bar minibuf icicle-clear-current-history] nil)
2815 (define-key map [menu-bar minibuf icicle-erase-minibuffer] nil)
2816 (define-key map [menu-bar minibuf icicle-delete-history-element] nil)
2817 (define-key map [menu-bar minibuf icicle-insert-list-join-string] nil)
2818 (define-key map [menu-bar minibuf icicle-insert-key-description] nil)
2819 (define-key map [menu-bar minibuf icicle-insert-history-element] nil)
2820 (define-key map [menu-bar minibuf icicle-insert-string-from-a-var] nil)
2821 (define-key map [menu-bar minibuf icicle-insert-string-from-std-var] nil)
2822 (define-key map [menu-bar minibuf icicle-insert-string-at-point] nil)
2823 (define-key map [menu-bar minibuf icicle-completing-read+insert] nil)
2824 (define-key map [menu-bar minibuf icicle-read+insert-file-name] nil)
2825
2826 ;; Keyboard keys
2827 (icicle-restore-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2828 (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c'
2829 (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f'
2830 ;; Do the non-nil bindings no matter what might be in `icicle-minibuffer-key-bindings'.
2831 (define-key map (icicle-kbd "C-g") (if (and (fboundp 'minibuffer-keyboard-quit)
2832 delete-selection-mode)
2833 'minibuffer-keyboard-quit
2834 'abort-recursive-edit)) ; `C-g'
2835 (define-key map (icicle-kbd "M-r") 'previous-matching-history-element) ; `M-r'
2836 (define-key map (icicle-kbd "M-s") 'next-matching-history-element) ; `M-s'
2837 (define-key map (icicle-kbd "C-j") 'exit-minibuffer) ; `C-j'
2838 )) ; End `minibuffer-local-ns-map'.
2839
2840 ;; `minibuffer-local-isearch-map': minibuffer map for editing isearch strings.
2841 ;; In Emacs 21+, local is parent of local-isearch
2842 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-isearch-map))
2843 (let ((map minibuffer-local-isearch-map))
2844 (define-key map [menu-bar minibuf quit]
2845 '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer"))
2846 (define-key map [menu-bar minibuf return]
2847 '(menu-item "Enter" exit-minibuffer
2848 :help "Terminate input and exit minibuffer" :keys "RET"))
2849 (define-key map [menu-bar minibuf separator-help] nil)
2850 (define-key map [menu-bar minibuf completion-help] nil)
2851 (define-key map [menu-bar minibuf separator-last] nil)
2852 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain] nil)
2853 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current] nil)
2854 (define-key map [menu-bar minibuf icicle-regexp-quote-input] nil)
2855 (define-key map [menu-bar minibuf separator-set2] nil)
2856 (define-key map [menu-bar minibuf icicle-clear-current-history] nil)
2857 (define-key map [menu-bar minibuf icicle-erase-minibuffer] nil)
2858 (define-key map [menu-bar minibuf icicle-delete-history-element] nil)
2859 (define-key map [menu-bar minibuf icicle-insert-list-join-string] nil)
2860 (define-key map [menu-bar minibuf icicle-insert-key-description] nil)
2861 (define-key map [menu-bar minibuf icicle-insert-history-element] nil)
2862 (define-key map [menu-bar minibuf icicle-insert-string-from-a-var] nil)
2863 (define-key map [menu-bar minibuf icicle-insert-string-from-std-var] nil)
2864 (define-key map [menu-bar minibuf icicle-insert-string-at-point] nil)
2865 (define-key map [menu-bar minibuf icicle-completing-read+insert] nil)
2866 (define-key map [menu-bar minibuf icicle-read+insert-file-name] nil)
2867
2868 ;; Keyboard keys
2869 (icicle-restore-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2870 (dolist (key icicle-completing-read+insert-keys) (define-key map key nil)) ; `C-M-S-c'
2871 (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil)) ; `C-M-S-f'
2872 ;; Do the non-nil bindings no matter what might be in `icicle-minibuffer-key-bindings'.
2873 (define-key map (icicle-kbd "C-g") (if (and (fboundp 'minibuffer-keyboard-quit)
2874 delete-selection-mode)
2875 'minibuffer-keyboard-quit
2876 'abort-recursive-edit)) ; `C-g'
2877 (define-key map (icicle-kbd "M-r") 'previous-matching-history-element) ; `M-r'
2878 (define-key map (icicle-kbd "M-s") 'next-matching-history-element) ; `M-s'
2879 (define-key map (icicle-kbd "C-j") 'exit-minibuffer) ; `C-j'
2880 )) ; End `minibuffer-local-isearch-map'.
2881
2882 ;; `minibuffer-local-completion-map': completion map.
2883 (icicle-restore-completion-keys minibuffer-local-completion-map)
2884
2885 ;; `minibuffer-local-must-match-map': must-match map.
2886 ;; In Emacs 22+, local-completion is parent of local-must-match
2887 (let ((map minibuffer-local-must-match-map))
2888 (if (not (eq minibuffer-local-completion-map (keymap-parent map)))
2889 (icicle-restore-completion-keys map)
2890 ;; Keyboard keys
2891 (icicle-restore-custom-minibuffer-keys map icicle-minibuffer-key-bindings)
2892 (dolist (key icicle-completing-read+insert-keys) (define-key map key nil))
2893 (dolist (key icicle-read+insert-file-name-keys) (define-key map key nil))
2894 ;; Do the non-nil bindings no matter what might be in `icicle-minibuffer-key-bindings'.
2895 ;; Need do `C-g' anyway, even if inherit completion map.
2896 (define-key map (icicle-kbd "C-g") (if (and (fboundp 'minibuffer-keyboard-quit)
2897 delete-selection-mode)
2898 'minibuffer-keyboard-quit
2899 'abort-recursive-edit)) ; `C-g'
2900 (define-key map (icicle-kbd "M-r") 'previous-matching-history-element) ; `M-r'
2901 (define-key map (icicle-kbd "M-s") 'next-matching-history-element) ; `M-s'
2902 (define-key map (icicle-kbd "C-j") 'minibuffer-complete-and-exit) ; `C-j' (newline)
2903 )) ; End `minibuffer-local-must-match-map'.
2904
2905 ;; `completion-list-mode-map': map for `*Completions*' buffer.
2906 (let ((map completion-list-mode-map))
2907 ;; Keyboard keys
2908 (icicle-restore-custom-minibuffer-keys map icicle-completion-list-key-bindings)
2909 (dolist (key icicle-candidate-help-keys) (define-key map key nil))
2910 (define-key map (icicle-kbd "C-g") nil)
2911 (define-key map (icicle-kbd "C-M-S-t") nil)
2912 ;; Do these last:
2913 (define-key map (icicle-kbd "right") 'next-completion)
2914 (define-key map (icicle-kbd "left") 'previous-completion))))
2915 (when (and (interactive-p) turn-on-p)
2916 (message (substitute-command-keys
2917 "Use `\\<minibuffer-local-completion-map>\
2918 \\[icicle-minibuffer-help]' in minibuffer for help."))))
2919
2920 (defun icicle-unmap (command map current)
2921 "In MAP, unbind any keys that are bound to COMMAND.
2922 If command remapping is available, remap COMMAND to nil in MAP,
2923 unbinding it.
2924 Otherwise, bind COMMAND to whatever CURRENT is bound to in MAP."
2925 (if (fboundp 'command-remapping)
2926 (define-key map (vector 'remap command) nil)
2927 (substitute-key-definition current command map)))
2928
2929 (defun icicle-rebind-global (old new map)
2930 "Bind command NEW in MAP to all keys currently bound globally to OLD."
2931 (substitute-key-definition old new map (current-global-map)))
2932
2933 (defun icicle-bind-completion-keys (map)
2934 "Bind keys for minibuffer completion map MAP.
2935 MAP is `minibuffer-local-completion-map' or
2936 `minibuffer-local-must-match-map'."
2937
2938 ;; Menu-bar `Minibuf' menu.
2939
2940 (define-key map [menu-bar minibuf separator-complete2] '("--"))
2941 (define-key map [menu-bar minibuf word-complete]
2942 '(menu-item "Word-Complete" icicle-prefix-word-complete
2943 :help "Complete at most one word of prefix"))
2944 (define-key map [menu-bar minibuf prefix-complete]
2945 '(menu-item "Prefix-Complete" icicle-prefix-complete
2946 :help "Complete prefix as far as possible"))
2947 (define-key map [menu-bar minibuf apropos-complete]
2948 '(menu-item "Apropos-Complete" icicle-apropos-complete :keys "S-TAB"
2949 :help "Complete regular expression as far as possible and list completions"))
2950 (define-key map [menu-bar minibuf separator-complete1] '("--"))
2951
2952
2953 ;; In Emacs 22+, local is parent of local-completion
2954 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map))
2955 (define-key-after (lookup-key map [menu-bar minibuf]) [icicle-top-level]
2956 '(menu-item "Top Level" icicle-top-level
2957 :help "Cancel all minibuffers and return to the top level")
2958 'quit)
2959 (define-key map [menu-bar minibuf icicle-recomplete-from-original-domain]
2960 '(menu-item "Recompute Completions" icicle-recomplete-from-original-domain
2961 :enable (and (active-minibuffer-window) icicle-completing-p)
2962 :help "Recomplete your last typed input, using the original domain."))
2963 (define-key map [menu-bar minibuf quit] ; Replace `keyboard-escape-quit'
2964 '(menu-item "Quit" icicle-abort-recursive-edit
2965 :help "Cancel this minibuffer and return to the next higher level"))
2966 (define-key map [menu-bar minibuf return]
2967 '(menu-item "Enter" exit-minibuffer
2968 :help "Terminate input and exit minibuffer" :keys "RET"))
2969 (define-key map [menu-bar minibuf separator-help] '("--"))
2970
2971 (when (fboundp 'icicle-complete-keys)
2972 (define-key map [menu-bar minibuf icicle-complete-keys]
2973 '(menu-item "Show Available Keys (Complete Key)" icicle-complete-keys
2974 :help "Show available keys (`C-g') or complete prefix key")))
2975 (define-key map [menu-bar minibuf completion-help]
2976 '(menu-item "Icicles Help" icicle-minibuffer-help
2977 :help "Display help for minibuffer input and completion" :keys "M-?"))
2978 (define-key map [menu-bar minibuf separator-last] '("--"))
2979
2980 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain]
2981 '(menu-item "Toggle Searching Complement"
2982 icicle-toggle-search-complementing-domain
2983 :help "Toggle `icicle-search-complement-domain-p'" :keys "C-M-~"))
2984 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current]
2985 '(menu-item "Toggle All-Current Icicle-Search Highlighting"
2986 icicle-toggle-highlight-all-current :enable icicle-searching-p
2987 :help "Toggle `icicle-search-highlight-all-current-flag'" :keys "C-^"))
2988 (define-key map [menu-bar minibuf icicle-multi-inputs-save]
2989 '(menu-item "Save Multiple Inputs for Completion" icicle-multi-inputs-save
2990 :help "Add inputs in minibuffer to saved candidates set for completion"))
2991 (define-key map [menu-bar minibuf icicle-multi-inputs-act]
2992 '(menu-item "Act on Multiple Inputs" icicle-multi-inputs-act
2993 :help "Parse minibuffer input into a list of candidates, then act on each"))
2994 (define-key map [menu-bar minibuf separator-misc] '("--"))
2995
2996 ;; Submenus.
2997 (define-key map [menu-bar minibuf edit]
2998 (list 'menu-item "Edit" icicle-minibuf-edit-menu-map))
2999 (define-key map [menu-bar minibuf history]
3000 (list 'menu-item "History" icicle-minibuf-history-menu-map))
3001
3002 )
3003
3004 ;; Remove some standard menu items.
3005 (define-key map [menu-bar minibuf ?\?] nil)
3006 (define-key map [menu-bar minibuf space] nil)
3007 (define-key map [menu-bar minibuf tab] nil)
3008
3009 ;; Submenus.
3010 (define-key map [menu-bar minibuf candidate-action]
3011 (list 'menu-item "Act on All Candidates" icicle-minibuf-act-on-all-menu-map))
3012 (define-key map [menu-bar minibuf candidate-set]
3013 (list 'menu-item "Candidate Set" icicle-minibuf-candidate-set-menu-map))
3014 (define-key map [menu-bar minibuf save/retrieve]
3015 (list 'menu-item "Save/Retrieve Candidates" icicle-minibuf-save-retrieve-menu-map))
3016
3017 ;; Remap some commands for completion.
3018 (icicle-remap 'self-insert-command 'icicle-self-insert map (current-global-map))
3019 (icicle-remap 'universal-argument 'icicle-universal-argument ; `C-u'
3020 map (current-global-map))
3021 (icicle-remap 'negative-argument 'icicle-negative-argument ; `M--'
3022 map (current-global-map))
3023 (icicle-remap 'digit-argument 'icicle-digit-argument ; `C-9'
3024 map (current-global-map))
3025 (icicle-remap 'backward-delete-char-untabify 'icicle-backward-delete-char-untabify ; `DEL'
3026 map (current-global-map))
3027 (icicle-remap 'delete-backward-char 'icicle-delete-backward-char ; `DEL'
3028 map (current-global-map))
3029 (icicle-remap 'delete-char 'icicle-delete-char ; `C-d', `deletechar'
3030 map (current-global-map))
3031 (icicle-remap 'backward-kill-word 'icicle-backward-kill-word ; `M-DEL'
3032 map (current-global-map))
3033 (icicle-remap 'kill-word 'icicle-kill-word ; `M-d'
3034 map (current-global-map))
3035 (icicle-remap 'backward-kill-sexp 'icicle-backward-kill-sexp ; `C-M-backspace'
3036 map (current-global-map))
3037 (icicle-remap 'kill-sexp 'icicle-kill-sexp ; `C-M-k', `C-M-delete'
3038 map (current-global-map))
3039 (icicle-remap 'backward-kill-sentence 'icicle-backward-kill-sentence ; `C-x DEL'
3040 map (current-global-map))
3041 (icicle-remap 'backward-kill-paragraph 'icicle-backward-kill-paragraph ; `C-backspace'
3042 map (current-global-map))
3043 (icicle-remap 'kill-paragraph 'icicle-kill-paragraph ; `C-delete'
3044 map (current-global-map))
3045 (icicle-remap 'kill-line 'icicle-kill-line ; `C-k', `deleteline'
3046 map (current-global-map))
3047 (icicle-remap 'reposition-window 'icicle-goto/kill-failed-input ; `C-M-l'
3048 map (current-global-map))
3049 (icicle-remap 'transpose-chars 'icicle-transpose-chars ; `C-t'
3050 map (current-global-map))
3051 (icicle-remap 'transpose-words 'icicle-transpose-words ; `M-t'
3052 map (current-global-map))
3053 (icicle-remap 'transpose-sexps 'icicle-transpose-sexps ; `C-M-t'
3054 map (current-global-map))
3055 (icicle-remap 'yank-pop 'icicle-yank-pop ; `M-y', `M-insert'
3056 map (current-global-map))
3057 (icicle-remap 'mouse-yank-secondary 'icicle-mouse-yank-secondary ; `M-mouse-2'
3058 map (current-global-map))
3059
3060 ;; Bind additional keys.
3061 (dolist (key icicle-candidate-action-keys)
3062 (define-key map key 'icicle-candidate-action)) ; `C-return', `C-RET'
3063 (dolist (key icicle-candidate-help-keys) ; `C-M-return', `C-M-RET', `C-help', `C-M-help',
3064 (define-key map key 'icicle-help-on-candidate)) ; `C-f1', `C-M-f1'
3065
3066 (dolist (key icicle-word-completion-keys)
3067 (define-key map key 'icicle-prefix-word-complete)) ; `M-SPC'
3068 (dolist (key icicle-apropos-complete-keys)
3069 (define-key map key 'icicle-apropos-complete)) ; `S-TAB'
3070 (dolist (key icicle-prefix-complete-keys) (define-key map key 'icicle-prefix-complete)) ; `TAB'
3071 (dolist (key icicle-apropos-complete-no-display-keys)
3072 (define-key map key 'icicle-apropos-complete-no-display)) ; `C-M-S-TAB'
3073 (dolist (key icicle-prefix-complete-no-display-keys)
3074 (define-key map key 'icicle-prefix-complete-no-display)) ; `C-M-TAB'
3075 (icicle-define-cycling-keys map) ; `up', `down', `prior', `next',
3076 ; `C-up', `C-down', `C-prior', `C-next',
3077 ; `C-M-up', `C-M-down', `C-M-prior', `C-M-next',
3078 ; `C-S-up', `C-S-down', `C-S-prior', `C-S-next',
3079 (icicle-bind-custom-minibuffer-keys map icicle-completion-key-bindings))
3080
3081 (defun icicle-restore-completion-keys (map)
3082 "Restore standard keys for minibuffer completion map MAP.
3083 MAP is `minibuffer-local-completion-map',
3084 `minibuffer-local-filename-completion-map', or
3085 `minibuffer-local-must-match-map'."
3086
3087 ;; Menu-bar `Minibuf' menu.
3088 ;; In Emacs 22+, local is parent of local-completion
3089 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map))
3090 (define-key map [menu-bar minibuf quit]
3091 '(menu-item "Quit" keyboard-escape-quit :help "Abort input and exit minibuffer"))
3092 (define-key map [menu-bar minibuf return]
3093 '(menu-item "Enter" exit-minibuffer
3094 :help "Terminate input and exit minibuffer" :keys "RET"))
3095 (define-key map [menu-bar minibuf separator-help] nil)
3096 (define-key map [menu-bar minibuf completion-help] nil)
3097 (define-key map [menu-bar minibuf separator-last] nil)
3098 (define-key map [menu-bar minibuf icicle-clear-current-history] nil)
3099 (define-key map [menu-bar minibuf icicle-toggle-search-complementing-domain] nil)
3100 (define-key map [menu-bar minibuf icicle-toggle-highlight-all-current] nil)
3101 (define-key map [menu-bar minibuf icicle-regexp-quote-input] nil)
3102 (define-key map [menu-bar minibuf separator-set2] nil)
3103 (define-key map [menu-bar minibuf icicle-clear-current-history] nil)
3104 (define-key map [menu-bar minibuf icicle-erase-minibuffer] nil)
3105 (define-key map [menu-bar minibuf icicle-delete-history-element] nil)
3106 (define-key map [menu-bar minibuf icicle-insert-list-join-string] nil)
3107 (define-key map [menu-bar minibuf icicle-insert-key-description] nil)
3108 (define-key map [menu-bar minibuf icicle-insert-history-element] nil)
3109 (define-key map [menu-bar minibuf icicle-insert-string-from-a-var] nil)
3110 (define-key map [menu-bar minibuf icicle-insert-string-from-std-var] nil)
3111 (define-key map [menu-bar minibuf icicle-insert-string-at-point] nil)
3112 (define-key map [menu-bar minibuf icicle-completing-read+insert] nil)
3113 (define-key map [menu-bar minibuf icicle-read+insert-file-name] nil)
3114 )
3115 (define-key map [menu-bar minibuf icicle-goto/kill-failed-input] nil)
3116 (define-key map [menu-bar minibuf icicle-retrieve-next-input] nil)
3117 (define-key map [menu-bar minibuf icicle-retrieve-previous-input] nil)
3118 (define-key map [menu-bar minibuf separator-C-l] nil)
3119 (define-key map [menu-bar minibuf alt-action-list-all] nil)
3120 (define-key map [menu-bar minibuf alt-action-all] nil)
3121 (define-key map [menu-bar minibuf action-list-all] nil)
3122 (define-key map [menu-bar minibuf action-all] nil)
3123 (define-key map [menu-bar minibuf separator-actions] nil)
3124 (define-key map [menu-bar minibuf set-define] nil)
3125 (define-key map [menu-bar minibuf icicle-keep-only-past-inputs] nil)
3126 (define-key map [menu-bar minibuf set-union] nil)
3127 (define-key map [menu-bar minibuf set-difference] nil)
3128 (define-key map [menu-bar minibuf set-intersection] nil)
3129 (define-key map [menu-bar minibuf icicle-save-predicate-to-variable] nil)
3130 (define-key map [menu-bar minibuf icicle-narrow-candidates-with-predicate] nil)
3131 (define-key map [menu-bar minibuf icicle-narrow-candidates] nil)
3132 (define-key map [menu-bar minibuf icicle-widen-candidates] nil)
3133 (define-key map [menu-bar minibuf set-complement] nil)
3134 (define-key map [menu-bar minibuf separator-set1] nil)
3135 (define-key map [menu-bar minibuf set-swap] nil)
3136 (define-key map [menu-bar minibuf icicle-candidate-set-save-more-selected] nil)
3137 (define-key map [menu-bar minibuf icicle-candidate-set-save-selected] nil)
3138 (define-key map [menu-bar minibuf icicle-candidate-set-save-more] nil)
3139 (define-key map [menu-bar minibuf set-retrieve-from-cache-file] nil)
3140 (define-key map [menu-bar minibuf set-retrieve-from-variable] nil)
3141 (define-key map [menu-bar minibuf set-retrieve] nil)
3142 (define-key map [menu-bar minibuf set-save-to-cache-file] nil)
3143 (define-key map [menu-bar minibuf set-save-to-variable] nil)
3144 (define-key map [menu-bar minibuf set-save] nil)
3145 (define-key map [menu-bar minibuf separator-set2] nil)
3146 (define-key map [menu-bar minibuf word-complete] nil)
3147 (define-key map [menu-bar minibuf prefix-complete] nil)
3148 (define-key map [menu-bar minibuf apropos-complete] nil)
3149 (define-key map [menu-bar minibuf ?\?]
3150 '(menu-item "List Completions" minibuffer-completion-help
3151 :help "Display all possible completions"))
3152 (define-key map [menu-bar minibuf space]
3153 '(menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word"))
3154 (define-key map [menu-bar minibuf tab]
3155 '(menu-item "Complete" minibuffer-complete :help "Complete as far as possible"))
3156
3157 ;; Unmap commands that were bound for completion.
3158 (icicle-unmap 'self-insert-command map 'icicle-self-insert)
3159 (icicle-unmap 'universal-argument map 'icicle-universal-argument)
3160 (icicle-unmap 'negative-argument map 'icicle-negative-argument)
3161 (icicle-unmap 'digit-argument map 'icicle-digit-argument)
3162 (icicle-unmap 'backward-delete-char-untabify map 'icicle-backward-delete-char-untabify)
3163 (icicle-unmap 'delete-backward-char map 'icicle-delete-backward-char)
3164 (icicle-unmap 'delete-char map 'icicle-delete-char)
3165 (icicle-unmap 'backward-kill-word map 'icicle-backward-kill-word)
3166 (icicle-unmap 'kill-word map 'icicle-kill-word)
3167 (icicle-unmap 'backward-kill-sexp map 'icicle-backward-kill-sexp)
3168 (icicle-unmap 'kill-sexp map 'icicle-kill-sexp)
3169 (icicle-unmap 'backward-kill-sentence map 'icicle-backward-kill-sentence)
3170 (icicle-unmap 'backward-kill-paragraph map 'icicle-backward-kill-paragraph)
3171 (icicle-unmap 'kill-paragraph map 'icicle-kill-paragraph)
3172 (icicle-unmap 'kill-line map 'icicle-kill-line)
3173 (icicle-unmap 'reposition-window map 'icicle-goto/kill-failed-input)
3174 (icicle-unmap 'transpose-chars map 'icicle-transpose-chars)
3175 (icicle-unmap 'transpose-words map 'icicle-transpose-words)
3176 (icicle-unmap 'transpose-sexps map 'icicle-transpose-sexps)
3177 (icicle-unmap 'yank-pop map 'icicle-yank-pop)
3178 (icicle-unmap 'mouse-yank-secondary map 'icicle-mouse-yank-secondary)
3179
3180 ;; Restore additional bindings.
3181 ;; Do the option keys first, so they can be rebound as needed.
3182 (dolist (key icicle-candidate-action-keys) (define-key map key nil))
3183 (dolist (key icicle-candidate-help-keys) (define-key map key nil))
3184 (dolist (key icicle-word-completion-keys) (define-key map key nil))
3185 (dolist (key icicle-apropos-complete-keys) (define-key map key nil))
3186 (dolist (key icicle-prefix-complete-keys) (define-key map key nil))
3187 (dolist (key icicle-apropos-complete-no-display-keys) (define-key map key nil))
3188 (dolist (key icicle-prefix-complete-no-display-keys) (define-key map key nil))
3189 (dolist (key icicle-prefix-cycle-previous-keys) (define-key map key nil))
3190 (dolist (key icicle-prefix-cycle-next-keys) (define-key map key nil))
3191 (dolist (key icicle-apropos-cycle-previous-keys) (define-key map key nil))
3192 (dolist (key icicle-apropos-cycle-next-keys) (define-key map key nil))
3193 (dolist (key icicle-prefix-cycle-previous-action-keys) (define-key map key nil))
3194 (dolist (key icicle-prefix-cycle-previous-alt-action-keys) (define-key map key nil))
3195 (dolist (key icicle-prefix-cycle-next-action-keys) (define-key map key nil))
3196 (dolist (key icicle-prefix-cycle-next-alt-action-keys) (define-key map key nil))
3197 (dolist (key icicle-apropos-cycle-previous-action-keys) (define-key map key nil))
3198 (dolist (key icicle-apropos-cycle-previous-alt-action-keys) (define-key map key nil))
3199 (dolist (key icicle-apropos-cycle-next-action-keys) (define-key map key nil))
3200 (dolist (key icicle-apropos-cycle-next-alt-action-keys) (define-key map key nil))
3201 (dolist (key icicle-modal-cycle-up-keys) (define-key map key nil))
3202 (dolist (key icicle-modal-cycle-down-keys) (define-key map key nil))
3203 (dolist (key icicle-modal-cycle-up-action-keys) (define-key map key nil))
3204 (dolist (key icicle-modal-cycle-up-alt-action-keys) (define-key map key nil))
3205 (dolist (key icicle-modal-cycle-down-action-keys) (define-key map key nil))
3206 (dolist (key icicle-modal-cycle-down-alt-action-keys) (define-key map key nil))
3207 (dolist (key icicle-modal-cycle-up-help-keys) (define-key map key nil))
3208 (dolist (key icicle-modal-cycle-down-help-keys) (define-key map key nil))
3209 (dolist (key icicle-prefix-cycle-previous-help-keys) (define-key map key nil))
3210 (dolist (key icicle-prefix-cycle-next-help-keys) (define-key map key nil))
3211 (dolist (key icicle-apropos-cycle-previous-help-keys) (define-key map key nil))
3212 (dolist (key icicle-apropos-cycle-next-help-keys) (define-key map key nil))
3213
3214 (icicle-restore-custom-minibuffer-keys map icicle-completion-key-bindings)
3215
3216 ;; Do these last. -----------------
3217 (define-key map (icicle-kbd "C-i") 'minibuffer-complete)
3218 (define-key map (icicle-kbd "tab") 'minibuffer-complete)
3219 (define-key map (icicle-kbd "?") 'minibuffer-completion-help)
3220 (define-key map (icicle-kbd "SPC") 'minibuffer-complete-word)
3221 (define-key map (icicle-kbd "C-g") (if (and (fboundp 'minibuffer-keyboard-quit)
3222 delete-selection-mode)
3223 'minibuffer-keyboard-quit
3224 'abort-recursive-edit))
3225 ;; In Emacs 22+, local is parent of local-completion
3226 (unless (eq minibuffer-local-map (keymap-parent minibuffer-local-completion-map))
3227 (define-key map (icicle-kbd "C-j") 'exit-minibuffer))
3228 (define-key map (icicle-kbd "M-p") 'previous-history-element)
3229 (define-key map (icicle-kbd "M-n") 'next-history-element)
3230 (define-key map (icicle-kbd "up") 'previous-history-element)
3231 (define-key map (icicle-kbd "down") 'next-history-element)
3232 (define-key map (icicle-kbd "M-v") 'switch-to-completions)
3233 (define-key map (icicle-kbd "prior") 'switch-to-completions)
3234 (define-key map (icicle-kbd "next") 'next-history-element))
3235
3236 (defun icicle-bind-custom-minibuffer-keys (map option &optional defs)
3237 "Bind customizable keys for minibuffer completion map MAP.
3238 These are the keys defined by option OPTION."
3239 (let (key command condition)
3240 (unless defs (setq defs option))
3241 (dolist (key-def defs)
3242 (setq key (car key-def)
3243 command (cadr key-def)
3244 condition (car (cddr key-def)))
3245 (when (eval condition)
3246 (if (symbolp key)
3247 (icicle-remap key command map)
3248 (define-key map key command))))))
3249
3250 (defun icicle-restore-custom-minibuffer-keys (map option)
3251 "Restore customizable keys for minibuffer map MAP.
3252 These are the keys defined by option OPTION."
3253 (let (key condition)
3254 (dolist (key-def option)
3255 (setq key (car key-def)
3256 condition (car (cddr key-def)))
3257 (when (eval condition)
3258 (if (symbolp key)
3259 (icicle-remap key nil map)
3260 (define-key map key nil))))))
3261
3262 (defun icicle-minibuffer-setup ()
3263 "Run in minibuffer on activation, to enable completion cycling.
3264 Usually run by inclusion in `minibuffer-setup-hook'."
3265 (when (and icicle-mode (window-minibuffer-p (selected-window)) (not executing-kbd-macro))
3266 ;; The pre- and post-command hooks are local to the
3267 ;; minibuffer, so they are added here, not in `icicle-mode'.
3268 ;; They are removed in `icicle-mode' when mode is exited.
3269 (unless (fboundp 'define-minor-mode) (make-local-hook 'pre-command-hook))
3270 (add-hook 'pre-command-hook 'icicle-top-level-prep) ; This must not be LOCAL (nil LOCAL arg).
3271 (add-hook 'pre-command-hook 'icicle-run-icicle-pre-command-hook nil t)
3272 (unless (fboundp 'define-minor-mode) (make-local-hook 'post-command-hook))
3273 (add-hook 'post-command-hook 'icicle-run-icicle-post-command-hook nil t)
3274 ;; Change the region background here dynamically. It would be better to
3275 ;; just use a buffer-local face, but those don't yet exist.
3276 (when (= 1 (recursion-depth))
3277 (setq icicle-saved-region-background (face-background 'region))
3278 (when icicle-change-region-background-flag
3279 (set-face-background 'region icicle-region-background)))
3280 ;; Reset prompt, because some commands (e.g. `find-file') don't use `read-file-name'
3281 ;; or `completing-read'. Reset other stuff too.
3282 (setq icicle-candidate-nb nil
3283 icicle-last-icomplete-mode-value (and (featurep 'icomplete)
3284 (or icomplete-mode
3285 icicle-last-icomplete-mode-value))
3286 icicle-completion-candidates nil
3287 ;; This is so that cycling works right initially, without first hitting `TAB' or `S-TAB'.
3288 icicle-current-completion-mode (and (< (minibuffer-depth) 2)
3289 (case icicle-default-cycling-mode
3290 ((nil) nil)
3291 (apropos 'apropos)
3292 (prefix 'prefix)
3293 (otherwise nil)))
3294 icicle-mode-line-help nil
3295 icicle-next-apropos-complete-cycles-p nil
3296 icicle-next-prefix-complete-cycles-p nil
3297 icicle-incremental-completion-p icicle-incremental-completion
3298 icicle-initial-value nil
3299 icicle-cmd-reading-input this-command
3300 icicle-last-completion-command nil
3301 icicle-last-completion-candidate nil
3302 icicle-last-input nil
3303 icicle-input-fail-pos nil
3304 icicle-saved-proxy-candidates nil
3305 ;; `other-buffer' doesn't work, because it looks for a buffer only from the same frame.
3306 icicle-pre-minibuffer-buffer (cadr (buffer-list)) ; $$$$$$ (other-buffer nil t)
3307 )
3308 (when (and (icicle-completing-p) (> emacs-major-version 20))
3309 (let ((prompt-prefix (if icicle-candidate-action-fn "+ " ". ")))
3310 (put-text-property 0 1 'face
3311 (cond ((and icicle-candidate-action-fn (icicle-require-match-p))
3312 '(icicle-multi-command-completion icicle-mustmatch-completion))
3313 (icicle-candidate-action-fn 'icicle-multi-command-completion)
3314 ((icicle-require-match-p)
3315 '(icicle-completion icicle-mustmatch-completion))
3316 (t 'icicle-completion))
3317 prompt-prefix)
3318 (if (overlayp icicle-completion-prompt-overlay)
3319 (move-overlay icicle-completion-prompt-overlay (point-min) (point-min))
3320 (setq icicle-completion-prompt-overlay (make-overlay (point-min) (point-min))))
3321 (overlay-put icicle-completion-prompt-overlay 'before-string prompt-prefix)))
3322 (unless icicle-add-proxy-candidates-flag
3323 (setq icicle-saved-proxy-candidates (prog1 icicle-proxy-candidates
3324 (setq icicle-proxy-candidates
3325 icicle-saved-proxy-candidates))))
3326 (while icicle-saved-candidate-overlays
3327 (delete-overlay (car icicle-saved-candidate-overlays))
3328 (setq icicle-saved-candidate-overlays (cdr icicle-saved-candidate-overlays)))
3329 (icicle-update-ignored-extensions-regexp)
3330 (when (memq icicle-default-value '(preselect-start preselect-end))
3331 (icicle-select-minibuffer-contents))
3332 (when (and icicle-show-Completions-initially-flag
3333 (not icicle-progressive-completing-p) ; If narrowed, then we have already completed.
3334 (icicle-completing-p) ; Function initializes variable `icicle-completing-p'.
3335 (sit-for icicle-incremental-completion-delay)) ; Let user interrupt.
3336 (case icicle-default-cycling-mode
3337 (apropos (icicle-apropos-complete))
3338 (otherwise (icicle-prefix-complete)))) ; Prefix completion, by default.
3339 (run-hooks 'icicle-minibuffer-setup-hook)))
3340
3341 (defun icicle-define-cycling-keys (map)
3342 "Define keys for cycling candidates.
3343 The modal keys are defined first, then the non-modal keys.
3344 That means that in case of conflict mode-specific cyling wins.
3345 For example, if you define both `icicle-modal-cycle-up-keys' and
3346 `icicle-prefix-cycle-previous-keys' as ([up]), the latter gets the
3347 binding."
3348 (cond (icicle-use-C-for-actions-flag ; Use `C-' for actions, no `C-' for plain cycling.
3349 ;; Modal cycling keys.
3350 (dolist (key icicle-modal-cycle-up-keys)
3351 (define-key map key 'icicle-previous-candidate-per-mode)) ; `up'
3352 (dolist (key icicle-modal-cycle-down-keys)
3353 (define-key map key 'icicle-next-candidate-per-mode)) ; `down'
3354 (dolist (key icicle-modal-cycle-up-action-keys)
3355 (define-key map key 'icicle-previous-candidate-per-mode-action)) ; `C-up'
3356 (dolist (key icicle-modal-cycle-down-action-keys)
3357 (define-key map key 'icicle-next-candidate-per-mode-action)) ; `C-down'
3358 ;; Non-modal cycling keys. In case of conflict, these will prevail over modal keys.
3359 (dolist (key icicle-prefix-cycle-previous-keys)
3360 (define-key map key 'icicle-previous-prefix-candidate)) ; `home'
3361 (dolist (key icicle-prefix-cycle-next-keys)
3362 (define-key map key 'icicle-next-prefix-candidate)) ; `end'
3363 (dolist (key icicle-apropos-cycle-previous-keys)
3364 (define-key map key 'icicle-previous-apropos-candidate)) ; `prior'
3365 (dolist (key icicle-apropos-cycle-next-keys)
3366 (define-key map key 'icicle-next-apropos-candidate)) ; `next'
3367 (dolist (key icicle-prefix-cycle-previous-action-keys)
3368 (define-key map key 'icicle-previous-prefix-candidate-action)) ; `C-home'
3369 (dolist (key icicle-prefix-cycle-next-action-keys)
3370 (define-key map key 'icicle-next-prefix-candidate-action)) ; `C-end'
3371 (dolist (key icicle-apropos-cycle-previous-action-keys)
3372 (define-key map key 'icicle-previous-apropos-candidate-action)) ; `C-prior'
3373 (dolist (key icicle-apropos-cycle-next-action-keys)
3374 (define-key map key 'icicle-next-apropos-candidate-action))) ; `C-next'
3375
3376 (t ; Use `C-' for plain cycling, NO `C-' for action.
3377 ;; Modal cycling keys. At least some of these will overwrite non-modal keys.
3378 (dolist (key icicle-modal-cycle-up-keys)
3379 (define-key map key 'icicle-previous-candidate-per-mode-action)) ; `up'
3380 (dolist (key icicle-modal-cycle-down-keys)
3381 (define-key map key 'icicle-next-candidate-per-mode-action)) ; `down'
3382 (dolist (key icicle-modal-cycle-up-action-keys)
3383 (define-key map key 'icicle-previous-candidate-per-mode)) ; `C-up'
3384 (dolist (key icicle-modal-cycle-down-action-keys)
3385 (define-key map key 'icicle-next-candidate-per-mode)) ; `C-down'
3386 ;; Non-modal cycling keys. In case of conflict, these will prevail over modal keys.
3387 (dolist (key icicle-prefix-cycle-previous-keys)
3388 (define-key map key 'icicle-previous-prefix-candidate-action)) ; `home'
3389 (dolist (key icicle-prefix-cycle-next-keys)
3390 (define-key map key 'icicle-next-prefix-candidate-action)) ; `end'
3391 (dolist (key icicle-apropos-cycle-previous-keys)
3392 (define-key map key 'icicle-previous-apropos-candidate-action)) ; `prior'
3393 (dolist (key icicle-apropos-cycle-next-keys)
3394 (define-key map key 'icicle-next-apropos-candidate-action)) ; `next'
3395 (dolist (key icicle-prefix-cycle-previous-action-keys)
3396 (define-key map key 'icicle-previous-prefix-candidate)) ; `C-home'
3397 (dolist (key icicle-prefix-cycle-next-action-keys)
3398 (define-key map key 'icicle-next-prefix-candidate)) ; `C-end'
3399 (dolist (key icicle-apropos-cycle-previous-action-keys)
3400 (define-key map key 'icicle-previous-apropos-candidate)) ; `C-prior'
3401 (dolist (key icicle-apropos-cycle-next-action-keys)
3402 (define-key map key 'icicle-next-apropos-candidate))))
3403
3404 ;; Help and alternative-action keys are NOT controlled by `icicle-use-C-for-actions-flag'.
3405 ;;
3406 ;; Define modal cycling help and alternative action keys.
3407 (dolist (key icicle-modal-cycle-up-help-keys)
3408 (define-key map key 'icicle-previous-candidate-per-mode-help)) ; `C-M-up'
3409 (dolist (key icicle-modal-cycle-down-help-keys)
3410 (define-key map key 'icicle-next-candidate-per-mode-help)) ; `C-M-down'
3411 (dolist (key icicle-modal-cycle-up-alt-action-keys)
3412 (define-key map key 'icicle-previous-candidate-per-mode-alt-action)) ; `C-S-up'
3413 (dolist (key icicle-modal-cycle-down-alt-action-keys)
3414 (define-key map key 'icicle-next-candidate-per-mode-alt-action)) ; `C-S-down'
3415 ;; Define non-modal cycling help and alternative action keys.
3416 (dolist (key icicle-prefix-cycle-previous-help-keys)
3417 (define-key map key 'icicle-help-on-previous-prefix-candidate)) ; `C-M-home'
3418 (dolist (key icicle-prefix-cycle-next-help-keys)
3419 (define-key map key 'icicle-help-on-next-prefix-candidate)) ; `C-M-end'
3420 (dolist (key icicle-apropos-cycle-previous-help-keys)
3421 (define-key map key 'icicle-help-on-previous-apropos-candidate)) ; `C-M-prior'
3422 (dolist (key icicle-apropos-cycle-next-help-keys)
3423 (define-key map key 'icicle-help-on-next-apropos-candidate)) ; `C-M-next'
3424 (dolist (key icicle-prefix-cycle-previous-alt-action-keys)
3425 (define-key map key 'icicle-previous-prefix-candidate-alt-action)) ; `C-S-home'
3426 (dolist (key icicle-prefix-cycle-next-alt-action-keys)
3427 (define-key map key 'icicle-next-prefix-candidate-alt-action)) ; `C-S-end'
3428 (dolist (key icicle-apropos-cycle-previous-alt-action-keys)
3429 (define-key map key 'icicle-previous-apropos-candidate-alt-action)) ; `C-S-prior'
3430 (dolist (key icicle-apropos-cycle-next-alt-action-keys)
3431 (define-key map key 'icicle-next-apropos-candidate-alt-action))) ; `C-S-next'
3432
3433 (defun icicle-select-minibuffer-contents ()
3434 "Select minibuffer contents and leave point at its beginning."
3435 (let ((min (icicle-minibuffer-prompt-end)))
3436 (set-mark (if (eq 'preselect-start icicle-default-value) (point-max) min))
3437 (goto-char (if (eq 'preselect-start icicle-default-value) min (point-max)))))
3438
3439 ;; $$$ (defadvice next-history-element (after icicle-select-minibuffer-contents activate)
3440 ;; "Select minibuffer contents and leave point at its beginning."
3441 ;; (when (and icicle-mode (memq icicle-default-value '(preselect-start preselect-end)))
3442 ;; (icicle-select-minibuffer-contents)
3443 ;; (setq deactivate-mark nil)))
3444
3445 (defun icicle-cancel-Help-redirection ()
3446 "Cancel redirection of focus from *Help* buffer to minibuffer.
3447 Focus was redirected during `icicle-help-on-candidate'."
3448 (let* ((help-window (get-buffer-window "*Help*" 0))
3449 (help-frame (and help-window (window-frame help-window))))
3450 (when help-frame (redirect-frame-focus help-frame))))
3451
3452 (defun icicle-run-icicle-pre-command-hook ()
3453 "Run `icicle-pre-command-hook' functions.
3454 Used in `pre-command-hook'."
3455 (run-hooks 'icicle-pre-command-hook))
3456
3457 (defun icicle-run-icicle-post-command-hook ()
3458 "Run `icicle-post-command-hook' functions.
3459 Used in `post-command-hook'."
3460 (run-hooks 'icicle-post-command-hook))
3461
3462 (defun icicle-set-calling-cmd ()
3463 "Remember last command that called for completion.
3464 Used in `completion-setup-hook'."
3465 (setq icicle-cmd-calling-for-completion this-command))
3466
3467 (defun icicle-update-ignored-extensions-regexp ()
3468 "Update ignored extensions if `completion-ignored-extensions' changed."
3469 (when (and (icicle-file-name-input-p) ; In `icicles-fn.el'.
3470 (not (equal icicle-ignored-extensions completion-ignored-extensions)))
3471 (setq icicle-ignored-extensions-regexp ; Make regexp for ignored file extensions.
3472 (concat "\\(" (mapconcat #'regexp-quote completion-ignored-extensions "\\|") "\\)\\'")
3473
3474 ;; Flag to prevent updating `icicle-ignored-extensions-regexp' unless
3475 ;; `completion-ignored-extensions' changes.
3476 icicle-ignored-extensions completion-ignored-extensions)))
3477
3478 ;; We change the region background here dynamically.
3479 ;; It would be better to just use a buffer-local face, but those don't yet exist.
3480 (defun icicle-restore-region-face ()
3481 "Restore region face. It was changed during minibuffer activity
3482 if `icicle-change-region-background-flag' is non-nil."
3483 (when (and icicle-change-region-background-flag (= 1 (recursion-depth)))
3484 (set-face-background 'region icicle-saved-region-background)))
3485
3486 (defun icicle-activate-mark ()
3487 "Prevent region from being deactivated. Used in `icicle-post-command-hook'."
3488 (when (and (window-minibuffer-p (selected-window))
3489 icicle-completing-p
3490 (not executing-kbd-macro))
3491 (setq deactivate-mark nil)))
3492
3493 (defun icicle-show-current-help-in-mode-line ()
3494 "Show `icicle-mode-line-help'. Used in `icicle-post-command-hook'."
3495 (when icicle-mode-line-help (icicle-show-help-in-mode-line icicle-mode-line-help)))
3496
3497 (defun icicle-redefine-standard-functions ()
3498 "Alias the functions in `icicle-functions-to-redefine' to Icicles versions."
3499 (when (fboundp 'icicle-completing-read)
3500 (dolist (fn icicle-functions-to-redefine)
3501 (when (fboundp (intern (concat "icicle-ORIG-" (symbol-name fn))))
3502 (fset fn (intern (concat "icicle-" (symbol-name fn))))))))
3503
3504 (defun icicle-restore-standard-functions ()
3505 "Restore original versions of functions in `icicle-functions-to-redefine'."
3506 (when (fboundp 'icicle-ORIG-completing-read)
3507 (let (orig-fn)
3508 (dolist (fn icicle-functions-to-redefine)
3509 (when (fboundp (setq orig-fn (intern (concat "icicle-ORIG-" (symbol-name fn)))))
3510 (fset fn orig-fn))))))
3511
3512 (defun icicle-redefine-standard-widgets ()
3513 "Alias the widgets in `icicle-widgets-to-redefine' to Icicles versions."
3514 (when (fboundp 'icicle-completing-read)
3515 (let (ici-wid)
3516 (dolist (wid icicle-widgets-to-redefine)
3517 (when (icicle-widgetp (intern (concat "icicle-ORIG-" (symbol-name wid))))
3518 (setq ici-wid (intern (concat "icicle-" (symbol-name wid))))
3519 (put wid 'widget-type (get ici-wid 'widget-type))
3520 (put wid 'widget-documentation (get ici-wid 'widget-documentation)))))))
3521
3522 (defun icicle-restore-standard-widgets ()
3523 "Restore original versions of widgets in `icicle-widgets-to-redefine'."
3524 (when (fboundp 'icicle-ORIG-completing-read)
3525 (let (orig-wid)
3526 (dolist (wid icicle-widgets-to-redefine)
3527 (when (icicle-widgetp (setq orig-wid (intern (concat "icicle-ORIG-" (symbol-name wid)))))
3528 (put wid 'widget-type (get orig-wid 'widget-type))
3529 (put wid 'widget-documentation (get orig-wid 'widget-documentation)))))))
3530
3531 ;;; In Emacs versions before 22:
3532 ;;; Save original `read-file-name'. We redefine it as `icicle-read-file-name' (which calls it).
3533 ;;; Then we restore it when you quit Icicle mode. (In Emacs 22+, no redefinition is needed.)
3534 (unless (or (boundp 'read-file-name-function) (fboundp 'icicle-ORIG-read-file-name))
3535 (defalias 'icicle-ORIG-read-file-name (symbol-function 'read-file-name)))
3536
3537 (defun icicle-redefine-std-completion-fns ()
3538 "Replace some standard functions with versions for Icicle mode."
3539 (when (fboundp 'icicle-completing-read)
3540 (fset 'choose-completion 'icicle-choose-completion)
3541 (fset 'choose-completion-string 'icicle-choose-completion-string)
3542 (fset 'completing-read 'icicle-completing-read)
3543 (when (fboundp 'icicle-completing-read-multiple)
3544 (fset 'completing-read-multiple 'icicle-completing-read-multiple)
3545 (setq crm-local-completion-map icicle-crm-local-completion-map
3546 crm-local-must-match-map icicle-crm-local-must-match-map))
3547 (fset 'completion-setup-function 'icicle-completion-setup-function)
3548 (unless (> emacs-major-version 22)
3549 (fset 'dired-smart-shell-command 'icicle-dired-smart-shell-command))
3550 (fset 'display-completion-list 'icicle-display-completion-list)
3551 (fset 'exit-minibuffer 'icicle-exit-minibuffer)
3552 (when (fboundp 'face-valid-attribute-values)
3553 (fset 'face-valid-attribute-values 'icicle-face-valid-attribute-values))
3554 (fset 'minibuffer-complete-and-exit 'icicle-minibuffer-complete-and-exit)
3555 (unless (or (> emacs-major-version 23) (and (= emacs-major-version 23)
3556 (> emacs-minor-version 1)))
3557 (fset 'mouse-choose-completion 'icicle-mouse-choose-completion)) ; Emacs < 23.2
3558 (fset 'next-history-element 'icicle-next-history-element)
3559 (fset 'read-buffer 'icicle-read-buffer)
3560 (fset 'read-face-name 'icicle-read-face-name)
3561 (if (boundp 'read-file-name-function) ; Emacs 22+
3562 (setq icicle-orig-read-file-name-fn (prog1 (and (not (eq read-file-name-function
3563 'icicle-read-file-name))
3564 read-file-name-function)
3565 (setq read-file-name-function
3566 'icicle-read-file-name)))
3567 (fset 'read-file-name 'icicle-read-file-name)) ; Emacs 20, 21
3568 (when (fboundp 'icicle-read-number)
3569 (fset 'read-number 'icicle-read-number))
3570 (unless (> emacs-major-version 22)
3571 (fset 'shell-command 'icicle-shell-command))
3572 (unless (> emacs-major-version 22)
3573 (fset 'shell-command-on-region 'icicle-shell-command-on-region))
3574 (when (> emacs-major-version 22)
3575 (fset 'sit-for 'icicle-sit-for))
3576 (fset 'switch-to-completions 'icicle-switch-to-completions)
3577 ))
3578
3579 (defun icicle-restore-std-completion-fns ()
3580 "Restore some standard functions that were replaced in Icicle mode."
3581 (when (fboundp 'icicle-ORIG-completing-read)
3582 (fset 'choose-completion 'icicle-ORIG-choose-completion)
3583 (fset 'choose-completion-string 'icicle-ORIG-choose-completion-string)
3584 (fset 'completing-read 'icicle-ORIG-completing-read)
3585 (when (fboundp 'icicle-ORIG-completing-read-multiple)
3586 (fset 'completing-read-multiple 'icicle-ORIG-completing-read-multiple)
3587 (setq crm-local-completion-map icicle-ORIG-crm-local-completion-map
3588 crm-local-must-match-map icicle-ORIG-crm-local-must-match-map))
3589 (fset 'completion-setup-function 'icicle-ORIG-completion-setup-function)
3590 (when (fboundp 'icicle-ORIG-dired-smart-shell-command) ; Emacs 23
3591 (fset 'dired-smart-shell-command 'icicle-ORIG-dired-smart-shell-command))
3592 (fset 'display-completion-list 'icicle-ORIG-display-completion-list)
3593 (fset 'exit-minibuffer 'icicle-ORIG-exit-minibuffer)
3594 (when (fboundp 'icicle-ORIG-face-valid-attribute-values)
3595 (fset 'face-valid-attribute-values 'icicle-ORIG-face-valid-attribute-values))
3596 (fset 'minibuffer-complete-and-exit 'icicle-ORIG-minibuffer-complete-and-exit)
3597 (unless (or (> emacs-major-version 23) (and (= emacs-major-version 23)
3598 (> emacs-minor-version 1)))
3599 (fset 'mouse-choose-completion 'icicle-ORIG-mouse-choose-completion)) ; Emacs < 23.2
3600 (fset 'next-history-element 'icicle-ORIG-next-history-element)
3601 (fset 'read-buffer 'icicle-ORIG-read-buffer)
3602 (fset 'read-face-name 'icicle-ORIG-read-face-name)
3603 (if (boundp 'read-file-name-function) ; Emacs 22+
3604 (setq read-file-name-function (and (not (eq icicle-orig-read-file-name-fn
3605 'icicle-read-file-name))
3606 icicle-orig-read-file-name-fn))
3607 (fset 'read-file-name 'icicle-ORIG-read-file-name)) ; Emacs 20, 21
3608 (when (fboundp 'icicle-ORIG-read-number)
3609 (fset 'read-number 'icicle-ORIG-read-number))
3610 (when (fboundp 'icicle-ORIG-shell-command) ; Emacs < 23
3611 (fset 'shell-command 'icicle-ORIG-shell-command))
3612 (when (fboundp 'icicle-ORIG-shell-command-on-region) ; Emacs < 23
3613 (fset 'shell-command-on-region 'icicle-ORIG-shell-command-on-region))
3614 (when (> emacs-major-version 22)
3615 (fset 'sit-for 'icicle-ORIG-sit-for))
3616 (fset 'switch-to-completions 'icicle-ORIG-switch-to-completions)
3617 ))
3618
3619 ;; Free vars here: `icicle-saved-kmacro-ring-max' is bound in `icicles-var.el'.
3620 (defun icicle-redefine-standard-options ()
3621 "Replace certain standard Emacs options with Icicles versions."
3622 (when (boundp 'icicle-search-ring-max)
3623 (setq icicle-saved-search-ring-max search-ring-max ; Save it.
3624 search-ring-max icicle-search-ring-max
3625 icicle-saved-regexp-search-ring-max regexp-search-ring-max ; Save it.
3626 regexp-search-ring-max icicle-regexp-search-ring-max))
3627 (when (boundp 'icicle-kmacro-ring-max)
3628 (setq icicle-saved-kmacro-ring-max kmacro-ring-max ; Save it.
3629 kmacro-ring-max icicle-kmacro-ring-max)))
3630
3631 (defun icicle-restore-standard-options ()
3632 "Restore standard Emacs options replaced in Icicle mode."
3633 (when (boundp 'icicle-saved-search-ring-max)
3634 (setq search-ring-max icicle-saved-search-ring-max
3635 regexp-search-ring-max icicle-saved-regexp-search-ring-max)))
3636
3637 ;; This is used only in Emacs 22+, but we define it always anyway.
3638 (defun icicle-undo-std-completion-faces ()
3639 "Get rid of standard completion-root highlighting in `*Completions*'."
3640 ;; Do this because the standard Emacs 22 highlighting can interfere with
3641 ;; apropos-completion highlighting.
3642 (when (fboundp 'face-spec-reset-face)
3643 (when (facep 'completions-common-part)
3644 (face-spec-reset-face 'completions-common-part)
3645 (set-face-attribute 'completions-common-part nil :inherit nil))
3646 (when (facep 'completions-first-difference)
3647 (face-spec-reset-face 'completions-first-difference)
3648 (set-face-attribute 'completions-first-difference nil :inherit nil))))
3649
3650
3651 ;;; Save original functions, so they can be restored when leave Icicle mode.
3652 ;;; Toggle Icicle mode after loading the library (and `icicles-mode.el'),
3653 ;;; to pick up the original definition.
3654 ;;;
3655 ;;; Note: The `boundp' test for `icicle-mode' is just in case the form gets evaluated while
3656 ;;; loading `icicles-mode.el' (e.g. the library gets loaded while loading `icicles-mode.el').
3657
3658 ;;; `comint.el' - `comint-dynamic-complete', `comint-dynamic-complete-filename',
3659 ;;; `comint-replace-by-expanded-filename', `comint-completion-at-point'.
3660 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3661 (when icyp (icicle-mode -1))
3662 (when (and (fboundp 'comint-dynamic-complete)
3663 (not (fboundp 'icicle-ORIG-comint-dynamic-complete)))
3664 (fset 'icicle-ORIG-comint-dynamic-complete
3665 (symbol-function 'comint-dynamic-complete)))
3666 (when (and (fboundp 'comint-dynamic-complete-filename)
3667 (not (fboundp 'icicle-ORIG-comint-dynamic-complete-filename)))
3668 (fset 'icicle-ORIG-comint-dynamic-complete-filename
3669 (symbol-function 'comint-dynamic-complete-filename)))
3670 (when (and (fboundp 'comint-replace-by-expanded-filename)
3671 (not (fboundp 'icicle-ORIG-comint-replace-by-expanded-filename)))
3672 (fset 'icicle-ORIG-comint-replace-by-expanded-filename
3673 (symbol-function 'comint-replace-by-expanded-filename)))
3674 (when (and (fboundp 'comint-completion-at-point) ; Emacs 24+
3675 (not (fboundp 'icicle-ORIG-comint-completion-at-point)))
3676 (fset 'icicle-ORIG-comint-completion-at-point
3677 (symbol-function 'comint-completion-at-point)))
3678 (when icyp (icicle-mode 1)))))
3679 (if (featurep 'comint) (eval-after-load "icicles-mode" form) (eval-after-load "comint" form)))
3680
3681 ;;; `ess-site.el' - `ess-complete-object-name'.
3682 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3683 (when icyp (icicle-mode -1))
3684 (when (and (fboundp 'ess-complete-object-name)
3685 (not (fboundp 'icicle-ORIG-ess-complete-object-name)))
3686 (fset 'icicle-ORIG-ess-complete-object-name
3687 (symbol-function 'ess-complete-object-name)))
3688 (when icyp (icicle-mode 1)))))
3689 (if (featurep 'ess-site) (eval-after-load "icicles-mode" form) (eval-after-load "ess-site" form)))
3690
3691 ;;; `gud.el' - `gud-gdb-complete-command'.
3692 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3693 (when icyp (icicle-mode -1))
3694 (when (and (fboundp 'gud-gdb-complete-command)
3695 (not (fboundp 'icicle-ORIG-gud-gdb-complete-command)))
3696 (fset 'icicle-ORIG-gud-gdb-complete-command
3697 (symbol-function 'gud-gdb-complete-command)))
3698 (when icyp (icicle-mode 1)))))
3699 (if (featurep 'gud) (eval-after-load "icicles-mode" form) (eval-after-load "gud" form)))
3700
3701 ;;; `info.el' - `Info-goto-node', `Info-index', `Info-menu'.
3702 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3703 (when icyp (icicle-mode -1))
3704 (when (and (featurep 'info) (not (fboundp 'icicle-ORIG-Info-goto-node)))
3705 (fset 'icicle-ORIG-Info-goto-node (symbol-function 'Info-goto-node))
3706 (fset 'icicle-ORIG-Info-index (symbol-function 'Info-index))
3707 (fset 'icicle-ORIG-Info-menu (symbol-function 'Info-menu)))
3708 (when icyp (icicle-mode 1)))))
3709 (if (featurep 'info) (eval-after-load "icicles-mode" form) (eval-after-load "info" form)))
3710
3711 ;;; `bbdb-com.el' version 2.35 - `bbdb-complete-name'.
3712 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3713 (when icyp (icicle-mode -1))
3714 (when (and (fboundp 'bbdb-complete-name)
3715 (not (fboundp 'bbdb-complete-mail))
3716 (not (fboundp 'icicle-ORIG-bbdb-complete-name)))
3717 (fset 'icicle-ORIG-bbdb-complete-name (symbol-function 'bbdb-complete-name)))
3718 (when icyp (icicle-mode 1)))))
3719 (if (and (featurep 'bbdb-com) (fboundp 'bbdb-complete-name) (not (fboundp 'bbdb-complete-mail)))
3720 (eval-after-load "icicles-mode" form)
3721 (eval-after-load "bbdb-com" form)))
3722
3723 ;;; `bbdb-com.el' version 3.02 and later - `bbdb-complete-mail'.
3724 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3725 (when icyp (icicle-mode -1))
3726 (when (and (fboundp 'bbdb-complete-mail)
3727 (not (fboundp 'icicle-ORIG-bbdb-complete-mail)))
3728 (fset 'icicle-ORIG-bbdb-complete-mail (symbol-function 'bbdb-complete-mail)))
3729 (when icyp (icicle-mode 1)))))
3730 (if (and (featurep 'bbdb-com) (fboundp 'bbdb-complete-mail))
3731 (eval-after-load "icicles-mode" form)
3732 (eval-after-load "bbdb-com" form)))
3733
3734 ;;; `dired-aux.el' - `dired-read-shell-command'.
3735 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3736 (when icyp (icicle-mode -1))
3737 (when (and (fboundp 'dired-read-shell-command)
3738 (not (fboundp 'icicle-ORIG-dired-read-shell-command)))
3739 (fset 'icicle-ORIG-dired-read-shell-command
3740 (symbol-function 'dired-read-shell-command)))
3741 (when icyp (icicle-mode 1)))))
3742 (if (featurep 'dired-aux)
3743 (eval-after-load "icicles-mode" form)
3744 (eval-after-load "dired-aux" form)))
3745
3746 ;;; `dired-x.el' - `dired-read-shell-command', `dired-smart-shell-command'.
3747 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3748 (when icyp (icicle-mode -1))
3749 (when (and (fboundp 'dired-read-shell-command)
3750 (not (fboundp 'icicle-ORIG-dired-read-shell-command)))
3751 (fset 'icicle-ORIG-dired-read-shell-command
3752 (symbol-function 'dired-read-shell-command)))
3753 (unless (fboundp 'read-shell-command) ; `dired-smart-shell-command' in Emacs < 23.
3754 (when (and (fboundp 'dired-smart-shell-command)
3755 (not (fboundp 'icicle-ORIG-dired-smart-shell-command)))
3756 (fset 'icicle-ORIG-dired-smart-shell-command
3757 (symbol-function 'dired-smart-shell-command))))
3758 (when icyp (icicle-mode 1)))))
3759 (if (featurep 'dired-x) (eval-after-load "icicles-mode" form) (eval-after-load "dired-x" form)))
3760
3761 ;;; `simple.el' - `read-shell-command' - Emacs 23+.
3762 (when (> emacs-major-version 22)
3763 ;; `simple.el' is preloaded for Emacs 23+, so just do it now.
3764 (let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3765 (when icyp (icicle-mode -1))
3766 (when (and (fboundp 'read-shell-command) (not (fboundp 'icicle-ORIG-read-shell-command)))
3767 (defalias 'icicle-ORIG-read-shell-command (symbol-function 'read-shell-command)))
3768 (when icyp (icicle-mode 1))))
3769
3770 ;;; `recentf.el' - `recentf-make-menu-items'.
3771 (let ((form '(let ((icyp (and (boundp 'icicle-mode) icicle-mode)))
3772 (when icyp (icicle-mode -1))
3773 (when (and (fboundp 'recentf-make-menu-items)
3774 (not (fboundp 'icicle-ORIG-recentf-make-menu-items)))
3775 (fset 'icicle-ORIG-recentf-make-menu-items
3776 (symbol-function 'recentf-make-menu-items)))
3777 (when icyp (icicle-mode 1)))))
3778 (if (featurep 'recentf) (eval-after-load "icicles-mode" form) (eval-after-load "recentf" form)))
3779
3780 ;;; `icomplete.el'. Reset `icicle-last-icomplete-mode-value', so it gets reinitialized properly.
3781 (eval-after-load "icomplete"
3782 (defadvice icomplete-mode (after icicle-reset-last-icomplete-mode activate)
3783 (when (interactive-p) (setq icicle-last-icomplete-mode-value nil))))
3784
3785 ;; Do this last.
3786 ;;
3787 ;; When these libraries are first loaded, toggle Icicle mode to pick up the definitions
3788 (dolist (library '("bookmark+" "buff-menu" "comint" "dired" "ess-site" "gud" "ibuffer"
3789 "idlw-shell" ; (untested - I don't have an `idl' program)
3790 "ielm" "info" "net-utils" "rlogin" "shell" "sh-script" "tcl"))
3791 (unless (if (fboundp 'load-history-regexp) ; Emacs 22+
3792 (load-history-filename-element (load-history-regexp library))
3793 (assoc library load-history))
3794 (eval-after-load library '(icicle-toggle-icicle-mode-twice))))
3795
3796 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3797
3798 (provide 'icicles-mode)
3799
3800 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3801 ;;; icicles-mode.el ends here