all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jason Kim <jason.kim@revtera.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Eli Zaretskii <eliz@gnu.org>, Jason Kim <jason.w.kim@icloud.com>,
	shivers@cs.cmu.edu, emacs-devel@gnu.org
Subject: Re: Small shell-mode patch to handle auto-cd (e.g. shells like zsh)
Date: Thu, 27 May 2021 10:09:25 -0700	[thread overview]
Message-ID: <50594491-8781-dee6-4a7e-544a1eeb7a3e@revtera.com> (raw)
In-Reply-To: <874kerntyl.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

Woops is all I can say.
After reading the CONTRIBUTE more carefully (and trying out git am 
locally and comparing to existing commit logs, I think I finally get it :-)

Profuse apologies for wasted bandwidth.
Updated :version to 28.1 as requested, and now I believe the commit log 
is finally up to snuff.

Thanks again!



On 5/25/21 12:38 AM, Michael Albinus wrote:
> Jason Kim <jason.kim@revtera.com> writes:
> 
> Hi Jason,
> 
>>  From bbdd6f2665c70e15ccc23f48d664eb6e20df7fa6 Mon Sep 17 00:00:00 2001
>> From: Jason Kim <jason.kim@revtera.com>
>> Date: Mon, 24 May 2021 10:04:54 -0700
>> Subject: [PATCH] Auto-cd support for lisp/shell.el
>>
>> Added a new defcustom shell-has-auto-cd (default: nil) for
>> users with shells like zsh that can auto-cd into a directory
>> without typing in the "cd" command.
>> If set to true and the command is a directory, then
>> shell-directory-tracker processes the command (which happens to be a
>> directory) as if it were prepended with "cd"
> 
> FTR, the commit message shall have a ChangeLog style.
> 
>> +(defcustom shell-has-auto-cd nil
>> +  "If non-nil, `shell-mode' handles implicit \"cd\" commands.
>> +Implicit \"cd\" is changing the directory if the command is a directory.
>> +You can make this variable buffer-local to change it, per shell-mode instance
>> +Useful for shells like zsh that has this feature."
>> +  :type 'boolean
>> +  :group 'shell-directories
>> +  :version "28")
> 
> This should be "28.1".
> 
>> Thanks!
>> -Jason
> 
> Best regards, Michael.
> 

[-- Attachment #2: 0001-Auto-cd-support-for-shells-like-zsh.patch --]
[-- Type: text/x-patch, Size: 2518 bytes --]

From 178d645a572a4a8a495930348ba07aea134b8617 Mon Sep 17 00:00:00 2001
From: Jason Kim <jason.kim@revtera.com>
Date: Mon, 24 May 2021 10:04:54 -0700
Subject: [PATCH] Auto-cd support for shells like zsh

Added a new defcustom shell-has-auto-cd (default: nil)
For shells like zsh that can auto-cd into a directory
without typing in the "cd" command, this change adds
completion support for directory contents.

* lisp/shell.el (shell-directory-tracker): handle implict "cd"
---
 lisp/shell.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lisp/shell.el b/lisp/shell.el
index 3098d3a14d..49725f7310 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -321,6 +321,16 @@ shell-last-dir
 (defvar shell-dirstack-query nil
   "Command used by `shell-resync-dirs' to query the shell.")
 
+(defcustom shell-has-auto-cd nil
+  "If non-nil, `shell-mode' handles implicit \"cd\" commands.
+Implicit \"cd\" is changing the directory if the command is a directory.
+You can make this variable buffer-local to change it, per shell-mode instance
+Useful for shells like zsh that has this feature."
+  :type 'boolean
+  :group 'shell-directories
+  :version "28.1")
+
+
 (defvar shell-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-f" 'shell-forward-command)
@@ -836,13 +846,15 @@ shell-directory-tracker
 			       str) ; skip whitespace
 			      (match-end 0)))
 		(case-fold-search)
-		end cmd arg1)
+		end cmd arg1 cmd-subst-fn)
 	    (while (string-match shell-command-regexp str start)
 	      (setq end (match-end 0)
 		    cmd (comint-arguments (substring str start end) 0 0)
 		    arg1 (comint-arguments (substring str start end) 1 1))
 	      (if arg1
 		  (setq arg1 (shell-unquote-argument arg1)))
+              (if shell-has-auto-cd
+                  (setq cmd-subst-fn (comint-substitute-in-file-name cmd)))
 	      (cond ((string-match (concat "\\`\\(" shell-popd-regexp
 					   "\\)\\($\\|[ \t]\\)")
 				   cmd)
@@ -859,7 +871,9 @@ shell-directory-tracker
 			  (string-match (concat "\\`\\(" shell-chdrive-regexp
 						"\\)\\($\\|[ \t]\\)")
 					cmd))
-		     (shell-process-cd (comint-substitute-in-file-name cmd))))
+		     (shell-process-cd (comint-substitute-in-file-name cmd)))
+                    ((and shell-has-auto-cd (file-directory-p cmd-subst-fn))
+                     (shell-process-cd cmd-subst-fn)))
 	      (setq start (progn (string-match shell-command-separator-regexp
 					       str end)
 				 ;; skip again
-- 
2.25.1


  reply	other threads:[~2021-05-27 17:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 19:55 Small shell-mode patch to handle auto-cd (e.g. shells like zsh) Jason Kim
2021-05-06  8:10 ` Michael Albinus
2021-05-06  8:23 ` Eli Zaretskii
2021-05-07 16:35   ` Jason Kim
2021-05-07 16:51     ` Jason Kim
2021-05-15  8:20       ` Eli Zaretskii
2021-05-24 17:15         ` Jason Kim
2021-05-24 17:20           ` Jason Kim
2021-05-25  7:38             ` Michael Albinus
2021-05-27 17:09               ` Jason Kim [this message]
2021-06-09 11:03                 ` Michael Albinus
2021-05-07 17:39     ` Michael Albinus
2021-05-08  6:36     ` Eli Zaretskii
2021-05-08 16:39       ` Jason Kim
2021-05-08 16:48         ` Eli Zaretskii
2021-05-08 17:19           ` Jason Kim
2021-05-08 17:58             ` Jason Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50594491-8781-dee6-4a7e-544a1eeb7a3e@revtera.com \
    --to=jason.kim@revtera.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jason.w.kim@icloud.com \
    --cc=michael.albinus@gmx.de \
    --cc=shivers@cs.cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.