annotate lisp/rlogin.el @ 20640:3305df803f6e

(Fminibuffer_complete_word): Fix a bug of refering `i'. We must refer `i_byte' instead.
author Kenichi Handa <handa@m17n.org>
date Mon, 12 Jan 1998 05:49:45 +0000
parents 9880156cf5b6
children 7ba84f53e054
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
1 ;;; rlogin.el --- remote login interface
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
2
17409
6f49eb13a7c6 Update copyright year.
Richard M. Stallman <rms@gnu.org>
parents: 17408
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
4
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
5 ;; Author: Noah Friedman
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
6 ;; Maintainer: Noah Friedman <friedman@prep.ai.mit.edu>
2259
2ba32183ea62 Added keyword.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2233
diff changeset
7 ;; Keywords: unix, comm
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
8
18419
9880156cf5b6 Provide 'rlogin.
Noah Friedman <friedman@splode.com>
parents: 17647
diff changeset
9 ;; $Id: rlogin.el,v 1.39 1997/05/05 01:00:35 rms Exp $
9880156cf5b6 Provide 'rlogin.
Noah Friedman <friedman@splode.com>
parents: 17647
diff changeset
10
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
11 ;; This file is part of GNU Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
12
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
16 ;; any later version.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
17
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
21 ;; GNU General Public License for more details.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
22
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13310
diff changeset
26 ;; Boston, MA 02111-1307, USA.
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
2315
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
28 ;;; Commentary:
9e7ec92a4fdf Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2259
diff changeset
29
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
30 ;; Support for remote logins using `rlogin'.
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
31 ;; This program is layered on top of shell.el; the code here only accounts
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
32 ;; for the variations needed to handle a remote process, e.g. directory
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
33 ;; tracking and the sending of some special characters.
4856
896f3b49b53c (rlogin-initially-track-cwd): New variable.
Noah Friedman <friedman@splode.com>
parents: 4685
diff changeset
34
7922
8fcef41c85b7 (rlogin-password-paranoia): Variable deleted.
Noah Friedman <friedman@splode.com>
parents: 5793
diff changeset
35 ;; If you wish for rlogin mode to prompt you in the minibuffer for
8fcef41c85b7 (rlogin-password-paranoia): Variable deleted.
Noah Friedman <friedman@splode.com>
parents: 5793
diff changeset
36 ;; passwords when a password prompt appears, just enter m-x send-invisible
8fcef41c85b7 (rlogin-password-paranoia): Variable deleted.
Noah Friedman <friedman@splode.com>
parents: 5793
diff changeset
37 ;; and type in your line, or add `comint-watch-for-password-prompt' to
8fcef41c85b7 (rlogin-password-paranoia): Variable deleted.
Noah Friedman <friedman@splode.com>
parents: 5793
diff changeset
38 ;; `comint-output-filter-functions'.
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
40 ;;; Code:
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
41
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 (require 'comint)
4685
3bf9019e5c39 require 'shell
Noah Friedman <friedman@splode.com>
parents: 4678
diff changeset
43 (require 'shell)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
45 (defgroup rlogin nil
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
46 "Remote login interface"
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
47 :group 'processes
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
48 :group 'unix)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
49
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
50
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
51 (defcustom rlogin-program "rlogin"
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
52 "*Name of program to invoke rlogin"
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
53 :type 'string
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
54 :group 'rlogin)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
56 (defcustom rlogin-explicit-args nil
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
57 "*List of arguments to pass to rlogin on the command line."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
58 :type '(repeat (string :tag "Argument"))
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
59 :group 'rlogin)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
60
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
61 (defcustom rlogin-mode-hook nil
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
62 "*Hooks to run after setting current buffer to rlogin-mode."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
63 :type 'hook
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
64 :group 'rlogin)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65
17472
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
66 (defcustom rlogin-process-connection-type
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
67 (save-match-data
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
68 ;; Solaris 2.x `rlogin' will spew a bunch of ioctl error messages if
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
69 ;; stdin isn't a tty.
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
70 (cond ((and (boundp 'system-configuration)
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
71 (stringp system-configuration)
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
72 (string-match "-solaris2" system-configuration))
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
73 t)
c7a720ef31e6 (rlogin-process-connection-type): Default to t for solaris 2.x.
Noah Friedman <friedman@splode.com>
parents: 17409
diff changeset
74 (t nil)))
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
75 "*If non-`nil', use a pty for the local rlogin process.
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
76 If `nil', use a pipe (if pipes are supported on the local system).
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
77
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
78 Generally it is better not to waste ptys on systems which have a static
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
79 number of them. On the other hand, some implementations of `rlogin' assume
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
80 a pty is being used, and errors will result from using a pipe instead."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
81 :type '(choice (const :tag "ptys" t)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
82 (const :tag "pipes" nil))
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
83 :group 'rlogin)
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
84
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
85 (defcustom rlogin-directory-tracking-mode 'local
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
86 "*Control whether and how to do directory tracking in an rlogin buffer.
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
87
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
88 nil means don't do directory tracking.
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
89
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
90 t means do so using an ftp remote file name.
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
91
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
92 Any other value means do directory tracking using local file names.
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
93 This works only if the remote machine and the local one
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
94 share the same directories (through NFS). This is the default.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
95
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
96 This variable becomes local to a buffer when set in any fashion for it.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
97
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
98 It is better to use the function of the same name to change the behavior of
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
99 directory tracking in an rlogin session once it has begun, rather than
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
100 simply setting this variable, since the function does the necessary
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
101 re-synching of directories."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
102 :type '(choice (const :tag "off" nil)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
103 (const :tag "ftp" t)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
104 (const :tag "local" local))
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
105 :group 'rlogin)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
106
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
107 (make-variable-buffer-local 'rlogin-directory-tracking-mode)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
108
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
109 (defcustom rlogin-host nil
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
110 "*The name of the remote host. This variable is buffer-local."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
111 :type '(choice (const nil) string)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
112 :group 'rlogin)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
113
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
114 (defcustom rlogin-remote-user nil
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
115 "*The username used on the remote host.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
116 This variable is buffer-local and defaults to your local user name.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
117 If rlogin is invoked with the `-l' option to specify the remote username,
17408
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
118 this variable is set from that."
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
119 :type '(choice (const nil) string)
cc4d6343afca Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 15490
diff changeset
120 :group 'rlogin)
4856
896f3b49b53c (rlogin-initially-track-cwd): New variable.
Noah Friedman <friedman@splode.com>
parents: 4685
diff changeset
121
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
122 ;; Initialize rlogin mode map.
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
123 (defvar rlogin-mode-map '())
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
124 (cond
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
125 ((null rlogin-mode-map)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
126 (setq rlogin-mode-map (if (consp shell-mode-map)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
127 (cons 'keymap shell-mode-map)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
128 (copy-keymap shell-mode-map)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
129 (define-key rlogin-mode-map "\C-c\C-c" 'rlogin-send-Ctrl-C)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
130 (define-key rlogin-mode-map "\C-c\C-d" 'rlogin-send-Ctrl-D)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
131 (define-key rlogin-mode-map "\C-c\C-z" 'rlogin-send-Ctrl-Z)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
132 (define-key rlogin-mode-map "\C-c\C-\\" 'rlogin-send-Ctrl-backslash)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
133 (define-key rlogin-mode-map "\C-d" 'rlogin-delchar-or-send-Ctrl-D)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
134 (define-key rlogin-mode-map "\C-i" 'rlogin-tab-or-complete)))
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
136
10977
a173cfead4ce (rlogin): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10849
diff changeset
137 ;;;###autoload (add-hook 'same-window-regexps "^\\*rlogin-.*\\*\\(\\|<[0-9]+>\\)")
a173cfead4ce (rlogin): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10849
diff changeset
138
11805
95a2506fba60 (rlogin-history): New defvar.
Roland McGrath <roland@gnu.org>
parents: 11276
diff changeset
139 (defvar rlogin-history nil)
95a2506fba60 (rlogin-history): New defvar.
Roland McGrath <roland@gnu.org>
parents: 11276
diff changeset
140
2387
cb44857cab89 moby rlogin-filter fixes
Noah Friedman <friedman@splode.com>
parents: 2315
diff changeset
141 ;;;###autoload
12126
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
142 (defun rlogin (input-args &optional buffer)
15436
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
143 "Open a network login connection via `rlogin' with args INPUT-ARGS.
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
144 INPUT-ARGS should start with a host name; it may also contain
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
145 other arguments for `rlogin'.
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
146
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
147 Input is sent line-at-a-time to the remote connection.
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
148
10977
a173cfead4ce (rlogin): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10849
diff changeset
149 Communication with the remote host is recorded in a buffer `*rlogin-HOST*'
a173cfead4ce (rlogin): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10849
diff changeset
150 \(or `*rlogin-USER@HOST*' if the remote username differs\).
a173cfead4ce (rlogin): Use pop-to-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 10849
diff changeset
151 If a prefix argument is given and the buffer `*rlogin-HOST*' already exists,
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
152 a new buffer with a different connection will be made.
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
153
15436
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
154 When called from a program, if the optional second argument BUFFER is
0dd0e409b9fb (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15182
diff changeset
155 a string or buffer, it specifies the buffer to use.
12126
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
156
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
157 The variable `rlogin-program' contains the name of the actual program to
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
158 run. It can be a relative or absolute path.
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
159
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
160 The variable `rlogin-explicit-args' is a list of arguments to give to
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
161 the rlogin when starting. They are added after any arguments given in
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
162 INPUT-ARGS.
9250
7cf726dccf2e (rlogin): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8917
diff changeset
163
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
164 If the default value of `rlogin-directory-tracking-mode' is t, then the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
165 default directory in that buffer is set to a remote (FTP) file name to
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
166 access your home directory on the remote machine. Occasionally this causes
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
167 an error, if you cannot access the home directory on that machine. This
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
168 error is harmless as long as you don't try to use that default directory.
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
169
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
170 If `rlogin-directory-tracking-mode' is neither t nor nil, then the default
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
171 directory is initially set up to your (local) home directory.
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
172 This is useful if the remote machine and your local machine
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
173 share the same files via NFS. This is the default.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
174
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
175 If you wish to change directory tracking styles during a session, use the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
176 function `rlogin-directory-tracking-mode' rather than simply setting the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
177 variable."
8917
de32691e953c * rlogin.el (rlogin): recognise the `-l user' option to rlogin and
Francesco Potortì <pot@gnu.org>
parents: 7922
diff changeset
178 (interactive (list
11805
95a2506fba60 (rlogin-history): New defvar.
Roland McGrath <roland@gnu.org>
parents: 11276
diff changeset
179 (read-from-minibuffer "rlogin arguments (hostname first): "
95a2506fba60 (rlogin-history): New defvar.
Roland McGrath <roland@gnu.org>
parents: 11276
diff changeset
180 nil nil nil 'rlogin-history)
8917
de32691e953c * rlogin.el (rlogin): recognise the `-l user' option to rlogin and
Francesco Potortì <pot@gnu.org>
parents: 7922
diff changeset
181 current-prefix-arg))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
182
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
183 (let* ((process-connection-type rlogin-process-connection-type)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
184 (args (if rlogin-explicit-args
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
185 (append (rlogin-parse-words input-args)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
186 rlogin-explicit-args)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
187 (rlogin-parse-words input-args)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
188 (host (car args))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
189 (user (or (car (cdr (member "-l" args)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
190 (user-login-name)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
191 (buffer-name (if (string= user (user-login-name))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
192 (format "*rlogin-%s*" host)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
193 (format "*rlogin-%s@%s*" user host)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
194 proc)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
195
12126
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
196 (cond ((null buffer))
13310
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
197 ((stringp buffer)
12126
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
198 (setq buffer-name buffer))
13310
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
199 ((bufferp buffer)
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
200 (setq buffer-name (buffer-name buffer)))
12126
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
201 ((numberp buffer)
0b0b0c2e5254 (rlogin): If optional second arg is buffer or string, use that as name.
Roland McGrath <roland@gnu.org>
parents: 11805
diff changeset
202 (setq buffer-name (format "%s<%d>" buffer-name buffer)))
11274
57b244b67848 (rlogin): Use format, not concat, to generate numeric buffer names.
Noah Friedman <friedman@splode.com>
parents: 10977
diff changeset
203 (t
57b244b67848 (rlogin): Use format, not concat, to generate numeric buffer names.
Noah Friedman <friedman@splode.com>
parents: 10977
diff changeset
204 (setq buffer-name (generate-new-buffer-name buffer-name))))
57b244b67848 (rlogin): Use format, not concat, to generate numeric buffer names.
Noah Friedman <friedman@splode.com>
parents: 10977
diff changeset
205
13310
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
206 (setq buffer (get-buffer-create buffer-name))
11274
57b244b67848 (rlogin): Use format, not concat, to generate numeric buffer names.
Noah Friedman <friedman@splode.com>
parents: 10977
diff changeset
207 (pop-to-buffer buffer-name)
13310
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
208
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
209 (cond
11274
57b244b67848 (rlogin): Use format, not concat, to generate numeric buffer names.
Noah Friedman <friedman@splode.com>
parents: 10977
diff changeset
210 ((comint-check-proc buffer-name))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
211 (t
13310
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
212 (comint-exec buffer buffer-name rlogin-program nil args)
5280c707658e (rlogin): If `buffer' arg is a buffer object, initialize buffer-name to the
Noah Friedman <friedman@splode.com>
parents: 12126
diff changeset
213 (setq proc (get-buffer-process buffer))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
214 ;; Set process-mark to point-max in case there is text in the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
215 ;; buffer from a previous exited process.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
216 (set-marker (process-mark proc) (point-max))
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
217
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
218 ;; comint-output-filter-functions is just like a hook, except that the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
219 ;; functions in that list are passed arguments. add-hook serves well
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
220 ;; enough for modifying it.
15465
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
221 ;; comint-output-filter-functions should already have a
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
222 ;; permanent-local property, at least in emacs 19.27 or later.
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
223 (if (fboundp 'make-local-hook)
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
224 (make-local-hook 'comint-output-filter-functions)
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
225 (make-local-variable 'comint-output-filter-functions))
15490
1fe754bafbcb (rlogin): add rlogin-carriage-filter to comint-output-filter-functions, not
Noah Friedman <friedman@splode.com>
parents: 15465
diff changeset
226 (add-hook 'comint-output-filter-functions 'rlogin-carriage-filter)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
227
15182
cab8ffe3a3b7 (rlogin): Call rlogin-mode after adding rlogin-carriage-filter to output
Noah Friedman <friedman@splode.com>
parents: 14169
diff changeset
228 (rlogin-mode)
cab8ffe3a3b7 (rlogin): Call rlogin-mode after adding rlogin-carriage-filter to output
Noah Friedman <friedman@splode.com>
parents: 14169
diff changeset
229
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
230 (make-local-variable 'rlogin-host)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
231 (setq rlogin-host host)
10384
1d0a7f841ffb rlogin-tab-or-complete: insert tab in buffer, don't send directly to process.
Noah Friedman <friedman@splode.com>
parents: 10374
diff changeset
232 (make-local-variable 'rlogin-remote-user)
1d0a7f841ffb rlogin-tab-or-complete: insert tab in buffer, don't send directly to process.
Noah Friedman <friedman@splode.com>
parents: 10374
diff changeset
233 (setq rlogin-remote-user user)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
234
15465
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
235 (condition-case ()
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
236 (cond ((eq rlogin-directory-tracking-mode t)
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
237 ;; Do this here, rather than calling the tracking mode
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
238 ;; function, to avoid a gratuitous resync check; the default
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
239 ;; should be the user's home directory, be it local or remote.
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
240 (setq comint-file-name-prefix
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
241 (concat "/" rlogin-remote-user "@" rlogin-host ":"))
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
242 (cd-absolute comint-file-name-prefix))
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
243 ((null rlogin-directory-tracking-mode))
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
244 (t
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
245 (cd-absolute (concat comint-file-name-prefix "~/"))))
d2efb8b0d453 (rlogin): make comint-output-filter-functions local before adding hooks.
Noah Friedman <friedman@splode.com>
parents: 15436
diff changeset
246 (error nil))))))
10130
2fb93cbc2d87 (rlogin-initially-track-cwd): Now a 3-way flag.
Richard M. Stallman <rms@gnu.org>
parents: 9250
diff changeset
247
17647
e99589f5ddd7 (rlogin-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17472
diff changeset
248 (put 'rlogin-mode 'mode-class 'special)
e99589f5ddd7 (rlogin-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17472
diff changeset
249
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250 (defun rlogin-mode ()
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
251 "Set major-mode for rlogin sessions.
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
252 If `rlogin-mode-hook' is set, run it."
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
253 (interactive)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
254 (kill-all-local-variables)
4678
cd842296bebf (rlogin): After rlogin-mode, set comint-filename-prefix locally to indicate
Roland McGrath <roland@gnu.org>
parents: 2948
diff changeset
255 (shell-mode)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
256 (setq major-mode 'rlogin-mode)
2404
845db675b3e9 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2387
diff changeset
257 (setq mode-name "rlogin")
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
258 (use-local-map rlogin-mode-map)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
259 (setq shell-dirtrackp rlogin-directory-tracking-mode)
4874
20154e6389eb (rlogin, rlogin-mode): Use comint-file-name-prefix,
Richard M. Stallman <rms@gnu.org>
parents: 4856
diff changeset
260 (make-local-variable 'comint-file-name-prefix)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
261 (run-hooks 'rlogin-mode-hook))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
262
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
263 (defun rlogin-directory-tracking-mode (&optional prefix)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
264 "Do remote or local directory tracking, or disable entirely.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
265
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
266 If called with no prefix argument or a unspecified prefix argument (just
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
267 ``\\[universal-argument]'' with no number) do remote directory tracking via
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
268 ange-ftp. If called as a function, give it no argument.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
269
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
270 If called with a negative prefix argument, disable directory tracking
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
271 entirely.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
272
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
273 If called with a positive, numeric prefix argument, e.g.
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
274 ``\\[universal-argument] 1 M-x rlogin-directory-tracking-mode\'',
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
275 then do directory tracking but assume the remote filesystem is the same as
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
276 the local system. This only works in general if the remote machine and the
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
277 local one share the same directories (through NFS)."
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
278 (interactive "P")
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
279 (cond
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
280 ((or (null prefix)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
281 (consp prefix))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
282 (setq rlogin-directory-tracking-mode t)
11276
7b78e66e6e3d (rlogin-directory-tracking-mode): Set shell-dirtrackp, not shell-dirtrack-p.
Noah Friedman <friedman@splode.com>
parents: 11274
diff changeset
283 (setq shell-dirtrackp t)
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
284 (setq comint-file-name-prefix
10384
1d0a7f841ffb rlogin-tab-or-complete: insert tab in buffer, don't send directly to process.
Noah Friedman <friedman@splode.com>
parents: 10374
diff changeset
285 (concat "/" rlogin-remote-user "@" rlogin-host ":")))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
286 ((< prefix 0)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
287 (setq rlogin-directory-tracking-mode nil)
11276
7b78e66e6e3d (rlogin-directory-tracking-mode): Set shell-dirtrackp, not shell-dirtrack-p.
Noah Friedman <friedman@splode.com>
parents: 11274
diff changeset
288 (setq shell-dirtrackp nil))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
289 (t
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
290 (setq rlogin-directory-tracking-mode 'local)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
291 (setq comint-file-name-prefix "")
11276
7b78e66e6e3d (rlogin-directory-tracking-mode): Set shell-dirtrackp, not shell-dirtrack-p.
Noah Friedman <friedman@splode.com>
parents: 11274
diff changeset
292 (setq shell-dirtrackp t)))
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
293 (cond
11276
7b78e66e6e3d (rlogin-directory-tracking-mode): Set shell-dirtrackp, not shell-dirtrack-p.
Noah Friedman <friedman@splode.com>
parents: 11274
diff changeset
294 (shell-dirtrackp
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
295 (let* ((proc (get-buffer-process (current-buffer)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
296 (proc-mark (process-mark proc))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
297 (current-input (buffer-substring proc-mark (point-max)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
298 (orig-point (point))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
299 (offset (and (>= orig-point proc-mark)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
300 (- (point-max) orig-point))))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
301 (unwind-protect
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
302 (progn
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
303 (delete-region proc-mark (point-max))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
304 (goto-char (point-max))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
305 (shell-resync-dirs))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
306 (goto-char proc-mark)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
307 (insert current-input)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
308 (if offset
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
309 (goto-char (- (point-max) offset))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
310 (goto-char orig-point)))))))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
311
2539
577c77cfd199 *** empty log message ***
Noah Friedman <friedman@splode.com>
parents: 2405
diff changeset
312
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
313 ;; Parse a line into its constituent parts (words separated by
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
314 ;; whitespace). Return a list of the words.
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
315 (defun rlogin-parse-words (line)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
316 (let ((list nil)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
317 (posn 0)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
318 (match-data (match-data)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
319 (while (string-match "[^ \t\n]+" line posn)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
320 (setq list (cons (substring line (match-beginning 0) (match-end 0))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
321 list))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
322 (setq posn (match-end 0)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
323 (store-match-data (match-data))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
324 (nreverse list)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
325
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
326 (defun rlogin-carriage-filter (string)
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
327 (let* ((point-marker (point-marker))
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
328 (end (process-mark (get-buffer-process (current-buffer))))
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
329 (beg (or (and (boundp 'comint-last-output-start)
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
330 comint-last-output-start)
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
331 (- end (length string)))))
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
332 (goto-char beg)
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
333 (while (search-forward "\C-m" end t)
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
334 (delete-char -1))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
335 (goto-char point-marker)))
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
336
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
337 (defun rlogin-send-Ctrl-C ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
338 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
339 (send-string nil "\C-c"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
340
5792
242985a124fc Removed many extra autoload cookies.
Roland McGrath <roland@gnu.org>
parents: 5208
diff changeset
341 (defun rlogin-send-Ctrl-D ()
242985a124fc Removed many extra autoload cookies.
Roland McGrath <roland@gnu.org>
parents: 5208
diff changeset
342 (interactive)
242985a124fc Removed many extra autoload cookies.
Roland McGrath <roland@gnu.org>
parents: 5208
diff changeset
343 (send-string nil "\C-d"))
242985a124fc Removed many extra autoload cookies.
Roland McGrath <roland@gnu.org>
parents: 5208
diff changeset
344
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
345 (defun rlogin-send-Ctrl-Z ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
347 (send-string nil "\C-z"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 (defun rlogin-send-Ctrl-backslash ()
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350 (interactive)
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351 (send-string nil "\C-\\"))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
352
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 (defun rlogin-delchar-or-send-Ctrl-D (arg)
5793
85abf27f701f (rlogin-delchar-or-send-Ctrl-D): Call rlogin-send-Ctrl-D. Doc fix.
Roland McGrath <roland@gnu.org>
parents: 5792
diff changeset
354 "\
10849
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
355 Delete ARG characters forward, or send a C-d to process if at end of buffer."
eb6af491e98f (rlogin-carriage-filter): Don't assume region is narrowed to most recent
Noah Friedman <friedman@splode.com>
parents: 10384
diff changeset
356 (interactive "p")
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
357 (if (eobp)
5793
85abf27f701f (rlogin-delchar-or-send-Ctrl-D): Call rlogin-send-Ctrl-D. Doc fix.
Roland McGrath <roland@gnu.org>
parents: 5792
diff changeset
358 (rlogin-send-Ctrl-D)
2231
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
359 (delete-char arg)))
1c7ad2a0f4d9 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
360
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
361 (defun rlogin-tab-or-complete ()
10384
1d0a7f841ffb rlogin-tab-or-complete: insert tab in buffer, don't send directly to process.
Noah Friedman <friedman@splode.com>
parents: 10374
diff changeset
362 "Complete file name if doing directory tracking, or just insert TAB."
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
363 (interactive)
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
364 (if rlogin-directory-tracking-mode
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
365 (comint-dynamic-complete)
10384
1d0a7f841ffb rlogin-tab-or-complete: insert tab in buffer, don't send directly to process.
Noah Friedman <friedman@splode.com>
parents: 10374
diff changeset
366 (insert "\C-i")))
10374
d6de68b87cbd Removed several more gratuitous autoload cookies.
Noah Friedman <friedman@splode.com>
parents: 10130
diff changeset
367
18419
9880156cf5b6 Provide 'rlogin.
Noah Friedman <friedman@splode.com>
parents: 17647
diff changeset
368 (provide 'rlogin)
9880156cf5b6 Provide 'rlogin.
Noah Friedman <friedman@splode.com>
parents: 17647
diff changeset
369
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2231
diff changeset
370 ;;; rlogin.el ends here