diff options
| author | Leo Liu | 2015-06-23 09:19:36 +0800 |
|---|---|---|
| committer | Leo Liu | 2015-06-23 09:19:36 +0800 |
| commit | eccfc0a487787a7c1c2465c469becad983fc2810 (patch) | |
| tree | cb3711c836c21c41c0b5cb88c852b0d617b8fd4e | |
| parent | 1b1b6644c8cb27539ca99e97ef2f352f411c06d8 (diff) | |
| download | emacs-eccfc0a487787a7c1c2465c469becad983fc2810.tar.gz emacs-eccfc0a487787a7c1c2465c469becad983fc2810.zip | |
Fix shell-for/backward-command to exclude spaces
* lisp/shell.el (shell-forward-command, shell-backward-command):
Handle the 'move case from re-search-forward/backward.
fixes debbugs:20873
| -rw-r--r-- | lisp/shell.el | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index f71d1407a49..f5cb3215a0a 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -83,8 +83,8 @@ | |||
| 83 | ;; tab completion-at-point Complete filename/command/history | 83 | ;; tab completion-at-point Complete filename/command/history |
| 84 | ;; m-? comint-dynamic-list-filename-completions | 84 | ;; m-? comint-dynamic-list-filename-completions |
| 85 | ;; List completions in help buffer | 85 | ;; List completions in help buffer |
| 86 | ;; m-c-f shell-forward-command Forward a shell command | 86 | ;; c-c c-f shell-forward-command Forward a shell command |
| 87 | ;; m-c-b shell-backward-command Backward a shell command | 87 | ;; c-c c-b shell-backward-command Backward a shell command |
| 88 | ;; dirs Resync the buffer's dir stack | 88 | ;; dirs Resync the buffer's dir stack |
| 89 | ;; shell-dirtrack-mode Turn dir tracking on/off | 89 | ;; shell-dirtrack-mode Turn dir tracking on/off |
| 90 | ;; comint-strip-ctrl-m Remove trailing ^Ms from output | 90 | ;; comint-strip-ctrl-m Remove trailing ^Ms from output |
| @@ -1092,10 +1092,12 @@ Copy Shell environment variable to Emacs: "))) | |||
| 1092 | "Move forward across ARG shell command(s). Does not cross lines. | 1092 | "Move forward across ARG shell command(s). Does not cross lines. |
| 1093 | See `shell-command-regexp'." | 1093 | See `shell-command-regexp'." |
| 1094 | (interactive "p") | 1094 | (interactive "p") |
| 1095 | (let ((limit (line-end-position))) | 1095 | (let ((limit (line-end-position)) |
| 1096 | (if (re-search-forward (concat shell-command-regexp "\\([;&|][\t ]*\\)+") | 1096 | (pt (point))) |
| 1097 | limit 'move arg) | 1097 | (re-search-forward (concat shell-command-regexp "\\([;&|][\t ]*\\)+") |
| 1098 | (skip-syntax-backward " ")))) | 1098 | limit 'move arg) |
| 1099 | (and (/= pt (point)) | ||
| 1100 | (skip-syntax-backward " " pt)))) | ||
| 1099 | 1101 | ||
| 1100 | 1102 | ||
| 1101 | (defun shell-backward-command (&optional arg) | 1103 | (defun shell-backward-command (&optional arg) |
| @@ -1106,10 +1108,13 @@ See `shell-command-regexp'." | |||
| 1106 | (when (> limit (point)) | 1108 | (when (> limit (point)) |
| 1107 | (setq limit (line-beginning-position))) | 1109 | (setq limit (line-beginning-position))) |
| 1108 | (skip-syntax-backward " " limit) | 1110 | (skip-syntax-backward " " limit) |
| 1109 | (if (re-search-backward | 1111 | (let ((pt (point))) |
| 1110 | (format "[;&|]+[\t ]*\\(%s\\)" shell-command-regexp) limit 'move arg) | 1112 | (if (re-search-backward |
| 1111 | (progn (goto-char (match-beginning 1)) | 1113 | (format "[;&|]+[\t ]*\\(%s\\)" shell-command-regexp) limit 'move arg) |
| 1112 | (skip-chars-forward ";&|"))))) | 1114 | (progn (goto-char (match-beginning 1)) |
| 1115 | (skip-chars-forward ";&|"))) | ||
| 1116 | (and (/= pt (point)) | ||
| 1117 | (skip-syntax-forward " " pt))))) | ||
| 1113 | 1118 | ||
| 1114 | (defun shell-dynamic-complete-command () | 1119 | (defun shell-dynamic-complete-command () |
| 1115 | "Dynamically complete the command at point. | 1120 | "Dynamically complete the command at point. |