branch: externals/denote commit 2bd24bcf7291419e343cbb68d1fd6a8cecc04550 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Rename all commands that interact with the query links buffer and move them outside denote-grep They apply to all our commands that use the denote-query-mode, so we want to make that clear already from the symbols we use. --- denote.el | 178 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/denote.el b/denote.el index 85bc496ccd..20556abcfe 100644 --- a/denote.el +++ b/denote.el @@ -5016,18 +5016,18 @@ file's title. This has the same meaning as in `denote-link'." (defvar denote-query-mode-map (let ((map (make-sparse-keymap))) (define-key map "a" #'outline-cycle-buffer) - (define-key map "f" #'denote-grep-focus) + (define-key map "f" #'denote-query-focus-last-search) (define-key map "k" #'outline-previous-heading) (define-key map "j" #'outline-next-heading) (define-key map "o" #'delete-other-windows) (define-key map "s" #'denote-grep) (define-key map "v" #'outline-cycle) - (define-key map "x" #'denote-grep-exclude-files) - (define-key map "i" #'denote-grep-only-include-files) + (define-key map "x" #'denote-query-exclude-files) + (define-key map "i" #'denote-query-only-include-files) (define-key map "l" #'recenter-current-error) - (define-key map "X" #'denote-grep-exclude-files-with-keywords) - (define-key map "I" #'denote-grep-only-include-files-with-keywords) - (define-key map "G" #'denote-grep-clear-all-filters) + (define-key map "X" #'denote-query-exclude-files-with-keywords) + (define-key map "I" #'denote-query-only-include-files-with-keywords) + (define-key map "G" #'denote-query-clear-all-filters) map) "Keymap for `denote-query-mode' buffers.") @@ -5214,77 +5214,7 @@ concomitant alist, such as `denote-backlinks-display-buffer-action'." "Function to make an Xref buffer showing query link results. It accepts the same arguments as `denote-make-links-buffer'.") -;;;;;; Additional features for searching file contents - -(defvar denote-grep-history nil - "Minibuffer history of content searches performed by `denote-grep'. -Also see `denote-grep-file-regexp-history'.") - -(defun denote-grep-query-prompt (&optional type) - "Prompt for a grep query in the minibuffer. - -The prompt assumes a search in all files, unless TYPE is non-nil. - -For now, the only recognized value for TYPE is :focused (for a focused -search (a search among matching files), see `denote-grep-focus'). - -TYPE only affects the prompt, not the returned value." - (read-string - (cond ((eq type :focused) - "Search (only files matched last): ") - (t "Search (all Denote files): ")) - nil 'denote-grep-history)) - -(defvar denote-grep-file-regexp-history nil - "Minibuffer history for `denote-grep' commands asking for a file regexp. -Also see `denote-grep-history'.") - -(defun denote-grep-file-regexp-prompt (&optional include) - "Prompt for a file regexp in the minibuffer. - -The prompt assumes the user wants to exclude files, unless INCLUDE is -non-nil." - (read-string - (if (not include) - "Exclude file names matching: " - "Only include file names matching: ") - nil 'denote-grep-file-regexp-history)) - -(defun denote-grep-keywords-prompt (&optional include) - "Prompt for keywords to filter in the minibuffer, with completion. - -Keywords are read using `completing-read-multiple'. - -The prompt assumes the user wants to exclude the keywords, unless -INCLUDE is non-nil. - -Returned value is a list in order to be used in an `interactive' spec." - (list - (delete-dups - (completing-read-multiple - (if (not include) - "Exclude files with keywords: " - "Only include files with keywords: ") - (denote-keywords) nil t nil 'denote-keyword-history)))) - -;;;###autoload -(defun denote-grep (query) - "Search QUERY in the content of Denote files. -QUERY should be a regular expression accepted by `xref-search-program'. - -The files to search for are those returned by `denote-directory-files' -with a non-nil TEXT-ONLY argument. - -Results are put in a buffer which allows folding and further -filtering (see the manual for details). - -You can insert a link to a grep search in any note by using the command -`denote-query-contents-link'." - (interactive (list (denote-grep-query-prompt))) - (let (denote-query--omit-current) - (denote-make-links-buffer query))) - -(defun denote-grep-focus (query) +(defun denote-query-focus-last-search (query) "Search QUERY in the content of files which matched the last search. \"Last search\" here means any call to `denote-grep', `denote-backlinks', `denote-query-contents-link', or, generally, any @@ -5295,13 +5225,13 @@ command that relies on the `denote-make-links-buffer'." nil '(display-buffer-same-window)) (message "Searching `%s' in files matched previously" query)) -(defun denote-grep-exclude-files (regexp) +(defun denote-query-exclude-files (regexp) "Exclude files whose name matches REGEXP from current search buffer. This is useful even if you don't know regular expressions, given the Denote file-naming scheme. For instance, to exclude notes with the keyword \"philosophy\" from current search buffer, type -‘\\<denote-query-mode-map>\\[denote-grep-exclude-files] _philosophy +‘\\<denote-query-mode-map>\\[denote-query-exclude-files] _philosophy RET’. Internally, this works by generating a new call to @@ -5312,7 +5242,7 @@ When called from Lisp, REGEXP can be a list; in that case, it should be a list of fixed strings (NOT regexps) to check against last matched files. Files that match any of the strings get excluded. Internally, the list is processed using `regexp-opt'. For an example of this usage, -see `denote-grep-exclude-files-with-keywords'." +see `denote-query-exclude-files-with-keywords'." (interactive (list (denote-grep-file-regexp-prompt))) (let (final-files) (dolist (file denote-query--last-files) @@ -5328,10 +5258,10 @@ see `denote-grep-exclude-files-with-keywords'." (user-error "No remaining files when applying that filter")) (message "Excluding files matching `%s'" regexp))) -(defun denote-grep-only-include-files (regexp) +(defun denote-query-only-include-files (regexp) "Exclude file names not matching REGEXP from current query buffer. -See `denote-grep-exclude-files' for details, including the behaviour +See `denote-query-exclude-files' for details, including the behaviour when REGEXP is a list." (interactive (list (denote-grep-file-regexp-prompt :include))) (let (final-files) @@ -5348,7 +5278,7 @@ when REGEXP is a list." (user-error "No remaining files when applying that filter")) (message "Only including files matching `%s'" regexp))) -(defun denote-grep-exclude-files-with-keywords (keywords) +(defun denote-query-exclude-files-with-keywords (keywords) "Exclude files with KEYWORDS from current query buffer. KEYWORDS should be a list of keywords (without underscore). @@ -5356,26 +5286,96 @@ KEYWORDS should be a list of keywords (without underscore). Interactively, KEYWORDS are read from the minibuffer using `completing-read-multiple', which see." (interactive (denote-grep-keywords-prompt)) - (denote-grep-exclude-files + (denote-query-exclude-files (mapcar (lambda (kw) (concat "_" kw)) keywords))) -(defun denote-grep-only-include-files-with-keywords (keywords) +(defun denote-query-only-include-files-with-keywords (keywords) "Exclude files without KEYWORDS from current query buffer. -See `denote-grep-exclude-files-with-keywords' for details." +See `denote-query-exclude-files-with-keywords' for details." (interactive (denote-grep-keywords-prompt :include)) - (denote-grep-only-include-files + (denote-query-only-include-files (mapcar (lambda (kw) (concat "_" kw)) keywords))) -(defun denote-grep-clear-all-filters () +(defun denote-query-clear-all-filters () "Run last search with the full set of files in the variable `denote-directory'. This effectively gets ride of any interactive filter applied (by the -means of e.g. `denote-grep-exclude-files')." +means of e.g. `denote-query-exclude-files')." (interactive) (denote-make-links-buffer denote-query--last-query) (message "Cleared all filters")) +;;;;;; Additional features for searching file contents + +(defvar denote-grep-history nil + "Minibuffer history of content searches performed by `denote-grep'. +Also see `denote-grep-file-regexp-history'.") + +(defun denote-grep-query-prompt (&optional type) + "Prompt for a grep query in the minibuffer. + +The prompt assumes a search in all files, unless TYPE is non-nil. + +For now, the only recognized value for TYPE is :focused (for a focused +search (a search among matching files), see `denote-query-focus-last-search'). + +TYPE only affects the prompt, not the returned value." + (read-string + (cond ((eq type :focused) + "Search (only files matched last): ") + (t "Search (all Denote files): ")) + nil 'denote-grep-history)) + +(defvar denote-grep-file-regexp-history nil + "Minibuffer history for `denote-grep' commands asking for a file regexp. +Also see `denote-grep-history'.") + +(defun denote-grep-file-regexp-prompt (&optional include) + "Prompt for a file regexp in the minibuffer. + +The prompt assumes the user wants to exclude files, unless INCLUDE is +non-nil." + (read-string + (if (not include) + "Exclude file names matching: " + "Only include file names matching: ") + nil 'denote-grep-file-regexp-history)) + +(defun denote-grep-keywords-prompt (&optional include) + "Prompt for keywords to filter in the minibuffer, with completion. + +Keywords are read using `completing-read-multiple'. + +The prompt assumes the user wants to exclude the keywords, unless +INCLUDE is non-nil. + +Returned value is a list in order to be used in an `interactive' spec." + (list + (delete-dups + (completing-read-multiple + (if (not include) + "Exclude files with keywords: " + "Only include files with keywords: ") + (denote-keywords) nil t nil 'denote-keyword-history)))) + +;;;###autoload +(defun denote-grep (query) + "Search QUERY in the content of Denote files. +QUERY should be a regular expression accepted by `xref-search-program'. + +The files to search for are those returned by `denote-directory-files' +with a non-nil TEXT-ONLY argument. + +Results are put in a buffer which allows folding and further +filtering (see the manual for details). + +You can insert a link to a grep search in any note by using the command +`denote-query-contents-link'." + (interactive (list (denote-grep-query-prompt))) + (let (denote-query--omit-current) + (denote-make-links-buffer query))) + ;;;;;; Backlinks (defun denote--backlinks-get-buffer-name (file id)