aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-07-19 15:50:13 +0000
committerGerd Moellmann2000-07-19 15:50:13 +0000
commitae57d456bc9b0d7c63f6ff020e61e1e6e1a21f93 (patch)
tree30ecd6d05d73d14dc4b9d370c834be46b35a93c2
parentf1c16db4be92d2f329851973e5b5af24fbacf027 (diff)
downloademacs-ae57d456bc9b0d7c63f6ff020e61e1e6e1a21f93.tar.gz
emacs-ae57d456bc9b0d7c63f6ff020e61e1e6e1a21f93.zip
(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.
-rw-r--r--lisp/comint.el57
1 files changed, 55 insertions, 2 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index d4d3ceda5d6..429eb2d11f4 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1,6 +1,7 @@
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>
@@ -201,6 +202,17 @@ This variable is buffer-local."
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.
207See 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.
206This mirrors the optional behavior of bash. 218This mirrors the optional behavior of bash.
@@ -214,7 +226,8 @@ This variable is buffer-local."
214See also `comint-read-input-ring' and `comint-write-input-ring'. 226See also `comint-read-input-ring' and `comint-write-input-ring'.
215 227
216This variable is buffer-local, and is a good thing to set in mode hooks." 228This 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
@@ -519,6 +532,10 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
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]
@@ -715,6 +732,33 @@ buffer. The hook `comint-exec-hook' is run after each exec."
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;; ===========================================================================
@@ -1328,6 +1372,15 @@ Similarly for Soar, Scheme, etc."
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