diff options
| author | Michael Albinus | 2022-03-23 16:04:57 +0100 |
|---|---|---|
| committer | Michael Albinus | 2022-03-23 16:04:57 +0100 |
| commit | fdbee9bc4c3e1c8f4dfa358282bdb2e746918daa (patch) | |
| tree | 9daf2ee30466587c06182b4e7c86ed21df06ceef /lisp | |
| parent | 7fa5d6c87d43926008c15a7f7ddc924bbf8d2e76 (diff) | |
| download | emacs-fdbee9bc4c3e1c8f4dfa358282bdb2e746918daa.tar.gz emacs-fdbee9bc4c3e1c8f4dfa358282bdb2e746918daa.zip | |
Support changing remoteness of DIR in rgrep and lgrep
* lisp/net/tramp-sh.el (tramp-get-remote-dev-tty): New defun.
(tramp-sh-handle-make-process): Use it.
* lisp/progmodes/grep.el: Prefer #' to quote named functions.
(lgrep, rgrep): Recompute grep defaults when the remoteness of DIR
changes.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/net/tramp-sh.el | 12 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 54 |
2 files changed, 40 insertions, 26 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 475d48cc30b..7a2b884bad3 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2865,8 +2865,10 @@ implementation will be used." | |||
| 2865 | (string-match-p "sh$" program) | 2865 | (string-match-p "sh$" program) |
| 2866 | (= (length args) 2) | 2866 | (= (length args) 2) |
| 2867 | (string-equal "-c" (car args)) | 2867 | (string-equal "-c" (car args)) |
| 2868 | ;; Don't if there is a string. | 2868 | ;; Don't if there is a quoted string. |
| 2869 | (not (string-match-p "'\\|\"" (cadr args))))) | 2869 | (not (string-match-p "'\\|\"" (cadr args))) |
| 2870 | ;; Check, that /dev/tty is usable. | ||
| 2871 | (tramp-get-remote-dev-tty v))) | ||
| 2870 | ;; When PROGRAM is nil, we just provide a tty. | 2872 | ;; When PROGRAM is nil, we just provide a tty. |
| 2871 | (args (if (not heredoc) args | 2873 | (args (if (not heredoc) args |
| 2872 | (let ((i 250)) | 2874 | (let ((i 250)) |
| @@ -5933,6 +5935,12 @@ This command is returned only if `delete-by-moving-to-trash' is non-nil." | |||
| 5933 | command)) | 5935 | command)) |
| 5934 | (delete-file tmpfile))))) | 5936 | (delete-file tmpfile))))) |
| 5935 | 5937 | ||
| 5938 | (defun tramp-get-remote-dev-tty (vec) | ||
| 5939 | "Check, whether remote /dev/tty is usable." | ||
| 5940 | (with-tramp-connection-property vec "dev-tty" | ||
| 5941 | (tramp-send-command-and-check | ||
| 5942 | vec "echo </dev/tty"))) | ||
| 5943 | |||
| 5936 | ;; Some predefined connection properties. | 5944 | ;; Some predefined connection properties. |
| 5937 | (defun tramp-get-inline-compress (vec prop size) | 5945 | (defun tramp-get-inline-compress (vec prop size) |
| 5938 | "Return the compress command related to PROP. | 5946 | "Return the compress command related to PROP. |
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 21280888562..3fbe4acd504 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -269,16 +269,16 @@ See `compilation-error-screen-columns'." | |||
| 269 | (defvar grep-mode-map | 269 | (defvar grep-mode-map |
| 270 | (let ((map (make-sparse-keymap))) | 270 | (let ((map (make-sparse-keymap))) |
| 271 | (set-keymap-parent map compilation-minor-mode-map) | 271 | (set-keymap-parent map compilation-minor-mode-map) |
| 272 | (define-key map " " 'scroll-up-command) | 272 | (define-key map " " #'scroll-up-command) |
| 273 | (define-key map [?\S-\ ] 'scroll-down-command) | 273 | (define-key map [?\S-\ ] #'scroll-down-command) |
| 274 | (define-key map "\^?" 'scroll-down-command) | 274 | (define-key map "\^?" #'scroll-down-command) |
| 275 | (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) | 275 | (define-key map "\C-c\C-f" #'next-error-follow-minor-mode) |
| 276 | 276 | ||
| 277 | (define-key map "\r" 'compile-goto-error) ;; ? | 277 | (define-key map "\r" #'compile-goto-error) ;; ? |
| 278 | (define-key map "{" 'compilation-previous-file) | 278 | (define-key map "{" #'compilation-previous-file) |
| 279 | (define-key map "}" 'compilation-next-file) | 279 | (define-key map "}" #'compilation-next-file) |
| 280 | (define-key map "\t" 'compilation-next-error) | 280 | (define-key map "\t" #'compilation-next-error) |
| 281 | (define-key map [backtab] 'compilation-previous-error) | 281 | (define-key map [backtab] #'compilation-previous-error) |
| 282 | map) | 282 | map) |
| 283 | "Keymap for grep buffers. | 283 | "Keymap for grep buffers. |
| 284 | `compilation-minor-mode-map' is a cdr of this.") | 284 | `compilation-minor-mode-map' is a cdr of this.") |
| @@ -322,24 +322,24 @@ See `compilation-error-screen-columns'." | |||
| 322 | ;; FIXME: Nowadays the last button is not "help" but "search"! | 322 | ;; FIXME: Nowadays the last button is not "help" but "search"! |
| 323 | (help (last tool-bar-map))) ;; Keep Help last in tool bar | 323 | (help (last tool-bar-map))) ;; Keep Help last in tool bar |
| 324 | (tool-bar-local-item | 324 | (tool-bar-local-item |
| 325 | "left-arrow" 'previous-error-no-select 'previous-error-no-select map | 325 | "left-arrow" #'previous-error-no-select #'previous-error-no-select map |
| 326 | :rtl "right-arrow" | 326 | :rtl "right-arrow" |
| 327 | :help "Goto previous match") | 327 | :help "Goto previous match") |
| 328 | (tool-bar-local-item | 328 | (tool-bar-local-item |
| 329 | "right-arrow" 'next-error-no-select 'next-error-no-select map | 329 | "right-arrow" #'next-error-no-select #'next-error-no-select map |
| 330 | :rtl "left-arrow" | 330 | :rtl "left-arrow" |
| 331 | :help "Goto next match") | 331 | :help "Goto next match") |
| 332 | (tool-bar-local-item | 332 | (tool-bar-local-item |
| 333 | "cancel" 'kill-compilation 'kill-compilation map | 333 | "cancel" #'kill-compilation #'kill-compilation map |
| 334 | :enable '(let ((buffer (compilation-find-buffer))) | 334 | :enable '(let ((buffer (compilation-find-buffer))) |
| 335 | (get-buffer-process buffer)) | 335 | (get-buffer-process buffer)) |
| 336 | :help "Stop grep") | 336 | :help "Stop grep") |
| 337 | (tool-bar-local-item | 337 | (tool-bar-local-item |
| 338 | "refresh" 'recompile 'recompile map | 338 | "refresh" #'recompile #'recompile map |
| 339 | :help "Restart grep") | 339 | :help "Restart grep") |
| 340 | (append map help)))) | 340 | (append map help)))) |
| 341 | 341 | ||
| 342 | (defalias 'kill-grep 'kill-compilation) | 342 | (defalias 'kill-grep #'kill-compilation) |
| 343 | 343 | ||
| 344 | ;; override compilation-last-buffer | 344 | ;; override compilation-last-buffer |
| 345 | (defvar grep-last-buffer nil | 345 | (defvar grep-last-buffer nil |
| @@ -443,9 +443,9 @@ buffer `default-directory'." | |||
| 443 | (defvar grep-find-abbreviate-properties | 443 | (defvar grep-find-abbreviate-properties |
| 444 | (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]")) | 444 | (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]")) |
| 445 | (map (make-sparse-keymap))) | 445 | (map (make-sparse-keymap))) |
| 446 | (define-key map [down-mouse-2] 'mouse-set-point) | 446 | (define-key map [down-mouse-2] #'mouse-set-point) |
| 447 | (define-key map [mouse-2] 'grep-find-toggle-abbreviation) | 447 | (define-key map [mouse-2] #'grep-find-toggle-abbreviation) |
| 448 | (define-key map "\C-m" 'grep-find-toggle-abbreviation) | 448 | (define-key map "\C-m" #'grep-find-toggle-abbreviation) |
| 449 | `(face nil display ,ellipsis mouse-face highlight | 449 | `(face nil display ,ellipsis mouse-face highlight |
| 450 | help-echo "RET, mouse-2: show unabbreviated command" | 450 | help-echo "RET, mouse-2: show unabbreviated command" |
| 451 | keymap ,map abbreviated-command t)) | 451 | keymap ,map abbreviated-command t)) |
| @@ -954,7 +954,7 @@ easily repeat a find command." | |||
| 954 | (grep command-args)))) | 954 | (grep command-args)))) |
| 955 | 955 | ||
| 956 | ;;;###autoload | 956 | ;;;###autoload |
| 957 | (defalias 'find-grep 'grep-find) | 957 | (defalias 'find-grep #'grep-find) |
| 958 | 958 | ||
| 959 | 959 | ||
| 960 | ;; User-friendly interactive API. | 960 | ;; User-friendly interactive API. |
| @@ -1013,7 +1013,7 @@ these include `opts', `dir', `files', `null-device', `excl' and | |||
| 1013 | ;; Instead of a `grep-read-files-function' variable, we used to lookup | 1013 | ;; Instead of a `grep-read-files-function' variable, we used to lookup |
| 1014 | ;; mode-specific functions in the major mode's symbol properties, so preserve | 1014 | ;; mode-specific functions in the major mode's symbol properties, so preserve |
| 1015 | ;; this behavior for backward compatibility. | 1015 | ;; this behavior for backward compatibility. |
| 1016 | (let ((old-function (get major-mode 'grep-read-files))) ;Obsolete since 28.1 | 1016 | (let ((old-function (get major-mode #'grep-read-files))) ;Obsolete since 28.1 |
| 1017 | (if old-function | 1017 | (if old-function |
| 1018 | (funcall old-function) | 1018 | (funcall old-function) |
| 1019 | (let ((file-name-at-point | 1019 | (let ((file-name-at-point |
| @@ -1115,6 +1115,9 @@ command before it's run." | |||
| 1115 | (when (and (stringp regexp) (> (length regexp) 0)) | 1115 | (when (and (stringp regexp) (> (length regexp) 0)) |
| 1116 | (unless (and dir (file-accessible-directory-p dir)) | 1116 | (unless (and dir (file-accessible-directory-p dir)) |
| 1117 | (setq dir default-directory)) | 1117 | (setq dir default-directory)) |
| 1118 | (unless (string-equal (file-remote-p dir) (file-remote-p default-directory)) | ||
| 1119 | (let ((default-directory dir)) | ||
| 1120 | (grep-compute-defaults))) | ||
| 1118 | (let ((command regexp) remote) | 1121 | (let ((command regexp) remote) |
| 1119 | (if (null files) | 1122 | (if (null files) |
| 1120 | (if (string= command grep-command) | 1123 | (if (string= command grep-command) |
| @@ -1163,7 +1166,7 @@ command before it's run." | |||
| 1163 | (if (and grep-use-null-device null-device (null-device)) | 1166 | (if (and grep-use-null-device null-device (null-device)) |
| 1164 | (concat command " " (null-device)) | 1167 | (concat command " " (null-device)) |
| 1165 | command) | 1168 | command) |
| 1166 | 'grep-mode)) | 1169 | #'grep-mode)) |
| 1167 | ;; Set default-directory if we started lgrep in the *grep* buffer. | 1170 | ;; Set default-directory if we started lgrep in the *grep* buffer. |
| 1168 | (if (eq next-error-last-buffer (current-buffer)) | 1171 | (if (eq next-error-last-buffer (current-buffer)) |
| 1169 | (setq default-directory dir)))))) | 1172 | (setq default-directory dir)))))) |
| @@ -1215,11 +1218,14 @@ command before it's run." | |||
| 1215 | (when (and (stringp regexp) (> (length regexp) 0)) | 1218 | (when (and (stringp regexp) (> (length regexp) 0)) |
| 1216 | (unless (and dir (file-accessible-directory-p dir)) | 1219 | (unless (and dir (file-accessible-directory-p dir)) |
| 1217 | (setq dir default-directory)) | 1220 | (setq dir default-directory)) |
| 1221 | (unless (string-equal (file-remote-p dir) (file-remote-p default-directory)) | ||
| 1222 | (let ((default-directory dir)) | ||
| 1223 | (grep-compute-defaults))) | ||
| 1218 | (if (null files) | 1224 | (if (null files) |
| 1219 | (if (not (string= regexp (if (consp grep-find-command) | 1225 | (if (not (string= regexp (if (consp grep-find-command) |
| 1220 | (car grep-find-command) | 1226 | (car grep-find-command) |
| 1221 | grep-find-command))) | 1227 | grep-find-command))) |
| 1222 | (compilation-start regexp 'grep-mode)) | 1228 | (compilation-start regexp #'grep-mode)) |
| 1223 | (setq dir (file-name-as-directory (expand-file-name dir))) | 1229 | (setq dir (file-name-as-directory (expand-file-name dir))) |
| 1224 | (let ((command (rgrep-default-command regexp files nil))) | 1230 | (let ((command (rgrep-default-command regexp files nil))) |
| 1225 | (when command | 1231 | (when command |
| @@ -1230,7 +1236,7 @@ command before it's run." | |||
| 1230 | (add-to-history 'grep-find-history command)) | 1236 | (add-to-history 'grep-find-history command)) |
| 1231 | (grep--save-buffers) | 1237 | (grep--save-buffers) |
| 1232 | (let ((default-directory dir)) | 1238 | (let ((default-directory dir)) |
| 1233 | (compilation-start command 'grep-mode)) | 1239 | (compilation-start command #'grep-mode)) |
| 1234 | ;; Set default-directory if we started rgrep in the *grep* buffer. | 1240 | ;; Set default-directory if we started rgrep in the *grep* buffer. |
| 1235 | (if (eq next-error-last-buffer (current-buffer)) | 1241 | (if (eq next-error-last-buffer (current-buffer)) |
| 1236 | (setq default-directory dir))))))) | 1242 | (setq default-directory dir))))))) |
| @@ -1359,7 +1365,7 @@ The returned file name is relative." | |||
| 1359 | (caar (compilation--loc->file-struct loc)))) | 1365 | (caar (compilation--loc->file-struct loc)))) |
| 1360 | 1366 | ||
| 1361 | ;;;###autoload | 1367 | ;;;###autoload |
| 1362 | (defalias 'rzgrep 'zrgrep) | 1368 | (defalias 'rzgrep #'zrgrep) |
| 1363 | 1369 | ||
| 1364 | (provide 'grep) | 1370 | (provide 'grep) |
| 1365 | 1371 | ||