summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-05-03 13:44:22 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-05-03 13:44:22 +0200
commit98c0e68b5354ef74cf26663d428a8f7839854681 (patch)
treef46668948e168ca127b9a056e876e37eb2463589
parenta63280cd55b342046966f95943ca9a45b2870c07 (diff)
downloadgeiser-98c0e68b5354ef74cf26663d428a8f7839854681.tar.gz
geiser-98c0e68b5354ef74cf26663d428a8f7839854681.tar.bz2
Better edit location heuristics.
-rw-r--r--elisp/geiser-edit.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el
index 9471981..c02e7bb 100644
--- a/elisp/geiser-edit.el
+++ b/elisp/geiser-edit.el
@@ -54,6 +54,9 @@
((eq method 'frame) (find-file-other-frame file))
(t (find-file file))))
+(defsubst geiser-edit--location-name (loc)
+ (cdr (assoc 'name loc)))
+
(defsubst geiser-edit--location-file (loc)
(cdr (assoc 'file loc)))
@@ -65,7 +68,6 @@
"defmacro"
"define-macro"
"define-syntax"
- "define-syntaxes"
"-define-syntax"
"-define"
"define*"
@@ -73,8 +75,18 @@
"define-class"
"define-struct")))
+(defconst geiser-edit--def-re*
+ (regexp-opt '("define-syntaxes" "define-values")))
+
(defsubst geiser-edit--def-re (thing)
- (format "(%s +(?%s\\_>" geiser-edit--def-re (regexp-quote (format "%s" thing))))
+ (format "(%s +(?%s\\_>"
+ geiser-edit--def-re
+ (regexp-quote (format "%s" thing))))
+
+(defsubst geiser-edit--def-re* (thing)
+ (format "(%s +([^)]*?\\_<%s\\_>"
+ geiser-edit--def-re*
+ (regexp-quote (format "%s" thing))))
(defsubst geiser-edit--symbol-re (thing)
(format "\\_<%s\\_>" (regexp-quote (format "%s" thing))))
@@ -84,11 +96,13 @@
(goto-line line)
(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)
(re-search-forward (geiser-edit--symbol-re symbol) nil t))
(goto-char (match-beginning 0)))))
(defun geiser-edit--try-edit-location (symbol loc &optional method)
- (let ((file (geiser-edit--location-file loc))
+ (let ((symbol (or (geiser-edit--location-name loc) symbol))
+ (file (geiser-edit--location-file loc))
(line (geiser-edit--location-line loc)))
(unless file (error "Couldn't find edit location for '%s'" symbol))
(unless (file-readable-p file) (error "Couldn't open '%s' for read" file))