Skip to content

Commit

Permalink
update zetteldeft--search-global to switch to Deft window
Browse files Browse the repository at this point in the history
When doing a global search, the Deft buffer is shown. To prevent that
the Deft buffer is shown in multiple windows, first switch to the
relevant window if the Deft buffer is already visible somewhere.
  • Loading branch information
EFLS committed Apr 9, 2021
1 parent 158cd53 commit c217052
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zetteldeft.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ This can be
If there is only one result, open that file (unless DNTOPN is true)."
;; Sanitize the filter string
(setq str (replace-regexp-in-string "[[:space:]\n]+" " " str))
;; Switch to Deft window if buffer is currently visible
(when (deft-buffer-visible-p)
(select-window (deft-buffer-visible-p)))
;; Call deft search on the filter string
(let ((deft-incremental-search t))
(deft)
Expand Down
6 changes: 6 additions & 0 deletions zetteldeft.org
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ Based on snippet suggested by =saf-dmitry= on deft's [[https://github.com/jrblev
If there is only one result, open that file (unless DNTOPN is true)."
;; Sanitize the filter string
(setq str (replace-regexp-in-string "[[:space:]\n]+" " " str))
;; Switch to Deft window if buffer is currently visible
(when (deft-buffer-visible-p)
(select-window (deft-buffer-visible-p)))
;; Call deft search on the filter string
(let ((deft-incremental-search t))
(deft)
Expand All @@ -400,6 +403,9 @@ If there is only one result, open that file (unless DNTOPN is true)."
(deft-open-file (car deft-current-files)))))
#+END_SRC

When doing a global search, the Deft buffer is shown.
To prevent that the Deft buffer is shown in multiple windows, first switch to the relevant window if the Deft buffer is already visible somewhere.

**** =zetteldeft--search-filename= for string

Deft search on filename.
Expand Down

0 comments on commit c217052

Please sign in to comment.