- (setq library
- (cond ((eq (car-safe def) 'autoload)
- (nth 1 def))
- ((describe-function-find-file function))))
- (if (null library)
- (error (format "`%s' is not in `load-history'" function)))
- (if (string-match "\\(\\.elc?\\'\\)" library)
- (setq library (substring library 0 (match-beginning 1))))
- (let* ((path (or path find-function-source-path))
- (compression (or (rassq 'jka-compr-handler file-name-handler-alist)
- (member 'crypt-find-file-hook find-file-hooks)))
- (filename (or (locate-library (concat library ".el")
- t path)
- (locate-library library t path)
- (if compression
- (or (locate-library (concat library ".el.gz")
- t path)
- (locate-library (concat library ".gz")
- t path))))))
- (if (not filename)
- (error "The library \"%s\" is not in the path." library))
- (save-excursion
- (set-buffer (find-file-noselect filename))
- (save-match-data
- (let (;; avoid defconst, defgroup, defvar (any others?)
- (regexp (format "^\\s-*(def[^cgv\W]\\w+\\s-+%s\\s-" function))
- (syntable (syntax-table)))
- (set-syntax-table emacs-lisp-mode-syntax-table)
- (goto-char (point-min))
- (if (prog1
- (re-search-forward regexp nil t)
- (set-syntax-table syntable))
- (progn
- (beginning-of-line)
- (list (current-buffer) (point)))
- (error "Cannot find definition of %s" function))))))))
-
-(defun function-at-point ()
- (or (condition-case ()
- (let ((stab (syntax-table)))
- (unwind-protect
- (save-excursion
- (set-syntax-table emacs-lisp-mode-syntax-table)
- (or (not (zerop (skip-syntax-backward "_w")))
- (eq (char-syntax (char-after (point))) ?w)
- (eq (char-syntax (char-after (point))) ?_)
- (forward-sexp -1))
- (skip-chars-forward "`'")
- (let ((obj (read (current-buffer))))
- (and (symbolp obj) (fboundp obj) obj)))
- (set-syntax-table stab)))
- (error nil))
- (condition-case ()
- (save-excursion
- (save-restriction
- (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
- (backward-up-list 1)
- (forward-char 1)
- (let (obj)
- (setq obj (read (current-buffer)))
- (and (symbolp obj) (fboundp obj) obj))))
- (error nil))))
-
-(defun find-function-read-function ()
- "Read and return a function, defaulting to the one near point.
-
-The function named by `find-function-function' is used to select the
-default function."
- (let ((fn (funcall find-function-function))
+ (let ((library
+ (cond ((eq (car-safe def) 'autoload)
+ (nth 1 def))
+ ((symbol-file function)))))
+ (find-function-search-for-symbol function nil library))))
+
+(defalias 'function-at-point 'function-called-at-point)
+
+(defun find-function-read (&optional variable-p)
+ "Read and return an interned symbol, defaulting to the one near point.
+
+If the optional VARIABLE-P is nil, then a function is gotten
+defaulting to the value of the function `function-at-point', otherwise
+a variable is asked for, with the default coming from
+`variable-at-point'."
+ (let ((symb (funcall (if variable-p
+ 'variable-at-point
+ 'function-at-point)))