-;;; hippie-exp.el --- expand text trying various ways to find its expansion.
+;;; hippie-exp.el --- expand text trying various ways to find its expansion
;; Copyright (C) 1992 Free Software Foundation, Inc.
;; Author: Anders Holst <aho@sans.kth.se>
;; Last change: 3 March 1998
;; Version: 1.6
-;; Keywords: abbrev
+;; Keywords: abbrev convenience
;; This file is part of GNU Emacs.
;;; Code:
+(eval-when-compile (require 'comint))
+
(defgroup hippie-expand nil
"Expand text trying various ways to find its expansion."
- :group 'abbrev)
+ :link '(custom-manual "(autotype)Hippie Expand")
+ :link '(emacs-commentary-link "hippie-exp")
+ :group 'abbrev
+ :group 'convenience)
(defvar he-num -1)
(defvar he-search-window ())
;;;###autoload
-(defvar hippie-expand-try-functions-list '(try-complete-file-name-partially
- try-complete-file-name
- try-expand-all-abbrevs
- try-expand-list
- try-expand-line
- try-expand-dabbrev
- try-expand-dabbrev-all-buffers
- try-expand-dabbrev-from-kill
- try-complete-lisp-symbol-partially
- try-complete-lisp-symbol)
+(defcustom hippie-expand-try-functions-list
+ '(try-complete-file-name-partially
+ try-complete-file-name
+ try-expand-all-abbrevs
+ try-expand-list
+ try-expand-line
+ try-expand-dabbrev
+ try-expand-dabbrev-all-buffers
+ try-expand-dabbrev-from-kill
+ try-complete-lisp-symbol-partially
+ try-complete-lisp-symbol)
"The list of expansion functions tried in order by `hippie-expand'.
To change the behavior of `hippie-expand', remove, change the order of,
-or insert functions in this list.")
+or insert functions in this list."
+ :type '(repeat function)
+ :group 'hippie-expand)
;;;###autoload
(defcustom hippie-expand-verbose t
(defcustom hippie-expand-only-buffers ()
"*A list specifying the only buffers to search (in addition to current).
Can contain both regexps matching buffer names (as strings) and major modes
-\(as atoms). If non-NIL, this variable overrides the variable
+\(as atoms). If non-nil, this variable overrides the variable
`hippie-expand-ignore-buffers'."
:type '(repeat (choice regexp (symbol :tag "Major Mode")))
:group 'hippie-expand)
;; Check if STR is a member of LST.
-;; Transform to the final case if optional TRANS-CASE is non-NIL.
+;; Transform to the final case if optional TRANS-CASE is non-nil.
(defun he-string-member (str lst &optional trans-case)
(if str
(member (if (and trans-case
"Construct a function similar to `hippie-expand'.
Make it use the expansion functions in TRY-LIST. An optional second
argument VERBOSE non-nil makes the function verbose."
- (` (function (lambda (arg)
- (, (concat
- "Try to expand text before point, using the following functions: \n"
- (mapconcat 'prin1-to-string (eval try-list) ", ")))
- (interactive "P")
- (let ((hippie-expand-try-functions-list (, try-list))
- (hippie-expand-verbose (, verbose)))
- (hippie-expand arg))))))
+ `(function (lambda (arg)
+ ,(concat
+ "Try to expand text before point, using the following functions: \n"
+ (mapconcat 'prin1-to-string (eval try-list) ", "))
+ (interactive "P")
+ (let ((hippie-expand-try-functions-list ,try-list)
+ (hippie-expand-verbose ,verbose))
+ (hippie-expand arg)))))
;;; Here follows the try-functions and their requisites:
string). It returns t if a new completion is found, nil otherwise."
(let ((expansion ())
(strip-prompt (and (get-buffer-process (current-buffer))
+ comint-use-prompt-regexp-instead-of-fields
comint-prompt-regexp)))
(if (not old)
(progn
string). It returns t if a new completion is found, nil otherwise."
(let ((expansion ())
(strip-prompt (and (get-buffer-process (current-buffer))
+ comint-use-prompt-regexp-instead-of-fields
comint-prompt-regexp))
(buf (current-buffer))
(orig-case-fold-search case-fold-search))
(widen))
(goto-char he-search-loc)
(setq strip-prompt (and (get-buffer-process (current-buffer))
+ comint-use-prompt-regexp-instead-of-fields
comint-prompt-regexp))
(setq expansion
(let ((case-fold-search orig-case-fold-search))
(re-search-forward
(he-line-search-regexp str strip-prompt)
nil t)))
- (setq result (buffer-substring-no-properties (match-beginning 2)
- (match-end 2)))
+ (setq result (buffer-substring-no-properties (match-end 1)
+ (match-end 0)))
(if (he-string-member result he-tried-table t)
(setq result nil))) ; if already in table, ignore
result))