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

Make it possible to disable ctrlf-mode locally in buffers #53

Merged
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ The format is based on [Keep a Changelog].
conflict with them. If you remapped the Isearch commands in your
configuration, this means you will need to update
`ctrlf-mode-bindings`. See [#51].
* It is now possible to disable `ctrlf-mode` buffer-locally by means
of `ctrlf-local-mode` ([#52], [#53]).

### Bugs fixed
* CTRLF previously caused an error during Emacs startup unless the
Expand All @@ -40,6 +42,8 @@ The format is based on [Keep a Changelog].
[#49]: https://github.com/raxod502/ctrlf/issues/49
[#50]: https://github.com/raxod502/ctrlf/pull/50
[#51]: https://github.com/raxod502/ctrlf/issues/51
[#52]: https://github.com/raxod502/ctrlf/issues/52
[#53]: https://github.com/raxod502/ctrlf/pull/53

## 1.0 (released 2020-03-31)
### Added
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ for single-buffer text search in Emacs, replacing packages such as
* [Search flow](#search-flow)
* [Customization](#customization)
* [Search styles](#search-styles)
* [Disabling CTRLF locally](#disabling-ctrlf-locally)
* [Miscellaneous](#miscellaneous)
- [Why use CTRLF?](#why-use-ctrlf)
* [Why not Isearch?](#why-not-isearch)
Expand Down Expand Up @@ -232,6 +233,17 @@ following steps:
`ctrlf-forward` and `ctrlf-backward`, respectively, as subroutines.
* Bind these functions in `ctrlf-mode-bindings`.

### Disabling CTRLF locally

`ctrlf-mode` is a globalized minor mode that enables the buffer-local
minor mode `ctrlf-local-mode`. This makes it possible to disable it
when there is a conflict, for example with `pdf-isearch-minor-mode`
from [pdf-tools](https://github.com/politza/pdf-tools):

```elisp
(add-hook 'pdf-isearch-minor-mode-hook (lambda () (ctrlf-local-mode -1)))
```

### Miscellaneous

The minibuffer history for CTRLF is stored in the variable
Expand Down
10 changes: 6 additions & 4 deletions ctrlf.el
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,12 @@ See `ctrlf-mode-bindings'.")

;;;###autoload
(progn
(define-minor-mode ctrlf-mode
(define-minor-mode ctrlf-local-mode
"Minor mode to use CTRLF in place of Isearch.
See `ctrlf-mode-bindings' to customize."
:global t
:keymap ctrlf--keymap
(require 'map)
(when ctrlf-mode
(when ctrlf-local-mode
;; Hack to clear out keymap. Presumably there's a `clear-keymap'
;; function lying around somewhere...?
(setcdr ctrlf--keymap nil)
Expand All @@ -1243,12 +1242,15 @@ See `ctrlf-mode-bindings' to customize."
(define-key ctrlf--keymap key cmd))
ctrlf-mode-bindings))
(with-eval-after-load 'ctrlf
(if ctrlf-mode
(if ctrlf-local-mode
(advice-add #'minibuffer-message :around
#'ctrlf--minibuffer-message-condense)
(advice-remove #'minibuffer-message
#'ctrlf--minibuffer-message-condense)))))

;;;###autoload
(define-globalized-minor-mode ctrlf-mode ctrlf-local-mode ctrlf-local-mode)

;;;; Closing remarks

(provide 'ctrlf)
Expand Down