another bug fix for the GNATS emacs interface

Mel Hatzis <[email protected]>
Newsgroups gmane.comp.bug-tracking.gnats.general
Message-ID <[email protected]>
The emacs client interface for GNATS has an edit-mode
whereby it's possible to right-click on an Enum field
and get a popup menu of all the enum field values.
Unfortunately, if the number of Enum values exceeds
the number that can be displayed in a single popup
menu, only a subset of the values is displayed.

Please review the attached patch which fixes the
edit mode so that the Enum values are displayed
in a a multi-paned (cascading) menu. The number
of values displayed in each sub-menu is based
on the frame-height associated with the emacs
session.

--
Mel Hatzis

_______________________________________________
Help-gnats mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/help-gnats
gnats.el.patch (text/plain, 2.6 KB)
--- gnats.el~	6 Dec 2002 10:32:58 -0000	1.1.1.1
+++ gnats.el	11 Oct 2003 01:13:05 -0000
@@ -85,6 +85,11 @@ If the environment variable is unset, \"
   :group 'gnats
   :type 'boolean)
 
+(defcustom gnats-menu-length 70
+  "*Maximum length of a name displayed on a popup menu."
+  :type 'integer
+  :group 'boolean)
+
 
 
 (defvar gnats-server-conn nil
@@ -294,6 +299,43 @@ Use an X menu for the value selection."
   (sit-for 0)
   (gnats-request-enum (get-text-property (point) 'gnats-field-name) e))
 
+(defun gnats-menu-build-paned-menu (name entries)
+  "Build a multi-paned menu named NAME from the strings in ENTRIES.
+That is, ENTRIES is a list of strings which appear as the choices
+in the menu.  The number of panes depends on the number of entries.
+The visible entries are truncated to `gnats-menu-length', but the
+strings returned are not."
+  (let* ((f-height (/ (frame-height) 2))
+         (pane-list
+          (let (temp-pane-list
+                (iter 0))
+            (while entries
+              (let (lst
+                    (count 0))
+                (while (and (< count f-height) entries)
+                  (let ((str (car entries)))
+                    (setq lst (cons
+                               (cons
+                                (if (> (length str) gnats-menu-length)
+                                    (substring str 0 gnats-menu-length)
+                                  str)
+                                str)
+                               lst))
+                    (setq entries (cdr entries))
+                    (setq count (1+ count))))
+                (setq iter (1+ iter))
+                (setq
+                 temp-pane-list
+                 (cons
+                  (cons
+                   (format "-*- %s (%d) -*-" name iter)
+                   (nreverse lst))
+                  temp-pane-list))))
+            (nreverse temp-pane-list))))
+
+    ;; Return the menu:
+    (cons (concat "-*- " name " -*-") pane-list)))
+
 (defun gnats-request-enum (field &optional menup no-default)
   "Ask the user for an enumerated value for FIELD and change the field value.
 If MENUP is non-nil, use an X menu for the selection.
@@ -305,9 +347,9 @@ minibuffer."
 	  (if menup
 	      (x-popup-menu
 	       t
-	       (list (concat "New value for " (get field 'field-name) ":")
-		     (cons "" (mapcar (lambda (x) (cons (car x) (cadr x)))
-				      completions))))
+	       (gnats-menu-build-paned-menu
+		(concat "New value for " (get field 'field-name) ":")
+		(mapcar (lambda (x) (car x)) completions)))
 	    (completing-read
 	     (concat "New value for " (get field 'field-name) ": ")
 	     completions nil t
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.