[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 6239f41d9d 033/323: Add a goto-match feature
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 6239f41d9d 033/323: Add a goto-match feature for easily traversing matches |
Date: |
Thu, 9 Mar 2023 10:57:57 -0500 (EST) |
branch: externals/beardbolt
commit 6239f41d9d9ca666561e0cb2c6e045a14ec5036d
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add a goto-match feature for easily traversing matches
---
rmsbolt.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 13 deletions(-)
diff --git a/rmsbolt.el b/rmsbolt.el
index 4a227cf105..ca7ba5173a 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -38,7 +38,10 @@
(defcustom rmsbolt-use-overlays t
"Whether we should use overlays to show matching code."
:type 'boolean
- :safe 'booleanp
+ :group 'rmsbolt)
+(defcustom rmsbolt-goto-match t
+ "Whether we should goto the match in the other buffer if it is non visible."
+ :type 'boolean
:group 'rmsbolt)
;;;;; Buffer Local Tweakables
@@ -96,8 +99,11 @@
(defvar rmsbolt-mode)
(defvar rmsbolt-hide-compile t)
-(defvar rmsbolt-binary-asm-limit 5000)
+(defvar rmsbolt-binary-asm-limit 10000)
(defun rmsbolt-output-filename (src-buffer &optional asm)
+ "Function for generating an output filename for SRC-BUFFER.
+
+Outputs assembly file if ASM."
(if (and (not asm)
(buffer-local-value 'rmsbolt-dissasemble src-buffer))
(expand-file-name "rmsbolt.out" rmsbolt-temp-dir)
@@ -265,6 +271,13 @@ Needed as ocaml cannot output asm to a non-hardcoded file"
"frame_dummy"
(and ".plt" (0+ any)))
eol))
+(defvar rmsbolt--hidden-func-ocaml)
+(setq rmsbolt--hidden-func-ocaml (rx bol
+ (or
+ (and "camlCamlinternalFormat__" (0+ any))
+ ;; (0+ any)
+ )
+ eol))
;;;; Language Definitions
(defvar rmsbolt-languages)
(setq
@@ -290,7 +303,7 @@ Needed as ocaml cannot output asm to a non-hardcoded file"
:supports-asm t
:starter-file-name "rmsbolt.ml"
:compile-cmd-function #'rmsbolt--ocaml-compile-cmd
- :dissas-hidden-funcs rmsbolt--hidden-func-c))))
+ :dissas-hidden-funcs rmsbolt--hidden-func-ocaml))))
;;;; Macros
@@ -637,18 +650,25 @@ Needed as ocaml cannot output asm to a non-hardcoded file"
;;;; Font lock matcher
(defun rmsbolt--goto-line (line)
"Goto a certain LINE."
- (let ((cur (line-number-at-pos)))
- (forward-line (- line cur))))
+ (when line
+ (let ((cur (line-number-at-pos)))
+ (forward-line (- line cur)))))
(defun rmsbolt--setup-overlay (start end buf)
"Setup overlay with START and END in BUF."
(let ((o (make-overlay start end buf)))
(overlay-put o 'face 'rmsbolt-current-line-face)
o))
+(cl-defun rmsbolt--point-visible (point)
+ "Check if the current point is visible in a winodw in the current buffer."
+ (dolist (w (get-buffer-window-list))
+ (when (pos-visible-in-window-p point w)
+ (cl-return-from rmsbolt--point-visible t)))
+ nil)
(defun rmsbolt-move-overlays ()
"Function for moving overlays for rmsbolt."
- (if-let* ((src-buffer
+ (if-let* ((should-run
(and rmsbolt-mode rmsbolt-use-overlays))
(src-buffer
(buffer-local-value 'rmsbolt-src-buffer (current-buffer)))
@@ -666,17 +686,37 @@ Needed as ocaml cannot output asm to a non-hardcoded file"
(save-excursion
(rmsbolt--goto-line src-current-line)
(values (c-point 'bol) (c-point 'eol))))))
- (progn
+ (let ((line-visible (not rmsbolt-goto-match))
+ (src-buffer-selected (eq (current-buffer) src-buffer)))
(mapc #'delete-overlay rmsbolt-overlays)
(setq rmsbolt-overlays nil)
(push (rmsbolt--setup-overlay (first src-pts) (second src-pts)
src-buffer)
rmsbolt-overlays)
+ (unless src-buffer-selected
+ (with-current-buffer src-buffer
+ (setq line-visible (rmsbolt--point-visible (first src-pts)))))
(with-current-buffer output-buffer
(save-excursion
(dolist (l asm-lines)
(rmsbolt--goto-line l)
+ ;; check if line is visible and set line-visible
+ (unless (or line-visible (not src-buffer-selected))
+ (setq line-visible (rmsbolt--point-visible (c-point 'bol))))
+
(push (rmsbolt--setup-overlay (c-point 'bol) (c-point 'eol)
output-buffer)
- rmsbolt-overlays)))))
+ rmsbolt-overlays)))
+ (unless line-visible
+ ;; Scroll buffer to first line
+ (when-let
+ ((scroll-buffer (if src-buffer-selected
+ output-buffer
+ src-buffer))
+ (line-scroll (if src-buffer-selected
+ (first asm-lines)
+ src-current-line))
+ (window (get-buffer-window scroll-buffer)))
+ (with-selected-window window
+ (rmsbolt--goto-line line-scroll))))))
(mapc #'delete-overlay rmsbolt-overlays)
(setq rmsbolt-overlays nil)))
@@ -687,11 +727,6 @@ Needed as ocaml cannot output asm to a non-hardcoded file"
(define-minor-mode rmsbolt-mode
"RMSbolt"
nil "RMSBolt" rmsbolt-mode-map
- (if rmsbolt-mode
- (font-lock-add-keywords
- nil '((rmsbolt-search-for-keyword
- (0 rmsbolt-current-line-face)))))
-
;; This idle timer always runs, even when we aren't in rmsbolt-mode
(unless rmsbolt--idle-timer
(setq rmsbolt--idle-timer (run-with-idle-timer
- [elpa] externals/beardbolt aea0966e9d 035/323: Don't add binary asm line data when viewing different files, (continued)
- [elpa] externals/beardbolt aea0966e9d 035/323: Don't add binary asm line data when viewing different files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c066da01c4 052/323: Fix ocaml def, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 83e29706f5 005/323: Work on porting used label finder, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 58c77d90c3 008/323: Add outshine comments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1545531849 006/323: Add initial implementation of filter, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d604adae64 015/323: Add initial functions for processing binary asm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e0bc9fc409 013/323: Fix starters, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 93f3cad769 017/323: Use local variables instead of custom parsing, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ce6511f715 024/323: Fix compiler warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 55c26882cd 025/323: Fix crash on quit, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 6239f41d9d 033/323: Add a goto-match feature for easily traversing matches,
ELPA Syncer <=
- [elpa] externals/beardbolt e6081fae6b 032/323: Add unrefined support for ocaml, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a638324882 039/323: Add OCaml demo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e0d917206e 038/323: Improve quality of default matching faces, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a950515dfc 043/323: Fix spelling mistake, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4213316f23 037/323: Fix recentering when not needed, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 545a366472 049/323: Add more tests, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2e6163c95a 047/323: Add testing framework, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5efa347027 046/323: Update readme, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 082cbc7b1c 048/323: Add new tests, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ff6f376d87 053/323: Update README.org, ELPA Syncer, 2023/03/09