Mercurial > hg > xemacs-beta
comparison lisp/list-mode.el @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 3b3709405255 |
children | 6240c7796c7a |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
75 (make-local-hook 'pre-command-hook) | 75 (make-local-hook 'pre-command-hook) |
76 (add-hook 'pre-command-hook 'list-mode-extent-pre-hook nil t) | 76 (add-hook 'pre-command-hook 'list-mode-extent-pre-hook nil t) |
77 (make-local-variable 'next-line-add-newlines) | 77 (make-local-variable 'next-line-add-newlines) |
78 (setq next-line-add-newlines nil) | 78 (setq next-line-add-newlines nil) |
79 (setq list-mode-extent nil) | 79 (setq list-mode-extent nil) |
80 ;; It is visually disconcerting to have the text cursor disappear within list | 80 (set-specifier text-cursor-visible-p nil (current-buffer)) |
81 ;; buffers, especially when moving from window to window, so leave it | |
82 ;; visible. -- Bob Weiner, 06/20/1999 | |
83 ; (set-specifier text-cursor-visible-p nil (current-buffer)) | |
84 (setq buffer-read-only t) | 81 (setq buffer-read-only t) |
85 (goto-char (point-min)) | 82 (goto-char (point-min)) |
86 (run-hooks 'list-mode-hook)) | 83 (run-hooks 'list-mode-hook)) |
87 | 84 |
88 ;; List mode is suitable only for specially formatted data. | 85 ;; List mode is suitable only for specially formatted data. |
285 (cl-parsing-keywords | 282 (cl-parsing-keywords |
286 ((:activate-callback 'default-choose-completion) | 283 ((:activate-callback 'default-choose-completion) |
287 :user-data | 284 :user-data |
288 :reference-buffer | 285 :reference-buffer |
289 (:help-string completion-default-help-string) | 286 (:help-string completion-default-help-string) |
290 (:completion-string "Possible completions are:") | |
291 :window-width) | 287 :window-width) |
292 () | 288 () |
293 (let ((old-buffer (current-buffer)) | 289 (let ((old-buffer (current-buffer)) |
294 (bufferp (bufferp standard-output))) | 290 (bufferp (bufferp standard-output))) |
295 (if bufferp | 291 (if bufferp |
343 ;; re-space the columns | 339 ;; re-space the columns |
344 (setq max-width (/ win-width cols)) | 340 (setq max-width (/ win-width cols)) |
345 (if (/= (% count cols) 0) ; want ceiling... | 341 (if (/= (% count cols) 0) ; want ceiling... |
346 (1+ (/ count cols)) | 342 (1+ (/ count cols)) |
347 (/ count cols))))))) | 343 (/ count cols))))))) |
348 (if (stringp cl-completion-string) | 344 (princ (gettext "Possible completions are:")) |
349 (princ (gettext cl-completion-string))) | |
350 (let ((tail completions) | 345 (let ((tail completions) |
351 (r 0) | 346 (r 0) |
352 (regexp-string | 347 (regexp-string |
353 (if (eq t | 348 (if (eq t |
354 completion-highlight-first-word-only) | 349 completion-highlight-first-word-only) |
459 (sort completions #'string-lessp)))))) | 454 (sort completions #'string-lessp)))))) |
460 | 455 |
461 (define-derived-mode completion-list-mode list-mode | 456 (define-derived-mode completion-list-mode list-mode |
462 "Completion List" | 457 "Completion List" |
463 "Major mode for buffers showing lists of possible completions. | 458 "Major mode for buffers showing lists of possible completions. |
464 \\{completion-list-mode-map}" | 459 Type \\<completion-list-mode-map>\\[choose-completion] in the completion list\ |
460 to select the completion near point. | |
461 Use \\<completion-list-mode-map>\\[mouse-choose-completion] to select one\ | |
462 with the mouse." | |
465 (make-local-variable 'completion-base-size) | 463 (make-local-variable 'completion-base-size) |
466 (setq completion-base-size nil)) | 464 (setq completion-base-size nil)) |
467 | 465 |
468 (let ((map completion-list-mode-map)) | 466 (let ((map completion-list-mode-map)) |
469 (define-key map 'button2up 'mouse-choose-completion) | |
470 (define-key map 'button2 'undefined) | |
471 (define-key map "\C-m" 'choose-completion) | |
472 (define-key map "\e\e\e" 'delete-completion-window) | 467 (define-key map "\e\e\e" 'delete-completion-window) |
473 (define-key map "\C-g" 'minibuffer-keyboard-quit) | 468 (define-key map "\C-g" 'minibuffer-keyboard-quit) |
474 (define-key map "q" 'completion-list-mode-quit) | 469 (define-key map "q" 'abort-recursive-edit) |
475 (define-key map " " 'completion-switch-to-minibuffer) | 470 (define-key map " " (lambda () (interactive) |
476 ;; [Tab] used to switch to the minibuffer but since [space] does that and | 471 (select-window (minibuffer-window)))) |
477 ;; since most applications in the world use [Tab] to select the next item | 472 (define-key map "\t" (lambda () (interactive) |
478 ;; in a list, do that in the *Completions* buffer too. -- Bob Weiner, | 473 (select-window (minibuffer-window))))) |
479 ;; BeOpen.com, 06/23/1999. | |
480 (define-key map "\t" 'next-list-mode-item)) | |
481 | 474 |
482 (defvar completion-reference-buffer nil | 475 (defvar completion-reference-buffer nil |
483 "Record the buffer that was current when the completion list was requested. | 476 "Record the buffer that was current when the completion list was requested. |
484 This is a local variable in the completion list buffer. | 477 This is a local variable in the completion list buffer. |
485 Initial value is nil to avoid some compiler warnings.") | 478 Initial value is nil to avoid some compiler warnings.") |
488 "Number of chars at beginning of minibuffer not involved in completion. | 481 "Number of chars at beginning of minibuffer not involved in completion. |
489 This is a local variable in the completion list buffer | 482 This is a local variable in the completion list buffer |
490 but it talks about the buffer in `completion-reference-buffer'. | 483 but it talks about the buffer in `completion-reference-buffer'. |
491 If this is nil, it means to compare text to determine which part | 484 If this is nil, it means to compare text to determine which part |
492 of the tail end of the buffer's text is involved in completion.") | 485 of the tail end of the buffer's text is involved in completion.") |
493 | |
494 ;; These names are referenced in the doc string for `completion-list-mode'. | |
495 (defalias 'choose-completion 'list-mode-item-keyboard-selected) | |
496 (defalias 'mouse-choose-completion 'list-mode-item-mouse-selected) | |
497 | 486 |
498 (defun delete-completion-window () | 487 (defun delete-completion-window () |
499 "Delete the completion list window. | 488 "Delete the completion list window. |
500 Go to the window from which completion was requested." | 489 Go to the window from which completion was requested." |
501 (interactive) | 490 (interactive) |
502 (let ((buf completion-reference-buffer)) | 491 (let ((buf completion-reference-buffer)) |
503 (delete-window (selected-window)) | 492 (delete-window (selected-window)) |
504 (if (get-buffer-window buf) | 493 (if (get-buffer-window buf) |
505 (select-window (get-buffer-window buf))))) | 494 (select-window (get-buffer-window buf))))) |
506 | |
507 (defun completion-switch-to-minibuffer () | |
508 "Move from a completions buffer to the active minibuffer window." | |
509 (interactive) | |
510 (select-window (minibuffer-window))) | |
511 | |
512 (defun completion-list-mode-quit () | |
513 "Abort any recursive edit and bury the completions buffer." | |
514 (interactive) | |
515 (condition-case () | |
516 (abort-recursive-edit) | |
517 (error nil)) | |
518 ;; If there was no recursive edit to abort, simply bury the completions | |
519 ;; list buffer. | |
520 (if (eq major-mode 'completion-list-mode) (bury-buffer))) | |
521 | 495 |
522 (defun completion-do-in-minibuffer () | 496 (defun completion-do-in-minibuffer () |
523 (interactive "_") | 497 (interactive "_") |
524 (save-excursion | 498 (save-excursion |
525 (set-buffer (window-buffer (minibuffer-window))) | 499 (set-buffer (window-buffer (minibuffer-window))) |