feat(emacs/lean-type): add lean-show-type-add-to-kill-ring option
If a customization option 'lean-show-type-add-to-kill-ring' is non-nil and a user runs 'lean-show-type' by explicitly typing 'C-c C-t', lean-mode saves the displayed type information message into kill-ring , which can be pasted by yank (C-y) command. Close #245
This commit is contained in:
parent
ba24d01dd2
commit
343a9a690e
3 changed files with 21 additions and 4 deletions
|
@ -87,7 +87,7 @@
|
|||
(local-set-key "\C-c\C-l" 'lean-std-exe)
|
||||
(local-set-key "\C-c\C-o" 'lean-set-option)
|
||||
(local-set-key "\C-c\C-e" 'lean-eval-cmd)
|
||||
(local-set-key "\C-c\C-t" 'lean-eldoc-documentation-function)
|
||||
(local-set-key "\C-c\C-t" 'lean-show-type)
|
||||
(local-set-key "\C-c\C-f" 'lean-fill-placeholder)
|
||||
(local-set-key "\M-." 'lean-find-tag)
|
||||
(local-set-key (kbd "TAB") 'lean-tab-indent-or-complete))
|
||||
|
|
|
@ -122,4 +122,11 @@ written."
|
|||
:type 'sexp
|
||||
:risky t)
|
||||
|
||||
(defcustom lean-show-type-add-to-kill-ring nil
|
||||
"If it is non-nil, add the type information to the kill-ring so
|
||||
that user can yank(paste) it later. By default, it's
|
||||
false (nil)."
|
||||
:group 'lean
|
||||
:type 'boolean)
|
||||
|
||||
(provide 'lean-settings)
|
||||
|
|
|
@ -33,13 +33,16 @@
|
|||
(interactive)
|
||||
(lean-get-info-record-at-point 'lean-fill-placeholder-cont))
|
||||
|
||||
(defun lean-eldoc-documentation-function-cont (info-record)
|
||||
(defun lean-eldoc-documentation-function-cont (info-record &optional add-to-kill-ring)
|
||||
"Continuation for lean-eldoc-documentation-function"
|
||||
(let ((info-string (lean-info-record-to-string info-record)))
|
||||
(when info-string
|
||||
(when add-to-kill-ring
|
||||
(kill-new
|
||||
(substring-no-properties info-string)))
|
||||
(message "%s" info-string))))
|
||||
|
||||
(defun lean-eldoc-documentation-function ()
|
||||
(defun lean-eldoc-documentation-function (&optional add-to-kill-ring)
|
||||
"Show information of lean expression at point if any"
|
||||
(interactive)
|
||||
(cond ((and lean-flycheck-use
|
||||
|
@ -50,7 +53,14 @@
|
|||
(not (eolp)))
|
||||
(and (looking-back (rx (not white)))
|
||||
(not (bolp))))
|
||||
(lean-get-info-record-at-point 'lean-eldoc-documentation-function-cont))))
|
||||
(lean-get-info-record-at-point
|
||||
(lambda (info-record)
|
||||
(lean-eldoc-documentation-function-cont info-record add-to-kill-ring))))))
|
||||
|
||||
(defun lean-show-type ()
|
||||
"Show information of lean-expression at point if any."
|
||||
(interactive)
|
||||
(lean-eldoc-documentation-function lean-show-type-add-to-kill-ring))
|
||||
|
||||
;; =======================================================
|
||||
;; eval
|
||||
|
|
Loading…
Reference in a new issue