Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle mark at point #2991

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps:
$(emacs) -batch -l targets/install-deps.el

test:
$(emacs) -batch $(LOAD) -l ivy-test.el -f ert-run-tests-batch-and-exit
$(emacs) -batch $(LOAD) -l ivy-test.el -f ivy-test-run-tests

checkdoc:
$(emacs) -batch -l targets/checkdoc.el
Expand Down
26 changes: 26 additions & 0 deletions ivy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

;;; Code:

(defvar require-features nil)

(defadvice require (before ivy-tests-require-hook (feature &rest _) activate)
"Record the requires into `require-features'."
(push feature require-features))

(require 'ert)
(require 'colir)

Expand All @@ -37,6 +43,14 @@

(message "%s" (emacs-version))

(ert-deftest ivy--lazy-load-ffap--ffap-url-p ()
(should (not (memq 'ffap require-features)))
(should (not (fboundp 'ffap-url-p)))
(should (string= (ivy-ffap-url-p "https://foo.org")
"https://foo.org"))
(should (memq 'ffap require-features))
(should (fboundp 'ffap-url-p)))

(defvar ivy-expr nil
"Holds a test expression to evaluate with `ivy-eval'.")

Expand Down Expand Up @@ -1390,6 +1404,18 @@ a buffer visiting a file."
(ivy--handle-directory "/sudo::"))
"/sudo::/tmp/")))

(defun ivy-test-run-tests ()
(let ((stats1
;; this test must run first as other tests might force a load
(ert-run-tests-batch 'ivy--lazy-load-ffap--ffap-url-p))
(stats2
;; run the rest of the tests
(ert-run-tests-batch '(not ivy--lazy-load-ffap--ffap-url-p))))
(kill-emacs (if (zerop (+ (ert-stats-completed-unexpected stats1)
(ert-stats-completed-unexpected stats2)))
0
1))))

(provide 'ivy-test)

;;; ivy-test.el ends here
27 changes: 27 additions & 0 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -4567,6 +4567,7 @@ buffer would modify `ivy-last'.")
(define-key map (kbd "c") 'ivy-occur-toggle-calling)
(define-key map (kbd "q") 'quit-window)
(define-key map (kbd "R") 'read-only-mode)
(define-key map (kbd "F") 'ivy-occur-flush)
(define-key map (kbd "C-d") 'ivy-occur-delete-candidate)
map)
"Keymap for Ivy Occur mode.")
Expand Down Expand Up @@ -4656,6 +4657,32 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
(delete-region (line-beginning-position)
(1+ (line-end-position)))))

(defun ivy-occur-flush ()
"Delete lines matching a regex.
See `flush-lines'."
(interactive)
(let* ((end (save-excursion
(goto-char (point-min))
(re-search-forward "\\([0-9]+\\) candidates:\n" nil t)))
(beg (match-beginning 0))
(n (string-to-number (match-string 1)))
(cands
(split-string (buffer-substring-no-properties
end
(point-max)) "\n" t " +")))
(ivy-read "Flush: " cands)
(save-excursion
(goto-char (point-max))
(dolist (cand (nreverse (copy-sequence ivy--old-cands)))
(search-backward cand)
(ivy-occur-delete-candidate)
(cl-decf n))
(goto-char beg)
(forward-sexp)
(let ((inhibit-read-only t))
(delete-region beg (point))
(insert (number-to-string n))))))

(define-derived-mode ivy-occur-grep-mode grep-mode "Ivy-Occur"
"Major mode for output from \\[ivy-occur].

Expand Down