0

How can I automatically set fill-column based on flake8 configuration for python-mode buffers, specifically the max-line-length value in .flake8? Solutions that employs existing extensions are welcome.

  • Can you supply us with a shell command (something built into flake8?) which will read and output that value? – phils Sep 14 at 2:27
  • @phils I don't know what command would do that and I couldn't find one. Perhaps I should go to flake8 team and request such a feature. – xuhdev Sep 14 at 18:35
  • I imagine flake8 is using some such thing behind the scenes to read its config. You could do it in elisp, but I couldn't immediately find an elisp parser for that conf format, so I don't know whether that exists. You could just do a simple text search for the expected max-line-length entry, though, which would probably be "good enough". Perhaps you could add an example .flake8 file to the question. – phils Sep 15 at 22:56
  • As an alternative, you could of course add a .dir-locals.el file in the same location, if you didn't mind the duplication (although my impression is that the duplication is precisely what you're looking to avoid). – phils Sep 15 at 22:59
  • @phils Yes, that is correct. The point is that when Emacs opens a file in a project, it should automatically detect the max-line-length settings by flake8 to avoid manually setting up every time. – xuhdev Sep 16 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.