0

I discovered that in php-mode, syntactic indentation makes rigid indentation very slow when the marked region is big. When I disable syntactic indentation, rigid indentation is not slow anymore.

So I made functions that disable syntactic indentation before indenting rigidly.

(defun my/indent-region-left-tab ()
  (interactive)
  (c-toggle-syntactic-indentation -1)
  (indent-rigidly (region-beginning) (region-end) -4)
  (c-toggle-syntactic-indentation 1)
  (setq deactivate-mark nil)
  )

(defun my/indent-region-right-tab ()
  (interactive)
  (c-toggle-syntactic-indentation -1)
  (indent-rigidly (region-beginning) (region-end) 4)
  (c-toggle-syntactic-indentation 1)
  (setq deactivate-mark nil)
  )

The problem is they don't seem to disable syntactic indentation, because they work just as slow. But if I use the next function before calling my/indent-region-left-tab or my/indent-region-right-tab, then the indentation is done fast:

(defun my/disable-syntactic-indentation ()
  (interactive)
  (c-toggle-syntactic-indentation -1)
  )

How to do it so it can be all put inside the functions so they are not slow anymore?

  • We need an example php-file (maybe html?) for reconstruction. Otherwise you will not get any valid answer. – Tobias Nov 20 '19 at 22:05
1

Just guessing here because I can't replicate the issue, but do the following slightly different functions work?

(defun my/indent-region-left-tab ()
  (interactive)
  (let ((c-syntactic-indentation nil))
    (indent-rigidly (region-beginning) (region-end) -4))
  (setq deactivate-mark nil))

(defun my/indent-region-right-tab ()
  (interactive)
  (let ((c-syntactic-indentation nil))
    (indent-rigidly (region-beginning) (region-end) 4))
  (setq deactivate-mark nil))
| improve this answer | |
  • They don't work, same issue. – mikl Nov 19 '19 at 16:19
  • That is a premature answer. Let @mikl give as much input as we need to reproduce the problem. – Tobias Nov 21 '19 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.