forked from haskell/haskell-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
146 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
;;; highlight-uses-mode.el --- Mode for highlighting uses | ||
|
||
;; Copyright (c) 2014 Chris Done. All rights reserved. | ||
|
||
;; This file is free software; you can redistribute it and/or modify | ||
;; it under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation; either version 3, or (at your option) | ||
;; any later version. | ||
|
||
;; This file is distributed in the hope that it will be useful, | ||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
;; GNU General Public License for more details. | ||
|
||
;; You should have received a copy of the GNU General Public License | ||
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
;;; Code: | ||
|
||
(defvar highlight-uses-mode-map | ||
(let ((map (make-sparse-keymap))) | ||
(define-key map (kbd "TAB") 'highlight-uses-mode-next) | ||
(define-key map (kbd "S-TAB") 'highlight-uses-mode-prev) | ||
(define-key map (kbd "<backtab>") 'highlight-uses-mode-prev) | ||
(define-key map (kbd "C-g") 'highlight-uses-mode) | ||
map) | ||
"Keymap for using haskell-interactive-mode.") | ||
|
||
;;;###autoload | ||
(define-minor-mode highlight-uses-mode | ||
"Minor mode for highlighting and jumping between uses." | ||
:lighter " Uses" | ||
:keymap highlight-uses-mode-map | ||
(remove-overlays (point-min) (point-max) 'highlight-uses-mode-highlight t)) | ||
|
||
(defun highlight-uses-mode-next () | ||
"Jump to next result." | ||
(interactive) | ||
(let ((os (overlays-in (point) (point-max)))) | ||
(let ((last-point (point))) | ||
(while (car os) | ||
(goto-char (overlay-start (car os))) | ||
(if (= (point) last-point) | ||
(setq os (cdr os)) | ||
(setq os nil)))))) | ||
|
||
(defun highlight-uses-mode-prev () | ||
"Jump to previous result." | ||
(interactive) | ||
(let ((os (overlays-in (point-min) (point)))) | ||
(let ((last-point (point))) | ||
(while (car os) | ||
(goto-char (overlay-start (car os))) | ||
(if (= (point) last-point) | ||
(setq os (cdr os)) | ||
(setq os nil)))))) | ||
|
||
(defun highlight-uses-mode-highlight (start end) | ||
"Make a highlight overlay at the given span." | ||
(let ((o (make-overlay start end))) | ||
(overlay-put o 'priority 999) | ||
(overlay-put o 'face 'isearch-lazy-highlight) | ||
(overlay-put o 'highlight-uses-mode-highlight t))) | ||
|
||
(provide 'highlight-uses-mode) |