all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* octave-mode: Indentation of multi-line expressions?
@ 2023-08-07 13:39 Klaus-Dieter Bauer
  2023-08-07 14:12 ` Klaus-Dieter Bauer
  0 siblings, 1 reply; 2+ messages in thread
From: Klaus-Dieter Bauer @ 2023-08-07 13:39 UTC (permalink / raw)
  To: help-gnu-emacs

   Hello!
   I am looking for a way to customize octave-mode such that it will
   produce indentation like
       [a, b] = function_name(
           first_argument,
           second_argument
       );
   Out of the box, except for setting `octave-block-offset` to 4 for
   compatibility with existing project code, I get an indentation
       [a, b] = function_name(
                        first_argument,
                        second_argument
                    );
   which is not ideal for readability.
   Best regards,
   Klaus
   ----------------------------------------------------------------------
   Emacs information:
   In GNU Emacs 27.1 (build 4, x86_64-pc-linux-gnu, GTK+ Version 2.24.32)
    of 2022-07-29 built on a PC named so weirdly by the admin, I censored
   it
   Windowing system distributor 'The X.Org Foundation', version
   11.0.12003000
   System Description: openSUSE Leap 15.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: octave-mode: Indentation of multi-line expressions?
  2023-08-07 13:39 octave-mode: Indentation of multi-line expressions? Klaus-Dieter Bauer
@ 2023-08-07 14:12 ` Klaus-Dieter Bauer
  0 siblings, 0 replies; 2+ messages in thread
From: Klaus-Dieter Bauer @ 2023-08-07 14:12 UTC (permalink / raw)
  To: help-gnu-emacs

For reference, I do not need that  e x a c t  formatting. Any reasonable indentation will do. Only, while cleaning up project code, the default behavior did not give useful results. For instance in the (anonymized) code sample:

     for i = 1:imax
         % ...
         if not(load_from_file)
             [p_ext,c_ext,time,origin] = calculate_coefficients(
                                                 a,long,list,of,arguments,as,existing,
                                                 in,the,code,base,followed,by,
                                                 'an expression in a string'
                                             );
         else
             % ...
         end
         % ...
     end

Recommendations on how to write the code in a way that plays more nicely with the indentation in Emacs would help as well. For reference, Octave's

     Edit > Format > Indent Code

will produce an unhelpful

     [p_ext,c_ext,time,origin] = calculate_coefficients(
     a,long,list,of,arguments,as,existing,
     in,the,code,base,followed,by,
     'an expression in a string'
     );

and Matlab's "Smart Indent" will produce

     [p_wbt,cond_wbt,time,source] = wbt_surfacewise_ngauss(...
         name,p,e,source,ar,as,at,nu_min,d_nu,nu_max,ngauss_steps,mult,...
         'savesys=0; save_and_collect=0; externalsolver=1; mlv_source_loaded=1;'...
         );

but requires explicit continuation syntax ("...").

best regards,
Klaus

On 07.08.23 15:39, Klaus wrote:
> Hello!
> 
> I am looking for a way to customize octave-modesuch that it will produce indentation like
> 
>      [a, b] = function_name(
>          first_argument,
>          second_argument
>      );
> 
> Out of the box, except for setting `octave-block-offset` to 4 for compatibility with existing project code, I get an indentation
> 
>      [a, b] = function_name(
>                       first_argument,
>                       second_argument
>                   );
> 
> which is not ideal for readability.
> 
> Best regards,
> Klaus
> 
> ----------------------------------------------------------------------
> Emacs information:
> In GNU Emacs 27.1 (build 4, x86_64-pc-linux-gnu, GTK+ Version 2.24.32)
>   of 2022-07-29 built on a PC named so weirdly by the admin, I censored it
> Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
> System Description: openSUSE Leap 15.3
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-07 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 13:39 octave-mode: Indentation of multi-line expressions? Klaus-Dieter Bauer
2023-08-07 14:12 ` Klaus-Dieter Bauer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.