-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c418225
Showing
446 changed files
with
861 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
css/documentation-topic~topic~tutorials-overview.82acfe22.css
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"primaryContentSections":[{"kind":"content","content":[{"anchor":"funcall-and-apply","level":2,"type":"heading","text":"funcall and apply"},{"type":"paragraph","inlineContent":[{"type":"text","text":"Similarly to Emacs Lisp functions "},{"type":"codeVoice","code":"funcall"},{"type":"text","text":" and "},{"type":"codeVoice","code":"apply"},{"type":"text","text":", "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Environment"},{"type":"text","text":" provides methods with the same names with similar semantics. In 99% of the cases you’ll need "},{"type":"codeVoice","code":"funcall"},{"type":"text","text":", which accepts a function to call and whatever arguments you pass with it. Every function has a structure."}]},{"type":"codeListing","syntax":"swift","code":["env.funcall(\"lisp-function\", with: 42, 36.6, true, \"String\", [10, 20, 30])"]},{"type":"paragraph","inlineContent":[{"type":"text","text":"As you can see, it accepts and properly converts native Swift types and values into their Lisp counterparts."},{"type":"text","text":" "},{"type":"text","text":"If something goes wrong on the Emacs side, this call will throw "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsError"},{"type":"text","text":". This can represent any error you usually see in Emacs, "},{"type":"codeVoice","code":"void-function"},{"type":"text","text":" for missing function with that name, or "},{"type":"codeVoice","code":"wrong-type-argument"},{"type":"text","text":", etc."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"The only difference "},{"type":"codeVoice","code":"apply"},{"type":"text","text":" function has over "},{"type":"codeVoice","code":"funcall"},{"type":"text","text":" is that it accepts an array of all of the call arguments as its second argument. So, it can be of use if you construct your arguments list in runtime."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"By default, "},{"type":"codeVoice","code":"funcall"},{"type":"text","text":" and "},{"type":"codeVoice","code":"apply"},{"type":"text","text":" return an opaque "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue"},{"type":"text","text":" (see "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/TypeConversions"},{"type":"text","text":") that represents some dynamically typed Lisp value. All of the values under the hood are "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue"},{"type":"text","text":". However, both of these functions have a bit of generic magic to it, and if the return type should be something different and it is clear from the context, the environment will try to convert it for you."}]},{"type":"paragraph","inlineContent":[{"type":"text","text":"Let’s consider the following example:"}]},{"type":"codeListing","syntax":"swift","code":["let result = try env.funcall(\"format\", with \"%S: %S\", 42, \"42\")"]},{"type":"paragraph","inlineContent":[{"type":"text","text":"This will produce "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue"},{"type":"text","text":", but if we change it to either"}]},{"type":"codeListing","syntax":"swift","code":["let result1: String = try env.funcall(\"format\", with \"%S: %S\", 42, \"42\")","let result2 = try env.funcall(\"format\", with \"%S: %S\", 42, \"42\") as String","acceptsString(try env.funcall(\"format\", with \"%S: %S\", 42, \"42\"))"]},{"type":"paragraph","inlineContent":[{"type":"text","text":"it will get correctly converted into Swift’s own "},{"type":"codeVoice","code":"String"},{"type":"text","text":"."}]}]}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/emacsswiftmodule\/callinglispfunctions"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/CallingLispFunctions","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"Calling Lisp functions from your Swift code."}],"kind":"article","metadata":{"roleHeading":"Article","title":"Calling Lisp Functions","role":"article","modules":[{"name":"EmacsSwiftModule"}]},"hierarchy":{"paths":[["doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule"],["doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Environment"]]},"seeAlsoSections":[{"title":"Getting started","identifiers":["doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/DefiningAModule","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/DefiningLispFunctions","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/TypeConversions","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/ErrorHandling"],"generated":true}],"references":{"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/ErrorHandling":{"role":"article","title":"Error Handling","abstract":[{"type":"text","text":"Handling Lisp errors on Swift side and vice versa."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/ErrorHandling","kind":"article","type":"topic","url":"\/documentation\/emacsswiftmodule\/errorhandling"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/Environment":{"role":"symbol","title":"Environment","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"Environment"}],"abstract":[{"type":"text","text":"Environment is the interaction point with Emacs. If you want to do anything on the Emacs side, you need to have an Environment."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Environment","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Environment"}],"url":"\/documentation\/emacsswiftmodule\/environment"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/EmacsValue":{"role":"symbol","title":"EmacsValue","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"EmacsValue"}],"abstract":[{"type":"text","text":"An opaque Emacs value representing something from the Emacs Lisp world."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"EmacsValue"}],"url":"\/documentation\/emacsswiftmodule\/emacsvalue"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/DefiningLispFunctions":{"role":"article","title":"Defining Lisp Functions","abstract":[{"type":"text","text":"Defining Emacs Lisp functions directly from Swift."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/DefiningLispFunctions","kind":"article","type":"topic","url":"\/documentation\/emacsswiftmodule\/defininglispfunctions"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/EmacsError":{"role":"symbol","title":"EmacsError","fragments":[{"kind":"keyword","text":"enum"},{"kind":"text","text":" "},{"kind":"identifier","text":"EmacsError"}],"abstract":[{"type":"text","text":"The main type representing Emacs errors."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsError","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"EmacsError"}],"url":"\/documentation\/emacsswiftmodule\/emacserror"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule":{"role":"collection","title":"EmacsSwiftModule","abstract":[{"type":"text","text":"A Swift library to write Emacs plugins in Swift!"}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule","kind":"symbol","type":"topic","url":"\/documentation\/emacsswiftmodule"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/DefiningAModule":{"role":"article","title":"Defining a module","abstract":[{"type":"text","text":"Defining a new Emacs module from Swift."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/DefiningAModule","kind":"article","type":"topic","url":"\/documentation\/emacsswiftmodule\/definingamodule"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/TypeConversions":{"role":"article","title":"Type conversions","abstract":[{"type":"text","text":"Converting Swift values into Lisp values and vice versa."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/TypeConversions","kind":"article","type":"topic","url":"\/documentation\/emacsswiftmodule\/typeconversions"}}} |
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
data/documentation/emacsswiftmodule/channel/callback(_:)-1u5q4.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"callback"},{"kind":"text","text":"("},{"kind":"externalParam","text":"_"},{"kind":"text","text":" "},{"kind":"internalParam","text":"function"},{"kind":"text","text":": "},{"kind":"typeIdentifier","identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue","preciseIdentifier":"s:16EmacsSwiftModule0A5ValueC","text":"EmacsValue"},{"kind":"text","text":") -> () -> "},{"kind":"typeIdentifier","text":"Void","preciseIdentifier":"s:s4Voida"}],"languages":["swift"],"platforms":["macOS"]}]},{"kind":"content","content":[{"anchor":"return-value","level":2,"type":"heading","text":"Return Value"},{"type":"paragraph","inlineContent":[{"type":"text","text":"a callback that if called, will eventually call the given function."}]}]},{"kind":"parameters","parameters":[{"name":"function","content":[{"type":"paragraph","inlineContent":[{"type":"text","text":"a Lisp function to turn into a callback."}]}]}]},{"kind":"content","content":[{"anchor":"discussion","level":2,"type":"heading","text":"Discussion"},{"type":"paragraph","inlineContent":[{"type":"text","text":"This allows us to use Emacs functions as callbacks in Swift APIs."},{"type":"text","text":" "},{"type":"text","text":"Please, see "},{"type":"reference","isActive":true,"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/AsyncCallbacks"},{"type":"text","text":" for more details on that."}]}]}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/emacsswiftmodule\/channel\/callback(_:)-1u5q4"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Channel\/callback(_:)-1u5q4","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"Make a Swift callback out of an Emacs function."}],"kind":"symbol","metadata":{"role":"symbol","title":"callback(_:)","roleHeading":"Instance Method","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"callback"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"EmacsValue","preciseIdentifier":"s:16EmacsSwiftModule0A5ValueC"},{"kind":"text","text":") -> () -> "},{"kind":"typeIdentifier","text":"Void","preciseIdentifier":"s:s4Voida"}],"symbolKind":"method","externalID":"s:16EmacsSwiftModule7ChannelC8callbackyyycAA0A5ValueCF","extendedModule":"EmacsSwiftModule","modules":[{"name":"EmacsSwiftModule"}]},"hierarchy":{"paths":[["doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Channel"],["doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Environment","doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Channel"]]},"references":{"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/Channel":{"role":"symbol","title":"Channel","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"Channel"}],"abstract":[{"type":"text","text":"A communication channel that can be used at all times."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Channel","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Channel"}],"url":"\/documentation\/emacsswiftmodule\/channel"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/EmacsValue":{"role":"symbol","title":"EmacsValue","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"EmacsValue"}],"abstract":[{"type":"text","text":"An opaque Emacs value representing something from the Emacs Lisp world."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/EmacsValue","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"EmacsValue"}],"url":"\/documentation\/emacsswiftmodule\/emacsvalue"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/AsyncCallbacks":{"role":"article","title":"Asynchronous Callbacks","abstract":[{"type":"text","text":"Calling Lisp functions without an active Environment."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/AsyncCallbacks","kind":"article","type":"topic","url":"\/documentation\/emacsswiftmodule\/asynccallbacks"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/Environment":{"role":"symbol","title":"Environment","fragments":[{"kind":"keyword","text":"class"},{"kind":"text","text":" "},{"kind":"identifier","text":"Environment"}],"abstract":[{"type":"text","text":"Environment is the interaction point with Emacs. If you want to do anything on the Emacs side, you need to have an Environment."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Environment","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Environment"}],"url":"\/documentation\/emacsswiftmodule\/environment"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule":{"role":"collection","title":"EmacsSwiftModule","abstract":[{"type":"text","text":"A Swift library to write Emacs plugins in Swift!"}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule","kind":"symbol","type":"topic","url":"\/documentation\/emacsswiftmodule"},"doc://EmacsSwiftModule/documentation/EmacsSwiftModule/Channel/callback(_:)-1u5q4":{"role":"symbol","title":"callback(_:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"callback"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"EmacsValue","preciseIdentifier":"s:16EmacsSwiftModule0A5ValueC"},{"kind":"text","text":") -> () -> "},{"kind":"typeIdentifier","text":"Void","preciseIdentifier":"s:s4Voida"}],"abstract":[{"type":"text","text":"Make a Swift callback out of an Emacs function."}],"identifier":"doc:\/\/EmacsSwiftModule\/documentation\/EmacsSwiftModule\/Channel\/callback(_:)-1u5q4","kind":"symbol","type":"topic","url":"\/documentation\/emacsswiftmodule\/channel\/callback(_:)-1u5q4"}}} |
Oops, something went wrong.