Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / lisp / net / telnet.el
index 3a0405b..00a5568 100644 (file)
@@ -1,7 +1,7 @@
 ;;; telnet.el --- run a telnet session from within an Emacs buffer
 
-;; Copyright (C) 1985, 1988, 1992, 1994, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2012
+;;   Free Software Foundation, Inc.
 
 ;; Author: William F. Schelter
 ;; Maintainer: FSF
@@ -61,7 +61,15 @@ PROGRAM says which program to run, to talk to that machine.
 LOGIN-NAME, which is optional, says what to log in as on that machine.")
 
 (defvar telnet-new-line "\r")
-(defvar telnet-mode-map nil)
+(defvar telnet-mode-map
+  (let ((map (nconc (make-sparse-keymap) comint-mode-map)))
+    (define-key map "\C-m" 'telnet-send-input)
+    ;; (define-key map "\C-j" 'telnet-send-input)
+    (define-key map "\C-c\C-q" 'send-process-next-char)
+    (define-key map "\C-c\C-c" 'telnet-interrupt-subjob)
+    (define-key map "\C-c\C-z" 'telnet-c-z)
+    map))
+
 (defvar telnet-prompt-pattern "^[^#$%>\n]*[#$%>] *")
 (defvar telnet-replace-c-g nil)
 (make-variable-buffer-local
@@ -104,16 +112,6 @@ rejecting one login and prompting again for a username and password.")
                           (prog1 (read-char)
                             (setq quit-flag nil))))))
 
-; initialization on first load.
-(if telnet-mode-map
-    nil
-  (setq telnet-mode-map (nconc (make-sparse-keymap) comint-mode-map))
-  (define-key telnet-mode-map "\C-m" 'telnet-send-input)
-;  (define-key telnet-mode-map "\C-j" 'telnet-send-input)
-  (define-key telnet-mode-map "\C-c\C-q" 'send-process-next-char)
-  (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob)
-  (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z))
-
 ;;maybe should have a flag for when have found type
 (defun telnet-check-software-type-initialize (string)
   "Tries to put correct initializations in.  Needs work."
@@ -159,8 +157,7 @@ rejecting one login and prompting again for a username and password.")
     (comint-send-string proc telnet-new-line)))
 
 (defun telnet-filter (proc string)
-  (save-excursion
-    (set-buffer (process-buffer proc))
+  (with-current-buffer (process-buffer proc)
     (let* ((last-insertion (marker-position (process-mark proc)))
           (delta (- (point) last-insertion))
           (ie (and comint-last-input-end
@@ -168,7 +165,7 @@ rejecting one login and prompting again for a username and password.")
           (w (get-buffer-window (current-buffer)))
           (ws (and w (window-start w))))
       (goto-char last-insertion)
-      (insert-before-markers string)
+      (insert string)
       (set-marker comint-last-output-start last-insertion)
       (set-marker (process-mark proc) (point))
       (if ws (set-window-start w ws t))
@@ -193,8 +190,6 @@ rejecting one login and prompting again for a username and password.")
       (delete-region comint-last-input-start
                     comint-last-input-end)))
 
-;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
-
 ;;;###autoload
 (defun telnet (host &optional port)
   "Open a network login connection to host named HOST (a string).
@@ -222,8 +217,8 @@ Normally input is edited in Emacs and sent a line at a time."
         (telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
         process)
     (if (and buffer (get-buffer-process buffer))
-       (pop-to-buffer (concat "*" name "*"))
-      (pop-to-buffer
+       (switch-to-buffer (concat "*" name "*"))
+      (switch-to-buffer
        (apply 'make-comint name telnet-program nil telnet-options))
       (setq process (get-buffer-process (current-buffer)))
       (set-process-filter process 'telnet-initial-filter)
@@ -245,11 +240,10 @@ It has most of the same commands as comint-mode.
 There is a variable ``telnet-interrupt-string'' which is the character
 sent to try to stop execution of a job on the remote host.
 Data is sent to the remote host when RET is typed."
+  (set (make-local-variable 'window-point-insertion-type) t)
   (set (make-local-variable 'comint-prompt-regexp) telnet-prompt-pattern)
   (set (make-local-variable 'comint-use-prompt-regexp) t))
 
-;;;###autoload (add-hook 'same-window-regexps "\\*rsh-[^-]*\\*\\(\\|<[0-9]*>\\)")
-
 ;;;###autoload
 (defun rsh (host)
   "Open a network login connection to host named HOST (a string).
@@ -258,12 +252,11 @@ Normally input is edited in Emacs and sent a line at a time."
   (interactive "sOpen rsh connection to host: ")
   (require 'shell)
   (let ((name (concat "rsh-" host )))
-    (pop-to-buffer (make-comint name remote-shell-program nil host))
+    (switch-to-buffer (make-comint name remote-shell-program nil host))
     (set-process-filter (get-process name) 'telnet-initial-filter)
     (telnet-mode)
     (setq telnet-count -16)))
 
 (provide 'telnet)
 
-;; arch-tag: 98218821-d04a-48b6-9058-57d0d4677a56
 ;;; telnet.el ends here