SLY: Fix file completion with #f and quote behaviour.
parent
1c62e98ac9
commit
8517e1c7e5
|
@ -202,19 +202,29 @@ Good substitute for `sly-mrepl-indent-and-complete-symbol'."
|
|||
|
||||
(defun ambrevar/complete-cl-file (action &rest _)
|
||||
(interactive (list 'interactive))
|
||||
(cl-case action
|
||||
(interactive (company-begin-backend #'my/complete-cl-file))
|
||||
(candidates
|
||||
(cond ((and (save-match-data (looking-back "#p" (- (point) 2))))
|
||||
(if (looking-at-p "\"")
|
||||
(forward-char)
|
||||
(insert "\"")
|
||||
(save-excursion (insert "\"")))
|
||||
(company-files 'candidates ambrevar/complete-cl-file-prefix))
|
||||
((save-match-data (looking-back "#p\"" (- (point) 3)))
|
||||
(company-files 'candidates ambrevar/complete-cl-file-prefix))))
|
||||
(prefix (and (save-match-data (looking-back "#p\"?")) ""))
|
||||
(t (company-files action))))
|
||||
(cl-flet ((look-back
|
||||
(&key suffix use-limit)
|
||||
(cl-some
|
||||
(lambda (reader-macro)
|
||||
(let ((expr (concat reader-macro suffix)))
|
||||
(looking-back expr
|
||||
(when use-limit
|
||||
(- (point) (length expr))))))
|
||||
;; #f is for FOF.
|
||||
'("#p" "#f"))))
|
||||
(cl-case action
|
||||
(interactive (company-begin-backend #'my/complete-cl-file))
|
||||
(candidates
|
||||
(cond ((and (save-match-data (look-back :use-limit t)))
|
||||
(if (looking-at-p "\"")
|
||||
(company-files 'candidates ambrevar/complete-cl-file-prefix)
|
||||
(mapcar (lambda (s)
|
||||
(concat "\"" s "\""))
|
||||
(company-files 'candidates ambrevar/complete-cl-file-prefix))))
|
||||
((save-match-data (look-back :suffix "\"" :use-limit t))
|
||||
(company-files 'candidates ambrevar/complete-cl-file-prefix))))
|
||||
(prefix (and (save-match-data (look-back :suffix "\"?")) ""))
|
||||
(t (company-files action)))))
|
||||
|
||||
(defun ambrevar/set-sly-company-backends ()
|
||||
(set (make-local-variable 'company-backends)
|
||||
|
|
Loading…
Reference in New Issue