emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 27b7f40 15/22: Make find-function work with defhydra


From: Oleh Krehel
Subject: [elpa] master 27b7f40 15/22: Make find-function work with defhydra
Date: Fri, 16 Oct 2015 10:06:59 +0000

branch: master
commit 27b7f40cb21157be0dabc37046b83ed99151a26e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Make find-function work with defhydra
    
    * hydra.el (find-function-search-for-symbol): New defadvice.
    
    Fixes #153
---
 hydra.el |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/hydra.el b/hydra.el
index fa4f641..a9b4587 100644
--- a/hydra.el
+++ b/hydra.el
@@ -250,6 +250,25 @@ Exitable only through a blue head.")
       (1 font-lock-keyword-face)
       (2 font-lock-type-face)))))
 
+;;* 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'."
+    ad-do-it
+    ;; The orignial 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)))))))
+
 ;;* Universal Argument
 (defvar hydra-base-map
   (let ((map (make-sparse-keymap)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]