Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
46 lines (41 sloc) 1.98 KB
(require 'my/project)
(defcustom akirak/project-formatter-list nil
"List of formatters to use in individual projects.")
(defun akirak/get-reformatter-formatters ()
(cl-loop for sym being the symbols of obarray
;; Filter minor modes
when (and (memq sym minor-mode-list)
(string-suffix-p "-on-save-mode" (symbol-name sym)))
collect (string-remove-suffix "-on-save-mode" (symbol-name sym))))
(defun akirak/pick-mode-formatter (mode)
(-some->> akirak/project-formatter-list
(assoc mode)
(cl-defun akirak/get-project-formatter (&optional project &key mode)
(let* ((project (or project (akirak/project-root default-directory)))
(mode (or mode major-mode))
(formatter (-some->> akirak/project-formatter-list
(assoc mode)
(assoc project)
(or formatter
(let* ((formatter (list 'reformatter
(completing-read (format "Formatter for %s in project %s: "
(abbreviate-file-name project))
nil t nil nil
(akirak/pick-mode-formatter mode))))
(cell (assoc mode akirak/project-formatter-list))
(subcell (cons project formatter)))
(setcdr cell (cons subcell (cdr cell))))
(add-to-list 'akirak/project-formatter-list (cons mode (list subcell)))))
(customize-save-variable 'akirak/project-formatter-list
"Set by akirak/get-project-formatter")
(provide 'my/formatter)