Function: pcomplete-insert-entry

pcomplete-insert-entry is a byte-compiled function defined in pcomplete.el.gz.

Signature

(pcomplete-insert-entry STUB ENTRY &optional ADDSUFFIX RAW-P)

Documentation

Insert a completion entry at point.

Returns non-nil if a space was appended at the end.

Source Code

;; Defined in /usr/src/emacs/lisp/pcomplete.el.gz
;; insert completion at point

(defun pcomplete-insert-entry (stub entry &optional addsuffix raw-p)
  "Insert a completion entry at point.
Returns non-nil if a space was appended at the end."
  (let ((here (point)))
    (if (not completion-ignore-case)
	(insert-and-inherit (if raw-p
				(substring entry (length stub))
			      (comint-quote-filename
			       (substring entry (length stub)))))
      ;; the stub is not quoted at this time, so to determine the
      ;; length of what should be in the buffer, we must quote it
      ;; FIXME: Here we presume that quoting `stub' gives us the exact
      ;; text in the buffer before point, which is not guaranteed;
      ;; e.g. it is not the case in eshell when completing ${FOO}tm[TAB].
      (delete-char (- (length (comint-quote-filename stub))))
      ;; if there is already a backslash present to handle the first
      ;; character, don't bother quoting it
      (when (eq (char-before) ?\\)
	(insert-and-inherit (substring entry 0 1))
	(setq entry (substring entry 1)))
      (insert-and-inherit (if raw-p
			      entry
			    (comint-quote-filename entry))))
    (let (space-added)
      (when (and (not (memq (char-before) pcomplete-suffix-list))
		 addsuffix)
	(insert-and-inherit pcomplete-termination-string)
	(setq space-added t))
      (setq pcomplete-last-completion-length (- (point) here)
	    pcomplete-last-completion-stub stub)
      space-added)))