emacs-elpa-diffs
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]