comparison lisp/comint/comint.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 360340f9fd5f
children 48d667d6f17f
comparison
equal deleted inserted replaced
109:e183fc049578 110:fe104dbd9147
352 (put 'comint-output-filter-functions 'permanent-local t) 352 (put 'comint-output-filter-functions 'permanent-local t)
353 (put 'comint-scroll-to-bottom-on-input 'permanent-local t) 353 (put 'comint-scroll-to-bottom-on-input 'permanent-local t)
354 (put 'comint-scroll-to-bottom-on-output 'permanent-local t) 354 (put 'comint-scroll-to-bottom-on-output 'permanent-local t)
355 (put 'comint-scroll-show-maximum-output 'permanent-local t) 355 (put 'comint-scroll-show-maximum-output 'permanent-local t)
356 (put 'comint-ptyp 'permanent-local t) 356 (put 'comint-ptyp 'permanent-local t)
357
358 (defface comint-input-face '((((class color)
359 (background dark))
360 (:foreground "red"))
361 (((class color)
362 (background light))
363 (:foreground "blue"))
364 (((class mono))
365 (:bold t))
366 (((class grayscale))
367 (:bold t))
368 (t
369 (:bold t)))
370 "How to display user input for comint shells."
371 :group 'comint-input-face)
372
373
357 374
358 (defun comint-mode () 375 (defun comint-mode ()
359 "Major mode for interacting with an inferior interpreter. 376 "Major mode for interacting with an inferior interpreter.
360 Interpreter name is same as buffer name, sans the asterisks. 377 Interpreter name is same as buffer name, sans the asterisks.
361 Return at end of buffer sends line as input. 378 Return at end of buffer sends line as input.
1345 ;; Update the markers before we send the input 1362 ;; Update the markers before we send the input
1346 ;; in case we get output amidst sending the input. 1363 ;; in case we get output amidst sending the input.
1347 (set-marker comint-last-input-start pmark) 1364 (set-marker comint-last-input-start pmark)
1348 (set-marker comint-last-input-end (point)) 1365 (set-marker comint-last-input-end (point))
1349 (set-marker (process-mark proc) (point)) 1366 (set-marker (process-mark proc) (point))
1367 (comint-input-done)
1350 (funcall comint-input-sender proc input) 1368 (funcall comint-input-sender proc input)
1369 (comint-input-setup)
1351 ;; XEmacs - A kludge to prevent the delay between insert and 1370 ;; XEmacs - A kludge to prevent the delay between insert and
1352 ;; process output affecting the display. A case for a 1371 ;; process output affecting the display. A case for a
1353 ;; comint-send-input-hook? 1372 ;; comint-send-input-hook?
1354 (run-hook-with-args 'comint-output-filter-functions 1373 (run-hook-with-args 'comint-output-filter-functions
1355 (concat input "\n")) 1374 (concat input "\n"))
1356 (comint-output-filter proc "") 1375 (comint-output-filter proc "")
1357 ))))) 1376 )))))
1377 (defun comint-input-done ()
1378 "Finalized comint-input-extent so nothing more is added."
1379 (if (not comint-input-extent)
1380 (comint-input-setup))
1381 (set-extent-property comint-input-extent 'start-closed nil)
1382 (set-extent-property comint-input-extent 'end-closed nil)
1383 (set-extent-property comint-input-extent 'detachable t)
1384 )
1385
1386 (defun comint-input-setup ()
1387 "Insure the comint-input-extent is ready."
1388 (setq comint-input-extent (make-extent (point) (point-max)))
1389 (set-extent-property comint-input-extent 'detachable nil)
1390 (set-extent-property comint-input-extent 'start-closed t)
1391 (set-extent-property comint-input-extent 'end-closed t)
1392 (set-extent-face comint-input-extent 'comint-input-face)
1393 )
1394
1395 (defvar comint-input-extent nil
1396 "Current extent used for displaying text in buffer.");
1397 (make-variable-buffer-local 'comint-input-extent)
1358 1398
1359 ;; The purpose of using this filter for comint processes 1399 ;; The purpose of using this filter for comint processes
1360 ;; is to keep comint-last-input-end from moving forward 1400 ;; is to keep comint-last-input-end from moving forward
1361 ;; when output is inserted. 1401 ;; when output is inserted.
1362 (defun comint-output-filter (process string) 1402 (defun comint-output-filter (process string)
1368 (set-buffer oprocbuf) 1408 (set-buffer oprocbuf)
1369 (setq string (replace-in-string string "\^M" "") 1409 (setq string (replace-in-string string "\^M" "")
1370 opoint (point) 1410 opoint (point)
1371 obeg (point-min) 1411 obeg (point-min)
1372 oend (point-max)) 1412 oend (point-max))
1413 ;; Keep stuff being output (before input) from using input-extent
1414 (if comint-input-extent
1415 (set-extent-property comint-input-extent 'start-closed nil))
1373 (let ((buffer-read-only nil) 1416 (let ((buffer-read-only nil)
1374 (nchars (length string)) 1417 (nchars (length string))
1375 (ostart nil)) 1418 (ostart nil))
1376 (widen) 1419 (widen)
1377 (goto-char (process-mark process)) 1420 (goto-char (process-mark process))
1392 (= (point) comint-last-input-end)) 1435 (= (point) comint-last-input-end))
1393 (set-marker comint-last-input-end (- comint-last-input-end nchars))) 1436 (set-marker comint-last-input-end (- comint-last-input-end nchars)))
1394 (set-marker comint-last-output-start ostart) 1437 (set-marker comint-last-output-start ostart)
1395 (set-marker (process-mark process) (point)) 1438 (set-marker (process-mark process) (point))
1396 (redraw-modeline)) 1439 (redraw-modeline))
1440 ;; Now insure everything inserted after (user input) is in extent
1441 (if (not comint-input-extent)
1442 (comint-input-setup))
1443 (set-extent-endpoints comint-input-extent (point) (point-max))
1444 (set-extent-property comint-input-extent 'start-closed t)
1397 1445
1398 (narrow-to-region obeg oend) 1446 (narrow-to-region obeg oend)
1399 (goto-char opoint) 1447 (goto-char opoint)
1400 (run-hook-with-args 'comint-output-filter-functions string) 1448 (run-hook-with-args 'comint-output-filter-functions string)
1401 (set-buffer obuf))))) 1449 (set-buffer obuf)))))