ideasman_42 · 2022-02-20 04:26
No-Command-791 · 2022-02-20 15:34
Fantastic idea!
github-alphapapa · 2022-02-20 17:15
Very nice. I could imagine it also cycling dates and times in various formats, similar to how Org does for its timestamps.
[deleted] · 2022-02-20 18:50
[deleted]
ZZhanChi · 2022-02-20 22:14
I especially like the idea of switching between True and False, thanks. Btw, there is a similar package: https://github.com/ROCKTAKEY/grugru FYI.
ideasman_42 · 2022-02-20 23:11
Right, you can cycle basically anything - generate the list on the fly, and as part of user configuration.
I was going to add support for cycling values where generating a complete list wasn't necessary too (just generate next/previous), which would be useful for incrementing/decrementing values (dates for example which are YY-MM-DD aware). But I don't think I'd actually use it much.
So far I just use the really obvious cases a lot `True` `False` (mostly) also `is` `is not`. `>=`, `<=` ... this kind of thing. So other more advanced cases may be interesting but personally not something I'm likely to use on a daily basis (and perhaps not at all).
ideasman_42 · 2022-02-20 23:17
Thanks, I found this after having written cycle-at-point, in general it looks fine and probably works well enough for the same basic use case - some notes though.
- I tried it and I couldn't get it working, not sure why (could have spent longer on this).
- As far as I can tell it adds multiple undo steps when cycling multiple times.
- The way it references symbol / word's means it can't swap multi-word identifiers. So `A is B` -> `A is not B` (maybe there is a way to handle this I'm not aware of).
Further, both packages could be made more sophisticated, see VIM's switch.vim ([issue](https://gitlab.com/ideasman42/emacs-cycle-at-point/-/issues/1)).
Which I'd be fine with but personally don't have a need for this. In fact I'm wary of getting too sophisticated as there can be all kinds of corner cases that end up needing a full AST to properly manipulate larger blocks of code.
One other thing, it would be nice to hook this up to switch synonyms.
ROCKTAKEY · 2022-03-08 13:27
Hi! I'm author of grugru! I'd like to help you use grugru if you don't mind!
You are true that symbol/word cannot multi-word, but you can use any function to get current position.
Actually, grugru is very simple structure.
(grugru-define-global A B)
A is function, called `getter`, which gets strings from current cursor. `symbol` or `word` is just an alias defined in [the variable `grugru-getter-alist`](https://github.com/ROCKTAKEY/grugru/blob/master/grugru.el#L328).
B is function, called `generator`, called with 1 or 2 arguments, `STRING` and `REVERSE`. This function generates string next to `STRING`. If `REVERSE` is non-nil, it generates string previous to `STRING`.
B can be also list of strings. The list is transferred to `generator` function by `metagenerator`, which generate `generator` from list of string. Default `metagenerator` is defined in [the variable `grugru-strings-metagenerator`](https://github.com/ROCKTAKEY/grugru/blob/1b3b807e84cb250f0cc70876a438fed3b27eb756/grugru.el#L393).
Multiple undo is just my preference, but I think it should be switchable.
Never mind opening issue and discussion, or replying to me to get my help or to request feature!