Commit graph

150 commits

Author SHA1 Message Date
Dmitry Gutov
62d5d46551 Add `project-ignores'
* lisp/progmodes/project.el (project-ignores): New generic
function, and an implementation for the	VC project type.

* lisp/progmodes/xref.el (xref--rgrep-command): Split, as a
variant of rgrep-default-command that handles a generic list of
ignores.
(xref-collect-matches): Use it, and pass through to it the value
of the newly added argument.
(xref-find-regexp): Handle ignored paths within the project.
Remove outdated comment.

* lisp/vc/vc.el (vc-default-ignore-completion-table):
Skip the comments and the empty lines.
2015-07-12 17:19:08 +03:00
Dmitry Gutov
d6c2b34e9e Bind grep-highlight-matches to nil
* lisp/progmodes/xref.el (xref-collect-matches):
Bind grep-highlight-matches to nil (bug#20728).
2015-07-11 18:56:42 +03:00
Dmitry Gutov
53cf3cfec1 Don't check the exit status, it can be misleading
* lisp/progmodes/xref.el (xref-collect-matches): Don't check the
exit status, it can be misleading.
2015-07-10 04:40:09 +03:00
Dmitry Gutov
f8c720b55b Introduce a Project API
* lisp/progmodes/project.el: New file.

* lisp/cedet/ede.el: (project-try-ede): New function.
(project-root): New implementation.

* lisp/progmodes/elisp-mode.el (emacs-lisp-mode):
Set project-search-path-function.
(elisp--xref-find-references): Delegate some logic to
project-search-path.
(elisp-search-path): New function.
(elisp-xref-find): Don't implement `matches' anymore.

* lisp/progmodes/etags.el: Don't implement `matches'.
Delegate some logic to project-search-path.
(etags-search-path): New function.

* lisp/progmodes/xref.el (xref-find-function):
Remove `matches' from the API.
(xref-find-regexp): Move whatever common logic was in elisp and
etags implementations, and search the directories returned by
project-directories and project-search-path.
2015-07-10 04:40:09 +03:00
Dmitry Gutov
c7e9792565 Syntax-propertize until the end of the line first
* lisp/progmodes/xref.el (xref--collect-match): Syntax-propertize
until the end of the line first.
2015-07-09 15:30:33 +03:00
Dmitry Gutov
15fafa34d0 * lisp/progmodes/xref.el (xref-collect-matches): Use `nreverse' in the end. 2015-07-09 05:15:50 +03:00
Dmitry Gutov
9b4b4a8355 Add --color Grep option to the command dynamically
* lisp/progmodes/grep.el (grep-template, grep-find-template):
Update the description for <C>.  (Bug#20728)
(grep-compute-defaults): Don't add the --color option to
grep-options.  Only add it to grep-command.
(grep-expand-keywords): Expand the env value opts into <C>.
(grep-expand-template): Replace cf in the env with the opts list,
that can include -i and --color.

* lisp/progmodes/xref.el (xref-collect-matches): Do not remove
"--color=always" from the template, because we don't have to.
2015-06-27 23:57:28 +03:00
Stefan Monnier
4fba36ce11 * lisp/progmodes/xref.el: Avoid init-args in oref.
* lisp/progmodes/xref.el (xref-location-group, xref-location-marker)
(xref--insert-xrefs, xref-collect-references): Avoid init-args in oref.
2015-06-24 16:32:09 -04:00
Dmitry Gutov
6d020ecd89 Override 'grep --color=always'
* lisp/progmodes/xref.el (xref-collect-matches):
Override --color=always in grep-find-template.
2015-06-04 02:46:43 +03:00
Dmitry Gutov
c6ee95ddee Restore <D> instead of '.' in grep-find-template
* lisp/cedet/semantic/symref/grep.el
(semantic-symref-grep-use-template): Update a comment.

* lisp/progmodes/grep.el (grep-compute-defaults): Restore <D>
instead of '.' in grep-find-template (bug#20719).
(rgrep): Pass nil as the directory to rgrep-default-command.

* lisp/progmodes/grep.el (grep-expand-keywords): Use '.' as the
default value for DIR.

* lisp/progmodes/xref.el (xref-collect-matches): Drop the
workaround.
2015-06-03 05:45:15 +03:00
Dmitry Gutov
7f01832e13 Reuse rgrep mechanics in xref-find-regexp
* lisp/progmodes/grep.el (rgrep-default-command):
Extract from `rgrep'.

* lisp/progmodes/xref.el (xref-collect-references): Split from
`xref-collect-matches'.  Only handle the case of symbol search.
(xref-collect-matches): Instead of Semantic Symref, use
`rgrep-default-command', to take advantage of its directory and
file ignore settings.
(xref--collect-match): Remove the last argument, leaving the
regexp construction up to the caller.

* lisp/progmodes/elisp-mode.el (elisp--xref-find-matches):
Change to take the xref-collect- function to use as an argument.
(elisp-xref-find): Update accordingly.

* lisp/progmodes/etags.el (etags--xref-find-matches)
(etags-xref-find): Same.
2015-06-02 18:47:43 +03:00
Dmitry Gutov
64f2d346b7 Move xref-elisp-location to elisp-mode.el
* lisp/progmodes/xref.el (xref-elisp-location)
(xref-make-elisp-location, xref-location-marker): Remove here.
(xref--xref): Don't limit the type of the location slot.

* lisp/progmodes/elisp-mode.el (xref-elisp-location):
Define as a cl-struct here.
(xref-location-marker): Move here.
2015-06-02 18:47:42 +03:00
Dmitry Gutov
d86ef9fc4a xref-prompt-for-identifier: Use a list value
* lisp/progmodes/xref.el (xref-prompt-for-identifier): Allow list
value, to be interpreted as a list of commands.
(xref--prompt-p): New function.
(xref--read-identifier): Use it.
2015-05-26 19:28:38 +03:00
Stefan Monnier
8994590317 * lisp/progmodes/xref.el (xref-find-apropos): Use read-string. 2015-05-23 12:05:47 -04:00
Dmitry Gutov
089632800a Add xref-find-regexp
* lisp/progmodes/xref.el (xref-find-function): Describe the
`matches' action.
(xref-find-regexp): New command, using it.
(xref-collect-references): Rename to xref-collect-matches.
(xref--collect-reference): Rename to xref--collect-match.
(xref-collect-matches, xref--collect-match): Accept new argument,
KIND.  Update accordingly.
(xref--regexp-to-extended): New function.

* lisp/progmodes/elisp-mode.el (elisp-xref-find): Support the
`matches' action.
(elisp--xref-find-matches): Accept new argument.  Resolve a FIXME.

* lisp/progmodes/etags.el (etags-xref-find):
Support the `matches' action.
(etags--xref-find-matches): New function.
2015-05-11 02:07:27 +03:00
Dmitry Gutov
f96313f110 Don't require match
* lisp/progmodes/xref.el (xref--read-identifier): Don't require
match. That doesn't work for every command, and some identifier
completion tables are bound to be imperfect anyway.
2015-05-06 05:58:23 +03:00
Dmitry Gutov
6337f2434e ; Update a comment 2015-05-05 05:17:35 +03:00
Dmitry Gutov
ca717aa0fd Buttonize the whole line, including the number at the beginning
* lisp/progmodes/xref.el (xref--location-at-point): Revert the
previous change.
(xref--insert-xrefs): Buttonize the whole line, including the
number at the beginning.
2015-05-05 05:14:01 +03:00
Dmitry Gutov
9fa69f6b14 Insert, highlight and align line numbers in xref output
* lisp/progmodes/etags.el (xref-location-line): Specialize for
xref-etags-location.

* lisp/progmodes/xref.el (xref-location-line): New generic method.
(xref-file-location): Add reader for the line slot.
(xref--location-at-point): Skip to the `xref-location' property.
(xref--collect-reference): Drop the line number from description.
(xref--insert-xrefs): Insert, highlight and align line numbers.
2015-05-05 02:59:34 +03:00
Dmitry Gutov
943c45f68b Don't pulse the indentation, or the newline
* lisp/cedet/pulse.el (pulse-lighten-highlight)
(pulse-reset-face): Fall back to the inherited background
attribute in FACE.
(pulse-momentary-highlight-region): Add autoload cookie.

* lisp/progmodes/xref.el (xref--maybe-pulse): Don't highlight the
indentation, or the newline, if the line's non-empty
(http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00118.html).
2015-05-04 23:24:36 +03:00
Dmitry Gutov
14c1d2106c Add xref-pulse-on-jump
* lisp/cedet/pulse.el (pulse-momentary-highlight-one-line):
Add autoload cookie.

* lisp/progmodes/xref.el (xref-pulse-on-jump): New option.
(xref--maybe-pulse): New function.
(xref-pop-marker-stack, xref--pop-to-location)
(xref--display-position): Use it.
(xref--location-at-point): Use back-to-indentation.
2015-05-04 18:51:48 +03:00
Dmitry Gutov
b7bb71c801 ; xref--insert-xrefs: Add (require 'compile) 2015-05-04 02:52:16 +03:00
Dmitry Gutov
bcfdfd2568 xref--insert-xrefs: Tweak the faces
* lisp/progmodes/xref.el (xref--insert-xrefs): Tweak the faces.
Always insert a newline at the end (to avoid mouse-face background
tail at the last line).
2015-05-04 00:39:06 +03:00
Dmitry Gutov
c50499edab ; * xref.el (xref-collect-references): Simplify. 2015-05-02 01:04:26 +03:00
Dmitry Gutov
fed6a0d6b1 Implement xref-find-references in etags and elisp-mode
* lisp/progmodes/elisp-mode.el (elisp--xref-find-references): New function.
(elisp-xref-find): Use it.

* lisp/progmodes/etags.el (etags-xref-find): Use `xref-collect-references'.

* lisp/progmodes/xref.el (xref-collect-references):
(xref--collect-reference): New functions.
2015-05-01 23:41:27 +03:00
Helmut Eller
fa175b4495 Set next-error-* in xref--xref-buffer-mode
* xref.el (xref--xref-buffer-mode): Set `next-error-function' and
`next-error-last-buffer'.
(xref--next-error-function): New function.
(http://lists.gnu.org/archive/html/emacs-devel/2015-04/msg01311.html)
2015-04-30 03:41:42 +03:00
Dmitry Gutov
2f3b409a28 Introduce xref-prompt-for-identifier
* lisp/progmodes/xref.el (xref-prompt-for-identifier): New option.
(xref--read-identifier): Use it
(http://lists.gnu.org/archive/html/emacs-devel/2015-04/msg01205.html).
2015-04-26 18:08:56 +03:00
Dmitry Gutov
fddff05e88 Pass id' to completing-read' as def instead of initial input
* xref.el (xref--read-identifier): Pass `id' to `completing-read'
as the default value instead of initial input
(http://lists.gnu.org/archive/html/emacs-devel/2015-04/msg01182.html).
2015-04-26 06:39:34 +03:00
Leo Liu
85c3e1be24 * lisp/progmodes/xref.el (xref-push-marker-stack): Add optional arg. 2015-04-17 12:32:33 +08:00
Dmitry Gutov
f6bb2ccb9b Introduce `xref-etags-mode'
Fixes: debbugs:19466

* lisp/progmodes/xref.el (xref-etags-mode--saved): New variable.
(xref-etags-mode): New minor mode.
2015-02-23 04:00:01 +02:00
Dmitry Gutov
03346fb074 xref: Replace defgeneric and defmethod with cl- counterparts
* lisp/progmodes/xref.el (xref-location-marker, xref-location-group):
Use `cl-defgeneric' and `cl-defmethod' instead of the EIEIO
counterparts.

* lisp/progmodes/etags.el (xref-location-marker): Same.
2015-01-22 04:24:31 +02:00
Dmitry Gutov
a17a5daebf xref: Input history and minor tweaks
* lisp/progmodes/xref.el (xref--current): Rename from `xref--selected'.
(xref--inhibit-mark-current): Rename from
`xref--inhibit-mark-selected'.  Update the usages.
(xref-quit): Reword the docstring.  Kill buffers after quitting
windows instead of before.
(xref--insert-xrefs): Tweak help-echo.
(xref--read-identifier-history, xref--read-pattern-history):
New variables.
(xref--read-identifier, xref-find-apropos): Use them.
2015-01-22 04:09:23 +02:00
Dmitry Gutov
e7697d9763 Remap quit-window to xref-quit in xref buffers
Fixes: debbugs:19466

* lisp/progmodes/xref.el (xref--xref-buffer-mode-map): Define before
the major mode.  Remap `quit-window' to `xref-quit'.
(xref--xref-buffer-mode): Inherit from special-mode.
2015-01-21 09:20:04 +02:00
Dmitry Gutov
956b13c527 xref: Keep track of temporary buffers
Fixes: debbugs:19466

xref: Keep track of temporary buffers.
* lisp/progmodes/xref.el (xref--temporary-buffers, xref--selected)
(xref--inhibit-mark-selected): New variables.
(xref--mark-selected): New function.
(xref--show-location): Maybe add the buffer to
`xref--temporary-buffers', add `xref--mark-selected' to
`buffer-list-update-hook' there.
(xref--window): Add docstring.
(xref-quit): Rename from `xref--quit'.  Update both references.
Add KILL argument.  When it's non-nil, kill the temporary buffers
that haven't been selected by the user.
(xref--show-xref-buffer): Change the second argument to alist,
extract the values for `xref--window' and
`xref--temporary-buffers' from it.  Add `xref--mark-selected' to
`buffer-list-update-hook' to each buffer in the list.
(xref--show-xrefs): Move the logic of calling `xref-find-function'
here.  Save the difference between buffer lists before and after
it's called as "temporary buffers", and `pass it to
`xref-show-xrefs-function'.
(xref--find-definitions, xref-find-references)
(xref-find-apropos): Update accordingly.
2015-01-21 08:43:39 +02:00
Dmitry Gutov
3ca37be9e7 Expand xref help-echo string
* lisp/progmodes/xref.el (xref--insert-xrefs): Expand help-echo string.
2015-01-20 04:52:48 +02:00
Dmitry Gutov
05fb53a16c Use etags-goto-tag-location in etags xref backend
* progmodes/etags.el (xref-etags-location): New class.
(xref-make-etags-location): New function.
(etags--xref-find-definitions): Use it.
(xref-location-marker): New method implementation.

* lisp/progmodes/xref.el: Mention that xref-location is an EIEIO class.
2015-01-20 04:32:25 +02:00
Dmitry Gutov
9592a014df xref: Use other-window-scroll-buffer and user-error
* lisp/progmodes/xref.el (xref--display-position):
Set `other-window-scroll-buffer'.
(xref-goto-xref): Use `user-error'.
2015-01-19 05:29:37 +02:00
Dmitry Gutov
36bfd6947f Use quit-window to hide buffers temporarily displayed by xref
* lisp/progmodes/xref.el (xref--display-history): New variable.
(xref--window-configuration): Remove.
(xref--save-to-history): New function.
(xref--display-position): Use it.  Add new argument.
(xref--restore-window-configuration): Remove.
(xref--show-location, xref-show-location-at-point): Update
accordingly.
(xref--xref-buffer-mode): Don't use `pre-command-hook'.
(xref--quit): New command.
(xref-goto-xref): Use it.
(xref--xref-buffer-mode-map): Bind `q' to it.
2015-01-19 04:19:32 +02:00
Dmitry Gutov
b87d7cc249 Perform xref jump even inside indentation or at eol
* lisp/progmodes/xref.el (xref-goto-xref): Perform xref jump even inside
indentation or at eol.
2015-01-19 01:11:25 +02:00
Martin Rudalics
cc59a3e577 Add autoload cookie for xref-marker-stack-empty-p (Bug#19554).
* progmodes/xref.el (xref-marker-stack-empty-p): Add autoload
cookie (Bug#19554).
2015-01-12 18:26:39 +01:00
Dmitry Gutov
f5afaf9ce7 Add help-echo to xrefs
* lisp/progmodes/xref.el (xref--insert-xrefs): Add `help-echo' property
to the references.
2015-01-06 02:47:58 +03:00
Dmitry Gutov
c477f20730 Add mouse interaction to xref
* lisp/progmodes/xref.el (xref--button-map): New variable.
(xref--mouse-2): New command.
(xref--insert-xrefs): Add `mouse-face' and `keymap' properties to
the inserted references.
2015-01-05 02:45:30 +03:00
Dmitry Gutov
8bef7b6ad1 Only show "Back" when the marker stack is non-empty
* lisp/menu-bar.el (menu-bar-goto-menu): Use it.

* lisp/progmodes/xref.el (xref-marker-stack-empty-p): New function.
2015-01-03 23:10:36 +02:00
Dmitry Gutov
5496236583 Don't remap next-line' and previous-line' in xref keymap
* lisp/progmodes/xref.el (xref--window-configuration): New variable.
(xref-show-location-at-point): New command.
(xref--restore-window-configuration): New function.
(xref-next-line, xref-prev-line): Delegate to
`xref-show-location-at-point'.
(xref--location-at-point): Don't signal the error.
(xref-goto-xref): Do that here instead.
(xref--xref-buffer-mode): Add `xref--restore-window-configuration'
to `pre-command-hook'.
(xref--xref-buffer-mode-map): Don't remap `next-line' and
`previous-line'.  Additionally bind `xref-next-line' and
`xref-prev-line' to `n' and `p' respectively.  Bind
`xref-show-location-at-point' to `C-o'.
2015-01-03 23:10:36 +02:00
Paul Eggert
7e09ef09a4 Update copyright year to 2015
Run admin/update-copyright.
2015-01-01 14:26:41 -08:00
Dmitry Gutov
0d7f85fbca (xref-find-definitions): Mention "no identifier at point" case
* lisp/progmodes/xref.el (xref-find-definitions): Mention "no
identifier at point" case in the docstring.
2014-12-30 21:54:03 +02:00
Dmitry Gutov
6d14e0d361 elisp-xref-find: Don't create buffers eagerly
* lisp/emacs-lisp/find-func.el (find-function-library): New function,
extracted from `find-function-noselect'.

* lisp/progmodes/elisp-mode.el (elisp--identifier-location): Fold back
into `elisp--company-location'.
(elisp--identifier-completion-table): Rename to
`elisp--identifier-completion-table', and do not include just any
symbols with a property list.
(elisp-completion-at-point): Revert the 2014-12-25 change.
(elisp--xref-identifier-file): New function.
(elisp--xref-find-definitions): Use it.

* lisp/progmodes/xref.el (xref-elisp-location): New class.
(xref-make-elisp-location): New function.
(xref-location-marker): New implementation.
2014-12-27 16:07:31 +02:00
Dmitry Gutov
807c3413c4 Add basic xref apropos implementation to elisp-mode
* lisp/progmodes/elisp-mode.el (elisp--xref-find-definitions):
Filter out nil results.
(elisp--xref-find-apropos): New function.
(elisp-xref-find): Use it.

* lisp/progmodes/xref.el (xref--show-xrefs): Use `user-error'.
2014-12-26 18:34:47 +02:00
Paul Eggert
b3946c9b9a Spelling fixes 2014-12-25 18:19:28 -08:00
Dmitry Gutov
394ce9514f Consolidate cross-referencing commands
Move autoloaded bindings for `M-.', `M-,', `C-x 4 .' and
`C-x 5 .' from etags.el to xref.el.

* progmodes/xref.el: New file.

* progmodes/elisp-mode.el (elisp--identifier-types): New variable.
(elisp--identifier-location): New function, extracted from
`elisp--company-location'.
(elisp--company-location): Use it.
(elisp--identifier-completion-table): New variable.
(elisp-completion-at-point): Use it.
(emacs-lisp-mode): Set the local values of `xref-find-function'
and `xref-identifier-completion-table-function'.
(elisp-xref-find, elisp--xref-find-definitions)
(elisp--xref-identifier-completion-table): New functions.

* progmodes/etags.el (find-tag-marker-ring): Mark obsolete in
favor of `xref--marker-ring'.
(tags-lazy-completion-table): Autoload.
(tags-reset-tags-tables): Use `xref-clear-marker-stack'.
(find-tag-noselect): Use `xref-push-marker-stack'.
(pop-tag-mark): Make an alias for `xref-pop-marker-stack'.
(etags--xref-limit): New constant.
(etags-xref-find, etags--xref-find-definitions): New functions.
2014-12-25 22:19:28 +02:00