;;; comint.el --- general command interpreter in a window stuff
-;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+;; Free Software Foundation, Inc.
;; Author: Olin Shivers <shivers@cs.cmu.edu> then
;; Simon Marshall <simon@gnu.org>
;; comint-save-input-ring-index number ...
;; comint-input-autoexpand symbol ...
;; comint-input-ignoredups boolean ...
-;; comint-last-input-match string ...
;; comint-dynamic-complete-functions hook For the completion mechanism
;; comint-completion-fignore list ...
;; comint-file-name-chars string ...
(other :tag "on" t))
:group 'comint)
+(defcustom comint-highlight-input t
+ "*If non-nil, highlight input; also allow choosing previous input with a mouse.
+See also `comint-highlight-face'."
+ :type 'boolean
+ :group 'comint)
+
+(defcustom comint-highlight-face 'bold
+ "*Face to use to highlight input when `comint-highlight-input' is non-nil."
+ :type 'face
+ :group 'comint)
+
(defcustom comint-input-ignoredups nil
"*If non-nil, don't add input matching the last on the input ring.
This mirrors the optional behavior of bash.
See also `comint-read-input-ring' and `comint-write-input-ring'.
This variable is buffer-local, and is a good thing to set in mode hooks."
- :type 'boolean
+ :type '(choice (const :tag "nil" nil)
+ file)
:group 'comint)
(defcustom comint-scroll-to-bottom-on-input nil
(define-key comint-mode-map "\C-c\C-n" 'comint-next-prompt)
(define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt)
(define-key comint-mode-map "\C-c\C-d" 'comint-send-eof)
+ ;; Mouse Buttons:
+ ;; Note, if you change this, you will have to change
+ ;; comint-insert-clicked-input as well
+ (define-key comint-mode-map [mouse-2] 'comint-insert-clicked-input)
;; Menu bars:
;; completion:
(define-key comint-mode-map [menu-bar completion]
default-directory
(char-to-string directory-sep-char)))
proc decoding encoding changed)
- (setq proc (apply 'start-process name buffer command switches))
+ (let ((exec-path (if (file-name-directory command)
+ ;; If the command has slashes, make sure we
+ ;; first look relative to the current directory.
+ (cons default-directory exec-path) exec-path)))
+ (setq proc (apply 'start-process name buffer command switches)))
(let ((coding-systems (process-coding-system proc)))
(setq decoding (car coding-systems)
encoding (cdr coding-systems)))
;; If start-process decided to use some coding system for decoding
- ;; data sent form the process and the coding system doesn't
+ ;; data sent from the process and the coding system doesn't
;; specify EOL conversion, we had better convert CRLF to LF.
(if (vectorp (coding-system-eol-type decoding))
(setq decoding (coding-system-change-eol-conversion decoding 'dos)
(if changed
(set-process-coding-system proc decoding encoding))
proc))
+
+
+(defun comint-insert-clicked-input (event)
+ "In a comint buffer, set the current input to the clicked-on previous input."
+ (interactive "e")
+ ;; This won't play nicely with other overlays...
+ (let ((overs (overlays-at (posn-point (event-end event)))))
+ ;; do we have input in this area?
+ (if overs
+ (let ((input-str (buffer-substring (overlay-start (car overs))
+ (overlay-end (car overs)))))
+ (if (not (comint-after-pmark-p))
+ (error "Not at command line"))
+ (delete-region
+ ;; Can't use kill-region as it sets this-command
+ (or (marker-position comint-accum-marker)
+ (process-mark (get-buffer-process (current-buffer))))
+ (point))
+ (insert input-str))
+ ;; fall back to the user's previous definition if we aren't
+ ;; on previous input region (note, if you change [mouse-2]
+ ;; to something else, you should also change the default
+ ;; keybinding above)
+ (let ((fun (lookup-key global-map [mouse-2])))
+ (if fun
+ (call-interactively fun event nil))))))
+
\f
;; Input history processing in a buffer
;; ===========================================================================
(message "Cannot read history file %s"
comint-input-ring-file-name)))
(t
- (let ((history-buf (get-buffer-create " *temp*"))
- (file comint-input-ring-file-name)
- (count 0)
- (ring (make-ring comint-input-ring-size)))
+ (let* ((history-buf (get-buffer-create " *temp*"))
+ (file comint-input-ring-file-name)
+ (count 0)
+ (size comint-input-ring-size)
+ (ring (make-ring size)))
(unwind-protect
(save-excursion
(set-buffer history-buf)
;; Save restriction in case file is already visited...
;; Watch for those date stamps in history files!
(goto-char (point-max))
- (while (and (< count comint-input-ring-size)
+ (while (and (< count size)
(re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
nil t))
(let (start end history)
(ring-insert comint-input-ring history))
(run-hook-with-args 'comint-input-filter-functions
(concat input "\n"))
+ (let ((beg (marker-position pmark))
+ (end (1- (point))))
+ (when (and comint-highlight-input
+ ;; handle a special case
+ (not (> beg end)))
+ (let ((over (make-overlay beg end)))
+ (overlay-put over 'face comint-highlight-face)
+ (overlay-put over 'mouse-face 'highlight)
+ (overlay-put over 'evaporate t))))
(setq comint-save-input-ring-index comint-input-ring-index)
(setq comint-input-ring-index nil)
;; Update the markers before we send the input
(setq env-var-val (if (getenv env-var-name)
(getenv env-var-name)
""))
- (setq name (replace-match env-var-val nil nil name))))))
+ (setq name (replace-match env-var-val t t name))))))
name))
(defun comint-match-partial-filename ()
"Send COMMAND to current process.
Return a list of expressions in the output which match REGEXP.
REGEXP-GROUP is the regular expression group in REGEXP to use."
- (interactive)
(comint-redirect-results-list-from-process
(get-buffer-process (current-buffer))
command regexp regexp-group))
"Send COMMAND to PROCESS.
Return a list of expressions in the output which match REGEXP.
REGEXP-GROUP is the regular expression group in REGEXP to use."
- (interactive)
(let ((output-buffer " *Comint Redirect Work Buffer*")
results)
(save-excursion
results)))
results)))
+(mapc (lambda (x)
+ (add-to-list 'debug-ignored-errors x))
+ '("^Not at command line$"
+ "^Empty input ring$"
+ "^No history$"
+ "^Not found$" ; Too common?
+ "^Current buffer has no process$"))
\f
;; Converting process modes to use comint mode
;; ===========================================================================