Comments (16)
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.
@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.
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.
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.
hi, @ejmr have you duplicated this?
from php-mode.
Sorry @cnwggu but not yet, unfortunately. I will continue to work on tracking down the problem though.
from php-mode.
I can replicate this problem now, so that is one step towards fixing it. :)
from php-mode.
@ejmr you are so nice
from php-mode.
@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.
@ejmr seems there is no better solutions for this, huh?
from php-mode.
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.
i never write elisp before.
so it's kind of difficult for me
from php-mode.
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.
@ejmr heh, Merry Christmas eve and Christmas day.
from php-mode.
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.
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)
- Please tag release (prerelease or beta is ok) for Emacs 28 compatibility HOT 1
- Error in ternary operator indentation HOT 1
- Unexpected syntax highlights after "new" in string HOT 1
- Automatic, overly-clever brace-matching is annoying and how to turn it off is non-obvious HOT 2
- Function faces HOT 1
- Commented out array elements break indentation HOT 2
- Drop Emacs 25 Support
- WordPress coding style removing spaces around function args HOT 1
- The last argument of the method is not highlighted
- PEAR method chaining wrong indentation HOT 5
- File mode specification error HOT 5
- Indentation issue with closure/anonymous functions
- Lineup Cascaded Calls doesn't work properly
- emacs master results in error HOT 2
- Drop Emacs 26 Support
- Newline Indentation aligning with equal sign HOT 3
- while keyword says 'At top level' HOT 2
- Remove `$` from face names for interoperability with treesit
- `php-function-call` face does not inherit from `font-lock-function-call-face` HOT 2
- Highlight of first heredoc with quotes broken depending on how many characters exists before it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-mode.