2014-09-09 21:06:30 +00:00
|
|
|
;;; lean-mode.el --- Emacs mode for Lean theorem prover
|
2014-08-07 15:02:04 +00:00
|
|
|
;;
|
2014-09-09 21:06:30 +00:00
|
|
|
;; Copyright (c) 2013, 2014 Microsoft Corporation. All rights reserved.
|
2015-07-28 01:39:56 +00:00
|
|
|
;; Copyright (c) 2015, 2014 Soonho Kong. All rights reserved.
|
2014-08-07 15:02:04 +00:00
|
|
|
;;
|
2014-09-09 21:06:30 +00:00
|
|
|
;; Author: Leonardo de Moura <leonardo@microsoft.com>
|
|
|
|
;; Soonho Kong <soonhok@cs.cmu.edu>
|
|
|
|
;; Maintainer: Soonho Kong <soonhok@cs.cmu.edu>
|
|
|
|
;; Created: Jan 09, 2014
|
2014-09-01 00:47:09 +00:00
|
|
|
;; Keywords: languages
|
|
|
|
;; Version: 0.1
|
2014-09-09 21:06:30 +00:00
|
|
|
;; URL: https://github.com/leanprover/lean/blob/master/src/emacs
|
|
|
|
;;
|
|
|
|
;; Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
;;
|
2014-10-31 22:23:45 +00:00
|
|
|
(require 'pcase)
|
2014-09-09 22:01:00 +00:00
|
|
|
(require 'lean-require)
|
2014-08-30 18:43:33 +00:00
|
|
|
(require 'eri)
|
2014-08-14 00:02:49 +00:00
|
|
|
(require 'lean-variable)
|
2014-08-07 15:02:04 +00:00
|
|
|
(require 'lean-util)
|
|
|
|
(require 'lean-settings)
|
|
|
|
(require 'lean-flycheck)
|
|
|
|
(require 'lean-input)
|
2014-08-14 00:02:49 +00:00
|
|
|
(require 'lean-type)
|
2014-08-16 03:48:30 +00:00
|
|
|
(require 'lean-tags)
|
2014-09-01 00:46:40 +00:00
|
|
|
(require 'lean-option)
|
2014-08-18 20:32:58 +00:00
|
|
|
(require 'lean-syntax)
|
2014-09-02 17:33:19 +00:00
|
|
|
(require 'lean-mmm-lua)
|
2014-09-04 22:46:41 +00:00
|
|
|
(require 'lean-company)
|
2014-09-12 21:22:39 +00:00
|
|
|
(require 'lean-changes)
|
2014-09-10 19:45:19 +00:00
|
|
|
(require 'lean-server)
|
2014-09-10 22:18:26 +00:00
|
|
|
(require 'lean-project)
|
2014-08-07 15:02:04 +00:00
|
|
|
|
|
|
|
(defun lean-compile-string (exe-name args file-name)
|
|
|
|
"Concatenate exe-name, args, and file-name"
|
2014-11-05 14:20:14 +00:00
|
|
|
(format "%s %s %s" exe-name args file-name))
|
2014-01-09 19:45:31 +00:00
|
|
|
|
2014-08-14 00:02:49 +00:00
|
|
|
(defun lean-create-temp-in-system-tempdir (file-name prefix)
|
2014-08-07 15:02:04 +00:00
|
|
|
"Create a temp lean file and return its name"
|
2014-07-28 00:03:06 +00:00
|
|
|
(make-temp-file (or prefix "flymake") nil ".lean"))
|
|
|
|
|
2014-07-29 17:57:52 +00:00
|
|
|
(defun lean-execute (&optional arg)
|
2014-01-09 19:45:31 +00:00
|
|
|
"Execute Lean in the current buffer"
|
2014-09-15 16:47:00 +00:00
|
|
|
(interactive)
|
|
|
|
(setq arg (concat (lean-option-string) " " arg))
|
|
|
|
(when (called-interactively-p)
|
|
|
|
(setq arg (read-string "arg: " arg)))
|
2014-08-07 15:02:04 +00:00
|
|
|
(let ((target-file-name
|
2014-08-14 00:02:49 +00:00
|
|
|
(or
|
|
|
|
(buffer-file-name)
|
|
|
|
(flymake-init-create-temp-buffer-copy 'lean-create-temp-in-system-tempdir))))
|
2014-08-07 15:02:04 +00:00
|
|
|
(compile (lean-compile-string
|
2015-04-16 23:24:42 +00:00
|
|
|
(shell-quote-argument (f-full (lean-get-executable lean-executable-name)))
|
2014-08-13 22:05:46 +00:00
|
|
|
(or arg "")
|
2015-04-16 23:24:42 +00:00
|
|
|
(shell-quote-argument (f-full target-file-name))))))
|
2014-07-29 17:57:52 +00:00
|
|
|
|
2015-07-28 01:39:56 +00:00
|
|
|
(defvar g-lean-exec-at-pos-buf ""
|
|
|
|
"Temp buffer to save the output from lean server (for lean-exec-at-pos)")
|
|
|
|
|
|
|
|
(defun lean-exec-at-pos-extract-body (str)
|
|
|
|
"Extract the body of LEAN_INFORMATION"
|
2015-07-28 18:13:31 +00:00
|
|
|
(let ((header "LEAN_INFORMATION")
|
|
|
|
(footer "END_LEAN_INFORMATION"))
|
|
|
|
(cond
|
|
|
|
((and (s-contains? header str)
|
|
|
|
(s-contains? footer str))
|
|
|
|
(let*
|
|
|
|
((begin-regex (eval `(rx line-start ,header (* not-newline) line-end)))
|
|
|
|
(end-regex (eval `(rx line-start (group ,footer) line-end)))
|
|
|
|
(pre-body-post
|
|
|
|
(lean-server-split-buffer str begin-regex end-regex))
|
|
|
|
(body (cadr pre-body-post))
|
|
|
|
(lines (s-lines body)))
|
|
|
|
(s-join "\n" (-butlast (-drop 1 lines)))))
|
|
|
|
(t ""))))
|
2015-07-28 01:39:56 +00:00
|
|
|
|
2015-07-27 20:15:56 +00:00
|
|
|
(defun lean-exec-at-pos-sentinel (process event)
|
|
|
|
"Sentinel function used for lean-exec-at-pos. It does the two
|
|
|
|
things: A. display the process buffer, B. scroll to the top"
|
|
|
|
(when (eq (process-status process) 'exit)
|
|
|
|
(let ((b (process-buffer process)))
|
2015-07-28 01:39:56 +00:00
|
|
|
(with-current-buffer b
|
2015-07-28 03:26:28 +00:00
|
|
|
(lean-info-mode)
|
2015-07-28 01:39:56 +00:00
|
|
|
(insert-string (lean-exec-at-pos-extract-body
|
|
|
|
g-lean-exec-at-pos-buf)))
|
2015-07-27 20:15:56 +00:00
|
|
|
(display-buffer b)
|
|
|
|
;; Temporary Hack to scroll to the top
|
|
|
|
;; See https://github.com/leanprover/lean/issues/499#issuecomment-125285231
|
|
|
|
(set-window-point (get-buffer-window b) 0))))
|
|
|
|
|
2015-07-28 01:39:56 +00:00
|
|
|
(defun lean-exec-at-pos-filter (process string)
|
|
|
|
"Filter function for lean-exec-at-pos. It append the string to
|
|
|
|
g-lean-exec-at-pos-buf variable"
|
|
|
|
(setq g-lean-exec-at-pos-buf (s-append string g-lean-exec-at-pos-buf)))
|
|
|
|
|
2015-03-24 18:57:49 +00:00
|
|
|
(defun lean-exec-at-pos (process-name process-buffer-name &rest options)
|
|
|
|
"Execute Lean by providing current position with optional
|
|
|
|
agruments. The output goes to 'process-buffer-name' buffer, which
|
|
|
|
will be flushed everytime it's executed."
|
2015-07-28 01:39:56 +00:00
|
|
|
(setq g-lean-exec-at-pos-buf "")
|
2015-03-24 18:57:49 +00:00
|
|
|
;; Kill process-name if exists
|
|
|
|
(let ((current-process (get-process process-name)))
|
|
|
|
(when current-process
|
|
|
|
(kill-process)))
|
|
|
|
;; Flush process-buffer
|
|
|
|
(let ((process-buffer (get-buffer process-buffer-name)))
|
|
|
|
(when process-buffer
|
|
|
|
(with-current-buffer process-buffer
|
|
|
|
(erase-buffer))))
|
|
|
|
;; Start process
|
|
|
|
(let* ((target-file-name
|
|
|
|
(or
|
|
|
|
;; Only use file-name if the current buffer is not modified
|
|
|
|
(and (not (buffer-modified-p)) (buffer-file-name))
|
|
|
|
(flymake-init-create-temp-buffer-copy 'lean-create-temp-in-system-tempdir)))
|
|
|
|
(cache-file-name
|
|
|
|
(s-concat (f-no-ext target-file-name)
|
|
|
|
".clean"))
|
|
|
|
(cache-option
|
|
|
|
;; Cache is only used when we use a non-temporary file
|
|
|
|
(if (s-equals? (buffer-file-name) target-file-name)
|
|
|
|
`("--cache" ,cache-file-name)
|
|
|
|
'()))
|
|
|
|
(lean-mode-option
|
|
|
|
(pcase (lean-choose-minor-mode-based-on-extension)
|
|
|
|
(`standard "--lean")
|
|
|
|
(`hott "--hlean")))
|
|
|
|
(process-args (append `(,process-name
|
|
|
|
,process-buffer-name
|
|
|
|
,(lean-get-executable lean-executable-name)
|
|
|
|
,lean-mode-option
|
|
|
|
"--line"
|
|
|
|
,(int-to-string (line-number-at-pos))
|
|
|
|
"--col"
|
|
|
|
,(int-to-string (current-column)))
|
|
|
|
options
|
|
|
|
cache-option
|
|
|
|
`(,target-file-name)))
|
|
|
|
(p (apply 'start-process process-args)))
|
2015-07-28 01:39:56 +00:00
|
|
|
(set-process-filter p 'lean-exec-at-pos-filter)
|
2015-07-27 20:15:56 +00:00
|
|
|
(set-process-sentinel p 'lean-exec-at-pos-sentinel)
|
2015-03-24 18:57:49 +00:00
|
|
|
(set-process-coding-system p 'utf-8 'utf-8)
|
2015-07-27 20:15:56 +00:00
|
|
|
(set-process-query-on-exit-flag p nil)))
|
2015-03-24 18:57:49 +00:00
|
|
|
|
2015-07-28 21:16:13 +00:00
|
|
|
(defun lean-show-goal-at-pos ()
|
|
|
|
"Show goal at the current point. If the current point is a
|
|
|
|
placeholder, call lean-server with --hole option, otherwise call
|
|
|
|
lean-server with --goal option"
|
|
|
|
(interactive)
|
|
|
|
(cond ((and (eq (char-after) ?_) ;; 1. at _
|
|
|
|
(not (lean-in-comment-p)) ;; 2. not in comment
|
|
|
|
(or (bolp) ;; 3. either beginning of line
|
|
|
|
(let ((cb (char-before))) ;; or whitespace
|
|
|
|
(or (char-equal cb ?\s)
|
|
|
|
(char-equal cb ?\t)
|
|
|
|
(char-equal cb ?\n)
|
2015-07-29 05:11:35 +00:00
|
|
|
(char-equal cb ?\r)))))
|
2015-07-28 21:16:13 +00:00
|
|
|
(lean-exec-at-pos "lean-hole" "*Lean Goal*" "--hole"))
|
|
|
|
(t
|
2015-07-29 05:11:35 +00:00
|
|
|
(lean-exec-at-pos "lean-goal" "*Lean Goal*" "--goal"))))
|
2015-07-28 21:16:13 +00:00
|
|
|
|
2014-07-29 17:57:52 +00:00
|
|
|
(defun lean-std-exe ()
|
|
|
|
(interactive)
|
|
|
|
(lean-execute))
|
|
|
|
|
2014-08-30 18:43:33 +00:00
|
|
|
(defun lean-check-expansion ()
|
2014-09-08 23:03:44 +00:00
|
|
|
(interactive)
|
2014-08-30 18:43:33 +00:00
|
|
|
(save-excursion
|
2014-09-08 23:03:44 +00:00
|
|
|
(if (looking-at (rx symbol-start "_")) t
|
|
|
|
(if (looking-at "\\_>") t
|
2014-08-30 18:43:33 +00:00
|
|
|
(backward-char 1)
|
2014-09-08 23:03:44 +00:00
|
|
|
(if (looking-at "\\.") t
|
|
|
|
(backward-char 1)
|
|
|
|
(if (looking-at "->") t nil))))))
|
2014-08-30 18:43:33 +00:00
|
|
|
|
2014-09-29 19:49:00 +00:00
|
|
|
(defun lean-tab-indent ()
|
|
|
|
(cond ((looking-back (rx line-start (* white)))
|
|
|
|
(eri-indent))
|
|
|
|
(t (indent-for-tab-command))))
|
|
|
|
|
2014-08-30 18:43:33 +00:00
|
|
|
(defun lean-tab-indent-or-complete ()
|
|
|
|
(interactive)
|
|
|
|
(if (minibufferp)
|
|
|
|
(minibuffer-complete)
|
2014-09-15 06:07:17 +00:00
|
|
|
(cond ((and lean-company-use (company-lean--check-prefix))
|
|
|
|
(company-complete-common))
|
2014-09-29 19:49:00 +00:00
|
|
|
(lean-company-use (lean-tab-indent))
|
2014-09-14 07:00:25 +00:00
|
|
|
((lean-check-expansion)
|
|
|
|
(completion-at-point-functions))
|
2014-09-29 19:49:00 +00:00
|
|
|
(t (lean-tab-indent)))))
|
2014-08-30 18:43:33 +00:00
|
|
|
|
2014-01-09 19:45:31 +00:00
|
|
|
(defun lean-set-keys ()
|
2014-09-02 21:02:35 +00:00
|
|
|
(local-set-key "\C-c\C-x" 'lean-std-exe)
|
|
|
|
(local-set-key "\C-c\C-l" 'lean-std-exe)
|
2014-11-07 22:28:21 +00:00
|
|
|
(local-set-key "\C-c\C-k" 'quail-show-key)
|
2014-09-02 21:02:35 +00:00
|
|
|
(local-set-key "\C-c\C-o" 'lean-set-option)
|
|
|
|
(local-set-key "\C-c\C-e" 'lean-eval-cmd)
|
2014-10-14 16:27:25 +00:00
|
|
|
(local-set-key "\C-c\C-t" 'lean-show-type)
|
2014-09-02 21:02:35 +00:00
|
|
|
(local-set-key "\C-c\C-f" 'lean-fill-placeholder)
|
2014-11-05 01:16:33 +00:00
|
|
|
(local-set-key "\C-c\C-r" 'lean-server-restart-process)
|
2014-09-02 21:02:35 +00:00
|
|
|
(local-set-key "\M-." 'lean-find-tag)
|
2015-07-28 00:40:56 +00:00
|
|
|
(local-set-key (kbd "TAB") 'lean-tab-indent-or-complete)
|
2015-07-28 21:16:13 +00:00
|
|
|
(lean-define-key-binding "\C-c\C-g" '(lean-show-goal-at-pos)))
|
2014-01-08 11:25:05 +00:00
|
|
|
|
2015-03-24 18:57:49 +00:00
|
|
|
(defun lean-define-key-binding (key cmd)
|
|
|
|
(local-set-key key `(lambda () (interactive) ,cmd)))
|
|
|
|
|
2014-08-18 20:32:58 +00:00
|
|
|
(define-abbrev-table 'lean-abbrev-table
|
2014-11-26 22:50:10 +00:00
|
|
|
'())
|
2014-01-10 03:57:00 +00:00
|
|
|
|
2014-09-01 00:47:53 +00:00
|
|
|
(defvar lean-mode-map (make-sparse-keymap)
|
|
|
|
"Keymap used in Lean mode")
|
|
|
|
|
|
|
|
(easy-menu-define lean-mode-menu lean-mode-map
|
|
|
|
"Menu for the Lean major mode"
|
|
|
|
`("Lean"
|
|
|
|
["Execute lean" lean-execute t]
|
2014-09-10 22:18:26 +00:00
|
|
|
["Create a new project" (call-interactively 'lean-project-create) (not (lean-project-inside-p))]
|
2014-09-01 00:47:53 +00:00
|
|
|
"-----------------"
|
2015-03-05 19:42:59 +00:00
|
|
|
["Show type info" lean-show-type (and lean-eldoc-use eldoc-mode)]
|
2014-09-01 00:47:53 +00:00
|
|
|
["Fill a placeholder" lean-fill-placeholder (looking-at (rx symbol-start "_"))]
|
|
|
|
["Find tag at point" lean-find-tag t]
|
2014-09-15 16:47:33 +00:00
|
|
|
["Global tag search" lean-global-search t]
|
2014-09-01 00:47:53 +00:00
|
|
|
"-----------------"
|
2015-03-05 19:42:59 +00:00
|
|
|
["Run flycheck" flycheck-compile (and lean-flycheck-use flycheck-mode)]
|
|
|
|
["List of errors" flycheck-list-errors (and lean-flycheck-use flycheck-mode)]
|
2014-09-01 00:47:53 +00:00
|
|
|
"-----------------"
|
2014-10-03 16:47:03 +00:00
|
|
|
["Clear all cache" lean-clear-cache t]
|
2014-09-01 00:47:53 +00:00
|
|
|
["Kill lean process" lean-server-kill-process t]
|
|
|
|
["Restart lean process" lean-server-restart-process t]
|
|
|
|
"-----------------"
|
2015-03-05 19:33:57 +00:00
|
|
|
("Configuration"
|
2015-03-05 19:42:59 +00:00
|
|
|
["Use flycheck (on-the-fly syntax check)"
|
|
|
|
lean-toggle-flycheck-mode :active t :style toggle :selected flycheck-mode]
|
|
|
|
["Show type at point"
|
|
|
|
lean-toggle-eldoc-mode :active t :style toggle :selected eldoc-mode])
|
2015-03-05 19:33:57 +00:00
|
|
|
"-----------------"
|
2014-09-01 00:47:53 +00:00
|
|
|
["Customize lean-mode" (customize-group 'lean) t]))
|
|
|
|
|
2014-08-25 20:31:44 +00:00
|
|
|
(defconst lean-hooks-alist
|
|
|
|
'(
|
|
|
|
;; Handle events that may start automatic syntax checks
|
2014-11-09 05:21:43 +00:00
|
|
|
(before-save-hook . lean-whitespace-cleanup)
|
2014-09-10 19:45:19 +00:00
|
|
|
(after-save-hook . lean-server-after-save)
|
2014-08-25 20:31:44 +00:00
|
|
|
;; ;; Handle events that may triggered pending deferred checks
|
2014-08-27 00:15:53 +00:00
|
|
|
;; (window-configuration-change-hook . lean-perform-deferred-syntax-check)
|
|
|
|
;; (post-command-hook . lean-perform-deferred-syntax-check)
|
|
|
|
;; ;; Teardown Lean whenever the buffer state is about to get lost, to
|
2014-08-25 20:31:44 +00:00
|
|
|
;; ;; clean up temporary files and directories.
|
2014-08-27 00:15:53 +00:00
|
|
|
;; (kill-buffer-hook . lean-teardown)
|
|
|
|
;; (change-major-mode-hook . lean-teardown)
|
2014-09-12 21:22:39 +00:00
|
|
|
(before-revert-hook . lean-before-revert)
|
|
|
|
(after-revert-hook . lean-after-revert)
|
2014-08-25 20:31:44 +00:00
|
|
|
;; ;; Update the error list if necessary
|
2014-08-27 00:15:53 +00:00
|
|
|
;; (post-command-hook . lean-error-list-update-source)
|
|
|
|
;; (post-command-hook . lean-error-list-highlight-errors)
|
2014-08-25 20:31:44 +00:00
|
|
|
;; ;; Show or hide error popups after commands
|
2014-08-27 00:15:53 +00:00
|
|
|
;; (post-command-hook . lean-display-error-at-point-soon)
|
|
|
|
;; (post-command-hook . lean-hide-error-buffer)
|
2014-08-21 16:09:54 +00:00
|
|
|
)
|
2014-09-04 22:46:41 +00:00
|
|
|
"Hooks which lean-mode needs to hook in.
|
2014-08-21 16:09:54 +00:00
|
|
|
|
2014-08-25 20:31:44 +00:00
|
|
|
The `car' of each pair is a hook variable, the `cdr' a function
|
|
|
|
to be added or removed from the hook variable if Flycheck mode is
|
|
|
|
enabled and disabled respectively.")
|
2014-08-21 16:09:54 +00:00
|
|
|
|
2014-10-30 06:57:54 +00:00
|
|
|
(when lean-follow-changes
|
|
|
|
(add-to-list 'lean-hooks-alist '(after-change-functions . lean-after-change-function))
|
|
|
|
(add-to-list 'lean-hooks-alist '(before-change-functions . lean-before-change-function)))
|
|
|
|
|
2014-08-25 20:31:44 +00:00
|
|
|
(defun lean-mode-setup ()
|
|
|
|
"Default lean-mode setup"
|
|
|
|
;; Flycheck
|
2014-09-05 23:08:54 +00:00
|
|
|
(when lean-flycheck-use
|
|
|
|
(lean-flycheck-turn-on)
|
2014-09-15 17:11:39 +00:00
|
|
|
(setq-local flycheck-disabled-checkers '(lua))
|
2014-09-05 23:08:54 +00:00
|
|
|
(add-hook 'flycheck-after-syntax-check-hook 'lean-flycheck-delete-temporaries nil t))
|
2014-08-25 20:31:44 +00:00
|
|
|
;; Draw a vertical line for rule-column
|
|
|
|
(when (and lean-rule-column
|
|
|
|
lean-show-rule-column-method)
|
|
|
|
(cl-case lean-show-rule-column-method
|
|
|
|
('vline (require 'fill-column-indicator)
|
|
|
|
(setq fci-rule-column lean-rule-column)
|
|
|
|
(setq fci-rule-color lean-rule-color)
|
|
|
|
(fci-mode t))))
|
|
|
|
;; eldoc
|
|
|
|
(when lean-eldoc-use
|
|
|
|
(set (make-local-variable 'eldoc-documentation-function)
|
|
|
|
'lean-eldoc-documentation-function)
|
2014-09-10 21:13:17 +00:00
|
|
|
(eldoc-mode t))
|
2014-08-25 20:31:44 +00:00
|
|
|
;; company-mode
|
|
|
|
(when lean-company-use
|
2014-09-15 17:22:31 +00:00
|
|
|
(company-lean-hook))
|
|
|
|
;; mmm-lua-mode
|
2015-02-10 16:16:08 +00:00
|
|
|
(lean-mmm-lua-hook)
|
|
|
|
;; choose minor mode -- Standard / HoTT
|
|
|
|
(let ((minor-mode (lean-choose-minor-mode-based-on-extension)))
|
|
|
|
(cond
|
|
|
|
((eq minor-mode 'hott) (lean-hott-mode) )
|
|
|
|
((eq minor-mode 'standard) (lean-standard-mode)))))
|
|
|
|
|
|
|
|
;; Define Minor mode
|
|
|
|
;; - Standard
|
|
|
|
;; - HoTT
|
|
|
|
(define-minor-mode lean-standard-mode
|
|
|
|
"Minor mode for standard Lean."
|
|
|
|
:init-value nil
|
|
|
|
:lighter " [Standard]"
|
|
|
|
:group 'lean
|
|
|
|
:require 'lean)
|
|
|
|
|
|
|
|
(define-minor-mode lean-hott-mode
|
|
|
|
"Minor mode for HoTT Lean."
|
|
|
|
:init-value nil
|
|
|
|
:lighter " [HoTT]"
|
|
|
|
:group 'lean
|
|
|
|
:require 'lean)
|
2014-08-25 20:31:44 +00:00
|
|
|
|
|
|
|
;; Automode List
|
|
|
|
;;;###autoload
|
|
|
|
(define-derived-mode lean-mode prog-mode "Lean"
|
2014-09-01 00:47:53 +00:00
|
|
|
"Major mode for Lean
|
|
|
|
\\{lean-mode-map}
|
|
|
|
Invokes `lean-mode-hook'.
|
|
|
|
"
|
2014-08-25 20:31:44 +00:00
|
|
|
:syntax-table lean-syntax-table
|
|
|
|
:abbrev-table lean-abbrev-table
|
|
|
|
:group 'lean
|
2014-08-30 03:08:29 +00:00
|
|
|
(set (make-local-variable 'comment-start) "--")
|
2014-08-25 20:31:44 +00:00
|
|
|
(set (make-local-variable 'comment-start-skip) "[-/]-[ \t]*")
|
|
|
|
(set (make-local-variable 'comment-end) "")
|
|
|
|
(set (make-local-variable 'comment-end-skip) "[ \t]*\\(-/\\|\\s>\\)")
|
|
|
|
(set (make-local-variable 'comment-padding) 1)
|
|
|
|
(set (make-local-variable 'comment-use-syntax) t)
|
|
|
|
(set (make-local-variable 'font-lock-defaults) lean-font-lock-defaults)
|
|
|
|
(set (make-local-variable 'indent-tabs-mode) nil)
|
2014-10-07 09:27:52 +00:00
|
|
|
(set 'compilation-mode-font-lock-keywords '())
|
2014-08-25 20:31:44 +00:00
|
|
|
(set-input-method "Lean")
|
|
|
|
(set (make-local-variable 'lisp-indent-function)
|
|
|
|
'common-lisp-indent-function)
|
|
|
|
(lean-set-keys)
|
2015-06-02 05:31:08 +00:00
|
|
|
(if (fboundp 'electric-indent-local-mode)
|
|
|
|
(electric-indent-local-mode -1))
|
2014-12-04 01:21:45 +00:00
|
|
|
;; (abbrev-mode 1)
|
2014-08-25 20:31:44 +00:00
|
|
|
(pcase-dolist (`(,hook . ,fn) lean-hooks-alist)
|
|
|
|
(add-hook hook fn nil 'local))
|
|
|
|
(lean-mode-setup))
|
2014-08-18 20:32:58 +00:00
|
|
|
|
2014-08-27 00:15:53 +00:00
|
|
|
;;; Automatically update TAGS file without asking
|
|
|
|
(setq tags-revert-without-query t)
|
|
|
|
|
2014-08-18 20:32:58 +00:00
|
|
|
;; Automatically use lean-mode for .lean files.
|
|
|
|
;;;###autoload
|
|
|
|
(push '("\\.lean$" . lean-mode) auto-mode-alist)
|
2014-12-05 21:09:23 +00:00
|
|
|
(push '("\\.hlean$" . lean-mode) auto-mode-alist)
|
2014-08-25 20:31:44 +00:00
|
|
|
|
2014-08-18 20:32:58 +00:00
|
|
|
;; Use utf-8 encoding
|
2014-08-18 23:10:07 +00:00
|
|
|
;;;### autoload
|
2014-08-18 20:32:58 +00:00
|
|
|
(modify-coding-system-alist 'file "\\.lean\\'" 'utf-8)
|
2014-12-05 21:09:23 +00:00
|
|
|
(modify-coding-system-alist 'file "\\.hlean\\'" 'utf-8)
|
2014-08-18 20:32:58 +00:00
|
|
|
|
2014-08-25 20:31:44 +00:00
|
|
|
;; Flycheck init
|
|
|
|
(when lean-flycheck-use
|
|
|
|
(require 'flycheck)
|
|
|
|
(eval-after-load 'flycheck
|
|
|
|
'(lean-flycheck-init)))
|
|
|
|
|
2014-10-29 21:28:43 +00:00
|
|
|
;; Lean Info Mode (for "*lean-info*" buffer)
|
|
|
|
;; Automode List
|
|
|
|
;;;###autoload
|
|
|
|
(define-derived-mode lean-info-mode prog-mode "Lean-Info"
|
|
|
|
"Major mode for Lean Info Buffer"
|
|
|
|
:syntax-table lean-syntax-table
|
|
|
|
:group 'lean
|
|
|
|
(set (make-local-variable 'font-lock-defaults) lean-info-font-lock-defaults)
|
|
|
|
(set (make-local-variable 'indent-tabs-mode) nil)
|
|
|
|
(set 'compilation-mode-font-lock-keywords '())
|
|
|
|
(set-input-method "Lean")
|
|
|
|
(set (make-local-variable 'lisp-indent-function)
|
|
|
|
'common-lisp-indent-function))
|
|
|
|
|
2014-01-09 17:32:47 +00:00
|
|
|
(provide 'lean-mode)
|
2014-09-09 21:06:30 +00:00
|
|
|
;;; lean-mode.el ends here
|