quantum_mattress · 2022-09-07 16:50
Hi all.
Long-time (30+ years) emacs user but not a programmer so can only do simple elisp functions. I use ediff all the time and have ediff-diff-options set to -wBb. This works most of the time but I've gotten burned diff-ing some Python scripts and the occasional makefile since whitespace matters there. Anyone have some code that would automatically change ediff-diff-options based on the buffer mode? I guess that means it would have to be a local setting.
Thanks for any pointers / ideas!
EternalMigrainity · 2022-09-07 17:23
Idk what ediff is but use hooks and setq-local
EternalMigrainity · 2022-09-07 17:25
Something like this:
(add-hook 'python-mode-hook #'(lambda () (setq-local thing (concat "command" some-variable))))
quantum_mattress · 2022-09-07 23:20
Thanks. I see where you're going but it really needs to add-hook to ediff-mode-hook which somehow needs to change ediff-diff-options before calling ediff-diff-program (which is usually diff). Ediff is about a dozen elisp files under the vc (version control) built-in package (along with cvs-\* and vc-\*). Probably way too complex for me to figure out but I'll try if I can't get any outside help.
I'm surprised anyone programming in emacs doesn't use ediff all the time but upon reflection, I guess most folks (not including me) use git and its associated utilities so vc is not too popular anymore.
00-11 · 2022-09-08 04:38
https://emacs.stackexchange.com/q/73500/105
7890yuiop · 2022-09-08 05:03
You can probably use `ediff-prepare-buffer-hook`.
> Hooks run after buffers A, B, and C are set up.
> For each buffer, the hooks are run with that buffer made current.
This happens before `ediff-exec-process` runs.
Alternatively, `ediff-keymap-setup-hook` -- which sounds like a weird option, but it only runs once instead of once per buffer, and you would have access to all of `ediff-buffer-A`, `ediff-buffer-B`, and `ediff-buffer-C` (and `ediff-control-buffer`, which should be current at that time).
I'm not seeing anything more appropriate offhand -- maybe it would be a good feature request.