-;;; em-term.el --- running visual commands
+;;; em-term.el --- running visual commands -*- lexical-binding:t -*-
-;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
"less" "more" ; M-x view-file
"lynx" "ncftp" ; w3.el, ange-ftp
"pine" "tin" "trn" "elm") ; GNUS!!
- "A list of commands that present their output in a visual fashion."
+ "A list of commands that present their output in a visual fashion.
+
+Commands listed here are run in a term buffer.
+
+See also `eshell-visual-subcommands' and `eshell-visual-options'."
:type '(repeat string)
:group 'eshell-term)
(defcustom eshell-visual-subcommands
nil
- "An alist of the form
+ "An alist of subcommands that present their output in a visual fashion.
+
+An alist of the form
((COMMAND1 SUBCOMMAND1 SUBCOMMAND2...)
(COMMAND2 SUBCOMMAND1 ...))
(\"git\" \"log\" \"diff\" \"show\")
-because git shows logs and diffs using a pager by default."
+because git shows logs and diffs using a pager by default.
+
+See also `eshell-visual-commands' and `eshell-visual-options'."
:type '(repeat (cons (string :tag "Command")
(repeat (string :tag "Subcommand"))))
:version "24.4"
(\"git\" \"--help\")
because \"git <command> --help\" shows the command's
-documentation with a pager."
+documentation with a pager.
+
+See also `eshell-visual-commands' and `eshell-visual-subcommands'."
:type '(repeat (cons (string :tag "Command")
(repeat (string :tag "Option"))))
:version "24.4"
"Initialize the `term' interface code."
(make-local-variable 'eshell-interpreter-alist)
(setq eshell-interpreter-alist
- (cons (cons (function
- (lambda (command args)
- (let ((command (file-name-nondirectory command)))
- (or (member command eshell-visual-commands)
- (member (car args)
- (cdr (assoc command eshell-visual-subcommands)))
- (cl-intersection args
- (cdr (assoc command eshell-visual-options))
- :test 'string=)))))
+ (cons (cons #'eshell-visual-command-p
'eshell-exec-visual)
eshell-interpreter-alist)))
+(defun eshell-visual-command-p (command args)
+ "Returns non-nil when given a visual command.
+If either COMMAND or a subcommand in ARGS (e.g. git log) is a
+visual command, returns non-nil."
+ (let ((command (file-name-nondirectory command)))
+ (and (eshell-interactive-output-p)
+ (or (member command eshell-visual-commands)
+ (member (car args)
+ (cdr (assoc command eshell-visual-subcommands)))
+ (cl-intersection args
+ (cdr (assoc command eshell-visual-options))
+ :test 'string=)))))
+
(defun eshell-exec-visual (&rest args)
"Run the specified PROGRAM in a terminal emulation buffer.
ARGS are passed to the program. At the moment, no piping of input is
(term-set-escape-char ?\C-x))))
nil)
-(defun eshell-term-sentinel (proc string)
+;; Process sentinels receive two arguments.
+(defun eshell-term-sentinel (proc _string)
"Destroy the buffer visiting PROC."
(let ((proc-buf (process-buffer proc)))
(when (and proc-buf (buffer-live-p proc-buf)