diff options
| author | Stefan Monnier | 2000-09-29 02:05:07 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 02:05:07 +0000 |
| commit | ef779078e24d9a7a2a22c6dcc1a5fbc225a555b4 (patch) | |
| tree | c645481e050929a01350f060169f77fb53c127b1 | |
| parent | d2251bbf79c3a3c7739f0813ac85c0f99d295d6d (diff) | |
| download | emacs-ef779078e24d9a7a2a22c6dcc1a5fbc225a555b4.tar.gz emacs-ef779078e24d9a7a2a22c6dcc1a5fbc225a555b4.zip | |
(comint-mode-hook): Docstring fix.
(comint-mode): Use define-derived-mode.
(comint-mode-map): Remove obsolete comment.
(make-comint): Minor stylistic change.
(comint-insert-clicked-input): Be more careful to find the overlay.
Use this-command-keys rather than hardcoding mouse-2.
| -rw-r--r-- | lisp/comint.el | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 4fc8f67402e..8e348797d39 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -388,7 +388,7 @@ field boundaries in a natural way)." | |||
| 388 | :group 'comint) | 388 | :group 'comint) |
| 389 | 389 | ||
| 390 | (defcustom comint-mode-hook '() | 390 | (defcustom comint-mode-hook '() |
| 391 | "Called upon entry into comint-mode | 391 | "Called upon entry into `comint-mode' |
| 392 | This is run before the process is cranked up." | 392 | This is run before the process is cranked up." |
| 393 | :type 'hook | 393 | :type 'hook |
| 394 | :group 'comint) | 394 | :group 'comint) |
| @@ -439,7 +439,7 @@ The command \\[comint-accumulate] sets this.") | |||
| 439 | 439 | ||
| 440 | (put 'comint-mode 'mode-class 'special) | 440 | (put 'comint-mode 'mode-class 'special) |
| 441 | 441 | ||
| 442 | (defun comint-mode () | 442 | (define-derived-mode comint-mode fundamental-mode "Comint" |
| 443 | "Major mode for interacting with an inferior interpreter. | 443 | "Major mode for interacting with an inferior interpreter. |
| 444 | Interpreter name is same as buffer name, sans the asterisks. | 444 | Interpreter name is same as buffer name, sans the asterisks. |
| 445 | Return at end of buffer sends line as input. | 445 | Return at end of buffer sends line as input. |
| @@ -475,13 +475,7 @@ to continue it. | |||
| 475 | \\{comint-mode-map} | 475 | \\{comint-mode-map} |
| 476 | 476 | ||
| 477 | Entry to this mode runs the hooks on `comint-mode-hook'." | 477 | Entry to this mode runs the hooks on `comint-mode-hook'." |
| 478 | (interactive) | ||
| 479 | ;; Do not remove this. All major modes must do this. | ||
| 480 | (kill-all-local-variables) | ||
| 481 | (setq major-mode 'comint-mode) | ||
| 482 | (setq mode-name "Comint") | ||
| 483 | (setq mode-line-process '(":%s")) | 478 | (setq mode-line-process '(":%s")) |
| 484 | (use-local-map comint-mode-map) | ||
| 485 | (make-local-variable 'comint-last-input-start) | 479 | (make-local-variable 'comint-last-input-start) |
| 486 | (setq comint-last-input-start (make-marker)) | 480 | (setq comint-last-input-start (make-marker)) |
| 487 | (set-marker comint-last-input-start (point-min)) | 481 | (set-marker comint-last-input-start (point-min)) |
| @@ -528,8 +522,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'." | |||
| 528 | (make-local-variable 'comint-file-name-quote-list) | 522 | (make-local-variable 'comint-file-name-quote-list) |
| 529 | (make-local-variable 'comint-accum-marker) | 523 | (make-local-variable 'comint-accum-marker) |
| 530 | (setq comint-accum-marker (make-marker)) | 524 | (setq comint-accum-marker (make-marker)) |
| 531 | (set-marker comint-accum-marker nil) | 525 | (set-marker comint-accum-marker nil)) |
| 532 | (run-hooks 'comint-mode-hook)) | ||
| 533 | 526 | ||
| 534 | (if comint-mode-map | 527 | (if comint-mode-map |
| 535 | nil | 528 | nil |
| @@ -563,8 +556,6 @@ Entry to this mode runs the hooks on `comint-mode-hook'." | |||
| 563 | (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt) | 556 | (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt) |
| 564 | (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof) | 557 | (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof) |
| 565 | ;; Mouse Buttons: | 558 | ;; Mouse Buttons: |
| 566 | ;; Note, if you change this, you will have to change | ||
| 567 | ;; comint-insert-clicked-input as well | ||
| 568 | (define-key comint-mode-map [mouse-2] 'comint-insert-clicked-input) | 559 | (define-key comint-mode-map [mouse-2] 'comint-insert-clicked-input) |
| 569 | ;; Menu bars: | 560 | ;; Menu bars: |
| 570 | ;; completion: | 561 | ;; completion: |
| @@ -658,11 +649,10 @@ If PROGRAM is a string, any more args are arguments to PROGRAM." | |||
| 658 | (let ((buffer (get-buffer-create (concat "*" name "*")))) | 649 | (let ((buffer (get-buffer-create (concat "*" name "*")))) |
| 659 | ;; If no process, or nuked process, crank up a new one and put buffer in | 650 | ;; If no process, or nuked process, crank up a new one and put buffer in |
| 660 | ;; comint mode. Otherwise, leave buffer and existing process alone. | 651 | ;; comint mode. Otherwise, leave buffer and existing process alone. |
| 661 | (cond ((not (comint-check-proc buffer)) | 652 | (unless (comint-check-proc buffer) |
| 662 | (save-excursion | 653 | (with-current-buffer buffer |
| 663 | (set-buffer buffer) | 654 | (comint-mode)) ; Install local vars, mode, keymap, ... |
| 664 | (comint-mode)) ; Install local vars, mode, keymap, ... | 655 | (comint-exec buffer name program startfile switches)) |
| 665 | (comint-exec buffer name program startfile switches))) | ||
| 666 | buffer)) | 656 | buffer)) |
| 667 | 657 | ||
| 668 | ;;;###autoload | 658 | ;;;###autoload |
| @@ -767,27 +757,25 @@ buffer. The hook `comint-exec-hook' is run after each exec." | |||
| 767 | (defun comint-insert-clicked-input (event) | 757 | (defun comint-insert-clicked-input (event) |
| 768 | "In a comint buffer, set the current input to the clicked-on previous input." | 758 | "In a comint buffer, set the current input to the clicked-on previous input." |
| 769 | (interactive "e") | 759 | (interactive "e") |
| 770 | ;; This won't play nicely with other overlays... | 760 | (let ((over (catch 'found |
| 771 | (let ((overs (overlays-at (posn-point (event-end event))))) | 761 | ;; Ignore non-input overlays |
| 762 | (dolist (ov (overlays-at (posn-point (event-end event)))) | ||
| 763 | (when (eq (overlay-get ov 'field) 'input) | ||
| 764 | (throw 'found ov)))))) | ||
| 772 | ;; do we have input in this area? | 765 | ;; do we have input in this area? |
| 773 | (if overs | 766 | (if over |
| 774 | (let ((input-str (buffer-substring (overlay-start (car overs)) | 767 | (let ((input-str (buffer-substring (overlay-start over) |
| 775 | (overlay-end (car overs))))) | 768 | (overlay-end over)))) |
| 776 | (if (not (comint-after-pmark-p)) | 769 | (delete-region |
| 777 | (error "Not at command line")) | ||
| 778 | (delete-region | ||
| 779 | ;; Can't use kill-region as it sets this-command | 770 | ;; Can't use kill-region as it sets this-command |
| 780 | (or (marker-position comint-accum-marker) | 771 | (or (marker-position comint-accum-marker) |
| 781 | (process-mark (get-buffer-process (current-buffer)))) | 772 | (process-mark (get-buffer-process (current-buffer)))) |
| 782 | (point)) | 773 | (point)) |
| 783 | (insert input-str)) | 774 | (insert input-str)) |
| 784 | ;; fall back to the user's previous definition if we aren't | 775 | ;; fall back to the user's previous definition if we aren't |
| 785 | ;; on previous input region (note, if you change [mouse-2] | 776 | ;; on previous input region. |
| 786 | ;; to something else, you should also change the default | 777 | (let ((fun (lookup-key global-map (this-command-keys)))) |
| 787 | ;; keybinding above) | 778 | (if fun (call-interactively fun)))))) |
| 788 | (let ((fun (lookup-key global-map [mouse-2]))) | ||
| 789 | (if fun | ||
| 790 | (call-interactively fun event nil)))))) | ||
| 791 | 779 | ||
| 792 | 780 | ||
| 793 | ;; Input history processing in a buffer | 781 | ;; Input history processing in a buffer |