Mercurial > emacs
comparison lisp/comint.el @ 30325:a7f5f8fff5b2
(comint-highlight-input, comint-highlight-face):
New user options.
(comint-input-ring-file-name): Change custom type.
(comint-mode-map): Bind mouse-2.
(comint-insert-clicked-input): New function.
(comint-send-input): Handle input highlighting.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 19 Jul 2000 15:50:13 +0000 |
parents | 53bc9bb1f0b8 |
children | 6f943008c543 |
comparison
equal
deleted
inserted
replaced
30324:d4713daa6716 | 30325:a7f5f8fff5b2 |
---|---|
1 ;;; comint.el --- general command interpreter in a window stuff | 1 ;;; comint.el --- general command interpreter in a window stuff |
2 | 2 |
3 ;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99, 2000 |
4 ;; Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Olin Shivers <shivers@cs.cmu.edu> then | 6 ;; Author: Olin Shivers <shivers@cs.cmu.edu> then |
6 ;; Simon Marshall <simon@gnu.org> | 7 ;; Simon Marshall <simon@gnu.org> |
7 ;; Maintainer: FSF | 8 ;; Maintainer: FSF |
8 ;; Keywords: processes | 9 ;; Keywords: processes |
199 (const input) | 200 (const input) |
200 (const history) | 201 (const history) |
201 (other :tag "on" t)) | 202 (other :tag "on" t)) |
202 :group 'comint) | 203 :group 'comint) |
203 | 204 |
205 (defcustom comint-highlight-input t | |
206 "*If non-nil, highlight input; also allow choosing previous input with a mouse. | |
207 See also `comint-highlight-face'." | |
208 :type 'boolean | |
209 :group 'comint) | |
210 | |
211 (defcustom comint-highlight-face 'bold | |
212 "*Face to use to highlight input when `comint-highlight-input' is non-nil." | |
213 :type 'face | |
214 :group 'comint) | |
215 | |
204 (defcustom comint-input-ignoredups nil | 216 (defcustom comint-input-ignoredups nil |
205 "*If non-nil, don't add input matching the last on the input ring. | 217 "*If non-nil, don't add input matching the last on the input ring. |
206 This mirrors the optional behavior of bash. | 218 This mirrors the optional behavior of bash. |
207 | 219 |
208 This variable is buffer-local." | 220 This variable is buffer-local." |
212 (defcustom comint-input-ring-file-name nil | 224 (defcustom comint-input-ring-file-name nil |
213 "*If non-nil, name of the file to read/write input history. | 225 "*If non-nil, name of the file to read/write input history. |
214 See also `comint-read-input-ring' and `comint-write-input-ring'. | 226 See also `comint-read-input-ring' and `comint-write-input-ring'. |
215 | 227 |
216 This variable is buffer-local, and is a good thing to set in mode hooks." | 228 This variable is buffer-local, and is a good thing to set in mode hooks." |
217 :type 'boolean | 229 :type '(choice (const :tag "nil" nil) |
230 file) | |
218 :group 'comint) | 231 :group 'comint) |
219 | 232 |
220 (defcustom comint-scroll-to-bottom-on-input nil | 233 (defcustom comint-scroll-to-bottom-on-input nil |
221 "*Controls whether input to interpreter causes window to scroll. | 234 "*Controls whether input to interpreter causes window to scroll. |
222 If nil, then do not scroll. If t or `all', scroll all windows showing buffer. | 235 If nil, then do not scroll. If t or `all', scroll all windows showing buffer. |
517 (define-key comint-mode-map "\C-c\C-e" 'comint-show-maximum-output) | 530 (define-key comint-mode-map "\C-c\C-e" 'comint-show-maximum-output) |
518 (define-key comint-mode-map "\C-c\C-l" 'comint-dynamic-list-input-ring) | 531 (define-key comint-mode-map "\C-c\C-l" 'comint-dynamic-list-input-ring) |
519 (define-key comint-mode-map "\C-c\C-n" 'comint-next-prompt) | 532 (define-key comint-mode-map "\C-c\C-n" 'comint-next-prompt) |
520 (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt) | 533 (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt) |
521 (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof) | 534 (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof) |
535 ;; Mouse Buttons: | |
536 ;; Note, if you change this, you will have to change | |
537 ;; comint-insert-clicked-input as well | |
538 (define-key comint-mode-map [mouse-2] 'comint-insert-clicked-input) | |
522 ;; Menu bars: | 539 ;; Menu bars: |
523 ;; completion: | 540 ;; completion: |
524 (define-key comint-mode-map [menu-bar completion] | 541 (define-key comint-mode-map [menu-bar completion] |
525 (cons "Complete" (make-sparse-keymap "Complete"))) | 542 (cons "Complete" (make-sparse-keymap "Complete"))) |
526 (define-key comint-mode-map [menu-bar completion complete-expand] | 543 (define-key comint-mode-map [menu-bar completion complete-expand] |
713 (setq encoding (coding-system-change-eol-conversion decoding 'unix) | 730 (setq encoding (coding-system-change-eol-conversion decoding 'unix) |
714 changed t)) | 731 changed t)) |
715 (if changed | 732 (if changed |
716 (set-process-coding-system proc decoding encoding)) | 733 (set-process-coding-system proc decoding encoding)) |
717 proc)) | 734 proc)) |
735 | |
736 | |
737 (defun comint-insert-clicked-input (event) | |
738 "In a comint buffer, set the current input to the clicked-on previous input." | |
739 (interactive "e") | |
740 ;; This won't play nicely with other overlays... | |
741 (let ((overs (overlays-at (posn-point (event-end event))))) | |
742 ;; do we have input in this area? | |
743 (if overs | |
744 (let ((input-str (buffer-substring (overlay-start (car overs)) | |
745 (overlay-end (car overs))))) | |
746 (if (not (comint-after-pmark-p)) | |
747 (error "Not at command line")) | |
748 (delete-region | |
749 ;; Can't use kill-region as it sets this-command | |
750 (or (marker-position comint-accum-marker) | |
751 (process-mark (get-buffer-process (current-buffer)))) | |
752 (point)) | |
753 (insert input-str)) | |
754 ;; fall back to the user's previous definition if we aren't | |
755 ;; on previous input region (note, if you change [mouse-2] | |
756 ;; to something else, you should also change the default | |
757 ;; keybinding above) | |
758 (let ((fun (lookup-key global-map [mouse-2]))) | |
759 (if fun | |
760 (call-interactively fun event nil)))))) | |
761 | |
718 | 762 |
719 ;; Input history processing in a buffer | 763 ;; Input history processing in a buffer |
720 ;; =========================================================================== | 764 ;; =========================================================================== |
721 ;; Useful input history functions, courtesy of the Ergo group. | 765 ;; Useful input history functions, courtesy of the Ergo group. |
722 | 766 |
1326 (not (string-equal (ring-ref comint-input-ring 0) | 1370 (not (string-equal (ring-ref comint-input-ring 0) |
1327 history)))) | 1371 history)))) |
1328 (ring-insert comint-input-ring history)) | 1372 (ring-insert comint-input-ring history)) |
1329 (run-hook-with-args 'comint-input-filter-functions | 1373 (run-hook-with-args 'comint-input-filter-functions |
1330 (concat input "\n")) | 1374 (concat input "\n")) |
1375 (let ((beg (marker-position pmark)) | |
1376 (end (1- (point)))) | |
1377 (when (and comint-highlight-input | |
1378 ;; handle a special case | |
1379 (not (> beg end))) | |
1380 (let ((over (make-overlay beg end))) | |
1381 (overlay-put over 'face comint-highlight-face) | |
1382 (overlay-put over 'mouse-face 'highlight) | |
1383 (overlay-put over 'evaporate t)))) | |
1331 (setq comint-save-input-ring-index comint-input-ring-index) | 1384 (setq comint-save-input-ring-index comint-input-ring-index) |
1332 (setq comint-input-ring-index nil) | 1385 (setq comint-input-ring-index nil) |
1333 ;; Update the markers before we send the input | 1386 ;; Update the markers before we send the input |
1334 ;; in case we get output amidst sending the input. | 1387 ;; in case we get output amidst sending the input. |
1335 (set-marker comint-last-input-start pmark) | 1388 (set-marker comint-last-input-start pmark) |