feature/lookup: fix OTHER-WINDOW arg

For +lookup/definition, +lookup/references and +lookup/documentation.
This commit is contained in:
Henrik Lissner 2018-10-21 17:53:23 -04:00
parent 54749d04e6
commit 9337c3f8c3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -87,21 +87,30 @@ properties:
((require 'xref nil t) ((require 'xref nil t)
(xref-backend-identifier-at-point (xref-find-backend))))) (xref-backend-identifier-at-point (xref-find-backend)))))
(defun +lookup--jump-to (prop identifier) (defun +lookup--jump-to (prop identifier &optional other-window)
(cl-loop with origin = (point-marker) (cl-loop with origin = (point-marker)
for fn in (plist-get (list :definition +lookup-definition-functions for fn
:references +lookup-references-functions in (plist-get (list :definition +lookup-definition-functions
:documentation +lookup-documentation-functions :references +lookup-references-functions
:file +lookup-file-functions) :documentation +lookup-documentation-functions
prop) :file +lookup-file-functions)
prop)
for cmd = (or (command-remapping fn) fn) for cmd = (or (command-remapping fn) fn)
if (condition-case e if (condition-case e
(or (if (commandp cmd) (save-window-excursion
(call-interactively cmd) (when (or (if (commandp cmd)
(funcall cmd identifier)) (call-interactively cmd)
(/= (point-marker) origin)) (funcall cmd identifier))
('error (ignore (message "%s" e)))) (/= (point-marker) origin))
return it)) (point-marker)))
(error (ignore (message "%s" e))))
return
(progn
(funcall (if other-window
#'pop-to-buffer
#'pop-to-buffer-same-window)
(marker-buffer it))
(goto-char it))))
(defun +lookup--file-search (identifier) (defun +lookup--file-search (identifier)
(unless identifier (unless identifier
@ -220,7 +229,7 @@ evil-mode is active."
(cond ((null identifier) (user-error "Nothing under point")) (cond ((null identifier) (user-error "Nothing under point"))
((and +lookup-definition-functions ((and +lookup-definition-functions
(+lookup--jump-to :definition identifier))) (+lookup--jump-to :definition identifier other-window)))
((error "Couldn't find the definition of '%s'" identifier)))) ((error "Couldn't find the definition of '%s'" identifier))))
@ -236,7 +245,7 @@ search otherwise."
(cond ((null identifier) (user-error "Nothing under point")) (cond ((null identifier) (user-error "Nothing under point"))
((and +lookup-references-functions ((and +lookup-references-functions
(+lookup--jump-to :references identifier))) (+lookup--jump-to :references identifier other-window)))
((error "Couldn't find references of '%s'" identifier)))) ((error "Couldn't find references of '%s'" identifier))))
@ -254,7 +263,7 @@ Goes down a list of possible backends:
(cond ((null identifier) (user-error "Nothing under point")) (cond ((null identifier) (user-error "Nothing under point"))
((and +lookup-documentation-functions ((and +lookup-documentation-functions
(+lookup--jump-to :documentation identifier))) (+lookup--jump-to :documentation identifier other-window)))
((user-error "Couldn't find documentation for '%s'" identifier)))) ((user-error "Couldn't find documentation for '%s'" identifier))))