Julia에는 함수 구현을 읽는 데 매우 편리한 @edit
, @less
등이 있습니다. 그러나 코드 위치를 찾기 위해서는 "충분히 좋은" (유형) 매개변수 세트를 지정해야 합니다.
대신 InteractiveCodeSearch
읽고 싶은 코드를 대화형으로 선택할 수 있는 몇 가지 매크로를 제공합니다.
@search show
, 함수 호출 표현 @search show(stdout, "hello")
, 함수 호출 서명 @search show(::IO, ::String)
, 모듈 이름 @search Base
, 인수 값 @searchmethods 1
및 인수 유형 @searchmethods ::Int
. using InteractiveCodeSearch
@search show # search method definitions
@searchmethods 1 # search methods defined for integer
@searchhistory # search history (Julia ≥ 0.7)
대화형 매칭 명령. 예를 들어:
@search
@search x [:shallow | :s | :recursive | :r]
대화형 일치자에서 x
정의된 파일 위치를 나열한 다음 편집기에서 선택한 위치를 엽니다.
x
모듈인 경우 최상위 정의만 검색됩니다. 서브모듈의 모든 정의를 검색하려면 :recursive
또는 :r
플래그를 전달하십시오.
@search
표현식이 제공되지 않으면 이전 실행에서 반환된 메서드를 검색합니다. 즉, x
기본값은 ans
입니다.
예
@search show # all method definitions
@search @time # all macro definitions
@search Base . Enums # methods and macros in a module
@search REPL :r # search the module recursively
@search * ( :: Integer , :: Integer ) # methods with specified types
@search dot (π, ℯ) # methods with inferred types
@search
는 .
및 []
다음과 같이 반환된 값이나 유형을 검색합니다.
@search Base . Multimedia . displays[ 2 ] . repl
@searchmethods
@searchmethods x
@searchmethods ::X
methodswith(typeof(x))
또는 methodswith(X)
통해 대화형으로 검색합니다.
예
@searchmethods 1 # search methods defined for integer
@searchmethods :: Int # search methods defined for a specified type
@searchhistory
@searchhistory
대화형으로 기록을 검색하세요. REPL 기록에서 찾고 있는 코드를 대화형으로 좁힙니다.
IJulia의 제한/기능 : IJulia에서 @searchhistory
현재 IJulia 세션의 기록이 아닌 터미널 REPL의 기록을 검색합니다.
InteractiveCodeSearch.CONFIG
InteractiveCodeSearch
에 대한 구성 인터페이스입니다.
예
using InteractiveCodeSearch
InteractiveCodeSearch . CONFIG . interactive_matcher = ` fzf ... ` # default in terminal
InteractiveCodeSearch . CONFIG . interactive_matcher = ` peco `
InteractiveCodeSearch . CONFIG . interactive_matcher = ` percol `
InteractiveCodeSearch . CONFIG . interactive_matcher =
` rofi -dmenu -i -p "?" ` # use GUI matcher (default in non-terminal
# environment like IJulia)
InteractiveCodeSearch . CONFIG . interactive_matcher =
` rofi -dmenu -i -p "?" -fullscreen ` # bigger screen
InteractiveCodeSearch . CONFIG . open = edit # default
InteractiveCodeSearch . CONFIG . open = less # use Base.less to read code
InteractiveCodeSearch . CONFIG . auto_open = true # default
InteractiveCodeSearch . CONFIG . auto_open = false # open matcher even when there
# is only one candidate
InteractiveCodeSearch . CONFIG . trigger_key = ' ) ' # insert "@search" on ')' (default)
InteractiveCodeSearch . CONFIG . trigger_key = nothing # disable shortcut
기본적으로 InteractiveCodeSearch.jl 사용
~/.julia/config/startup.jl
(≥ Julia 0.7) 또는 ~/.juliarc.jl
(Julia 0.6)에 다음 코드를 입력하세요.
using InteractiveCodeSearch
# InteractiveCodeSearch.CONFIG.interactive_matcher = ...