* term.el and undo
@ 2004-08-22 23:39 Richard Stallman
2004-08-23 1:43 ` undo in compilation mode Karl Chen
2004-08-24 20:13 ` term.el and undo Mark Plaksin
0 siblings, 2 replies; 15+ messages in thread
From: Richard Stallman @ 2004-08-22 23:39 UTC (permalink / raw)
Cases like running `top' under M-x term build up big undo lists.
It seems to me that undo information is useless in that case.
However, just disabling undo in term buffers seems like a mistake.
There are some cases, such as editing user input in line mode,
where undo info is certainly desired.
Here's a patch that should disable generation of undo information
for output done by the subprogram. Could those who use term.el
try it and report on whether the results make sense?
*** term.el 15 Aug 2004 21:45:46 -0400 1.55
--- term.el 22 Aug 2004 14:00:44 -0400
***************
*** 2647,2960 ****
;;; It emulates (most of the features of) a VT100/ANSI-style terminal.
(defun term-emulate-terminal (proc str)
! (let* ((previous-buffer (current-buffer))
! (i 0) char funny count save-point save-marker old-point temp win
! (selected (selected-window))
! last-win
! (str-length (length str)))
! (unwind-protect
! (progn
! (set-buffer (process-buffer proc))
;;; Let's handle the messages. -mm
! (setq str (term-handle-ansi-terminal-messages str))
! (setq str-length (length str))
! (if (marker-buffer term-pending-delete-marker)
! (progn
! ;; Delete text following term-pending-delete-marker.
! (delete-region term-pending-delete-marker (process-mark proc))
! (set-marker term-pending-delete-marker nil)))
!
! (if (eq (window-buffer) (current-buffer))
! (progn
! (setq term-vertical-motion (symbol-function 'vertical-motion))
! (term-check-size proc))
! (setq term-vertical-motion
! (symbol-function 'buffer-vertical-motion)))
!
! (setq save-marker (copy-marker (process-mark proc)))
!
! (if (/= (point) (process-mark proc))
! (progn (setq save-point (point-marker))
! (goto-char (process-mark proc))))
!
! (save-restriction
! ;; If the buffer is in line mode, and there is a partial
! ;; input line, save the line (by narrowing to leave it
! ;; outside the restriction ) until we're done with output.
! (if (and (> (point-max) (process-mark proc))
! (term-in-line-mode))
! (narrow-to-region (point-min) (process-mark proc)))
!
! (if term-log-buffer
! (princ str term-log-buffer))
! (cond ((eq term-terminal-state 4) ;; Have saved pending output.
! (setq str (concat term-terminal-parameter str))
! (setq term-terminal-parameter nil)
! (setq str-length (length str))
! (setq term-terminal-state 0)))
!
! (while (< i str-length)
! (setq char (aref str i))
! (cond ((< term-terminal-state 2)
! ;; Look for prefix of regular chars
! (setq funny
! (string-match "[\r\n\000\007\033\t\b\032\016\017]"
! str i))
! (if (not funny) (setq funny str-length))
! (cond ((> funny i)
! (cond ((eq term-terminal-state 1)
! (term-move-columns 1)
! (setq term-terminal-state 0)))
! (setq count (- funny i))
! (setq temp (- (+ (term-horizontal-column) count)
! term-width))
! (cond ((<= temp 0)) ;; All count chars fit in line.
! ((> count temp) ;; Some chars fit.
! ;; This iteration, handle only what fits.
! (setq count (- count temp))
! (setq funny (+ count i)))
! ((or (not (or term-pager-count
! term-scroll-with-delete))
! (> (term-handle-scroll 1) 0))
! (term-adjust-current-row-cache 1)
! (setq count (min count term-width))
! (setq funny (+ count i))
! (setq term-start-line-column
! term-current-column))
! (t ;; Doing PAGER processing.
! (setq count 0 funny i)
! (setq term-current-column nil)
! (setq term-start-line-column nil)))
! (setq old-point (point))
!
! ;; Insert a string, check how many columns
! ;; we moved, then delete that many columns
! ;; following point if not eob nor insert-mode.
! (let ((old-column (current-column))
! columns pos)
! (insert (substring str i funny))
! (setq term-current-column (current-column)
! columns (- term-current-column old-column))
! (when (not (or (eobp) term-insert-mode))
! (setq pos (point))
! (term-move-columns columns)
! (delete-region pos (point))))
! (setq term-current-column nil)
!
! (put-text-property old-point (point)
! 'face term-current-face)
! ;; If the last char was written in last column,
! ;; back up one column, but remember we did so.
! ;; Thus we emulate xterm/vt100-style line-wrapping.
! (cond ((eq temp 0)
! (term-move-columns -1)
! (setq term-terminal-state 1)))
! (setq i (1- funny)))
! ((and (setq term-terminal-state 0)
! (eq char ?\^I)) ; TAB
! ;; FIXME: Does not handle line wrap!
! (setq count (term-current-column))
! (setq count (+ count 8 (- (mod count 8))))
! (if (< (move-to-column count nil) count)
! (term-insert-char char 1))
! (setq term-current-column count))
! ((eq char ?\r)
! ;; Optimize CRLF at end of buffer:
! (cond ((and (< (setq temp (1+ i)) str-length)
! (eq (aref str temp) ?\n)
! (= (point) (point-max))
! (not (or term-pager-count
! term-kill-echo-list
! term-scroll-with-delete)))
! (insert ?\n)
! (term-adjust-current-row-cache 1)
! (setq term-start-line-column 0)
! (setq term-current-column 0)
! (setq i temp))
! (t ;; Not followed by LF or can't optimize:
! (term-vertical-motion 0)
! (setq term-current-column term-start-line-column))))
! ((eq char ?\n)
! (if (not (and term-kill-echo-list
! (term-check-kill-echo-list)))
! (term-down 1 t)))
! ((eq char ?\b)
! (term-move-columns -1))
! ((eq char ?\033) ; Escape
! (setq term-terminal-state 2))
! ((eq char 0)) ; NUL: Do nothing
! ((eq char ?\016)) ; Shift Out - ignored
! ((eq char ?\017)) ; Shift In - ignored
! ((eq char ?\^G)
! (beep t)) ; Bell
! ((eq char ?\032)
! (let ((end (string-match "\r?$" str i)))
! (if end
! (funcall term-command-hook
! (prog1 (substring str (1+ i) end)
! (setq i (match-end 0))))
! (setq term-terminal-parameter
! (substring str i))
! (setq term-terminal-state 4)
! (setq i str-length))))
! (t ; insert char FIXME: Should never happen
! (term-move-columns 1)
! (backward-delete-char 1)
! (insert char))))
! ((eq term-terminal-state 2) ; Seen Esc
! (cond ((eq char ?\133) ;; ?\133 = ?[
;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
;;; Note that now the init value of term-terminal-previous-parameter has
;;; been changed to -1
! (make-local-variable 'term-terminal-parameter)
! (make-local-variable 'term-terminal-previous-parameter)
! (make-local-variable 'term-terminal-previous-parameter-2)
! (make-local-variable 'term-terminal-previous-parameter-3)
! (make-local-variable 'term-terminal-previous-parameter-4)
! (make-local-variable 'term-terminal-more-parameters)
! (setq term-terminal-parameter 0)
! (setq term-terminal-previous-parameter -1)
! (setq term-terminal-previous-parameter-2 -1)
! (setq term-terminal-previous-parameter-3 -1)
! (setq term-terminal-previous-parameter-4 -1)
! (setq term-terminal-more-parameters 0)
! (setq term-terminal-state 3))
! ((eq char ?D) ;; scroll forward
! (term-handle-deferred-scroll)
! (term-down 1 t)
! (setq term-terminal-state 0))
! ((eq char ?M) ;; scroll reversed
! (term-insert-lines 1)
! (setq term-terminal-state 0))
! ((eq char ?7) ;; Save cursor
! (term-handle-deferred-scroll)
! (setq term-saved-cursor
! (cons (term-current-row)
! (term-horizontal-column)))
! (setq term-terminal-state 0))
! ((eq char ?8) ;; Restore cursor
! (if term-saved-cursor
! (term-goto (car term-saved-cursor)
! (cdr term-saved-cursor)))
! (setq term-terminal-state 0))
! ((setq term-terminal-state 0))))
! ((eq term-terminal-state 3) ; Seen Esc [
! (cond ((and (>= char ?0) (<= char ?9))
! (setq term-terminal-parameter
! (+ (* 10 term-terminal-parameter) (- char ?0))))
! ((eq char ?\;)
;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
! (setq term-terminal-more-parameters 1)
! (setq term-terminal-previous-parameter-4
! term-terminal-previous-parameter-3)
! (setq term-terminal-previous-parameter-3
! term-terminal-previous-parameter-2)
! (setq term-terminal-previous-parameter-2
! term-terminal-previous-parameter)
! (setq term-terminal-previous-parameter
! term-terminal-parameter)
! (setq term-terminal-parameter 0))
! ((eq char ??)) ; Ignore ?
! (t
! (term-handle-ansi-escape proc char)
! (setq term-terminal-more-parameters 0)
! (setq term-terminal-previous-parameter-4 -1)
! (setq term-terminal-previous-parameter-3 -1)
! (setq term-terminal-previous-parameter-2 -1)
! (setq term-terminal-previous-parameter -1)
! (setq term-terminal-state 0)))))
! (if (term-handling-pager)
! ;; Finish stuff to get ready to handle PAGER.
! (progn
! (if (> (% (current-column) term-width) 0)
! (setq term-terminal-parameter
! (substring str i))
! ;; We're at column 0. Goto end of buffer; to compensate,
! ;; prepend a ?\r for later. This looks more consistent.
! (if (zerop i)
(setq term-terminal-parameter
! (concat "\r" (substring str i)))
! (setq term-terminal-parameter (substring str (1- i)))
! (aset term-terminal-parameter 0 ?\r))
! (goto-char (point-max)))
! (setq term-terminal-state 4)
! (make-local-variable 'term-pager-old-filter)
! (setq term-pager-old-filter (process-filter proc))
! (set-process-filter proc term-pager-filter)
! (setq i str-length)))
! (setq i (1+ i))))
!
! (if (>= (term-current-row) term-height)
! (term-handle-deferred-scroll))
!
! (set-marker (process-mark proc) (point))
! (if save-point
! (progn (goto-char save-point)
! (set-marker save-point nil)))
!
! ;; Check for a pending filename-and-line number to display.
! ;; We do this before scrolling, because we might create a new window.
! (if (and term-pending-frame
! (eq (window-buffer selected) (current-buffer)))
! (progn (term-display-line (car term-pending-frame)
! (cdr term-pending-frame))
! (setq term-pending-frame nil)
! ;; We have created a new window, so check the window size.
! (term-check-size proc)))
!
! ;; Scroll each window displaying the buffer but (by default)
! ;; only if the point matches the process-mark we started with.
! (setq win selected)
! ;; Avoid infinite loop in strange case where minibuffer window
! ;; is selected but not active.
! (while (window-minibuffer-p win)
! (setq win (next-window win nil t)))
! (setq last-win win)
! (while (progn
! (setq win (next-window win nil t))
! (if (eq (window-buffer win) (process-buffer proc))
! (let ((scroll term-scroll-to-bottom-on-output))
! (select-window win)
! (if (or (= (point) save-marker)
! (eq scroll t) (eq scroll 'all)
! ;; Maybe user wants point to jump to the end.
! (and (eq selected win)
! (or (eq scroll 'this) (not save-point)))
! (and (eq scroll 'others)
! (not (eq selected win))))
! (progn
! (goto-char term-home-marker)
! (recenter 0)
! (goto-char (process-mark proc))
! (if (not (pos-visible-in-window-p (point) win))
! (recenter -1))))
! ;; Optionally scroll so that the text
! ;; ends at the bottom of the window.
! (if (and term-scroll-show-maximum-output
! (>= (point) (process-mark proc)))
! (save-excursion
! (goto-char (point-max))
! (recenter -1)))))
! (not (eq win last-win))))
;;; Stolen from comint.el and adapted -mm
! (if (> term-buffer-maximum-size 0)
! (save-excursion
! (goto-char (process-mark (get-buffer-process (current-buffer))))
! (forward-line (- term-buffer-maximum-size))
! (beginning-of-line)
! (delete-region (point-min) (point))))
;;;
! (set-marker save-marker nil))
! ;; unwind-protect cleanup-forms follow:
! (set-buffer previous-buffer)
! (select-window selected))))
(defun term-handle-deferred-scroll ()
(let ((count (- (term-current-row) term-height)))
--- 2647,2958 ----
;;; It emulates (most of the features of) a VT100/ANSI-style terminal.
(defun term-emulate-terminal (proc str)
! (with-current-buffer (process-buffer proc)
! (let* ((i 0) char funny count save-point save-marker old-point temp win
! (selected (selected-window))
! last-win
! (str-length (length str)))
! (unwind-protect
! (let ((buffer-undo-list t))
;;; Let's handle the messages. -mm
! (setq str (term-handle-ansi-terminal-messages str))
! (setq str-length (length str))
! (if (marker-buffer term-pending-delete-marker)
! (progn
! ;; Delete text following term-pending-delete-marker.
! (delete-region term-pending-delete-marker (process-mark proc))
! (set-marker term-pending-delete-marker nil)))
!
! (if (eq (window-buffer) (current-buffer))
! (progn
! (setq term-vertical-motion (symbol-function 'vertical-motion))
! (term-check-size proc))
! (setq term-vertical-motion
! (symbol-function 'buffer-vertical-motion)))
!
! (setq save-marker (copy-marker (process-mark proc)))
!
! (if (/= (point) (process-mark proc))
! (progn (setq save-point (point-marker))
! (goto-char (process-mark proc))))
!
! (save-restriction
! ;; If the buffer is in line mode, and there is a partial
! ;; input line, save the line (by narrowing to leave it
! ;; outside the restriction ) until we're done with output.
! (if (and (> (point-max) (process-mark proc))
! (term-in-line-mode))
! (narrow-to-region (point-min) (process-mark proc)))
!
! (if term-log-buffer
! (princ str term-log-buffer))
! (cond ((eq term-terminal-state 4) ;; Have saved pending output.
! (setq str (concat term-terminal-parameter str))
! (setq term-terminal-parameter nil)
! (setq str-length (length str))
! (setq term-terminal-state 0)))
!
! (while (< i str-length)
! (setq char (aref str i))
! (cond ((< term-terminal-state 2)
! ;; Look for prefix of regular chars
! (setq funny
! (string-match "[\r\n\000\007\033\t\b\032\016\017]"
! str i))
! (if (not funny) (setq funny str-length))
! (cond ((> funny i)
! (cond ((eq term-terminal-state 1)
! (term-move-columns 1)
! (setq term-terminal-state 0)))
! (setq count (- funny i))
! (setq temp (- (+ (term-horizontal-column) count)
! term-width))
! (cond ((<= temp 0)) ;; All count chars fit in line.
! ((> count temp) ;; Some chars fit.
! ;; This iteration, handle only what fits.
! (setq count (- count temp))
! (setq funny (+ count i)))
! ((or (not (or term-pager-count
! term-scroll-with-delete))
! (> (term-handle-scroll 1) 0))
! (term-adjust-current-row-cache 1)
! (setq count (min count term-width))
! (setq funny (+ count i))
! (setq term-start-line-column
! term-current-column))
! (t ;; Doing PAGER processing.
! (setq count 0 funny i)
! (setq term-current-column nil)
! (setq term-start-line-column nil)))
! (setq old-point (point))
!
! ;; Insert a string, check how many columns
! ;; we moved, then delete that many columns
! ;; following point if not eob nor insert-mode.
! (let ((old-column (current-column))
! columns pos)
! (insert (substring str i funny))
! (setq term-current-column (current-column)
! columns (- term-current-column old-column))
! (when (not (or (eobp) term-insert-mode))
! (setq pos (point))
! (term-move-columns columns)
! (delete-region pos (point))))
! (setq term-current-column nil)
!
! (put-text-property old-point (point)
! 'face term-current-face)
! ;; If the last char was written in last column,
! ;; back up one column, but remember we did so.
! ;; Thus we emulate xterm/vt100-style line-wrapping.
! (cond ((eq temp 0)
! (term-move-columns -1)
! (setq term-terminal-state 1)))
! (setq i (1- funny)))
! ((and (setq term-terminal-state 0)
! (eq char ?\^I)) ; TAB
! ;; FIXME: Does not handle line wrap!
! (setq count (term-current-column))
! (setq count (+ count 8 (- (mod count 8))))
! (if (< (move-to-column count nil) count)
! (term-insert-char char 1))
! (setq term-current-column count))
! ((eq char ?\r)
! ;; Optimize CRLF at end of buffer:
! (cond ((and (< (setq temp (1+ i)) str-length)
! (eq (aref str temp) ?\n)
! (= (point) (point-max))
! (not (or term-pager-count
! term-kill-echo-list
! term-scroll-with-delete)))
! (insert ?\n)
! (term-adjust-current-row-cache 1)
! (setq term-start-line-column 0)
! (setq term-current-column 0)
! (setq i temp))
! (t ;; Not followed by LF or can't optimize:
! (term-vertical-motion 0)
! (setq term-current-column term-start-line-column))))
! ((eq char ?\n)
! (if (not (and term-kill-echo-list
! (term-check-kill-echo-list)))
! (term-down 1 t)))
! ((eq char ?\b)
! (term-move-columns -1))
! ((eq char ?\033) ; Escape
! (setq term-terminal-state 2))
! ((eq char 0)) ; NUL: Do nothing
! ((eq char ?\016)) ; Shift Out - ignored
! ((eq char ?\017)) ; Shift In - ignored
! ((eq char ?\^G)
! (beep t)) ; Bell
! ((eq char ?\032)
! (let ((end (string-match "\r?$" str i)))
! (if end
! (funcall term-command-hook
! (prog1 (substring str (1+ i) end)
! (setq i (match-end 0))))
! (setq term-terminal-parameter
! (substring str i))
! (setq term-terminal-state 4)
! (setq i str-length))))
! (t ; insert char FIXME: Should never happen
! (term-move-columns 1)
! (backward-delete-char 1)
! (insert char))))
! ((eq term-terminal-state 2) ; Seen Esc
! (cond ((eq char ?\133) ;; ?\133 = ?[
;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
;;; Note that now the init value of term-terminal-previous-parameter has
;;; been changed to -1
! (make-local-variable 'term-terminal-parameter)
! (make-local-variable 'term-terminal-previous-parameter)
! (make-local-variable 'term-terminal-previous-parameter-2)
! (make-local-variable 'term-terminal-previous-parameter-3)
! (make-local-variable 'term-terminal-previous-parameter-4)
! (make-local-variable 'term-terminal-more-parameters)
! (setq term-terminal-parameter 0)
! (setq term-terminal-previous-parameter -1)
! (setq term-terminal-previous-parameter-2 -1)
! (setq term-terminal-previous-parameter-3 -1)
! (setq term-terminal-previous-parameter-4 -1)
! (setq term-terminal-more-parameters 0)
! (setq term-terminal-state 3))
! ((eq char ?D) ;; scroll forward
! (term-handle-deferred-scroll)
! (term-down 1 t)
! (setq term-terminal-state 0))
! ((eq char ?M) ;; scroll reversed
! (term-insert-lines 1)
! (setq term-terminal-state 0))
! ((eq char ?7) ;; Save cursor
! (term-handle-deferred-scroll)
! (setq term-saved-cursor
! (cons (term-current-row)
! (term-horizontal-column)))
! (setq term-terminal-state 0))
! ((eq char ?8) ;; Restore cursor
! (if term-saved-cursor
! (term-goto (car term-saved-cursor)
! (cdr term-saved-cursor)))
! (setq term-terminal-state 0))
! ((setq term-terminal-state 0))))
! ((eq term-terminal-state 3) ; Seen Esc [
! (cond ((and (>= char ?0) (<= char ?9))
! (setq term-terminal-parameter
! (+ (* 10 term-terminal-parameter) (- char ?0))))
! ((eq char ?\;)
;;; Some modifications to cope with multiple settings like ^[[01;32;43m -mm
! (setq term-terminal-more-parameters 1)
! (setq term-terminal-previous-parameter-4
! term-terminal-previous-parameter-3)
! (setq term-terminal-previous-parameter-3
! term-terminal-previous-parameter-2)
! (setq term-terminal-previous-parameter-2
! term-terminal-previous-parameter)
! (setq term-terminal-previous-parameter
! term-terminal-parameter)
! (setq term-terminal-parameter 0))
! ((eq char ??)) ; Ignore ?
! (t
! (term-handle-ansi-escape proc char)
! (setq term-terminal-more-parameters 0)
! (setq term-terminal-previous-parameter-4 -1)
! (setq term-terminal-previous-parameter-3 -1)
! (setq term-terminal-previous-parameter-2 -1)
! (setq term-terminal-previous-parameter -1)
! (setq term-terminal-state 0)))))
! (if (term-handling-pager)
! ;; Finish stuff to get ready to handle PAGER.
! (progn
! (if (> (% (current-column) term-width) 0)
(setq term-terminal-parameter
! (substring str i))
! ;; We're at column 0. Goto end of buffer; to compensate,
! ;; prepend a ?\r for later. This looks more consistent.
! (if (zerop i)
! (setq term-terminal-parameter
! (concat "\r" (substring str i)))
! (setq term-terminal-parameter (substring str (1- i)))
! (aset term-terminal-parameter 0 ?\r))
! (goto-char (point-max)))
! (setq term-terminal-state 4)
! (make-local-variable 'term-pager-old-filter)
! (setq term-pager-old-filter (process-filter proc))
! (set-process-filter proc term-pager-filter)
! (setq i str-length)))
! (setq i (1+ i))))
!
! (if (>= (term-current-row) term-height)
! (term-handle-deferred-scroll))
!
! (set-marker (process-mark proc) (point))
! (if save-point
! (progn (goto-char save-point)
! (set-marker save-point nil)))
!
! ;; Check for a pending filename-and-line number to display.
! ;; We do this before scrolling, because we might create a new window.
! (if (and term-pending-frame
! (eq (window-buffer selected) (current-buffer)))
! (progn (term-display-line (car term-pending-frame)
! (cdr term-pending-frame))
! (setq term-pending-frame nil)
! ;; We have created a new window, so check the window size.
! (term-check-size proc)))
!
! ;; Scroll each window displaying the buffer but (by default)
! ;; only if the point matches the process-mark we started with.
! (setq win selected)
! ;; Avoid infinite loop in strange case where minibuffer window
! ;; is selected but not active.
! (while (window-minibuffer-p win)
! (setq win (next-window win nil t)))
! (setq last-win win)
! (while (progn
! (setq win (next-window win nil t))
! (if (eq (window-buffer win) (process-buffer proc))
! (let ((scroll term-scroll-to-bottom-on-output))
! (select-window win)
! (if (or (= (point) save-marker)
! (eq scroll t) (eq scroll 'all)
! ;; Maybe user wants point to jump to the end.
! (and (eq selected win)
! (or (eq scroll 'this) (not save-point)))
! (and (eq scroll 'others)
! (not (eq selected win))))
! (progn
! (goto-char term-home-marker)
! (recenter 0)
! (goto-char (process-mark proc))
! (if (not (pos-visible-in-window-p (point) win))
! (recenter -1))))
! ;; Optionally scroll so that the text
! ;; ends at the bottom of the window.
! (if (and term-scroll-show-maximum-output
! (>= (point) (process-mark proc)))
! (save-excursion
! (goto-char (point-max))
! (recenter -1)))))
! (not (eq win last-win))))
;;; Stolen from comint.el and adapted -mm
! (if (> term-buffer-maximum-size 0)
! (save-excursion
! (goto-char (process-mark (get-buffer-process (current-buffer))))
! (forward-line (- term-buffer-maximum-size))
! (beginning-of-line)
! (delete-region (point-min) (point))))
;;;
! (set-marker save-marker nil))
! ;; unwind-protect cleanup-forms follow:
! (select-window selected)))))
(defun term-handle-deferred-scroll ()
(let ((count (- (term-current-row) term-height)))
^ permalink raw reply [flat|nested] 15+ messages in thread
* undo in compilation mode
2004-08-22 23:39 term.el and undo Richard Stallman
@ 2004-08-23 1:43 ` Karl Chen
2004-08-23 23:26 ` Richard Stallman
2004-08-24 20:13 ` term.el and undo Mark Plaksin
1 sibling, 1 reply; 15+ messages in thread
From: Karl Chen @ 2004-08-23 1:43 UTC (permalink / raw)
By the way, I think undo support in compilation mode (for text
output by 'compile' at least) is usually superfluous as well, and
in fact even a little confusing
--
Karl 2004-08-22 18:41
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-23 1:43 ` undo in compilation mode Karl Chen
@ 2004-08-23 23:26 ` Richard Stallman
2004-08-23 23:32 ` Florian Weimer
2004-08-24 2:08 ` Stefan
0 siblings, 2 replies; 15+ messages in thread
From: Richard Stallman @ 2004-08-23 23:26 UTC (permalink / raw)
Cc: emacs-devel
By the way, I think undo support in compilation mode (for text
output by 'compile' at least) is usually superfluous as well, and
in fact even a little confusing
If people want to play with trying to turn that off,
we could see what the results are like.
Would it be sufficient just to turn off undo
in those buffers?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-23 23:26 ` Richard Stallman
@ 2004-08-23 23:32 ` Florian Weimer
2004-08-24 21:02 ` Richard Stallman
2004-08-24 2:08 ` Stefan
1 sibling, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2004-08-23 23:32 UTC (permalink / raw)
Cc: quarl+dated+1093657282.52fc76, emacs-devel
* Richard Stallman:
> By the way, I think undo support in compilation mode (for text
> output by 'compile' at least) is usually superfluous as well, and
> in fact even a little confusing
>
> If people want to play with trying to turn that off,
> we could see what the results are like.
In this case, it shouldn't be possible to accidently change the
buffer. It happens quite often that I inadvertently change a file
name in the buffer (most of the time by pressing "f"), and using undo
before pressing RET is necessary in such cases.
(Disclaimer: I'm not using the CVS version.)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-23 23:32 ` Florian Weimer
@ 2004-08-24 21:02 ` Richard Stallman
2004-08-24 23:25 ` Karl Chen
0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2004-08-24 21:02 UTC (permalink / raw)
Cc: quarl+dated+1093657282.52fc76, emacs-devel
> By the way, I think undo support in compilation mode (for text
> output by 'compile' at least) is usually superfluous as well, and
> in fact even a little confusing
>
> If people want to play with trying to turn that off,
> we could see what the results are like.
In this case, it shouldn't be possible to accidently change the
buffer. It happens quite often that I inadvertently change a file
name in the buffer (most of the time by pressing "f"), and using undo
before pressing RET is necessary in such cases.
The buffer could be made read-only, and the filter could bind
inhibit-read-only to t in order to write in it.
Do people see cases where that would cause trouble?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-23 23:26 ` Richard Stallman
2004-08-23 23:32 ` Florian Weimer
@ 2004-08-24 2:08 ` Stefan
2004-08-24 14:50 ` Karl Chen
1 sibling, 1 reply; 15+ messages in thread
From: Stefan @ 2004-08-24 2:08 UTC (permalink / raw)
Cc: quarl+dated+1093657282.52fc76, emacs-devel
> By the way, I think undo support in compilation mode (for text
> output by 'compile' at least) is usually superfluous as well, and
> in fact even a little confusing
> If people want to play with trying to turn that off, we could see what the
> results are like. Would it be sufficient just to turn off undo in
> those buffers?
I think turning off undo in "write-mostly" buffers doesn't make much sense:
the undo log takes very little space in such a case anyway (it only tracks
the boundaries of each insertion).
I think the OP's problem has more to do with writability than with the
undo facility. Many people expect the *compile* buffer to be read-only.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-24 2:08 ` Stefan
@ 2004-08-24 14:50 ` Karl Chen
2004-08-25 4:41 ` Richard Stallman
0 siblings, 1 reply; 15+ messages in thread
From: Karl Chen @ 2004-08-24 14:50 UTC (permalink / raw)
>>>>> "Stefan" == Stefan <monnier@iro.umontreal.ca> writes:
Stefan> I think the OP's problem has more to do with
Stefan> writability than with the undo facility. Many people
Stefan> expect the *compile* buffer to be read-only.
Yes, read-only would be better (also prevents user from undoing)
--
Karl 2004-08-24 07:49
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: undo in compilation mode
2004-08-24 14:50 ` Karl Chen
@ 2004-08-25 4:41 ` Richard Stallman
0 siblings, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2004-08-25 4:41 UTC (permalink / raw)
Cc: emacs-devel
Stefan> I think the OP's problem has more to do with
Stefan> writability than with the undo facility. Many people
Stefan> expect the *compile* buffer to be read-only.
Yes, read-only would be better (also prevents user from undoing)
Does this change do it?
*** compile.el 11 Aug 2004 16:46:19 -0400 1.323
--- compile.el 25 Aug 2004 00:03:13 -0400
***************
*** 892,908 ****
(error nil))
(error "Cannot have two processes in `%s' at once"
(buffer-name)))))
- ;; Clear out the compilation buffer and make it writable.
- ;; Change its default-directory to the directory where the compilation
- ;; will happen, and insert a `cd' command to indicate this.
- (setq buffer-read-only nil)
(buffer-disable-undo (current-buffer))
! (erase-buffer)
! (buffer-enable-undo (current-buffer))
! (setq default-directory thisdir)
! ;; output a mode setter, for saving and later reloading this buffer
! (insert "cd " thisdir " # -*-" name-of-mode
! "-*-\nEntering directory `" thisdir "'\n" command "\n")
(set-buffer-modified-p nil))
;; If we're already in the compilation buffer, go to the end
;; of the buffer, so point will track the compilation output.
--- 892,909 ----
(error nil))
(error "Cannot have two processes in `%s' at once"
(buffer-name)))))
(buffer-disable-undo (current-buffer))
! ;; Make compilation buffer read-only. The filter can still write it.
! ;; Clear out the compilation buffer.
! (let ((inhibit-read-only t))
! (erase-buffer)
! ;; Change its default-directory to the directory where the compilation
! ;; will happen, and insert a `cd' command to indicate this.
! (setq default-directory thisdir)
! ;; output a mode setter, for saving and later reloading this buffer
! (insert "cd " thisdir " # -*-" name-of-mode
! "-*-\nEntering directory `" thisdir "'\n"
! command "\n"))
(set-buffer-modified-p nil))
;; If we're already in the compilation buffer, go to the end
;; of the buffer, so point will track the compilation output.
***************
*** 913,922 ****
(with-current-buffer outbuf
(if (not (eq mode t))
(funcall mode)
(with-no-warnings (comint-mode))
(compilation-shell-minor-mode))
- ;; In what way is it non-ergonomic ? -stef
- ;; (toggle-read-only 1) ;;; Non-ergonomic.
(if highlight-regexp
(set (make-local-variable 'compilation-highlight-regexp)
highlight-regexp))
--- 914,922 ----
(with-current-buffer outbuf
(if (not (eq mode t))
(funcall mode)
+ (setq buffer-read-only nil)
(with-no-warnings (comint-mode))
(compilation-shell-minor-mode))
(if highlight-regexp
(set (make-local-variable 'compilation-highlight-regexp)
highlight-regexp))
***************
*** 1174,1179 ****
--- 1174,1180 ----
"Prepare the buffer for the compilation parsing commands to work.
Optional argument MINOR indicates this is called from
`compilation-minor-mode'."
+ (setq buffer-read-only t)
(make-local-variable 'compilation-current-error)
(make-local-variable 'compilation-messages-start)
(make-local-variable 'compilation-error-screen-columns)
***************
*** 1235,1241 ****
(defun compilation-handle-exit (process-status exit-status msg)
"Write MSG in the current buffer and hack its mode-line-process."
! (let ((buffer-read-only nil)
(status (if compilation-exit-message-function
(funcall compilation-exit-message-function
process-status exit-status msg)
--- 1236,1242 ----
(defun compilation-handle-exit (process-status exit-status msg)
"Write MSG in the current buffer and hack its mode-line-process."
! (let ((inhibit-read-only t)
(status (if compilation-exit-message-function
(funcall compilation-exit-message-function
process-status exit-status msg)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-22 23:39 term.el and undo Richard Stallman
2004-08-23 1:43 ` undo in compilation mode Karl Chen
@ 2004-08-24 20:13 ` Mark Plaksin
2004-08-25 4:41 ` Richard Stallman
1 sibling, 1 reply; 15+ messages in thread
From: Mark Plaksin @ 2004-08-24 20:13 UTC (permalink / raw)
Richard Stallman <rms@gnu.org> writes:
> Cases like running `top' under M-x term build up big undo lists.
> It seems to me that undo information is useless in that case.
> However, just disabling undo in term buffers seems like a mistake.
> There are some cases, such as editing user input in line mode,
> where undo info is certainly desired.
>
> Here's a patch that should disable generation of undo information
> for output done by the subprogram. Could those who use term.el
> try it and report on whether the results make sense?
Personally I'd be happy with *no* undo in term buffers. Undo with the
patch works as expected when in line mode and editing a command-line.
That's the only time that undo seems useful. With the patch using undo at
any other time makes the cursor jump around from line to line which is
confusing.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-24 20:13 ` term.el and undo Mark Plaksin
@ 2004-08-25 4:41 ` Richard Stallman
2004-08-25 8:03 ` David Kastrup
0 siblings, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2004-08-25 4:41 UTC (permalink / raw)
Cc: emacs-devel
Personally I'd be happy with *no* undo in term buffers. Undo with the
patch works as expected when in line mode and editing a command-line.
That's the only time that undo seems useful. With the patch using undo at
any other time makes the cursor jump around from line to line which is
confusing.
I do not understand what you mean. Could you describe a precise
test case in which this jumping occurs?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-25 4:41 ` Richard Stallman
@ 2004-08-25 8:03 ` David Kastrup
2004-08-25 12:59 ` Florian Weimer
2004-08-25 22:40 ` Richard Stallman
0 siblings, 2 replies; 15+ messages in thread
From: David Kastrup @ 2004-08-25 8:03 UTC (permalink / raw)
Cc: Mark Plaksin, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> Personally I'd be happy with *no* undo in term buffers. Undo
> with the patch works as expected when in line mode and editing a
> command-line. That's the only time that undo seems useful.
> With the patch using undo at any other time makes the cursor
> jump around from line to line which is confusing.
>
> I do not understand what you mean. Could you describe a precise
> test case in which this jumping occurs?
I'd suppose that the terminal has one idea of the cursor location, and
undo happens at other points.
However, since the whole point of term is to provide an
ncurses-capable terminal, and since undo or any other output or cursor
movement operation not initiated from the device writing into the
pseudotty would lead to a discrepancy between the screen contents and
the application's expectations, _any_ editing by the user including
undo would seem completely pointless. term probably keeps track of
its own cursor position, so at least you can use copy and paste to do
screenshots as long as the application is not writing to the screen,
but apart from read-only operations like that, user access does not
seem sensible. "Undo" might be a curiosity to go back in time in the
term, but just like it would seem necessary to move the cursor to the
expected place before inserting new output, it would seem necessary to
completely redo all changes before the application writes new
material.
Since this would require specialized undo semantics, I think we are
better off with disabling it altogether by default.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-25 8:03 ` David Kastrup
@ 2004-08-25 12:59 ` Florian Weimer
2004-08-25 20:25 ` Mark Plaksin
2004-08-25 22:40 ` Richard Stallman
1 sibling, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2004-08-25 12:59 UTC (permalink / raw)
* David Kastrup:
> However, since the whole point of term is to provide an
> ncurses-capable terminal, and since undo or any other output or cursor
> movement operation not initiated from the device writing into the
> pseudotty would lead to a discrepancy between the screen contents and
> the application's expectations, _any_ editing by the user including
> undo would seem completely pointless.
Minor nitpick: In *line* *mode*, undo does make sense, because the
application doesn't see any data before the user presses RET. (Line
mode is the default mode, and typically it supports limited line
editing via ^H, ^W and ^U.)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-25 12:59 ` Florian Weimer
@ 2004-08-25 20:25 ` Mark Plaksin
0 siblings, 0 replies; 15+ messages in thread
From: Mark Plaksin @ 2004-08-25 20:25 UTC (permalink / raw)
Florian Weimer <fw@deneb.enyo.de> writes:
> * David Kastrup:
>
>> However, since the whole point of term is to provide an
>> ncurses-capable terminal, and since undo or any other output or cursor
>> movement operation not initiated from the device writing into the
>> pseudotty would lead to a discrepancy between the screen contents and
>> the application's expectations, _any_ editing by the user including
>> undo would seem completely pointless.
>
> Minor nitpick: In *line* *mode*, undo does make sense, because the
> application doesn't see any data before the user presses RET. (Line
> mode is the default mode, and typically it supports limited line
> editing via ^H, ^W and ^U.)
Right but it only makes sense *on the current command-line*. Undoing
anything beyond that will make the point move to some random place in the
window where some prior insert happened.
Say you typed ls at the top of the window and the output took up half the
window. The point is in the middle of the window. Then while typing your
next command you delete some text and want to undo the deletion. That
works fine unless you undo again--that will make the point move to the top
of the buffer which probably isn't what you want.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: term.el and undo
2004-08-25 8:03 ` David Kastrup
2004-08-25 12:59 ` Florian Weimer
@ 2004-08-25 22:40 ` Richard Stallman
1 sibling, 0 replies; 15+ messages in thread
From: Richard Stallman @ 2004-08-25 22:40 UTC (permalink / raw)
Cc: happy, emacs-devel
> I do not understand what you mean. Could you describe a precise
> test case in which this jumping occurs?
I'd suppose that the terminal has one idea of the cursor location, and
undo happens at other points.
Maybe so, but to really understand, I need a test case.
However, since the whole point of term is to provide an
ncurses-capable terminal, and since undo or any other output or cursor
movement operation not initiated from the device writing into the
pseudotty would lead to a discrepancy between the screen contents and
the application's expectations, _any_ editing by the user including
undo would seem completely pointless.
Not in line mode, though.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2004-08-25 22:40 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-22 23:39 term.el and undo Richard Stallman
2004-08-23 1:43 ` undo in compilation mode Karl Chen
2004-08-23 23:26 ` Richard Stallman
2004-08-23 23:32 ` Florian Weimer
2004-08-24 21:02 ` Richard Stallman
2004-08-24 23:25 ` Karl Chen
2004-08-24 2:08 ` Stefan
2004-08-24 14:50 ` Karl Chen
2004-08-25 4:41 ` Richard Stallman
2004-08-24 20:13 ` term.el and undo Mark Plaksin
2004-08-25 4:41 ` Richard Stallman
2004-08-25 8:03 ` David Kastrup
2004-08-25 12:59 ` Florian Weimer
2004-08-25 20:25 ` Mark Plaksin
2004-08-25 22:40 ` Richard Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).