Hello,

> Maybe it would be a good idea to let the user specify the regexps
> directly in jde-imports-groups. That way a string like "javax?."
> would match both the "java.*" and "javax.*" classes and order them
> in the same group.

This is a very good idea :-)

The following redefines `jde-import-groups' and `jde-imports-group-of'
to let the user specify the regexps directly.

(defcustom jde-imports-groups '("^javax?\\.")
  "*List of import groups used by `jde-order-imports'.
Each group is a regexp.  An import belongs to a group when
its name matches the regexp."
  :group 'jde-project
  :type '(repeat (string))
  :set '(lambda (sym val)
          (custom-set-default sym (delete "" val))))

(defun jde-imports-group-of (import-token)
  "Return the group IMPORT-TOKEN belongs to or nil if not found.
Returned group is the first value of `jde-imports-groups' matched
by the import name."
  (let ((import-name (semantic-token-name import-token))
        (groups      jde-imports-groups)
        match group)
    (while (and groups (not match))
      (setq group  (car groups))
      (setq match  (and (string-match group import-name)
                        group))
      (setq groups (cdr groups)))
    match))

Thank you for your feedback.
Sincerely,
David

Reply via email to