Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sp1ff/elfeed-score
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1ff committed Apr 18, 2023
2 parents eac7cd8 + ed97a73 commit 4a04c57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
36 changes: 17 additions & 19 deletions elfeed-score-scoring.el
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ This function is used in `elfeed-new-entry-hook'."
(t
(error "Don't know how to evaluate %S" match))))

(defun elfeed-score-scoring-explain-entry (entry)
"Explain an Elfeed ENTRY.
(defun elfeed-score-scoring-explain-entry (entry buffer)
"Explain an Elfeed ENTRY in BUFFER.
This function will apply all scoring rules to an entry, but will
not change anything (e.g. update ENTRY's meta-data, or the
Expand Down Expand Up @@ -736,9 +736,7 @@ understanding of scoring rules."
:initial-value elfeed-score-scoring-default-score))
(sticky (and elfeed-score-scoring-manual-is-sticky
(elfeed-score-scoring-entry-is-sticky entry))))
(with-current-buffer-window
elfeed-score-scoring-explanation-buffer-name
nil nil
(with-current-buffer buffer
(goto-char (point-max))
(insert
(if sticky
Expand Down Expand Up @@ -777,20 +775,20 @@ to the rules currently in-memory)\n")
(format " %d. %s\n" (1+ idx)
(elfeed-score-scoring--pp-rule-match-to-string match)))))
(cl-loop
for match being the elements of matches using (index idx)
do
(insert
(format " %d. " (1+ idx)))
(insert-text-button
(elfeed-score-scoring--pp-rule-match-to-string match)
'tag (elfeed-score-serde-tag-for-explanation match)
'index (elfeed-score-rules-index-for-explanation match)
'action
(lambda (btn)
(elfeed-score-scoring-visit-rule
(button-get btn 'tag)
(button-get btn 'index))))
(insert "\n"))))))))
for match being the elements of matches using (index idx)
do
(insert
(format " %d. " (1+ idx)))
(insert-text-button
(elfeed-score-scoring--pp-rule-match-to-string match)
'tag (elfeed-score-serde-tag-for-explanation match)
'index (elfeed-score-rules-index-for-explanation match)
'action
(lambda (btn)
(elfeed-score-scoring-visit-rule
(button-get btn 'tag)
(button-get btn 'index))))
(insert "\n"))))))))

(defun elfeed-score-scoring-visit-rule (tag index)
"Visit rule TAG, INDEX in the score file.
Expand Down
6 changes: 4 additions & 2 deletions elfeed-score.el
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ point will be explained. If the region is not active, only the
entry under point will be explained."
(interactive)
(let ((entries (elfeed-search-selected ignore-region)))
(dolist (entry entries)
(elfeed-score-scoring-explain-entry entry))
(with-help-window elfeed-score-scoring-explanation-buffer-name
(with-current-buffer elfeed-score-scoring-explanation-buffer-name
(dolist (entry entries)
(elfeed-score-scoring-explain-entry entry (current-buffer)))))
(elfeed-search-update t)))

(defun elfeed-score-load-score-file (score-file)
Expand Down
2 changes: 1 addition & 1 deletion test/test-explanations.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
(list (elfeed-score-tag-rule--create :tags '(b c d) :value 1)))
(elfeed-score-serde-udf-rules
(list (elfeed-score-udf-rule--create :function (lambda (_) 1)))))
(elfeed-score-scoring-explain-entry entry)
(elfeed-score-scoring-explain-entry entry elfeed-score-scoring-explanation-buffer-name)
(let ((text
(with-current-buffer "*explanation-smoke-tests*"
(buffer-string))))
Expand Down

0 comments on commit 4a04c57

Please sign in to comment.