Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:08:34+00:00 2026-06-08T10:08:34+00:00

I use php-mode in Emacs, it work fine execept when I use closures as

  • 0

I use php-mode in Emacs, it work fine execept when I use closures as argument like this:

$app->get('/', function() use ($app) {
        echo "foo";
    });

It seams that when function is inside function invocation the indentation is doubled. How to fix this?

EDIT

How to make it look like this (the same as javascript-mode handle anonymous functions).

$app->get('/', function() use ($app) {
    echo "foo";
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:08:37+00:00Added an answer on June 8, 2026 at 10:08 am

    With help from @amalloy I manage to create this fix that solve the problem:

    (defun unident-closure ()
      (let ((syntax (mapcar 'car c-syntactic-context)))
        (if (and (member 'arglist-cont-nonempty syntax)
                 (or
                  (member 'statement-block-intro syntax)
                  (member 'block-close syntax)))
            (save-excursion
              (beginning-of-line)
              (delete-char c-basic-offset)))))
    
    (add-hook 'php-mode-hook (lambda ()
                               (add-hook 'c-special-indent-hook 'unident-closure))
    

    not sure If it need to be in php-mode-hook or not

    Great help was C-c C-s that show what will be in c-syntactic-context variable when c-special-indent-hook is fired (and it’s after indent was done).

    CC-Mode Manual also help

    UPDATE

    I found this code that is invalid

    array('tags' => array_map($rows,function($row) {
    ....    return array(
    ....        'name' => $row['name'],
    ....        'size' => $normalize($row['tag_count']);
    ....    );
    ....});
    

    (dots are the spaces that need to be removed)

    and another one

    return array('tags' =>
                 array_map($rows, function($row) use ($normalize) {
                 ....    return array(
                 ....        'name' => $row['name'],
                 ....        'size' => $normalize($row['tag_count']);
                 ....    );
                 ....});
    

    so I need to modify the function, C-c C-s shows that arglist-cont-nonempty appear twice (each additional arglist-cont-nonempty add more indent that need to be removed)

    (defun unident-closure ()
      (let ((syntax (mapcar 'car c-syntactic-context)))
        (if (and (member 'arglist-cont-nonempty syntax)
                 (or
                  (member 'statement-block-intro syntax)
                  (member 'brace-list-intro syntax)
                  (member 'brace-list-close syntax)
                  (member 'block-close syntax)))
            (save-excursion
              (beginning-of-line)
              (delete-char (* (count 'arglist-cont-nonempty syntax)
                              c-basic-offset))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to know, how I can use php's function mode_rewrite correctly. I'm currently
I am writing a minor mode for php/html files. I use a function (cf.
I need to do use php/regex to replace this: {{image-4-m}} to this: <img src=4.jpg
I want to use php in console mode and create an environment to test
I use NearlyFreeSpeech.Net as my host, and my php app (coded in CodeIgniter) needs
My header code: $(document).ready(function() { $('#sampleFile').uploadify({ 'uploader': 'include/uploadify/uploadify.swf', 'script': 'add_list.php', 'scriptData': {'mode': 'upload'}, 'fileDataName':
Use PHP and Mysql. Fields in my table (product) are id , full_price ,
I use php to display a table of data drawn from my mysql database.
I use php with ajax. <?php /* * Suppose, user has entered both correct
I am trying to use PHP to fire hits at Google to track newsletter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.