summaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
Diffstat (limited to 'elisp')
-rw-r--r--elisp/geiser-edit.el22
-rw-r--r--elisp/geiser-imenu.el43
-rw-r--r--elisp/geiser-mode.el6
-rw-r--r--elisp/geiser-reload.el3
4 files changed, 65 insertions, 9 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el
index 14c782c..bfb89d6 100644
--- a/elisp/geiser-edit.el
+++ b/elisp/geiser-edit.el
@@ -112,16 +112,25 @@ or following links in error buffers.")
(beginning-of-line)
(forward-char col)))
+(defun geiser-edit--try-imenu (symbol)
+ (let* ((s (format "%s" symbol))
+ (imenu-auto-rescan t)
+ (item (assoc s (imenu--make-index-alist t))))
+ (if item (imenu item) (error "Couldn't find location for '%s'" s))))
+
(defun geiser-edit--try-edit-location (symbol loc &optional method)
(let ((symbol (or (geiser-edit--location-name loc) symbol))
- (file (geiser-edit--location-file loc))
+ (file (or (geiser-edit--location-file loc)
+ (and geiser-mode (buffer-file-name))))
(line (geiser-edit--location-line loc))
(col (geiser-edit--location-column loc))
(pos (geiser-edit--location-char loc)))
- (unless file (error "Couldn't find edit location for %s" symbol))
+ (unless file (error "Couldn't find location for '%s'" symbol))
(unless (file-readable-p file) (error "%s is not readable" file))
(geiser-edit--visit-file file (or method geiser-edit-symbol-method))
- (geiser-edit--goto-location symbol line col pos)
+ (if (or line col pos)
+ (geiser-edit--goto-location symbol line col pos)
+ (geiser-edit--try-imenu symbol))
(cons (current-buffer) (point))))
(defsubst geiser-edit--try-edit (symbol ret &optional method)
@@ -242,9 +251,10 @@ With prefix, asks for the symbol to edit."
(let* ((symbol (or (and (not arg) (geiser--symbol-at-point))
(geiser-completion--read-symbol "Edit symbol: ")))
(cmd `(:eval (:ge symbol-location ',symbol)))
- (marker (point-marker)))
+ (marker (point-marker))
+ (ret (ignore-errors (geiser-eval--send/wait cmd))))
(condition-case-unless-debug sym-err
- (progn (geiser-edit--try-edit symbol (geiser-eval--send/wait cmd))
+ (progn (geiser-edit--try-edit symbol ret)
(when marker (xref-push-marker-stack marker)))
(error (condition-case-unless-debug mod-err
(geiser-edit-module-at-point)
@@ -258,7 +268,7 @@ With prefix, asks for the symbol to edit."
"Pop back to where \\[geiser-edit-symbol-at-point] was last invoked."
(interactive)
(condition-case nil
- (pop-tag-mark)
+ (xref-pop-marker-stack)
(error "No previous location for find symbol invocation")))
(defun geiser-edit-module (module &optional method)
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
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index 24b0512..1bfe98d 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -1,6 +1,6 @@
-;;; geiser-mode.el -- minor mode for scheme buffers
+;;; geiser-mode.el -- minor mode for scheme buffers -*- lexical-binding: t; -*-
-;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2022 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009-2017, 2020, 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
@@ -14,6 +14,7 @@
(require 'geiser-repl)
(require 'geiser-capf)
+(require 'geiser-imenu)
(require 'geiser-menu)
(require 'geiser-doc)
(require 'geiser-compile)
@@ -387,6 +388,7 @@ 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 0cd3b51..431304c 100644
--- a/elisp/geiser-reload.el
+++ b/elisp/geiser-reload.el
@@ -1,4 +1,4 @@
-;;; geiser-reload.el -- unload/load geiser packages
+;;; geiser-reload.el -- unload/load geiser packages -*- lexical-binding: t; -*-
;; Copyright (C) 2009, 2010, 2012, 2020, 2021, 2022 Jose Antonio Ortega Ruiz
@@ -24,6 +24,7 @@
(defmacro geiser--features-list ()
(quote '(
geiser-mode
+ geiser-imenu
geiser-repl
geiser-capf
geiser-doc