]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/gnorb/nngnorb.el
Merging Gnorb commits up to 1.0.1
[gnu-emacs-elpa] / packages / gnorb / nngnorb.el
index 0f0999abd8e05ed854eccab4ab2691f15c3b52d4..d1ed896556e0336bf0f30e9e04423db460eebaae 100644 (file)
@@ -39,6 +39,7 @@
 
 ;;; Code:
 
+(require 'gnus)
 (eval-and-compile
   (require 'nnheader)
   (require 'nnir))
@@ -156,7 +157,8 @@ be scanned for gnus messages, and those messages displayed."
          (setq m (org-link-unescape m))
          (when (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" m)
            (setq server-group (match-string 1 m)
-                 msg-id (match-string 3 m)
+                 msg-id (gnorb-bracket-message-id
+                         (match-string 3 m))
                  result (ignore-errors (gnus-request-head msg-id server-group)))
            (when result
             (setq artno (cdr result))
@@ -302,27 +304,32 @@ This is used in a Gnorb-created *Summary* buffer to remove the
 connection between the message and whichever Org TODO resulted in
 the message being included in this search."
   (interactive)
+  (unless (get-buffer-window gnus-article-buffer t)
+    (gnus-summary-display-article
+     (gnus-summary-article-number)))
   (let* ((msg-id (gnus-fetch-original-field "message-id"))
         (org-ids (gnus-registry-get-id-key msg-id 'gnorb-ids))
         chosen)
-    (when org-ids
-      (if (= (length org-ids) 1)
-         ;; Only one associated Org TODO.
-         (progn (gnus-registry-set-id-key msg-id 'gnorb-ids)
-                (setq chosen (car org-ids)))
-       ;; Multiple associated TODOs, prompt to choose one.
-       (setq chosen
-             (cdr
-              (org-completing-read
-               "Choose a TODO to disassociate from: "
-               (mapcar
-                (lambda (h)
-                  (cons (gnorb-pretty-outline h) h))
-                org-ids))))
-       (gnus-registry-set-id-key msg-id 'gnorb-ids
-                                 (remove chosen org-ids)))
-      (message "Message disassociated from %s"
-              (gnorb-pretty-outline chosen)))))
+    (if org-ids
+       (progn
+         (if (= (length org-ids) 1)
+             ;; Only one associated Org TODO.
+             (progn (gnus-registry-set-id-key msg-id 'gnorb-ids nil)
+                    (setq chosen (car org-ids)))
+           ;; Multiple associated TODOs, prompt to choose one.
+           (setq chosen
+                 (cdr
+                  (org-completing-read
+                   "Choose a TODO to disassociate from: "
+                   (mapcar
+                    (lambda (h)
+                      (cons (gnorb-pretty-outline h) h))
+                    org-ids))))
+           (gnus-registry-set-id-key msg-id 'gnorb-ids
+                                     (remove chosen org-ids)))
+         (message "Message disassociated from %s"
+                  (gnorb-pretty-outline chosen)))
+      (message "Message has no associations"))))
 
 (defvar nngnorb-status-string "")