+(defun debbugs-org-regenerate-status ()
+ "Regenerate the `tabulated-list-id' text property.
+This property is used when following the [Messages] link, so you
+need to regenerate it when opening an .org file after you killed
+the corresponding buffer (e.g. by closing Emacs.)"
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward ":DEBBUGS_ID:[ \t]*\\([0-9]+\\)" nil t)
+ (let* ((bugnum (string-to-number (match-string 1)))
+ (mw (org-entry-get (point) "MERGEDWIDTH"))
+ (tli (list (cons 'id bugnum)
+ (cons 'bug_num bugnum)
+ (cons 'mergedwidth (if mw (string-to-number mw)))))
+ (beg (org-back-to-heading t))
+ (end (org-end-of-subtree t)))
+ (add-text-properties beg end `(tabulated-list-id ,tli))))))
+