1
1
module REPLCompletions
2
2
3
- export completions, shell_completions, latex_completions
3
+ export completions, shell_completions, bslash_completions
4
4
5
5
using Base. Meta
6
6
@@ -236,6 +236,7 @@ function complete_methods(ex_org::Expr)
236
236
end
237
237
238
238
include (" latex_symbols.jl" )
239
+ include (" emoji_symbols.jl" )
239
240
240
241
const non_identifier_chars = [" \t\n\r\"\\ '`\$ ><=:;|&{}()[],+-*/?%^~" ... ]
241
242
const whitespace_chars = [" \t\n\r " ... ]
@@ -253,17 +254,26 @@ function afterusing(string::ByteString, startpos::Int)
253
254
return ismatch (r" ^\b (using|import)\s *(\w +\s *,\s *)*\w *$" , str[fr: end ])
254
255
end
255
256
256
- function latex_completions (string, pos)
257
+ function bslash_completions (string, pos)
257
258
slashpos = rsearch (string, ' \\ ' , pos)
258
- if rsearch (string, whitespace_chars, pos) < slashpos && ! (1 < slashpos && (string[prevind (string, slashpos)]== ' \\ ' ))
259
- # latex symbol substitution
259
+ if (rsearch (string, whitespace_chars, pos) < slashpos &&
260
+ ! (1 < slashpos && (string[prevind (string, slashpos)]== ' \\ ' )))
261
+ # latex / emoji symbol substitution
260
262
s = string[slashpos: pos]
261
263
latex = get (latex_symbols, s, " " )
262
264
if ! isempty (latex) # complete an exact match
263
265
return (true , ([latex], slashpos: pos, true ))
264
- else
265
- # return possible matches; these cannot be mixed with regular
266
- # Julian completions as only latex symbols contain the leading \
266
+ end
267
+ emoji = get (emoji_symbols, s, " " )
268
+ if ! isempty (emoji)
269
+ return (true , ([emoji], slashpos: pos, true ))
270
+ end
271
+ # return possible matches; these cannot be mixed with regular
272
+ # Julian completions as only latex / emoji symbols contain the leading \
273
+ if startswith (s, " \\ :" ) # emoji
274
+ emoji_names = filter (k -> startswith (k, s), keys (emoji_symbols))
275
+ return (true , (sort! (collect (emoji_names)), slashpos: pos, true ))
276
+ else # latex
267
277
latex_names = filter (k -> startswith (k, s), keys (latex_symbols))
268
278
return (true , (sort! (collect (latex_names)), slashpos: pos, true ))
269
279
end
@@ -290,9 +300,10 @@ function completions(string, pos)
290
300
(success || inc_tag== :cmd ) && return sort (paths), r, success
291
301
end
292
302
293
- ok, ret = latex_completions (string, pos)
303
+ ok, ret = bslash_completions (string, pos)
294
304
ok && return ret
295
- # Make sure that only latex_completions is working on strings
305
+
306
+ # Make sure that only bslash_completions is working on strings
296
307
inc_tag== :string && return UTF8String[], 0 : - 1 , false
297
308
298
309
if inc_tag == :other && should_method_complete (partial)
0 commit comments