;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
Entry to this mode runs the hooks on `comint-mode-hook'."
(setq mode-line-process '(":%s"))
+ (set (make-local-variable 'window-point-insertion-type) t)
(set (make-local-variable 'comint-last-input-start) (point-min-marker))
(set (make-local-variable 'comint-last-input-end) (point-min-marker))
(set (make-local-variable 'comint-last-output-start) (make-marker))
;; Insert STRING
(let ((inhibit-read-only t)
- ;; Avoid the overhead of save-excursion, since we just
- ;; fiddle with the point
- (saved-point (point-marker)))
-
- ;; The point should float after any insertion we do
- (set-marker-insertion-type saved-point t)
+ ;; The point should float after any insertion we do.
+ (saved-point (copy-marker (point) t)))
;; We temporarly remove any buffer narrowing, in case the
;; process mark is outside of the restriction
(set-marker comint-last-output-start (point))
;; insert-before-markers is a bad thing. XXX
- ;;
- ;; It is used here to force window-point markers (used to
- ;; store the value of point in non-selected windows) to
- ;; advance, but it also screws up any other markers that we
- ;; don't _want_ to advance, such as the start-marker of some
- ;; of the overlays we create.
- ;;
- ;; We work around the problem with the overlays by
- ;; explicitly adjusting them after we do the insertion, but
- ;; in the future this problem should be solved correctly, by
- ;; using `insert', and making the insertion-type of
- ;; window-point markers settable (via a buffer-local
- ;; variable). In comint buffers, this variable would be set
- ;; to `t', to cause point in non-select windows to advance.
- (insert-before-markers string)
- ;; Fixup markers and overlays that got screwed up because we
- ;; used `insert-before-markers'.
- (let ((old-point (- (point) (length string))))
- ;; comint-last-output-start
- (set-marker comint-last-output-start old-point)
- ;; comint-last-input-end
- (when (and comint-last-input-end
- (equal (marker-position comint-last-input-end)
- (point)))
- (set-marker comint-last-input-end old-point))
- ;; No overlays we create are set to advance upon insertion
- ;; (at the start/end), so we assume that any overlay which
- ;; is at the current point was incorrectly advanced by
- ;; insert-before-markers. First fixup overlays that might
- ;; start at point:
- (dolist (over (overlays-at (point)))
- (when (= (overlay-start over) (point))
- (let ((end (overlay-end over)))
- (move-overlay over
- old-point
- (if (= end (point)) old-point end)))))
- ;; Then do overlays that might end at point:
- (dolist (over (overlays-at (1- (point))))
- (when (= (overlay-end over) (point))
- (move-overlay over
- (min (overlay-start over) old-point)
- old-point))))
+ ;; Luckily we don't have to use it any more, we use
+ ;; window-point-insertion-type instead.
+ (insert string)
;; Advance process-mark
(set-marker (process-mark process) (point))
(let ((inhibit-read-only t)
(inhibit-modification-hooks t))
(add-text-properties comint-last-output-start (point)
- '(rear-nonsticky t
+ '(front-sticky
+ (field inhibit-line-move-field-capture)
+ rear-nonsticky t
field output
inhibit-line-move-field-capture t))))
(set-window-start (selected-window) (point))
(comint-skip-prompt))
(t
- (let* ((beg (field-beginning pos))
- (pt (if (= (point-min) beg)
- (point-min)
- (1+ beg))))
- (goto-char pt))
+ (goto-char (field-beginning pos))
(set-window-start (selected-window) (point))))))
" ")
(t
(cdr comint-completion-addsuffix))))
- (filename (or (comint-match-partial-filename) ""))
+ (filename (comint-match-partial-filename))
+ (filename-beg (if filename (match-beginning 0) (point)))
+ (filename-end (if filename (match-end 0) (point)))
+ (filename (or filename ""))
(filedir (file-name-directory filename))
(filenondir (file-name-nondirectory filename))
(directory (if filedir (comint-directory filedir) default-directory))
(comint-dynamic-list-filename-completions))
(t ; Completion string returned.
(let ((file (concat (file-name-as-directory directory) completion)))
- (insert (comint-quote-filename
- (substring (directory-file-name completion)
- (length filenondir))))
+ ;; Insert completion. Note that the completion string
+ ;; may have a different case than what's in the prompt,
+ ;; if read-file-name-completion-ignore-case is non-nil,
+ (delete-region filename-beg filename-end)
+ (if filedir (insert (comint-quote-filename filedir)))
+ (insert (comint-quote-filename (directory-file-name completion)))
(cond ((symbolp (file-name-completion completion directory))
;; We inserted a unique completion.
(insert (if (file-directory-p file) dirsuffix filesuffix))
(message "No completions of %s" filename))
(comint-dynamic-list-completions
(mapcar 'comint-quote-filename completions)
- filenondir))))
+ (comint-quote-filename filenondir)))))
;; This is bound locally in a *Completions* buffer to the list of