123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121open!Core_kernelopen!ImportmoduleQ=structincludeQletbounds_of_thing_at_point="bounds-of-thing-at-point"|>Symbol.internandemail="email"|>Symbol.internandfilename="filename"|>Symbol.internandline="line"|>Symbol.internandpage="page"|>Symbol.internandsentence="sentence"|>Symbol.internandurl="url"|>Symbol.internandwhitespace="whitespace"|>Symbol.internandword="word"|>Symbol.internendtypet=|Defun|Email|Filename|Line|List|Number|OtherofSymbol.t|Page|Sentence|Sexp|String_ofof{chars:string}|Symbol|Url|Whitespace|Word[@@derivingsexp_of](* Not giving [t] a [type_] because it's not quite the same as what gets
passed to [thing-at-point]. In particular, [Custom_chars] means to pass
['filename] to [thing-at-point] but set [thing-at-point-file-name-chars]
first. *)letto_symbol=function|Defun->Q.defun|Email->Q.email|Filename->Q.filename|Line->Q.line|List->Q.list|Number->Q.number|Othersym->sym|Page->Q.page|Sentence->Q.sentence|Sexp->Q.sexp(* [chars] is passed separately through the [file_name_chars] variable. *)|String_of_->Q.filename|Symbol->Q.symbol|Url->Q.url|Whitespace->Q.whitespace|Word->Q.word;;letfile_name_chars=Var.Wrap.("thing-at-point-file-name-chars"<:string)letwith_settingst~f=matchtwith|String_of{chars}->Current_buffer.set_value_temporarilySyncfile_name_charschars~f|_->f();;letthing_at_point=Funcall.("thing-at-point"<:Symbol.t@->bool@->return(nil_orText.t));;letfind?(text_properties=false)thing=with_settingsthing~f:(fun()->thing_at_point(thing|>to_symbol)(nottext_properties));;letforward_thing=Funcall.("forward-thing"<:Symbol.t@->int@->returnbool)letforward?(n=1)thing=with_settingsthing~f:(fun()->forward_thing(thing|>to_symbol)n);;letbounds_of_thing_at_point=Funcall.("bounds-of-thing-at-point"<:Symbol.t@->return(nil_or(tuplePosition.tPosition.t)));;letboundsthing=with_settingsthing~f:(fun()->bounds_of_thing_at_point(thing|>to_symbol));;letdid_not_raisefx=matchfxwith|_->true|exception_->false;;letbeginning_of_thing=Funcall.("beginning-of-thing"<:Symbol.t@->returnnil)letbeginning_exnthing=with_settingsthing~f:(fun()->beginning_of_thing(thing|>to_symbol));;letbeginning=did_not_raisebeginning_exnletend_of_thing=Funcall.("end-of-thing"<:Symbol.t@->returnnil)letend_exnthing=with_settingsthing~f:(fun()->end_of_thing(thing|>to_symbol))letend_=did_not_raiseend_exnletbounds_prop=Symbol.Property.createQ.bounds_of_thing_at_pointFunction.tletdefthingsymbolloc~(bounds:unit->(Position.t*Position.t)option)=Symbol.Property.putbounds_propsymbol(Defun.lambda_nullaryloc(ReturnsValue.Type.(nil_or(tuplePosition.tPosition.t)))bounds);Othersymbol;;