rolandwalker / fixmee

Quickly navigate to FIXME notices in Emacs
66 stars 4 forks source link

add fixmee-measure-urgency-function #15

Closed jcostello50 closed 1 year ago

jcostello50 commented 1 year ago

Adds the defcustom fixmee-measure-urgency-function to allow the user to specify an alternate function for determining the urgency for each notice.

rolandwalker commented 1 year ago

Fun. Example?

jcostello50 commented 1 year ago

With the fixmee-notice-regexp set like

(setq fixmee-notice-regexp
      (concat  "\\(?:#\\|//\\|;*\\).*\\("
               (regexp-opt
                '("TODO"
                  "COMMENT"
                  "FACTOR"
                  "REVIEW"
                  "STYLE")
                nil)
               (rx
                (opt "("
                     (+ num)
                     ")"))
               "\\):.*"))

I use this function for fixmee-measure-urgency-function

(defun jnc/fixmee-measure-urgency (kwd)
  (or (save-match-data
    (when (string-match (rx (+ anychar) "(" (group (+ num)) ")") kwd)
      (string-to-number (match-string 1 kwd))))
      9999))

Then with these comments in foo.cc

int main(int argc, char *argv[]) {
   // COMMENT: lowest urgency
   int x = 47;
   // FACTOR(2): second highest urgency
   int y = 42;
   // TODO(1): highest urgency
   return 0;
}

I can sort by urgency in the *fixmee notices* buffer and get:

foo.cc:6                            1          // TODO(1): highest urgency
foo.cc:4                            2          // FACTOR(2): second highest urgency
foo.cc:2                            9999       // COMMENT: lowest urgency

I use this when code is in a "roughly finished" state to explicitly decide that some of the todos should be tackled first.