Add :gblame & :grevert ex commands
This commit is contained in:
parent
546c672f8a
commit
d5d0f26c09
5 changed files with 70 additions and 30 deletions
|
@ -418,6 +418,8 @@ In modules, checks modules/*/autoload.el and modules/*/autoload/*.el.
|
|||
Rerun this whenever init.el is modified. You can also use `make autoloads` from
|
||||
the commandline."
|
||||
(interactive)
|
||||
;; This function must not use `cl-lib', autoloaded functions or external
|
||||
;; dependencies. It must assume nothing is set up!
|
||||
(doom-initialize-packages (not noninteractive))
|
||||
(let ((generated-autoload-file doom-autoload-file)
|
||||
(autoload-files
|
||||
|
|
21
modules/feature/jump/autoload/evil.el
Normal file
21
modules/feature/jump/autoload/evil.el
Normal file
|
@ -0,0 +1,21 @@
|
|||
;;; feature/jump/autoload/evil.el
|
||||
|
||||
;;;###autoload (autoload '+jump:online "feature/jump/autoload/evil" nil t)
|
||||
(evil-define-command +jump:online (query &optional bang)
|
||||
"Look up QUERY online. You can prefix your queries with a one-letter shortcut
|
||||
key (dictated by `+jump-search-url-alist'), otherwise you will be prompted for
|
||||
what search engine to use."
|
||||
(interactive "<a><!>")
|
||||
(let ((query query)
|
||||
(engine (assoc (car-safe (split-string query " " t t))
|
||||
+jump-search-url-alist)))
|
||||
(if engine
|
||||
(setq query (string-join (cdr-safe (split-string query " " t t)) " "))
|
||||
(let ((engine (completing-read "Search on: "
|
||||
(mapcar #'cadr +jump-search-url-alist)
|
||||
nil t)))
|
||||
(setq engine (cl-find-if (lambda (x) (equal (cadr x) engine))
|
||||
+jump-search-url-alist))))
|
||||
(unless engine
|
||||
(error "Search engine couldn't be found"))
|
||||
(+jump/online engine query)))
|
|
@ -5,9 +5,10 @@
|
|||
|
||||
;;;###autoload
|
||||
(defun +jump/definition (&optional other-window)
|
||||
"Find definition of the symbol at point.
|
||||
"Jump to the definition of the symbol at point.
|
||||
|
||||
Tries xref and falls back to `dumb-jump', then rg/ag."
|
||||
Tries xref and falls back to `dumb-jump', then rg/ag, then
|
||||
`evil-goto-definition' (if evil is active)."
|
||||
(interactive "P")
|
||||
(let ((sym (thing-at-point 'symbol t))
|
||||
successful)
|
||||
|
@ -52,7 +53,9 @@ Tries xref and falls back to `dumb-jump', then rg/ag."
|
|||
|
||||
;;;###autoload
|
||||
(defun +jump/references ()
|
||||
"TODO"
|
||||
"Show a list of references to the symbol at point.
|
||||
|
||||
Tries `xref-find-references' and falls back to rg/ag."
|
||||
(interactive)
|
||||
(let ((sym (thing-at-point 'symbol t)))
|
||||
(cond ((progn
|
||||
|
@ -69,14 +72,27 @@ Tries xref and falls back to `dumb-jump', then rg/ag."
|
|||
|
||||
(t (error "Couldn't find '%s'" sym)))))
|
||||
|
||||
(defvar +jump--online-last-url nil)
|
||||
|
||||
;;;###autoload
|
||||
(defun +jump/online (where &optional search)
|
||||
"TODO"
|
||||
(defun +jump/online (where search)
|
||||
"Looks up SEARCH online, in you browser, as dictated by WHERE.
|
||||
|
||||
Interactively, you are prompted to choose a source from
|
||||
`+jump-search-url-alist'."
|
||||
(interactive
|
||||
(list (completing-read "Search on: "
|
||||
(mapcar #'car +jump-search-url-alist)
|
||||
nil t)))
|
||||
(let ((url (cdr (assoc where +jump-search-url-alist)))
|
||||
(search (or search (read-string "Query: "))))
|
||||
(mapcar #'cdr +jump-search-url-alist)
|
||||
nil t)
|
||||
(or (and (not current-prefix-arg)
|
||||
+jump--online-last-url)
|
||||
(thing-at-point 'symbol t))))
|
||||
(let ((url (cdr (assoc where +jump-search-url-alist))))
|
||||
(when (or (functionp url) (symbolp url))
|
||||
(setq url (funcall url)))
|
||||
(cl-assert (stringp url))
|
||||
(cl-assert (not (string-empty-p url)))
|
||||
(cl-assert (not (string-empty-p search)))
|
||||
(setq +jump--online-last-url url)
|
||||
(browse-url (format url (url-encode-url search)))))
|
||||
|
|
@ -3,37 +3,35 @@
|
|||
;; "What am I looking at?"
|
||||
;;
|
||||
;; This module helps you answer that question. It helps you look up whatever
|
||||
;; you're looking at, with:
|
||||
;; you're looking at.
|
||||
;;
|
||||
;; 1. A dwim Jump-to-definition functionality that "just works", with the help
|
||||
;; of `dumb-jump' and `xref'.
|
||||
;; 2. A dwim interface to the new (and experimental) xref API built into Emacs.
|
||||
;; Once its API is more stable, backends could be written (or provided by
|
||||
;; plugins) to create universal find-references and find-definition
|
||||
;; functionality. Warning: xref may change drastically in future updates.
|
||||
;; 3. Simple ways to look up the symbol at point in external resources, like
|
||||
;; stackoverflow, devdocs.io or google. See `+jump/online' (TODO Test me!)
|
||||
;; 4. TODO Automatic & transparent integration with cscope dbs + ctags.
|
||||
;; Databases are optionally isolated to the Emacs environment.
|
||||
;; + `+jump/definition': a jump-to-definition that should 'just work'
|
||||
;; + `+jump/references': find a symbol's references in the current project
|
||||
;; + `+jump/online'; look up a symbol on online resources, like stackoverflow,
|
||||
;; devdocs.io or google.
|
||||
;;
|
||||
;; This module uses `xref', an experimental new library in Emacs. It may change
|
||||
;; in the future. When xref can't be depended on it will fall back to
|
||||
;; `dumb-jump' to find what you want.
|
||||
|
||||
(defvar +jump-search-url-alist
|
||||
'(("Google" . "https://google.com/search?q=%s")
|
||||
("DuckDuckGo" . "https://duckduckgo.com/?q=%s")
|
||||
("DevDocs.io" . "http://devdocs.io/#q=%s")
|
||||
("StackOverflow" . "https://stackoverflow.com/search?q=%s"))
|
||||
"An alist that maps online resources to their search url. Used by
|
||||
`+jump/online'.")
|
||||
|
||||
(set! :popup "*xref*" :size 10 :noselect t :autokill t :autoclose t)
|
||||
|
||||
;; Let me control what backends to fall back on
|
||||
(setq-default xref-backend-functions '())
|
||||
"An alist that maps online resources to their search url or a function that
|
||||
produces an url. Used by `+jump/online'.")
|
||||
|
||||
(def-setting! :xref-backend (mode function)
|
||||
"TODO"
|
||||
`(add-hook! ,mode
|
||||
(add-hook 'xref-backend-functions #',function nil t)))
|
||||
|
||||
(set! :popup "*xref*" :noselect t :autokill t :autoclose t)
|
||||
|
||||
;; Let me control what backends to fall back on
|
||||
(setq-default xref-backend-functions '(t))
|
||||
|
||||
;; Recenter after certain jumps
|
||||
(add-hook!
|
||||
'(imenu-after-jump-hook evil-jumps-post-jump-hook counsel-grep-post-action-hook)
|
||||
|
@ -47,6 +45,10 @@
|
|||
(def-package! dumb-jump
|
||||
:commands (dumb-jump-go dumb-jump-quick-look dumb-jump-back)
|
||||
:config
|
||||
(setq dumb-jump-default-project doom-emacs-dir
|
||||
dumb-jump-selector (cond ((featurep! :completion ivy) 'ivy)
|
||||
((featurep! :completion helm) 'helm)
|
||||
(t 'popup))))
|
||||
|
||||
|
||||
(def-package! gxref
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
(ex! "git" #'magit-status) ; open magit status window
|
||||
(ex! "gstage" #'magit-stage)
|
||||
(ex! "gunstage" #'magit-unstage)
|
||||
;; TODO :gblame
|
||||
;; TODO :grevert
|
||||
;; TODO :gblame
|
||||
(ex! "gblame" #'magit-blame)
|
||||
(ex! "grevert" #'git-gutter:revert-hunk)
|
||||
|
||||
;; Dealing with buffers
|
||||
(ex! "clean[up]" #'doom/cleanup-buffers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue