This repository has been archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Some improvement on ghc-show-type #480
Open
iquiw
wants to merge
2
commits into
DanielG:master
Choose a base branch
from
iquiw:show-type-improve
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -31,10 +31,25 @@ | |
;;; type | ||
;;; | ||
|
||
(defface ghc-type-region | ||
'((default :inherit region) | ||
(((background light)) | ||
:background "LightBlue") | ||
(((background dark)) | ||
:background "RoyalBlue")) | ||
"Face used to mark region selected by `ghc-show-type'.") | ||
|
||
(defvar ghc-type-overlay nil) | ||
|
||
(make-variable-buffer-local 'ghc-type-overlay) | ||
|
||
(defvar ghc-type-map | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're overriding all these operations why not just set the region temporarily, that'll eliminate the type highlighting vs. region confusion. It looks like the region highlighting doesn't survive a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can probably do that with push-mark and pop-mark. |
||
(let ((map (make-sparse-keymap))) | ||
(define-key map (kbd "C-w") 'ghc-type-kill-region) | ||
(define-key map (kbd "M-w") 'ghc-type-copy-region) | ||
(define-key map (kbd "M-t") 'ghc-type-copy-type) | ||
map)) | ||
|
||
(defun ghc-type-set-ix (n) | ||
(overlay-put ghc-type-overlay 'ix n)) | ||
|
||
|
@@ -57,7 +72,8 @@ | |
|
||
(defun ghc-type-init () | ||
(setq ghc-type-overlay (make-overlay 0 0)) | ||
(overlay-put ghc-type-overlay 'face 'region) | ||
(overlay-put ghc-type-overlay 'face 'ghc-type-region) | ||
(overlay-put ghc-type-overlay 'keymap ghc-type-map) | ||
(ghc-type-clear-overlay) | ||
(setq after-change-functions | ||
(cons 'ghc-type-clear-overlay after-change-functions)) | ||
|
@@ -119,6 +135,25 @@ | |
(while (search-forward "[Char]" nil t) | ||
(replace-match "String")))) | ||
|
||
(defun ghc-type-copy-region () | ||
"Copy the region selected by `ghc-show-type'." | ||
(interactive) | ||
(kill-new (filter-buffer-substring | ||
(overlay-start ghc-type-overlay) (overlay-end ghc-type-overlay))) | ||
(ghc-type-clear-overlay)) | ||
|
||
(defun ghc-type-kill-region () | ||
"Kill the region selected by `ghc-show-type'." | ||
(interactive) | ||
(kill-region (overlay-start ghc-type-overlay) (overlay-end ghc-type-overlay)) | ||
(ghc-type-clear-overlay)) | ||
|
||
(defun ghc-type-copy-type () | ||
"Copy the current type given by `ghc-show-type'." | ||
(interactive) | ||
(let ((tinfo (nth (ghc-type-get-ix) (ghc-type-get-types)))) | ||
(kill-new (ghc-tinfo-get-info tinfo)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Expanding Template Haskell | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This face makes text under it quite unreadable, at least with my theme. How about we use an underline face or something less intrusive instead? Or maybe base the default colors for this theme on ones from the default faces of the current theme and modify them a bit.