;; merge them into the master source.
;; - Per Bothner (bothner@cygnus.com)
-;; This file defines a general command-interpreter-in-a-buffer package
-;; (term mode). The idea is that you can build specific process-in-a-buffer
-;; modes on top of term mode -- e.g., lisp, shell, scheme, T, soar, ....
-;; This way, all these specific packages share a common base functionality,
-;; and a common set of bindings, which makes them easier to use (and
-;; saves code, implementation time, etc., etc.).
-
-;; For hints on converting existing process modes (e.g., tex-mode,
-;; background, dbx, gdb, kermit, prolog, telnet) to use term-mode
-;; instead of shell-mode, see the notes at the end of this file.
-
\f
;; Brief Command Documentation:
;;============================================================================
(defvar term-pager-count nil
"Number of lines before we need to page; if nil, paging is disabled.")
(defvar term-saved-cursor nil)
-(defvar term-command-hook)
+(define-obsolete-variable-alias 'term-command-hook
+ 'term-command-function "27.1")
+(defvar term-command-function #'term-command-hook)
(defvar term-log-buffer nil)
(defvar term-scroll-with-delete nil
"If t, forward scrolling should be implemented by delete to
:type 'boolean
:group 'term)
(make-obsolete-variable 'term-suppress-hard-newline nil
- "27.1"
- 'set)
+ "27.1")
;; Where gud-display-frame should put the debugging arrow. This is
;; set by the marker-filter, which scans the debugger's output for
This variable is buffer-local.")
-(defvar term-input-sender (function term-simple-send)
+(defvar term-input-sender #'term-simple-send
"Function to actually send to PROCESS the STRING submitted by user.
Usually this is just `term-simple-send', but if your mode needs to
massage the input string, this is your hook. This is called from
(set (make-local-variable 'term-last-input-start) (make-marker))
(set (make-local-variable 'term-last-input-end) (make-marker))
(set (make-local-variable 'term-last-input-match) "")
- (set (make-local-variable 'term-command-hook)
- (symbol-function 'term-command-hook))
;; These local variables are set to their local values:
(make-local-variable 'term-saved-home-marker)
(make-local-variable 'term-pager-old-local-map)
(make-local-variable 'term-old-mode-map)
(make-local-variable 'term-insert-mode)
- (make-local-variable 'term-dynamic-complete-functions)
(make-local-variable 'term-completion-fignore)
(make-local-variable 'term-get-old-input)
(make-local-variable 'term-matching-input-from-input-string)
(make-local-variable 'term-input-autoexpand)
(make-local-variable 'term-input-ignoredups)
(make-local-variable 'term-delimiter-argument-list)
- (make-local-variable 'term-input-filter-functions)
(make-local-variable 'term-input-filter)
(make-local-variable 'term-input-sender)
(make-local-variable 'term-eol-on-send)
(make-local-variable 'term-scroll-to-bottom-on-output)
(make-local-variable 'term-scroll-show-maximum-output)
(make-local-variable 'term-ptyp)
- (make-local-variable 'term-exec-hook)
(set (make-local-variable 'term-vertical-motion) 'vertical-motion)
(set (make-local-variable 'term-pending-delete-marker) (make-marker))
(make-local-variable 'term-current-face)
(while (setq fake-newline (next-single-property-change (point)
'term-line-wrap))
(goto-char fake-newline)
- (assert (eq ?\n (char-after)))
+ (cl-assert (eq ?\n (char-after)))
(let ((inhibit-read-only t))
(delete-char 1)))))
(add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t)
;; Send existing partial line to inferior (without newline).
- (let ((pmark (process-mark (get-buffer-process (current-buffer))))
- (save-input-sender term-input-sender))
+ (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
(when (> (point) pmark)
(unwind-protect
(progn
- (setq term-input-sender
- (symbol-function 'term-send-string))
+ (add-function :override term-input-sender #'term-send-string)
(end-of-line)
(term-send-input))
- (setq term-input-sender save-input-sender))))
+ (remove-function term-input-sender #'term-send-string))))
(term-update-mode-line)))
(defun term-line-mode ()
;; Jump to the end, and set the process mark.
(goto-char (point-max))
(set-marker (process-mark proc) (point))
- (set-process-filter proc 'term-emulate-terminal)
- (set-process-sentinel proc 'term-sentinel)
+ (set-process-filter proc #'term-emulate-terminal)
+ (set-process-sentinel proc #'term-sentinel)
;; Feed it the startfile.
(when startfile
;;This is guaranteed to wait long enough
(when (term--bash-needs-EMACSp)
(push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
process-environment))
- (apply 'start-process name buffer
+ (apply #'start-process name buffer
"/bin/sh" "-c"
(format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
if [ $1 = .. ]; then shift; fi; exec \"$@\""
(let ((n (or nth (1- count)))
(m (if mth (1- (- count mth)) 0)))
(mapconcat
- (function (lambda (a) a)) (nthcdr n (nreverse (nthcdr m args))) " "))))
+ #'identity (nthcdr n (nreverse (nthcdr m args))) " "))))
\f
;;;
;;; Input processing stuff [line mode]
(not (string-equal (ring-ref term-input-ring 0)
history))))
(ring-insert term-input-ring history))
- (let ((functions term-input-filter-functions))
- (while functions
- (funcall (car functions) (concat input "\n"))
- (setq functions (cdr functions))))
+ (run-hook-with-args 'term-input-filter-functions (concat input "\n"))
(setq term-input-ring-index nil)
;; Update the markers before we send the input
(?\C-g ;; (terminfo: bel)
(beep t))
(?\032 ; Emacs specific control sequence.
- (funcall term-command-hook
+ (funcall term-command-function
(decode-coding-string
(substring str (1+ i)
(- ctl-end
(setq term-terminal-undecoded-bytes (substring str (1- i)))
(aset term-terminal-undecoded-bytes 0 ?\r))
(goto-char (point-max)))
+ ;; FIXME: Use (add-function :override (process-filter proc)
(make-local-variable 'term-pager-old-filter)
(setq term-pager-old-filter (process-filter proc))
+ ;; FIXME: Where is `term-pager-filter' set to a function?!
(set-process-filter proc term-pager-filter)
(setq i str-length))
(setq i ctl-end)))))
;; (setq term-current-row 0)
;; (term-goto row col))))
-;; Default value for the symbol term-command-hook.
+;; Default value for the symbol term-command-function.
(defun term-command-hook (string)
(cond ((equal string "")
completion until a function returns non-nil, at which point completion is
assumed to have occurred."
(interactive)
- (let ((functions term-dynamic-complete-functions))
- (while (and functions (null (funcall (car functions))))
- (setq functions (cdr functions)))))
+ (run-hook-with-args-until-success 'term-dynamic-complete-functions))
(defun term-dynamic-complete-filename ()
See also `term-dynamic-complete-filename'."
(declare (obsolete completion-in-region "23.2"))
(let* ((completion-ignore-case nil)
- (candidates (mapcar (function (lambda (x) (list x))) candidates))
(completions (all-completions stub candidates)))
(cond ((null completions)
(message "No completions of %s" stub)
(setq serial-name-history file-name-history))
(when (or (null x) (and (stringp x) (zerop (length x))))
(error "No serial port selected"))
- (when (and (not (serial-port-is-file-p))
- (not (string-match "\\\\" x)))
- (set 'x (concat "\\\\.\\" x)))
+ (when (not (or (serial-port-is-file-p)
+ (string-match "\\\\" x)))
+ (setq x (concat "\\\\.\\" x)))
x))
(defun serial-read-speed ()
(term-char-mode)
(goto-char (point-max))
(set-marker (process-mark process) (point))
- (set-process-filter process 'term-emulate-terminal)
- (set-process-sentinel process 'term-sentinel))
+ (set-process-filter process #'term-emulate-terminal)
+ (set-process-sentinel process #'term-sentinel))
(switch-to-buffer buffer)
buffer))
;; term-mode will take care of it. The following example, from shell.el,
;; is typical:
;;
-;; (defvar shell-mode-map '())
-;; (cond ((not shell-mode-map)
-;; (setq shell-mode-map (copy-keymap term-mode-map))
-;; (define-key shell-mode-map "\C-c\C-f" 'shell-forward-command)
-;; (define-key shell-mode-map "\C-c\C-b" 'shell-backward-command)
-;; (define-key shell-mode-map "\t" 'term-dynamic-complete)
-;; (define-key shell-mode-map "\M-?"
-;; 'term-dynamic-list-filename-completions)))
-;;
-;; (defun shell-mode ()
-;; (interactive)
-;; (term-mode)
-;; (setq term-prompt-regexp shell-prompt-pattern)
-;; (setq major-mode 'shell-mode)
-;; (setq mode-name "Shell")
-;; (use-local-map shell-mode-map)
-;; (make-local-variable 'shell-directory-stack)
-;; (setq shell-directory-stack nil)
-;; (add-hook 'term-input-filter-functions 'shell-directory-tracker)
-;; (run-mode-hooks 'shell-mode-hook))
+;; (defvar shell-mode-map
+;; (let ((map (make-sparse-keymap)))
+;; (define-key map "\C-c\C-f" 'shell-forward-command)
+;; (define-key map "\C-c\C-b" 'shell-backward-command)
+;; (define-key map "\t" 'term-dynamic-complete)
+;; (define-key map "\M-?"
+;; 'term-dynamic-list-filename-completions)))
;;
+;; (define-derived-mode shell-mode term-mode "Shell"
+;; "A shell mode."
+;; (setq-local term-prompt-regexp shell-prompt-pattern)
+;; (setq-local shell-directory-stack nil)
+;; (add-hook 'term-input-filter-functions #'shell-directory-tracker nil t))
;;
;; Completion for term-mode users
;;