lang/emacs-lisp: improve +emacs-lisp/find-function (other-window/popup support)
This commit is contained in:
parent
59d2e71e04
commit
6d6da0e9aa
2 changed files with 16 additions and 18 deletions
|
@ -3,25 +3,24 @@
|
||||||
;; ---- emacs-lisp ---------------------------------------------------
|
;; ---- emacs-lisp ---------------------------------------------------
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +emacs-lisp/find-function ()
|
(defun +emacs-lisp/find-function (&optional arg)
|
||||||
"Jump to the definition of the function at point."
|
"Jump to the definition of the function at point. If ARG (the prefix) is
|
||||||
(interactive)
|
non-nil, the function will be revealed in another window. If ARG is 16 (C-u
|
||||||
(let ((func (function-called-at-point)))
|
C-u), then reveal the function in a popup window."
|
||||||
(if func (find-function func))))
|
(interactive "p")
|
||||||
|
(when-let (func (function-called-at-point))
|
||||||
;;;###autoload
|
(cond ((= arg 16)
|
||||||
(defun +emacs-lisp/find-function-other-window ()
|
(let ((buf (find-function-noselect func t)))
|
||||||
"Jump to the definition of the function at point in a popup window."
|
(doom-popup-buffer (car buf) :align t :size 30 :select t)
|
||||||
(interactive)
|
(goto-char (cdr buf))))
|
||||||
(let ((fn (function-called-at-point)))
|
((> arg 1)
|
||||||
(when fn
|
(find-function-other-window func))
|
||||||
(find-function-do-it
|
(t
|
||||||
fn nil
|
(find-function func)))))
|
||||||
(lambda (buffer)
|
|
||||||
(select-window (doom-popup-buffer buffer :size 30)))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +emacs-lisp/repl ()
|
(defun +emacs-lisp/repl ()
|
||||||
|
"Open an ielm REPL for Emacs Lisp."
|
||||||
(interactive)
|
(interactive)
|
||||||
(ielm)
|
(ielm)
|
||||||
(let ((buf (current-buffer)))
|
(let ((buf (current-buffer)))
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(map! :map emacs-lisp-mode-map
|
(map! :map emacs-lisp-mode-map
|
||||||
:m "gd" '+emacs-lisp/find-function
|
:m "gd" '+emacs-lisp/find-function)
|
||||||
:leader :m "gd" '+emacs-lisp/find-function-in-other-window)
|
|
||||||
|
|
||||||
(set! :rotate 'emacs-lisp-mode
|
(set! :rotate 'emacs-lisp-mode
|
||||||
:symbols '(("t" "nil")
|
:symbols '(("t" "nil")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue