Raul, like I said, it was naive and good enough for me for now. All points noted and I will attempt to factor them in as the needs arises.
I also considered extending the regex to look for 'define' as well instead etc. Thanks, Sean. On Tue, 22 Dec 2020 at 21:25, Raul Miller <[email protected]> wrote: > I don't use emacs (RSI issues), however, I can see a couple things > that I would change in this implementation. > > Instead of > (re-search-backward ": 0$") > > I would use > (re-search-backward ": *0 *$") > > Or, even better: > > (re-search-backward ": *0 *(NB\..*)?$") > > It's fine to use spaces here instead of \s (because J basically > requires spaces in this context) but J places no significance on the > spaces, so the regexp probably should not, either. > > Also, I prefer to avoid implementing rules which discourage people > from using comments. > > Similarly, I would use > > (re-search-forward "^ *) *$")) > > again, to match how J works (sadly, J currently does not allow > comments on the ending lines for script blocks). > > If we were really ambitious, though, I imagine that we'd grab the > region this way, set the cursor back to where it was, and grab a {{ }} > delimited definition, and if we get both run some tests on them to see > which was the best match (which has a start which is closest to the > cursor, probably). > > Thanks, > > -- > Raul > > On Tue, Dec 22, 2020 at 7:24 AM emacstheviking <[email protected]> wrote: > > > > Morning. > > > > I wrote this quickly, it works for me, YMMV and its as simple as it needs > > to be, it mostly finds the start and end of the current verb definition. > > The j-mode I have has > > compile line > > compile region > > compile buffer > > > > I offer 'jselverb' which I have bound to C-c C-v as that fits the > pattern, > > it's unpolished and care free. > > > > ;; Selects the current verb for C-c C-r to digest > > (defun jselverb () > > (interactive) > > (re-search-backward ": 0$") > > (beginning-of-line) > > (set-mark-command nil) > > (re-search-forward "^)$")) > > > > (defun jeatverb () > > (interactive) > > (save-excursion > > (jselverb) > > (j-console-execute-region (region-beginning) (region-end)))) > > > > (global-set-key (kbd "C-c C-v") 'jeatverb) > > > > To use it, just be in the verb, hit C-c C-v C-c C-r > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
