Skip to content

Commit

Permalink
Working version
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlyak40wt committed Dec 3, 2017
1 parent 6a857b0 commit adbf9dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
13 changes: 7 additions & 6 deletions elisp/log4slime.el
Expand Up @@ -261,7 +261,7 @@ argument, the parent effective log level (string)")
;; I swear it something in slime-eval screws with point sometimes
(save-excursion
(let ((slime-current-thread t))
(slime-eval `(cl:ignore-errors ,form))))))
(sly-eval `(cl:ignore-errors ,form))))))

(defvar log4slime-goto-definition-window nil
"Passed as WHERE to `slime-pop-to-location', can be 'WINDOW or 'FRAME too")
Expand Down Expand Up @@ -509,8 +509,8 @@ default `add-log-current-defun-function' for CL code"
defun loggers based on current Emacs context. Sets the
log4slime-xxx-logger variables with returned info."
(save-excursion
(when (slime-connected-p)
(let ((pkg (slime-current-package))
(when (sly-connected-p)
(let ((pkg (sly-current-package))
(file (buffer-file-name))
(current-defun (ignore-errors
(funcall (or log4slime-current-defun-function
Expand Down Expand Up @@ -813,13 +813,14 @@ to the first log statement"
log4slime-defun-logger nil)
args)


(defun log4slime-check-connection (&optional from-mode)
"Load the :log4slime system on inferior-lisp side"
;; weird, point in current buffer was moved on error, wondering what
;; is doing in?
(save-excursion
(when (slime-connected-p)
(let* ((conn (slime-current-connection)))
(when (sly-connected-p)
(let* ((conn (sly-current-connection)))
(when conn
(let ((try (process-get conn 'log4slime-loaded)))
(cond ((eq try t) t)
Expand All @@ -836,7 +837,7 @@ to the first log statement"
(if from-mode 5 300))))
;; mark it that we trying to do it
(process-put conn 'log4slime-loaded (float-time))
(let* ((result (slime-eval
(let* ((result (sly-eval
`(cl:multiple-value-bind
(ok err)
(cl:ignore-errors
Expand Down
22 changes: 11 additions & 11 deletions src/log4slime.lisp
Expand Up @@ -49,8 +49,8 @@ figure it out
((search "DEFUN" repr) 'defun)
((search "FUNCTION" repr) 'defun))))))

(defun slime-loc-defun-p (loc) (eq (slime-loc-type loc) 'swank-backend::defun))
(defun slime-loc-defvar-p (loc) (eq (slime-loc-type loc) 'swank-backend::defvar))
;; (defun slime-loc-defun-p (loc) (eq (slime-loc-type loc) 'swank-backend::defun))
;; (defun slime-loc-defvar-p (loc) (eq (slime-loc-type loc) 'swank-backend::defvar))

(defun find-best-location-match (categories definitions)
"User had left-clicked on a log message coming list of CATEGORIES
Expand Down Expand Up @@ -131,9 +131,9 @@ be split into multiple ones, but I have no time right now"
(defs (when cats
(if (and (eq (first cats) 'setf)
(second cats))
(swank::find-definitions (subseq cats 0 2))
(swank::find-definitions (first cats))))))
(mapcar #'swank::xref>elisp (find-best-location-match cats defs))))
(slynk::find-definitions (subseq cats 0 2))
(slynk::find-definitions (first cats))))))
(mapcar #'slynk::xref>elisp (find-best-location-match cats defs))))
(logger-name-for-emacs (logger)
(format nil "Category ~a" (logger-category logger)))
(children-level-count (logger)
Expand Down Expand Up @@ -201,7 +201,7 @@ be split into multiple ones, but I have no time right now"
(or (find-package package)
(find-package (string-upcase package))
(find-package (string-downcase package))
(swank::parse-package package)
(slynk::parse-package package)
(let* ((str (ignore-errors
(string (read-from-string package)))))
(when str
Expand All @@ -210,7 +210,7 @@ be split into multiple ones, but I have no time right now"
(find-package (string-downcase str)))))))))
(log:expr pkg)
(when (or pkg (not package))
(swank::with-buffer-syntax (pkg)
(slynk::with-buffer-syntax (pkg)
(with-package-naming-configuration (*package*)
(find-package-categories)
(multiple-value-bind (logger display-name) (find-logger)
Expand Down Expand Up @@ -252,21 +252,21 @@ be split into multiple ones, but I have no time right now"
;; Support for snippets compiled via C-c C-c correctly identifying the source file
;;
(defvar *old-compile-string-for-emacs*
(fdefinition 'swank::compile-string-for-emacs))
(fdefinition 'slynk::compile-string-for-emacs))

;; Patch the COMPILE-STRING-FOR-EMACS to bind *LOGGER-TRUENAME* to the file
;; name that C-c C-c snippet is from
(setf (fdefinition 'swank::compile-string-for-emacs)
(setf (fdefinition 'slynk::compile-string-for-emacs)
(lambda (string buffer position filename policy)
(let ((*logger-truename*
(when filename (ignore-errors (parse-namestring filename)))))
(funcall *old-compile-string-for-emacs*
string buffer position filename policy))))

;; In case SWANK was patched with the "thread stopper" patch that defines
;; In case SLYNK was patched with the "thread stopper" patch that defines
;; protocol for starting/stopping threads around calls to fork(), register
;; a callback for the watcher thread
(let ((rss-foo (find-symbol (symbol-name '#:register-thread-stopper) (find-package :swank))))
(let ((rss-foo (find-symbol (symbol-name '#:register-thread-stopper) (find-package :slynk))))
(and rss-foo (funcall rss-foo :log4cl #'log4cl::start/stop-watcher-hook)))
;;
;; Some copy-paste from CLHS package
Expand Down

0 comments on commit adbf9dd

Please sign in to comment.