Skip to content

Instantly share code, notes, and snippets.

@mgalgs
Created February 21, 2014 06:38
Show Gist options
  • Save mgalgs/9129823 to your computer and use it in GitHub Desktop.
Save mgalgs/9129823 to your computer and use it in GitHub Desktop.
(defun is-array-def ()
(save-excursion
(let (end-of-statement (save-excursion (search-forward ";")))
;; it's an array if we find all of the following characters before
;; the next semi-colon: `[={'. Is that good enough??
(and (re-search-forward "\\[" end-of-statement t)
(re-search-forward "=" end-of-statement t)
(re-search-forward "{" end-of-statement t)))))
@mgalgs
Copy link
Author

mgalgs commented Feb 21, 2014

Test with:

int stuff[] = {1,2,3};

put point at the beginning of the line and run the function. Use edebug to verify that point isn't getting restored.

@mgalgs
Copy link
Author

mgalgs commented Feb 21, 2014

Fix is simple: need another set of parens around my let binding variables. DOH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment