From eaeeece92da51b517097667f13d580aa92ad5d59 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 4 Dec 2018 12:39:47 -0500 Subject: [PATCH] * lisp/shell.el (shell--parse-pcomplete-arguments): Stop at semi-colon * test/lisp/shell-tests.el (shell-tests-completion-before-semi): New corresponding test. --- lisp/shell.el | 14 +++++++------- test/lisp/shell-tests.el | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index ac6f11aeb40..16aeffc1b61 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -426,7 +426,7 @@ Thus, this does not include the shell's current directory.") (while (looking-at (eval-when-compile (concat - "\\(?:[^\s\t\n\\\"']+" + "\\(?:[^\s\t\n\\\"';]+" "\\|'\\([^']*\\)'?" "\\|\"\\(\\(?:[^\"\\]\\|\\\\.\\)*\\)\"?" "\\|\\\\\\(\\(?:.\\|\n\\)?\\)\\)"))) @@ -490,7 +490,7 @@ Shell buffers. It implements `shell-completion-execonly' for (setq comint-input-autoexpand shell-input-autoexpand) ;; Not needed in shell-mode because it's inherited from comint-mode, but ;; placed here for read-shell-command. - (add-hook 'completion-at-point-functions 'comint-completion-at-point nil t)) + (add-hook 'completion-at-point-functions #'comint-completion-at-point nil t)) (put 'shell-mode 'mode-class 'special) @@ -606,7 +606,7 @@ buffer." ;; Bypass a bug in certain versions of bash. (when (string-equal shell "bash") (add-hook 'comint-preoutput-filter-functions - 'shell-filter-ctrl-a-ctrl-b nil t))) + #'shell-filter-ctrl-a-ctrl-b nil t))) (comint-read-input-ring t))) (defun shell-apply-ansi-color (beg end face) @@ -751,7 +751,7 @@ Otherwise, one argument `-i' is passed to the shell. (xargs-name (intern-soft (concat "explicit-" name "-args")))) (unless (file-exists-p startfile) (setq startfile (concat user-emacs-directory "init_" name ".sh"))) - (apply 'make-comint-in-buffer "shell" buffer prog + (apply #'make-comint-in-buffer "shell" buffer prog (if (file-exists-p startfile) startfile) (if (and xargs-name (boundp xargs-name)) (symbol-value xargs-name) @@ -973,10 +973,10 @@ this feature; see the function `dirtrack-mode'." nil nil nil (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) (if shell-dirtrack-mode - (add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t) - (remove-hook 'comint-input-filter-functions 'shell-directory-tracker t))) + (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) + (remove-hook 'comint-input-filter-functions #'shell-directory-tracker t))) -(define-obsolete-function-alias 'shell-dirtrack-toggle 'shell-dirtrack-mode +(define-obsolete-function-alias 'shell-dirtrack-toggle #'shell-dirtrack-mode "23.1") (defun shell-cd (dir) diff --git a/test/lisp/shell-tests.el b/test/lisp/shell-tests.el index 105701ebbc8..9550800f453 100644 --- a/test/lisp/shell-tests.el +++ b/test/lisp/shell-tests.el @@ -30,4 +30,12 @@ "Test problem found by Filipp Gunbin in emacs-devel." (should (equal (car (shell--unquote&requote-argument "te'st" 2)) "test"))) +(ert-deftest shell-tests-completion-before-semi () + (with-temp-buffer + (shell-mode) + (insert "cd ba;") + (forward-char -1) + (should (equal (shell--parse-pcomplete-arguments) + '(("cd" "ba") 1 4))))) + ;;; shell-tests.el ends here -- 2.39.5