Function: hippie-expand

hippie-expand is an autoloaded, interactive and byte-compiled function defined in hippie-exp.el.gz.

Signature

(hippie-expand ARG)

Documentation

Try to expand text before point, using multiple methods.

The expansion functions in hippie-expand-try-functions-list are tried in order, until a possible expansion is found. Repeated application of hippie-expand inserts successively possible expansions. With a positive numeric argument, jumps directly to the ARG next function in this list. With a negative argument or just C-u (universal-argument), undoes the expansion.

Probably introduced at or before Emacs version 20.3.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/hippie-exp.el.gz
;;;###autoload
(defun hippie-expand (arg)
  "Try to expand text before point, using multiple methods.
The expansion functions in `hippie-expand-try-functions-list' are
tried in order, until a possible expansion is found.  Repeated
application of `hippie-expand' inserts successively possible
expansions.
With a positive numeric argument, jumps directly to the ARG next
function in this list.  With a negative argument or just \\[universal-argument],
undoes the expansion."
  (interactive "P")
  (if (or (not arg)
	  (and (integerp arg) (> arg 0)))
      (let ((first (or (= he-num -1)
		       (not (equal this-command last-command)))))
	(if first
	    (progn
	      (setq he-num -1)
	      (setq he-tried-table nil)))
	(if arg
	    (if (not first) (he-reset-string))
	    (setq arg 0))
	(let ((i (max (+ he-num arg) 0)))
	  (while (not (or (>= i (length hippie-expand-try-functions-list))
			  (apply (nth i hippie-expand-try-functions-list)
				 (list (= he-num i)))))
	    (setq i (1+ i)))
	  (setq he-num i))
	(if (>= he-num (length hippie-expand-try-functions-list))
	    (progn
	      (setq he-num -1)
	      (if first
		  (message "No expansion found")
		  (message "No further expansions found"))
	      (ding))
	    (if (and hippie-expand-verbose
		     (not (window-minibuffer-p)))
		(message "Using %s"
			 (nth he-num hippie-expand-try-functions-list)))))
      (if (and (>= he-num 0)
	       (eq (marker-buffer he-string-beg) (current-buffer)))
	  (progn
	    (setq he-num -1)
	    (he-reset-string)
	    (if (and hippie-expand-verbose
		     (not (window-minibuffer-p)))
		(message "Undoing expansions"))))))