Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port defadvice to define-advice #423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions hydra.el
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,20 @@ Exitable only through a blue head.")
2)))

;;* Find Function
(eval-after-load 'find-func
'(defadvice find-function-search-for-symbol
(around hydra-around-find-function-search-for-symbol-advice
(symbol type library) activate)
"Navigate to hydras with `find-function-search-for-symbol'."
(prog1 ad-do-it
(when (symbolp symbol)
;; The original function returns (cons (current-buffer) (point))
;; if it found the point.
(unless (cdr ad-return-value)
(with-current-buffer (find-file-noselect library)
(let ((sn (symbol-name symbol)))
(when (and (null type)
(string-match "\\`\\(hydra-[a-z-A-Z0-9]+\\)/\\(.*\\)\\'" sn)
(re-search-forward (concat "(defhydra " (match-string 1 sn))
nil t))
(goto-char (match-beginning 0)))
(cons (current-buffer) (point)))))))))
(define-advice find-function-search-for-symbol
(:around (fn symbol type library) hydra-around-find-function-search-for-symbol-advice)
(when (symbolp symbol)
;; The original function returns (cons (current-buffer) (point))
;; if it found the point.
(unless (cdr (funcall fn symbol type library))
(with-current-buffer (find-file-noselect library)
(let ((sn (symbol-name symbol)))
(when (and (null type)
(string-match "\\`\\(hydra-[a-z-A-Z0-9]+\\)/\\(.*\\)\\'" sn)
(re-search-forward (concat "(defhydra " (match-string 1 sn))
nil t))
(goto-char (match-beginning 0)))
(cons (current-buffer) (point)))))))

;;* Universal Argument
(defvar hydra-base-map
Expand Down