Package: cscope
Version: 15.5-1.1
Severity: minor
Tags: patch

When searching for functions called by the current function and
selecting a result in the *cscope* buffer, the cursor often jumps to a
wrong line in the source code buffer.

This happens because the cscope-adjust variable is set to true and emacs
tries to search the name of the _calling_ function near the line
reported by cscope. The cscope-find-* functions try to disable or enable
the fuzzy matching feature by setting the cscope-adjust variable to nil
or true.  However, the cscope-adjust is set inside (let), which does not
work outside the find function. The attached patch fixes the problem by
setting the cscope-adjust globally with (setq).

There is also a related patch in the upstream:
http://sourceforge.net/tracker/index.php?func=detail&aid=482960&group_id=4664&atid=304664

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.9
Locale: LANG=C, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8)

Versions of packages cscope depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an
ii  libncurses5                 5.4-7        Shared libraries for terminal hand

cscope recommends no packages.

-- no debconf information
--- /usr/share/emacs/site-lisp/xcscope.el       2002-06-20 18:48:59.000000000 
+0300
+++ xcscope.el  2005-06-22 21:52:24.386650679 +0300
@@ -2307,8 +2307,9 @@
   (interactive (list
                (cscope-prompt-for-symbol "Find this symbol: " nil)
                ))
-  (let ( (cscope-adjust t) )    ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding symbol: %s" symbol)
                 (list "-0" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2320,8 +2321,9 @@
   (interactive (list
                (cscope-prompt-for-symbol "Find this global definition: " nil)
                ))
-  (let ( (cscope-adjust t) )    ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding global definition: %s" symbol)
                 (list "-1" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2331,9 +2333,9 @@
 (defun cscope-find-global-definition-no-prompting ()
   "Find a symbol's global definition without prompting."
   (interactive)
-  (let ( (symbol (cscope-extract-symbol-at-cursor nil))
-        (cscope-adjust t) )     ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ( (symbol (cscope-extract-symbol-at-cursor nil)) )
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding global definition: %s" symbol)
                 (list "-1" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2346,8 +2348,9 @@
                (cscope-prompt-for-symbol
                 "Find functions called by this function: " nil)
                ))
-  (let ( (cscope-adjust nil) )  ;; Disable fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust nil) ;; Disable fuzzy matching.
     (cscope-call (format "Finding functions called by: %s" symbol)
                 (list "-2" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2360,8 +2363,9 @@
                (cscope-prompt-for-symbol
                 "Find functions calling this function: " nil)
                ))
-  (let ( (cscope-adjust t) )    ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding functions calling: %s" symbol)
                 (list "-3" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2373,8 +2377,9 @@
   (interactive (list
                (cscope-prompt-for-symbol "Find this text string: " nil)
                ))
-  (let ( (cscope-adjust t) )    ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding text string: %s" symbol)
                 (list "-4" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2387,8 +2392,9 @@
                (let (cscope-no-mouse-prompts)
                  (cscope-prompt-for-symbol "Find this egrep pattern: " nil))
                ))
-  (let ( (cscope-adjust t) )    ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding egrep pattern: %s" symbol)
                 (list "-6" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2401,8 +2407,9 @@
                (let (cscope-no-mouse-prompts)
                  (cscope-prompt-for-symbol "Find this file: " t))
                ))
-  (let ( (cscope-adjust nil) )  ;; Disable fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust nil) ;; Disable fuzzy matching.
     (cscope-call (format "Finding file: %s" symbol)
                 (list "-7" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)
@@ -2416,8 +2423,9 @@
                  (cscope-prompt-for-symbol
                   "Find files #including this file: " t))
                ))
-  (let ( (cscope-adjust t) )   ;; Use fuzzy matching.
-    (setq cscope-symbol symbol)
+  (let ()
+    (setq cscope-symbol symbol
+         cscope-adjust t) ;; Use fuzzy matching.
     (cscope-call (format "Finding files #including file: %s" symbol)
                 (list "-8" symbol) nil 'cscope-process-filter
                 'cscope-process-sentinel)

Reply via email to