ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
163 stars 54 forks source link

Implement beginning/end-of-defun #54

Closed ve-nt closed 3 years ago

ve-nt commented 3 years ago

This allows us to use C-M-a and C-M-e to navigate by function blocks. Also includes test, const, and export blocks that contain a brace.

Credit goes to rust-mode, which this code was yanked and modified from.

ve-nt commented 3 years ago

Spotted a bug. Converting this PR to draft until I fix them.

To elaborate: Neither beginning-of-defun or end-of-defun work for function blocks that have their opening brace on a different line from the fn keyword.

ve-nt commented 3 years ago

Okay so I've been using this for a few days, and I haven't noticed any more bugs. The only issue I've noticed is that beginning-of-defun matches on all global const declarations, even the ones it's not really supposed to. For example, it will match on statements like this:

const maps_dir = "data/maps/";

I will work on fixing this. The rest of the functionality is working fine and is pretty handy, so it could be merged in and ironed out later, or merged after this issue has been fixed. Up to you.

ve-nt commented 3 years ago

Oof. Just when I'm getting confident, another bug! Marking as WIP.