-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #68 "Don't depend on Dash" (<#68>). In README, do not mention Dash. Most complex change involves a replacement for an expression like (-let* (((a b) (--split-with ...)))) for which a new (private inline helper) function has been introduced: lean4-info-buffer-redisplay--partition-errors.
- Loading branch information
Showing
7 changed files
with
135 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
;;; lean4-info.el --- Emacs mode for Lean theorem prover -*- lexical-binding: t -*- | ||
;; | ||
|
||
;; Copyright (c) 2016 Gabriel Ebner. All rights reserved. | ||
;; | ||
;; Copyright (c) 2024 Mekeor Melire | ||
|
||
;; Author: Gabriel Ebner <[email protected]> | ||
;; Maintainer: Gabriel Ebner <[email protected]> | ||
;; Created: Oct 29, 2016 | ||
|
@@ -30,7 +31,6 @@ | |
|
||
;;; Code: | ||
|
||
(require 'dash) | ||
(require 'lean4-syntax) | ||
(require 'lean4-settings) | ||
(require 'lsp-mode) | ||
|
@@ -67,7 +67,7 @@ Also choose settings used for the *Lean Goal* buffer." | |
(defun lean4-toggle-info-buffer (buffer) | ||
"Create or delete BUFFER. | ||
The buffer is supposed to be the *Lean Goal* buffer." | ||
(-if-let (window (get-buffer-window buffer)) | ||
(if-let ((window (get-buffer-window buffer))) | ||
(quit-window nil window) | ||
(lean4-ensure-info-buffer buffer) | ||
(display-buffer buffer))) | ||
|
@@ -142,18 +142,42 @@ The buffer is supposed to be the *Lean Goal* buffer." | |
'help-echo "mouse-2: visit this file, line and column")) | ||
(lean4-info--insert-highlight-inaccessible-names "\n" message "\n"))))))) | ||
|
||
(define-inline lean4-info-buffer-redisplay--partition-errors (line errors) | ||
"Partition ERRORS into errors above, on and below LINE. | ||
It is assumed that the ERRORS list is sorted ascendingly on the | ||
`lean4-diagnostic-full-end-line' predicate. The result is a list with | ||
three elements: Firstly, the errors above the given LINE; secondly, the | ||
errors on given LINE; and thirdly, the errors below given LINE." | ||
(let* ((above nil) | ||
(here nil) | ||
(below (seq-drop-while | ||
(lambda (e) | ||
(when (= (lean4-diagnostic-full-end-line e) line) | ||
(push e here))) | ||
(seq-drop-while | ||
(lambda (e) | ||
(when (< (lean4-diagnostic-full-end-line e) line) | ||
(push e above))) | ||
errors)))) | ||
(nreverse above) | ||
(nreverse here) | ||
(list above here below))) | ||
|
||
(defun lean4-info-buffer-redisplay () | ||
(when (lean4-info-buffer-active lean4-info-buffer-name) | ||
(-let* ((deactivate-mark) ; keep transient mark | ||
(inhibit-read-only t) | ||
(buffer (current-buffer)) | ||
(line (lsp--cur-line)) | ||
(errors (lsp--get-buffer-diagnostics)) | ||
(errors (-sort (-on #'< #'lean4-diagnostic-full-end-line) errors)) | ||
((errors-above errors) | ||
(--split-with (< (lean4-diagnostic-full-end-line it) line) errors)) | ||
((errors-here errors-below) | ||
(--split-with (<= (lean4-diagnostic-full-start-line it) line) errors))) | ||
(let* ((deactivate-mark) ; keep transient mark | ||
(inhibit-read-only t) | ||
(buffer (current-buffer)) | ||
(line (lsp--cur-line)) | ||
(errors (lsp--get-buffer-diagnostics)) | ||
(errors (seq-sort-by | ||
#'lean4-diagnostic-full-end-line #'< errors)) | ||
(errors (lean4-info-buffer-redisplay--partition-errors | ||
line errors)) | ||
(errors-above (nth 0 errors)) | ||
(errors-here (nth 1 errors)) | ||
(errors-below (nth 2 errors))) | ||
(with-current-buffer lean4-info-buffer-name | ||
(progn | ||
(erase-buffer) | ||
|
@@ -162,11 +186,11 @@ The buffer is supposed to be the *Lean Goal* buffer." | |
(magit-insert-section (magit-section 'goals) | ||
(magit-insert-heading "Goals:") | ||
(magit-insert-section-body | ||
(if (> (length goals) 0) | ||
(seq-doseq (g goals) | ||
(magit-insert-section (magit-section) | ||
(lean4--insert-goal-text g "\n\n"))) | ||
(insert "goals accomplished\n\n"))))) | ||
(if (> (length goals) 0) | ||
(seq-doseq (g goals) | ||
(magit-insert-section (magit-section) | ||
(lean4--insert-goal-text g "\n\n"))) | ||
(insert "goals accomplished\n\n"))))) | ||
(when-let ((term-goal lean4-term-goal)) ;; capture for deferred rendering | ||
(magit-insert-section (magit-section 'term-goal) | ||
(magit-insert-heading "Expected type:") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
;; Maintainer: Yury G. Kudryashov <[email protected]> | ||
;; Created: Jan 09, 2014 | ||
;; Keywords: languages | ||
;; Package-Requires: ((emacs "27.1") (dash "2.18.0") (flycheck "30") (magit-section "2.90.1") (lsp-mode "8.0.0")) | ||
;; Package-Requires: ((emacs "27.1") (flycheck "30") (magit-section "2.90.1") (lsp-mode "8.0.0")) | ||
;; URL: https://github.com/leanprover/lean4-mode | ||
;; SPDX-License-Identifier: Apache-2.0 | ||
;; Version: 1.0.1 | ||
|
@@ -42,7 +42,6 @@ | |
;;; Code: | ||
|
||
(require 'cl-lib) | ||
(require 'dash) | ||
(require 'pcase) | ||
(require 'flycheck) | ||
(require 'lsp-mode) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.