(advice-add 'yas-new-snippet :override 'my/yas-new-snippet ) but I was wondering if there was something like this which would allow me to override a function in a function only in that function:
(override-func 'yas-new-snippet 'switch-to-buffer 'switch-to-buffer-other-window)
What I did was override the function to open the snippet in another window. This works but assume that the package maintainer is actively maintaining. I would have to copy this when/if it gets updated. Fortunately for me yas does not get updates frequently. Another thing is that it adds more code to my config.
(defun my/yas-new-snippet (&optional no-template) "Pops a new buffer for writing a snippet. Expands a snippet-writing snippet, unless the optional prefix arg NO-TEMPLATE is non-nil." (interactive "P") (let ((guessed-directories (yas--guess-snippet-directories)) (yas-selected-text (or yas-selected-text (and (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)))))) ;;(switch-to-buffer yas-new-snippet-buffer-name) (switch-to-buffer-other-window yas-new-snippet-buffer-name) (erase-buffer) (kill-all-local-variables) (snippet-mode) (yas-minor-mode 1) (set (make-local-variable 'yas--guessed-modes) (mapcar (lambda (d) (yas--table-mode (car d))) guessed-directories)) (set (make-local-variable 'default-directory) (car (cdr (car guessed-directories)))) (if (and (not no-template) yas-new-snippet-default) (yas-expand-snippet yas-new-snippet-default)))) ;; Open new snippet in other window. (advice-add 'yas-new-snippet :override 'my/yas-new-snippet )