[MLton-commit] r5131
Vesa Karvonen
vesak at mlton.org
Mon Feb 5 01:48:22 PST 2007
Index move-to-symbol by mode.
----------------------------------------------------------------------
U mlton/trunk/ide/emacs/def-use-mode.el
U mlton/trunk/ide/emacs/esml-du-mlton.el
----------------------------------------------------------------------
Modified: mlton/trunk/ide/emacs/def-use-mode.el
===================================================================
--- mlton/trunk/ide/emacs/def-use-mode.el 2007-02-05 08:14:38 UTC (rev 5130)
+++ mlton/trunk/ide/emacs/def-use-mode.el 2007-02-05 09:48:06 UTC (rev 5131)
@@ -26,7 +26,6 @@
;; TBD:
;; - mode specific on-off switching
;; - disable def-use when file is modified
-;; - use mode dependent identifier charset (e.g also skip over _ in sml-mode)
;; - rename-variable
(require 'def-use-data)
@@ -124,6 +123,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; High-level symbol lookup
+(defvar def-use-mode-to-move-to-symbol-beginning-alist nil
+ "Association list mapping modes to functions that move the point
+(backwards) to the beginning of the symbol at the point.")
+
(defun def-use-ref-at-point (point)
"Returns a reference for the symbol at the specified point in the
current buffer."
@@ -133,8 +136,13 @@
(def-use-point-to-pos
(save-excursion
(goto-char point)
- ;; XXX Index this logic in a mode specific manner
- (esml-du-move-to-symbol-beginning)
+ (let ((mode-move
+ (assoc
+ major-mode
+ def-use-mode-to-move-to-symbol-beginning-alist)))
+ (if mode-move
+ (funcall (cdr mode-move))
+ (skip-syntax-backward "w_" (def-use-point-at-current-line))))
(point)))))))
(defun def-use-sym-at-point (point)
Modified: mlton/trunk/ide/emacs/esml-du-mlton.el
===================================================================
--- mlton/trunk/ide/emacs/esml-du-mlton.el 2007-02-05 08:14:38 UTC (rev 5130)
+++ mlton/trunk/ide/emacs/esml-du-mlton.el 2007-02-05 09:48:06 UTC (rev 5131)
@@ -23,13 +23,18 @@
(function esml-du-finalize)
ctx)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Move to symbol
+
(defun esml-du-move-to-symbol-beginning ()
- "XXX"
- (when (zerop (skip-chars-backward
- "a-zA-Z0-9_'" (def-use-point-at-current-line)))
- (skip-chars-backward
- "-!%&$#+/:<=>?@~`^|*\\" (def-use-point-at-current-line))))
+ "Moves to the beginning of the SML symbol at point."
+ (let ((limit (def-use-point-at-current-line)))
+ (when (zerop (skip-chars-backward "a-zA-Z0-9_'" limit))
+ (skip-chars-backward "-!%&$#+/:<=>?@~`^|*\\" limit))))
+(add-to-list 'def-use-mode-to-move-to-symbol-beginning-alist
+ (cons 'sml-mode (function esml-du-move-to-symbol-beginning)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Methods
More information about the MLton-commit
mailing list