Format your elisp code and save your time, you don’t need to format elisp code line by line. 😊
What is ElispFormat?
ElispFormat is a mode that format elisp code.
Install
From MELPA
There is a slightly updated version at https://github.com/Yuki-Inoue/elisp-format, which can be installed by ‘M-x package-install elisp-format’
, after configuring package.el to use the MELPA repository.
From EmacsWiki
- Put Lisp:elisp-format.el in your load-path, and add
(require 'elisp-format)
- in your ~/.emacs
Command List
- Format region or defun.
- Format buffer.
- Format file.
- “elisp-format-file-batch”
- Format file with
‘batch’
.
- Format recursive elisp files under specify directory.
- “elisp-format-directory-batch”
- Format recursive elisp files under specify directory, but with
‘batch’
.
- “elisp-format-dired-mark-files”
- Format dired marked files.
- Format library file.
Customize
All below option can customize by: M-x customize-group RET elisp-format RET
‘elisp-format-batch-program’
- The program name for execute batch command.
- The column number to truncate long line.
‘elisp-format-indent-comment’
- Whether indent comment.
‘elisp-format-dired-confirm’
- Whether confirmation is needed to format dired marked files.
‘elisp-format-newline-keyword-addons-list’
- The list contain addons keywords for newline.
‘elisp-format-newline-keyword-except-list’
- The list contains except keywords for newline.
‘elisp-format-split-subexp-keyword-addons-list’
- The list contains addons keywords that will split it’s sub-expression.
‘elisp-format-split-subexp-keyword-except-list’
- The list contains except keywords that will split it’s sub-expression.
‘elisp-format-split-subexp-keyword-keep-alist’
- The alist contains keep keyword when split it’s sub-expression.
Tips
- If current mark is active, command “elisp-format-region” will format region you select, otherwise it will format defun around point.
- If you want format many files, you can marked them in dired, and use command “elisp-format-dired” to format marked files in dired.
- You can format special file through command “elisp-format-file”.
- By default, when you format huge file, it will hang emacs. So you can use command
‘elisp-format-file-batch’
make format process at background. - You also can use command
‘elisp-format-directory’
format all recursive elisp files in special directory. - By default, when you use command
‘elisp-format-directory’
format too many elisp fields, it will hang emacs. So you can use command ‘elisp-format-directory-batch’
make format process at background. - If you’re lazy, you can use command “elisp-format-library” format special library and don’t need to input long file path.
Notes
I can’t ensure this package will do a perfect work with all situations, I have test it with all elisp files that are builtin GNU Emacs 23.0.60.1. So please let me know if you have any suggestion or bug. – AndyStewart