2

I am trying to make undo-tree auto compress the history save file. The document suggests adding the following advice

(defadvice undo-tree-make-history-save-file-name
    (after undo-tree activate)
  (setq ad-return-value (concat ad-return-value ".gz")))

This works as expected, but defadvice is now obsolete, so I want rewrite this piece of code with advice-add. Here is what I've done

(defun undo-tree-advice-history-save-file-name (history-save-file-name)
    (concat history-save-file-name ".gz"))
(advice-add #'undo-tree :filter-return #'undo-tree-advice-history-save-file-name)

This doesn't produce any error or warning, but it has no effect: save files were not compressed into a .gz archive, but were left as plain text files instead. So I took this answer as reference and tried

(defun undo-tree-advice-history-save-file-name (old-function &rest arguments)
    (concat (apply old-function arguments) ".gz"))
(advice-add #'undo-tree :around #'undo-tree-advice-history-save-file-name)

Again, this advice is ignored. What am I doing wrong?

3
(advice-add #'undo-tree :filter-return #'undo-tree-advice-history-save-file-name)

This advises the function undo-tree, whereas the defadvice form advises undo-tree-make-history-save-file-name. The equivalent advice-add would be

(advice-add 'undo-tree-make-history-save-file-name :filter-return #'undo-tree-advice-history-save-file-name)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.