]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (ivy-ffap-url-functions): Add Emacs git repo
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 24 Jan 2016 12:15:41 +0000 (13:15 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 24 Jan 2016 12:15:41 +0000 (13:15 +0100)
* counsel.el (counsel-emacs-url-p): New defun.

counsel.el

index 6c5a2838c3d674cef7b5b3fed558f17acaac882f..4a523cb22f1fb0b78145c1c05fd9f8315088b9e4 100644 (file)
@@ -515,6 +515,21 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer during completion."
                           user repo (substring url 1)))))))
 (add-to-list 'ivy-ffap-url-functions 'counsel-github-url-p)
 
+(defun counsel-emacs-url-p ()
+  "Return a Debbugs issue URL at point."
+  (when (and (looking-at "#[0-9]+")
+             (or
+              (eq (vc-backend (buffer-file-name)) 'Git)
+              (memq major-mode '(magit-commit-mode))))
+    (let ((url (match-string-no-properties 0))
+          (origin (shell-command-to-string
+                   "git remote get-url origin")))
+      (when (string-match "git.sv.gnu.org:/srv/git/emacs.git" origin)
+        (format "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=%s"
+                (substring url 1))))))
+
+(add-to-list 'ivy-ffap-url-functions 'counsel-emacs-url-p)
+
 (defcustom counsel-find-file-ignore-regexp nil
   "A regexp of files to ignore while in `counsel-find-file'.
 These files are un-ignored if `ivy-text' matches them.