Subject: bug#14070: 24.3.50; incorrect doc from `C-h f' when use `defadvice' with `before'

From: Stefan Monnier <[email-masked]>
Date: Wed, 27 Mar 2013 15:19:42 -0400

tags 14070 notabug
thanks

>  :around advice: `ad-Advice-query-replace'
> 1. It should be :before, not :around, no?
> (When you click on that link it confirms that it is `Before-advice'.)

ad-Advice-query-replace is an "advice container" which in turns contains
all the advice added via `defadvice'.

> 2. How can you tell where that advice is defined?

You can't because defadvice does not record this information.
If you replace your advice with something like:

   (advice-add 'query-replace :before
               #'respect-search/replace-region-as-default-flag)
   (defun respect-search/replace-region-as-default-flag (&rest ignore)
     (interactive
      (let ((common
             (query-replace-read-args
              (concat "Query replace"
                      (and current-prefix-arg  " word")
                      (and transient-mark-mode  mark-active
                           (not search/replace-region-as-default-flag)
                           " in region"))
              nil)))
        (list (nth 0 common) (nth 1 common) (nth 2 common)
              (and transient-mark-mode  mark-active  (region-beginning))
              (and transient-mark-mode  mark-active  (region-end)))))
     nil)

then C-h f should tell you it's a before advice and should let you click
your way to its source code.

        Stefan