X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/29c360ee1cb0ba68470d831739d4df33016fada1..991c801cd6b6b323fb4510de9e295b3fea2fb12f:/lisp/progmodes/elisp-mode.el diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index daf5e41d28..9e175a20e2 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1,6 +1,6 @@ ;;; elisp-mode.el --- Emacs Lisp mode -*- lexical-binding:t -*- -;; Copyright (C) 1985-1986, 1999-2015 Free Software Foundation, Inc. +;; Copyright (C) 1985-1986, 1999-2016 Free Software Foundation, Inc. ;; Maintainer: emacs-devel@gnu.org ;; Keywords: lisp, languages @@ -228,9 +228,7 @@ Blank lines separate paragraphs. Semicolons start comments. \\{emacs-lisp-mode-map}" :group 'lisp - (defvar xref-find-function) - (defvar xref-identifier-completion-table-function) - (defvar project-search-path-function) + (defvar project-vc-external-roots-function) (lisp-mode-variables nil nil 'elisp) (add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers) (setq-local electric-pair-text-pairs @@ -239,10 +237,8 @@ Blank lines separate paragraphs. Semicolons start comments. (setq imenu-case-fold-search nil) (add-function :before-until (local 'eldoc-documentation-function) #'elisp-eldoc-documentation-function) - (setq-local xref-find-function #'elisp-xref-find) - (setq-local xref-identifier-completion-table-function - #'elisp--xref-identifier-completion-table) - (setq-local project-search-path-function #'elisp-search-path) + (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) + (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)) @@ -579,8 +575,9 @@ It can be quoted, or be inside a quoted form." " " (cadr table-etc))) (cddr table-etc))))))))) -(define-obsolete-function-alias - 'lisp-completion-at-point 'elisp-completion-at-point "25.1") +(defun lisp-completion-at-point (_predicate) + (declare (obsolete elisp-completion-at-point "25.1")) + (elisp-completion-at-point)) ;;; Xref backend @@ -588,21 +585,7 @@ It can be quoted, or be inside a quoted form." (declare-function xref-make "xref" (summary location)) (declare-function xref-collect-references "xref" (symbol dir)) -(defun elisp-xref-find (action id) - (require 'find-func) - ;; FIXME: use information in source near point to filter results: - ;; (dvc-log-edit ...) - exclude 'feature - ;; (require 'dvc-log-edit) - only 'feature - ;; Semantic may provide additional information - (pcase action - (`definitions - (let ((sym (intern-soft id))) - (when sym - (elisp--xref-find-definitions sym)))) - (`references - (elisp--xref-find-references id)) - (`apropos - (elisp--xref-find-apropos id)))) +(defun elisp--xref-backend () 'elisp) ;; WORKAROUND: This is nominally a constant, but the text properties ;; are not preserved thru dump if use defconst. See bug#21237. @@ -638,7 +621,17 @@ Each function should return a list of xrefs, or nil; the first non-nil result supercedes the xrefs produced by `elisp--xref-find-definitions'.") -;; FIXME: name should be singular; match xref-find-definition +(cl-defmethod xref-backend-definitions ((_backend (eql elisp)) identifier) + (require 'find-func) + ;; FIXME: use information in source near point to filter results: + ;; (dvc-log-edit ...) - exclude 'feature + ;; (require 'dvc-log-edit) - only 'feature + ;; Semantic may provide additional information + ;; + (let ((sym (intern-soft identifier))) + (when sym + (elisp--xref-find-definitions sym)))) + (defun elisp--xref-find-definitions (symbol) ;; The file name is not known when `symbol' is defined via interactive eval. (let (xrefs) @@ -652,6 +645,7 @@ non-nil result supercedes the xrefs produced by ;; alphabetical by result type symbol ;; FIXME: advised function; list of advice functions + ;; FIXME: aliased variable ;; Coding system symbols do not appear in ‘load-history’, ;; so we can’t get a location for them. @@ -801,17 +795,9 @@ non-nil result supercedes the xrefs produced by xrefs)) -(declare-function project-search-path "project") -(declare-function project-current "project") - -(defun elisp--xref-find-references (symbol) - "Find all references to SYMBOL (a string) in the current project." - (cl-mapcan - (lambda (dir) - (xref-collect-references symbol dir)) - (project-search-path (project-current)))) +(declare-function project-external-roots "project") -(defun elisp--xref-find-apropos (regexp) +(cl-defmethod xref-backend-apropos ((_backend (eql elisp)) regexp) (apply #'nconc (let (lst) (dolist (sym (apropos-internal regexp)) @@ -828,7 +814,7 @@ non-nil result supercedes the xrefs produced by (facep sym))) 'strict)) -(defun elisp--xref-identifier-completion-table () +(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql elisp))) elisp--xref-identifier-completion-table) (cl-defstruct (xref-elisp-location @@ -846,9 +832,10 @@ non-nil result supercedes the xrefs produced by (cl-defmethod xref-location-group ((l xref-elisp-location)) (xref-elisp-location-file l)) -(defun elisp-search-path () - (defvar package-user-dir) - (cons package-user-dir load-path)) +(defun elisp-load-path-roots () + (if (boundp 'package-user-dir) + (cons package-user-dir load-path) + load-path)) ;;; Elisp Interaction mode @@ -1116,17 +1103,9 @@ include additional formats for integers \(octal, hexadecimal, and character)." (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) ;; Setup the lexical environment if lexical-binding is enabled. - (prog1 - (elisp--eval-last-sexp-print-value - (eval (eval-sexp-add-defvars (elisp--preceding-sexp)) lexical-binding) - eval-last-sexp-arg-internal) - ;; If we are going to display the result in the echo area, force - ;; a more thorough redisplay, in case the sexp we evaluated - ;; changes something that should affect the display of the - ;; current window. Otherwise, Emacs might decide that only the - ;; echo area needs to be redisplayed. - (if (eq standard-output t) - (force-mode-line-update 'all))))) + (elisp--eval-last-sexp-print-value + (eval (eval-sexp-add-defvars (elisp--preceding-sexp)) lexical-binding) + eval-last-sexp-arg-internal))) (defun elisp--eval-last-sexp-print-value (value &optional eval-last-sexp-arg-internal) (let ((unabbreviated (let ((print-length nil) (print-level nil))