(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)
(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.
(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
(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)))))))