Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Whitesmith style indentation issues

Aperta
#133 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
emacs, emacs-lisp, php
Ambito
tooling

Direzione di ricerca

Inizia riproducendo l'indentazione in stile Whitesmith con php-mode 1.12, soprattutto quando il cursore si trova all'interno delle parentesi rispetto a quando si trova alla fine delle parentesi e quando electric-pair è abilitato. Confronta gli offset delle parentesi graffe di chiusura e l'indentazione di funzioni, condizionali e righe annidate; il lavoro è completato quando questi casi producono un'indentazione coerente allineata alle parentesi graffe senza modifiche manuali agli offset.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I apologize if php-mode was only intended to use the four styles mentioned in the readme, but I know for certain I indent my code in Whitesmith style, so that's what I've been using because there isn't clear documentation on the php-mode styles. If there is a Whitesmith-like I should be using, feel free to point me toward it.

I've noticed two issues that are more of an annoyance to me, for each of which I have a workaround and are not present in K&R. First is close braces are indented one indent deeper than their matching open braces. I was not able to replicate this behavior in other major modes, although I'm new to Emacs, so I may not have controlled the offset variables well enough in my tests. I'm able to circumvent this behavior by manually setting the close offsets to 0 after loading php-mode and switching to the Whitesmith style.

Second, I noticed while using electric-pair that functions, if's / and elseif's, and any line requiring parentheses will indent to two different places depending on if the cursor is within the parentheses. If the cursor is between the parentheses where the argument variables go, functions, if's, and else's will indent one deeper than the braces, putting them two deeper than the class and function level code beneath them. If the cursor is at the end of the line during the indent, these lines are appropriately indented to be in line with the braces and one deeper than the class and function level code beneath them. This behavior can be replicated after a line has its argument list closed by going to the end of the line, indenting, moving the cursor into the parentheses, and indenting again.

Here is an example of what I can indent my code to look like if I indent while in the parentheses of each line:

class namespace ()
    {
        function foo ()
            {
                if ($x)
                    {
                    echo $bar;
                    }
            }
    }

If I put parentheses around $bar, I can give echo $bar an additional indent by indenting with my cursor in the parentheses. With electric-pair off, the line indents too far when opening parentheses, and indents it back to proper depth when closing parentheses. Using electric-pair, because open and close are done in that order in one function, indents the line too far, and must be indented back by moving to the end of the line and issuing the indent command.

Where if I indent at the end of the lines, I get (and should only get) this:

class namespace ()
    {
    function foo ()
        {
        if ($x);
            {
            echo $bar;
            }
        }
    }

My php-mode-modified variable is 2013-09-20, and my php-mode-version variable is 1.12.

Lingua principale
Emacs Lisp
Stelle
602
Fork
117
Merge medio
12h 54m
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di emacs-php/php-mode

Tutte le issue di emacs-php/php-mode

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.