]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: New option fuel-xref-follow-link-method (current buffer, new window or frame).
authorJose A. Ortega Ruiz <jao@gnu.org>
Thu, 22 Jan 2009 08:55:39 +0000 (09:55 +0100)
committerJose A. Ortega Ruiz <jao@gnu.org>
Thu, 22 Jan 2009 08:55:39 +0000 (09:55 +0100)
misc/fuel/fuel-edit.el
misc/fuel/fuel-xref.el

index 0334ab61041bca7068b0ad7dcd5f2488153f9d68..484fed66cd5c65b054d24994cecac07259067a0c 100644 (file)
 \f
 ;;; Customization
 
-(defcustom fuel-edit-word-method nil
-  "How the new buffer is opened when invoking
-\\[fuel-edit-word-at-point]."
-  :group 'fuel
-  :type '(choice (const :tag "Other window" window)
-                 (const :tag "Other frame" frame)
-                 (const :tag "Current window" nil)))
+(defmacro fuel-edit--define-custom-visit (var group doc)
+  `(defcustom ,var nil
+     ,doc
+     :group ',group
+     :type '(choice (const :tag "Other window" window)
+                    (const :tag "Other frame" frame)
+                    (const :tag "Current window" nil))))
+
+(fuel-edit--define-custom-visit
+ fuel-edit-word-method fuel
+ "How the new buffer is opened when invoking \\[fuel-edit-word-at-point]")
 
 \f
 ;;; Auxiliar functions:
 
+(defun fuel-edit--visit-file (file method)
+  (cond ((eq method 'window) (find-file-other-window file))
+        ((eq method 'frame) (find-file-other-frame file))
+        (t (find-file file))))
+
 (defun fuel-edit--looking-at-vocab ()
   (save-excursion
     (fuel-syntax--beginning-of-defun)
@@ -45,9 +54,7 @@
       (error "Couldn't find edit location"))
     (unless (file-readable-p (car loc))
       (error "Couldn't open '%s' for read" (car loc)))
-    (cond ((eq fuel-edit-word-method 'window) (find-file-other-window (car loc)))
-          ((eq fuel-edit-word-method 'frame) (find-file-other-frame (car loc)))
-          (t (find-file (car loc))))
+    (fuel-edit--visit-file (car loc) fuel-edit-word-method)
     (goto-line (if (numberp (cadr loc)) (cadr loc) 1))))
 
 (defun fuel-edit--read-vocabulary-name (refresh)
index f754c626f718c8c58679050d0bd78287529dc7ab..d98c0b0a69f91297d402093fbb280fc38c0e25a1 100644 (file)
@@ -37,6 +37,11 @@ cursor at the first ocurrence of the used word."
   :group 'fuel-xref
   :type 'boolean)
 
+(fuel-edit--define-custom-visit
+ fuel-xref-follow-link-method
+ fuel-xref
+ "How new buffers are opened when following a crossref link.")
+
 (fuel-font-lock--defface fuel-font-lock-xref-link
   'link fuel-xref "highlighting links in cross-reference buffers")
 
@@ -59,12 +64,12 @@ cursor at the first ocurrence of the used word."
     (when (not (file-readable-p file))
       (error "File '%s' is not readable" file))
     (let ((word fuel-xref--word))
-      (find-file-other-window file)
+      (fuel-edit--visit-file file fuel-xref-follow-link-method)
       (when (numberp line) (goto-line line))
       (when (and word fuel-xref-follow-link-to-word-p)
-        (and (search-forward word
-                             (fuel-syntax--end-of-defun-pos)
-                             t)
+        (and (re-search-forward (format "\\_<%s\\_>" word)
+                                (fuel-syntax--end-of-defun-pos)
+                                t)
              (goto-char (match-beginning 0)))))))
 
 \f
@@ -126,21 +131,25 @@ cursor at the first ocurrence of the used word."
 (defun fuel-xref--show-callers (word)
   (let* ((cmd `(:fuel* (((:quote ,word) fuel-callers-xref))))
          (res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
+    (with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word word))
     (fuel-xref--fill-and-display word "using" res)))
 
 (defun fuel-xref--show-callees (word)
   (let* ((cmd `(:fuel* (((:quote ,word) fuel-callees-xref))))
          (res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
+    (with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word nil))
     (fuel-xref--fill-and-display word "used by" res)))
 
 (defun fuel-xref--apropos (str)
   (let* ((cmd `(:fuel* ((,str fuel-apropos-xref))))
          (res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
+    (with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word nil))
     (fuel-xref--fill-and-display str "containing" res)))
 
 (defun fuel-xref--show-vocab (vocab &optional app)
   (let* ((cmd `(:fuel* ((,vocab fuel-vocab-xref)) ,vocab))
          (res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
+    (with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word nil))
     (fuel-xref--fill-buffer vocab "in vocabulary" res t app)))
 
 (defun fuel-xref--show-vocab-words (vocab &optional private)