bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

suggestion for imenu


From: Konstantin Malakhanov
Subject: suggestion for imenu
Date: Wed, 19 Jun 2002 14:39:57 +0200
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-msvc-nt5.0.2195)

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.2.1 (i386-msvc-nt5.0.2195)
 of 2002-06-18 on TRITON
configured using `configure --with-msvc (12.00)'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: DEU
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: nil

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

It's not a bug, its a suggestion for imenu.

I introduce a new option for imenu: if imenu call finds a reasonalble
completion, use it without prompt, with possibilities 'never (current
imenu behaviour), for mouse event only and always. 

Notice that this is different from
imenu-always-use-completion-buffer-p, which just select between asking
in completion buffer or as mouse menu.

I don't like the standard way if imenu, where I have always confirm
jump to a function, whether imenu has found a suitable name at the
point or not. With the new option , if imenu "sees" a suitable name,
it just go to it without confirmation. Next, I patch imenu to set
point to where the mouse click occurs, if imenu is called via
mouse. So now I can bind (define-key esc-map [mouse-1] 'imenu)

and with a click at the function name somewhere in the source code I
get it's definition. Speeds up things a lot!

A patch is beneath.
--- /cygdrive/c/emacs-21.2/lisp/imenu.el        Sun Jul 15 16:15:34 2001
+++ /cygdrive/h/emacs/imenu.el  Tue Dec  4 09:01:38 2001
@@ -174,6 +174,13 @@
   :type 'string
   :group 'imenu)
 
+(defcustom imenu-use-default-completion nil
+  "*If imenu call finds a reasonalble completion, use it without prompt." 
+  :type '(choice (const :tag "On Mouse" nil)
+                (const :tag "Never - use prompt anyway" never)
+                (other :tag "Always" t))
+  :group 'imenu)
+
 ;;;###autoload
 (defvar imenu-generic-expression nil
   "The regex pattern to use for creating a buffer index.
@@ -870,6 +877,8 @@
 
 Returns t for rescan and otherwise a position number."
   ;; Create a list for this buffer only when needed.
+  (if (listp last-nonmenu-event) 
+      (mouse-set-point last-nonmenu-event))
   (let ((name (thing-at-point 'symbol))
        choice
        (prepared-index-alist
@@ -883,6 +892,10 @@
          ((and name (imenu--in-alist name prepared-index-alist))
           (setq prompt (format "Index item (default %s): " name)))
          (t (setq prompt "Index item: ")))
+    (if (or (null name) ;; no name found
+           (and (null imenu-use-default-completion) ;; use name if mouse & not 
mouse event 
+                (not (listp last-nonmenu-event)))
+           (eq imenu-use-default-completion 'never)) ;; never use name, always 
go though prompt
     (if (eq imenu-always-use-completion-buffer-p 'never)
        (setq name (completing-read prompt
                                    prepared-index-alist
@@ -902,7 +915,7 @@
          ;; Make a completion question
          (setq name (completing-read prompt
                                      prepared-index-alist
-                                     nil t nil 'imenu--history-list name)))))
+                                         nil t nil 'imenu--history-list 
name))))))
     (cond ((not (stringp name))
           nil)
          ((string= name (car imenu--rescan-item))

-- 
Konstantin Malakhanov 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]