What you've done is fine. Those are two different functions, which happen to do similar things. So advising each of them the same way is fine.
But those functions themselves (in synonyms.el
) each call function synonyms-lookup
to display the results. So you can just advise that single function instead (the same way you advised the two commands that call it). That saves a little code repetition.
(defadvice synonyms-lookup (after synonyms-jump-to-window activate)
(switch-to-buffer-other-window "*Synonyms*"))
FWIW, personally I make buffers whose names begin and end with *
be "special-display" buffers, which means that their windows are automatically dedicated, so the result here is always shown in a separate window. I do that just by customizing option special-display-regexps
to this value:
("[ ]?[*][^*]+[*]")