Simplify :ag interface + add :org

This commit is contained in:
Henrik Lissner 2016-03-11 19:30:38 -05:00
parent 4e49b86f68
commit 65c0410925
2 changed files with 9 additions and 30 deletions

View file

@ -17,14 +17,13 @@
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf:helm-ag-search "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-search (beg end &optional search hidden-files-p pwd-p regex-p)
(evil-define-operator narf:helm-ag-search (beg end search regex-p &optional dir)
:type inclusive
:repeat nil
(interactive "<r><a><!>")
(require 'helm-ag)
(let* ((helm-ag--default-directory (if pwd-p default-directory (concat (narf/project-root) "/")))
(helm-ag-command-option (concat (unless regex-p "-Q ")
(if hidden-files-p "--hidden ")))
(let* ((helm-ag--default-directory (or dir (f-slash (narf/project-root))))
(helm-ag-command-option (unless regex-p "-Q "))
(input "")
(header-name (format "Search in %s" helm-ag--default-directory)))
(if search
@ -39,25 +38,13 @@
:keymap helm-ag-map
:input input)))
;;;###autoload (autoload 'narf:helm-ag-regex-search "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-regex-search (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-ag-search beg end search bang nil t))
;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted
;; as regexp
;;;###autoload (autoload 'narf:helm-ag-search-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-search-cwd (beg end &optional search bang)
;; Ex-mode interface for `helm-do-ag'. If `bang', then `search' is interpreted
;; as regexp
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-ag-search beg end search bang t nil))
;;;###autoload (autoload 'narf:helm-ag-regex-search-cwd "defuns-helm" nil t)
(evil-define-operator narf:helm-ag-regex-search-cwd (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:helm-ag-search beg end search bang t t))
(narf:helm-ag-search beg end search bang default-directory))
;; Ex-mode interface for `helm-swoop', `helm-multi-swoop-all' (if `bang'), or
;; `helm-css-scss' and `helm-css-scss-multi' (if `bang') if major-mode is

View file

@ -130,18 +130,10 @@
;; Ex-mode interface for `helm-ag'. If `bang', then `search' is interpreted as
;; regexp.
;;;###autoload (autoload 'narf:org-helm-ag-search "defuns-org-notebook" nil t)
(evil-define-operator narf:org-helm-ag-search (beg end &optional search hidden-files-p regex-p)
:type inclusive :repeat nil
;;;###autoload (autoload 'narf:org-helm-search "defuns-org-notebook" nil t)
(evil-define-operator narf:org-helm-search (beg end &optional search bang)
(interactive "<r><a><!>")
(in! org-directory
(narf:helm-ag-search beg end search bang t t)))
;;;###autoload (autoload 'narf:org-helm-ag-regex-search "defuns-org-notebook" nil t)
(evil-define-operator narf:org-helm-ag-regex-search (beg end &optional search bang)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(narf:org-helm-ag-search beg end search bang t))
(narf:helm-ag-search beg end (if bang (concat "^\\*+.*" search ".*$") search) t org-directory))
(provide 'defuns-org-notebook)
;;; defuns-org-notebook.el ends here