[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 25/117: Add command prompt here and powershell here
From: |
Matthew Fidler |
Subject: |
[elpa] 25/117: Add command prompt here and powershell here |
Date: |
Fri, 25 Jul 2014 13:23:58 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit af8eb10de86f04a11d70a256c583b2e00114bede
Author: Matthew L. Fidler <address@hidden>
Date: Wed Jul 16 10:18:50 2014 -0500
Add command prompt here and powershell here
---
ergoemacs-functions.el | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
ergoemacs-menus.el | 6 ++++-
ergoemacs-mode.el | 1 -
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index 0fe26b7..53355b5 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -2126,6 +2126,57 @@ Guillemet -> quote, degree -> @, s-zed -> ss,
upside-down ?! -> ?!."
(insert (cdr sans-accent))
(backward-char))))
+;; Shell handling
+
+
+(defun ergoemacs-shell-here-directory-change-hook ()
+ "Renames buffer to reflect directory name."
+ (rename-buffer
+ (generate-new-buffer-name
+ (concat (replace-regexp-in-string "\\`\\(address@hidden).*\\'" "\\1"
(buffer-name) t)
+ (if (eq system-type 'windows-nt)
+ (w32-long-file-name default-directory) ;; Fix case issues
+ default-directory) "*"))))
+
+(add-hook 'dirtrack-directory-change-hook
'ergoemacs-shell-here-directory-change-hook)
+
+(defun ergoemacs-shell-here-hook ()
+ "Hook for `ergoemacs-shell-here'.
+Sends shell prompt string to process, then turns on
+`dirtrack-mode' as well as add rename buffer filter when the directory has
been changed."
+ (when (string-match "address@hidden" (buffer-name))
+ (let ((shell (or (and (boundp 'explicit-shell-file-name)
explicit-shell-file-name)
+ (getenv "ESHELL") shell-file-name))
+ (proc (get-buffer-process (current-buffer))))
+ (require 'dirtrack)
+ (cond
+ ((string-match "cmd\\(proxy\\)?.exe" shell)
+ (set (make-local-variable 'dirtrack-list) (list "^\\([a-zA-Z]:.*\\)>"
1))
+ (shell-dirtrack-mode -1)
+ (dirtrack-mode 1))
+ ((string-match "powershell.exe" shell)
+ (set (make-local-variable 'dirtrack-list) (list "^PS
\\([a-zA-Z]:.*\\)>" 1))
+ (shell-dirtrack-mode -1)
+ (dirtrack-mode 1))))))
+
+(add-hook 'shell-mode-hook 'ergoemacs-shell-here-hook)
+
+(defun ergoemacs-shell-here (&optional shell-program buffer-prefix)
+ "Runs a shell process in the current directory, or switches to a shell in
the current directory."
+ (interactive)
+ (let* ((shell (or shell-program 'shell))
+ (buf-prefix (or buffer-prefix (symbol-name shell)))
+ (name (concat "*" buf-prefix "@" default-directory "*")))
+ (set-buffer (get-buffer-create name))
+ (funcall shell name)))
+
+(defun ergoemacs-powershell-here ()
+ "Runs PowerShell Here"
+ (interactive)
+ (if (not (fboundp 'powershell))
+ (error "Requires powershell package to run PowerShell.")
+ (ergoemacs-shell-here 'powershell "PowerShell")))
+
;;; Ergoemacs lookup words. from lookup-word-on-internet.el
diff --git a/ergoemacs-menus.el b/ergoemacs-menus.el
index fef7321..1f77b19 100644
--- a/ergoemacs-menus.el
+++ b/ergoemacs-menus.el
@@ -261,7 +261,11 @@ All other modes are assumed to be minor modes or
unimportant.
((eq system-type 'windows-nt) "In
Explorer")
((eq system-type 'darwin) "In
Finder")
(t "In File Manager"))
- ergoemacs-open-in-desktop)))
+ ergoemacs-open-in-desktop)
+ (sep1 menu-item "--")
+ (open-shell-here menu-item ,(if (eq system-type
'windows-nt) "In Command Prompt" "In Shell") ergoemacs-shell-here)
+ ,(if (eq system-type 'windows-nt)
'(powershell-here menu-item "In PowerShell" ergoemacs-powershell-here :enable
(fboundp 'powershell)))
+ ))
;; FIXME -- Somehow put open last closed in recentf menu; It
;; seems to fit there the best
;; (open-last-closed menu-item "Open last closed"
ergoemacs-open-last-closed)
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index 60bb345..9e5845b 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -539,7 +539,6 @@ These hooks are deferred to make sure `this-command' is set
appropriately.")
(ergoemacs-reset-global-where-is))
-
;;; Frequently used commands as aliases
(defcustom ergoemacs-use-aliases t
- [elpa] 06/117: Lexical binding for ergoemacs-layouts., (continued)
- [elpa] 06/117: Lexical binding for ergoemacs-layouts., Matthew Fidler, 2014/07/25
- [elpa] 18/117: Use save-match-data with ergoemacs-pretty-key, Matthew Fidler, 2014/07/25
- [elpa] 13/117: Remove pop dependence, Matthew Fidler, 2014/07/25
- [elpa] 17/117: Add rudimentary guide-key support; F1/C-h activates guide-key, Matthew Fidler, 2014/07/25
- [elpa] 14/117: Attempt Lexical Scoping for ergoemacs-translate.el, Matthew Fidler, 2014/07/25
- [elpa] 20/117: Add left/right to pretty key descriptions, Matthew Fidler, 2014/07/25
- [elpa] 19/117: Pretty key cleanup, Matthew Fidler, 2014/07/25
- [elpa] 22/117: Fix guide-key-mode requirement, Matthew Fidler, 2014/07/25
- [elpa] 24/117: Comment ergoemacs-substitute-command-keys, Matthew Fidler, 2014/07/25
- [elpa] 21/117: Better guide-key support, Matthew Fidler, 2014/07/25
- [elpa] 25/117: Add command prompt here and powershell here,
Matthew Fidler <=
- [elpa] 23/117: Fix (substitute-command-keys "\\[recover-session]"), Matthew Fidler, 2014/07/25
- [elpa] 27/117: Fix recursive loading in ergoemacs-mode source, Matthew Fidler, 2014/07/25
- [elpa] 30/117: Declare w32-long-file-name, Matthew Fidler, 2014/07/25
- [elpa] 29/117: Cleanup byte compile, Matthew Fidler, 2014/07/25
- [elpa] 31/117: More emcompassing shell prompt regexp, Matthew Fidler, 2014/07/25
- [elpa] 26/117: Fix load dependence, See Issue #232, Matthew Fidler, 2014/07/25
- [elpa] 33/117: Added space as separtor for PS1 prompt, Matthew Fidler, 2014/07/25
- [elpa] 35/117: Remap shell to ergoemacs-shell-here, Matthew Fidler, 2014/07/25
- [elpa] 28/117: Add unix shell support, Matthew Fidler, 2014/07/25
- [elpa] 36/117: Add eshell here and powershell key, Matthew Fidler, 2014/07/25