7

Since Emacs 25.1, syntax-begin-function is obsolete:

syntax-begin-function is a variable defined in ‘syntax.el’.
Its value is nil

  This variable is obsolete since 25.1.
  This variable may be risky if used as a file-local variable.

Documentation:
Function to move back outside of any comment/string/paren.
This function should move the cursor back to some syntactically safe
point (where the PPSS is equivalent to nil).

This was done in commit dd1e6846198e559b1c2ca321a1e6f8b05945fd66 which offers no further explanation how that functionality should be achieved now. The code also still refers to syntax-begin-function in several comments as if nothing happened.

php-mode just surrounded the offending code with with-no-warnings (cf. https://github.com/ejmr/php-mode/blob/master/php-mode.el#L1193-L1196), and other projects seem to have found no "proper" solution yet either. The function php-mode used for this variable, c-beginning-of-syntax, refers to font-lock-beginning-of-syntax-function which was also removed in Emacs 25.1 (but, again, is referred to in several other comments as well).

If I completely remove the section:

  ;; syntax-begin-function is obsolete in Emacs 25.1
  (with-no-warnings
    (set (make-local-variable 'syntax-begin-function)
         'c-beginning-of-syntax))

from php-mode.el and test it with Emacs 24.3 and 25.2, I don't see any obvious adverse effects.

What was syntax-begin-function obsoleted in favour of? Is the reference in php-mode.el just dead code that did nothing? If not, how can I test its behaviour?

  • 3
    Consider filing a bug: M-x report-emacs-bug. The "obsolete" message should indicate what to use instead (IMHO). – Drew Sep 10 '17 at 2:30
  • I don't think @Stefan would leave out the replacement if there was one, so presumably it's just obsolete. Of course, only he can confirm that. It is strange, though, that some references to the now always nil syntax-begin-function still exists. – Tianxiang Xiong Sep 12 '17 at 22:46
  • @TianxiangXiong: AFAICT, you are correct. I'll write up an answer with my findings later (and file a bug). – Tim Landscheidt Sep 17 '17 at 16:20

Your Answer

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

Browse other questions tagged or ask your own question.