On 24.12.2016 13:00, Eli Zaretskii wrote:

I think one missing piece of the puzzle, which is what confused Elias,
is that open-paren-in-column-0-is-defun-start is not only about '(',
it's about any character that has the "open parenthesis" syntax class
under the current syntax tables.  And in C mode, that includes '{' and
'[', with the former being the important one.  I think.


Hi Alan and all,

there is no necessity for these `open-paren-in-column-0-is-defun-start' , as a function def starts at the beginning of the list, if its beginning is followed by the keyword "defun".

`open-paren-in-column-0-is-defun-start'  will never be reliable WRT nested definitions.

Here is a suggestion how to solve this for Emacs Lisp:

ar-backward-defun

from


https://github.com/andreas-roehler/thingatpt-utils-core/blob/master/ar-subr.el

It should be possible to write things accordingly for other languages.