multi-line icon indicating copy to clipboard operation
multi-line copied to clipboard

Add Leading Commas Support (C++, Haskell)

Open articuluxe opened this issue 9 years ago • 4 comments

My compliments on a slick package. It looks very powerful, although it is not very clear how to configure it.

On to my question. Is it possible to configure multi-line for a c++ signature such that the parameters take one per line, but the commas lead the parameters, not trail them?

void func(
    int a
    , char b
    , double c
    , bool b = false
    );

articuluxe avatar Sep 08 '16 02:09 articuluxe

My compliments on a slick package. It looks very powerful, although it is not very clear how to configure it.

Yeah, configuration is pretty complicated because of how multi-line aims to support so many different languages, indentation styles.

On to my question. Is it possible to configure multi-line for a c++ signature such that the parameters take one per line, but the commas lead the parameters, not trail them?

Wow, I've never heard of that multi-lining style before. Yes, that should be possible but it will require writing a tiny bit of elisp. Let me see if I can cook something up.

colonelpanic8 avatar Sep 08 '16 04:09 colonelpanic8

Hah, okay, this is a mouthful, but it was actually pretty easy. Single lining doesn't really work, but I'm pretty sure that I could get it there, but I think that I would need to tweak the way respacing works.

(defvar multi-line-leading-commas-strategy
  (make-instance 'multi-line-strategy
                 :find
                 (make-instance 'multi-line-forward-sexp-find-strategy
                                :split-advance-fn (lambda ()))
                 :respace
                 (multi-line-default-respacers
                  (multi-line-clearing-reindenting-respacer
                   (make-instance 'multi-line-always-newline)))))

EDIT: oh and to make it active in C++ buffers you would add:

(multi-line-defhook c++ multi-line-leading-commas-strategy)

If you want this strategy everywhere:

(setq-default multi-line-leading-commas-strategy)

colonelpanic8 avatar Sep 08 '16 05:09 colonelpanic8

@danrharms can let me know when you get a chance to test this out so I can close this issue

colonelpanic8 avatar Sep 08 '16 18:09 colonelpanic8

Sure will do, sorry I'm away from my computer today.

On Sep 8, 2016, at 1:48 PM, Ivan Malison [email protected] wrote:

@danrharms can let me know when you get a chance to test this out so I can close this issue

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

articuluxe avatar Sep 08 '16 20:09 articuluxe