Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong indentation #138

Closed
crocket opened this issue Oct 18, 2013 · 8 comments
Closed

Wrong indentation #138

crocket opened this issue Oct 18, 2013 · 8 comments

Comments

@crocket
Copy link

crocket commented Oct 18, 2013

preg_replace_callback('/=\?[^\s?]+\?[^\s?]\?[^\s?]+\?=/',
function ($match) {
    $ret=imap_utf8($match[0]);
    if($ret === $match[0])
        $ret=mb_decode_mimeheader($match[0]);
    return $ret;
}, $header);

If you press TAB in an anonymous function, indentation goes wrong.

@TatriX
Copy link

TatriX commented Oct 18, 2013

Also:

$a = array('test',
'it'
);

$a = ['test',
'it'
];

# exptected:
$a = array('test',
    'it'
);
$a = ['test',
    'it'
];

@ejmr
Copy link
Collaborator

ejmr commented Oct 19, 2013

@crocket Would you please show what indentation you expect and with which style? I.e. C-c .

Thanks both for reporting the indentation issues.

@crocket
Copy link
Author

crocket commented Oct 19, 2013

I don't know any style, but I want indentations exactly as below.

preg_replace_callback('/=\?[^\s?]+\?[^\s?]\?[^\s?]+\?=/',
function ($match) {
    $ret=imap_utf8($match[0]);
    if($ret === $match[0])
        $ret=mb_decode_mimeheader($match[0]);
    return $ret;
}, $header);

However, I'm also okay with the following indentations.

preg_replace_callback('/=\?[^\s?]+\?[^\s?]\?[^\s?]+\?=/',
    function ($match) {
        $ret=imap_utf8($match[0]);
        if($ret === $match[0])
            $ret=mb_decode_mimeheader($match[0]);
        return $ret;
    }, $header);

Thankfully, none of styles that I can give to "C-c ." would satisfy me.
Each of them either has an issue with #114 or the above snippet.

@sten0
Copy link
Contributor

sten0 commented Sep 24, 2019

I think Debian Bug #286416 might be related to this issue, and maybe helps clarify the nature of the problem.

Cyril Bouthors writes:

I think php-elisp makes wrong indentation of the switch/case
statements when switch() is used inside any curly braces like for() or
function().

First example, switch is aligned on the first column, php-elisp makes
a correct indentation:

switch ($country) {
case 'France':
$phone_prefix=33;
break;
}

Second example, switch is used inside a function() and is not aligned
on the first column, php-elisp makes an incorrect indentation:

function foo()
{
switch ($country) {
case 'France':
$phone_prefix=33;
break;
}
}

The second example should be indented as:

function foo()
{
switch ($country) {
case 'France':
$phone_prefix=33;
break;
}
}

@sten0
Copy link
Contributor

sten0 commented Sep 26, 2019

Ah, quoting dropped the critical indentation. Oops. Here's what that bug actually reported:

First example, switch is aligned on the first column, php-elisp makes
a correct indentation:

switch ($country) {
 case 'France':
   $phone_prefix=33;
   break;
}


Second example, switch is used inside a function() and is not aligned
on the first column, php-elisp makes an _incorrect_ indentation:

function foo()
{
  switch ($country) {
  case 'France':
    $phone_prefix=33;
    break;
  }
}

The second example should be indented as:

function foo()
{
  switch ($country) {
    case 'France':
      $phone_prefix=33;
      break;
  }
}

I can confirm that the "incorrect indentation" in the second case is present in php-mode-1.21.4. Also, the first case appears differently in this release. It looks like this:

switch ($country) {
case 'France':
    $phone_prefix=33;
    break;
}

I don't know whether this is a genuine issue, or just a style thing.

@mallt
Copy link
Contributor

mallt commented Sep 26, 2019

@sten0 If you change the php-style to drupal you should be able to achieve the desired indendation: M-x php-set-style and then select drupal.

@sten0
Copy link
Contributor

sten0 commented Sep 27, 2019

Thank you @mallt :-D

@zonuexe zonuexe closed this as completed Sep 27, 2019
@sten0
Copy link
Contributor

sten0 commented Sep 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants