(defun refactor-backends ()
"Return alist of refactor operations and backends that support them."
- (let ((act-be-alist nil))
- (pcase-dolist (`(,be . ,acts)
- (seq-keep #'funcall refactor-backend-functions))
- (dolist (act acts)
- (push be (alist-get act act-be-alist))))
- act-be-alist))
+ (let ((op-be-alist nil))
+ (run-hook-wrapped
+ 'refactor-backend-functions
+ (lambda (be-fun &rest _)
+ (pcase (funcall be-fun)
+ (`(,be . ,ops)
+ (dolist (op ops)
+ (push be (alist-get op op-be-alist)))))))
+ op-be-alist))
;;;###autoload
(defun refactor (operation backend)
(interactive
(let* ((op-be-alist (refactor-backends))
- (op (funcall refactor-read-operation-function op-be-alist)))
+ (op (if op-be-alist
+ (funcall refactor-read-operation-function op-be-alist)
+ (user-error "No refactor operations available"))))
(list op (car (alist-get op op-be-alist)))))
(pcase operation
('rename (refactor-rename backend))
;; ('inline (refactor-inline backend))
;; ('organize (refactor-organize backend))
;; ('simplify (refactor-simplify backend))
- (_ (refactor-backend-custom-operation backend operation))
- ))
+ (_ (refactor-backend-custom-operation backend operation))))
(cl-defgeneric refactor-backend-custom-operation (backend operation)
"Apply custom refactoring OPERATION provided by BACKEND.")