X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/068922a2973033ea826b458a17f3e06cf6b44299..35e1f9d9fcbaab51808e05f514e63927f959ae51:/lisp/eshell/em-term.el diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index f30aad305e..4a8f368879 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el @@ -1,6 +1,6 @@ -;;; 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 @@ -62,13 +62,19 @@ which commands are considered visual in nature." "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 ...)) @@ -78,7 +84,9 @@ visual fashion. A likely entry is (\"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" @@ -97,7 +105,9 @@ fashion. For example, a sensible entry would be (\"git\" \"--help\") because \"git --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" @@ -132,18 +142,23 @@ character to the invoked process." "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 @@ -174,7 +189,8 @@ allowed." (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)