[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/javaimp d9ea64a: * javaimp.el: Rename and improve javai
From: |
Filipp Gunbin |
Subject: |
[elpa] externals/javaimp d9ea64a: * javaimp.el: Rename and improve javaimp-show-scopes-at-point |
Date: |
Tue, 15 Jun 2021 12:47:50 -0400 (EDT) |
branch: externals/javaimp
commit d9ea64a751433a23191ce08ef59111536775450a
Author: Filipp Gunbin <fgunbin@fastmail.fm>
Commit: Filipp Gunbin <fgunbin@fastmail.fm>
* javaimp.el: Rename and improve javaimp-show-scopes-at-point
---
javaimp.el | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 64 insertions(+), 11 deletions(-)
diff --git a/javaimp.el b/javaimp.el
index 7d88bb5..9aeae61 100644
--- a/javaimp.el
+++ b/javaimp.el
@@ -567,18 +567,71 @@ cache."
(when arg
(setq javaimp-cached-jars nil)))
-(defun javaimp-show-scopes-at-point ()
- "Shows current scopes in a *javaimp-parse* buffer. Useful for
-debugging."
+
+
+;; Help
+
+(defvar javaimp-help-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-m" #'javaimp-help-goto-scope)
+ (define-key map [mouse-2] #'javaimp-help-goto-scope-mouse)
+ map)
+ "Keymap for Javaimp help buffers.")
+
+(defun javaimp-help-goto-scope (pos)
+ "Go to scope at point in another window."
+ (interactive "d")
+ (javaimp-help--goto-scope-1 pos))
+
+;; TODO handle mouse-1
+(defun javaimp-help-goto-scope-mouse (event)
+ "Go to scope you click on in another window."
+ (interactive "e")
+ (let ((window (posn-window (event-end event)))
+ (pos (posn-point (event-end event))))
+ (with-current-buffer (window-buffer window)
+ (javaimp-help--goto-scope-1 pos))))
+
+(defun javaimp-help--goto-scope-1 (pos)
+ "Go to the opening brace (`javaimp-scope-open-brace') of the
+scope at POS. With prefix arg, go to scope
+start (`javaimp-scope-start') instead."
+ (let ((scope (get-text-property pos 'javaimp-help-scope))
+ (file (get-text-property (point-min) 'javaimp-help-file)))
+ (when (and scope file)
+ (with-current-buffer (find-file-other-window file)
+ (goto-char (if current-prefix-arg
+ (javaimp-scope-start scope)
+ (javaimp-scope-open-brace scope)))))))
+
+(defun javaimp-help-scopes-at-point ()
+ "Shows enclosing scopes at point in a *javaimp-scopes* buffer,
+which is first cleared."
(interactive)
- (with-output-to-temp-buffer "*javaimp-parse*"
- (let ((parse-sexp-ignore-comments t) ; FIXME remove with major mode
- (parse-sexp-lookup-properties nil))
- (prin1 (javaimp--parse-scopes nil)))
- (with-current-buffer standard-output
- (fundamental-mode)
- (goto-char (point-min))
- (indent-pp-sexp t))))
+ (let* ((parse-sexp-ignore-comments t) ; FIXME remove with major mode
+ (parse-sexp-lookup-properties nil)
+ (scopes (javaimp--parse-scopes nil))
+ (file buffer-file-name)
+ (pos (point))
+ (buf (get-buffer-create "*javaimp-scopes*")))
+ (with-current-buffer buf
+ (setq buffer-read-only nil)
+ (erase-buffer)
+ (insert (propertize (format "Scopes at position %d in file:\n %s\n\n"
+ pos file)
+ 'javaimp-help-file file))
+ (dolist (scope scopes)
+ (insert (propertize
+ (concat (symbol-name (javaimp-scope-type scope))
+ " "
+ (javaimp-scope-name scope)
+ "\n")
+ 'mouse-face 'highlight
+ 'help-echo "mouse-2: go to this scope"
+ 'javaimp-help-scope scope
+ 'keymap javaimp-help-keymap)))
+ (setq buffer-read-only t))
+ (display-buffer buf)))
(provide 'javaimp)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/javaimp d9ea64a: * javaimp.el: Rename and improve javaimp-show-scopes-at-point,
Filipp Gunbin <=