Commit 4a2a8120 authored by Troels Henriksen's avatar Troels Henriksen

Added local-definition finding.

parent e45f64c8
......@@ -119,7 +119,10 @@ If there is no symbol at point, this is a no-op."
(let* ((token (this-form (current-syntax) (point)))
(this-symbol (form-to-object (current-syntax) token)))
(when (and this-symbol (symbolp this-symbol))
(edit-definition this-symbol))))
(let ((local-definition (find-local-definition (current-syntax) token)))
(if local-definition
(setf (offset (point)) (start-offset local-definition))
(edit-definition this-symbol))))))
(define-command (com-return-from-definition :name t :command-table climacs-lisp-table)
......@@ -342,6 +342,26 @@ Each newline and following whitespace is replaced by a single space."
(t t))))
(defun find-local-definition (syntax symbol-form)
"Return a form locally defining `symbol-form' as a
function (explicitly via `flet' or `labels', does not expand
macros or similar). If no such form can be found, return NIL."
(labels ((locally-binding-p (form)
(or (form-equal syntax (form-operator form) "FLET")
(form-equal syntax (form-operator form) "LABELS")))
(match (form-operator)
(when form-operator
(form-equal syntax form-operator symbol-form)))
(find-local-binding (form)
(or (when (locally-binding-p form)
(loop for binding in (form-children (first (form-operands form)))
when (and (form-list-p binding)
(match (form-operator binding)))
return binding))
(unless (form-at-top-level-p form)
(find-local-binding (parent form))))))
(find-local-binding (list-at-mark syntax (start-offset symbol-form)))))
(defun edit-definition (symbol &optional type)
(let ((all-definitions (find-definitions-for-drei
(get-usable-image (current-syntax))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment