Skip to content

Commit 1c2cae4

Browse files
committed
Initial attempt at magit integration for tracing changed files
1 parent c813d94 commit 1c2cae4

File tree

2 files changed

+66
-9
lines changed

2 files changed

+66
-9
lines changed

src/el/sayid-magit.el

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
;;; sayid-magit.el --- Choose sayid tracing from magit -*- lexical-binding: t -*-
2+
3+
;; Author: Mark Dawson
4+
;; Maintainer: Bill Piel <[email protected]>
5+
;; Version: 0.0.1
6+
;; URL: https://github.com/clojure-emacs/sayid
7+
;; Package-Requires: ((cider "0.21.0"))
8+
9+
;; Licensed under the Apache License, Version 2.0 (the "License");
10+
;; you may not use this file except in compliance with the License.
11+
;; You may obtain a copy of the License at
12+
13+
;; http://www.apache.org/licenses/LICENSE-2.0
14+
15+
;; Unless required by applicable law or agreed to in writing, software
16+
;; distributed under the License is distributed on an "AS IS" BASIS,
17+
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
;; See the License for the specific language governing permissions and
19+
;; limitations under the License.
20+
21+
;;; Commentary:
22+
23+
;;; Code:
24+
25+
;;;###autoload
26+
(defun sayid-magit--trace-ns-in-files (file-names)
27+
"Trace namespace in FILE-NAMES."
28+
(mapcar (lambda (file-name)
29+
(with-current-buffer (find-file-noselect
30+
(expand-file-name file-name))
31+
(nrepl-send-sync-request (list "op" "sayid-trace-ns-in-file"
32+
"file" (buffer-file-name))
33+
(cider-current-connection))))
34+
file-names)
35+
(sayid-show-traced))
36+
37+
;;;###autoload
38+
(defun sayid-magit-trace-changed-ns ()
39+
"Trace the changed namespaces in a git commit."
40+
(interactive)
41+
(sayid--trace-ns-in-files
42+
(magit-changed-files (magit-read-starting-point "Sayid trace" nil "HEAD"))))
43+
44+
(provide 'sayid-magit)
45+
46+
;;; sayid-magit.el ends here

src/el/sayid.el

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -718,19 +718,30 @@ Disable traces, load buffer, enable traces, clear log."
718718
(setq paths (cdr paths)))
719719
(car paths))))
720720

721-
;;;###autoload
722-
(defun sayid-buffer-nav-from-point ()
723-
"Navigate from sayid buffer to function source."
721+
(defun sayid-buffer-file-at-point ()
722+
"Return file path for function at point in sayid buffer."
724723
(interactive)
725724
(let* ((file (get-text-property (point) 'src-file))
726-
(line (get-text-property (point) 'src-line))
727725
(xfile (sayid-find-existing-file file)))
728726
(if xfile
729-
(progn
730-
(pop-to-buffer (find-file-noselect xfile))
731-
(goto-char (point-min))
732-
(forward-line (- line 1)))
733-
(message (concat "File not found: " file)))))
727+
xfile
728+
(user-error (concat "File not found: " file)))))
729+
730+
(defun sayid-buffer-line-at-point ()
731+
"Return line number for function at point in sayid buffer."
732+
(get-text-property (point) 'src-line))
733+
734+
;;;###autoload
735+
(defun sayid-buffer-nav-from-point ()
736+
"Navigate from sayid buffer to function source."
737+
(interactive)
738+
(let ((line (sayid-buffer-line-at-point))
739+
(file (sayid-buffer-file-at-point)))
740+
(when file
741+
(progn
742+
(pop-to-buffer (find-file-noselect file))
743+
(goto-char (point-min))
744+
(forward-line (- line 1))))))
734745

735746
;;;###autoload
736747
(defun sayid-buffer-nav-to-prev ()

0 commit comments

Comments
 (0)