]> code.delx.au - gnu-emacs/blobdiff - lisp/shell.el
(Converting Representations): Update the description of what
[gnu-emacs] / lisp / shell.el
index 0a4119f0f8d361266ec2c5d3085f86c667c981dc..ec52a2f3624cbb5004f78fb18bca6c563eb67bfa 100644 (file)
@@ -314,7 +314,8 @@ Thus, this does not include the shell's current directory.")
        (define-key shell-mode-map "\M-?"
         'comint-dynamic-list-filename-completions)
        (define-key shell-mode-map [menu-bar completion]
-        (copy-keymap (lookup-key comint-mode-map [menu-bar completion])))
+        (cons "Complete"
+              (copy-keymap (lookup-key comint-mode-map [menu-bar completion]))))
        (define-key-after (lookup-key shell-mode-map [menu-bar completion])
         [complete-env-variable] '("Complete Env. Variable Name" .
                                   shell-dynamic-complete-environment-variable)
@@ -414,28 +415,29 @@ buffer."
   (make-local-variable 'list-buffers-directory)
   (setq list-buffers-directory (expand-file-name default-directory))
   ;; shell-dependent assignments.
-  (let ((shell (file-name-nondirectory (car
-                (process-command (get-buffer-process (current-buffer)))))))
-    (setq comint-input-ring-file-name
-         (or (getenv "HISTFILE")
-             (cond ((string-equal shell "bash") "~/.bash_history")
-                   ((string-equal shell "ksh") "~/.sh_history")
-                   (t "~/.history"))))
-    (if (or (equal comint-input-ring-file-name "")
-           (equal (file-truename comint-input-ring-file-name)
-                  (file-truename "/dev/null")))
-       (setq comint-input-ring-file-name nil))
-    ;; Arrange to write out the input ring on exit, if the shell doesn't
-    ;; do this itself.
-    (if (and comint-input-ring-file-name
-            (string-match shell-dumb-shell-regexp shell))
-       (set-process-sentinel (get-buffer-process (current-buffer))
-                             #'shell-write-history-on-exit))
-    (setq shell-dirstack-query
-         (cond ((string-equal shell "sh") "pwd")
-               ((string-equal shell "ksh") "echo $PWD ~-")
-               (t "dirs"))))
-  (comint-read-input-ring t))
+  (when (ring-empty-p comint-input-ring)
+    (let ((shell (file-name-nondirectory (car
+                  (process-command (get-buffer-process (current-buffer)))))))
+      (setq comint-input-ring-file-name
+           (or (getenv "HISTFILE")
+               (cond ((string-equal shell "bash") "~/.bash_history")
+                     ((string-equal shell "ksh") "~/.sh_history")
+                     (t "~/.history"))))
+      (if (or (equal comint-input-ring-file-name "")
+             (equal (file-truename comint-input-ring-file-name)
+                    (file-truename "/dev/null")))
+         (setq comint-input-ring-file-name nil))
+      ;; Arrange to write out the input ring on exit, if the shell doesn't
+      ;; do this itself.
+      (if (and comint-input-ring-file-name
+              (string-match shell-dumb-shell-regexp shell))
+         (set-process-sentinel (get-buffer-process (current-buffer))
+                               #'shell-write-history-on-exit))
+      (setq shell-dirstack-query
+           (cond ((string-equal shell "sh") "pwd")
+                 ((string-equal shell "ksh") "echo $PWD ~-")
+                 (t "dirs"))))
+    (comint-read-input-ring t)))
 
 (defun shell-write-history-on-exit (process event)
   "Called when the shell process is stopped.
@@ -857,7 +859,6 @@ See `shell-command-regexp'."
        (progn (goto-char (match-beginning 1))
               (skip-chars-forward ";&|")))))
 
-
 (defun shell-dynamic-complete-command ()
   "Dynamically complete the command at point.
 This function is similar to `comint-dynamic-complete-filename', except that it
@@ -992,7 +993,7 @@ Returns t if successful."
        (let ((stack (cons default-directory shell-dirstack))
              (index (cond ((looking-at "=-/?")
                            (length shell-dirstack))
-                          ((looking-at "=\\([0-9]+\\)")
+                          ((looking-at "=\\([0-9]+\\)/?")
                            (string-to-number
                             (buffer-substring
                              (match-beginning 1) (match-end 1)))))))