help-gnats
[Top][All Lists]
Advanced

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

Re: Is anyone using the Emacs interface in 4.1.0?


From: Mel Hatzis
Subject: Re: Is anyone using the Emacs interface in 4.1.0?
Date: Mon, 01 Aug 2005 13:01:19 -0700
User-agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716)

Chad Walstrom wrote:
> Chuck Alexander <address@hidden>  wrote:
> 
>>... But I also know zip about lisp, so I'm not able to look into the
>>problems I'm seeing with Gnats 4.1.
> 
> 
> Any elispers out there that could help?

I spent a little time mucking with the elisp a while back.
With help from a colleague at work we were able to come up
with a few patches that addressed some of the problems I'd
encountered.

I am attaching the patches for your perusal. My lisp is extremely
rusty...in fact, you could argue that it no longer exists,
so please don't ask me for much more assistance unless you're
desperate.

gnats.el.1.patch and gnats.el.3.patch are bug fixes from memory.

gnats.el.2.patch is an enhancement which builds multi-paned menus
for some lists (useful if you have many categories for example).

The major problem I recall with the emacs interface is that
it's possible for users to overwrite each other's changes.
i.e. there's no checking to determine if the PR was modified
prior to updating it when you're editing. I had an idea to
supplement the GNATS protocol with some additional commands
to support transactions however, I've had very little time
recently.

I hope the patches prove useful.

--
Mel Hatzis
Change Log:

2003-10-10  Mark D Baushke <address@hidden>

        * gnats.el (gnats-do-query): Accept a list of PR numbers as an
                  alternative to just a gnats query expression.

--- gnats.el~   Fri Oct 10 13:55:33 2003
+++ gnats.el    Fri Oct 10 14:55:34 2003
@@ -1592,9 +1592,15 @@ The function works in the query buffers.
   ;; TODO: Handle gnatsd errors.
   (gnats-send-command "QFMT" "summary")
   (gnats-send-command "RSET")
-  (unless (string= query "")
-    (gnats-send-command "EXPR" query))
-  (let ((result (gnats-send-command "QUER")))
+  (let* ((quer-cmd
+         (cond
+          ((string-match "^\[0-9 \]\+$" query)
+           (concat "QUER " query))
+          (t
+           (unless (string= query "")
+             (gnats-send-command "EXPR" query))
+           "QUER")))
+         (result (gnats-send-command quer-cmd)))
     (unless (= (caar result) 300)
       (error "Query error (%d %s)" (car (car result)) (cadr (car result))))
     (setq result (cdr result))
--- 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
--- gnats.el~   6 Dec 2002 10:32:58 -0000       1.1.1.1
+++ gnats.el    11 Oct 2003 01:09:57 -0000
@@ -1197,7 +1197,7 @@ gnats-server-conn's `parsed-output' prop
 parsed, the `output-complete' property is set."
   (put gnats-server-conn 'curr-output
        (concat (get gnats-server-conn 'curr-output) output))
-  (if (eq 10 (string-to-char (substring output -1)))
+  (if (eq ?\n (string-to-char (substring output -1)))
       (progn
        (gnats-debug-string (get gnats-server-conn 'curr-output))
        (let ((our-output (get gnats-server-conn 'curr-output)))

reply via email to

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