feat(emacs): add lean-fill-placeholder (C-c C-f)
This commit is contained in:
parent
3e2e6702ba
commit
a4e8389695
3 changed files with 32 additions and 1 deletions
|
@ -50,3 +50,14 @@ Put the following elisp code on your emacs setup:
|
|||
(customize-set-variable 'lean-rule-color "#ff0000")
|
||||
(customize-set-variable 'lean-delete-trailing-whitespace t)
|
||||
```
|
||||
|
||||
Key Bindings
|
||||
------------
|
||||
|
||||
|Key | Function |
|
||||
|-------------------|-----------------------------------|
|
||||
|<kbd>C-c C-x</kbd> | lean-std-exe |
|
||||
|<kbd>C-c C-l</kbd> | lean-std-exe |
|
||||
|<kbd>C-c C-k</kbd> | lean-hott-exe |
|
||||
|<kbd>C-c C-t</kbd> | lean-eldoc-documentation-function |
|
||||
|<kbd>C-c C-f</kbd> | lean-fill-placeholder |
|
||||
|
|
|
@ -47,7 +47,8 @@
|
|||
(local-set-key "\C-c\C-x" 'lean-std-exe)
|
||||
(local-set-key "\C-c\C-l" 'lean-std-exe)
|
||||
(local-set-key "\C-c\C-k" 'lean-hott-exe)
|
||||
(local-set-key "\C-c\C-t" 'lean-eldoc-documentation-function))
|
||||
(local-set-key "\C-c\C-t" 'lean-eldoc-documentation-function)
|
||||
(local-set-key "\C-c\C-f" 'lean-fill-placeholder))
|
||||
|
||||
(define-abbrev-table 'lean-mode-abbrev-table '(
|
||||
("var" "variable")
|
||||
|
|
|
@ -86,6 +86,25 @@ The return valus has the form of '([symbol-string] [start-pos])"
|
|||
(output-str (concat type-output-str overload-output-str)))
|
||||
(message "%s" output-str))))
|
||||
|
||||
(defun lean-fill-placeholder ()
|
||||
"Fill the placeholder with a synthesized expression by Lean."
|
||||
(interactive)
|
||||
(let ((cur_char (buffer-substring-no-properties (point) (1+ (point)))))
|
||||
(when (string= cur_char "_")
|
||||
(let* ((file-name (buffer-file-name))
|
||||
(line-number (line-number-at-pos))
|
||||
(column (current-column))
|
||||
(sym-info (lean-get-current-sym-info))
|
||||
(sym-name (cl-first sym-info))
|
||||
(start-pos (cl-second sym-info))
|
||||
(start-column (- column (- (point) start-pos)))
|
||||
typeinfo overload)
|
||||
(cl-multiple-value-setq (typeinfo overload synth)
|
||||
(lean-extract-info-at-pos file-name line-number column start-pos))
|
||||
(when synth
|
||||
(delete-forward-char 1)
|
||||
(insert (concat "(" (lean-synth-body-str synth) ")")))))))
|
||||
|
||||
(defun lean-eldoc-documentation-function ()
|
||||
"Show information of lean expression at point if any"
|
||||
(interactive)
|
||||
|
|
Loading…
Reference in a new issue