Rethink SPC n keybinds and add new ones

Adds the following keybinds:

SPC n .    Browses org-directory
SPC n /    Text search in org-directory
SPC n *    Text search in org-directory with symbol at point
SPC n h    Jump to org headline in org-agenda-files
This commit is contained in:
Henrik Lissner 2019-05-17 23:57:24 -04:00
parent 5ec0c5ba3f
commit 2e6d8be6fc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 44 additions and 12 deletions

View file

@ -121,7 +121,8 @@ selection of all minor-modes, active or not."
;;
;;; Documentation commands
(defun doom--org-headings (files &optional depth include-files)
;;;###autoload
(defun doom-completing-read-org-headlings (files &optional depth include-files)
(require 'org)
(let* ((default-directory doom-docs-dir)
(org-agenda-files (mapcar #'expand-file-name (doom-enlist files)))
@ -167,8 +168,9 @@ selection of all minor-modes, active or not."
"Search Doom's documentation and jump to a headline."
(interactive)
(let (ivy-sort-functions-alist)
(completing-read "Find in Doom help: "
(doom--org-headings (list "getting_started.org"
(completing-read
"Find in Doom help: "
(doom-completing-read-org-headlings (list "getting_started.org"
"contributing.org"
"troubleshooting.org"
"tutorials.org"
@ -180,7 +182,7 @@ selection of all minor-modes, active or not."
"Search Doom's FAQ and jump to a question."
(interactive)
(completing-read "Find in FAQ: "
(doom--org-headings (list "faq.org"))))
(doom-completing-read-org-headlings (list "faq.org"))))
;;;###autoload
(defun doom/help-news ()

View file

@ -675,12 +675,16 @@
;;; <leader> n --- notes
(:prefix-map ("n" . "notes")
:desc "Open deft" "d" #'deft
:desc "Find file in notes" "n" #'+default/find-in-notes
:desc "Browse notes" "N" #'+default/browse-notes
:desc "Pop scratch buffer" "s" #'doom/open-scratch-buffer
:desc "Org capture" "x" #'org-capture
:desc "Org store link" "l" #'org-store-link)
:desc "Browse notes" "." #'+default/browse-notes
:desc "Search notes" "/" #'+default/org-notes-search
:desc "Search notes for symbol" "*" #'+default/search-notes-for-symbol-at-point
:desc "Open deft" "d" #'deft
:desc "Search org agenda headlines" "h" #'+default/org-notes-headlines
:desc "Find file in notes" "n" #'+default/find-in-notes
:desc "Browse notes" "N" #'+default/browse-notes
:desc "Pop scratch buffer" "s" #'doom/open-scratch-buffer
:desc "Org capture" "x" #'org-capture
:desc "Org store link" "l" #'org-store-link)
;;; <leader> o --- open
(:prefix-map ("o" . "open")

View file

@ -255,8 +255,7 @@ If prefix ARG is set, prompt for a known project to search from."
"Conduct a text search in the current project for symbol at point.
If prefix ARG is set, prompt for a known project to search from."
(interactive
(list current-prefix-arg
(thing-at-point 'symbol t)))
(list current-prefix-arg (thing-at-point 'symbol t)))
(let ((default-directory
(if arg
(if-let* ((projects (projectile-relevant-known-projects)))
@ -269,3 +268,30 @@ If prefix ARG is set, prompt for a known project to search from."
((featurep! :completion helm)
(+helm/project-search nil (rxt-quote-pcre symbol)))
((rgrep (regexp-quote symbol))))))
;;;###autoload
(defun +default/search-notes-for-symbol-at-point (&optional arg symbol)
"Conduct a text search in the current project for symbol at point. If prefix
ARG is set, prompt for a known project to search from."
(interactive
(list current-prefix-arg (thing-at-point 'symbol t)))
(require 'org)
(let ((default-directory org-directory))
(+default/search-project-for-symbol-at-point
nil symbol)))
;;;###autoload
(defun +default/org-notes-search ()
"Perform a text search on `org-directory'."
(interactive)
(require 'org)
(let ((default-directory org-directory))
(+default/search-project-for-symbol-at-point nil "")))
;;;###autoload
(defun +default/org-notes-headlines ()
"Jump to an Org headline in `org-agenda-files'."
(interactive)
(completing-read
"Jump to org headline: "
(doom-completing-read-org-headlings org-agenda-files 3 t)))