github.phpd.cn/thought-machine/please@v12.2.0+incompatible/tools/misc/please-mode.el (about) 1 ; Definition of Please mode for Emacs. 2 ; Mostly inherits from python-mode and has that do all the hard work, the 3 ; main advantage is automatic invocation of buildifier. 4 ; 5 ; Add this to .emacs to make this load automatically. 6 ;(add-to-list 'auto-mode-alist '("BUILD" . please-mode)) 7 ; And add this to run buildifier on the current buffer when saving: 8 ; (add-hook 'after-save-hook 'please-buildify-on-save). 9 10 (defun please-buildify () 11 "Format the current buffer according to the buildifier tool, 12 in a pretty quick and dirty way." 13 (interactive) 14 (call-process "buildifier" nil nil nil "-mode=fix" (buffer-file-name)) 15 (revert-buffer t t)) 16 17 ;;;###autoload 18 (defun please-buildify-on-save () 19 (interactive) 20 (when (eq major-mode 'please-mode) (please-buildify))) 21 22 (define-derived-mode please-mode python-mode "Please mode") 23 24 (provide 'please-mode)