Function: shell-c-a-p-replace-by-expanded-directory
shell-c-a-p-replace-by-expanded-directory is a byte-compiled function
defined in shell.el.gz.
Signature
(shell-c-a-p-replace-by-expanded-directory)
Documentation
Expand directory stack reference before point.
For use on completion-at-point-functions.
Source Code
;; Defined in /usr/src/emacs/lisp/shell.el.gz
(defun shell-c-a-p-replace-by-expanded-directory ()
"Expand directory stack reference before point.
For use on `completion-at-point-functions'."
(when (comint-match-partial-filename)
(save-excursion
(goto-char (match-beginning 0))
(let ((stack (cons default-directory shell-dirstack))
(index (cond ((looking-at "=-/?")
(length shell-dirstack))
((looking-at "=\\([0-9]+\\)/?")
(string-to-number
(buffer-substring
(match-beginning 1) (match-end 1)))))))
(when index
(let ((start (match-beginning 0))
(end (match-end 0))
(replacement (file-name-as-directory (nth index stack))))
(lambda ()
(cond
((>= index (length stack))
(error "Directory stack not that deep"))
(t
(save-excursion
(goto-char start)
(insert replacement)
(delete-char (- end start)))
(message "Directory item: %d" index)
t)))))))))