|
From: | Kevin Rodgers |
Subject: | Re: Inject some eshell features into shell? |
Date: | Fri, 17 Oct 2003 13:31:20 -0600 |
User-agent: | Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2 |
Kai Grossjohann wrote:
So maybe it would be nifty if one could somehow hook a function into the RET key in shell-mode that looks if it recognizes the command on the current line. If so, it invokes a given Lisp function, depending on the command. That way, I could get the "vi foo.c" back. Other candidates would be "man" and "less", I guess.
Here's a start. It's main deficiency is that it only works for commands that take zero or one argument: (defun shell-maybe-send (process command) "Maybe send the shell PROCESS the COMMAND string. But if COMMAND can be interpreted as an Emacs command (e.g. \"find-file foo.c\"), evaluate it instead." (with-syntax-table emacs-lisp-mode-syntax-table (let* ((command-name (and (string-match "\\`\\(\\(\\sw\\|\\s_\\)+\\)\\s *" command) (match-string 1 command))) (command-symbol (and command-name (intern-soft command-name)))) (if (and command-symbol (commandp command-symbol)) (if (= (match-end 0) (length command)) (funcall command-symbol) (funcall command-symbol (substring command (match-end 0)))) (comint-simple-send process command))))) (add-hook 'shell-mode-hook (lambda () (setq comint-input-sender 'shell-maybe-send))) -- Kevin Rodgers
[Prev in Thread] | Current Thread | [Next in Thread] |