Giter Site home page Giter Site logo

Comments (16)

ejmr avatar ejmr commented on August 24, 2024

Sorry but I cannot duplicate this. If I take your example and run indent-region on it then the code lines up with the -> operator as expected. However, this may be because we are using different versions of Emacs and/or php-mode. Please let me know what version of Emacs you have (i.e. from C-h C-a) and values of php-mode-version-number and php-mode-modified so I can try to replicate it. Thanks.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

@ejmr i use TAB or C-j to indent next line. i will check emacs version and php-mode version later.

thank you for the patience.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

php-mode-version: PHP mode 1.5.0-nxhtml-1.94 of 2009-08-12
GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu)

i can not excute `php-mode-modified' command, but i opened php-mode.el and get things like below:

;; Maintainer: Eric James Michael Ritz <lobbyjones at gmail dot com>
;; Original Author: Turadg Aleahmad, 1999-2004
;; Keywords: php languages oop
;; Created: 1999-05-17
;; X-URL:   https://github.com/ejmr/php-mode

(defconst php-mode-version-number "1.9"
  "PHP Mode version number.")

(defconst php-mode-modified "2012-12-11"
  "PHP Mode build date.")

are these all right?

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

Thank you, that is very helpful :)

Also, php-mode-modified is a variable and not a command, so in the future you can use the command C-h v to see its value; and for php-mode-version-number too.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

hi, @ejmr have you duplicated this?

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

Sorry @cnwggu but not yet, unfortunately. I will continue to work on tracking down the problem though.

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

I can replicate this problem now, so that is one step towards fixing it. :)

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

@ejmr you are so nice

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

@cnwggu Thanks :)

So here is the problem. There are lots of calls to c-set-offset in php-mode to setup the indentation and alignment rules. By default php-mode sets three offsets to c-lineup-cascaded-calls; this is what aligns the -> operator. However, commit 89eefdf by @zapad changes the offset for statement-cont to the value +. I cannot simply revert that commit because it fixes an indentation bug and we need his fix in php-mode.

i am thinking a solution may be to write a 'custom line-up function' (section 11.4 of the CC Mode manual) which looks at the previous line and decides whether or not to use the + offset or c-linup-cascaded-calls. My first idea was to simply check to see if there is a brace at the end of the previous line, but that does not work. So instead the function will have to determine if the previous line is something that may be potentially followed a single line, such as

foreach ($x as $y)
    echo $y;

But if anyone knows a more simple solution, or sees a problem with my approach, I would greatly appreciate the feedback.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

@ejmr seems there is no better solutions for this, huh?

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

seems there is no better solutions for this, huh?

There probably is a better solution since I am no expert with Elisp, but the approach I described above is what I am going to work on implementing. I will try to patch php-mode to fix this problem in the next few days.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

i never write elisp before.

so it's kind of difficult for me

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

That's ok @cnwggu because I was not trying to ask you to write the patch. I was only explaining the approach I intend to take and give insight for any others who may have a better idea than mine. I will try to write the Elisp to fix this problem in the next week, but with it being Christmas in the United States I may not have the time.

from php-mode.

guweigang avatar guweigang commented on August 24, 2024

@ejmr heh, Merry Christmas eve and Christmas day.

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

Thank you @cnwggu :)

And the same to you as well, and to everyone else who helps me work on php-mode. Thank you everyone.

from php-mode.

ejmr avatar ejmr commented on August 24, 2024

I applied a patch to my local copy of master which addresses this problem, which I will be pushing out soon after merging in a few other updates. So for now I am going to close this issue.

from php-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.