aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2008-03-05 01:57:57 +0000
committerKenichi Handa2008-03-05 01:57:57 +0000
commit40dd88cfb3e7bff190adfd8bea6e60cea02deacc (patch)
tree8744736a73925208583cd4cff91fcddf1aa30614
parentf18ea992ca0448a00e9744b979896484780830c1 (diff)
downloademacs-40dd88cfb3e7bff190adfd8bea6e60cea02deacc.tar.gz
emacs-40dd88cfb3e7bff190adfd8bea6e60cea02deacc.zip
(comint-exec-1): Don't change the coding-system for
decoding to dos-like EOL. (comint-carriage-motion): Fully rewrite.
-rw-r--r--lisp/comint.el81
1 files changed, 49 insertions, 32 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index e4ee37c50f9..bc0419bf6e2 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -800,12 +800,6 @@ buffer. The hook `comint-exec-hook' is run after each exec."
800 (let ((coding-systems (process-coding-system proc))) 800 (let ((coding-systems (process-coding-system proc)))
801 (setq decoding (car coding-systems) 801 (setq decoding (car coding-systems)
802 encoding (cdr coding-systems))) 802 encoding (cdr coding-systems)))
803 ;; If start-file-process decided to use some coding system for decoding
804 ;; data sent from the process and the coding system doesn't
805 ;; specify EOL conversion, we had better convert CRLF to LF.
806 (if (vectorp (coding-system-eol-type decoding))
807 (setq decoding (coding-system-change-eol-conversion decoding 'dos)
808 changed t))
809 ;; Even if start-file-process left the coding system for encoding data 803 ;; Even if start-file-process left the coding system for encoding data
810 ;; sent from the process undecided, we had better use the same one 804 ;; sent from the process undecided, we had better use the same one
811 ;; as what we use for decoding. But, we should suppress EOL 805 ;; as what we use for decoding. But, we should suppress EOL
@@ -1674,33 +1668,56 @@ Translate carriage return/linefeed sequences to linefeeds.
1674Make single carriage returns delete to the beginning of the line. 1668Make single carriage returns delete to the beginning of the line.
1675Make backspaces delete the previous character." 1669Make backspaces delete the previous character."
1676 (save-excursion 1670 (save-excursion
1677 ;; First do a quick check to see if there are any applicable 1671 ;; We used to check the existence of \b and \r at first to avoid
1678 ;; characters, so we can avoid calling save-match-data and 1672 ;; calling save-match-data and save-restriction. But, such a
1679 ;; save-restriction if not. 1673 ;; check is not necessary now because we don't use regexp search
1674 ;; nor save-restriction. Note that the buffer is already widen,
1675 ;; and calling narrow-to-region and widen are not that heavy.
1680 (goto-char start) 1676 (goto-char start)
1681 (when (< (skip-chars-forward "^\b\r" end) (- end start)) 1677 (let* ((inhibit-field-text-motion t)
1682 (save-match-data 1678 (inhibit-read-only t)
1683 (save-restriction 1679 (lbeg (line-beginning-position))
1684 (widen) 1680 delete-end ch)
1685 (let ((inhibit-field-text-motion t) 1681 ;; If the preceding text is marked as "must-overwrite", record
1686 (inhibit-read-only t)) 1682 ;; it in delete-end.
1687 ;; CR LF -> LF 1683 (when (and (> start (point-min))
1688 ;; Note that this won't work properly when the CR and LF 1684 (get-text-property (1- start) 'comint-must-overwrite))
1689 ;; are in different output chunks, but this is probably an 1685 (setq delete-end (point-marker))
1690 ;; exceedingly rare case (because they are generally 1686 (remove-text-properties lbeg start '(comint-must-overwrite nil)))
1691 ;; written as a unit), and to delay interpretation of a 1687 (narrow-to-region lbeg end)
1692 ;; trailing CR in a chunk would result in odd interactive 1688 ;; Handle BS, LF, and CR specially.
1693 ;; behavior (and this case is probably far more common). 1689 (while (and (skip-chars-forward "^\b\n\r") (not (eobp)))
1694 (while (re-search-forward "\r$" end t) 1690 (setq ch (following-char))
1695 (delete-char -1)) 1691 (cond ((= ch ?\b) ; CH = BS
1696 ;; bare CR -> delete preceding line 1692 (delete-char 1)
1697 (goto-char start) 1693 (if (> (point) lbeg)
1698 (while (search-forward "\r" end t) 1694 (delete-char -1)))
1699 (delete-region (point) (line-beginning-position))) 1695 ((= ch ?\n)
1700 ;; BS -> delete preceding character 1696 (when delete-end ; CH = LF
1701 (goto-char start) 1697 (if (< delete-end (point))
1702 (while (search-forward "\b" end t) 1698 (delete-region lbeg delete-end))
1703 (delete-char -2)))))))) 1699 (set-marker delete-end nil)
1700 (setq delete-end nil))
1701 (forward-char 1)
1702 (setq lbeg (point)))
1703 (t ; CH = CR
1704 (delete-char 1)
1705 (if delete-end
1706 (when (< delete-end (point))
1707 (delete-region lbeg delete-end)
1708 (move-marker delete-end (point)))
1709 (setq delete-end (point-marker))))))
1710 (when delete-end
1711 (if (< delete-end (point))
1712 ;; As there's a text after the last CR, make the current
1713 ;; line contain only that text.
1714 (delete-region lbeg delete-end)
1715 ;; Remember that the process output ends by CR, and thus we
1716 ;; must overwrite the contents of the current line next
1717 ;; time.
1718 (put-text-property lbeg delete-end 'comint-must-overwrite t))
1719 (set-marker delete-end nil))
1720 (widen))))
1704 1721
1705;; The purpose of using this filter for comint processes 1722;; The purpose of using this filter for comint processes
1706;; is to keep comint-last-input-end from moving forward 1723;; is to keep comint-last-input-end from moving forward