Function: eshell-complete-history-reference
eshell-complete-history-reference is a byte-compiled function defined
in em-hist.el.gz.
Signature
(eshell-complete-history-reference)
Documentation
Complete a history reference, by completing the event designator.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/em-hist.el.gz
(defun eshell-complete-history-reference ()
"Complete a history reference, by completing the event designator."
(let ((arg (pcomplete-actual-arg)))
(when (string-match "\\`![^:^$*%]*\\'" arg)
(setq pcomplete-stub (substring arg 1)
pcomplete-last-completion-raw t)
(throw 'pcomplete-completions
(let ((history nil)
(index (1- (ring-length eshell-history-ring)))
(stublen (length pcomplete-stub)))
;; We have to build up a list ourselves from the ring
;; vector.
(while (>= index 0)
(let ((hist (eshell-get-history index)))
(if (and (>= (length hist) stublen)
(string= (substring hist 0 stublen)
pcomplete-stub)
(string-match "^\\([^:^$*% \t\n]+\\)" hist))
(setq history (cons (match-string 1 hist)
history))))
(setq index (1- index)))
(let ((fhist (list t)))
;; uniquify the list, but preserve the order
(while history
(unless (member (car history) fhist)
(nconc fhist (list (car history))))
(setq history (cdr history)))
(cdr fhist)))))))