ไปที่คำจำกัดความของสัญลักษณ์ ณ จุด สนับสนุนคำจำกัดความทั่วโลกคำจำกัดความท้องถิ่นและแม้กระทั่งรหัสมหภาคที่หนักหน่วง!

elisp-def วิเคราะห์รหัสของคุณและกลับไปที่ฮิวริสติกซึ่งเป็นไปไม่ได้ ควรทำงาน 99% ของเวลาดังนั้นโปรดยื่นข้อบกพร่องหากไม่พบคำจำกัดความสำหรับรหัสของคุณ
ติดตั้งจาก Melpa จากนั้นเพิ่มสิ่งต่อไปนี้ในการกำหนดค่า EMACS ของคุณ:
( dolist (hook '(emacs-lisp-mode-hook ielm-mode-hook))
( add-hook hook # 'elisp-def-mode )) elisp-def จะพบคำจำกัดความของฟังก์ชั่นทั่วโลกและตัวแปรทั่วโลก ณ จุด
( defun demo/foo ()
1 )
( defun demo/bar ()
; ; M-x eval-buffer, then elisp-def on this:
(demo/foo))นอกจากนี้ยังจะใช้ข้อมูล EDEBUG เพื่อค้นหาคำจำกัดความของฟังก์ชั่นดังนั้นจึงพบคำจำกัดความบ่อยกว่า XREF
elisp-def เข้าใจความแตกต่างระหว่างสัญลักษณ์และฟังก์ชั่นและกระโดดไปยังคำจำกัดความที่ถูกต้อง
( require 'cc-mode )
; ; `c-version' is both a variable and a function.
( defun demo/foo ()
; ; `elisp-def` will find the function here.
( c-version ))
( defun demo/foo ()
; ; `elisp-def` will find the variable here.
( setq c-version t )) elisp-def เข้าใจมาโครดังนั้นจึงสามารถตรวจจับการอ้างอิงฟังก์ชั่นได้อย่างถูกต้อง
( require 'dash )
( defvar demo/foo nil )
( defun demo/foo ( x )
x)
( defun demo/bar ()
(-> > 123
; ; `elisp-def' knows that this is a function, even though there are
; ; no parens.
demo/foo))นอกจากนี้ยังสามารถเข้าใจแมโครที่กำหนดฟังก์ชั่นหรือตัวแปร
( define-derived-mode demo/foo-mode fundamental-mode " demo " )
; ; `elisp-def' will expand macros to discover where major mode hooks
; ; are defined.
demo/foo-mode-hook
( cl-defstruct demo/point x y)
; ; `elisp-def' can find this function even though the defstruct
; ; call doesn't contain this symbol name.
(make-demo/point 1 2 ) elisp-def จะพบห้องสมุดแสดงการประกาศ provide หากเป็นไปได้
; ; `elisp-def' will open python.el here.
( require 'python )
; ; Unlike `xref-find-definition' , `elisp-def' will not confuse this
; ; library name with the macro named `use-package' .
( require 'use-package )
; ; `elisp-def' will even find python.el here, because the macro
; ; expands to a call to `require' .
( use-package python
:config
( setq python-indent-guess-indent-offset-verbose nil )) elisp-def เข้าใจการผูกและพารามิเตอร์ในท้องถิ่น
( defun demo/foo ( bar )
( let ((foo 1 ))
; ; `elisp-def' on the FOO below will move point to the let
; ; binding.
( setq foo 2 )
; ; `elisp-def' on the BAR below will move point to the function
; ; parameters line.
( setq bar 3 )))
( defun demo/bar ()
( let* ((foo 1 )
(bar 2 )
(foo 3 )
; ; `elisp-def' on the second FOO on the following line will
; ; move point to the relevant binding, which is the line
; ; immediately above.
(foo ( + foo 1 ))
(foo 5 ))
nil ))สิ่งนี้ใช้งานได้กับแมโครที่แนะนำการผูก
( require 'dash )
( eval-when-compile
( require 'cl-lib ))
( defun demo/foo ( items )
( cl-destructuring-bind ( first second) items
; ; `elisp-def' knowns that FIRST is bound on line above.
( message " first is %s " first))
(-let [( first . rest) items]
; ; `elisp-def' knowns that FIRST is bound on line above.
( message " first is %s " first))) elisp-def ช่วยให้คุณสามารถวางจุดบนสัญลักษณ์ที่ยกมาสัญลักษณ์เอกสารหรือสัญลักษณ์ backquoted
( defun demo/foo ( x )
; ; `elisp-def' on X in the docstring will find the parameter.
" Adds one to X and returns it. "
( 1+ x))
( defun demo/bar ()
; ; `elisp-def' can find demo/foo even when point is on the #.
( funcall # 'demo/foo 1 )
; ; `elisp-def' on demo/foo below will find the function.
; ;
; ; See `demo/foo' for more information.
nil )
( defun demo/baz ( foo )
; ; `elisp-def' understands that @ is not part of foo here.
`(blah ,@foo ))เมื่อพบสัญลักษณ์ ELISP-DEF จะเน้นชั่วคราวเพื่อการมองเห็น
elisp-def มีข้อ จำกัด ในความสามารถในการวิเคราะห์สัญลักษณ์ที่ยกมา
; ; `elisp-def' is able to find these quoted symbols because they're
; ; only globally bound in one namespace.
( mapcar 'symbol-name '(foo bar baz))
( add-to-list 'auto-mode-alist '( " \ .java \ ' " . java-mode))
( require 'cc-mode )
( defun demo/calls-fn ( sym )
( funcall sym))
; ; Since `c-version' is both a function and a variable, and we're not
; ; using a sharp-quote #'c-version, we have to prompt the user.
(demo/calls-fn 'c-version )
( defun demo/foo ( c-version )
; ; Here we have no idea whether we're using `c-version' as a
; ; function (e.g. funcall), as a variable (e.g. set) or as a
; ; parameter (e.g. eval).
(bar 'c-version nil )) elisp-def ไม่สามารถค้นหาคำจำกัดความในมาโครที่มีความหมาย let* และตัวแปรที่ซ้ำกัน
( require 'dash )
( defun demo/foo ()
(-let ((x 1 )
(x 2 ))
; ; `elisp-def' on X below will move to the first X binding, rather
; ; than the second.
x)) elisp-def ยังไม่สามารถจัดการกับมาโครที่เขียนรูปแบบใหม่ได้ว่าสัญลักษณ์จะหายไปอย่างสิ้นเชิง
( eval-when-compile ( require 'cl-lib ))
( cl-labels ((foo (x y) ( + x y)))
; ; `cl-labels' completely rewrites this body to (--cl-foo-- 1 2), so
; ; `elisp-def' can't find the definition of FOO.
(foo 1 2 ))elisp-slime-nav-find-elisp-thing-at-point จาก elisp-slime-navxref-find-definitions ใน emacs-lisp-mode (ส่วนหนึ่งของ Emacs Core)semantic-ia-fast-jump จาก semantic/ia.el (รวมอยู่ใน emacs) คนดีใน #emacs สำหรับตอบคำถามของฉันเกี่ยวกับ Elisp Esoterica โดยเฉพาะ Wasamasa
ไลบรารีคำชมสำหรับการสร้างความสำเร็จของ Clojure มีความคิดเกี่ยวกับบริบทซึ่งคล้ายกับวิธีการแยกและการวิเคราะห์แบบฟอร์ม ELISP-DEF
Hacklang มีความคิดที่คล้ายกันของตัวยึดตำแหน่งสำหรับการวิเคราะห์ความสำเร็จ ณ จุดหนึ่งในรหัส
GPLV3+
ฉันกำลังให้รหัสในที่เก็บให้คุณภายใต้ใบอนุญาตโอเพ่นซอร์ส เพราะนี่คือที่เก็บส่วนตัวของฉันใบอนุญาตที่คุณได้รับมาจากรหัสของฉันมาจากฉันไม่ใช่นายจ้างของฉัน