Hi,

thanks for gnu global!

gtags.el enables completion on "tab" only for tag and symbols. I am so
used to completion, that I find myself often removing a "tab" from the
"Find files:" prompt :-).

So, I patched "Find files:" to enable completion. I find it useful,
and it makes the emacs user interface more consistent.

A patch against 5.7.6 is attached. As I am not a lisp expert, there
may be better ways to do this.

Regards,
  Tobias
--- gtags.el.orig	2009-10-15 14:11:39.000000000 +0200
+++ gtags.el	2009-10-15 14:13:28.000000000 +0200
@@ -223,8 +223,10 @@
   (gtags-completing 'gtags string predicate code))
 (defun gtags-completing-gsyms (string predicate code)
   (gtags-completing 'gsyms string predicate code))
+(defun gtags-completing-files (string predicate code)
+  (gtags-completing 'files string predicate code))
 ;; common part of completing-XXXX
-;;   flag: 'gtags or 'gsyms
+;;   flag: 'gtags or 'gsyms or 'files
 (defun gtags-completing (flag string predicate code)
   (let ((option "-c")
         (complete-list (make-vector 63 0))
@@ -233,11 +235,18 @@
     (set-buffer (generate-new-buffer "*Completions*"))
     (if (eq flag 'gsyms)
         (setq option (concat option "s")))
+    (if (eq flag 'files)
+        (setq option "-P"))
     (call-process "global" nil t nil option string)
     (goto-char (point-min))
-    (while (looking-at gtags-symbol-regexp)
-      (intern (gtags-match-string 0) complete-list)
-      (forward-line))
+    (if (eq flag 'files)
+        (while (looking-at (concat ".*\\(" string ".*\\)"))
+          (intern (gtags-match-string 1) complete-list)
+          (forward-line))
+      (while (looking-at gtags-symbol-regexp)
+        (intern (gtags-match-string 0) complete-list)
+        (forward-line))
+      )
     (kill-buffer (current-buffer))
     ; recover current buffer
     (set-buffer prev-buffer)
@@ -349,7 +358,8 @@
   (interactive)
   (let (tagname prompt input)
     (setq prompt "Find files: ")
-    (setq input (read-string prompt))
+    (setq input (completing-read prompt 'gtags-completing-files
+                  nil nil nil gtags-history-list))
     (if (not (equal "" input)) (setq tagname input))
     (gtags-push-context)
     (gtags-goto-tag tagname "P")))
_______________________________________________
Bug-global mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to