diff options
author | jao <jao@gnu.org> | 2022-10-12 03:37:56 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-10-12 03:37:56 +0100 |
commit | a9b17f08a0c40d2b2ac5d3d130a8b40f5890ccfa (patch) | |
tree | 45e2cb79d34a1b7cdcc17ac6d63bfa8472597436 /elisp/geiser-imenu.el | |
parent | d836c0025f9e51689c4c078c57546c0870498137 (diff) | |
download | geiser-a9b17f08a0c40d2b2ac5d3d130a8b40f5890ccfa.tar.gz geiser-a9b17f08a0c40d2b2ac5d3d130a8b40f5890ccfa.tar.bz2 |
imenu as a last resort for jumping to definition
... as well as a way of telling imenu to look for nested define forms, as the
ones one finds for instance inside (library ...) or (module ...) sexps, or
simply nested defines in function bodies. it's a crappy way of finding
definitions, but it's better than nothing when it's all we have (e.g., R6RS
libraries don't seem to provide an environment/namespace including their
privates, which is a killjoy).
Diffstat (limited to 'elisp/geiser-imenu.el')
-rw-r--r-- | elisp/geiser-imenu.el | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/elisp/geiser-imenu.el b/elisp/geiser-imenu.el new file mode 100644 index 0000000..9573a6b --- /dev/null +++ b/elisp/geiser-imenu.el @@ -0,0 +1,43 @@ +;;; geiser-imenu.el -- Tweaks to imenu configuration -*- lexical-binding: t; -*- + +;; Copyright (c) 2022 Jose Antonio Ortega Ruiz + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the Modified BSD License. You should +;; have received a copy of the license along with this program. If +;; not, see <http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5>. + +;; Start date: Wed Oct 12, 2022 01:43 + + +(require 'geiser-impl) + +(require 'imenu) +(require 'scheme) + +(defvar geiser-imenu-generic-expression + (mapcar (lambda (e) + `(,(car e) + ,(concat "^\\(?: *\\)" (substring (cadr e) 1)) + ,@(cddr e))) + scheme-imenu-generic-expression)) + +(defvar geiser-imenu--nested-defs nil) +(geiser-impl--register-local-variable + 'geiser-imenu--nested-defs 'nested-definitions nil + "A flag indicating whether this implementation accepts nested definitions. +For instance, R6%S library forms will contain them.") + +(defun geiser-imenu-declare-nested-definitions (impl) + "Declare IMPL as one that accepts nested definitions." + (add-to-list 'geiser-imenu--nested-definition-impls impl)) + +(defun geiser-imenu-setup (activate) + "Adjust imenu for the current implementation." + (setq-local imenu-generic-expression + (if (and activate geiser-imenu--nested-defs) + geiser-imenu-generic-expression + scheme-imenu-generic-expression))) + +(provide 'geiser-imenu) +;;; geiser-imenu.el ends here |