diff options
| author | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
| commit | f0f8d7b82492e741950c363a03b886965c91b1b0 (patch) | |
| tree | 19b716830b1ebabc0d7d75949c4e6800c0f104ad /lisp/shell.el | |
| parent | 9e64a087c4d167e7ec1c4e22bea3e6af53b563de (diff) | |
| parent | c818c29771d3cb51875643b2f6c894073e429dd2 (diff) | |
| download | emacs-feature/native-comp-macos-fixes.tar.gz emacs-feature/native-comp-macos-fixes.zip | |
Merge branch 'feature/native-comp' into feature/native-comp-macos-fixesfeature/native-comp-macos-fixes
Diffstat (limited to 'lisp/shell.el')
| -rw-r--r-- | lisp/shell.el | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index f5e18bbc728..9667dab2afd 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -990,9 +990,6 @@ this feature; see the function `dirtrack-mode'." | |||
| 990 | (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) | 990 | (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) |
| 991 | (remove-hook 'comint-input-filter-functions #'shell-directory-tracker t))) | 991 | (remove-hook 'comint-input-filter-functions #'shell-directory-tracker t))) |
| 992 | 992 | ||
| 993 | (define-obsolete-function-alias 'shell-dirtrack-toggle #'shell-dirtrack-mode | ||
| 994 | "23.1") | ||
| 995 | |||
| 996 | (defun shell-cd (dir) | 993 | (defun shell-cd (dir) |
| 997 | "Do normal `cd' to DIR, and set `list-buffers-directory'." | 994 | "Do normal `cd' to DIR, and set `list-buffers-directory'." |
| 998 | (cd dir) | 995 | (cd dir) |
| @@ -1038,25 +1035,41 @@ command again." | |||
| 1038 | (accept-process-output proc) | 1035 | (accept-process-output proc) |
| 1039 | (goto-char pt))) | 1036 | (goto-char pt))) |
| 1040 | (goto-char pmark) (delete-char 1) ; remove the extra newline | 1037 | (goto-char pmark) (delete-char 1) ; remove the extra newline |
| 1041 | ;; That's the dirlist. grab it & parse it. | 1038 | ;; That's the dirlist. Grab it & parse it. |
| 1042 | (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2)))) | 1039 | (let* ((dls (buffer-substring-no-properties |
| 1043 | (dl-len (length dl)) | 1040 | (match-beginning 0) (1- (match-end 0)))) |
| 1044 | (ds '()) ; new dir stack | 1041 | (dlsl nil) |
| 1045 | (i 0)) | 1042 | (pos 0) |
| 1046 | (while (< i dl-len) | 1043 | (ds nil)) |
| 1047 | ;; regexp = optional whitespace, (non-whitespace), optional whitespace | 1044 | ;; Split the dirlist into whitespace and non-whitespace chunks. |
| 1048 | (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir | 1045 | ;; dlsl will be a reversed list of tokens. |
| 1049 | (setq ds (cons (concat comint-file-name-prefix | 1046 | (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) |
| 1050 | (substring dl (match-beginning 1) | 1047 | (push (match-string 1 dls) dlsl) |
| 1051 | (match-end 1))) | 1048 | (setq pos (match-end 1))) |
| 1052 | ds)) | 1049 | |
| 1053 | (setq i (match-end 0))) | 1050 | ;; Prepend trailing entries until they form an existing directory, |
| 1054 | (let ((ds (nreverse ds))) | 1051 | ;; whitespace and all. Discard the next whitespace and repeat. |
| 1055 | (with-demoted-errors "Couldn't cd: %s" | 1052 | (while dlsl |
| 1056 | (shell-cd (car ds)) | 1053 | (let ((newelt "") |
| 1057 | (setq shell-dirstack (cdr ds) | 1054 | tem1 tem2) |
| 1058 | shell-last-dir (car shell-dirstack)) | 1055 | (while newelt |
| 1059 | (shell-dirstack-message))))) | 1056 | ;; We need tem1 because we don't want to prepend |
| 1057 | ;; `comint-file-name-prefix' repeatedly into newelt via tem2. | ||
| 1058 | (setq tem1 (pop dlsl) | ||
| 1059 | tem2 (concat comint-file-name-prefix tem1 newelt)) | ||
| 1060 | (cond ((file-directory-p tem2) | ||
| 1061 | (push tem2 ds) | ||
| 1062 | (when (string= " " (car dlsl)) | ||
| 1063 | (pop dlsl)) | ||
| 1064 | (setq newelt nil)) | ||
| 1065 | (t | ||
| 1066 | (setq newelt (concat tem1 newelt))))))) | ||
| 1067 | |||
| 1068 | (with-demoted-errors "Couldn't cd: %s" | ||
| 1069 | (shell-cd (car ds)) | ||
| 1070 | (setq shell-dirstack (cdr ds) | ||
| 1071 | shell-last-dir (car shell-dirstack)) | ||
| 1072 | (shell-dirstack-message)))) | ||
| 1060 | (if started-at-pmark (goto-char (marker-position pmark))))) | 1073 | (if started-at-pmark (goto-char (marker-position pmark))))) |
| 1061 | 1074 | ||
| 1062 | ;; For your typing convenience: | 1075 | ;; For your typing convenience: |