aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-09-13 07:22:19 +0000
committerGlenn Morris2007-09-13 07:22:19 +0000
commit45a4af634fbcf5206ebe9aa0ed55c93c619bf218 (patch)
tree67bfb5384ed6f2c58c53bf6ad4d2f44628297391
parent36e625ec8fa9e652b95faa30e4b46cd296218e87 (diff)
downloademacs-45a4af634fbcf5206ebe9aa0ed55c93c619bf218.tar.gz
emacs-45a4af634fbcf5206ebe9aa0ed55c93c619bf218.zip
Chris Moore <dooglus at gmail.com>
(shell-resync-dirs): Don't move the cursor relative to the command being edited.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/shell.el93
2 files changed, 53 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b9d112cf70d..522704335a2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-09-13 Chris Moore <dooglus@gmail.com>
2
3 * shell.el (shell-resync-dirs): Don't move the cursor relative to
4 the command being edited.
5
12007-09-12 Jim Meyering <jim@meyering.net> (tiny change) 62007-09-12 Jim Meyering <jim@meyering.net> (tiny change)
2 7
3 * emacs-lisp/copyright.el (copyright-names-regexp): Doc fix: typo. 8 * emacs-lisp/copyright.el (copyright-names-regexp): Doc fix: typo.
diff --git a/lisp/shell.el b/lisp/shell.el
index 392440ede81..a8daf8b76d2 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -808,51 +808,54 @@ new directory stack -- you lose. If this happens, just do the
808command again." 808command again."
809 (interactive) 809 (interactive)
810 (let* ((proc (get-buffer-process (current-buffer))) 810 (let* ((proc (get-buffer-process (current-buffer)))
811 (pmark (process-mark proc))) 811 (pmark (process-mark proc))
812 (goto-char pmark) 812 (started-at-pmark (= (point) (marker-position pmark))))
813 ;; If the process echoes commands, don't insert a fake command in 813 (save-excursion
814 ;; the buffer or it will appear twice. 814 (goto-char pmark)
815 (unless comint-process-echoes 815 ;; If the process echoes commands, don't insert a fake command in
816 (insert shell-dirstack-query) (insert "\n")) 816 ;; the buffer or it will appear twice.
817 (sit-for 0) ; force redisplay 817 (unless comint-process-echoes
818 (comint-send-string proc shell-dirstack-query) 818 (insert shell-dirstack-query) (insert "\n"))
819 (comint-send-string proc "\n") 819 (sit-for 0) ; force redisplay
820 (set-marker pmark (point)) 820 (comint-send-string proc shell-dirstack-query)
821 (let ((pt (point)) 821 (comint-send-string proc "\n")
822 (regexp 822 (set-marker pmark (point))
823 (concat 823 (let ((pt (point))
824 (if comint-process-echoes 824 (regexp
825 ;; Skip command echo if the process echoes 825 (concat
826 (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)") 826 (if comint-process-echoes
827 "\\(\\)") 827 ;; Skip command echo if the process echoes
828 "\\(.+\n\\)"))) 828 (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)")
829 ;; This extra newline prevents the user's pending input from spoofing us. 829 "\\(\\)")
830 (insert "\n") (backward-char 1) 830 "\\(.+\n\\)")))
831 ;; Wait for one line. 831 ;; This extra newline prevents the user's pending input from spoofing us.
832 (while (not (looking-at regexp)) 832 (insert "\n") (backward-char 1)
833 (accept-process-output proc) 833 ;; Wait for one line.
834 (goto-char pt))) 834 (while (not (looking-at regexp))
835 (goto-char pmark) (delete-char 1) ; remove the extra newline 835 (accept-process-output proc)
836 ;; That's the dirlist. grab it & parse it. 836 (goto-char pt)))
837 (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2)))) 837 (goto-char pmark) (delete-char 1) ; remove the extra newline
838 (dl-len (length dl)) 838 ;; That's the dirlist. grab it & parse it.
839 (ds '()) ; new dir stack 839 (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2))))
840 (i 0)) 840 (dl-len (length dl))
841 (while (< i dl-len) 841 (ds '()) ; new dir stack
842 ;; regexp = optional whitespace, (non-whitespace), optional whitespace 842 (i 0))
843 (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir 843 (while (< i dl-len)
844 (setq ds (cons (concat comint-file-name-prefix 844 ;; regexp = optional whitespace, (non-whitespace), optional whitespace
845 (substring dl (match-beginning 1) 845 (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
846 (match-end 1))) 846 (setq ds (cons (concat comint-file-name-prefix
847 ds)) 847 (substring dl (match-beginning 1)
848 (setq i (match-end 0))) 848 (match-end 1)))
849 (let ((ds (nreverse ds))) 849 ds))
850 (condition-case nil 850 (setq i (match-end 0)))
851 (progn (shell-cd (car ds)) 851 (let ((ds (nreverse ds)))
852 (setq shell-dirstack (cdr ds) 852 (condition-case nil
853 shell-last-dir (car shell-dirstack)) 853 (progn (shell-cd (car ds))
854 (shell-dirstack-message)) 854 (setq shell-dirstack (cdr ds)
855 (error (message "Couldn't cd"))))))) 855 shell-last-dir (car shell-dirstack))
856 (shell-dirstack-message))
857 (error (message "Couldn't cd"))))))
858 (if started-at-pmark (goto-char (marker-position pmark)))))
856 859
857;; For your typing convenience: 860;; For your typing convenience:
858(defalias 'dirs 'shell-resync-dirs) 861(defalias 'dirs 'shell-resync-dirs)