797 |
(let* ((proc (get-buffer-process (current-buffer))) |
(let* ((proc (get-buffer-process (current-buffer))) |
798 |
(pmark (process-mark proc))) |
(pmark (process-mark proc))) |
799 |
(goto-char pmark) |
(goto-char pmark) |
800 |
(insert shell-dirstack-query) (insert "\n") |
;; If the process echoes commands, don't insert a fake command in |
801 |
|
;; the buffer or it will appear twice. |
802 |
|
(unless comint-process-echoes |
803 |
|
(insert shell-dirstack-query) (insert "\n")) |
804 |
(sit-for 0) ; force redisplay |
(sit-for 0) ; force redisplay |
805 |
(comint-send-string proc shell-dirstack-query) |
(comint-send-string proc shell-dirstack-query) |
806 |
(comint-send-string proc "\n") |
(comint-send-string proc "\n") |
807 |
(set-marker pmark (point)) |
(set-marker pmark (point)) |
808 |
(let ((pt (point))) ; wait for 1 line |
(let ((pt (point)) |
809 |
|
(regexp |
810 |
|
(concat |
811 |
|
(if comint-process-echoes |
812 |
|
;; Skip command echo if the process echoes |
813 |
|
(concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)") |
814 |
|
"\\(\\)") |
815 |
|
"\\(.+\n\\)"))) |
816 |
;; This extra newline prevents the user's pending input from spoofing us. |
;; This extra newline prevents the user's pending input from spoofing us. |
817 |
(insert "\n") (backward-char 1) |
(insert "\n") (backward-char 1) |
818 |
(while (not (looking-at |
;; Wait for one line. |
819 |
(concat "\\(" ; skip literal echo in case of stty echo |
(while (not (looking-at regexp)) |
|
(regexp-quote shell-dirstack-query) |
|
|
"\n\\)?" ; skip if present |
|
|
"\\(" ".+\n" "\\)")) ) ; what to actually look for |
|
820 |
(accept-process-output proc) |
(accept-process-output proc) |
821 |
(goto-char pt))) |
(goto-char pt))) |
822 |
(goto-char pmark) (delete-char 1) ; remove the extra newline |
(goto-char pmark) (delete-char 1) ; remove the extra newline |