summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-10-15 16:58:18 +0100
committerjao <jao@gnu.org>2022-10-15 17:01:04 +0100
commitb64ee5b8a984e06aae29b8a92362a6db03cfed3b (patch)
tree0137967f5dd95a7716b35497c897f493219a7c9a /elisp
parentaf81e4fb1088d9ccbd36dcd541e29eb2770e4d87 (diff)
downloadgeiser-b64ee5b8a984e06aae29b8a92362a6db03cfed3b.tar.gz
geiser-b64ee5b8a984e06aae29b8a92362a6db03cfed3b.tar.bz2
local definition discovery sans imenu
we already had our own lighter mechanism, just needed to use it better. it will also allow guessing local signatures, quite useful in chezzy (or more generally r6rs-librarish) schemes.
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-edit.el33
-rw-r--r--elisp/geiser-imenu.el43
-rw-r--r--elisp/geiser-mode.el2
-rw-r--r--elisp/geiser-reload.el1
4 files changed, 14 insertions, 65 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el
index 750ccef..165e0fc 100644
--- a/elisp/geiser-edit.el
+++ b/elisp/geiser-edit.el
@@ -97,32 +97,28 @@ or following links in error buffers.")
geiser-edit--def-re*
(regexp-quote (format "%s" thing))))
+(defun geiser-edit--find-def (symbol)
+ (save-excursion
+ (goto-char (point-min))
+ (when (or (re-search-forward (geiser-edit--def-re symbol) nil t)
+ (re-search-forward (geiser-edit--def-re* symbol) nil t))
+ (cons (match-beginning 0) (match-string-no-properties 0)))))
+
(defsubst geiser-edit--symbol-re (thing)
(format "\\_<%s\\_>" (regexp-quote (format "%s" thing))))
(defun geiser-edit--goto-location (symbol line col pos)
- (goto-char (point-min))
- (cond ((numberp line) (forward-line (max 0 (1- line))))
+ (cond ((numberp line)
+ (goto-char (point-min))
+ (forward-line (max 0 (1- line))))
((numberp pos) (goto-char pos)))
(if (not col)
- (when (or (re-search-forward (geiser-edit--def-re symbol) nil t)
- (re-search-forward (geiser-edit--def-re* symbol) nil t)
- (re-search-forward (geiser-edit--symbol-re symbol) nil t))
- (goto-char (match-beginning 0)))
+ (when-let (pos (car (geiser-edit--find-def symbol)))
+ (goto-char pos))
(beginning-of-line)
(forward-char col)
(cons (current-buffer) (point))))
-(defun geiser-edit--try-imenu (symbol no-error)
- (let* ((s (format "%s" symbol))
- (imenu-auto-rescan t)
- (item (assoc s (imenu--make-index-alist t))))
- (unless (or item no-error)
- (error "Couldn't find location for '%s'" s))
- (when item
- (imenu item)
- (cons (current-buffer) (point)))))
-
(defun geiser-edit--try-edit-location (symbol loc &optional method no-error)
(let ((symbol (or (geiser-edit--location-name loc) symbol))
(file (geiser-edit--location-file loc))
@@ -131,9 +127,8 @@ or following links in error buffers.")
(pos (geiser-edit--location-char loc)))
(when file
(geiser-edit--visit-file file (or method geiser-edit-symbol-method)))
- (if (or file line col pos)
- (geiser-edit--goto-location symbol line col pos)
- (geiser-edit--try-imenu symbol no-error))))
+ (or (geiser-edit--goto-location symbol line col pos)
+ (error "Couldn't find location for symbol at point"))))
(defsubst geiser-edit--try-edit (symbol ret &optional method no-error)
(geiser-edit--try-edit-location symbol
diff --git a/elisp/geiser-imenu.el b/elisp/geiser-imenu.el
deleted file mode 100644
index 9573a6b..0000000
--- a/elisp/geiser-imenu.el
+++ /dev/null
@@ -1,43 +0,0 @@
-;;; 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
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 1bfe98d..eebb1ef 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -14,7 +14,6 @@
(require 'geiser-repl)
(require 'geiser-capf)
-(require 'geiser-imenu)
(require 'geiser-menu)
(require 'geiser-doc)
(require 'geiser-compile)
@@ -388,7 +387,6 @@ interacting with the Geiser REPL is at your disposal.
(setq geiser-autodoc-mode-string "/A")
(setq geiser-smart-tab-mode-string "/T")
(geiser-capf-setup geiser-mode)
- (geiser-imenu-setup geiser-mode)
(when geiser-mode-autodoc-p
(geiser-autodoc-mode (if geiser-mode 1 -1)))
(when geiser-mode-smart-tab-p
diff --git a/elisp/geiser-reload.el b/elisp/geiser-reload.el
index 431304c..bd4d1a3 100644
--- a/elisp/geiser-reload.el
+++ b/elisp/geiser-reload.el
@@ -24,7 +24,6 @@
(defmacro geiser--features-list ()
(quote '(
geiser-mode
- geiser-imenu
geiser-repl
geiser-capf
geiser-doc